CommitteeRankingCurrentCommitteePartiesChartsPageModContentFactoryImpl.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.committeeranking.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.PageCommandCommitteeRankingConstants;
  28. import com.hack23.cia.web.impl.ui.application.views.common.pagemode.CardInfoRowUtil;
  29. import com.hack23.cia.web.impl.ui.application.views.common.pagemode.CommonViewConstants;
  30. import com.hack23.cia.web.impl.ui.application.views.common.sizing.ContentRatio;
  31. import com.hack23.cia.web.impl.ui.application.views.common.viewnames.UserViews;
  32. import com.hack23.cia.web.impl.ui.application.views.user.committee.pagemode.CommitteeViewConstants;
  33. import com.vaadin.ui.HorizontalLayout;
  34. import com.vaadin.ui.Layout;
  35. import com.vaadin.ui.MenuBar;
  36. import com.vaadin.ui.Panel;
  37. import com.vaadin.ui.VerticalLayout;

  38. /**
  39.  * The Class
  40.  * CommitteeRankingCurrentCommitteePartiesChartsPageModContentFactoryImpl.
  41.  */
  42. @Service
  43. public final class CommitteeRankingCurrentCommitteePartiesChartsPageModContentFactoryImpl
  44.         extends AbstractCommitteeRankingPageModContentFactoryImpl {

  45.     /** The Constant NAME. */
  46.     public static final String NAME = UserViews.COMMITTEE_RANKING_VIEW_NAME;

  47.     /** The chart data manager. */
  48.     @Autowired
  49.     private ChartDataManager chartDataManager;

  50.     /** The data series factory 2. */
  51.     @Autowired
  52.     private PartyDataSeriesFactory dataSeriesFactory2;

  53.     /**
  54.      * Instantiates a new committee ranking current committee parties charts
  55.      * page mod content factory impl.
  56.      */
  57.     public CommitteeRankingCurrentCommitteePartiesChartsPageModContentFactoryImpl() {
  58.         super();
  59.     }

  60.     @Secured({ "ROLE_ANONYMOUS", "ROLE_USER", "ROLE_ADMIN" })
  61.     @Override
  62.     public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
  63.         final VerticalLayout panelContent = createPanelContent();

  64.         getCommitteeRankingMenuItemFactory().createCommitteeeRankingMenuBar(menuBar);
  65.         CardInfoRowUtil.createPageHeader(panel, panelContent,
  66.             CommitteeViewConstants.CR_CURRENT_PARTY_TITLE_HEADER,
  67.             CommitteeViewConstants.CR_CURRENT_PARTY_TITLE,
  68.             CommitteeViewConstants.CR_CURRENT_PARTY_DESCRIPTION);

  69.         final String pageId = getPageId(parameters);

  70.         final HorizontalLayout chartLayout = new HorizontalLayout();
  71.         chartLayout.setSizeFull();

  72.         chartDataManager.createChartPanel(chartLayout,
  73.                 dataSeriesFactory2.createChartTimeSeriesCurrentCommitteeByParty(),
  74.                 CommonViewConstants.CHART_CURRENT_PARTIES);

  75.         panelContent.addComponent(chartLayout);
  76.         panelContent.setExpandRatio(chartLayout,ContentRatio.LARGE_FORM);

  77.         getPageActionEventHelper().createPageEvent(ViewAction.VISIT_COMMITTEE_RANKING_VIEW, ApplicationEventGroup.USER,
  78.                 NAME, parameters, pageId);

  79.         return panelContent;

  80.     }

  81.     @Override
  82.     public boolean matches(final String page, final String parameters) {
  83.         return PageCommandCommitteeRankingConstants.COMMAND_CURRENT_COMMITTEES_BY_PARTY_DAYS_SERVED.matches(page, parameters);
  84.     }

  85. }