Jean-Francois Leveque

Compile (WIP sur updateUser.xhtml et le reste de la transition User)

......@@ -2,6 +2,7 @@ package org.legrog.application;
import org.legrog.entities.Country;
import org.legrog.entities.DisplayNameMask;
import org.legrog.entities.UserProperty;
import org.legrog.entities.UserRole;
import java.util.List;
......@@ -16,4 +17,6 @@ public interface SharedService {
List<UserRole> getAvailableUserRoles();
List<UserProperty> getAvailableUserProperties();
}
\ No newline at end of file
......
......@@ -16,6 +16,8 @@ public class SharedServiceSpring implements SharedService {
CountryRepository countryRepository;
@Inject
UserRoleRepository userRoleRepository;
@Inject
UserPropertyRepository userPropertyRepository;
private List<DisplayNameMask> allDisplayNameMasks;
......@@ -43,4 +45,6 @@ public class SharedServiceSpring implements SharedService {
public List<UserRole> getAvailableUserRoles() {
return userRoleRepository.findAll();
}
public List<UserProperty> getAvailableUserProperties() { return userPropertyRepository.findAll(); }
}
......
......@@ -425,7 +425,7 @@ public class User /* extends org.roliste.data.DbTraceableEntity */ implements Di
/**
* The list of attributes / properties for this user.
*/
// private List<UserAttribute> _attrs;
private List<UserAttribute> userAttributes;
/**
* Retrieve this user's attributes.
......@@ -440,22 +440,22 @@ public class User /* extends org.roliste.data.DbTraceableEntity */ implements Di
* @return a {@link java.util.List} of user attributes linked to this. Shall not be <code>null</code>.
* @see #setAttributes(java.util.List)
*/
/*
public List<UserAttribute> getAttributes()
{
return _attrs;
return userAttributes;
}
*/
/**
* @param attribs the List of attributes for this user.
* @see #getAttributes()
*/
/*
public void setAttributes(List<UserAttribute> attribs)
{
_attrs = attribs;
this.userAttributes = attribs;
}
*/
/**
* The {@link org.roliste.data.db.GamingEvent}s this user's visited.
*/
......
package org.legrog.entities;
import javax.persistence.*;
@Entity
public class UserAttribute {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private int userAttributeId;
public int getUserAttributeId() {
return userAttributeId;
}
/**
* The linked user.
*/
@ManyToOne
private User user;
/**
* Retrieve the user this attribute is attached to.
* @hibernate.many-to-one
* column="ID_UTILISATEUR"
* class="org.roliste.data.db.User"
* not-null="true"
* access="property"
* lazy="proxy"
* properties-name="PropertyPerUser"
* foreign-key="FK_ATTRIBUTUTILISATEUR_UTILISATEUR"
* @return the {link org.roliste.data.db.User} this attribute is attached to.
* Shall not be <code>null</code>.
* see #setUser(org.roliste.data.db.User)
*/
public User getUser() {
return user;
}
/**
* Set the user this attribute is attached to.
* @param user the new {link org.roliste.data.db.User} this attribute will be attached to. Shall not be <code>null</code>.
* @see #getUser()
*/
public void setUser(User user) {
this.user = user;
}
/**
* The linked property.
*/
@ManyToOne
private UserProperty userProperty;
/**
* Retrieve the property this attribute is attached to.
* @hibernate.many-to-one
* column="ID_PROP"
* class="org.roliste.data.db.UserProperty"
* not-null="true"
* access="property"
* lazy="false"
* properties-name="PropertyPerUser"
* foreign-key="FK_ATTRIBUTUTILISATEUR_PROPRIETE"
* @return the {link org.roliste.data.db.UserProperty} this attribute is attached to.
* Shall not be <code>null</code>.
* see #setProperty(org.roliste.data.db.UserProperty)
*/
public UserProperty getProperty() {
return userProperty;
}
/**
* Set the property this attribute is attached to.
* @param prop the new {link org.roliste.data.db.UserProperty} this attribute will be attached to. Shall not be <code>null</code>.
* @see #getProperty()
*/
public void setProperty(UserProperty prop) {
userProperty = prop;
}
/**
* The property value.
*/
private String value;
/**
* Returns the property value.
* @return the {@link String} value. If property is known to be some other kind of value, you shall
* convert it yourself. May be <code>null</code>, in cases where the sole existence of the attribute
* is the value, or for unset attributes.
* @see #setValue(String)
* @hibernate.property
* column="ATTR_VALUE"
* access="property"
* length="200"
*/
public String getValue() {
return value;
}
/**
* Initializes attribute value.
* @param value the new {@link String} value.
* @see #getValue()
*/
public void setValue(String value) {
this.value = value;
}
/**
* Returns a string representation of this user attribute definition.
* @return a string representing this user attribute definition.
* @hidden
*/
public String toString()
{
StringBuilder sb = new StringBuilder();
sb.append("ID_ATTR=");
sb.append(getUserAttributeId());
sb.append(" ATTR_PROP=");
sb.append(userProperty);
sb.append(" ATTR_VALUE=");
sb.append(value);
return sb.toString();
}
}
package org.legrog.entities;
import org.springframework.data.jpa.repository.JpaRepository;
public interface UserAttributeRepository extends JpaRepository<UserAttribute, Integer> {
}
package org.legrog.entities;
import javax.persistence.*;
@Entity
public class UserProperty {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private int userPropertyId;
/**
*
* hibernate.id
* generator-class="identity"
* column="ID_PROP"
* access="property"
*/
public Integer getUserPropertyId() {
return userPropertyId;
}
/**
* The property name.
*/
private String name;
/**
* Returns the property name.
* @return the {@link String} attribute identifier.
* @see #setName(String)
* hibernate.property
* column="ATTR_NAME"
* not-null="true"
* unique="true"
* access="property"
* length="50"
*/
public String getName() {
return name;
}
/**
* Initializes the property name.
* @param name the new {@link String} identifier.
* @see #getName()
*/
public void setName(String name) {
this.name = name;
}
/**
* The property tag.
*/
private String tag;
/**
* Returns the property tag.
* @return the {@link String} value.
* @see #setTag(String)
* hibernate.property
* column="PROP_TAG"
* access="property"
* length="100"
*/
public String getTag() {
return tag;
}
/**
* Initializes property tag.
* @param tag the new {@link String} tag.
* @see #getTag()
*/
public void setTag(String tag) {
this.tag = tag;
}
/**
* The property validation status.
* A property may be temporarily deactivated.
*/
private boolean visible;
/**
* Indicates if the property is visible / usable.
* If not, users should not be able to access the privileges
* they inherit from having this property set.
* @return the visible flag.
* @see #setVisible(boolean)
* hibernate.property
* column="IND_VISIBLE"
* access="property"
*/
public boolean isVisible() {
return visible;
}
/**
* Initializes the property visible flag.
* @param visible the new flag value.
* @see #isVisible
*/
public void setVisible(boolean visible) {
this.visible = visible;
}
/**
* Returns a string representation of this property definition.
* @return a string representing this property definition.
* hidden
*/
public String toString()
{
StringBuilder sb = new StringBuilder();
sb.append("ID_PROP=");
sb.append(getUserPropertyId());
sb.append(" PROP_NAME=");
sb.append(name);
sb.append(" PROP_TAG=");
sb.append(tag);
sb.append(" IND_VISIBLE=");
sb.append(visible);
return sb.toString();
}
}
\ No newline at end of file
package org.legrog.entities;
import org.springframework.data.jpa.repository.JpaRepository;
public interface UserPropertyRepository extends JpaRepository<UserProperty, Integer> {
}
......@@ -2,9 +2,7 @@ package org.legrog.presentation;
import org.legrog.application.SharedService;
import org.legrog.application.UserService;
import org.legrog.entities.DisplayNameMask;
import org.legrog.entities.User;
import org.legrog.entities.UserRole;
import org.legrog.entities.*;
import javax.annotation.PostConstruct;
import javax.enterprise.context.RequestScoped;
......@@ -14,7 +12,7 @@ import java.util.List;
@Named
@RequestScoped
public class AddUserBean {
public class UpdateUserBean {
@Inject
private UserService userService;
@Inject
......@@ -36,6 +34,8 @@ public class AddUserBean {
private List<UserRole> availableUserRoles;
private List<UserProperty> availableUserProperties;
private String email;
private boolean anonymous;
......@@ -46,6 +46,14 @@ public class AddUserBean {
private String presentation;
private List<UserAttribute> userAttributes;
private boolean criticProvider;
private boolean visible;
private boolean activated;
public String getUsername() {
return username;
}
......@@ -146,6 +154,7 @@ public class AddUserBean {
public void init() {
allDisplayNameMasks = sharedService.getAllDisplayNameMasks();
availableUserRoles = sharedService.getAvailableUserRoles();
availableUserProperties = sharedService.getAvailableUserProperties();
}
public List<UserRole> getAvailableUserRoles() {
......@@ -163,4 +172,44 @@ public class AddUserBean {
public void setPresentation(String presentation) {
this.presentation = presentation;
}
public List<UserProperty> getAvailableUserProperties() {
return availableUserProperties;
}
public void setAvailableUserProperties(List<UserProperty> availableUserProperties) {
this.availableUserProperties = availableUserProperties;
}
public List<UserAttribute> getUserAttributes() {
return userAttributes;
}
public void setUserAttributes(List<UserAttribute> userAttributes) {
this.userAttributes = userAttributes;
}
public boolean isCriticProvider() {
return criticProvider;
}
public void setCriticProvider(boolean criticProvider) {
this.criticProvider = criticProvider;
}
public boolean isVisible() {
return visible;
}
public void setVisible(boolean visible) {
this.visible = visible;
}
public boolean isActivated() {
return activated;
}
public void setActivated(boolean activated) {
this.activated = activated;
}
}
\ No newline at end of file
......
......@@ -33,7 +33,7 @@
</navigation-case>
<navigation-case>
<from-outcome>addUser</from-outcome>
<to-view-id>/addUser.xhtml</to-view-id>
<to-view-id>/addUser_short.xhtml</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>listUsers</from-outcome>
......@@ -50,7 +50,7 @@
</navigation-rule>
<navigation-rule>
<from-view-id>/addUser.xhtml</from-view-id>
<from-view-id>/addUser_short.xhtml</from-view-id>
<navigation-case>
<from-outcome>success</from-outcome>
<to-view-id>/listUsers_short.xhtml</to-view-id>
......
......@@ -13,9 +13,9 @@
<h:panelGrid columns="2">
<h:outputText value="Username de l'utilisateur"/>
<h:inputText value='#{addUserBean.username}'/>
<h:inputText value='#{updateUserBean.username}'/>
<h:outputText value='Add'/>
<h:commandButton action="#{addUserBean.add}" value="Add"/>
<h:commandButton action="#{updateUserBean.add}" value="Add"/>
</h:panelGrid>
</h:form>
</body>
......
......@@ -12,10 +12,10 @@
</h:commandLink>
</h:form>
<f:metadata>
<f:event type="preRenderView" listener="#{addUserBean.onload}" />
<f:event type="preRenderView" listener="#{updateUserBean.onload}" />
</f:metadata>
<ul>
<ui:repeat value="#{addUserBean.users}" var="user">
<ui:repeat value="#{updateUserBean.users}" var="user">
<li>#{user.username}</li>
</ui:repeat>
</ul>
......
This diff is collapsed. Click to expand it.