View Javadoc
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.committee.pagemode;
20  
21  import org.apache.commons.lang3.StringUtils;
22  import org.springframework.beans.factory.annotation.Autowired;
23  import org.springframework.security.access.annotation.Secured;
24  import org.springframework.stereotype.Service;
25  
26  import com.hack23.cia.model.internal.application.system.impl.ApplicationEventGroup;
27  import com.hack23.cia.web.impl.ui.application.action.ViewAction;
28  import com.hack23.cia.web.impl.ui.application.views.common.chartfactory.api.ChartDataManager;
29  import com.hack23.cia.web.impl.ui.application.views.common.dataseriesfactory.api.PartyDataSeriesFactory;
30  import com.hack23.cia.web.impl.ui.application.views.common.viewnames.ChartIndicators;
31  import com.hack23.cia.web.impl.ui.application.views.common.viewnames.PageMode;
32  import com.hack23.cia.web.impl.ui.application.views.common.viewnames.UserViews;
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  /**
40   * The Class
41   * CommitteeRankingCurrentCommitteePartiesChartsPageModContentFactoryImpl.
42   */
43  @Service
44  public final class CommitteeRankingCurrentCommitteePartiesChartsPageModContentFactoryImpl
45  		extends AbstractCommitteeRankingPageModContentFactoryImpl {
46  
47  	/** The Constant NAME. */
48  	public static final String NAME = UserViews.COMMITTEE_RANKING_VIEW_NAME;
49  
50  	/** The Constant CHARTS. */
51  	private static final String CHARTS = "Charts:";
52  
53  	/** The Constant CURRENT_PARTIES_HEADCOUNT. */
54  	private static final String CURRENT_PARTIES_HEADCOUNT = "Current Parties, headcount";
55  
56  	/** The chart data manager. */
57  	@Autowired
58  	private ChartDataManager chartDataManager;
59  
60  	/** The data series factory 2. */
61  	@Autowired
62  	private PartyDataSeriesFactory dataSeriesFactory2;
63  
64  	/**
65  	 * Instantiates a new committee ranking current committee parties charts
66  	 * page mod content factory impl.
67  	 */
68  	public CommitteeRankingCurrentCommitteePartiesChartsPageModContentFactoryImpl() {
69  		super();
70  	}
71  
72  	@Override
73  	public boolean matches(final String page, final String parameters) {
74  		return NAME.equals(page) && !StringUtils.isEmpty(parameters) && parameters.contains(PageMode.CHARTS.toString())
75  				&& parameters.contains(ChartIndicators.CURRENTCOMMITTEESBYPARTYHEADCOUNT.toString());
76  	}
77  
78  	@Secured({ "ROLE_ANONYMOUS", "ROLE_USER", "ROLE_ADMIN" })
79  	@Override
80  	public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
81  		final VerticalLayout panelContent = createPanelContent();
82  
83  		getCommitteeRankingMenuItemFactory().createCommitteeeRankingMenuBar(menuBar);
84  
85  		final String pageId = getPageId(parameters);
86  
87  		final HorizontalLayout chartLayout = new HorizontalLayout();
88  		chartLayout.setSizeFull();
89  
90  		chartDataManager.createChartPanel(chartLayout,
91  				dataSeriesFactory2.createChartTimeSeriesCurrentCommitteeByParty(), CURRENT_PARTIES_HEADCOUNT);
92  
93  		panelContent.addComponent(chartLayout);
94  
95  		panel.setCaption(CHARTS + parameters);
96  
97  		getPageActionEventHelper().createPageEvent(ViewAction.VISIT_COMMITTEE_RANKING_VIEW, ApplicationEventGroup.USER,
98  				NAME, parameters, pageId);
99  
100 		return panelContent;
101 
102 	}
103 
104 }