PoliticianRankingChartsAllPartiesPageModContentFactoryImpl.java

  1. /*
  2.  * Copyright 2010-2025 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.politicianranking.pagemode;

  20. import org.springframework.beans.factory.annotation.Autowired;
  21. import org.springframework.security.access.annotation.Secured;
  22. import org.springframework.stereotype.Service;

  23. import com.hack23.cia.model.internal.application.system.impl.ApplicationEventGroup;
  24. import com.hack23.cia.web.impl.ui.application.action.ViewAction;
  25. import com.hack23.cia.web.impl.ui.application.views.common.chartfactory.api.ChartDataManager;
  26. import com.hack23.cia.web.impl.ui.application.views.common.dataseriesfactory.api.PartyDataSeriesFactory;
  27. import com.hack23.cia.web.impl.ui.application.views.common.menufactory.api.pagecommands.PageCommandPoliticianRankingConstants;
  28. import com.hack23.cia.web.impl.ui.application.views.common.pagemode.CardInfoRowUtil;
  29. import com.hack23.cia.web.impl.ui.application.views.common.viewnames.UserViews;
  30. import com.vaadin.ui.Layout;
  31. import com.vaadin.ui.MenuBar;
  32. import com.vaadin.ui.Panel;
  33. import com.vaadin.ui.VerticalLayout;

  34. /**
  35.  * The Class PoliticianRankingChartsAllPartiesPageModContentFactoryImpl.
  36.  */
  37. @Service
  38. public final class PoliticianRankingChartsAllPartiesPageModContentFactoryImpl
  39.         extends AbstractPoliticianRankingPageModContentFactoryImpl {

  40.     /** The Constant NAME. */
  41.     public static final String NAME = UserViews.POLITICIAN_RANKING_VIEW_NAME;

  42.     /** The chart data manager. */
  43.     @Autowired
  44.     private ChartDataManager chartDataManager;

  45.     /** The data series factory. */
  46.     @Autowired
  47.     private PartyDataSeriesFactory dataSeriesFactory;

  48.     /**
  49.      * Instantiates a new politician ranking charts all parties page mod content
  50.      * factory impl.
  51.      */
  52.     public PoliticianRankingChartsAllPartiesPageModContentFactoryImpl() {
  53.         super();
  54.     }

  55.     @Secured({ "ROLE_ANONYMOUS", "ROLE_USER", "ROLE_ADMIN" })
  56.     @Override
  57.     public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
  58.         final VerticalLayout panelContent = createPanelContent();

  59.         final String pageId = getPageId(parameters);

  60.         getPoliticianRankingMenuItemFactory().createPoliticianRankingMenuBar(menuBar);
  61.         CardInfoRowUtil.createPageHeader(panel, panelContent,
  62.                 PoliticianRankingDescriptionConstants.ALL_PARTIES_HEADER,
  63.                 PoliticianRankingDescriptionConstants.ALL_PARTIES_SUBTITLE,
  64.                 PoliticianRankingDescriptionConstants.ALL_PARTIES_DESC);

  65.         chartDataManager.createChartPanel(panelContent,
  66.             dataSeriesFactory.createPartyChartTimeSeriesAll(),
  67.             PoliticianRankingConstants.CHART_TYPE_ALL);

  68.         getPageActionEventHelper().createPageEvent(ViewAction.VISIT_POLITICIAN_RANKING_VIEW, ApplicationEventGroup.USER,
  69.                 NAME, parameters, pageId);

  70.         return panelContent;

  71.     }

  72.     @Override
  73.     public boolean matches(final String page, final String parameters) {
  74.         return PageCommandPoliticianRankingConstants.POL_RANK_COMMAND_CHARTS_ALL_PARTIES_BY_HEADCOUNT.matches(page, parameters);
  75.     }

  76. }