PartyRankingAllPartiesChartsPageModContentFactoryImpl.java

  1. /*
  2.  * Copyright 2014 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.party.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.Service;

  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.ChartDataManager;
  27. import com.hack23.cia.web.impl.ui.application.views.common.dataseriesfactory.api.PartyDataSeriesFactory;
  28. import com.hack23.cia.web.impl.ui.application.views.common.viewnames.ChartIndicators;
  29. import com.hack23.cia.web.impl.ui.application.views.common.viewnames.PageMode;
  30. import com.hack23.cia.web.impl.ui.application.views.common.viewnames.UserViews;
  31. import com.vaadin.ui.HorizontalLayout;
  32. import com.vaadin.ui.Layout;
  33. import com.vaadin.ui.MenuBar;
  34. import com.vaadin.ui.Panel;
  35. import com.vaadin.ui.VerticalLayout;

  36. /**
  37.  * The Class PartyRankingChartsPageModContentFactoryImpl.
  38.  */
  39. @Service
  40. public final class PartyRankingAllPartiesChartsPageModContentFactoryImpl extends AbstractPartyRankingPageModContentFactoryImpl {

  41.     /** The Constant CHARTS. */
  42.     private static final String CHARTS = "Charts:";

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

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

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

  51.     /**
  52.      * Instantiates a new party ranking all parties charts page mod content
  53.      * factory impl.
  54.      */
  55.     public PartyRankingAllPartiesChartsPageModContentFactoryImpl() {
  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.         final String pageId = getPageId(parameters);


  63.         getPartyRankingMenuItemFactory().createPartyRankingMenuBar(menuBar);
  64.         final HorizontalLayout chartLayout = new HorizontalLayout();
  65.         chartLayout.setSizeFull();

  66.         chartDataManager.createChartPanel(chartLayout,dataSeriesFactory.createPartyChartTimeSeriesAll(),"All");

  67.         panelContent.addComponent(chartLayout);

  68.         panel.setCaption(CHARTS + parameters);

  69.         getPageActionEventHelper().createPageEvent(ViewAction.VISIT_PARTY_RANKING_VIEW, ApplicationEventGroup.USER, NAME,
  70.                 parameters, pageId);

  71.         return panelContent;

  72.     }

  73.     @Override
  74.     public boolean matches(final String page, final String parameters) {
  75.         return NAME.equals(page) && !StringUtils.isEmpty(parameters) && parameters.contains(PageMode.CHARTS.toString())
  76.                 && parameters.contains(ChartIndicators.ALLPARTIES.toString());
  77.     }


  78. }