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 org.springframework.beans.factory.annotation.Autowired;
22
23 import com.hack23.cia.model.internal.application.data.politician.impl.ViewRiksdagenPolitician;
24 import com.hack23.cia.model.internal.application.system.impl.ApplicationEventGroup;
25 import com.hack23.cia.web.impl.ui.application.action.ViewAction;
26 import com.hack23.cia.web.impl.ui.application.views.common.menufactory.api.PoliticianMenuItemFactory;
27 import com.hack23.cia.web.impl.ui.application.views.common.pagemode.AbstractPageModContentFactoryImpl;
28 import com.hack23.cia.web.impl.ui.application.views.common.viewnames.UserViews;
29 import com.vaadin.ui.Component;
30
31
32
33
34 abstract class AbstractPoliticianPageModContentFactoryImpl extends AbstractPageModContentFactoryImpl {
35
36
37 public static final String NAME = UserViews.POLITICIAN_VIEW_NAME;
38
39
40 private static final String POLITICIAN = "Politician:";
41
42
43 private static final long DAYS_PER_STANDARD_YEAR = 365L;
44
45
46 @Autowired
47 private PoliticianMenuItemFactory politicianMenuItemFactory;
48
49
50
51
52
53 AbstractPoliticianPageModContentFactoryImpl() {
54 super();
55 }
56
57
58
59
60
61
62
63
64 protected final String convertToYearsString(final long totalDays) {
65 final long years = totalDays / DAYS_PER_STANDARD_YEAR;
66 final long days = totalDays - years * DAYS_PER_STANDARD_YEAR;
67
68 return years + " Years " + days + " days";
69 }
70
71
72
73
74
75
76
77
78
79
80
81
82
83 protected final void pageCompleted(final String parameters, final Component panel, final String pageId,
84 final ViewRiksdagenPolitician viewRiksdagenPolitician) {
85 getPageActionEventHelper().createPageEvent(ViewAction.VISIT_POLITICIAN_VIEW, ApplicationEventGroup.USER,
86 UserViews.POLITICIAN_VIEW_NAME, parameters, pageId);
87
88 panel.setCaption(POLITICIAN + viewRiksdagenPolitician.getFirstName() + ' '
89 + viewRiksdagenPolitician.getLastName() + '(' + viewRiksdagenPolitician.getParty() + ')');
90 }
91
92
93
94
95
96
97 protected final PoliticianMenuItemFactory getPoliticianMenuItemFactory() {
98 return politicianMenuItemFactory;
99 }
100
101 }