MinistryRankingGovernmentOutcomePageModContentFactoryImpl.java

  1. /*
  2.  * Copyright 2010-2024 James Pether Sörling
  3.  *
  4.  * Licensed under the Apache License, Version 2.0 (the "License");
  5.  * you may not use this file except in compliance with the License.
  6.  * You may obtain a copy of the License at
  7.  *
  8.  *   http://www.apache.org/licenses/LICENSE-2.0
  9.  *
  10.  * Unless required by applicable law or agreed to in writing, software
  11.  * distributed under the License is distributed on an "AS IS" BASIS,
  12.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13.  * See the License for the specific language governing permissions and
  14.  * limitations under the License.
  15.  *
  16.  *  $Id$
  17.  *  $HeadURL$
  18. */
  19. package com.hack23.cia.web.impl.ui.application.views.user.goverment.pagemode;

  20. import org.apache.commons.lang3.StringUtils;
  21. import org.springframework.beans.factory.annotation.Autowired;
  22. import org.springframework.security.access.annotation.Secured;
  23. import org.springframework.stereotype.Component;

  24. import com.hack23.cia.model.internal.application.system.impl.ApplicationEventGroup;
  25. import com.hack23.cia.web.impl.ui.application.action.ViewAction;
  26. import com.hack23.cia.web.impl.ui.application.views.common.chartfactory.api.GovernmentOutcomeChartDataManager;
  27. import com.hack23.cia.web.impl.ui.application.views.common.viewnames.MinistryPageMode;
  28. import com.vaadin.ui.Layout;
  29. import com.vaadin.ui.MenuBar;
  30. import com.vaadin.ui.Panel;
  31. import com.vaadin.ui.VerticalLayout;

  32. /**
  33.  * The Class MinistryRankingGovernmentOutcomePageModContentFactoryImpl.
  34.  */
  35. @Component
  36. public final class MinistryRankingGovernmentOutcomePageModContentFactoryImpl extends AbstractMinistryRankingPageModContentFactoryImpl {

  37.     @Autowired
  38.     private GovernmentOutcomeChartDataManager governmentOutcomeChartDataManager;

  39.     /**
  40.      * Instantiates a new ministry ranking government outcome page mod content
  41.      * factory impl.
  42.      */
  43.     public MinistryRankingGovernmentOutcomePageModContentFactoryImpl() {
  44.         super();
  45.     }

  46.     @Secured({ "ROLE_ANONYMOUS", "ROLE_USER", "ROLE_ADMIN" })
  47.     @Override
  48.     public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
  49.         final VerticalLayout panelContent = createPanelContent();

  50.         getMinistryRankingMenuItemFactory().createMinistryRankingMenuBar(menuBar);
  51.         createPageHeader(panel, panelContent,
  52.                 "Ministry Ranking - Government Outcomes",
  53.                 "Evaluating Results",
  54.                 "Evaluating ministry influence on governance results.");


  55.         final String pageId = getPageId(parameters);

  56.         governmentOutcomeChartDataManager.createGovernmentOutcomeChart(panelContent);

  57.         getPageActionEventHelper().createPageEvent(ViewAction.VISIT_MINISTRY_RANKING_VIEW, ApplicationEventGroup.USER, NAME,
  58.                 parameters, pageId);

  59.         return panelContent;

  60.     }

  61.     @Override
  62.     public boolean matches(final String page, final String parameters) {
  63.         return NAME.equals(page) && StringUtils.contains(parameters, MinistryPageMode.GOVERNMENT_OUTCOME.toString());
  64.     }

  65. }