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.politician.pagemode;
20
21 import java.util.List;
22
23 import org.springframework.security.access.annotation.Secured;
24 import org.springframework.stereotype.Component;
25
26 import com.hack23.cia.model.external.riksdagen.person.impl.PersonData;
27 import com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenCommitteeBallotDecisionPoliticianEmbeddedId;
28 import com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenCommitteeBallotDecisionPoliticianEmbeddedId_;
29 import com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenCommitteeBallotDecisionPoliticianSummary;
30 import com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenCommitteeBallotDecisionPoliticianSummary_;
31 import com.hack23.cia.model.internal.application.data.politician.impl.ViewRiksdagenPolitician;
32 import com.hack23.cia.service.api.DataContainer;
33 import com.hack23.cia.web.impl.ui.application.views.common.labelfactory.LabelFactory;
34 import com.hack23.cia.web.impl.ui.application.views.common.viewnames.PoliticianPageMode;
35 import com.hack23.cia.web.impl.ui.application.views.common.viewnames.UserViews;
36 import com.hack23.cia.web.impl.ui.application.views.pageclicklistener.PageItemPropertyClickListener;
37 import com.vaadin.data.util.BeanItemContainer;
38 import com.vaadin.ui.Layout;
39 import com.vaadin.ui.MenuBar;
40 import com.vaadin.ui.Panel;
41 import com.vaadin.ui.VerticalLayout;
42
43
44
45
46 @Component
47 public final class PoliticianBallotDecisionSummaryPageModContentFactoryImpl extends AbstractPoliticianPageModContentFactoryImpl {
48
49
50
51
52
53 public PoliticianBallotDecisionSummaryPageModContentFactoryImpl() {
54 super();
55 }
56
57 @Override
58 public boolean matches(final String page, final String parameters) {
59 return NAME.equals(page) && parameters.contains(PoliticianPageMode.BALLOTDECISIONSUMMARY.toString());
60 }
61
62 @Secured({ "ROLE_ANONYMOUS", "ROLE_USER", "ROLE_ADMIN" })
63 @Override
64 public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
65 final VerticalLayout panelContent = createPanelContent();
66
67 final String pageId = getPageId(parameters);
68
69 final DataContainer<PersonData, String> dataContainer = getApplicationManager()
70 .getDataContainer(PersonData.class);
71
72 final PersonData personData = dataContainer.load(pageId);
73 if (personData != null) {
74
75 final DataContainer<ViewRiksdagenPolitician, String> politicianDataContainer = getApplicationManager()
76 .getDataContainer(ViewRiksdagenPolitician.class);
77
78 final ViewRiksdagenPolitician viewRiksdagenPolitician = politicianDataContainer.load(personData.getId());
79
80 getPoliticianMenuItemFactory().createPoliticianMenuBar(menuBar, pageId);
81
82 LabelFactory.createHeader2Label(panelContent,PoliticianPageMode.BALLOTDECISIONSUMMARY.toString());
83
84
85 final DataContainer<ViewRiksdagenCommitteeBallotDecisionPoliticianSummary, ViewRiksdagenCommitteeBallotDecisionPoliticianEmbeddedId> committeeBallotDecisionPartyDataContainer = getApplicationManager()
86 .getDataContainer(ViewRiksdagenCommitteeBallotDecisionPoliticianSummary.class);
87
88 final List<ViewRiksdagenCommitteeBallotDecisionPoliticianSummary> decisionPartySummaryList = committeeBallotDecisionPartyDataContainer
89 .findOrderedByPropertyListByEmbeddedProperty(
90 ViewRiksdagenCommitteeBallotDecisionPoliticianSummary.class,
91 ViewRiksdagenCommitteeBallotDecisionPoliticianSummary_.embeddedId,
92 ViewRiksdagenCommitteeBallotDecisionPoliticianEmbeddedId.class,
93 ViewRiksdagenCommitteeBallotDecisionPoliticianEmbeddedId_.intressentId, pageId,
94 ViewRiksdagenCommitteeBallotDecisionPoliticianSummary_.voteDate);
95
96 final BeanItemContainer<ViewRiksdagenCommitteeBallotDecisionPoliticianSummary> committeeBallotDecisionPartyDataSource = new BeanItemContainer<>(
97 ViewRiksdagenCommitteeBallotDecisionPoliticianSummary.class, decisionPartySummaryList);
98
99 getGridFactory()
100 .createBasicBeanItemNestedPropertiesGrid(panelContent,committeeBallotDecisionPartyDataSource,
101 "Committee Ballot Decision Politician Summary",
102 new String[] { "embeddedId.concern", "embeddedId.issue" },
103 new String[] { "voteDate", "rm", "org", "committeeReport", "title", "subTitle",
104 "winner", "embeddedId.concern", "embeddedId.issue", "vote", "won", "rebel",
105 "noWinner", "approved", "partyApproved", "againstProposalNumber",
106 "againstProposalParties", "totalVotes", "partyTotalVotes", "yesVotes",
107 "partyYesVotes", "noVotes", "partyNoVotes", "partyAbstainVotes",
108 "abstainVotes", "partyAbsentVotes", "absentVotes", "bornYear",
109 "partyAvgBornYear", "avgBornYear", "ballotType", "decisionType",
110 "ballotId" },
111 new String[] { "label", "endNumber", "publicDate", "createdDate", "embeddedId",
112 "partyNoWinner", "partyPercentageYes", "partyPercentageNo",
113 "partyPercentageAbsent", "partyPercentageAbstain", "percentageYes",
114 "percentageNo", "percentageAbsent", "percentageAbstain", "firstName",
115 "lastName", "party", "ballotId", "decisionType", "ballotType", "againstProposalNumber" },
116 new PageItemPropertyClickListener(UserViews.BALLOT_VIEW_NAME, "ballotId"), "ballotId", null);
117
118 pageCompleted(parameters, panel, pageId, viewRiksdagenPolitician);
119
120 }
121 return panelContent;
122
123 }
124 }