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.politician.pagemode;
20
21 import java.util.List;
22
23 import org.springframework.beans.factory.annotation.Autowired;
24 import org.springframework.security.access.annotation.Secured;
25 import org.springframework.stereotype.Component;
26
27 import com.hack23.cia.model.external.riksdagen.person.impl.AssignmentData;
28 import com.hack23.cia.model.external.riksdagen.person.impl.PersonData;
29 import com.hack23.cia.model.internal.application.data.politician.impl.ViewRiksdagenPolitician;
30 import com.hack23.cia.service.api.DataContainer;
31 import com.hack23.cia.web.impl.ui.application.views.common.chartfactory.api.PoliticianGhantChartManager;
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.PoliticianPageMode;
34 import com.vaadin.ui.Layout;
35 import com.vaadin.ui.MenuBar;
36 import com.vaadin.ui.Panel;
37 import com.vaadin.ui.VerticalLayout;
38
39
40
41
42 @Component
43 public final class PoliticianRoleGhantPageModContentFactoryImpl extends AbstractPoliticianPageModContentFactoryImpl {
44
45 @Autowired
46 private PoliticianGhantChartManager politicianGhantChartManager;
47
48
49
50
51 public PoliticianRoleGhantPageModContentFactoryImpl() {
52 super();
53 }
54
55 @Override
56 public boolean matches(final String page, final String parameters) {
57 return NAME.equals(page) && parameters.contains(PoliticianPageMode.ROLEGHANT.toString());
58 }
59
60 @Secured({ "ROLE_ANONYMOUS", "ROLE_USER", "ROLE_ADMIN" })
61 @Override
62 public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
63 final VerticalLayout panelContent = createPanelContent();
64
65 final String pageId = getPageId(parameters);
66
67 final DataContainer<PersonData, String> dataContainer = getApplicationManager()
68 .getDataContainer(PersonData.class);
69
70 final PersonData personData = dataContainer.load(pageId);
71 if (personData != null) {
72
73 final DataContainer<ViewRiksdagenPolitician, String> politicianDataContainer = getApplicationManager()
74 .getDataContainer(ViewRiksdagenPolitician.class);
75
76 final ViewRiksdagenPolitician viewRiksdagenPolitician = politicianDataContainer.load(personData.getId());
77
78 getPoliticianMenuItemFactory().createPoliticianMenuBar(menuBar, pageId);
79
80 LabelFactory.createHeader2Label(panelContent,PoliticianPageMode.ROLEGHANT.toString());
81
82 final List<AssignmentData> assignmentList = personData.getPersonAssignmentData()
83 .getAssignmentList();
84
85 politicianGhantChartManager.createRoleGhant(panelContent, assignmentList);
86
87 pageCompleted(parameters, panel, pageId, viewRiksdagenPolitician);
88
89 }
90 return panelContent;
91
92 }
93
94 }