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.parliament.pagemode;
20
21 import org.apache.commons.lang3.StringUtils;
22 import org.springframework.beans.factory.annotation.Autowired;
23 import org.springframework.security.access.annotation.Secured;
24 import org.springframework.stereotype.Component;
25
26 import com.hack23.cia.model.internal.application.system.impl.ApplicationEventGroup;
27 import com.hack23.cia.web.impl.ui.application.action.ViewAction;
28 import com.hack23.cia.web.impl.ui.application.views.common.chartfactory.api.PartyChartDataManager;
29 import com.hack23.cia.web.impl.ui.application.views.common.viewnames.ChartIndicators;
30 import com.hack23.cia.web.impl.ui.application.views.common.viewnames.PageMode;
31 import com.vaadin.ui.Layout;
32 import com.vaadin.ui.MenuBar;
33 import com.vaadin.ui.Panel;
34 import com.vaadin.ui.VerticalLayout;
35
36
37
38
39 @Component
40 public final class ParliamentChartsPartyWinnerPageModContentFactoryImpl extends AbstractParliamentPageModContentFactoryImpl {
41
42
43 private static final String PARTY_WINNER_DAILY_AVERAGE_FOR_ALL_BALLOTS = "Party Winner, daily average for all ballots";
44
45
46 @Autowired
47 private PartyChartDataManager partyChartDataManager;
48
49
50
51
52
53 public ParliamentChartsPartyWinnerPageModContentFactoryImpl() {
54 super();
55 }
56
57 @Override
58 public boolean matches(final String page, final String parameters) {
59 return NAME.equals(page) && !StringUtils.isEmpty(parameters) && parameters.contains(PageMode.CHARTS.toString())
60 && parameters.contains(ChartIndicators.PARTYWINNER.toString());
61 }
62
63 @Secured({ "ROLE_ANONYMOUS", "ROLE_USER", "ROLE_ADMIN" })
64 @Override
65 public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
66 final VerticalLayout panelContent = createPanelContent();
67 getParliamentMenuItemFactory().createParliamentTopicMenu(menuBar);
68
69
70 final String pageId = getPageId(parameters);
71
72 partyChartDataManager.createPartyWinnerChart(panelContent);
73
74 getPageActionEventHelper().createPageEvent(ViewAction.VISIT_TEST_CHART_VIEW, ApplicationEventGroup.USER, NAME,
75 parameters, pageId);
76 panel.setCaption(PARTY_WINNER_DAILY_AVERAGE_FOR_ALL_BALLOTS);
77
78 return panelContent;
79
80 }
81
82 }