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.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 CommitteeRankingOverviewPageModContentFactoryImpl.
37   */
38  @Component
39  public final class CommitteeRankingOverviewPageModContentFactoryImpl extends AbstractCommitteeRankingPageModContentFactoryImpl {
40  
41  	/** The Constant NAME. */
42  	public static final String NAME = UserViews.COMMITTEE_RANKING_VIEW_NAME;
43  
44  	/** The Constant OVERVIEW. */
45  	private static final String OVERVIEW = "overview";
46  
47  	/** The Constant COMMITTEE_RANKING_BY_TOPIC. */
48  	private static final String COMMITTEE_RANKING_BY_TOPIC = "Committee Ranking by topic";
49  
50  	/** The Constant COMMITTEE_RANKING_BY_TOPIC_DESCRIPTION. */
51  	private static final String COMMITTEE_RANKING_BY_TOPIC_DESCRIPTION = "Time served in Committee:ALL:CURRENT:" + "\nPoliticans served in Committee:ALL:CURRENT:"
52  			+ "\nTop document author NR:ALL:YEAR:CURRENT:*FILTER:DocumnetType"
53  			+ "\nTop document author SIZE:YEAR:ALL:CURRENT:*FILTER:DocumnetType"
54  
55  			+ "\nTop decisions NR/PERCENTAGE :ALL:YEAR:CURRENT::#Views:List,Timeline,BarChart,PieChart"
56  			+ "\nTop Votes NR/PERCENTAGE :ALL:YEAR:CURRENT::#Views:List,Timeline,BarChart,PieChart"
57  
58  			+ "\nTop vote winner NR/PERCENTAGE :ALL:YEAR:CURRENT::#Views:List,Timeline,BarChart,PieChart"
59  			+ "\nSearch by name";
60  
61  
62  	/**
63  	 * Instantiates a new committee ranking overview page mod content factory
64  	 * impl.
65  	 */
66  	public CommitteeRankingOverviewPageModContentFactoryImpl() {
67  		super();
68  	}
69  
70  	@Override
71  	public boolean matches(final String page, final String parameters) {
72  		return NAME.equals(page) && (StringUtils.isEmpty(parameters) || parameters.contains(PageMode.OVERVIEW.toString()));
73  	}
74  
75  	@Secured({ "ROLE_ANONYMOUS", "ROLE_USER", "ROLE_ADMIN" })
76  	@Override
77  	public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
78  		final VerticalLayout panelContent = createPanelContent();
79  
80  		getCommitteeRankingMenuItemFactory().createCommitteeeRankingMenuBar(menuBar);
81  
82  		final String pageId = getPageId(parameters);
83  
84  		panelContent.addComponent(createDescription());
85  
86  		getCommitteeRankingMenuItemFactory().createOverviewPage(panelContent);
87  
88  		panel.setCaption(OVERVIEW + parameters);
89  
90  		getPageActionEventHelper().createPageEvent(ViewAction.VISIT_COMMITTEE_RANKING_VIEW, ApplicationEventGroup.USER, NAME,
91  				parameters, pageId);
92  
93  		return panelContent;
94  
95  	}
96  
97  
98  	/**
99  	 * Creates the description.
100 	 *
101 	 * @return the text area
102 	 */
103 	private static TextArea createDescription() {
104 		final TextArea totalCommitteeRankinglistLabel = new TextArea(COMMITTEE_RANKING_BY_TOPIC,
105 				COMMITTEE_RANKING_BY_TOPIC_DESCRIPTION);
106 		totalCommitteeRankinglistLabel.setSizeFull();
107 		totalCommitteeRankinglistLabel.setStyleName("Level2Header");
108 		return totalCommitteeRankinglistLabel;
109 	}
110 
111 
112 }