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.politician.pagemode;
20  
21  import org.springframework.security.access.annotation.Secured;
22  import org.springframework.stereotype.Component;
23  
24  import com.hack23.cia.model.external.riksdagen.person.impl.PersonData;
25  import com.hack23.cia.model.internal.application.data.politician.impl.ViewRiksdagenPolitician;
26  import com.hack23.cia.service.api.DataContainer;
27  import com.hack23.cia.web.impl.ui.application.views.common.labelfactory.LabelFactory;
28  import com.hack23.cia.web.impl.ui.application.views.common.viewnames.PageMode;
29  import com.vaadin.ui.Layout;
30  import com.vaadin.ui.MenuBar;
31  import com.vaadin.ui.Panel;
32  import com.vaadin.ui.VerticalLayout;
33  
34  /**
35   * The Class ChartsPageModContentFactoryImpl.
36   */
37  @Component
38  public final class PoliticianChartsPageModContentFactoryImpl extends AbstractPoliticianPageModContentFactoryImpl {
39  
40  	/** The Constant CHARTS_NOT_IMPLEMENTED. */
41  	private static final String CHARTS_NOT_IMPLEMENTED = "Charts Not Implemented";
42  
43  
44  	/**
45  	 * Instantiates a new politician charts page mod content factory impl.
46  	 */
47  	public PoliticianChartsPageModContentFactoryImpl() {
48  		super();
49  	}
50  
51  	@Override
52  	public boolean matches(final String page, final String parameters) {
53  		return NAME.equals(page) && parameters.contains(PageMode.CHARTS.toString());
54  	}
55  
56  	@Secured({ "ROLE_ANONYMOUS", "ROLE_USER", "ROLE_ADMIN" })
57  	@Override
58  	public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
59  		final VerticalLayout panelContent = createPanelContent();
60  
61  		final String pageId = getPageId(parameters);
62  
63  		final DataContainer<PersonData, String> dataContainer = getApplicationManager()
64  				.getDataContainer(PersonData.class);
65  
66  		final PersonData personData = dataContainer.load(pageId);
67  		if (personData != null) {
68  
69  			final DataContainer<ViewRiksdagenPolitician, String> politicianDataContainer = getApplicationManager()
70  					.getDataContainer(ViewRiksdagenPolitician.class);
71  
72  			final ViewRiksdagenPolitician viewRiksdagenPolitician = politicianDataContainer.load(personData.getId());
73  
74  			getPoliticianMenuItemFactory().createPoliticianMenuBar(menuBar, pageId);
75  
76  			LabelFactory.createHeader2Label(panelContent,CHARTS_NOT_IMPLEMENTED);
77  
78  			pageCompleted(parameters, panel, pageId, viewRiksdagenPolitician);
79  
80  		}
81  		return panelContent;
82  
83  	}
84  
85  }