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.security.access.annotation.Secured;
24 import org.springframework.stereotype.Component;
25
26 import com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenCommitteeBallotDecisionPartyEmbeddedId;
27 import com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenCommitteeBallotDecisionPartyEmbeddedId_;
28 import com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenCommitteeBallotDecisionPartySummary;
29 import com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenCommitteeBallotDecisionPartySummary_;
30 import com.hack23.cia.model.internal.application.data.party.impl.ViewRiksdagenParty;
31 import com.hack23.cia.service.api.DataContainer;
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.hack23.cia.web.impl.ui.application.views.common.viewnames.UserViews;
35 import com.hack23.cia.web.impl.ui.application.views.pageclicklistener.PageItemPropertyClickListener;
36 import com.vaadin.data.util.BeanItemContainer;
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 PartyCommitteeBallotDecisionSummaryPageModContentFactoryImpl
47 extends AbstractPartyPageModContentFactoryImpl {
48
49
50 private static final String COMMITTEE_BALLOT_DECISION_PARTY_SUMMARY = "Committee Ballot Decision Party Summary";
51
52
53 private static final String COMMITTEE_BALLOT_DECISION_SUMMARY = "CommitteeBallotDecisionSummary";
54
55
56
57
58
59 public PartyCommitteeBallotDecisionSummaryPageModContentFactoryImpl() {
60 super();
61 }
62
63 @Override
64 public boolean matches(final String page, final String parameters) {
65 return NAME.equals(page) && parameters.contains(PartyPageMode.COMMITTEEBALLOTDECISIONSUMMARY.toString());
66 }
67
68 @Secured({ "ROLE_ANONYMOUS", "ROLE_USER", "ROLE_ADMIN" })
69 @Override
70 public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
71 final VerticalLayout panelContent = createPanelContent();
72
73 final String pageId = getPageId(parameters);
74
75 final DataContainer<ViewRiksdagenParty, String> dataContainer = getApplicationManager()
76 .getDataContainer(ViewRiksdagenParty.class);
77
78 final ViewRiksdagenParty viewRiksdagenParty = dataContainer.load(pageId);
79
80 if (viewRiksdagenParty != null) {
81
82 getPartyMenuItemFactory().createPartyMenuBar(menuBar, pageId);
83
84 LabelFactory.createHeader2Label(panelContent, COMMITTEE_BALLOT_DECISION_SUMMARY);
85
86 final DataContainer<ViewRiksdagenCommitteeBallotDecisionPartySummary, ViewRiksdagenCommitteeBallotDecisionPartyEmbeddedId> committeeBallotDecisionPartyDataContainer = getApplicationManager()
87 .getDataContainer(ViewRiksdagenCommitteeBallotDecisionPartySummary.class);
88
89 final List<ViewRiksdagenCommitteeBallotDecisionPartySummary> decisionPartySummaryList = committeeBallotDecisionPartyDataContainer
90 .findOrderedListByEmbeddedProperty(ViewRiksdagenCommitteeBallotDecisionPartySummary.class,
91 ViewRiksdagenCommitteeBallotDecisionPartySummary_.embeddedId,
92 ViewRiksdagenCommitteeBallotDecisionPartyEmbeddedId.class,
93 ViewRiksdagenCommitteeBallotDecisionPartyEmbeddedId_.party, pageId,
94 ViewRiksdagenCommitteeBallotDecisionPartyEmbeddedId_.issue);
95
96 final BeanItemContainer<ViewRiksdagenCommitteeBallotDecisionPartySummary> committeeBallotDecisionPartyDataSource = new BeanItemContainer<>(
97 ViewRiksdagenCommitteeBallotDecisionPartySummary.class, decisionPartySummaryList);
98
99 getGridFactory().createBasicBeanItemNestedPropertiesGrid(panelContent,
100 committeeBallotDecisionPartyDataSource, COMMITTEE_BALLOT_DECISION_PARTY_SUMMARY,
101 new String[] { "embeddedId.id", "embeddedId.concern", "embeddedId.issue", "embeddedId.party" },
102 new String[] { "voteDate", "rm", "org", "embeddedId.id", "embeddedId.party", "committeeReport",
103 "title", "subTitle", "winner", "partyApproved", "againstProposalParties", "embeddedId.concern",
104 "embeddedId.issue", "endNumber", "createdDate", "publicDate", "ballotId", "decisionType",
105 "againstProposalNumber", "ballotType", "label", "avgBornYear", "totalVotes", "approved",
106 "noWinner", "percentageYes", "percentageNo", "percentageAbsent", "percentageAbstain",
107 "percentageMale", "partyAvgBornYear", "partyTotalVotes", "partyYesVotes", "partyNoVotes",
108 "partyAbstainVotes", "partyAbsentVotes", "yesVotes", "noVotes",
109 "abstainVotes", "absentVotes", "partyNoWinner", "partyPercentageYes", "partyPercentageNo",
110 "partyPercentageAbsent", "partyPercentageAbstain", "partyPercentageMale" },
111 new String[] { "embeddedId", "ballotId", "decisionType", "ballotType", "againstProposalNumber",
112 "embeddedId.id", "embeddedId.party", "createdDate", "publicDate", "label", "endNumber",
113 "org", "partyPercentageYes", "partyPercentageNo", "partyPercentageAbsent",
114 "partyPercentageAbstain", "partyPercentageMale", "partyAvgBornYear", "avgBornYear",
115 "percentageYes", "percentageNo", "percentageAbsent", "percentageAbstain", "percentageMale",
116 "approved", "noWinner" },
117 new PageItemPropertyClickListener(UserViews.BALLOT_VIEW_NAME, "ballotId"), "ballotId", null);
118
119 pageCompleted(parameters, panel, pageId, viewRiksdagenParty);
120 }
121 return panelContent;
122
123 }
124
125 }