Protection collision sequence, Uer creation ~OK (manque retour liste), User modification en travaux
Showing
11 changed files
with
84 additions
and
17 deletions
... | @@ -44,6 +44,16 @@ | ... | @@ -44,6 +44,16 @@ |
44 | <version>6.0</version> | 44 | <version>6.0</version> |
45 | </dependency> | 45 | </dependency> |
46 | 46 | ||
47 | + <dependency> | ||
48 | + <groupId>org.apache.myfaces.core</groupId> | ||
49 | + <artifactId>myfaces-api</artifactId> | ||
50 | + <version>2.2.10</version> | ||
51 | + </dependency> | ||
52 | + <dependency> | ||
53 | + <groupId>org.apache.myfaces.core</groupId> | ||
54 | + <artifactId>myfaces-impl</artifactId> | ||
55 | + <version>2.2.10</version> | ||
56 | + </dependency> | ||
47 | <!-- **** FRAMEWORK : JSF + CDI **** --> | 57 | <!-- **** FRAMEWORK : JSF + CDI **** --> |
48 | 58 | ||
49 | <dependency> | 59 | <dependency> | ... | ... |
... | @@ -7,7 +7,8 @@ import javax.persistence.*; | ... | @@ -7,7 +7,8 @@ import javax.persistence.*; |
7 | public class Country /* extends org.roliste.data.DbEntity */ { | 7 | public class Country /* extends org.roliste.data.DbEntity */ { |
8 | // @Column(name = "ID_PAYS") | 8 | // @Column(name = "ID_PAYS") |
9 | @Id | 9 | @Id |
10 | - @GeneratedValue(strategy = GenerationType.AUTO) | 10 | + @GeneratedValue(strategy = GenerationType.IDENTITY) /* Permet la population */ |
11 | + @Column(name="COUNTRY_ID") | ||
11 | private int countryId; | 12 | private int countryId; |
12 | private String countryName; | 13 | private String countryName; |
13 | 14 | ... | ... |
... | @@ -9,7 +9,7 @@ public class Publisher /* extends org.roliste.data.DbLinkableEntity */ { | ... | @@ -9,7 +9,7 @@ public class Publisher /* extends org.roliste.data.DbLinkableEntity */ { |
9 | // TODO L'éventuel usage de Linkable reste à confirmer https://tree.taiga.io/project/jr-utily-grog-v3/us/48 | 9 | // TODO L'éventuel usage de Linkable reste à confirmer https://tree.taiga.io/project/jr-utily-grog-v3/us/48 |
10 | // TODO Attention, en v2 Linkable implique Traceable (journalisable) qui devrait aussi être évalué | 10 | // TODO Attention, en v2 Linkable implique Traceable (journalisable) qui devrait aussi être évalué |
11 | @Id | 11 | @Id |
12 | -// @Column(name = "ID_EDITEUR") | 12 | + @Column(name = "PUBLISHER_ID") |
13 | @GeneratedValue(strategy = GenerationType.AUTO) | 13 | @GeneratedValue(strategy = GenerationType.AUTO) |
14 | private int publisherId; | 14 | private int publisherId; |
15 | 15 | ||
... | @@ -19,7 +19,7 @@ public class Publisher /* extends org.roliste.data.DbLinkableEntity */ { | ... | @@ -19,7 +19,7 @@ public class Publisher /* extends org.roliste.data.DbLinkableEntity */ { |
19 | @OneToOne | 19 | @OneToOne |
20 | private User activeValidator; | 20 | private User activeValidator; |
21 | 21 | ||
22 | - @OneToMany | 22 | + @OneToMany(mappedBy = "publisher") |
23 | private Set<PublisherRevision> revisions; | 23 | private Set<PublisherRevision> revisions; |
24 | 24 | ||
25 | public int getPublisherId() { | 25 | public int getPublisherId() { | ... | ... |
... | @@ -7,7 +7,10 @@ import java.sql.Timestamp; | ... | @@ -7,7 +7,10 @@ import java.sql.Timestamp; |
7 | public class PublisherRevision { | 7 | public class PublisherRevision { |
8 | @Id | 8 | @Id |
9 | @GeneratedValue(strategy = GenerationType.AUTO) | 9 | @GeneratedValue(strategy = GenerationType.AUTO) |
10 | + @Column(name = "PUBLISHER_REVISION_ID") | ||
10 | private int publisherRevisionId; | 11 | private int publisherRevisionId; |
12 | + @ManyToOne | ||
13 | + private Publisher publisher; | ||
11 | private String publisherName; | 14 | private String publisherName; |
12 | private String publisherStreetAddress; | 15 | private String publisherStreetAddress; |
13 | private String publisherPostalCode; | 16 | private String publisherPostalCode; | ... | ... |
... | @@ -12,9 +12,9 @@ import java.util.*; | ... | @@ -12,9 +12,9 @@ import java.util.*; |
12 | @Table(name="UserTable") | 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") | ||
16 | @Id | 15 | @Id |
17 | - @GeneratedValue(strategy = GenerationType.AUTO) | 16 | + @GeneratedValue(strategy = GenerationType.IDENTITY) /* Permet la population */ |
17 | + @Column(name="USER_ID") | ||
18 | private int userId; | 18 | private int userId; |
19 | 19 | ||
20 | // TODO traiter Traceable | 20 | // TODO traiter Traceable |
... | @@ -120,6 +120,7 @@ public class User /* extends org.roliste.data.DbTraceableEntity */ implements Di | ... | @@ -120,6 +120,7 @@ public class User /* extends org.roliste.data.DbTraceableEntity */ implements Di |
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 | + @Column(name = "USER_ROLE_ID") | ||
123 | private List<UserRole> roles; | 124 | private List<UserRole> roles; |
124 | 125 | ||
125 | /** | 126 | /** |
... | @@ -425,7 +426,7 @@ public class User /* extends org.roliste.data.DbTraceableEntity */ implements Di | ... | @@ -425,7 +426,7 @@ public class User /* extends org.roliste.data.DbTraceableEntity */ implements Di |
425 | /** | 426 | /** |
426 | * The list of attributes / properties for this user. | 427 | * The list of attributes / properties for this user. |
427 | */ | 428 | */ |
428 | - @OneToMany | 429 | + @OneToMany(mappedBy = "user") |
429 | private List<UserAttribute> userAttributes; | 430 | private List<UserAttribute> userAttributes; |
430 | 431 | ||
431 | /** | 432 | /** | ... | ... |
... | @@ -16,6 +16,7 @@ public class UserAttribute { | ... | @@ -16,6 +16,7 @@ public class UserAttribute { |
16 | * The linked user. | 16 | * The linked user. |
17 | */ | 17 | */ |
18 | @ManyToOne | 18 | @ManyToOne |
19 | + @JoinColumn(name = "USER_ID") | ||
19 | private User user; | 20 | private User user; |
20 | 21 | ||
21 | /** | 22 | /** |
... | @@ -49,6 +50,7 @@ public class UserAttribute { | ... | @@ -49,6 +50,7 @@ public class UserAttribute { |
49 | * The linked property. | 50 | * The linked property. |
50 | */ | 51 | */ |
51 | @ManyToOne | 52 | @ManyToOne |
53 | + @JoinColumn(name = "USER_PROPERTY_ID") | ||
52 | private UserProperty userProperty; | 54 | private UserProperty userProperty; |
53 | 55 | ||
54 | /** | 56 | /** | ... | ... |
... | @@ -5,7 +5,8 @@ import javax.persistence.*; | ... | @@ -5,7 +5,8 @@ import javax.persistence.*; |
5 | @Entity | 5 | @Entity |
6 | public class UserProperty { | 6 | public class UserProperty { |
7 | @Id | 7 | @Id |
8 | - @GeneratedValue(strategy = GenerationType.AUTO) | 8 | + @GeneratedValue(strategy = GenerationType.IDENTITY) /* Permet la population */ |
9 | + @Column(name="USER_PROPERTY_ID") | ||
9 | private int userPropertyId; | 10 | private int userPropertyId; |
10 | 11 | ||
11 | /** | 12 | /** | ... | ... |
... | @@ -19,7 +19,8 @@ import javax.persistence.*; | ... | @@ -19,7 +19,8 @@ import javax.persistence.*; |
19 | public class UserRole /* extends org.roliste.data.DbEntity */ | 19 | public class UserRole /* extends org.roliste.data.DbEntity */ |
20 | { | 20 | { |
21 | @Id | 21 | @Id |
22 | - @GeneratedValue(strategy = GenerationType.AUTO) | 22 | + @GeneratedValue(strategy = GenerationType.IDENTITY) /* Permet la population */ |
23 | + @Column(name="USER_ROLE_ID") | ||
23 | private int userRoleId; | 24 | private int userRoleId; |
24 | 25 | ||
25 | /** | 26 | /** |
... | @@ -30,7 +31,8 @@ public class UserRole /* extends org.roliste.data.DbEntity */ | ... | @@ -30,7 +31,8 @@ public class UserRole /* extends org.roliste.data.DbEntity */ |
30 | /** | 31 | /** |
31 | * The {@link User}s for this user role. | 32 | * The {@link User}s for this user role. |
32 | */ | 33 | */ |
33 | - @ManyToMany | 34 | + @ManyToMany(mappedBy = "roles") |
35 | + @Column(name = "USER_ID") | ||
34 | private Set<User> users; | 36 | private Set<User> users; |
35 | 37 | ||
36 | /** | 38 | /** | ... | ... |
... | @@ -3,11 +3,18 @@ package org.legrog.presentation; | ... | @@ -3,11 +3,18 @@ package org.legrog.presentation; |
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.*; | 5 | import org.legrog.entities.*; |
6 | +import org.slf4j.Logger; | ||
7 | +import org.slf4j.LoggerFactory; | ||
6 | 8 | ||
7 | import javax.annotation.PostConstruct; | 9 | import javax.annotation.PostConstruct; |
8 | import javax.enterprise.context.RequestScoped; | 10 | import javax.enterprise.context.RequestScoped; |
11 | +import javax.faces.bean.ManagedProperty; | ||
12 | +import javax.faces.context.ExternalContext; | ||
13 | +import javax.faces.context.FacesContext; | ||
9 | import javax.inject.Inject; | 14 | import javax.inject.Inject; |
10 | import javax.inject.Named; | 15 | import javax.inject.Named; |
16 | +import java.io.IOException; | ||
17 | +import java.util.ArrayList; | ||
11 | import java.util.Date; | 18 | import java.util.Date; |
12 | import java.util.List; | 19 | import java.util.List; |
13 | 20 | ||
... | @@ -19,6 +26,7 @@ public class UpdateUserBean { | ... | @@ -19,6 +26,7 @@ public class UpdateUserBean { |
19 | @Inject | 26 | @Inject |
20 | private SharedService sharedService; | 27 | private SharedService sharedService; |
21 | 28 | ||
29 | + @ManagedProperty("#{param.userId}") | ||
22 | private int userId; | 30 | private int userId; |
23 | 31 | ||
24 | private String username; | 32 | private String username; |
... | @@ -97,6 +105,37 @@ public class UpdateUserBean { | ... | @@ -97,6 +105,37 @@ public class UpdateUserBean { |
97 | return "success"; | 105 | return "success"; |
98 | } | 106 | } |
99 | 107 | ||
108 | + public String prepareUpdate(int userId) { | ||
109 | + ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext(); | ||
110 | + Logger logger = LoggerFactory.getLogger(UpdateUserBean.class); | ||
111 | + logger.info("prepareUpdate"); | ||
112 | + | ||
113 | + logger.info("userId ="+userId); | ||
114 | + if (userId != 0) { | ||
115 | + User user = userService.findUserById(userId); | ||
116 | + if (user != null) { | ||
117 | + activated = user.isActivated(); | ||
118 | + anonymous = user.isAnonymous(); | ||
119 | + userAttributes = user.getAttributes(); | ||
120 | + criticProvider = user.isCriticProvider(); | ||
121 | + displayNameMask = user.getDisplayNameMask(); | ||
122 | + email = user.getEmail(); | ||
123 | + firstName = user.getFirstName(); | ||
124 | + lastName = user.getLastName(); | ||
125 | + nickName = user.getNickName(); | ||
126 | + presentation = user.getPresentation(); | ||
127 | + roles = user.getRoles(); | ||
128 | + if (roles == null) { | ||
129 | + roles = new ArrayList<UserRole>(); | ||
130 | + } | ||
131 | + username = user.getUsername(); | ||
132 | + visible = user.isVisible(); | ||
133 | + return "updateUser.xhtml"; | ||
134 | + } | ||
135 | + } | ||
136 | + return "listUsers.xhtml"; | ||
137 | + } | ||
138 | + | ||
100 | public String update() { | 139 | public String update() { |
101 | User user = userService.findUserById(userId); | 140 | User user = userService.findUserById(userId); |
102 | user.setActivated(activated); | 141 | user.setActivated(activated); |
... | @@ -198,6 +237,8 @@ public class UpdateUserBean { | ... | @@ -198,6 +237,8 @@ public class UpdateUserBean { |
198 | 237 | ||
199 | @PostConstruct | 238 | @PostConstruct |
200 | public void init() { | 239 | public void init() { |
240 | + Logger logger = LoggerFactory.getLogger(UpdateUserBean.class); | ||
241 | + logger.info("init"); | ||
201 | allDisplayNameMasks = sharedService.getAllDisplayNameMasks(); | 242 | allDisplayNameMasks = sharedService.getAllDisplayNameMasks(); |
202 | availableUserRoles = sharedService.getAvailableUserRoles(); | 243 | availableUserRoles = sharedService.getAvailableUserRoles(); |
203 | availableUserProperties = sharedService.getAvailableUserProperties(); | 244 | availableUserProperties = sharedService.getAvailableUserProperties(); | ... | ... |
... | @@ -20,9 +20,16 @@ INSERT INTO UserProperty VALUES (2, 'avatar', 'Lien vers une icône ou une photo | ... | @@ -20,9 +20,16 @@ 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 (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); | 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); |
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); | 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); |
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); | 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); |
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); | 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); |
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); | 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); |
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); | 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); |
29 | +INSERT INTO UserTable_UserRole VALUES (1,2); | ||
30 | +INSERT INTO UserTable_UserRole VALUES (2,2); | ||
31 | +INSERT INTO UserTable_UserRole VALUES (3,2); | ||
32 | +INSERT INTO UserTable_UserRole VALUES (4,2); | ||
33 | +INSERT INTO UserTable_UserRole VALUES (5,2); | ||
34 | +INSERT INTO UserTable_UserRole VALUES (6,2); | ||
35 | +INSERT INTO UserTable_UserRole VALUES (5,4); | ... | ... |
... | @@ -61,9 +61,8 @@ | ... | @@ -61,9 +61,8 @@ |
61 | </h:commandLink>--> | 61 | </h:commandLink>--> |
62 | </p:column> | 62 | </p:column> |
63 | <p:column> | 63 | <p:column> |
64 | - <h:commandLink action="add"> | 64 | + <h:commandLink action="#{updateUserBean.prepareUpdate(user.userId)}"> |
65 | <img src="/images/structure/vide.gif" class="icEdit" alt="Modifier" title="Modifier" /> | 65 | <img src="/images/structure/vide.gif" class="icEdit" alt="Modifier" title="Modifier" /> |
66 | - <f:setPropertyActionListener value="#{user.userId}" target="updateUserBean.userId" /> | ||
67 | </h:commandLink> | 66 | </h:commandLink> |
68 | </p:column> | 67 | </p:column> |
69 | <p:column styleClass="third" sortBy="#{user.username}"> | 68 | <p:column styleClass="third" sortBy="#{user.username}"> | ... | ... |
-
Please register or login to post a comment