1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package com.hack23.cia.web.impl.ui.application.views.user.goverment.pagemode;
20
21 import java.util.List;
22
23 import org.apache.commons.lang3.StringUtils;
24 import org.springframework.beans.factory.annotation.Autowired;
25 import org.springframework.security.access.annotation.Secured;
26 import org.springframework.stereotype.Service;
27
28 import com.hack23.cia.model.internal.application.data.ministry.impl.ViewRiksdagenGovermentRoleMember;
29 import com.hack23.cia.model.internal.application.system.impl.ApplicationEventGroup;
30 import com.hack23.cia.service.api.DataContainer;
31 import com.hack23.cia.web.impl.ui.application.action.ViewAction;
32 import com.hack23.cia.web.impl.ui.application.views.common.chartfactory.api.MinistryGhantChartManager;
33 import com.hack23.cia.web.impl.ui.application.views.common.viewnames.ChartIndicators;
34 import com.hack23.cia.web.impl.ui.application.views.common.viewnames.PageMode;
35 import com.vaadin.ui.HorizontalLayout;
36 import com.vaadin.ui.Layout;
37 import com.vaadin.ui.MenuBar;
38 import com.vaadin.ui.Panel;
39 import com.vaadin.ui.VerticalLayout;
40
41
42
43
44 @Service
45 public final class MinistryRankingAllRolesChartsPageModContentFactoryImpl
46 extends AbstractMinistryRankingPageModContentFactoryImpl {
47
48
49 private static final String CHARTS = "Charts: Current parties by headcount";
50
51 @Autowired
52 private MinistryGhantChartManager ministryGhantChartManager;
53
54
55
56
57
58 public MinistryRankingAllRolesChartsPageModContentFactoryImpl() {
59 super();
60 }
61
62 @Override
63 public boolean matches(final String page, final String parameters) {
64 return NAME.equals(page) && !StringUtils.isEmpty(parameters) && parameters.contains(PageMode.CHARTS.toString())
65 && parameters.contains(ChartIndicators.ALL_GOVERNMENT_ROLE_CHART.toString());
66 }
67
68 @Secured({ "ROLE_ANONYMOUS", "ROLE_USER", "ROLE_ADMIN" })
69 @Override
70 public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
71 final VerticalLayout panelContent = createPanelContent();
72
73 getMinistryRankingMenuItemFactory().createMinistryRankingMenuBar(menuBar);
74
75 final String pageId = getPageId(parameters);
76
77 final HorizontalLayout chartLayout = new HorizontalLayout();
78 chartLayout.setSizeFull();
79
80 final DataContainer<ViewRiksdagenGovermentRoleMember, String> govermentRoleMemberDataContainer = getApplicationManager()
81 .getDataContainer(ViewRiksdagenGovermentRoleMember.class);
82
83 final List<ViewRiksdagenGovermentRoleMember> allMembers = govermentRoleMemberDataContainer.getAll();
84
85 ministryGhantChartManager.createRoleGhant(panelContent, allMembers);
86
87 panel.setCaption(CHARTS + parameters);
88
89 getPageActionEventHelper().createPageEvent(ViewAction.VISIT_MINISTRY_RANKING_VIEW, ApplicationEventGroup.USER,
90 NAME, parameters, pageId);
91
92 return panelContent;
93
94 }
95
96 }