1
2
3
4
5 package com.hack23.cia.web.controller.admin;
6
7 import com.hack23.cia.model.application.impl.admin.AgencyActionEvent;
8 import com.hack23.cia.service.api.admin.AgencyRequest;
9 import com.hack23.cia.service.api.admin.AgencyResponse;
10 import com.hack23.cia.service.api.application.ApplicationManager;
11 import com.hack23.cia.web.action.admin.AgencyAction;
12 import com.hack23.cia.web.viewfactory.api.admin.AgencyModelAndView;
13 import com.hack23.cia.web.viewfactory.api.admin.AgencyModelAndView.AgencyViewSpecification;
14 import com.hack23.cia.web.viewfactory.api.common.ModelAndView;
15 import com.hack23.cia.web.viewfactory.api.common.ViewFactoryService;
16
17 /***
18 * The Class AgencyActionHandler.
19 */
20 public class AgencyActionHandler extends
21 AbstractAdminActionHandler<AgencyAction, AgencyRequest, AgencyResponse> {
22
23 /***
24 * Instantiates a new agency action handler.
25 *
26 * @param viewFactoryService the view factory service
27 * @param applicationManager the application manager
28 */
29 public AgencyActionHandler(final ViewFactoryService viewFactoryService,
30 final ApplicationManager applicationManager) {
31 super(viewFactoryService, applicationManager);
32 }
33
34
35
36
37
38
39
40 @Override
41 public final AgencyRequest createServiceRequest(final AgencyAction action) {
42 AgencyRequest agencyRequest = null;
43 if (action.getOperation().equals(AgencyActionEvent.Operation.UpdateAgency)) {
44 agencyRequest= new AgencyRequest(getUserStateService().getUserSessionId(),
45 action.getOperation(), action.getAgencyId(),action.getAgencyDto());
46 } else {
47 agencyRequest= new AgencyRequest(getUserStateService().getUserSessionId(),
48 action.getOperation(), action.getAgencyId());
49 }
50
51 return agencyRequest;
52 }
53
54
55
56
57
58
59 @SuppressWarnings("unchecked")
60 @Override
61 public final Class getSupportedAction() {
62 return AgencyAction.class;
63 }
64
65
66
67
68
69
70
71
72 @Override
73 public final ModelAndView handleSuccessResponse(final AgencyAction action,
74 final AgencyResponse response) {
75 return new AgencyModelAndView(response.getUserSessionDTO(), action,
76 AgencyViewSpecification.ConfigureAgencyView, response
77 .getAgency());
78 }
79
80 }