1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35 package fr.paris.lutece.plugins.chatbot.modules.stationnement.web;
36
37 import fr.paris.lutece.plugins.chatbot.modules.stationnement.business.NoFeesDay;
38 import fr.paris.lutece.plugins.chatbot.modules.stationnement.business.NoFeesDayHome;
39 import fr.paris.lutece.portal.service.message.AdminMessage;
40 import fr.paris.lutece.portal.service.message.AdminMessageService;
41 import fr.paris.lutece.portal.util.mvc.admin.annotations.Controller;
42 import fr.paris.lutece.portal.util.mvc.commons.annotations.Action;
43 import fr.paris.lutece.portal.util.mvc.commons.annotations.View;
44 import fr.paris.lutece.util.url.UrlItem;
45
46 import java.util.List;
47 import java.util.Map;
48 import javax.servlet.http.HttpServletRequest;
49
50
51
52
53 @Controller( controllerJsp = "ManageNoFeesDays.jsp", controllerPath = "jsp/admin/plugins/chatbot/modules/stationnement/", right = "STATIONNEMENT_NOFEESDAYS_MANAGEMENT" )
54 public class NoFeesDayJspBean extends AbstractManageNoFeesDaysJspBean
55 {
56
57 private static final String TEMPLATE_MANAGE_NOFEESDAYS = "/admin/plugins/chatbot/modules/stationnement/manage_nofeesdays.html";
58 private static final String TEMPLATE_CREATE_NOFEESDAY = "/admin/plugins/chatbot/modules/stationnement/create_nofeesday.html";
59 private static final String TEMPLATE_MODIFY_NOFEESDAY = "/admin/plugins/chatbot/modules/stationnement/modify_nofeesday.html";
60
61
62 private static final String PARAMETER_ID_NOFEESDAY = "id";
63
64
65 private static final String PROPERTY_PAGE_TITLE_MANAGE_NOFEESDAYS = "module.chatbot.stationnement.manage_nofeesdays.pageTitle";
66 private static final String PROPERTY_PAGE_TITLE_MODIFY_NOFEESDAY = "module.chatbot.stationnement.modify_nofeesday.pageTitle";
67 private static final String PROPERTY_PAGE_TITLE_CREATE_NOFEESDAY = "module.chatbot.stationnement.create_nofeesday.pageTitle";
68
69
70 private static final String MARK_NOFEESDAY_LIST = "nofeesday_list";
71 private static final String MARK_NOFEESDAY = "nofeesday";
72
73 private static final String JSP_MANAGE_NOFEESDAYS = "jsp/admin/plugins/chatbot/modules/stationnement/ManageNoFeesDays.jsp";
74
75
76 private static final String MESSAGE_CONFIRM_REMOVE_NOFEESDAY = "module.chatbot.stationnement.message.confirmRemoveNoFeesDay";
77
78
79 private static final String VALIDATION_ATTRIBUTES_PREFIX = "module.chatbot.stationnement.model.entity.nofeesday.attribute.";
80
81
82 private static final String VIEW_MANAGE_NOFEESDAYS = "manageNoFeesDays";
83 private static final String VIEW_CREATE_NOFEESDAY = "createNoFeesDay";
84 private static final String VIEW_MODIFY_NOFEESDAY = "modifyNoFeesDay";
85
86
87 private static final String ACTION_CREATE_NOFEESDAY = "createNoFeesDay";
88 private static final String ACTION_MODIFY_NOFEESDAY = "modifyNoFeesDay";
89 private static final String ACTION_REMOVE_NOFEESDAY = "removeNoFeesDay";
90 private static final String ACTION_CONFIRM_REMOVE_NOFEESDAY = "confirmRemoveNoFeesDay";
91
92
93 private static final String INFO_NOFEESDAY_CREATED = "module.chatbot.stationnement.info.nofeesday.created";
94 private static final String INFO_NOFEESDAY_UPDATED = "module.chatbot.stationnement.info.nofeesday.updated";
95 private static final String INFO_NOFEESDAY_REMOVED = "module.chatbot.stationnement.info.nofeesday.removed";
96
97
98 private NoFeesDay _nofeesday;
99
100
101
102
103
104
105 @View( value = VIEW_MANAGE_NOFEESDAYS, defaultView = true )
106 public String getManageNoFeesDays( HttpServletRequest request )
107 {
108 _nofeesday = null;
109 List<NoFeesDay> listNoFeesDays = NoFeesDayHome.getNoFeesDaysList( );
110 Map<String, Object> model = getPaginatedListModel( request, MARK_NOFEESDAY_LIST, listNoFeesDays, JSP_MANAGE_NOFEESDAYS );
111
112 return getPage( PROPERTY_PAGE_TITLE_MANAGE_NOFEESDAYS, TEMPLATE_MANAGE_NOFEESDAYS, model );
113 }
114
115
116
117
118
119
120
121 @View( VIEW_CREATE_NOFEESDAY )
122 public String getCreateNoFeesDay( HttpServletRequest request )
123 {
124 _nofeesday = ( _nofeesday != null ) ? _nofeesday : new NoFeesDay( );
125
126 Map<String, Object> model = getModel( );
127 model.put( MARK_NOFEESDAY, _nofeesday );
128
129 return getPage( PROPERTY_PAGE_TITLE_CREATE_NOFEESDAY, TEMPLATE_CREATE_NOFEESDAY, model );
130 }
131
132
133
134
135
136
137
138 @Action( ACTION_CREATE_NOFEESDAY )
139 public String doCreateNoFeesDay( HttpServletRequest request )
140 {
141 populate( _nofeesday, request );
142
143
144 if ( !validateBean( _nofeesday, VALIDATION_ATTRIBUTES_PREFIX ) )
145 {
146 return redirectView( request, VIEW_CREATE_NOFEESDAY );
147 }
148
149 NoFeesDayHome.create( _nofeesday );
150 addInfo( INFO_NOFEESDAY_CREATED, getLocale( ) );
151
152 return redirectView( request, VIEW_MANAGE_NOFEESDAYS );
153 }
154
155
156
157
158
159
160
161
162 @Action( ACTION_CONFIRM_REMOVE_NOFEESDAY )
163 public String getConfirmRemoveNoFeesDay( HttpServletRequest request )
164 {
165 int nId = Integer.parseInt( request.getParameter( PARAMETER_ID_NOFEESDAY ) );
166 UrlItem url = new UrlItem( getActionUrl( ACTION_REMOVE_NOFEESDAY ) );
167 url.addParameter( PARAMETER_ID_NOFEESDAY, nId );
168
169 String strMessageUrl = AdminMessageService.getMessageUrl( request, MESSAGE_CONFIRM_REMOVE_NOFEESDAY, url.getUrl( ), AdminMessage.TYPE_CONFIRMATION );
170
171 return redirect( request, strMessageUrl );
172 }
173
174
175
176
177
178
179
180 @Action( ACTION_REMOVE_NOFEESDAY )
181 public String doRemoveNoFeesDay( HttpServletRequest request )
182 {
183 int nId = Integer.parseInt( request.getParameter( PARAMETER_ID_NOFEESDAY ) );
184 NoFeesDayHome.remove( nId );
185 addInfo( INFO_NOFEESDAY_REMOVED, getLocale( ) );
186
187 return redirectView( request, VIEW_MANAGE_NOFEESDAYS );
188 }
189
190
191
192
193
194
195
196 @View( VIEW_MODIFY_NOFEESDAY )
197 public String getModifyNoFeesDay( HttpServletRequest request )
198 {
199 int nId = Integer.parseInt( request.getParameter( PARAMETER_ID_NOFEESDAY ) );
200
201 if ( _nofeesday == null || ( _nofeesday.getId( ) != nId ))
202 {
203 _nofeesday = NoFeesDayHome.findByPrimaryKey( nId );
204 }
205
206 Map<String, Object> model = getModel( );
207 model.put( MARK_NOFEESDAY, _nofeesday );
208
209 return getPage( PROPERTY_PAGE_TITLE_MODIFY_NOFEESDAY, TEMPLATE_MODIFY_NOFEESDAY, model );
210 }
211
212
213
214
215
216
217
218 @Action( ACTION_MODIFY_NOFEESDAY )
219 public String doModifyNoFeesDay( HttpServletRequest request )
220 {
221 populate( _nofeesday, request );
222
223
224 if ( !validateBean( _nofeesday, VALIDATION_ATTRIBUTES_PREFIX ) )
225 {
226 return redirect( request, VIEW_MODIFY_NOFEESDAY, PARAMETER_ID_NOFEESDAY, _nofeesday.getId( ) );
227 }
228
229 NoFeesDayHome.update( _nofeesday );
230 addInfo( INFO_NOFEESDAY_UPDATED, getLocale( ) );
231
232 return redirectView( request, VIEW_MANAGE_NOFEESDAYS );
233 }
234 }