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 org.springframework.security.access.annotation.Secured;
22 import org.springframework.stereotype.Component;
23
24 import com.hack23.cia.model.internal.application.data.party.impl.ViewRiksdagenParty;
25 import com.hack23.cia.model.internal.application.data.politician.impl.ViewRiksdagenPolitician;
26 import com.hack23.cia.model.internal.application.data.politician.impl.ViewRiksdagenPolitician_;
27 import com.hack23.cia.service.api.DataContainer;
28 import com.hack23.cia.web.impl.ui.application.views.common.labelfactory.LabelFactory;
29 import com.hack23.cia.web.impl.ui.application.views.common.viewnames.PartyPageMode;
30 import com.hack23.cia.web.impl.ui.application.views.common.viewnames.UserViews;
31 import com.hack23.cia.web.impl.ui.application.views.pageclicklistener.PageItemPropertyClickListener;
32 import com.vaadin.data.util.BeanItemContainer;
33 import com.vaadin.ui.Layout;
34 import com.vaadin.ui.MenuBar;
35 import com.vaadin.ui.Panel;
36 import com.vaadin.ui.VerticalLayout;
37
38
39
40
41 @Component
42 public final class PartyCurrentMembersPageModContentFactoryImpl extends AbstractPartyPageModContentFactoryImpl {
43
44
45 private static final String CURRENT_MEMBERS = "Current Members";
46
47
48
49
50 public PartyCurrentMembersPageModContentFactoryImpl() {
51 super();
52 }
53
54 @Override
55 public boolean matches(final String page, final String parameters) {
56 return NAME.equals(page) && parameters.contains(PartyPageMode.CURRENTMEMBERS.toString());
57 }
58
59 @Secured({ "ROLE_ANONYMOUS", "ROLE_USER", "ROLE_ADMIN" })
60 @Override
61 public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
62 final VerticalLayout panelContent = createPanelContent();
63
64 final String pageId = getPageId(parameters);
65
66 final DataContainer<ViewRiksdagenParty, String> dataContainer = getApplicationManager()
67 .getDataContainer(ViewRiksdagenParty.class);
68
69 final ViewRiksdagenParty viewRiksdagenParty = dataContainer.load(pageId);
70
71 if (viewRiksdagenParty != null) {
72
73 getPartyMenuItemFactory().createPartyMenuBar(menuBar, pageId);
74
75 LabelFactory.createHeader2Label(panelContent,CURRENT_MEMBERS);
76
77
78 final DataContainer<ViewRiksdagenPolitician, String> politicianDataContainer = getApplicationManager()
79 .getDataContainer(ViewRiksdagenPolitician.class);
80
81 final BeanItemContainer<ViewRiksdagenPolitician> politicianDataSource = new BeanItemContainer<>(
82 ViewRiksdagenPolitician.class,
83 politicianDataContainer.findListByProperty(
84 new Object[] { viewRiksdagenParty.getPartyId(), Boolean.TRUE },
85 ViewRiksdagenPolitician_.party, ViewRiksdagenPolitician_.active));
86
87 getGridFactory().createBasicBeanItemGrid(panelContent,
88 politicianDataSource,
89 "Politicians",
90 new String[] { "personId", "firstName", "lastName", "party", "bornYear", "totalDaysServed",
91 "currentAssignments", "totalAssignments", "firstAssignmentDate", "lastAssignmentDate",
92 "totalDaysServedParliament", "totalDaysServedCommittee", "totalDaysServedGovernment",
93 "totalDaysServedEu",
94
95 "active", "activeEu", "activeGovernment", "activeCommittee", "activeParliament",
96
97 "activeParty", "activeSpeaker", "totalDaysServedSpeaker", "totalDaysServedParty",
98
99 "totalPartyAssignments", "totalMinistryAssignments", "totalCommitteeAssignments",
100 "totalSpeakerAssignments",
101
102 "currentPartyAssignments", "currentMinistryAssignments", "currentCommitteeAssignments",
103 "currentSpeakerAssignments", "gender" }, new String[] { "personId", "active", "activeEu", "party", "activeGovernment", "activeCommittee", "activeParliament", "activeParty", "activeSpeaker","bornYear" }, new PageItemPropertyClickListener(UserViews.POLITICIAN_VIEW_NAME, "personId"), null, null);
104
105
106 pageCompleted(parameters, panel, pageId, viewRiksdagenParty);
107 }
108 return panelContent;
109
110 }
111
112 }