Jean-Francois Leveque

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

...@@ -2,6 +2,7 @@ package org.legrog.application; ...@@ -2,6 +2,7 @@ package org.legrog.application;
2 2
3 import org.legrog.entities.Country; 3 import org.legrog.entities.Country;
4 import org.legrog.entities.DisplayNameMask; 4 import org.legrog.entities.DisplayNameMask;
5 +import org.legrog.entities.UserProperty;
5 import org.legrog.entities.UserRole; 6 import org.legrog.entities.UserRole;
6 7
7 import java.util.List; 8 import java.util.List;
...@@ -16,4 +17,6 @@ public interface SharedService { ...@@ -16,4 +17,6 @@ public interface SharedService {
16 17
17 List<UserRole> getAvailableUserRoles(); 18 List<UserRole> getAvailableUserRoles();
18 19
20 + List<UserProperty> getAvailableUserProperties();
21 +
19 } 22 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -16,6 +16,8 @@ public class SharedServiceSpring implements SharedService { ...@@ -16,6 +16,8 @@ public class SharedServiceSpring implements SharedService {
16 CountryRepository countryRepository; 16 CountryRepository countryRepository;
17 @Inject 17 @Inject
18 UserRoleRepository userRoleRepository; 18 UserRoleRepository userRoleRepository;
19 + @Inject
20 + UserPropertyRepository userPropertyRepository;
19 21
20 private List<DisplayNameMask> allDisplayNameMasks; 22 private List<DisplayNameMask> allDisplayNameMasks;
21 23
...@@ -43,4 +45,6 @@ public class SharedServiceSpring implements SharedService { ...@@ -43,4 +45,6 @@ public class SharedServiceSpring implements SharedService {
43 public List<UserRole> getAvailableUserRoles() { 45 public List<UserRole> getAvailableUserRoles() {
44 return userRoleRepository.findAll(); 46 return userRoleRepository.findAll();
45 } 47 }
48 +
49 + public List<UserProperty> getAvailableUserProperties() { return userPropertyRepository.findAll(); }
46 } 50 }
......
...@@ -425,7 +425,7 @@ public class User /* extends org.roliste.data.DbTraceableEntity */ implements Di ...@@ -425,7 +425,7 @@ public class User /* extends org.roliste.data.DbTraceableEntity */ implements Di
425 /** 425 /**
426 * The list of attributes / properties for this user. 426 * The list of attributes / properties for this user.
427 */ 427 */
428 -// private List<UserAttribute> _attrs; 428 + private List<UserAttribute> userAttributes;
429 429
430 /** 430 /**
431 * Retrieve this user's attributes. 431 * Retrieve this user's attributes.
...@@ -440,22 +440,22 @@ public class User /* extends org.roliste.data.DbTraceableEntity */ implements Di ...@@ -440,22 +440,22 @@ public class User /* extends org.roliste.data.DbTraceableEntity */ implements Di
440 * @return a {@link java.util.List} of user attributes linked to this. Shall not be <code>null</code>. 440 * @return a {@link java.util.List} of user attributes linked to this. Shall not be <code>null</code>.
441 * @see #setAttributes(java.util.List) 441 * @see #setAttributes(java.util.List)
442 */ 442 */
443 - /* 443 +
444 public List<UserAttribute> getAttributes() 444 public List<UserAttribute> getAttributes()
445 { 445 {
446 - return _attrs; 446 + return userAttributes;
447 } 447 }
448 -*/ 448 +
449 /** 449 /**
450 * @param attribs the List of attributes for this user. 450 * @param attribs the List of attributes for this user.
451 * @see #getAttributes() 451 * @see #getAttributes()
452 */ 452 */
453 - /* 453 +
454 public void setAttributes(List<UserAttribute> attribs) 454 public void setAttributes(List<UserAttribute> attribs)
455 { 455 {
456 - _attrs = attribs; 456 + this.userAttributes = attribs;
457 } 457 }
458 -*/ 458 +
459 /** 459 /**
460 * The {@link org.roliste.data.db.GamingEvent}s this user's visited. 460 * The {@link org.roliste.data.db.GamingEvent}s this user's visited.
461 */ 461 */
......
1 +package org.legrog.entities;
2 +
3 +import javax.persistence.*;
4 +
5 +@Entity
6 +public class UserAttribute {
7 + @Id
8 + @GeneratedValue(strategy = GenerationType.AUTO)
9 + private int userAttributeId;
10 +
11 + public int getUserAttributeId() {
12 + return userAttributeId;
13 + }
14 +
15 + /**
16 + * The linked user.
17 + */
18 + @ManyToOne
19 + private User user;
20 +
21 + /**
22 + * Retrieve the user this attribute is attached to.
23 + * @hibernate.many-to-one
24 + * column="ID_UTILISATEUR"
25 + * class="org.roliste.data.db.User"
26 + * not-null="true"
27 + * access="property"
28 + * lazy="proxy"
29 + * properties-name="PropertyPerUser"
30 + * foreign-key="FK_ATTRIBUTUTILISATEUR_UTILISATEUR"
31 + * @return the {link org.roliste.data.db.User} this attribute is attached to.
32 + * Shall not be <code>null</code>.
33 + * see #setUser(org.roliste.data.db.User)
34 + */
35 + public User getUser() {
36 + return user;
37 + }
38 +
39 + /**
40 + * Set the user this attribute is attached to.
41 + * @param user the new {link org.roliste.data.db.User} this attribute will be attached to. Shall not be <code>null</code>.
42 + * @see #getUser()
43 + */
44 + public void setUser(User user) {
45 + this.user = user;
46 + }
47 +
48 + /**
49 + * The linked property.
50 + */
51 + @ManyToOne
52 + private UserProperty userProperty;
53 +
54 + /**
55 + * Retrieve the property this attribute is attached to.
56 + * @hibernate.many-to-one
57 + * column="ID_PROP"
58 + * class="org.roliste.data.db.UserProperty"
59 + * not-null="true"
60 + * access="property"
61 + * lazy="false"
62 + * properties-name="PropertyPerUser"
63 + * foreign-key="FK_ATTRIBUTUTILISATEUR_PROPRIETE"
64 + * @return the {link org.roliste.data.db.UserProperty} this attribute is attached to.
65 + * Shall not be <code>null</code>.
66 + * see #setProperty(org.roliste.data.db.UserProperty)
67 + */
68 + public UserProperty getProperty() {
69 + return userProperty;
70 + }
71 +
72 + /**
73 + * Set the property this attribute is attached to.
74 + * @param prop the new {link org.roliste.data.db.UserProperty} this attribute will be attached to. Shall not be <code>null</code>.
75 + * @see #getProperty()
76 + */
77 + public void setProperty(UserProperty prop) {
78 + userProperty = prop;
79 + }
80 +
81 + /**
82 + * The property value.
83 + */
84 + private String value;
85 +
86 + /**
87 + * Returns the property value.
88 + * @return the {@link String} value. If property is known to be some other kind of value, you shall
89 + * convert it yourself. May be <code>null</code>, in cases where the sole existence of the attribute
90 + * is the value, or for unset attributes.
91 + * @see #setValue(String)
92 + * @hibernate.property
93 + * column="ATTR_VALUE"
94 + * access="property"
95 + * length="200"
96 + */
97 + public String getValue() {
98 + return value;
99 + }
100 +
101 + /**
102 + * Initializes attribute value.
103 + * @param value the new {@link String} value.
104 + * @see #getValue()
105 + */
106 + public void setValue(String value) {
107 + this.value = value;
108 + }
109 +
110 + /**
111 + * Returns a string representation of this user attribute definition.
112 + * @return a string representing this user attribute definition.
113 + * @hidden
114 + */
115 + public String toString()
116 + {
117 + StringBuilder sb = new StringBuilder();
118 +
119 + sb.append("ID_ATTR=");
120 + sb.append(getUserAttributeId());
121 +
122 + sb.append(" ATTR_PROP=");
123 + sb.append(userProperty);
124 +
125 + sb.append(" ATTR_VALUE=");
126 + sb.append(value);
127 +
128 + return sb.toString();
129 + }
130 +
131 +}
1 +package org.legrog.entities;
2 +
3 +import org.springframework.data.jpa.repository.JpaRepository;
4 +
5 +public interface UserAttributeRepository extends JpaRepository<UserAttribute, Integer> {
6 +}
1 +package org.legrog.entities;
2 +
3 +import javax.persistence.*;
4 +
5 +@Entity
6 +public class UserProperty {
7 + @Id
8 + @GeneratedValue(strategy = GenerationType.AUTO)
9 + private int userPropertyId;
10 +
11 + /**
12 + *
13 + * hibernate.id
14 + * generator-class="identity"
15 + * column="ID_PROP"
16 + * access="property"
17 + */
18 + public Integer getUserPropertyId() {
19 + return userPropertyId;
20 + }
21 +
22 + /**
23 + * The property name.
24 + */
25 + private String name;
26 +
27 + /**
28 + * Returns the property name.
29 + * @return the {@link String} attribute identifier.
30 + * @see #setName(String)
31 + * hibernate.property
32 + * column="ATTR_NAME"
33 + * not-null="true"
34 + * unique="true"
35 + * access="property"
36 + * length="50"
37 + */
38 + public String getName() {
39 + return name;
40 + }
41 +
42 + /**
43 + * Initializes the property name.
44 + * @param name the new {@link String} identifier.
45 + * @see #getName()
46 + */
47 + public void setName(String name) {
48 + this.name = name;
49 + }
50 +
51 + /**
52 + * The property tag.
53 + */
54 + private String tag;
55 +
56 + /**
57 + * Returns the property tag.
58 + * @return the {@link String} value.
59 + * @see #setTag(String)
60 + * hibernate.property
61 + * column="PROP_TAG"
62 + * access="property"
63 + * length="100"
64 + */
65 + public String getTag() {
66 + return tag;
67 + }
68 +
69 + /**
70 + * Initializes property tag.
71 + * @param tag the new {@link String} tag.
72 + * @see #getTag()
73 + */
74 + public void setTag(String tag) {
75 + this.tag = tag;
76 + }
77 +
78 + /**
79 + * The property validation status.
80 + * A property may be temporarily deactivated.
81 + */
82 + private boolean visible;
83 +
84 + /**
85 + * Indicates if the property is visible / usable.
86 + * If not, users should not be able to access the privileges
87 + * they inherit from having this property set.
88 + * @return the visible flag.
89 + * @see #setVisible(boolean)
90 + * hibernate.property
91 + * column="IND_VISIBLE"
92 + * access="property"
93 + */
94 + public boolean isVisible() {
95 + return visible;
96 + }
97 +
98 + /**
99 + * Initializes the property visible flag.
100 + * @param visible the new flag value.
101 + * @see #isVisible
102 + */
103 + public void setVisible(boolean visible) {
104 + this.visible = visible;
105 + }
106 +
107 + /**
108 + * Returns a string representation of this property definition.
109 + * @return a string representing this property definition.
110 + * hidden
111 + */
112 + public String toString()
113 + {
114 + StringBuilder sb = new StringBuilder();
115 +
116 + sb.append("ID_PROP=");
117 + sb.append(getUserPropertyId());
118 +
119 + sb.append(" PROP_NAME=");
120 + sb.append(name);
121 +
122 + sb.append(" PROP_TAG=");
123 + sb.append(tag);
124 +
125 + sb.append(" IND_VISIBLE=");
126 + sb.append(visible);
127 +
128 + return sb.toString();
129 + }
130 +
131 +}
...\ No newline at end of file ...\ No newline at end of file
1 +package org.legrog.entities;
2 +
3 +import org.springframework.data.jpa.repository.JpaRepository;
4 +
5 +public interface UserPropertyRepository extends JpaRepository<UserProperty, Integer> {
6 +}
...@@ -2,9 +2,7 @@ package org.legrog.presentation; ...@@ -2,9 +2,7 @@ package org.legrog.presentation;
2 2
3 import org.legrog.application.SharedService; 3 import org.legrog.application.SharedService;
4 import org.legrog.application.UserService; 4 import org.legrog.application.UserService;
5 -import org.legrog.entities.DisplayNameMask; 5 +import org.legrog.entities.*;
6 -import org.legrog.entities.User;
7 -import org.legrog.entities.UserRole;
8 6
9 import javax.annotation.PostConstruct; 7 import javax.annotation.PostConstruct;
10 import javax.enterprise.context.RequestScoped; 8 import javax.enterprise.context.RequestScoped;
...@@ -14,7 +12,7 @@ import java.util.List; ...@@ -14,7 +12,7 @@ import java.util.List;
14 12
15 @Named 13 @Named
16 @RequestScoped 14 @RequestScoped
17 -public class AddUserBean { 15 +public class UpdateUserBean {
18 @Inject 16 @Inject
19 private UserService userService; 17 private UserService userService;
20 @Inject 18 @Inject
...@@ -36,6 +34,8 @@ public class AddUserBean { ...@@ -36,6 +34,8 @@ public class AddUserBean {
36 34
37 private List<UserRole> availableUserRoles; 35 private List<UserRole> availableUserRoles;
38 36
37 + private List<UserProperty> availableUserProperties;
38 +
39 private String email; 39 private String email;
40 40
41 private boolean anonymous; 41 private boolean anonymous;
...@@ -46,6 +46,14 @@ public class AddUserBean { ...@@ -46,6 +46,14 @@ public class AddUserBean {
46 46
47 private String presentation; 47 private String presentation;
48 48
49 + private List<UserAttribute> userAttributes;
50 +
51 + private boolean criticProvider;
52 +
53 + private boolean visible;
54 +
55 + private boolean activated;
56 +
49 public String getUsername() { 57 public String getUsername() {
50 return username; 58 return username;
51 } 59 }
...@@ -146,6 +154,7 @@ public class AddUserBean { ...@@ -146,6 +154,7 @@ public class AddUserBean {
146 public void init() { 154 public void init() {
147 allDisplayNameMasks = sharedService.getAllDisplayNameMasks(); 155 allDisplayNameMasks = sharedService.getAllDisplayNameMasks();
148 availableUserRoles = sharedService.getAvailableUserRoles(); 156 availableUserRoles = sharedService.getAvailableUserRoles();
157 + availableUserProperties = sharedService.getAvailableUserProperties();
149 } 158 }
150 159
151 public List<UserRole> getAvailableUserRoles() { 160 public List<UserRole> getAvailableUserRoles() {
...@@ -163,4 +172,44 @@ public class AddUserBean { ...@@ -163,4 +172,44 @@ public class AddUserBean {
163 public void setPresentation(String presentation) { 172 public void setPresentation(String presentation) {
164 this.presentation = presentation; 173 this.presentation = presentation;
165 } 174 }
175 +
176 + public List<UserProperty> getAvailableUserProperties() {
177 + return availableUserProperties;
178 + }
179 +
180 + public void setAvailableUserProperties(List<UserProperty> availableUserProperties) {
181 + this.availableUserProperties = availableUserProperties;
182 + }
183 +
184 + public List<UserAttribute> getUserAttributes() {
185 + return userAttributes;
186 + }
187 +
188 + public void setUserAttributes(List<UserAttribute> userAttributes) {
189 + this.userAttributes = userAttributes;
190 + }
191 +
192 + public boolean isCriticProvider() {
193 + return criticProvider;
194 + }
195 +
196 + public void setCriticProvider(boolean criticProvider) {
197 + this.criticProvider = criticProvider;
198 + }
199 +
200 + public boolean isVisible() {
201 + return visible;
202 + }
203 +
204 + public void setVisible(boolean visible) {
205 + this.visible = visible;
206 + }
207 +
208 + public boolean isActivated() {
209 + return activated;
210 + }
211 +
212 + public void setActivated(boolean activated) {
213 + this.activated = activated;
214 + }
166 } 215 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
33 </navigation-case> 33 </navigation-case>
34 <navigation-case> 34 <navigation-case>
35 <from-outcome>addUser</from-outcome> 35 <from-outcome>addUser</from-outcome>
36 - <to-view-id>/addUser.xhtml</to-view-id> 36 + <to-view-id>/addUser_short.xhtml</to-view-id>
37 </navigation-case> 37 </navigation-case>
38 <navigation-case> 38 <navigation-case>
39 <from-outcome>listUsers</from-outcome> 39 <from-outcome>listUsers</from-outcome>
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
50 </navigation-rule> 50 </navigation-rule>
51 51
52 <navigation-rule> 52 <navigation-rule>
53 - <from-view-id>/addUser.xhtml</from-view-id> 53 + <from-view-id>/addUser_short.xhtml</from-view-id>
54 <navigation-case> 54 <navigation-case>
55 <from-outcome>success</from-outcome> 55 <from-outcome>success</from-outcome>
56 <to-view-id>/listUsers_short.xhtml</to-view-id> 56 <to-view-id>/listUsers_short.xhtml</to-view-id>
......
...@@ -13,9 +13,9 @@ ...@@ -13,9 +13,9 @@
13 13
14 <h:panelGrid columns="2"> 14 <h:panelGrid columns="2">
15 <h:outputText value="Username de l'utilisateur"/> 15 <h:outputText value="Username de l'utilisateur"/>
16 - <h:inputText value='#{addUserBean.username}'/> 16 + <h:inputText value='#{updateUserBean.username}'/>
17 <h:outputText value='Add'/> 17 <h:outputText value='Add'/>
18 - <h:commandButton action="#{addUserBean.add}" value="Add"/> 18 + <h:commandButton action="#{updateUserBean.add}" value="Add"/>
19 </h:panelGrid> 19 </h:panelGrid>
20 </h:form> 20 </h:form>
21 </body> 21 </body>
......
...@@ -12,10 +12,10 @@ ...@@ -12,10 +12,10 @@
12 </h:commandLink> 12 </h:commandLink>
13 </h:form> 13 </h:form>
14 <f:metadata> 14 <f:metadata>
15 - <f:event type="preRenderView" listener="#{addUserBean.onload}" /> 15 + <f:event type="preRenderView" listener="#{updateUserBean.onload}" />
16 </f:metadata> 16 </f:metadata>
17 <ul> 17 <ul>
18 - <ui:repeat value="#{addUserBean.users}" var="user"> 18 + <ui:repeat value="#{updateUserBean.users}" var="user">
19 <li>#{user.username}</li> 19 <li>#{user.username}</li>
20 </ui:repeat> 20 </ui:repeat>
21 </ul> 21 </ul>
......
This diff is collapsed. Click to expand it.