JR Utily

exemple d'insert multiligne

...@@ -9,8 +9,10 @@ import org.slf4j.LoggerFactory; ...@@ -9,8 +9,10 @@ import org.slf4j.LoggerFactory;
9 import javax.annotation.PostConstruct; 9 import javax.annotation.PostConstruct;
10 import javax.enterprise.context.RequestScoped; 10 import javax.enterprise.context.RequestScoped;
11 import javax.faces.bean.ManagedProperty; 11 import javax.faces.bean.ManagedProperty;
12 +import javax.faces.bean.SessionScoped;
12 import javax.faces.context.ExternalContext; 13 import javax.faces.context.ExternalContext;
13 import javax.faces.context.FacesContext; 14 import javax.faces.context.FacesContext;
15 +import javax.faces.view.ViewScoped;
14 import javax.inject.Inject; 16 import javax.inject.Inject;
15 import javax.inject.Named; 17 import javax.inject.Named;
16 import java.io.IOException; 18 import java.io.IOException;
...@@ -19,7 +21,7 @@ import java.util.Date; ...@@ -19,7 +21,7 @@ import java.util.Date;
19 import java.util.List; 21 import java.util.List;
20 22
21 @Named 23 @Named
22 -@RequestScoped 24 +@SessionScoped
23 public class UpdateUserBean { 25 public class UpdateUserBean {
24 @Inject 26 @Inject
25 private UserService userService; 27 private UserService userService;
...@@ -63,13 +65,7 @@ public class UpdateUserBean { ...@@ -63,13 +65,7 @@ public class UpdateUserBean {
63 65
64 private boolean activated; 66 private boolean activated;
65 67
66 - public String getUsername() {
67 - return username;
68 - }
69 68
70 - public void setUsername(String username) {
71 - this.username = username;
72 - }
73 69
74 public String add() 70 public String add()
75 { 71 {
...@@ -161,6 +157,104 @@ public class UpdateUserBean { ...@@ -161,6 +157,104 @@ public class UpdateUserBean {
161 return "success"; 157 return "success";
162 } 158 }
163 159
160 +
161 + @PostConstruct
162 + public void init() {
163 + Logger logger = LoggerFactory.getLogger(UpdateUserBean.class);
164 + logger.info("init");
165 + allDisplayNameMasks = sharedService.getAllDisplayNameMasks();
166 + availableUserRoles = sharedService.getAvailableUserRoles();
167 + availableUserProperties = sharedService.getAvailableUserProperties();
168 + }
169 +
170 + public List<UserRole> getAvailableUserRoles() {
171 + return availableUserRoles;
172 + }
173 +
174 + public void setAvailableUserRoles(List<UserRole> availableUserRoles) {
175 + this.availableUserRoles = availableUserRoles;
176 + }
177 +
178 + public String getPresentation() {
179 + return presentation;
180 + }
181 +
182 + public void setPresentation(String presentation) {
183 + this.presentation = presentation;
184 + }
185 +
186 + public List<UserProperty> getAvailableUserProperties() {
187 + return availableUserProperties;
188 + }
189 +
190 + public void setAvailableUserProperties(List<UserProperty> availableUserProperties) {
191 + this.availableUserProperties = availableUserProperties;
192 + }
193 +
194 + public List<UserAttribute> getUserAttributes() {
195 + return userAttributes;
196 + }
197 +
198 + public void setUserAttributes(List<UserAttribute> userAttributes) {
199 + this.userAttributes = userAttributes;
200 + }
201 +
202 + public boolean isCriticProvider() {
203 + return criticProvider;
204 + }
205 +
206 + public void setCriticProvider(boolean criticProvider) {
207 + this.criticProvider = criticProvider;
208 + }
209 +
210 + public boolean isVisible() {
211 + return visible;
212 + }
213 +
214 + public void setVisible(boolean visible) {
215 + this.visible = visible;
216 + }
217 +
218 + public boolean isActivated() {
219 + return activated;
220 + }
221 +
222 + public void setActivated(boolean activated) {
223 + this.activated = activated;
224 + }
225 +
226 + public UserService getUserService() {
227 + return userService;
228 + }
229 +
230 + public void setUserService(UserService userService) {
231 + this.userService = userService;
232 + }
233 +
234 + public SharedService getSharedService() {
235 + return sharedService;
236 + }
237 +
238 + public void setSharedService(SharedService sharedService) {
239 + this.sharedService = sharedService;
240 + }
241 +
242 + public int getUserId() {
243 + return userId;
244 + }
245 +
246 + public void setUserId(int userId) {
247 + this.userId = userId;
248 + }
249 +
250 + public String getUsername() {
251 + return username;
252 + }
253 +
254 + public void setUsername(String username) {
255 + this.username = username;
256 + }
257 +
164 public String getFirstName() { 258 public String getFirstName() {
165 return firstName; 259 return firstName;
166 } 260 }
...@@ -201,14 +295,6 @@ public class UpdateUserBean { ...@@ -201,14 +295,6 @@ public class UpdateUserBean {
201 this.allDisplayNameMasks = allDisplayNameMasks; 295 this.allDisplayNameMasks = allDisplayNameMasks;
202 } 296 }
203 297
204 - public int getUserId() {
205 - return userId;
206 - }
207 -
208 - public void setUserId(int userId) {
209 - this.userId = userId;
210 - }
211 -
212 public String getEmail() { 298 public String getEmail() {
213 return email; 299 return email;
214 } 300 }
...@@ -240,69 +326,4 @@ public class UpdateUserBean { ...@@ -240,69 +326,4 @@ public class UpdateUserBean {
240 public void setRoles(List<UserRole> roles) { 326 public void setRoles(List<UserRole> roles) {
241 this.roles = roles; 327 this.roles = roles;
242 } 328 }
243 -
244 - @PostConstruct
245 - public void init() {
246 - Logger logger = LoggerFactory.getLogger(UpdateUserBean.class);
247 - logger.info("init");
248 - allDisplayNameMasks = sharedService.getAllDisplayNameMasks();
249 - availableUserRoles = sharedService.getAvailableUserRoles();
250 - availableUserProperties = sharedService.getAvailableUserProperties();
251 - }
252 -
253 - public List<UserRole> getAvailableUserRoles() {
254 - return availableUserRoles;
255 - }
256 -
257 - public void setAvailableUserRoles(List<UserRole> availableUserRoles) {
258 - this.availableUserRoles = availableUserRoles;
259 - }
260 -
261 - public String getPresentation() {
262 - return presentation;
263 - }
264 -
265 - public void setPresentation(String presentation) {
266 - this.presentation = presentation;
267 - }
268 -
269 - public List<UserProperty> getAvailableUserProperties() {
270 - return availableUserProperties;
271 - }
272 -
273 - public void setAvailableUserProperties(List<UserProperty> availableUserProperties) {
274 - this.availableUserProperties = availableUserProperties;
275 - }
276 -
277 - public List<UserAttribute> getUserAttributes() {
278 - return userAttributes;
279 - }
280 -
281 - public void setUserAttributes(List<UserAttribute> userAttributes) {
282 - this.userAttributes = userAttributes;
283 - }
284 -
285 - public boolean isCriticProvider() {
286 - return criticProvider;
287 - }
288 -
289 - public void setCriticProvider(boolean criticProvider) {
290 - this.criticProvider = criticProvider;
291 - }
292 -
293 - public boolean isVisible() {
294 - return visible;
295 - }
296 -
297 - public void setVisible(boolean visible) {
298 - this.visible = visible;
299 - }
300 -
301 - public boolean isActivated() {
302 - return activated;
303 - }
304 -
305 - public void setActivated(boolean activated) {
306 - this.activated = activated;
307 - }
308 } 329 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
9 <properties> 9 <properties>
10 <property name="hibernate.hbm2ddl.auto" value="create-drop" /> 10 <property name="hibernate.hbm2ddl.auto" value="create-drop" />
11 <property name="hibernate.hbm2ddl.import_files" value="import.sql"/> 11 <property name="hibernate.hbm2ddl.import_files" value="import.sql"/>
12 -<!-- <property name="hibernate.hbm2ddl.import_files_sql_extractor" value="org.hibernate.tool.hbm2ddl.MultipleLinesSqlCommandExtractor" />--> 12 + <property name="hibernate.hbm2ddl.import_files_sql_extractor" value="org.hibernate.tool.hbm2ddl.MultipleLinesSqlCommandExtractor" />
13 </properties> 13 </properties>
14 </persistence-unit> 14 </persistence-unit>
15 15
......
...@@ -20,12 +20,15 @@ INSERT INTO UserProperty VALUES (2, 'avatar', 'Lien vers une icône ou une photo ...@@ -20,12 +20,15 @@ INSERT INTO UserProperty VALUES (2, 'avatar', 'Lien vers une icône ou une photo
20 INSERT INTO UserProperty VALUES (3, 'tagline', 'Ligne de présentation pour les contributeurs', TRUE); 20 INSERT INTO UserProperty VALUES (3, 'tagline', 'Ligne de présentation pour les contributeurs', TRUE);
21 INSERT INTO UserProperty VALUES (4, 'taille_listes', 'Nombre d''éléments affichés dans les listes', TRUE); 21 INSERT INTO UserProperty VALUES (4, 'taille_listes', 'Nombre d''éléments affichés dans les listes', TRUE);
22 INSERT INTO UserProperty VALUES (5, 'skin', 'Thème visuel', TRUE); 22 INSERT INTO UserProperty VALUES (5, 'skin', 'Thème visuel', TRUE);
23 -INSERT INTO UserTable (USER_ID, username, password, firstName, lastName, nickname, email, activated, anonymous, visible, criticProvider) VALUES (1, 'one', 'one', 'Derrick', 'Moss', 'one', 'one@raza.org', TRUE, FALSE, TRUE, TRUE); 23 +
24 -INSERT INTO UserTable (USER_ID, username, password, firstName, lastName, nickname, email, activated, anonymous, visible, criticProvider) VALUES (2, 'two', 'two', 'Portia', 'Lin', 'two', 'two@raza.org', TRUE, FALSE, TRUE, TRUE); 24 +INSERT INTO UserTable (USER_ID, username, password, firstName, lastName, nickname, email, activated, anonymous, visible, criticProvider) VALUES
25 -INSERT INTO UserTable (USER_ID, username, password, firstName, lastName, nickname, email, activated, anonymous, visible, criticProvider) VALUES (3, 'three', 'three', 'Marcus', 'Boone', 'three', 'three@raza.org', TRUE, FALSE, TRUE, TRUE); 25 + (1, 'one', 'one', 'Derrick', 'Moss', 'one', 'one@raza.org', TRUE, FALSE, TRUE, TRUE),
26 -INSERT INTO UserTable (USER_ID, username, password, firstName, lastName, nickname, email, activated, anonymous, visible, criticProvider) VALUES (4, 'four', 'four', 'Ryo', 'Tetsuda', 'four', 'four@raza.org', TRUE, FALSE, TRUE, TRUE); 26 + (2, 'two', 'two', 'Portia', 'Lin', 'two', 'two@raza.org', TRUE, FALSE, TRUE, TRUE),
27 -INSERT INTO UserTable (USER_ID, username, password, firstName, lastName, nickname, email, activated, anonymous, visible, criticProvider) VALUES (5, 'five', 'five', 'Emily', 'Kolburn', 'five', 'five@raza.org', TRUE, FALSE, TRUE, TRUE); 27 + (3, 'three', 'three', 'Marcus', 'Boone', 'three', 'three@raza.org', TRUE, FALSE, TRUE, TRUE),
28 -INSERT INTO UserTable (USER_ID, username, password, firstName, lastName, nickname, email, activated, anonymous, visible, criticProvider) VALUES (6, 'six', 'six', 'Kal', 'Varrik', 'six', 'six@raza.org', TRUE, FALSE, TRUE, TRUE); 28 + (4, 'four', 'four', 'Ryo', 'Tetsuda', 'four', 'four@raza.org', TRUE, FALSE, TRUE, TRUE),
29 + (5, 'five', 'five', 'Emily', 'Kolburn', 'five', 'five@raza.org', TRUE, FALSE, TRUE, TRUE),
30 + (6, 'six', 'six', 'Kal', 'Varrik', 'six', 'six@raza.org', TRUE, FALSE, TRUE, TRUE);
31 +
29 INSERT INTO UserTable_UserRole VALUES (1,2); 32 INSERT INTO UserTable_UserRole VALUES (1,2);
30 INSERT INTO UserTable_UserRole VALUES (2,2); 33 INSERT INTO UserTable_UserRole VALUES (2,2);
31 INSERT INTO UserTable_UserRole VALUES (3,2); 34 INSERT INTO UserTable_UserRole VALUES (3,2);
......