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.Component;
27
28 import com.hack23.cia.model.internal.application.data.ministry.impl.ViewRiksdagenGovermentRoleMember;
29 import com.hack23.cia.model.internal.application.data.ministry.impl.ViewRiksdagenGovermentRoleMember_;
30 import com.hack23.cia.model.internal.application.data.ministry.impl.ViewRiksdagenMinistry;
31 import com.hack23.cia.model.internal.application.system.impl.ApplicationEventGroup;
32 import com.hack23.cia.service.api.DataContainer;
33 import com.hack23.cia.web.impl.ui.application.action.ViewAction;
34 import com.hack23.cia.web.impl.ui.application.views.common.chartfactory.api.MinistryGhantChartManager;
35 import com.hack23.cia.web.impl.ui.application.views.common.labelfactory.LabelFactory;
36 import com.hack23.cia.web.impl.ui.application.views.common.viewnames.MinistryPageMode;
37 import com.vaadin.ui.Layout;
38 import com.vaadin.ui.MenuBar;
39 import com.vaadin.ui.Panel;
40 import com.vaadin.ui.VerticalLayout;
41
42
43
44
45 @Component
46 public final class MinistryRoleGhantPageModContentFactoryImpl extends AbstractMinistryPageModContentFactoryImpl {
47
48
49 private static final String ROLE_GHANT = "Role Ghant";
50
51
52 private static final String MINISTRY = "Ministry:";
53
54 @Autowired
55 private MinistryGhantChartManager ministryGhantChartManager;
56
57
58
59
60 public MinistryRoleGhantPageModContentFactoryImpl() {
61 super();
62 }
63
64 @Override
65 public boolean matches(final String page, final String parameters) {
66 return NAME.equals(page) && (!StringUtils.isEmpty(parameters) && parameters.contains(MinistryPageMode.ROLEGHANT.toString()));
67 }
68
69 @Secured({ "ROLE_ANONYMOUS", "ROLE_USER", "ROLE_ADMIN" })
70 @Override
71 public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
72 final VerticalLayout panelContent = createPanelContent();
73
74 final String pageId = getPageId(parameters);
75
76 final DataContainer<ViewRiksdagenMinistry, String> dataContainer = getApplicationManager()
77 .getDataContainer(ViewRiksdagenMinistry.class);
78
79 final ViewRiksdagenMinistry viewRiksdagenMinistry = dataContainer.load(pageId);
80
81 if (viewRiksdagenMinistry != null) {
82
83 getMinistryMenuItemFactory().createMinistryMenuBar(menuBar, pageId);
84
85 LabelFactory.createHeader2Label(panelContent,ROLE_GHANT);
86
87
88 final DataContainer<ViewRiksdagenGovermentRoleMember, String> govermentRoleMemberDataContainer = getApplicationManager()
89 .getDataContainer(ViewRiksdagenGovermentRoleMember.class);
90
91 final List<ViewRiksdagenGovermentRoleMember> allMembers = govermentRoleMemberDataContainer.getAllBy(ViewRiksdagenGovermentRoleMember_.detail, viewRiksdagenMinistry.getNameId());
92
93 ministryGhantChartManager.createRoleGhant(panelContent, allMembers);
94
95 panel.setCaption(MINISTRY + viewRiksdagenMinistry.getNameId());
96 getPageActionEventHelper().createPageEvent(ViewAction.VISIT_MINISTRY_VIEW, ApplicationEventGroup.USER, NAME,
97 parameters, pageId);
98
99 }
100
101 return panelContent;
102
103 }
104
105 }