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.*;
// TODO Vérifier les extends
// TODO NameMask et DbMaskableEntity à traiter ensemble
@Entity
//@Table(name="utilisateur")
@Table(name="UserTable")
public class User /* extends org.roliste.data.DbTraceableEntity */ implements DisplayNameConfigurable /*, DbValidationEntity */ {
// @Column(name="ID_UTILISATEUR")
......@@ -117,7 +117,7 @@ public class User /* extends org.roliste.data.DbTraceableEntity */ implements Di
private String email;
/**
* The {@link org.roliste.data.db.UserRole}s for this user.
* The {link org.roliste.data.db.UserRole}s for this user.
*/
@ManyToMany
private List<UserRole> roles;
......@@ -129,8 +129,8 @@ public class User /* extends org.roliste.data.DbTraceableEntity */ implements Di
* the returned value without caution.
* @return a {@link List} of {@link UserRole}. Shall not be <code>null</code>.
* @see #setRoles(List)
* @see #addToRole(UserRole)
* @see #removeFromRole(UserRole)
* see #addToRole(UserRole)
* see #removeFromRole(UserRole)
* hibernate.many-to-many
* column="ROLE_FK"
* class="org.roliste.data.db.UserRole"
......
......@@ -8,6 +8,7 @@ import javax.annotation.PostConstruct;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.inject.Named;
import java.util.Date;
import java.util.List;
@Named
......@@ -67,18 +68,31 @@ public class UpdateUserBean {
User user = new User();
user.setActivated(activated);
user.setAnonymous(anonymous);
user.setAttributes(userAttributes);
if (userAttributes != null) {
user.setAttributes(userAttributes);
}
user.setCriticProvider(criticProvider);
user.setDisplayNameMask(displayNameMask);
if (displayNameMask != null) {
user.setDisplayNameMask(displayNameMask);
} else {
user.setDisplayNameMask(DisplayNameMask.PRENOMNOM);
}
user.setEmail(email);
user.setFirstName(firstName);
user.setLastName(lastName);
user.setNickName(nickName);
if (nickName != null && !nickName.isEmpty()) {
user.setNickName(nickName);
}
user.setPassword(password);
user.setPresentation(presentation);
user.setRoles(roles);
if (presentation != null) {
user.setPresentation(presentation);
}
if (roles != null) {
user.setRoles(roles);
}
user.setUsername(username);
user.setVisible(visible);
user.setCreationDate(new Date());
userService.addUser(user);
return "success";
}
......
......@@ -8,4 +8,21 @@ INSERT INTO Country VALUES (8, 'Espagne');
INSERT INTO Country VALUES (9, 'Portugal');
INSERT INTO Country VALUES (10, 'Royaume-Uni');
INSERT INTO Country VALUES (11, 'Allemagne');
INSERT INTO Country VALUES (12, 'Pologne');
\ No newline at end of file
INSERT INTO Country VALUES (12, 'Pologne');
INSERT INTO UserRole VALUES (1, 'VISITEUR', TRUE);
INSERT INTO UserRole VALUES (2, 'RECRUE', TRUE);
INSERT INTO UserRole VALUES (3, 'CONTRIBUTEUR', TRUE);
INSERT INTO UserRole VALUES (4, 'ADMINISTRATEUR', TRUE);
INSERT INTO UserRole VALUES (5, 'RETRAITE', TRUE);
INSERT INTO UserRole VALUES (6, 'ASSOCE', TRUE);
INSERT INTO UserProperty VALUES (1, 'nb_vignettes', 'Nombre de vignettes en home', TRUE);
INSERT INTO UserProperty VALUES (2, 'avatar', 'Lien vers une icône ou une photo', TRUE);
INSERT INTO UserProperty VALUES (3, 'tagline', 'Ligne de présentation pour les contributeurs', TRUE);
INSERT INTO UserProperty VALUES (4, 'taille_listes', 'Nombre d''éléments affichés dans les listes', TRUE);
INSERT INTO UserProperty VALUES (5, 'skin', 'Thème visuel', TRUE);
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);
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);
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);
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);
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);
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 @@
</h:commandLink>-->
</p:column>
<p:column>
<!--<h:commandLink action="#{userListMgr.goToUpdate('user', user.userId)}">
<img src="/images/structure/vide.gif" class="icEdit" alt="" title="Modifier" />
</h:commandLink>-->
<h:commandLink action="add">
<img src="/images/structure/vide.gif" class="icEdit" alt="Modifier" title="Modifier" />
<f:setPropertyActionListener value="#{user.userId}" target="updateUserBean.userId" />
</h:commandLink>
</p:column>
<p:column styleClass="third" sortBy="#{user.username}">
<f:facet name="header">Identifiant</f:facet>
<!-- TODO Dcider de l'avenir de traceable -->
<!-- <h:outputLink value="#{user.traceable.urlRewrite}">-->
<ui:remove>
<!-- <h:outputLink value="#{user.traceable.urlRewrite}">-->
</ui:remove>
<h:outputText value="#{user.username}" />
<!-- </h:outputLink>-->
</p:column>
<p:column styleClass="third" sortBy="#{user.firstName} #{user.lastName}">
<f:facet name="header">Nom</f:facet>
<!--<h:outputLink value="#{user.traceable.urlRewrite}">-->
<ui:remove>
<!--<h:outputLink value="#{user.traceable.urlRewrite}">-->
</ui:remove>
<h:outputText value="#{user.firstName} #{user.lastName}" />
<!--</h:outputLink>-->
</p:column>
......
......@@ -18,8 +18,8 @@
<!-- content -->
<!-- <ui:define name="content">-->
<body>
<h2><h:outputText value="Cration " rendered="#{empty(updateUserBean.userId)}"/>
<h:outputText value="Modification " rendered="#{not empty(updateUserBean.userId)}"/>d'un utilisateur</h2>
<h2><h:outputText value="Cration " rendered="#{updateUserBean.userId == 0}"/>
<h:outputText value="Modification " rendered="#{updateUserBean.userId != 0}"/>d'un utilisateur</h2>
<p>
Les rles sont hirarchiss, et la hirarchie est automatiquement applique lorsque vous
......@@ -37,28 +37,22 @@
<p:panel headerClass="colDroite" bodyClass="colTexte" label="Informations"
switchType="ajax" opened="true">
<h:form>
<!-- <s:validateAll>-->
<table class="noMargin">
<tr>
<td><h:outputLabel for="username">Identifiant *</h:outputLabel></td>
<td><h:inputText id="username" value="#{updateUserBean.username}" required="true" style="width: 175px;" maxlength="50"/></td>
<td><h:message errorClass="errorMsg" infoClass="infoMsg" for="username"/></td>
</tr>
<tr>
<td><h:outputLabel for="firstname">Prnom *</h:outputLabel></td>
<td><h:inputText id="firstname" value="#{updateUserBean.firstName}" required="true" style="width: 175px;" maxlength="50"/></td>
<td><h:message errorClass="errorMsg" infoClass="infoMsg" for="firstname"/></td>
</tr>
<tr>
<td><h:outputLabel for="lastname">Nom *</h:outputLabel></td>
<td><h:inputText id="lastname" value="#{updateUserBean.lastName}" required="true" style="width: 175px;" maxlength="50"/></td>
<td><h:message errorClass="errorMsg" infoClass="infoMsg" for="lastname"/></td>
</tr>
<tr>
<td><h:outputLabel for="nickname">Pseudonyme</h:outputLabel></td>
<td><h:inputText id="nickname" value="#{updateUserBean.nickName}" style="width: 175px;" maxlength="50"/></td>
<td><h:message errorClass="errorMsg" infoClass="infoMsg" for="nickname"/></td>
</tr>
<tr>
<td><h:outputLabel for="mask">Affichage public du nom *</h:outputLabel></td>
......@@ -67,42 +61,37 @@
<f:selectItems value="#{updateUserBean.allDisplayNameMasks}"/>
</h:selectOneMenu>
</td>
<td><h:message errorClass="errorMsg" infoClass="infoMsg" for="mask"/></td>
</tr>
<tr>
<td><h:outputLabel for="email">Adresse email *</h:outputLabel></td>
<td><h:inputText id="email" value="#{updateUserBean.email}" required="true" style="width: 175px;" maxlength="100"><!--<f:validator validatorId="validateEmail"/>--></h:inputText></td>
<td><h:message errorClass="errorMsg" infoClass="infoMsg" for="email"/></td>
</tr>
<tr>
<td><h:outputLabel for="anonymous">Profil Anonyme ?</h:outputLabel></td>
<td><h:selectBooleanCheckbox id="anonymous" value="#{updateUserBean.anonymous}"/></td>
<td><h:message errorClass="errorMsg" infoClass="infoMsg" for="anonymous"/></td>
</tr>
<tr>
<td><h:outputLabel for="password">Mot de passe *</h:outputLabel></td>
<td><h:inputSecret id="password" redisplay="true" value="#{updateUserBean.password}" required="true" style="width: 175px;" maxlength="50"/></td>
<td><h:message errorClass="errorMsg" infoClass="infoMsg" for="password"/></td>
</tr>
<tr>
<td><h:outputLabel for="roles">Rles</h:outputLabel></td>
<td>
<h:selectManyCheckbox id="roles" value="#{updateUserBean.roles}" converter="omnifaces.SelectItemsConverter" layout="pageDirection" >
<f:selectItems value="#{updateUserBean.availableUserRoles}" var="role" label="#{role.rolename}" />
<f:selectItems value="#{updateUserBean.availableUserRoles}" var="role" itemLabel="#{role.rolename}" />
</h:selectManyCheckbox>
</td>
<td><h:message errorClass="errorMsg" infoClass="infoMsg" for="roles"/></td>
</tr>
<tr>
<td valign="top">
<!--
<h:outputLabel for="text">Texte de prsentation</h:outputLabel><br/>
<h:message styleClass="errorMsg" for="text"/>
-->
</td>
<td colspan="2"><!--<rich:editor id="text" value="#{updateUserBean.presentation}" configuration="article-editor"/>--></td>
</tr>
<ui:fragment rendered="#{not empty(updateUserBean.userId)}">
<!--
<ui:fragment rendered="#{updateUserBean.userId != 0}">
<tr>
<td colspan="3" class="taCenter">
<h:dataTable style="width:75%" headerClass="colDroite"
......@@ -120,36 +109,33 @@
</td>
</tr>
</ui:fragment>
-->
<tr>
<td><h:outputLabel for="criticProvider">Archives de critiques ?</h:outputLabel></td>
<td><h:selectBooleanCheckbox id="criticProvider" value="#{updateUserBean.criticProvider}"/></td>
<td><h:message errorClass="errorMsg" infoClass="infoMsg" for="criticProvider"/></td>
</tr>
<tr>
<td><h:outputLabel for="visible">Visible ?</h:outputLabel></td>
<td><h:selectBooleanCheckbox id="visible" value="#{updateUserBean.visible}"/></td>
<td><h:message errorClass="errorMsg" infoClass="infoMsg" for="visible"/></td>
</tr>
<tr>
<td><h:outputLabel for="activated">Activ ?</h:outputLabel></td>
<td><h:selectBooleanCheckbox id="activated" value="#{updateUserBean.activated}"/></td>
<td><h:message errorClass="errorMsg" infoClass="infoMsg" for="activated"/></td>
</tr>
<tr>
<td colspan="3" class="taCenter">
<h:commandButton id="update" value="Enregistrer" action="#{updateUserBean.update}" rendered="#{not empty(updateUserBean.userId)}"/>&#160;
<h:commandButton id="add" value="Crer" action="#{updateUserBean.add}" rendered="#{empty(updateUserBean.userId)}"/>&#160;
<h:commandButton id="cancel" value="Annuler" action="cancel">
</h:commandButton>
<!-- <h:outputText>"</h:outputText>#{updateUserBean.userId}<h:outputText>"</h:outputText>-->
<h:commandButton id="update" value="Enregistrer" action="#{updateUserBean.update}" rendered="#{updateUserBean.userId != 0}"/>&#160;
<h:commandButton id="add" value="Crer" action="#{updateUserBean.add}" rendered="#{updateUserBean.userId == 0}"/>&#160;
<h:button id="cancel" value="Annuler" outcome="cancel"/>
</td>
</tr>
</table>
<!--</s:validateAll>-->
</h:form>
</p:panel>
<p:panel headerClass="colDroite" bodyClass="colTexte" label="Import d'anciennes donnes"
switchType="ajax" opened="true" rendered="#{not empty(updateUserBean.userId)}">
switchType="ajax" opened="true" rendered="#{updateUserBean.userId != 0}">
<h:form>
<!-- <s:validateAll>-->
<p>
......@@ -188,7 +174,7 @@
</h:form>
</p:panel>
<!--
<h:form rendered="#{not empty(updateUserBean.userId)}">
<h:form rendered="#{updateUserBean.userId != 0}">
<h3>Dlgations</h3>
<p>
Les sections suivantes rpertorient les diffrents lments pour lesquels l'utilisateur
......