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

  37. /**
  38.  * The Class CommitteeRankingCommitteeByPart    yChartsPageModContentFactoryImpl.
  39.  */
  40. @Service
  41. public final class CommitteeRankingCommitteeByPartyChartsPageModContentFactoryImpl
  42.         extends AbstractCommitteeRankingPageModContentFactoryImpl {

  43.     /** The Constant ALL_PARTIES_TOTAL_DAYS_SERVED. */
  44.     private static final String ALL_PARTIES_TOTAL_DAYS_SERVED = "All Parties, total days served";

  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. */
  51.     @Autowired
  52.     private CommitteeDataSeriesFactory dataSeriesFactory;

  53.     /**
  54.      * Instantiates a new committee ranking committee by party charts page mod
  55.      * content factory impl.
  56.      */
  57.     public CommitteeRankingCommitteeByPartyChartsPageModContentFactoryImpl() {
  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_PARTY_TITLE_HEADER,
  67.             CommitteeViewConstants.CR_PARTY_TITLE,
  68.             CommitteeViewConstants.CR_PARTY_DESCRIPTION);

  69.         final String pageId = getPageId(parameters);

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

  72.         chartDataManager.createChartPanel(chartLayout,
  73.                 dataSeriesFactory.createChartTimeSeriesTotalDaysServedCommitteeByParty(),
  74.                 ALL_PARTIES_TOTAL_DAYS_SERVED);

  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_ALL_PARTIES.matches(page, parameters);
  84.     }

  85. }