1
2
3
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.BallotRequest;
9 import com.hack23.cia.service.api.user.BallotResponse;
10 import com.hack23.cia.web.action.user.BallotAction;
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.VotesModelAndView;
14 import com.hack23.cia.web.viewfactory.api.user.VotesModelAndView.VotesViewSpecification;
15
16 /***
17 * The Class BallotActionHandler.
18 */
19 public class BallotActionHandler extends
20 AbstractUserActionHandler<BallotAction, BallotRequest, BallotResponse> {
21
22 /***
23 * Instantiates a new ballot action handler.
24 *
25 * @param viewFactoryService the view factory service
26 * @param applicationManager the application manager
27 */
28 public BallotActionHandler(final ViewFactoryService viewFactoryService,
29 final ApplicationManager applicationManager) {
30 super(viewFactoryService, applicationManager);
31 }
32
33
34
35
36
37
38
39 @Override
40 public final BallotRequest createServiceRequest(final BallotAction action) {
41 return new BallotRequest(getUserStateService().getUserSessionId(),
42 action.getBallotId());
43 }
44
45
46
47
48
49
50 @SuppressWarnings("unchecked")
51 @Override
52 public final Class getSupportedAction() {
53 return BallotAction.class;
54 }
55
56
57
58
59
60
61
62
63 @Override
64 public final ModelAndView handleSuccessResponse(final BallotAction action,
65 final BallotResponse response) {
66 return new VotesModelAndView(response.getUserSessionDTO(), action,
67 VotesViewSpecification.BallotView, response
68 .getFindLastVotesByBallotId());
69 }
70
71 }