View Javadoc

1   /*
2   Copyright 2010 James Pether Sörling Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 
3   	$Id
4   */
5   package com.hack23.cia.web.controller.admin;
6   
7   import com.hack23.cia.service.api.admin.LanguageRequest;
8   import com.hack23.cia.service.api.admin.LanguageResponse;
9   import com.hack23.cia.service.api.application.ApplicationManager;
10  import com.hack23.cia.web.action.admin.LanguageAgencyAction;
11  import com.hack23.cia.web.viewfactory.api.admin.AgencyModelAndView;
12  import com.hack23.cia.web.viewfactory.api.admin.LanguageAgencyModelAndView;
13  import com.hack23.cia.web.viewfactory.api.admin.LanguageContentModelAndView;
14  import com.hack23.cia.web.viewfactory.api.admin.AgencyModelAndView.AgencyViewSpecification;
15  import com.hack23.cia.web.viewfactory.api.admin.LanguageAgencyModelAndView.LanguageAgencyViewSpecification;
16  import com.hack23.cia.web.viewfactory.api.admin.LanguageContentModelAndView.LanguageContentViewSpecification;
17  import com.hack23.cia.web.viewfactory.api.common.ModelAndView;
18  import com.hack23.cia.web.viewfactory.api.common.ViewFactoryService;
19  
20  /***
21   * The Class LanguageAgencyActionHandler.
22   */
23  public class LanguageAgencyActionHandler
24          extends
25          AbstractAdminActionHandler<LanguageAgencyAction, LanguageRequest, LanguageResponse> {
26  
27      /***
28       * Instantiates a new language agency action handler.
29       *
30       * @param viewFactoryService the view factory service
31       * @param applicationManager the application manager
32       */
33      public LanguageAgencyActionHandler(
34              final ViewFactoryService viewFactoryService,
35              final ApplicationManager applicationManager) {
36          super(viewFactoryService, applicationManager);
37      }
38  
39      /*
40       * (non-Javadoc)
41       * 
42       * @seecom.hack23.cia.web.controller.common.AbstractGenericHandler#
43       * createServiceRequest(com.hack23.cia.web.action.common.AbstractAction)
44       */
45      @Override
46      public final LanguageRequest createServiceRequest(
47              final LanguageAgencyAction action) {
48          return new LanguageRequest(getUserStateService().getUserSessionId(),
49                  action.getOperation(), action.getAgency(), action.getLanguage());
50      }
51  
52      /*
53       * (non-Javadoc)
54       * 
55       * @see com.hack23.cia.web.controller.ActionHandler#getSupportedAction()
56       */
57      @SuppressWarnings("unchecked")
58      @Override
59      public final Class getSupportedAction() {
60          return LanguageAgencyAction.class;
61      }
62  
63      /*
64       * (non-Javadoc)
65       * 
66       * @seecom.hack23.cia.web.controller.common.AbstractGenericHandler#
67       * handleSuccessResponse(com.hack23.cia.web.action.common.AbstractAction,
68       * com.hack23.cia.service.api.common.AbstractServiceResponse)
69       */
70      @Override
71      public final ModelAndView handleSuccessResponse(
72              final LanguageAgencyAction action, final LanguageResponse response) {
73          ModelAndView modelAndView = null;
74  
75          switch (action.getOperation()) {
76          case Update:
77              modelAndView = new LanguageAgencyModelAndView(
78                      response.getUserSessionDTO(),
79                      action,
80                      LanguageAgencyViewSpecification.ConfigureAgencyLanguageView,
81                      response.getAgency(), response.getLanguage());
82              break;
83          case Delete:
84              modelAndView = new AgencyModelAndView(response.getUserSessionDTO(),
85                      action, AgencyViewSpecification.ConfigureAgencyView,
86                      response.getAgency());
87              break;
88          case AddLanguageContent:
89              modelAndView = new LanguageContentModelAndView(response.getUserSessionDTO(),
90                      action, LanguageContentViewSpecification.ConfigureLanguageContentView,
91                      response.getAgency(),response.getLanguageContent());                        
92              break;
93          default:
94              break;
95          }
96  
97          return modelAndView;
98      }
99  
100 }