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.admin.system.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.system.impl.ApplicationEventGroup;
26  import com.hack23.cia.web.impl.ui.application.action.ViewAction;
27  import com.hack23.cia.web.impl.ui.application.views.common.chartfactory.api.AdminChartDataManager;
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.AdminViews;
30  import com.hack23.cia.web.impl.ui.application.views.common.viewnames.PageMode;
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 AdminApplicationEventsChartsPageModContentFactoryImpl.
38   */
39  @Component
40  public final class AdminApplicationEventsChartsPageModContentFactoryImpl
41  		extends AbstractAdminSystemPageModContentFactoryImpl {
42  
43  	/** The Constant ADMIN_APPLICATION_ACTION_EVENT. */
44  	private static final String ADMIN_APPLICATION_ACTION_EVENT = "Admin Application Action Event chart";
45  
46  	/** The Constant NAME. */
47  	public static final String NAME = AdminViews.ADMIN_APPLICATIONS_EVENTS_VIEW_NAME;
48  
49  	/** The chart data manager. */
50  	@Autowired
51  	private AdminChartDataManager chartDataManager;
52  
53  	/**
54  	 * Instantiates a new admin application events charts page mod content
55  	 * factory impl.
56  	 */
57  	public AdminApplicationEventsChartsPageModContentFactoryImpl() {
58  		super();
59  	}
60  
61  	@Override
62  	public boolean matches(final String page, final String parameters) {
63  		return parameters != null && NAME.equals(page) && parameters.contains(PageMode.CHARTS.toString());
64  	}
65  
66  	@Secured({ "ROLE_ADMIN" })
67  	@Override
68  	public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
69  		final VerticalLayout content = createPanelContent();
70  
71  		final String pageId = getPageId(parameters);
72  
73  		getMenuItemFactory().createMainPageMenuBar(menuBar);
74  
75  		LabelFactory.createHeader2Label(content, ADMIN_APPLICATION_ACTION_EVENT);
76  
77  		chartDataManager.createApplicationActionEventPageDailySummaryChart(content);
78  
79  		getPageActionEventHelper().createPageEvent(ViewAction.VISIT_ADMIN_APPLICATION_EVENTS_VIEW,
80  				ApplicationEventGroup.ADMIN, NAME, null, pageId);
81  
82  		return content;
83  
84  	}
85  
86  }