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   
6   package com.hack23.cia.web.viewfactory.impl.user;
7   
8   import com.hack23.cia.model.application.dto.common.UserSessionDTO;
9   import com.hack23.cia.model.application.impl.common.Agency;
10  import com.hack23.cia.model.application.impl.common.ParliamentChart;
11  import com.hack23.cia.web.common.ImageConstants;
12  import com.hack23.cia.web.viewfactory.api.user.ParliamentMemberListModelAndView;
13  import com.hack23.cia.web.views.common.ActiveUserView;
14  import com.hack23.cia.web.views.components.gridboxes.TopAbsenceGridBox;
15  import com.hack23.cia.web.views.components.gridboxes.TopLosersGridBox;
16  import com.hack23.cia.web.views.components.gridboxes.TopLoyalsGridBox;
17  import com.hack23.cia.web.views.components.gridboxes.TopPresenceGridBox;
18  import com.hack23.cia.web.views.components.gridboxes.TopRebelsGridBox;
19  import com.hack23.cia.web.views.components.gridboxes.TopWinnersGridBox;
20  import com.hack23.cia.web.views.components.panels.ImagePanel;
21  import com.hack23.cia.web.views.components.panels.SimpleComponentPanel;
22  import com.hack23.cia.web.views.user.ParliamentMemberSearchResultPanel;
23  
24  /***
25   * The Class ParliamentMemberListViewFactoryImpl.
26   */
27  public class ParliamentMemberListViewFactoryImpl extends
28          AbstractParliamentViewFactoryImpl<ParliamentMemberListModelAndView> {
29  
30      /***
31       * Instantiates a new parliament member list view factory impl.
32       */
33      public ParliamentMemberListViewFactoryImpl() {
34          super();
35      }
36  
37      /*
38       * (non-Javadoc)
39       * 
40       * @seecom.hack23.cia.web.viewfactory.impl.common.ViewFactory#
41       * getSupportedModelAndView()
42       */
43      @SuppressWarnings("unchecked")
44      @Override
45      public final Class getSupportedModelAndView() {
46          return ParliamentMemberListModelAndView.class;
47      }
48  
49      /*
50       * (non-Javadoc)
51       * 
52       * @seecom.hack23.cia.web.viewfactory.impl.common.AbstractViewFactoryImpl#
53       * processSpecificView
54       * (com.hack23.cia.web.viewfactory.api.common.AbstractModelAndView)
55       */
56      @Override
57      public final void processSpecificView(
58              final ParliamentMemberListModelAndView modelAndView) {
59          final UserSessionDTO userSessionDTO = modelAndView.getUserSessionDTO();
60          
61          switch (modelAndView.getParliamentMemberListViewSpecification()) {
62          case TopWinnersView:
63              ActiveUserView.changeContentView(new SimpleComponentPanel(
64                      userSessionDTO.getLanguageResource(Agency.LanguageContentKey.WINNERS),
65                      ImageConstants.WINNER_ICON_SMALL, new TopWinnersGridBox(modelAndView.getUserSessionDTO(),
66                              (modelAndView).getParliamentMemberList()),userSessionDTO.getLanguageResource(Agency.LanguageContentKey.CHARTS),
67                              ImageConstants.CHART_IMAGE_SMALL, new ImagePanel(ParliamentChart.getFileName(ParliamentChart.Outcome, userSessionDTO.getUserSession().getLanguage())),userSessionDTO));
68              return;
69          case TopLosersView:
70              ActiveUserView.changeContentView(new SimpleComponentPanel(
71                      userSessionDTO.getLanguageResource(Agency.LanguageContentKey.LOSERS),
72                      ImageConstants.LOSER_ICON_SMALL, new TopLosersGridBox(modelAndView.getUserSessionDTO(),
73                              (modelAndView).getParliamentMemberList()),userSessionDTO.getLanguageResource(Agency.LanguageContentKey.CHARTS),
74                              ImageConstants.CHART_IMAGE_SMALL, new ImagePanel(ParliamentChart.getFileName(ParliamentChart.Outcome, userSessionDTO.getUserSession().getLanguage())),userSessionDTO));
75              return;
76          case TopPresentView:
77              ActiveUserView.changeContentView(new SimpleComponentPanel(
78                      userSessionDTO.getLanguageResource(Agency.LanguageContentKey.PRESENCE),
79                      ImageConstants.PRESENCE_ICON_SMALL, new TopPresenceGridBox(modelAndView.getUserSessionDTO(),
80                              (modelAndView).getParliamentMemberList()),userSessionDTO.getLanguageResource(Agency.LanguageContentKey.CHARTS),
81                              ImageConstants.CHART_IMAGE_SMALL, new ImagePanel(ParliamentChart.getFileName(ParliamentChart.ProffessionalBehavior, userSessionDTO.getUserSession().getLanguage())),userSessionDTO));
82              return;
83          case TopAbsentView:
84              ActiveUserView.changeContentView(new SimpleComponentPanel(
85                      userSessionDTO
86                              .getLanguageResource(Agency.LanguageContentKey.ABSENCE),
87                      ImageConstants.ABSENCE_ICON_SMALL, new TopAbsenceGridBox(modelAndView.getUserSessionDTO(),
88                              (modelAndView).getParliamentMemberList()),userSessionDTO.getLanguageResource(Agency.LanguageContentKey.CHARTS),
89                              ImageConstants.CHART_IMAGE_SMALL, new ImagePanel(ParliamentChart.getFileName(ParliamentChart.ProffessionalBehavior, userSessionDTO.getUserSession().getLanguage())),userSessionDTO));
90              return;
91          case TopRebelsView:
92              ActiveUserView
93                      .changeContentView(new SimpleComponentPanel(
94                              userSessionDTO
95                                      .getLanguageResource(Agency.LanguageContentKey.REBELS),
96                              ImageConstants.REBEL_ICON_SMALL,
97                              new TopRebelsGridBox(modelAndView.getUserSessionDTO(),(modelAndView)
98                                      .getParliamentMemberList()),userSessionDTO.getLanguageResource(Agency.LanguageContentKey.CHARTS),
99                                      ImageConstants.CHART_IMAGE_SMALL, new ImagePanel(ParliamentChart.getFileName(ParliamentChart.PoliticalPartyBehavior, userSessionDTO.getUserSession().getLanguage())),userSessionDTO));
100             return;
101         case TopLoyalsView:
102             ActiveUserView.changeContentView(new SimpleComponentPanel(
103                     userSessionDTO.getLanguageResource(Agency.LanguageContentKey.LOYAL),
104                     ImageConstants.LOYAL_ICON_SMALL, new TopLoyalsGridBox(modelAndView.getUserSessionDTO(),
105                             (modelAndView).getParliamentMemberList()),userSessionDTO.getLanguageResource(Agency.LanguageContentKey.CHARTS),
106                             ImageConstants.CHART_IMAGE_SMALL, new ImagePanel(ParliamentChart.getFileName(ParliamentChart.PoliticalPartyBehavior, userSessionDTO.getUserSession().getLanguage())),userSessionDTO));
107             return;
108         case SearchResultView:
109             ActiveUserView
110                     .changeContentView(new ParliamentMemberSearchResultPanel(modelAndView.getUserSessionDTO(),
111                             (modelAndView).getParliamentMemberList()));
112             return;
113         case TopLosersInPartyView:
114         	ActiveUserView.changeContentView(new SimpleComponentPanel(
115                             userSessionDTO
116                                     .getLanguageResource(Agency.LanguageContentKey.LOSERS),
117                             ImageConstants.LOSER_ICON_SMALL,
118                             new TopLosersGridBox(modelAndView.getUserSessionDTO(),(modelAndView)
119                                     .getParliamentMemberList()),userSessionDTO.getLanguageResource(Agency.LanguageContentKey.CHARTS),
120                                     ImageConstants.CHART_IMAGE_SMALL, new ImagePanel(ParliamentChart.getFileName(ParliamentChart.Outcome,modelAndView.getParliamentMemberList().get(0).getPoliticalParty(), userSessionDTO.getUserSession().getLanguage())),userSessionDTO));
121             return;
122         case TopWinnersInPartyView:
123             ActiveUserView.changeContentView(new SimpleComponentPanel(
124                     userSessionDTO
125                             .getLanguageResource(Agency.LanguageContentKey.WINNERS),
126                     ImageConstants.WINNER_ICON_SMALL, new TopWinnersGridBox(modelAndView.getUserSessionDTO(),
127                             (modelAndView).getParliamentMemberList()),userSessionDTO.getLanguageResource(Agency.LanguageContentKey.CHARTS),
128                             ImageConstants.CHART_IMAGE_SMALL, new ImagePanel(ParliamentChart.getFileName(ParliamentChart.Outcome,modelAndView.getParliamentMemberList().get(0).getPoliticalParty(), userSessionDTO.getUserSession().getLanguage())),userSessionDTO));
129             return;
130         case TopAbsentInPartyView:
131             ActiveUserView.changeContentView(new SimpleComponentPanel(
132                     userSessionDTO
133                             .getLanguageResource(Agency.LanguageContentKey.ABSENCE),
134                     ImageConstants.ABSENCE_ICON_SMALL, new TopAbsenceGridBox(modelAndView.getUserSessionDTO(),
135                             (modelAndView).getParliamentMemberList()),userSessionDTO.getLanguageResource(Agency.LanguageContentKey.CHARTS),
136                             ImageConstants.CHART_IMAGE_SMALL, new ImagePanel(ParliamentChart.getFileName(ParliamentChart.ProffessionalBehavior,modelAndView.getParliamentMemberList().get(0).getPoliticalParty(), userSessionDTO.getUserSession().getLanguage())),userSessionDTO));
137             return;
138         case TopPresentInPartyView:
139             ActiveUserView.changeContentView(new SimpleComponentPanel(
140                     userSessionDTO
141                             .getLanguageResource(Agency.LanguageContentKey.PRESENCE),
142                     ImageConstants.PRESENCE_ICON_SMALL, new TopPresenceGridBox(modelAndView.getUserSessionDTO(),
143                             (modelAndView).getParliamentMemberList()),userSessionDTO.getLanguageResource(Agency.LanguageContentKey.CHARTS),
144                             ImageConstants.CHART_IMAGE_SMALL, new ImagePanel(ParliamentChart.getFileName(ParliamentChart.ProffessionalBehavior,modelAndView.getParliamentMemberList().get(0).getPoliticalParty(), userSessionDTO.getUserSession().getLanguage())),userSessionDTO));
145             return;
146         case TopRebelsInPartyView:
147             ActiveUserView.changeContentView(new SimpleComponentPanel(
148                     userSessionDTO
149                             .getLanguageResource(Agency.LanguageContentKey.REBELS),
150                     ImageConstants.REBEL_ICON_SMALL, new TopRebelsGridBox(modelAndView.getUserSessionDTO(),
151                             (modelAndView).getParliamentMemberList()),userSessionDTO.getLanguageResource(Agency.LanguageContentKey.CHARTS),
152                             ImageConstants.CHART_IMAGE_SMALL, new ImagePanel(ParliamentChart.getFileName(ParliamentChart.PoliticalPartyBehavior,modelAndView.getParliamentMemberList().get(0).getPoliticalParty(), userSessionDTO.getUserSession().getLanguage())),userSessionDTO));
153             return;
154         case TopLoyalsInPartyView:
155             ActiveUserView.changeContentView(new SimpleComponentPanel(
156                     userSessionDTO
157                             .getLanguageResource(Agency.LanguageContentKey.LOYAL),
158                     ImageConstants.LOYAL_ICON_SMALL, new TopLoyalsGridBox(modelAndView.getUserSessionDTO(),
159                             (modelAndView).getParliamentMemberList()),userSessionDTO.getLanguageResource(Agency.LanguageContentKey.CHARTS),
160                             ImageConstants.CHART_IMAGE_SMALL, new ImagePanel(ParliamentChart.getFileName(ParliamentChart.PoliticalPartyBehavior,modelAndView.getParliamentMemberList().get(0).getPoliticalParty(), userSessionDTO.getUserSession().getLanguage())),userSessionDTO));
161             return;
162         default:
163             return;
164         }
165     }
166 }