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.goverment.pagemode;
20  
21  import org.apache.commons.lang3.StringUtils;
22  import org.springframework.security.access.annotation.Secured;
23  import org.springframework.stereotype.Component;
24  
25  import com.hack23.cia.model.internal.application.system.impl.ApplicationEventGroup;
26  import com.hack23.cia.web.impl.ui.application.action.ViewAction;
27  import com.hack23.cia.web.impl.ui.application.views.common.viewnames.PageMode;
28  import com.vaadin.ui.Layout;
29  import com.vaadin.ui.MenuBar;
30  import com.vaadin.ui.Panel;
31  import com.vaadin.ui.TextArea;
32  import com.vaadin.ui.VerticalLayout;
33  
34  /**
35   * The Class MinistryRankingOverviewPageModContentFactoryImpl.
36   */
37  @Component
38  public final class MinistryRankingOverviewPageModContentFactoryImpl extends AbstractMinistryRankingPageModContentFactoryImpl {
39  
40  	/** The Constant OVERVIEW. */
41  	private static final String OVERVIEW = "overview";
42  
43  	/** The Constant MINISTRY_RANKING_BY_TOPIC. */
44  	private static final String MINISTRY_RANKING_BY_TOPIC = "Ministry Ranking by topic";
45  
46  	/** The Constant MINISTRY_RANKING_BY_TOPIC_DESCRIPTION. */
47  	private static final String MINISTRY_RANKING_BY_TOPIC_DESCRIPTION = "Time served in Ministry:ALL:CURRENT:"
48  			+ "\nPoliticans served in Committee:ALL:CURRENT:"
49  			+ "\nTop document author NR:ALL:YEAR:CURRENT:*FILTER:DocumnetType"
50  			+ "\nTop document author SIZE:YEAR:ALL:CURRENT:*FILTER:DocumnetType"
51  
52  			+ "\nTop decisions NR/PERCENTAGE :ALL:YEAR:CURRENT::#Views:List,Timeline,BarChart,PieChart"
53  			+ "\nTop Votes NR/PERCENTAGE :ALL:YEAR:CURRENT::#Views:List,Timeline,BarChart,PieChart"
54  
55  			+ "\nTop vote winner NR/PERCENTAGE :ALL:YEAR:CURRENT::#Views:List,Timeline,BarChart,PieChart"
56  			+ "\nSearch by name";
57  
58  
59  	/**
60  	 * Instantiates a new ministry ranking overview page mod content factory
61  	 * impl.
62  	 */
63  	public MinistryRankingOverviewPageModContentFactoryImpl() {
64  		super();
65  	}
66  
67  	@Override
68  	public boolean matches(final String page, final String parameters) {
69  		return NAME.equals(page) && (StringUtils.isEmpty(parameters) || parameters.contains(PageMode.OVERVIEW.toString()));
70  	}
71  
72  	@Secured({ "ROLE_ANONYMOUS", "ROLE_USER", "ROLE_ADMIN" })
73  	@Override
74  	public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
75  		final VerticalLayout panelContent = createPanelContent();
76  
77  		getMinistryRankingMenuItemFactory().createMinistryRankingMenuBar(menuBar);
78  
79  		final String pageId = getPageId(parameters);
80  
81  		panelContent.addComponent(createDescription());
82  
83  		getMinistryRankingMenuItemFactory().createOverviewPage(panelContent);
84  
85  		panel.setCaption(OVERVIEW + parameters);
86  
87  		getPageActionEventHelper().createPageEvent(ViewAction.VISIT_MINISTRY_RANKING_VIEW, ApplicationEventGroup.USER, NAME,
88  				parameters, pageId);
89  
90  		return panelContent;
91  
92  	}
93  
94  
95  	/**
96  	 * Creates the description.
97  	 *
98  	 * @return the text area
99  	 */
100 	private static TextArea createDescription() {
101 		final TextArea totalCommitteeRankinglistLabel = new TextArea(MINISTRY_RANKING_BY_TOPIC,
102 				MINISTRY_RANKING_BY_TOPIC_DESCRIPTION);
103 		totalCommitteeRankinglistLabel.setSizeFull();
104 		totalCommitteeRankinglistLabel.setStyleName("Level2Header");
105 		return totalCommitteeRankinglistLabel;
106 	}
107 
108 
109 }