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 import java.util.Locale;
23
24 import org.apache.commons.lang3.StringUtils;
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.ViewRiksdagenCommitteeBallotDecisionPartyEmbeddedId;
30 import com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenCommitteeBallotDecisionSummary;
31 import com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenCommitteeBallotDecisionSummary_;
32 import com.hack23.cia.model.internal.application.system.impl.ApplicationEventGroup;
33 import com.hack23.cia.service.api.DataContainer;
34 import com.hack23.cia.web.impl.ui.application.action.ViewAction;
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.hack23.cia.web.impl.ui.application.views.common.viewnames.UserViews;
38 import com.hack23.cia.web.impl.ui.application.views.pageclicklistener.PageItemPropertyClickListener;
39 import com.vaadin.data.util.BeanItemContainer;
40 import com.vaadin.ui.Layout;
41 import com.vaadin.ui.MenuBar;
42 import com.vaadin.ui.Panel;
43 import com.vaadin.ui.VerticalLayout;
44
45
46
47
48 @Component
49 public final class CommitteeBallotDecisionSummaryPageModContentFactoryImpl
50 extends AbstractCommitteePageModContentFactoryImpl {
51
52
53 private static final String COMMITTEE = "Committee:";
54
55
56 private static final String BALLOT_DECISION_SUMMARY = "Ballot Decision Summary";
57
58
59
60
61
62 public CommitteeBallotDecisionSummaryPageModContentFactoryImpl() {
63 super();
64 }
65
66 @Override
67 public boolean matches(final String page, final String parameters) {
68 return NAME.equals(page) && (!StringUtils.isEmpty(parameters)
69 && parameters.contains(CommitteePageMode.BALLOTDECISIONSUMMARY.toString()));
70 }
71
72 @Secured({ "ROLE_ANONYMOUS", "ROLE_USER", "ROLE_ADMIN" })
73 @Override
74 public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
75 final VerticalLayout panelContent = createPanelContent();
76
77 final String pageId = getPageId(parameters);
78
79 final DataContainer<ViewRiksdagenCommittee, String> dataContainer = getApplicationManager()
80 .getDataContainer(ViewRiksdagenCommittee.class);
81
82 final ViewRiksdagenCommittee viewRiksdagenCommittee = dataContainer.load(pageId);
83
84 if (viewRiksdagenCommittee != null) {
85
86 getCommitteeMenuItemFactory().createCommitteeeMenuBar(menuBar, pageId);
87
88 LabelFactory.createHeader2Label(panelContent, BALLOT_DECISION_SUMMARY);
89
90 final DataContainer<ViewRiksdagenCommitteeBallotDecisionSummary, ViewRiksdagenCommitteeBallotDecisionPartyEmbeddedId> committeeBallotDecisionPartyDataContainer = getApplicationManager()
91 .getDataContainer(ViewRiksdagenCommitteeBallotDecisionSummary.class);
92
93 final List<ViewRiksdagenCommitteeBallotDecisionSummary> decisionPartySummaryList = committeeBallotDecisionPartyDataContainer
94 .findOrderedListByProperty(ViewRiksdagenCommitteeBallotDecisionSummary_.org,
95 pageId.toUpperCase(Locale.ENGLISH),
96 ViewRiksdagenCommitteeBallotDecisionSummary_.createdDate);
97
98 final BeanItemContainer<ViewRiksdagenCommitteeBallotDecisionSummary> committeeBallotDecisionPartyDataSource = new BeanItemContainer<>(
99 ViewRiksdagenCommitteeBallotDecisionSummary.class, decisionPartySummaryList);
100
101 getGridFactory().createBasicBeanItemNestedPropertiesGrid(panelContent,
102 committeeBallotDecisionPartyDataSource, "Committee Ballot Decision Summary",
103 new String[] { "embeddedId.concern", "embeddedId.issue", "embeddedId.id" },
104 new String[] { "voteDate", "embeddedId.concern", "embeddedId.id", "committeeReport",
105 "embeddedId.issue", "rm", "title", "subTitle", "endNumber", "org", "createdDate",
106 "publicDate", "ballotId", "decisionType", "againstProposalParties", "againstProposalNumber",
107 "winner", "ballotType", "label", "avgBornYear", "totalVotes", "yesVotes", "noVotes",
108 "abstainVotes", "absentVotes", "approved", "noWinner", "percentageYes", "percentageNo",
109 "percentageAbsent", "percentageAbstain", "percentageMale" },
110 new String[] { "embeddedId", "embeddedId.id", "endNumber", "org", "createdDate", "publicDate",
111 "ballotId", "decisionType", "label", "againstProposalNumber", "avgBornYear",
112 "percentageMale", "approved", "noWinner", "ballotType", "percentageYes", "percentageNo",
113 "percentageAbsent", "percentageAbstain" },
114 new PageItemPropertyClickListener(UserViews.BALLOT_VIEW_NAME, "ballotId"), "ballotId", null);
115
116 panel.setCaption(COMMITTEE + viewRiksdagenCommittee.getEmbeddedId().getDetail());
117 getPageActionEventHelper().createPageEvent(ViewAction.VISIT_COMMITTEE_VIEW, ApplicationEventGroup.USER,
118 NAME, parameters, pageId);
119 }
120 return panelContent;
121
122 }
123
124 }