Jean-Francois Leveque

Population tables UserRole, UserProperty, UserTable (User réservé). Ajout d'User et liste des Users.

...@@ -9,7 +9,7 @@ import java.util.*; ...@@ -9,7 +9,7 @@ import java.util.*;
9 // TODO Vérifier les extends 9 // TODO Vérifier les extends
10 // TODO NameMask et DbMaskableEntity à traiter ensemble 10 // TODO NameMask et DbMaskableEntity à traiter ensemble
11 @Entity 11 @Entity
12 -//@Table(name="utilisateur") 12 +@Table(name="UserTable")
13 public class User /* extends org.roliste.data.DbTraceableEntity */ implements DisplayNameConfigurable /*, DbValidationEntity */ { 13 public class User /* extends org.roliste.data.DbTraceableEntity */ implements DisplayNameConfigurable /*, DbValidationEntity */ {
14 14
15 // @Column(name="ID_UTILISATEUR") 15 // @Column(name="ID_UTILISATEUR")
...@@ -117,7 +117,7 @@ public class User /* extends org.roliste.data.DbTraceableEntity */ implements Di ...@@ -117,7 +117,7 @@ public class User /* extends org.roliste.data.DbTraceableEntity */ implements Di
117 private String email; 117 private String email;
118 118
119 /** 119 /**
120 - * The {@link org.roliste.data.db.UserRole}s for this user. 120 + * The {link org.roliste.data.db.UserRole}s for this user.
121 */ 121 */
122 @ManyToMany 122 @ManyToMany
123 private List<UserRole> roles; 123 private List<UserRole> roles;
...@@ -129,8 +129,8 @@ public class User /* extends org.roliste.data.DbTraceableEntity */ implements Di ...@@ -129,8 +129,8 @@ public class User /* extends org.roliste.data.DbTraceableEntity */ implements Di
129 * the returned value without caution. 129 * the returned value without caution.
130 * @return a {@link List} of {@link UserRole}. Shall not be <code>null</code>. 130 * @return a {@link List} of {@link UserRole}. Shall not be <code>null</code>.
131 * @see #setRoles(List) 131 * @see #setRoles(List)
132 - * @see #addToRole(UserRole) 132 + * see #addToRole(UserRole)
133 - * @see #removeFromRole(UserRole) 133 + * see #removeFromRole(UserRole)
134 * hibernate.many-to-many 134 * hibernate.many-to-many
135 * column="ROLE_FK" 135 * column="ROLE_FK"
136 * class="org.roliste.data.db.UserRole" 136 * class="org.roliste.data.db.UserRole"
......
...@@ -8,6 +8,7 @@ import javax.annotation.PostConstruct; ...@@ -8,6 +8,7 @@ import javax.annotation.PostConstruct;
8 import javax.enterprise.context.RequestScoped; 8 import javax.enterprise.context.RequestScoped;
9 import javax.inject.Inject; 9 import javax.inject.Inject;
10 import javax.inject.Named; 10 import javax.inject.Named;
11 +import java.util.Date;
11 import java.util.List; 12 import java.util.List;
12 13
13 @Named 14 @Named
...@@ -67,18 +68,31 @@ public class UpdateUserBean { ...@@ -67,18 +68,31 @@ public class UpdateUserBean {
67 User user = new User(); 68 User user = new User();
68 user.setActivated(activated); 69 user.setActivated(activated);
69 user.setAnonymous(anonymous); 70 user.setAnonymous(anonymous);
71 + if (userAttributes != null) {
70 user.setAttributes(userAttributes); 72 user.setAttributes(userAttributes);
73 + }
71 user.setCriticProvider(criticProvider); 74 user.setCriticProvider(criticProvider);
75 + if (displayNameMask != null) {
72 user.setDisplayNameMask(displayNameMask); 76 user.setDisplayNameMask(displayNameMask);
77 + } else {
78 + user.setDisplayNameMask(DisplayNameMask.PRENOMNOM);
79 + }
73 user.setEmail(email); 80 user.setEmail(email);
74 user.setFirstName(firstName); 81 user.setFirstName(firstName);
75 user.setLastName(lastName); 82 user.setLastName(lastName);
83 + if (nickName != null && !nickName.isEmpty()) {
76 user.setNickName(nickName); 84 user.setNickName(nickName);
85 + }
77 user.setPassword(password); 86 user.setPassword(password);
87 + if (presentation != null) {
78 user.setPresentation(presentation); 88 user.setPresentation(presentation);
89 + }
90 + if (roles != null) {
79 user.setRoles(roles); 91 user.setRoles(roles);
92 + }
80 user.setUsername(username); 93 user.setUsername(username);
81 user.setVisible(visible); 94 user.setVisible(visible);
95 + user.setCreationDate(new Date());
82 userService.addUser(user); 96 userService.addUser(user);
83 return "success"; 97 return "success";
84 } 98 }
......
...@@ -9,3 +9,20 @@ INSERT INTO Country VALUES (9, 'Portugal'); ...@@ -9,3 +9,20 @@ INSERT INTO Country VALUES (9, 'Portugal');
9 INSERT INTO Country VALUES (10, 'Royaume-Uni'); 9 INSERT INTO Country VALUES (10, 'Royaume-Uni');
10 INSERT INTO Country VALUES (11, 'Allemagne'); 10 INSERT INTO Country VALUES (11, 'Allemagne');
11 INSERT INTO Country VALUES (12, 'Pologne'); 11 INSERT INTO Country VALUES (12, 'Pologne');
12 +INSERT INTO UserRole VALUES (1, 'VISITEUR', TRUE);
13 +INSERT INTO UserRole VALUES (2, 'RECRUE', TRUE);
14 +INSERT INTO UserRole VALUES (3, 'CONTRIBUTEUR', TRUE);
15 +INSERT INTO UserRole VALUES (4, 'ADMINISTRATEUR', TRUE);
16 +INSERT INTO UserRole VALUES (5, 'RETRAITE', TRUE);
17 +INSERT INTO UserRole VALUES (6, 'ASSOCE', TRUE);
18 +INSERT INTO UserProperty VALUES (1, 'nb_vignettes', 'Nombre de vignettes en home', TRUE);
19 +INSERT INTO UserProperty VALUES (2, 'avatar', 'Lien vers une icône ou une photo', 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);
22 +INSERT INTO UserProperty VALUES (5, 'skin', 'Thème visuel', TRUE);
23 +INSERT INTO UserTable (userId, username, password, firstName, lastName, nickname, email, activated, anonymous, visible, criticProvider) VALUES (1, 'one', 'one', 'Derrick', 'Moss', 'one', 'one@raza.org', TRUE, FALSE, TRUE, TRUE);
24 +INSERT INTO UserTable (userId, username, password, firstName, lastName, nickname, email, activated, anonymous, visible, criticProvider) VALUES (2, 'two', 'two', 'Portia', 'Lin', 'two', 'two@raza.org', TRUE, FALSE, TRUE, TRUE);
25 +INSERT INTO UserTable (userId, username, password, firstName, lastName, nickname, email, activated, anonymous, visible, criticProvider) VALUES (3, 'three', 'three', 'Marcus', 'Boone', 'three', 'three@raza.org', TRUE, FALSE, TRUE, TRUE);
26 +INSERT INTO UserTable (userId, username, password, firstName, lastName, nickname, email, activated, anonymous, visible, criticProvider) VALUES (4, 'four', 'four', 'Ryo', 'Tetsuda', 'four', 'four@raza.org', TRUE, FALSE, TRUE, TRUE);
27 +INSERT INTO UserTable (userId, username, password, firstName, lastName, nickname, email, activated, anonymous, visible, criticProvider) VALUES (5, 'five', 'five', 'Emily', 'Kolburn', 'five', 'five@raza.org', TRUE, FALSE, TRUE, TRUE);
28 +INSERT INTO UserTable (userId, username, password, firstName, lastName, nickname, email, activated, anonymous, visible, criticProvider) VALUES (6, 'six', 'six', 'Kal', 'Varrik', 'six', 'six@raza.org', TRUE, FALSE, TRUE, TRUE);
......
...@@ -61,20 +61,25 @@ ...@@ -61,20 +61,25 @@
61 </h:commandLink>--> 61 </h:commandLink>-->
62 </p:column> 62 </p:column>
63 <p:column> 63 <p:column>
64 - <!--<h:commandLink action="#{userListMgr.goToUpdate('user', user.userId)}"> 64 + <h:commandLink action="add">
65 - <img src="/images/structure/vide.gif" class="icEdit" alt="" title="Modifier" /> 65 + <img src="/images/structure/vide.gif" class="icEdit" alt="Modifier" title="Modifier" />
66 - </h:commandLink>--> 66 + <f:setPropertyActionListener value="#{user.userId}" target="updateUserBean.userId" />
67 + </h:commandLink>
67 </p:column> 68 </p:column>
68 <p:column styleClass="third" sortBy="#{user.username}"> 69 <p:column styleClass="third" sortBy="#{user.username}">
69 <f:facet name="header">Identifiant</f:facet> 70 <f:facet name="header">Identifiant</f:facet>
70 <!-- TODO Dcider de l'avenir de traceable --> 71 <!-- TODO Dcider de l'avenir de traceable -->
71 -<!-- <h:outputLink value="#{user.traceable.urlRewrite}">--> 72 + <ui:remove>
73 + <!-- <h:outputLink value="#{user.traceable.urlRewrite}">-->
74 + </ui:remove>
72 <h:outputText value="#{user.username}" /> 75 <h:outputText value="#{user.username}" />
73 <!-- </h:outputLink>--> 76 <!-- </h:outputLink>-->
74 </p:column> 77 </p:column>
75 <p:column styleClass="third" sortBy="#{user.firstName} #{user.lastName}"> 78 <p:column styleClass="third" sortBy="#{user.firstName} #{user.lastName}">
76 <f:facet name="header">Nom</f:facet> 79 <f:facet name="header">Nom</f:facet>
80 + <ui:remove>
77 <!--<h:outputLink value="#{user.traceable.urlRewrite}">--> 81 <!--<h:outputLink value="#{user.traceable.urlRewrite}">-->
82 + </ui:remove>
78 <h:outputText value="#{user.firstName} #{user.lastName}" /> 83 <h:outputText value="#{user.firstName} #{user.lastName}" />
79 <!--</h:outputLink>--> 84 <!--</h:outputLink>-->
80 </p:column> 85 </p:column>
......
...@@ -18,8 +18,8 @@ ...@@ -18,8 +18,8 @@
18 <!-- content --> 18 <!-- content -->
19 <!-- <ui:define name="content">--> 19 <!-- <ui:define name="content">-->
20 <body> 20 <body>
21 - <h2><h:outputText value="Cration " rendered="#{empty(updateUserBean.userId)}"/> 21 + <h2><h:outputText value="Cration " rendered="#{updateUserBean.userId == 0}"/>
22 - <h:outputText value="Modification " rendered="#{not empty(updateUserBean.userId)}"/>d'un utilisateur</h2> 22 + <h:outputText value="Modification " rendered="#{updateUserBean.userId != 0}"/>d'un utilisateur</h2>
23 23
24 <p> 24 <p>
25 Les rles sont hirarchiss, et la hirarchie est automatiquement applique lorsque vous 25 Les rles sont hirarchiss, et la hirarchie est automatiquement applique lorsque vous
...@@ -37,28 +37,22 @@ ...@@ -37,28 +37,22 @@
37 <p:panel headerClass="colDroite" bodyClass="colTexte" label="Informations" 37 <p:panel headerClass="colDroite" bodyClass="colTexte" label="Informations"
38 switchType="ajax" opened="true"> 38 switchType="ajax" opened="true">
39 <h:form> 39 <h:form>
40 -<!-- <s:validateAll>-->
41 -
42 <table class="noMargin"> 40 <table class="noMargin">
43 <tr> 41 <tr>
44 <td><h:outputLabel for="username">Identifiant *</h:outputLabel></td> 42 <td><h:outputLabel for="username">Identifiant *</h:outputLabel></td>
45 <td><h:inputText id="username" value="#{updateUserBean.username}" required="true" style="width: 175px;" maxlength="50"/></td> 43 <td><h:inputText id="username" value="#{updateUserBean.username}" required="true" style="width: 175px;" maxlength="50"/></td>
46 - <td><h:message errorClass="errorMsg" infoClass="infoMsg" for="username"/></td>
47 </tr> 44 </tr>
48 <tr> 45 <tr>
49 <td><h:outputLabel for="firstname">Prnom *</h:outputLabel></td> 46 <td><h:outputLabel for="firstname">Prnom *</h:outputLabel></td>
50 <td><h:inputText id="firstname" value="#{updateUserBean.firstName}" required="true" style="width: 175px;" maxlength="50"/></td> 47 <td><h:inputText id="firstname" value="#{updateUserBean.firstName}" required="true" style="width: 175px;" maxlength="50"/></td>
51 - <td><h:message errorClass="errorMsg" infoClass="infoMsg" for="firstname"/></td>
52 </tr> 48 </tr>
53 <tr> 49 <tr>
54 <td><h:outputLabel for="lastname">Nom *</h:outputLabel></td> 50 <td><h:outputLabel for="lastname">Nom *</h:outputLabel></td>
55 <td><h:inputText id="lastname" value="#{updateUserBean.lastName}" required="true" style="width: 175px;" maxlength="50"/></td> 51 <td><h:inputText id="lastname" value="#{updateUserBean.lastName}" required="true" style="width: 175px;" maxlength="50"/></td>
56 - <td><h:message errorClass="errorMsg" infoClass="infoMsg" for="lastname"/></td>
57 </tr> 52 </tr>
58 <tr> 53 <tr>
59 <td><h:outputLabel for="nickname">Pseudonyme</h:outputLabel></td> 54 <td><h:outputLabel for="nickname">Pseudonyme</h:outputLabel></td>
60 <td><h:inputText id="nickname" value="#{updateUserBean.nickName}" style="width: 175px;" maxlength="50"/></td> 55 <td><h:inputText id="nickname" value="#{updateUserBean.nickName}" style="width: 175px;" maxlength="50"/></td>
61 - <td><h:message errorClass="errorMsg" infoClass="infoMsg" for="nickname"/></td>
62 </tr> 56 </tr>
63 <tr> 57 <tr>
64 <td><h:outputLabel for="mask">Affichage public du nom *</h:outputLabel></td> 58 <td><h:outputLabel for="mask">Affichage public du nom *</h:outputLabel></td>
...@@ -67,42 +61,37 @@ ...@@ -67,42 +61,37 @@
67 <f:selectItems value="#{updateUserBean.allDisplayNameMasks}"/> 61 <f:selectItems value="#{updateUserBean.allDisplayNameMasks}"/>
68 </h:selectOneMenu> 62 </h:selectOneMenu>
69 </td> 63 </td>
70 - <td><h:message errorClass="errorMsg" infoClass="infoMsg" for="mask"/></td>
71 </tr> 64 </tr>
72 <tr> 65 <tr>
73 <td><h:outputLabel for="email">Adresse email *</h:outputLabel></td> 66 <td><h:outputLabel for="email">Adresse email *</h:outputLabel></td>
74 <td><h:inputText id="email" value="#{updateUserBean.email}" required="true" style="width: 175px;" maxlength="100"><!--<f:validator validatorId="validateEmail"/>--></h:inputText></td> 67 <td><h:inputText id="email" value="#{updateUserBean.email}" required="true" style="width: 175px;" maxlength="100"><!--<f:validator validatorId="validateEmail"/>--></h:inputText></td>
75 - <td><h:message errorClass="errorMsg" infoClass="infoMsg" for="email"/></td>
76 </tr> 68 </tr>
77 <tr> 69 <tr>
78 <td><h:outputLabel for="anonymous">Profil Anonyme ?</h:outputLabel></td> 70 <td><h:outputLabel for="anonymous">Profil Anonyme ?</h:outputLabel></td>
79 <td><h:selectBooleanCheckbox id="anonymous" value="#{updateUserBean.anonymous}"/></td> 71 <td><h:selectBooleanCheckbox id="anonymous" value="#{updateUserBean.anonymous}"/></td>
80 - <td><h:message errorClass="errorMsg" infoClass="infoMsg" for="anonymous"/></td>
81 </tr> 72 </tr>
82 <tr> 73 <tr>
83 <td><h:outputLabel for="password">Mot de passe *</h:outputLabel></td> 74 <td><h:outputLabel for="password">Mot de passe *</h:outputLabel></td>
84 <td><h:inputSecret id="password" redisplay="true" value="#{updateUserBean.password}" required="true" style="width: 175px;" maxlength="50"/></td> 75 <td><h:inputSecret id="password" redisplay="true" value="#{updateUserBean.password}" required="true" style="width: 175px;" maxlength="50"/></td>
85 - <td><h:message errorClass="errorMsg" infoClass="infoMsg" for="password"/></td>
86 </tr> 76 </tr>
87 <tr> 77 <tr>
88 <td><h:outputLabel for="roles">Rles</h:outputLabel></td> 78 <td><h:outputLabel for="roles">Rles</h:outputLabel></td>
89 <td> 79 <td>
90 <h:selectManyCheckbox id="roles" value="#{updateUserBean.roles}" converter="omnifaces.SelectItemsConverter" layout="pageDirection" > 80 <h:selectManyCheckbox id="roles" value="#{updateUserBean.roles}" converter="omnifaces.SelectItemsConverter" layout="pageDirection" >
91 - <f:selectItems value="#{updateUserBean.availableUserRoles}" var="role" label="#{role.rolename}" /> 81 + <f:selectItems value="#{updateUserBean.availableUserRoles}" var="role" itemLabel="#{role.rolename}" />
92 </h:selectManyCheckbox> 82 </h:selectManyCheckbox>
93 </td> 83 </td>
94 - <td><h:message errorClass="errorMsg" infoClass="infoMsg" for="roles"/></td>
95 </tr> 84 </tr>
96 <tr> 85 <tr>
97 <td valign="top"> 86 <td valign="top">
98 <!-- 87 <!--
99 <h:outputLabel for="text">Texte de prsentation</h:outputLabel><br/> 88 <h:outputLabel for="text">Texte de prsentation</h:outputLabel><br/>
100 - <h:message styleClass="errorMsg" for="text"/>
101 --> 89 -->
102 </td> 90 </td>
103 <td colspan="2"><!--<rich:editor id="text" value="#{updateUserBean.presentation}" configuration="article-editor"/>--></td> 91 <td colspan="2"><!--<rich:editor id="text" value="#{updateUserBean.presentation}" configuration="article-editor"/>--></td>
104 </tr> 92 </tr>
105 - <ui:fragment rendered="#{not empty(updateUserBean.userId)}"> 93 + <!--
94 + <ui:fragment rendered="#{updateUserBean.userId != 0}">
106 <tr> 95 <tr>
107 <td colspan="3" class="taCenter"> 96 <td colspan="3" class="taCenter">
108 <h:dataTable style="width:75%" headerClass="colDroite" 97 <h:dataTable style="width:75%" headerClass="colDroite"
...@@ -120,36 +109,33 @@ ...@@ -120,36 +109,33 @@
120 </td> 109 </td>
121 </tr> 110 </tr>
122 </ui:fragment> 111 </ui:fragment>
112 + -->
123 <tr> 113 <tr>
124 <td><h:outputLabel for="criticProvider">Archives de critiques ?</h:outputLabel></td> 114 <td><h:outputLabel for="criticProvider">Archives de critiques ?</h:outputLabel></td>
125 <td><h:selectBooleanCheckbox id="criticProvider" value="#{updateUserBean.criticProvider}"/></td> 115 <td><h:selectBooleanCheckbox id="criticProvider" value="#{updateUserBean.criticProvider}"/></td>
126 - <td><h:message errorClass="errorMsg" infoClass="infoMsg" for="criticProvider"/></td>
127 </tr> 116 </tr>
128 <tr> 117 <tr>
129 <td><h:outputLabel for="visible">Visible ?</h:outputLabel></td> 118 <td><h:outputLabel for="visible">Visible ?</h:outputLabel></td>
130 <td><h:selectBooleanCheckbox id="visible" value="#{updateUserBean.visible}"/></td> 119 <td><h:selectBooleanCheckbox id="visible" value="#{updateUserBean.visible}"/></td>
131 - <td><h:message errorClass="errorMsg" infoClass="infoMsg" for="visible"/></td>
132 </tr> 120 </tr>
133 <tr> 121 <tr>
134 <td><h:outputLabel for="activated">Activ ?</h:outputLabel></td> 122 <td><h:outputLabel for="activated">Activ ?</h:outputLabel></td>
135 <td><h:selectBooleanCheckbox id="activated" value="#{updateUserBean.activated}"/></td> 123 <td><h:selectBooleanCheckbox id="activated" value="#{updateUserBean.activated}"/></td>
136 - <td><h:message errorClass="errorMsg" infoClass="infoMsg" for="activated"/></td>
137 </tr> 124 </tr>
138 <tr> 125 <tr>
139 <td colspan="3" class="taCenter"> 126 <td colspan="3" class="taCenter">
140 - <h:commandButton id="update" value="Enregistrer" action="#{updateUserBean.update}" rendered="#{not empty(updateUserBean.userId)}"/>&#160; 127 +<!-- <h:outputText>"</h:outputText>#{updateUserBean.userId}<h:outputText>"</h:outputText>-->
141 - <h:commandButton id="add" value="Crer" action="#{updateUserBean.add}" rendered="#{empty(updateUserBean.userId)}"/>&#160; 128 + <h:commandButton id="update" value="Enregistrer" action="#{updateUserBean.update}" rendered="#{updateUserBean.userId != 0}"/>&#160;
142 - <h:commandButton id="cancel" value="Annuler" action="cancel"> 129 + <h:commandButton id="add" value="Crer" action="#{updateUserBean.add}" rendered="#{updateUserBean.userId == 0}"/>&#160;
143 - </h:commandButton> 130 + <h:button id="cancel" value="Annuler" outcome="cancel"/>
144 </td> 131 </td>
145 </tr> 132 </tr>
146 </table> 133 </table>
147 - <!--</s:validateAll>-->
148 </h:form> 134 </h:form>
149 </p:panel> 135 </p:panel>
150 136
151 <p:panel headerClass="colDroite" bodyClass="colTexte" label="Import d'anciennes donnes" 137 <p:panel headerClass="colDroite" bodyClass="colTexte" label="Import d'anciennes donnes"
152 - switchType="ajax" opened="true" rendered="#{not empty(updateUserBean.userId)}"> 138 + switchType="ajax" opened="true" rendered="#{updateUserBean.userId != 0}">
153 <h:form> 139 <h:form>
154 <!-- <s:validateAll>--> 140 <!-- <s:validateAll>-->
155 <p> 141 <p>
...@@ -188,7 +174,7 @@ ...@@ -188,7 +174,7 @@
188 </h:form> 174 </h:form>
189 </p:panel> 175 </p:panel>
190 <!-- 176 <!--
191 - <h:form rendered="#{not empty(updateUserBean.userId)}"> 177 + <h:form rendered="#{updateUserBean.userId != 0}">
192 <h3>Dlgations</h3> 178 <h3>Dlgations</h3>
193 <p> 179 <p>
194 Les sections suivantes rpertorient les diffrents lments pour lesquels l'utilisateur 180 Les sections suivantes rpertorient les diffrents lments pour lesquels l'utilisateur
......