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.party.pagemode;
20  
21  import org.springframework.beans.factory.annotation.Autowired;
22  import org.springframework.security.access.annotation.Secured;
23  import org.springframework.stereotype.Component;
24  
25  import com.hack23.cia.model.internal.application.data.party.impl.ViewRiksdagenParty;
26  import com.hack23.cia.service.api.DataContainer;
27  import com.hack23.cia.web.impl.ui.application.views.common.chartfactory.api.PartyDocumentChartDataManager;
28  import com.hack23.cia.web.impl.ui.application.views.common.labelfactory.LabelFactory;
29  import com.hack23.cia.web.impl.ui.application.views.common.viewnames.PartyPageMode;
30  import com.vaadin.ui.Layout;
31  import com.vaadin.ui.MenuBar;
32  import com.vaadin.ui.Panel;
33  import com.vaadin.ui.VerticalLayout;
34  
35  /**
36   * The Class DocumentActivityPageModContentFactoryImpl.
37   */
38  @Component
39  public final class PartyDocumentActivityPageModContentFactoryImpl extends AbstractPartyPageModContentFactoryImpl {
40  
41  	/** The Constant DOCUMENT_ACTIVITY. */
42  	private static final String DOCUMENT_ACTIVITY = "Document Activity";
43  
44  	/** The document chart data manager. */
45  	@Autowired
46  	private PartyDocumentChartDataManager documentChartDataManager;
47  
48  	/**
49  	 * Instantiates a new party document activity page mod content factory impl.
50  	 */
51  	public PartyDocumentActivityPageModContentFactoryImpl() {
52  		super();
53  	}
54  
55  	@Override
56  	public boolean matches(final String page, final String parameters) {
57  		return NAME.equals(page) && parameters.contains(PartyPageMode.DOCUMENTACTIVITY.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<ViewRiksdagenParty, String> dataContainer = getApplicationManager()
68  				.getDataContainer(ViewRiksdagenParty.class);
69  
70  		final ViewRiksdagenParty viewRiksdagenParty = dataContainer.load(pageId);
71  
72  		if (viewRiksdagenParty != null) {
73  
74  			getPartyMenuItemFactory().createPartyMenuBar(menuBar, pageId);
75  
76  			LabelFactory.createHeader2Label(panelContent,DOCUMENT_ACTIVITY);
77  
78  			documentChartDataManager.createDocumentHistoryPartyChart(panelContent,pageId);
79  
80  			pageCompleted(parameters, panel, pageId, viewRiksdagenParty);
81  		}
82  		return panelContent;
83  
84  	}
85  
86  }