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.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.AdminChartDataManager;
29  import com.hack23.cia.web.impl.ui.application.views.common.viewnames.PageMode;
30  import com.hack23.cia.web.impl.ui.application.views.common.viewnames.UserViews;
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   * The Class CommitteeRankingPageVisitHistoryPageModContentFactoryImpl.
38   */
39  @Component
40  public final class CommitteeRankingPageVisitHistoryPageModContentFactoryImpl
41  		extends AbstractCommitteeRankingPageModContentFactoryImpl {
42  
43  	/** The Constant NAME. */
44  	public static final String NAME = UserViews.COMMITTEE_RANKING_VIEW_NAME;
45  
46  	/** The Constant PAGE_VISIT_HISTORY. */
47  	private static final String PAGE_VISIT_HISTORY = "Page Visit History:";
48  
49  	/** The admin chart data manager. */
50  	@Autowired
51  	private AdminChartDataManager adminChartDataManager;
52  
53  	/**
54  	 * Instantiates a new committee ranking page visit history page mod content
55  	 * factory impl.
56  	 */
57  	public CommitteeRankingPageVisitHistoryPageModContentFactoryImpl() {
58  		super();
59  	}
60  
61  	@Override
62  	public boolean matches(final String page, final String parameters) {
63  		return NAME.equals(page) && (!StringUtils.isEmpty(parameters) && parameters.contains(PageMode.PAGEVISITHISTORY.toString()));
64  	}
65  
66  	@Secured({ "ROLE_ANONYMOUS", "ROLE_USER", "ROLE_ADMIN" })
67  	@Override
68  	public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
69  		final VerticalLayout panelContent = createPanelContent();
70  
71  		getCommitteeRankingMenuItemFactory().createCommitteeeRankingMenuBar(menuBar);
72  
73  		final String pageId = getPageId(parameters);
74  
75  		adminChartDataManager.createApplicationActionEventPageModeDailySummaryChart(panelContent,NAME);
76  
77  		panel.setCaption(PAGE_VISIT_HISTORY + parameters);
78  
79  		getPageActionEventHelper().createPageEvent(ViewAction.VISIT_COMMITTEE_RANKING_VIEW, ApplicationEventGroup.USER,
80  				NAME, parameters, pageId);
81  
82  		return panelContent;
83  
84  	}
85  
86  }