1
2
3
4
5
6 package com.hack23.cia.web.viewfactory.impl.user;
7
8 import org.apache.commons.logging.Log;
9 import org.apache.commons.logging.LogFactory;
10
11 import com.hack23.cia.web.viewfactory.api.user.UserModelAndView;
12 import com.hack23.cia.web.views.common.ActiveUserView;
13 import com.hack23.cia.web.views.user.LoginPanel;
14 import com.hack23.cia.web.views.user.WelcomePanel;
15
16 /***
17 * The Class UserViewFactoryImpl.
18 */
19 public class UserViewFactoryImpl extends
20 AbstractUserViewFactoryImpl<UserModelAndView> {
21
22 /*** The Constant LOGGER. */
23 private static final Log LOGGER = LogFactory
24 .getLog(UserViewFactoryImpl.class);
25
26 /*** The menu factory. */
27 private final MenuFactory menuFactory;
28
29 /*** The top number. */
30 private final int topNumber;
31
32 /***
33 * Instantiates a new user view factory impl.
34 *
35 * @param menuFactory the menu factory
36 * @param topNumber the top number
37 */
38 public UserViewFactoryImpl(final MenuFactory menuFactory,
39 final int topNumber) {
40 super();
41 this.menuFactory = menuFactory;
42 this.topNumber = topNumber;
43 }
44
45
46
47
48
49
50
51 @SuppressWarnings("unchecked")
52 @Override
53 public final Class getSupportedModelAndView() {
54 return UserModelAndView.class;
55 }
56
57
58
59
60
61
62
63
64 @Override
65 public final void processSpecificView(final UserModelAndView modelAndView) {
66 switch (modelAndView.getUserViewSpecification()) {
67 case WelcomePageView:
68 ActiveUserView.changeContentView(new WelcomePanel(modelAndView.getUserSessionDTO()));
69 return;
70 case LoginView:
71 ActiveUserView.changeContentView(new LoginPanel(modelAndView.getUserSessionDTO()));
72 return;
73 case LogoutView:
74 ActiveUserView.changeContentView(new WelcomePanel(modelAndView.getUserSessionDTO()));
75 ActiveUserView.changeActiveMenu(menuFactory.createApplicationMenu(
76 modelAndView.getUserSessionDTO(),modelAndView.getPoliticalParties(), topNumber));
77 return;
78 case UserHomeView:
79 ActiveUserView.changeContentView(new WelcomePanel(modelAndView.getUserSessionDTO()));
80 ActiveUserView.changeActiveMenu(menuFactory.createApplicationMenu(
81 modelAndView.getUserSessionDTO(),modelAndView.getPoliticalParties(), topNumber));
82 return;
83 default:
84 LOGGER
85 .warn("Not implemented :" + modelAndView.getUserViewSpecification());
86 return;
87 }
88 }
89 }