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 java.util.Arrays;
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.external.riksdagen.dokumentlista.impl.DocumentElement;
28 import com.hack23.cia.model.external.riksdagen.dokumentstatus.impl.DocumentData;
29 import com.hack23.cia.model.external.riksdagen.dokumentstatus.impl.DocumentData_;
30 import com.hack23.cia.model.external.riksdagen.dokumentstatus.impl.DocumentProposalData;
31 import com.hack23.cia.model.external.riksdagen.dokumentstatus.impl.DocumentStatusContainer;
32 import com.hack23.cia.model.external.riksdagen.dokumentstatus.impl.DocumentStatusContainer_;
33 import com.hack23.cia.model.external.riksdagen.utskottsforslag.impl.CommitteeProposalComponentData;
34 import com.hack23.cia.model.internal.application.system.impl.ApplicationEventGroup;
35 import com.hack23.cia.service.api.DataContainer;
36 import com.hack23.cia.web.impl.ui.application.action.ViewAction;
37 import com.hack23.cia.web.impl.ui.application.views.common.labelfactory.LabelFactory;
38 import com.hack23.cia.web.impl.ui.application.views.common.viewnames.DocumentPageMode;
39 import com.vaadin.data.util.BeanItem;
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 DocumentDecisionPageModContentFactoryImpl extends AbstractDocumentPageModContentFactoryImpl {
50
51
52 private static final String DOCUMENT_DECISION = "Document Decision";
53
54
55
56
57 public DocumentDecisionPageModContentFactoryImpl() {
58 super();
59 }
60
61 @Override
62 public boolean matches(final String page, final String parameters) {
63 return NAME.equals(page) && (!StringUtils.isEmpty(parameters) && parameters.contains(DocumentPageMode.DOCUMENTDECISION.toString()));
64 }
65
66 @Secured({ "ROLE_ANONYMOUS", "ROLE_USER", "ROLE_ADMIN" })
67 @Override
68 public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
69 final VerticalLayout panelContent = createPanelContent();
70
71 final String pageId = getPageId(parameters);
72
73 final DataContainer<DocumentElement, String> documentElementDataContainer = getApplicationManager()
74 .getDataContainer(DocumentElement.class);
75
76 final DataContainer<DocumentStatusContainer, String> documentStatusContainerDataContainer = getApplicationManager()
77 .getDataContainer(DocumentStatusContainer.class);
78
79 getApplicationManager()
80 .getDataContainer(CommitteeProposalComponentData.class);
81
82 final DocumentElement documentElement = documentElementDataContainer.load(pageId);
83
84 if (documentElement != null) {
85
86 getDocumentMenuItemFactory().createDocumentMenuBar(menuBar, pageId);
87
88 final DocumentStatusContainer documentStatusContainer = documentStatusContainerDataContainer
89 .findByQueryProperty(DocumentStatusContainer.class, DocumentStatusContainer_.document,
90 DocumentData.class, DocumentData_.id, pageId);
91
92
93
94
95 LabelFactory.createHeader2Label(panelContent,DOCUMENT_DECISION);
96
97 if (documentStatusContainer != null && documentStatusContainer.getDocumentProposal() != null
98 && documentStatusContainer.getDocumentProposal().getProposal() != null) {
99
100 getFormFactory().addFormPanelTextFields(panelContent,
101 new BeanItem<>(
102 documentStatusContainer.getDocumentProposal().getProposal()),
103 DocumentProposalData.class,
104 Arrays.asList(new String[] { "committee", "chamber", "processedIn", "decisionType",
105 "proposalNumber", "designation", "wording", "wording2", "wording3",
106 "wording4" }));
107
108 }
109
110 panel.setContent(panelContent);
111 getPageActionEventHelper().createPageEvent(ViewAction.VISIT_DOCUMENT_VIEW, ApplicationEventGroup.USER, NAME, parameters, pageId);
112 }
113
114 return panelContent;
115
116 }
117
118
119 }