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.politician.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.hack23.cia.web.impl.ui.application.views.common.viewnames.UserViews;
29  import com.vaadin.ui.Layout;
30  import com.vaadin.ui.MenuBar;
31  import com.vaadin.ui.Panel;
32  import com.vaadin.ui.TextArea;
33  import com.vaadin.ui.VerticalLayout;
34  
35  /**
36   * The Class PoliticianRankingOverviewPageModContentFactoryImpl.
37   */
38  @Component
39  public final class PoliticianRankingOverviewPageModContentFactoryImpl
40  		extends AbstractPoliticianRankingPageModContentFactoryImpl {
41  
42  	/** The Constant NAME. */
43  	public static final String NAME = UserViews.POLITICIAN_RANKING_VIEW_NAME;
44  
45  	/** The Constant OVERVIEW. */
46  	private static final String OVERVIEW = "overview";
47  
48  	/**
49  	 * Instantiates a new politician ranking overview page mod content factory
50  	 * impl.
51  	 */
52  	public PoliticianRankingOverviewPageModContentFactoryImpl() {
53  		super();
54  	}
55  
56  	@Override
57  	public boolean matches(final String page, final String parameters) {
58  		return NAME.equals(page) && (StringUtils.isEmpty(parameters) || parameters.contains(PageMode.OVERVIEW.toString()));
59  	}
60  
61  	@Secured({ "ROLE_ANONYMOUS", "ROLE_USER", "ROLE_ADMIN" })
62  	@Override
63  	public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
64  		final VerticalLayout panelContent = createPanelContent();
65  
66  		getPoliticianRankingMenuItemFactory().createPoliticianRankingMenuBar(menuBar);
67  
68  		final String pageId = getPageId(parameters);
69  
70  		panelContent.addComponent(createDescription());
71  
72  		getPoliticianRankingMenuItemFactory().createOverviewPage(panelContent);
73  
74  		panel.setCaption(OVERVIEW + parameters);
75  
76  		getPageActionEventHelper().createPageEvent(ViewAction.VISIT_POLITICIAN_RANKING_VIEW, ApplicationEventGroup.USER,
77  				NAME, parameters, pageId);
78  
79  		return panelContent;
80  
81  	}
82  
83  	/**
84  	 * Creates the description.
85  	 *
86  	 * @return the text area
87  	 */
88  	private static TextArea createDescription() {
89  		final TextArea totalpoliticantoplistLabel = new TextArea("Politician Ranking by topic",
90  				"Time served in Parliament:ALL:CURRENT:*FILTER:Gender,Party,ElectionRegion"
91  						+ "\nTime served in Committees:ALL:CURRENT:*FILTER:Gender,Party,ElectionRegion"
92  						+ "\nTime served in Government:ALL:CURRENT:*FILTER:Gender,Party,ElectionRegion"
93  						+ "\nTop document author NR:ALL:YEAR:CURRENT:*FILTER:DocumnetType,Gender,Party,ElectionRegion"
94  						+ "\nTop document author SIZE:YEAR:ALL:CURRENT:*FILTER:DocumnetType,Gender,Party,ElectionRegion"
95  
96  						+ "\nTop votes:ALL:YEAR:CURRENT::*FILTER:Gender,Party,ElectionRegion"
97  						+ "\nTop vote winner NR/PERCENTAGE :ALL:YEAR:CURRENT::*FILTER:Gender,Party,ElectionRegion"
98  						+ "\nTop vote party rebel NR/PERCENTAGE :ALL:YEAR:CURRENT::*FILTER:Gender,Party,ElectionRegion"
99  						+ "\nTop vote presence NR/PERCENTAGE :ALL:YEAR:CURRENT::*FILTER:Gender,Party,ElectionRegion"
100 						+ "\nSearch by name");
101 		totalpoliticantoplistLabel.setSizeFull();
102 		totalpoliticantoplistLabel.setStyleName("Level2Header");
103 		return totalpoliticantoplistLabel;
104 	}
105 
106 }