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
23 import org.apache.commons.lang3.StringUtils;
24 import org.springframework.security.access.annotation.Secured;
25 import org.springframework.stereotype.Component;
26
27 import com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenCommittee;
28 import com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenCommitteeDecisions;
29 import com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenCommitteeDecisionsEmbeddedId;
30 import com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenCommitteeDecisions_;
31 import com.hack23.cia.model.internal.application.system.impl.ApplicationEventGroup;
32 import com.hack23.cia.service.api.DataContainer;
33 import com.hack23.cia.web.impl.ui.application.action.ViewAction;
34 import com.hack23.cia.web.impl.ui.application.views.common.labelfactory.LabelFactory;
35 import com.hack23.cia.web.impl.ui.application.views.common.viewnames.CommitteePageMode;
36 import com.hack23.cia.web.impl.ui.application.views.common.viewnames.UserViews;
37 import com.hack23.cia.web.impl.ui.application.views.pageclicklistener.PageItemPropertyClickListener;
38 import com.vaadin.data.util.BeanItemContainer;
39 import com.vaadin.ui.Layout;
40 import com.vaadin.ui.MenuBar;
41 import com.vaadin.ui.Panel;
42 import com.vaadin.ui.VerticalLayout;
43
44
45
46
47 @Component
48 public final class CommitteeDecisionSummaryPageModContentFactoryImpl
49 extends AbstractCommitteePageModContentFactoryImpl {
50
51
52 private static final String COMMITTEE = "Committee:";
53
54
55 private static final String DECISION_SUMMARY = "Decision Summary";
56
57
58
59
60
61 public CommitteeDecisionSummaryPageModContentFactoryImpl() {
62 super();
63 }
64
65 @Override
66 public boolean matches(final String page, final String parameters) {
67 return NAME.equals(page) && (!StringUtils.isEmpty(parameters)
68 && parameters.contains(CommitteePageMode.DECISIONSUMMARY.toString()));
69 }
70
71 @Secured({ "ROLE_ANONYMOUS", "ROLE_USER", "ROLE_ADMIN" })
72 @Override
73 public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
74 final VerticalLayout panelContent = createPanelContent();
75
76 final String pageId = getPageId(parameters);
77
78 final DataContainer<ViewRiksdagenCommittee, String> dataContainer = getApplicationManager()
79 .getDataContainer(ViewRiksdagenCommittee.class);
80
81 final ViewRiksdagenCommittee viewRiksdagenCommittee = dataContainer.load(pageId);
82
83 if (viewRiksdagenCommittee != null) {
84
85 getCommitteeMenuItemFactory().createCommitteeeMenuBar(menuBar, pageId);
86
87 LabelFactory.createHeader2Label(panelContent, DECISION_SUMMARY);
88
89 final DataContainer<ViewRiksdagenCommitteeDecisions, ViewRiksdagenCommitteeDecisionsEmbeddedId> committeeDecisionDataContainer = getApplicationManager()
90 .getDataContainer(ViewRiksdagenCommitteeDecisions.class);
91
92 final List<ViewRiksdagenCommitteeDecisions> decisionPartySummaryList = committeeDecisionDataContainer
93 .findOrderedListByProperty(ViewRiksdagenCommitteeDecisions_.org, pageId,
94 ViewRiksdagenCommitteeDecisions_.createdDate);
95
96 final BeanItemContainer<ViewRiksdagenCommitteeDecisions> committeeDecisionDataSource = new BeanItemContainer<>(
97 ViewRiksdagenCommitteeDecisions.class, decisionPartySummaryList);
98
99 getGridFactory().createBasicBeanItemNestedPropertiesGrid(panelContent, committeeDecisionDataSource,
100 DECISION_SUMMARY, new String[] { "embeddedId.hangarId", "embeddedId.id", "embeddedId.issueNummer" },
101 new String[] { "createdDate", "publicDate", "committeeReport", "embeddedId.hangarId",
102 "embeddedId.id", "embeddedId.issueNummer", "rm", "decisionType", "winner", "title",
103 "header", "endNumber", "org", "committeeProposalUrlXml", "ballotId",
104 "againstProposalParties", "againstProposalNumber" },
105 new String[] { "embeddedId", "embeddedId.hangarId", "embeddedId.id", "endNumber", "org",
106 "committeeProposalUrlXml", "ballotId", "againstProposalParties", "againstProposalNumber",
107 "createdDate" },
108 new PageItemPropertyClickListener(UserViews.BALLOT_VIEW_NAME, "ballotId"), "ballotId", null);
109
110 panel.setCaption(COMMITTEE + viewRiksdagenCommittee.getEmbeddedId().getDetail());
111 getPageActionEventHelper().createPageEvent(ViewAction.VISIT_COMMITTEE_VIEW, ApplicationEventGroup.USER,
112 NAME, parameters, pageId);
113 }
114 return panelContent;
115
116 }
117
118 }