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.party.pagemode;
20
21 import java.util.List;
22
23 import org.springframework.beans.factory.annotation.Autowired;
24 import org.springframework.security.access.annotation.Secured;
25 import org.springframework.stereotype.Component;
26
27 import com.hack23.cia.model.internal.application.data.party.impl.ViewRiksdagenParty;
28 import com.hack23.cia.model.internal.application.data.party.impl.ViewRiksdagenPartyRoleMember;
29 import com.hack23.cia.model.internal.application.data.party.impl.ViewRiksdagenPartyRoleMember_;
30 import com.hack23.cia.service.api.DataContainer;
31 import com.hack23.cia.web.impl.ui.application.views.common.chartfactory.api.PartyGhantChartManager;
32 import com.hack23.cia.web.impl.ui.application.views.common.labelfactory.LabelFactory;
33 import com.hack23.cia.web.impl.ui.application.views.common.viewnames.PartyPageMode;
34 import com.vaadin.ui.Layout;
35 import com.vaadin.ui.MenuBar;
36 import com.vaadin.ui.Panel;
37 import com.vaadin.ui.VerticalLayout;
38
39
40
41
42 @Component
43 public final class PartyRoleGhantPageModContentFactoryImpl extends AbstractPartyPageModContentFactoryImpl {
44
45
46 private static final String ROLE_GHANT = "Role chart";
47
48 @Autowired
49 private PartyGhantChartManager partyGhantChartManager;
50
51
52
53
54 public PartyRoleGhantPageModContentFactoryImpl() {
55 super();
56 }
57
58 @Override
59 public boolean matches(final String page, final String parameters) {
60 return NAME.equals(page) && parameters.contains(PartyPageMode.ROLEGHANT.toString());
61 }
62
63 @Secured({ "ROLE_ANONYMOUS", "ROLE_USER", "ROLE_ADMIN" })
64 @Override
65 public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
66 final VerticalLayout panelContent = createPanelContent();
67
68 final String pageId = getPageId(parameters);
69
70 final DataContainer<ViewRiksdagenParty, String> dataContainer = getApplicationManager()
71 .getDataContainer(ViewRiksdagenParty.class);
72
73 final ViewRiksdagenParty viewRiksdagenParty = dataContainer.load(pageId);
74
75 if (viewRiksdagenParty != null) {
76
77 getPartyMenuItemFactory().createPartyMenuBar(menuBar, pageId);
78
79 LabelFactory.createHeader2Label(panelContent, ROLE_GHANT);
80
81 final DataContainer<ViewRiksdagenPartyRoleMember, String> partyRoleMemberDataContainer = getApplicationManager()
82 .getDataContainer(ViewRiksdagenPartyRoleMember.class);
83
84 final List<ViewRiksdagenPartyRoleMember> allMembers = partyRoleMemberDataContainer
85 .getAllBy(ViewRiksdagenPartyRoleMember_.party, viewRiksdagenParty.getPartyId());
86
87 partyGhantChartManager.createRoleGhant(panelContent, allMembers);
88
89 pageCompleted(parameters, panel, pageId, viewRiksdagenParty);
90 }
91 return panelContent;
92
93 }
94
95 }