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.service.impl.user;
6   
7   import java.util.Date;
8   
9   import com.hack23.cia.model.application.dto.common.UserSessionDTO;
10  import com.hack23.cia.model.application.impl.common.ActionEvent;
11  import com.hack23.cia.model.application.impl.common.UserSession;
12  import com.hack23.cia.model.application.impl.user.CommitteeReportActionEvent;
13  import com.hack23.cia.model.sweden.impl.CommitteeReport;
14  import com.hack23.cia.service.api.common.ServiceResponse;
15  import com.hack23.cia.service.api.user.CommitteeReportRequest;
16  import com.hack23.cia.service.api.user.CommitteeReportResponse;
17  import com.hack23.cia.service.impl.common.ParliamentService;
18  import com.hack23.cia.service.impl.common.UserSessionService;
19  
20  /***
21   * The Class CommitteeReportRequestService.
22   */
23  public class CommitteeReportRequestService extends
24          AbstractParliamentRequestService<CommitteeReportRequest> {
25  
26      /***
27       * Instantiates a new committee report request service.
28       *
29       * @param userSessionService the user session service
30       * @param parliamentService the parliament service
31       */
32      public CommitteeReportRequestService(
33              final UserSessionService userSessionService,
34              final ParliamentService parliamentService) {
35          super(userSessionService, parliamentService);
36      }
37  
38      /*
39       * (non-Javadoc)
40       * 
41       * @see
42       * com.hack23.cia.service.impl.common.AbstractGenericService#createActionEvent
43       * (com.hack23.cia.service.api.common.AbstractServiceRequest,
44       * com.hack23.cia.model.application.UserSession)
45       */
46      @Override
47      public final ActionEvent createActionEvent(
48              final CommitteeReportRequest request, final UserSession userSession) {
49          return new CommitteeReportActionEvent(new Date(), userSession, request
50                  .getCommitteeReportId());
51      }
52  
53      /*
54       * (non-Javadoc)
55       * 
56       * @see com.hack23.cia.service.common.ServiceHandler#getSupportedService()
57       */
58      @SuppressWarnings("unchecked")
59      @Override
60      public final Class getSupportedService() {
61          return CommitteeReportRequest.class;
62      }
63  
64      /*
65       * (non-Javadoc)
66       * 
67       * @seecom.hack23.cia.service.common.AbstractGenericServiceHandler#
68       * handleServiceRequest(com.hack23.cia.service.api.AbstractServiceRequest)
69       */
70      @Override
71      public final ServiceResponse handleServiceRequest(
72              final CommitteeReportRequest request, final UserSessionDTO userSession) {
73          final CommitteeReport committeeReport = getParliamentService()
74                  .loadCommitteeReportById(request.getCommitteeReportId());
75          final CommitteeReportResponse committeeReportResponse = new CommitteeReportResponse(
76                  userSession, committeeReport);
77          return committeeReportResponse;
78      }
79  }