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.common.menufactory.impl;
20  
21  import org.springframework.beans.factory.annotation.Autowired;
22  import org.springframework.stereotype.Service;
23  
24  import com.hack23.cia.web.impl.ui.application.views.common.menufactory.api.ApplicationMenuItemFactory;
25  import com.hack23.cia.web.impl.ui.application.views.common.menufactory.api.MinistryRankingMenuItemFactory;
26  import com.hack23.cia.web.impl.ui.application.views.common.pagelinks.api.PageModeMenuCommand;
27  import com.hack23.cia.web.impl.ui.application.views.common.viewnames.ChartIndicators;
28  import com.hack23.cia.web.impl.ui.application.views.common.viewnames.MinistryPageMode;
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.server.FontAwesome;
32  import com.vaadin.ui.GridLayout;
33  import com.vaadin.ui.MenuBar;
34  import com.vaadin.ui.MenuBar.MenuItem;
35  import com.vaadin.ui.VerticalLayout;
36  
37  /**
38   * The Class MinistryRankingMenuItemFactoryImpl.
39   */
40  @Service
41  public final class MinistryRankingMenuItemFactoryImpl extends AbstractMenuItemFactoryImpl
42  		implements MinistryRankingMenuItemFactory {
43  
44  	/** The Constant GOVERNMENT_ROLES_CHART. */
45  	private static final String GOVERNMENT_ROLES_CHART = "Government roles chart";
46  
47  	/** The Constant COMMAND_PAGEVISITHISTORY. */
48  	private static final PageModeMenuCommand COMMAND_PAGEVISITHISTORY = new PageModeMenuCommand(UserViews.MINISTRY_RANKING_VIEW_NAME,
49  			PageMode.PAGEVISITHISTORY);
50  
51  	/** The Constant COMMAND_CHARTS_ALL_MINISTRIES_BY_HEADCOUNT. */
52  	private static final PageModeMenuCommand COMMAND_CHARTS_ALL_MINISTRIES_BY_HEADCOUNT = new PageModeMenuCommand(UserViews.MINISTRY_RANKING_VIEW_NAME,
53  			PageMode.CHARTS, ChartIndicators.ALLMINISTRIESBYHEADCOUNT.toString());
54  
55  	/** The Constant COMMAND_CHARTS_ALLMINISTRIES_BY_TOTAL_DAYS. */
56  	private static final PageModeMenuCommand COMMAND_CHARTS_ALLMINISTRIES_BY_TOTAL_DAYS = new PageModeMenuCommand(UserViews.MINISTRY_RANKING_VIEW_NAME,
57  			PageMode.CHARTS, ChartIndicators.ALLMINISTRIESPARTYBYTOTALDAYS.toString());
58  
59  	/** The Constant COMMAND_CHARTS_CURRENT_MINISTRIES_BY_HEADCOUNT. */
60  	private static final PageModeMenuCommand COMMAND_CHARTS_CURRENT_MINISTRIES_BY_HEADCOUNT = new PageModeMenuCommand(UserViews.MINISTRY_RANKING_VIEW_NAME,
61  			PageMode.CHARTS, ChartIndicators.CURRENTMINISTRIESBYHEADCOUNT.toString());
62  
63  	/** The Constant COMMAND_CHARTS_CURRENT_PARTIES_BY_HEADCOUNT. */
64  	private static final PageModeMenuCommand COMMAND_CHARTS_CURRENT_PARTIES_BY_HEADCOUNT = new PageModeMenuCommand(UserViews.MINISTRY_RANKING_VIEW_NAME,
65  			PageMode.CHARTS, ChartIndicators.CURRENTPARTIESBYHEADCOUNT.toString());
66  
67  	/** The Constant COMMAND_CHARTS_ALL_GOVERNMENT_ROLE_GANTT. */
68  	private static final PageModeMenuCommand COMMAND_CHARTS_ALL_GOVERNMENT_ROLE_GANTT = new PageModeMenuCommand(UserViews.MINISTRY_RANKING_VIEW_NAME,
69  			PageMode.CHARTS, ChartIndicators.ALL_GOVERNMENT_ROLE_CHART.toString());
70  
71  	/** The Constant COMMAND_DATAGRID. */
72  	private static final PageModeMenuCommand COMMAND_DATAGRID = new PageModeMenuCommand(UserViews.MINISTRY_RANKING_VIEW_NAME,
73  			PageMode.DATAGRID);
74  
75  	/** The Constant COMMAN_OVERVIEW. */
76  	private static final PageModeMenuCommand COMMAN_OVERVIEW = new PageModeMenuCommand(UserViews.MINISTRY_RANKING_VIEW_NAME,
77  			PageMode.OVERVIEW);
78  
79  	/** The Constant COMMAND_GOVERNMENT_BODIES. */
80  	private static final PageModeMenuCommand COMMAND_GOVERNMENT_BODIES = new PageModeMenuCommand(UserViews.MINISTRY_RANKING_VIEW_NAME,
81  			MinistryPageMode.GOVERNMENT_BODIES.toString());
82  
83  	/** The Constant GOVERNMENT_BODIES. */
84  	private static final String GOVERNMENT_BODIES = "Government bodies";
85  
86  	/** The Constant MINISTRY_RANKING. */
87  	private static final String MINISTRY_RANKING = "Ministry Ranking";
88  
89  	/** The Constant ALL_MINISTRIES_TOTAL_MEMBERS_TEXT. */
90  	private static final String ALL_MINISTRIES_TOTAL_MEMBERS_TEXT = "All ministries, total members";
91  
92  	/** The Constant ALL_PARTIES_TOTAL_DAYS_SERVED_IN_MINISTRIES_TEXT. */
93  	private static final String ALL_PARTIES_TOTAL_DAYS_SERVED_IN_MINISTRIES_TEXT = "All parties, total days served in ministries";
94  
95  	/** The Constant CURRENT_PARTIES_ACTIVE_IN_MINISTRIES_HEAD_COUNT_TEXT. */
96  	private static final String CURRENT_PARTIES_ACTIVE_IN_MINISTRIES_HEAD_COUNT_TEXT = "Current parties active in ministries, head count";
97  
98  	/** The Constant CURRENT_MINISTRIES_CURRENT_MEMBERS_TEXT. */
99  	private static final String CURRENT_MINISTRIES_CURRENT_MEMBERS_TEXT = "Current ministries, current members";
100 
101 	/**
102 	 * The Constant
103 	 * CURRENT_AND_PAST_MEMBER_AND_SUMMARY_OF_TOTAL_POLTICIAL_DAYS_MEMBERSHIP_DESCRIPTION.
104 	 */
105 	private static final String CURRENT_AND_PAST_MEMBER_AND_SUMMARY_OF_TOTAL_POLTICIAL_DAYS_MEMBERSHIP_DESCRIPTION = "Current and past member and summary of total polticial days membership";
106 
107 	/** The Constant POLITICAL_WORK_SUMMARY_TEXT. */
108 	private static final String POLITICAL_WORK_SUMMARY_TEXT = "Political Work Summary";
109 
110 	/** The Constant RANKING_LIST_BY_TOPIC_TEXT. */
111 	private static final String RANKING_LIST_BY_TOPIC_TEXT = "Ranking list by topic";
112 
113 	/** The Constant CHART_BY_TOPIC_TEXT. */
114 	private static final String CHART_BY_TOPIC_TEXT = "Chart by topic";
115 
116 	/** The Constant OVERVIEW_TEXT. */
117 	private static final String OVERVIEW_TEXT = "Overview";
118 
119 	/** The Constant PAGE_VISIT_HISTORY_TEXT. */
120 	private static final String PAGE_VISIT_HISTORY_TEXT = "Page Visit History";
121 
122 	/** The application menu item factory. */
123 	@Autowired
124 	private ApplicationMenuItemFactory applicationMenuItemFactory;
125 
126 	/**
127 	 * Instantiates a new ministry ranking menu item factory impl.
128 	 */
129 	public MinistryRankingMenuItemFactoryImpl() {
130 		super();
131 	}
132 
133 	@Override
134 	public void createMinistryRankingMenuBar(final MenuBar menuBar) {
135 		initApplicationMenuBar(menuBar);
136 
137 		applicationMenuItemFactory.addRankingMenu(menuBar);
138 
139 		createMinistryRankingTopics(menuBar.addItem(MINISTRY_RANKING, null, null));
140 
141 	}
142 
143 	@Override
144 	public void createMinistryRankingTopics(final MenuItem ministryMenuItem) {
145 
146 		ministryMenuItem.addItem(OVERVIEW_TEXT, FontAwesome.GROUP, COMMAN_OVERVIEW);
147 
148 		final MenuItem listByTopic = ministryMenuItem.addItem(RANKING_LIST_BY_TOPIC_TEXT, FontAwesome.GROUP, null);
149 
150 		final MenuItem listItem = listByTopic.addItem(POLITICAL_WORK_SUMMARY_TEXT, FontAwesome.GROUP, COMMAND_DATAGRID);
151 		listItem.setDescription(CURRENT_AND_PAST_MEMBER_AND_SUMMARY_OF_TOTAL_POLTICIAL_DAYS_MEMBERSHIP_DESCRIPTION);
152 
153 		final MenuItem chartByTopic = ministryMenuItem.addItem(CHART_BY_TOPIC_TEXT, FontAwesome.GROUP, null);
154 
155 		chartByTopic.addItem(CURRENT_MINISTRIES_CURRENT_MEMBERS_TEXT, FontAwesome.GROUP, COMMAND_CHARTS_CURRENT_MINISTRIES_BY_HEADCOUNT);
156 		chartByTopic.addItem(CURRENT_PARTIES_ACTIVE_IN_MINISTRIES_HEAD_COUNT_TEXT, FontAwesome.GROUP, COMMAND_CHARTS_CURRENT_PARTIES_BY_HEADCOUNT);
157 
158 		chartByTopic.addItem(ALL_PARTIES_TOTAL_DAYS_SERVED_IN_MINISTRIES_TEXT, FontAwesome.GROUP, COMMAND_CHARTS_ALLMINISTRIES_BY_TOTAL_DAYS);
159 		chartByTopic.addItem(ALL_MINISTRIES_TOTAL_MEMBERS_TEXT, FontAwesome.GROUP, COMMAND_CHARTS_ALL_MINISTRIES_BY_HEADCOUNT);
160 
161 		chartByTopic.addItem(GOVERNMENT_BODIES, FontAwesome.GROUP, COMMAND_GOVERNMENT_BODIES);
162 
163 		chartByTopic.addItem(GOVERNMENT_ROLES_CHART, FontAwesome.GROUP, COMMAND_CHARTS_ALL_GOVERNMENT_ROLE_GANTT);
164 
165 		ministryMenuItem.addItem(PAGE_VISIT_HISTORY_TEXT, FontAwesome.GROUP, COMMAND_PAGEVISITHISTORY);
166 
167 	}
168 
169 	@Override
170 	public void createOverviewPage(final VerticalLayout panelContent) {
171 		final GridLayout grid = createGridLayout(panelContent);
172 
173 		createButtonLink(grid, POLITICAL_WORK_SUMMARY_TEXT, FontAwesome.GROUP, COMMAND_DATAGRID, "Default description");
174 
175 		createButtonLink(grid, CURRENT_MINISTRIES_CURRENT_MEMBERS_TEXT, FontAwesome.GROUP, COMMAND_CHARTS_CURRENT_MINISTRIES_BY_HEADCOUNT,
176 				"Default description");
177 		createButtonLink(grid, CURRENT_PARTIES_ACTIVE_IN_MINISTRIES_HEAD_COUNT_TEXT, FontAwesome.GROUP, COMMAND_CHARTS_CURRENT_PARTIES_BY_HEADCOUNT,
178 				"Default description");
179 
180 		createButtonLink(grid, ALL_PARTIES_TOTAL_DAYS_SERVED_IN_MINISTRIES_TEXT, FontAwesome.GROUP, COMMAND_CHARTS_ALLMINISTRIES_BY_TOTAL_DAYS,
181 				"Default description");
182 		createButtonLink(grid, ALL_MINISTRIES_TOTAL_MEMBERS_TEXT, FontAwesome.GROUP, COMMAND_CHARTS_ALL_MINISTRIES_BY_HEADCOUNT, "Default description");
183 		createButtonLink(grid, GOVERNMENT_BODIES, FontAwesome.GROUP, COMMAND_GOVERNMENT_BODIES, "Default description");
184 
185 		createButtonLink(grid,GOVERNMENT_ROLES_CHART, FontAwesome.GROUP, COMMAND_CHARTS_ALL_GOVERNMENT_ROLE_GANTT, "Default description");
186 
187 		createButtonLink(grid, PAGE_VISIT_HISTORY_TEXT, FontAwesome.GROUP, COMMAND_PAGEVISITHISTORY, "Default description");
188 
189 	}
190 
191 }