1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package com.hack23.cia.web.impl.ui.application.action;
20
21 import org.apache.commons.lang.StringUtils;
22 import org.springframework.beans.factory.annotation.Autowired;
23 import org.springframework.stereotype.Service;
24 import org.springframework.web.context.request.RequestContextHolder;
25
26 import com.hack23.cia.model.internal.application.system.impl.ApplicationEventGroup;
27 import com.hack23.cia.model.internal.application.system.impl.ApplicationOperationType;
28 import com.hack23.cia.service.api.ApplicationManager;
29 import com.hack23.cia.service.api.action.application.CreateApplicationEventRequest;
30 import com.hack23.cia.web.impl.ui.application.util.UserContextUtil;
31
32
33
34
35 @Service
36 public final class PageActionEventHelperImpl implements PageActionEventHelper {
37
38
39 @Autowired
40 private ApplicationManager applicationManager;
41
42
43
44
45 public PageActionEventHelperImpl() {
46 super();
47 }
48
49
50 @Override
51 public void createPageEvent(final ViewAction viewAction,final ApplicationEventGroup applicationEventGroup,final String page, final String pageMode, final String elementId) {
52
53
54
55 String pageModeToUse;
56
57 if (pageMode != null && elementId != null && pageMode.contains(elementId)) {
58 pageModeToUse= pageMode.replace(elementId, "").replace("/", "");
59 } else {
60 pageModeToUse = pageMode;
61 }
62
63 if ((pageModeToUse == null || "".equals(pageModeToUse)) && ApplicationEventGroup.USER == applicationEventGroup) {
64 pageModeToUse="Overview";
65 }
66
67 final CreateApplicationEventRequest serviceRequest = new CreateApplicationEventRequest();
68 serviceRequest.setSessionId(RequestContextHolder.currentRequestAttributes().getSessionId());
69
70 serviceRequest.setEventGroup(applicationEventGroup);
71 serviceRequest.setApplicationOperation(ApplicationOperationType.READ);
72
73 serviceRequest.setPage(StringUtils.defaultString(page));
74 serviceRequest.setPageMode(StringUtils.defaultString(pageModeToUse));
75 serviceRequest.setElementId(StringUtils.defaultString(elementId));
76
77 serviceRequest.setActionName(viewAction.toString());
78
79 serviceRequest.setUserId(UserContextUtil.getUserIdFromSecurityContext());
80
81 serviceRequest.setApplicationMessage(viewAction.toString());
82
83 applicationManager
84 .service(serviceRequest);
85 }
86
87 }