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.user;
6   
7   import com.hack23.cia.service.api.application.ApplicationManager;
8   import com.hack23.cia.service.api.user.ParliamentMemberRequest;
9   import com.hack23.cia.service.api.user.ParliamentMemberResponse;
10  import com.hack23.cia.web.action.user.ParliamentMemberAction;
11  import com.hack23.cia.web.viewfactory.api.common.ModelAndView;
12  import com.hack23.cia.web.viewfactory.api.common.ViewFactoryService;
13  import com.hack23.cia.web.viewfactory.api.user.ParliamentMemberSummaryModelAndView;
14  import com.hack23.cia.web.viewfactory.api.user.ParliamentMemberSummaryModelAndView.ParliamentMemberSummaryViewSpecification;
15  
16  /***
17   * The Class ParliamentMemberActionHandler.
18   */
19  public class ParliamentMemberActionHandler
20          extends
21          AbstractUserActionHandler<ParliamentMemberAction, ParliamentMemberRequest, ParliamentMemberResponse> {
22  
23      /***
24       * Instantiates a new parliament member action handler.
25       *
26       * @param viewFactoryService the view factory service
27       * @param applicationManager the application manager
28       */
29      public ParliamentMemberActionHandler(
30              final ViewFactoryService viewFactoryService,
31              final ApplicationManager applicationManager) {
32          super(viewFactoryService, applicationManager);
33      }
34  
35      /*
36       * (non-Javadoc)
37       * 
38       * @seecom.hack23.cia.web.controller.common.AbstractGenericHandler#
39       * createServiceRequest(com.hack23.cia.web.action.common.AbstractAction)
40       */
41      @Override
42      public final ParliamentMemberRequest createServiceRequest(
43              final ParliamentMemberAction action) {
44          return new ParliamentMemberRequest(getUserStateService()
45                  .getUserSessionId(), action.getParliamentMemberId());
46      }
47  
48      /*
49       * (non-Javadoc)
50       * 
51       * @see com.hack23.cia.web.controller.ActionHandler#getSupportedAction()
52       */
53      @SuppressWarnings("unchecked")
54      @Override
55      public final Class getSupportedAction() {
56          return ParliamentMemberAction.class;
57      }
58  
59      /*
60       * (non-Javadoc)
61       * 
62       * @seecom.hack23.cia.web.controller.common.AbstractGenericHandler#
63       * handleSuccessResponse(com.hack23.cia.web.action.common.AbstractAction,
64       * com.hack23.cia.service.api.common.AbstractServiceResponse)
65       */
66      @Override
67      public final ModelAndView handleSuccessResponse(
68              final ParliamentMemberAction action,
69              final ParliamentMemberResponse response) {
70          return new ParliamentMemberSummaryModelAndView(
71                  response.getUserSessionDTO(),
72                  action,
73                  ParliamentMemberSummaryViewSpecification.ParliamentMemberSummaryView,
74                  response.getParliamentMember(), response.getFriendList(),
75                  response.getEnemyList(), response.getFriendPartyList(),
76                  response.getEnemyPartyList(), response.getVotes(), response
77                          .getRegisterInformation());
78      }
79  }