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.committee.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.committee.impl.ViewRiksdagenCommittee;
29 import com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenCommitteeRoleMember;
30 import com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenCommitteeRoleMember_;
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.CommitteeGhantChartManager;
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.CommitteePageMode;
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 CommitteeRoleGhantPageModContentFactoryImpl extends AbstractCommitteePageModContentFactoryImpl {
47
48
49 private static final String COMMITTEE = "Committee:";
50
51
52 private static final String ROLE_GHANT = "Role chart";
53
54 @Autowired
55 private CommitteeGhantChartManager committeeGhantChartManager;
56
57
58
59
60 public CommitteeRoleGhantPageModContentFactoryImpl() {
61 super();
62 }
63
64 @Override
65 public boolean matches(final String page, final String parameters) {
66 return NAME.equals(page)
67 && (!StringUtils.isEmpty(parameters) && parameters.contains(CommitteePageMode.ROLEGHANT.toString()));
68 }
69
70 @Secured({ "ROLE_ANONYMOUS", "ROLE_USER", "ROLE_ADMIN" })
71 @Override
72 public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
73 final VerticalLayout panelContent = createPanelContent();
74
75 final String pageId = getPageId(parameters);
76
77 final DataContainer<ViewRiksdagenCommittee, String> dataContainer = getApplicationManager()
78 .getDataContainer(ViewRiksdagenCommittee.class);
79
80 final ViewRiksdagenCommittee viewRiksdagenCommittee = dataContainer.load(pageId);
81
82 if (viewRiksdagenCommittee != null) {
83
84 getCommitteeMenuItemFactory().createCommitteeeMenuBar(menuBar, pageId);
85
86 LabelFactory.createHeader2Label(panelContent,ROLE_GHANT);
87
88
89 final DataContainer<ViewRiksdagenCommitteeRoleMember, String> committeeRoleMemberDataContainer = getApplicationManager()
90 .getDataContainer(ViewRiksdagenCommitteeRoleMember.class);
91
92 final List<ViewRiksdagenCommitteeRoleMember> allMembers = committeeRoleMemberDataContainer.getAllBy(ViewRiksdagenCommitteeRoleMember_.detail,
93 viewRiksdagenCommittee.getEmbeddedId().getDetail());
94
95 committeeGhantChartManager.createRoleGhant(panelContent, allMembers);
96
97 panel.setCaption(COMMITTEE + viewRiksdagenCommittee.getEmbeddedId().getDetail());
98 getPageActionEventHelper().createPageEvent(ViewAction.VISIT_COMMITTEE_VIEW, ApplicationEventGroup.USER,
99 NAME, parameters, pageId);
100 }
101 return panelContent;
102
103 }
104
105 }