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.document.pagemode;
20
21 import org.apache.commons.lang3.StringUtils;
22 import org.springframework.security.access.annotation.Secured;
23 import org.springframework.stereotype.Component;
24
25 import com.hack23.cia.model.external.riksdagen.dokumentlista.impl.DocumentElement;
26 import com.hack23.cia.model.external.riksdagen.dokumentstatus.impl.DocumentData;
27 import com.hack23.cia.model.external.riksdagen.dokumentstatus.impl.DocumentData_;
28 import com.hack23.cia.model.external.riksdagen.dokumentstatus.impl.DocumentPersonReferenceData;
29 import com.hack23.cia.model.external.riksdagen.dokumentstatus.impl.DocumentStatusContainer;
30 import com.hack23.cia.model.external.riksdagen.dokumentstatus.impl.DocumentStatusContainer_;
31 import com.hack23.cia.model.external.riksdagen.utskottsforslag.impl.CommitteeProposalComponentData;
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.DocumentPageMode;
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 DocumentPersonReferencesPageModContentFactoryImpl extends AbstractDocumentPageModContentFactoryImpl {
50
51
52 private static final String PERSON_REFERENCES = "Person References";
53
54
55
56
57
58 public DocumentPersonReferencesPageModContentFactoryImpl() {
59 super();
60 }
61
62 @Override
63 public boolean matches(final String page, final String parameters) {
64 return NAME.equals(page) && (!StringUtils.isEmpty(parameters) && parameters.contains(DocumentPageMode.PERSONREFERENCES.toString()));
65 }
66
67 @Secured({ "ROLE_ANONYMOUS", "ROLE_USER", "ROLE_ADMIN" })
68 @Override
69 public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
70 final VerticalLayout panelContent = createPanelContent();
71
72 final String pageId = getPageId(parameters);
73
74 final DataContainer<DocumentElement, String> documentElementDataContainer = getApplicationManager()
75 .getDataContainer(DocumentElement.class);
76
77 final DataContainer<DocumentStatusContainer, String> documentStatusContainerDataContainer = getApplicationManager()
78 .getDataContainer(DocumentStatusContainer.class);
79
80 getApplicationManager()
81 .getDataContainer(CommitteeProposalComponentData.class);
82
83 final DocumentElement documentElement = documentElementDataContainer.load(pageId);
84
85 if (documentElement != null) {
86
87 getDocumentMenuItemFactory().createDocumentMenuBar(menuBar, pageId);
88
89 final DocumentStatusContainer documentStatusContainer = documentStatusContainerDataContainer
90 .findByQueryProperty(DocumentStatusContainer.class, DocumentStatusContainer_.document,
91 DocumentData.class, DocumentData_.id, pageId);
92
93
94 LabelFactory.createHeader2Label(panelContent,PERSON_REFERENCES);
95
96
97 if (documentStatusContainer != null
98 && documentStatusContainer.getDocumentPersonReferenceContainer() != null
99 && documentStatusContainer.getDocumentPersonReferenceContainer()
100 .getDocumentPersonReferenceList() != null) {
101 final BeanItemContainer<DocumentPersonReferenceData> documentPersonReferenceDataDataSource = new BeanItemContainer<>(
102 DocumentPersonReferenceData.class, documentStatusContainer
103 .getDocumentPersonReferenceContainer().getDocumentPersonReferenceList());
104
105 getGridFactory().createBasicBeanItemGrid(
106 panelContent, documentPersonReferenceDataDataSource,
107 "Document person references",
108 new String[] { "personReferenceId", "referenceName", "partyShortCode", "orderNumber",
109 "roleDescription" }, new String[] { "personReferenceId", "hjid" },
110 new PageItemPropertyClickListener(UserViews.POLITICIAN_VIEW_NAME,"personReferenceId"), null, null);
111
112 }
113
114
115 panel.setContent(panelContent);
116 getPageActionEventHelper().createPageEvent(ViewAction.VISIT_DOCUMENT_VIEW, ApplicationEventGroup.USER, NAME, parameters, pageId);
117 }
118
119 return panelContent;
120
121 }
122
123
124 }