CommitteeRankingAllCommitteesChartsPageModContentFactoryImpl.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 CommitteeRankingAllCommitteesChartsPageModContentFactoryImpl.
  39.  */
  40. @Service
  41. public final class CommitteeRankingAllCommitteesChartsPageModContentFactoryImpl
  42.         extends AbstractCommitteeRankingPageModContentFactoryImpl {

  43.     /** The Constant NAME. */
  44.     public static final String NAME = UserViews.COMMITTEE_RANKING_VIEW_NAME;

  45.     /** The chart data manager. */
  46.     @Autowired
  47.     private ChartDataManager chartDataManager;

  48.     /** The data series factory. */
  49.     @Autowired
  50.     private CommitteeDataSeriesFactory dataSeriesFactory;

  51.     /**
  52.      * Instantiates a new committee ranking all committees charts page mod
  53.      * content factory impl.
  54.      */
  55.     public CommitteeRankingAllCommitteesChartsPageModContentFactoryImpl() {
  56.         super();
  57.     }

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

  62.         getCommitteeRankingMenuItemFactory().createCommitteeeRankingMenuBar(menuBar);

  63.         final String pageId = getPageId(parameters);

  64.         CardInfoRowUtil.createPageHeader(panel, panelContent,
  65.             CommitteeViewConstants.CR_ALL_TITLE_HEADER,
  66.             CommitteeViewConstants.CR_ALL_TITLE,
  67.             CommitteeViewConstants.CR_ALL_DESCRIPTION);

  68.         final HorizontalLayout chartLayout = new HorizontalLayout();
  69.         chartLayout.setSizeFull();

  70.         chartDataManager.createChartPanel(chartLayout, dataSeriesFactory.createCommitteeChartTimeSeriesAll(), "All");

  71.         panelContent.addComponent(chartLayout);
  72.         panelContent.setExpandRatio(chartLayout,ContentRatio.LARGE_FORM);

  73.         getPageActionEventHelper().createPageEvent(ViewAction.VISIT_COMMITTEE_RANKING_VIEW, ApplicationEventGroup.USER,
  74.                 NAME, parameters, pageId);

  75.         return panelContent;

  76.     }

  77.     @Override
  78.     public boolean matches(final String page, final String parameters) {
  79.         return PageCommandCommitteeRankingConstants.COMMAND_ALL_COMMITTEES_BY_HEADCOUNT.matches(page, parameters);
  80.     }

  81. }