1
2
3
4
5 package com.hack23.cia.web.controller.admin;
6
7 import com.hack23.cia.service.api.admin.LanguageContentRequest;
8 import com.hack23.cia.service.api.admin.LanguageContentResponse;
9 import com.hack23.cia.service.api.application.ApplicationManager;
10 import com.hack23.cia.web.action.admin.LanguageContentAction;
11 import com.hack23.cia.web.viewfactory.api.admin.LanguageAgencyModelAndView;
12 import com.hack23.cia.web.viewfactory.api.admin.LanguageContentModelAndView;
13 import com.hack23.cia.web.viewfactory.api.admin.LanguageAgencyModelAndView.LanguageAgencyViewSpecification;
14 import com.hack23.cia.web.viewfactory.api.admin.LanguageContentModelAndView.LanguageContentViewSpecification;
15 import com.hack23.cia.web.viewfactory.api.common.ModelAndView;
16 import com.hack23.cia.web.viewfactory.api.common.ViewFactoryService;
17
18 /***
19 * The Class LanguageContentActionHandler.
20 */
21 public class LanguageContentActionHandler
22 extends
23 AbstractAdminActionHandler<LanguageContentAction, LanguageContentRequest, LanguageContentResponse> {
24
25 /***
26 * Instantiates a new language content action handler.
27 *
28 * @param viewFactoryService the view factory service
29 * @param applicationManager the application manager
30 */
31 public LanguageContentActionHandler(
32 final ViewFactoryService viewFactoryService,
33 final ApplicationManager applicationManager) {
34 super(viewFactoryService, applicationManager);
35 }
36
37
38
39
40
41
42
43 @Override
44 public final LanguageContentRequest createServiceRequest(
45 final LanguageContentAction action) {
46 return new LanguageContentRequest(getUserStateService().getUserSessionId(),
47 action.getOperation(), action.getAgency(),action.getLanguageContent());
48 }
49
50
51
52
53
54
55 @SuppressWarnings("unchecked")
56 @Override
57 public final Class getSupportedAction() {
58 return LanguageContentAction.class;
59 }
60
61
62
63
64
65
66
67
68 @Override
69 public final ModelAndView handleSuccessResponse(
70 final LanguageContentAction action, final LanguageContentResponse response) {
71 ModelAndView modelAndView = null;
72
73 switch (action.getOperation()) {
74 case Update:
75 modelAndView = new LanguageContentModelAndView(
76 response.getUserSessionDTO(),
77 action,
78 LanguageContentViewSpecification.ConfigureLanguageContentView,
79 response.getAgency(), response.getLanguageContent());
80 break;
81 case Delete:
82 modelAndView = new LanguageAgencyModelAndView(
83 response.getUserSessionDTO(),
84 action,
85 LanguageAgencyViewSpecification.ConfigureAgencyLanguageView,
86 response.getAgency(), response.getLanguage());
87 break;
88 default:
89 break;
90 }
91
92 return modelAndView;
93 }
94
95 }