View Javadoc
1   /*
2    * Copyright 2014 James Pether Sörling
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *   http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   *
16   *	$Id$
17   *  $HeadURL$
18  */
19  package com.hack23.cia.web.impl.ui.application.views.user.committee.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.data.committee.impl.ViewRiksdagenCommittee;
27  import com.hack23.cia.model.internal.application.system.impl.ApplicationEventGroup;
28  import com.hack23.cia.service.api.DataContainer;
29  import com.hack23.cia.web.impl.ui.application.action.ViewAction;
30  import com.hack23.cia.web.impl.ui.application.views.common.chartfactory.api.DecisionChartDataManager;
31  import com.hack23.cia.web.impl.ui.application.views.common.labelfactory.LabelFactory;
32  import com.hack23.cia.web.impl.ui.application.views.common.viewnames.CommitteePageMode;
33  import com.vaadin.ui.Layout;
34  import com.vaadin.ui.MenuBar;
35  import com.vaadin.ui.Panel;
36  import com.vaadin.ui.VerticalLayout;
37  
38  /**
39   * The Class CommitteeDecisionTypeDailySummaryPageModContentFactoryImpl2.
40   */
41  @Component
42  public final class CommitteeDecisionTypeDailySummaryPageModContentFactoryImpl2
43  		extends AbstractCommitteePageModContentFactoryImpl {
44  
45  	/** The Constant COMMITTEE. */
46  	private static final String COMMITTEE = "Committee:";
47  
48  	/** The Constant DECISION_TYPE_DAILY_SUMMARY. */
49  	private static final String DECISION_TYPE_DAILY_SUMMARY = "Decision Type Daily Summary";
50  
51  	/** The chart data manager. */
52  	@Autowired
53  	private DecisionChartDataManager chartDataManager;
54  
55  	/**
56  	 * Instantiates a new committee decision type daily summary page mod content
57  	 * factory impl2.
58  	 */
59  	public CommitteeDecisionTypeDailySummaryPageModContentFactoryImpl2() {
60  		super();
61  	}
62  
63  	@Override
64  	public boolean matches(final String page, final String parameters) {
65  		return NAME.equals(page) && (!StringUtils.isEmpty(parameters)
66  				&& parameters.contains(CommitteePageMode.DECISIONTYPEDAILYSUMMARY.toString()));
67  	}
68  
69  	@Secured({ "ROLE_ANONYMOUS", "ROLE_USER", "ROLE_ADMIN" })
70  	@Override
71  	public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
72  		final VerticalLayout panelContent = createPanelContent();
73  
74  		final String pageId = getPageId(parameters);
75  
76  		final DataContainer<ViewRiksdagenCommittee, String> dataContainer = getApplicationManager()
77  				.getDataContainer(ViewRiksdagenCommittee.class);
78  
79  		final ViewRiksdagenCommittee viewRiksdagenCommittee = dataContainer.load(pageId);
80  
81  		if (viewRiksdagenCommittee != null) {
82  
83  			getCommitteeMenuItemFactory().createCommitteeeMenuBar(menuBar, pageId);
84  
85  			LabelFactory.createHeader2Label(panelContent,DECISION_TYPE_DAILY_SUMMARY);
86  
87  			chartDataManager
88  					.createDecisionTypeChart(panelContent,viewRiksdagenCommittee.getEmbeddedId().getOrgCode());
89  
90  			panel.setCaption(COMMITTEE + viewRiksdagenCommittee.getEmbeddedId().getDetail());
91  			getPageActionEventHelper().createPageEvent(ViewAction.VISIT_COMMITTEE_VIEW, ApplicationEventGroup.USER,
92  					NAME, parameters, pageId);
93  		}
94  		return panelContent;
95  
96  	}
97  
98  }