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.security.access.annotation.Secured;
22  import org.springframework.stereotype.Component;
23  
24  import com.hack23.cia.model.internal.application.data.party.impl.ViewRiksdagenParty;
25  import com.hack23.cia.service.api.DataContainer;
26  import com.hack23.cia.web.impl.ui.application.views.common.viewnames.PageMode;
27  import com.vaadin.ui.Layout;
28  import com.vaadin.ui.MenuBar;
29  import com.vaadin.ui.Panel;
30  import com.vaadin.ui.VerticalLayout;
31  
32  /**
33   * The Class PageVisitHistoryPageModContentFactoryImpl.
34   */
35  @Component
36  public final class PartyPageVisitHistoryPageModContentFactoryImpl extends AbstractPartyPageModContentFactoryImpl {
37  
38  	/**
39  	 * Instantiates a new party page visit history page mod content factory
40  	 * impl.
41  	 */
42  	public PartyPageVisitHistoryPageModContentFactoryImpl() {
43  		super();
44  	}
45  
46  	@Override
47  	public boolean matches(final String page, final String parameters) {
48  		return NAME.equals(page) && parameters.contains(PageMode.PAGEVISITHISTORY.toString());
49  	}
50  
51  	@Secured({ "ROLE_ANONYMOUS", "ROLE_USER", "ROLE_ADMIN" })
52  	@Override
53  	public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
54  		final VerticalLayout panelContent = createPanelContent();
55  
56  		final String pageId = getPageId(parameters);
57  
58  		final DataContainer<ViewRiksdagenParty, String> dataContainer = getApplicationManager()
59  				.getDataContainer(ViewRiksdagenParty.class);
60  
61  		final ViewRiksdagenParty viewRiksdagenParty = dataContainer.load(pageId);
62  
63  		if (viewRiksdagenParty != null) {
64  
65  			getPartyMenuItemFactory().createPartyMenuBar(menuBar, pageId);
66  
67  			createPageVisitHistory(NAME, pageId, panelContent);
68  
69  			pageCompleted(parameters, panel, pageId, viewRiksdagenParty);
70  		}
71  		return panelContent;
72  
73  	}
74  
75  }