Toggle navigation
Toggle navigation
This project
Loading...
Sign in
grogv3
/
grog-cubi
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
Jean-Francois Leveque
2016-10-11 17:37:09 +0200
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
92ed08fa93d65e1d16183ceef86ad2df8af87bf1
92ed08fa
1 parent
28820101
Protection collision sequence, Uer creation ~OK (manque retour liste), User modification en travaux
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
84 additions
and
17 deletions
pom.xml
src/main/java/org/legrog/entities/Country.java
src/main/java/org/legrog/entities/Publisher.java
src/main/java/org/legrog/entities/PublisherRevision.java
src/main/java/org/legrog/entities/User.java
src/main/java/org/legrog/entities/UserAttribute.java
src/main/java/org/legrog/entities/UserProperty.java
src/main/java/org/legrog/entities/UserRole.java
src/main/java/org/legrog/presentation/UpdateUserBean.java
src/main/webapp/WEB-INF/classes/import.sql
src/main/webapp/listUsers.xhtml
pom.xml
View file @
92ed08f
...
...
@@ -44,6 +44,16 @@
<version>
6.0
</version>
</dependency>
<dependency>
<groupId>
org.apache.myfaces.core
</groupId>
<artifactId>
myfaces-api
</artifactId>
<version>
2.2.10
</version>
</dependency>
<dependency>
<groupId>
org.apache.myfaces.core
</groupId>
<artifactId>
myfaces-impl
</artifactId>
<version>
2.2.10
</version>
</dependency>
<!-- **** FRAMEWORK : JSF + CDI **** -->
<dependency>
...
...
src/main/java/org/legrog/entities/Country.java
View file @
92ed08f
...
...
@@ -7,7 +7,8 @@ import javax.persistence.*;
public
class
Country
/* extends org.roliste.data.DbEntity */
{
// @Column(name = "ID_PAYS")
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
AUTO
)
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
/* Permet la population */
@Column
(
name
=
"COUNTRY_ID"
)
private
int
countryId
;
private
String
countryName
;
...
...
src/main/java/org/legrog/entities/Publisher.java
View file @
92ed08f
...
...
@@ -9,7 +9,7 @@ public class Publisher /* extends org.roliste.data.DbLinkableEntity */ {
// TODO L'éventuel usage de Linkable reste à confirmer https://tree.taiga.io/project/jr-utily-grog-v3/us/48
// TODO Attention, en v2 Linkable implique Traceable (journalisable) qui devrait aussi être évalué
@Id
// @Column(name = "ID_EDITEUR
")
@Column
(
name
=
"PUBLISHER_ID
"
)
@GeneratedValue
(
strategy
=
GenerationType
.
AUTO
)
private
int
publisherId
;
...
...
@@ -19,7 +19,7 @@ public class Publisher /* extends org.roliste.data.DbLinkableEntity */ {
@OneToOne
private
User
activeValidator
;
@OneToMany
@OneToMany
(
mappedBy
=
"publisher"
)
private
Set
<
PublisherRevision
>
revisions
;
public
int
getPublisherId
()
{
...
...
src/main/java/org/legrog/entities/PublisherRevision.java
View file @
92ed08f
...
...
@@ -7,7 +7,10 @@ import java.sql.Timestamp;
public
class
PublisherRevision
{
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
AUTO
)
@Column
(
name
=
"PUBLISHER_REVISION_ID"
)
private
int
publisherRevisionId
;
@ManyToOne
private
Publisher
publisher
;
private
String
publisherName
;
private
String
publisherStreetAddress
;
private
String
publisherPostalCode
;
...
...
src/main/java/org/legrog/entities/User.java
View file @
92ed08f
...
...
@@ -12,9 +12,9 @@ import java.util.*;
@Table
(
name
=
"UserTable"
)
public
class
User
/* extends org.roliste.data.DbTraceableEntity */
implements
DisplayNameConfigurable
/*, DbValidationEntity */
{
// @Column(name="ID_UTILISATEUR")
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
AUTO
)
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
/* Permet la population */
@Column
(
name
=
"USER_ID"
)
private
int
userId
;
// TODO traiter Traceable
...
...
@@ -120,6 +120,7 @@ public class User /* extends org.roliste.data.DbTraceableEntity */ implements Di
* The {link org.roliste.data.db.UserRole}s for this user.
*/
@ManyToMany
@Column
(
name
=
"USER_ROLE_ID"
)
private
List
<
UserRole
>
roles
;
/**
...
...
@@ -425,7 +426,7 @@ public class User /* extends org.roliste.data.DbTraceableEntity */ implements Di
/**
* The list of attributes / properties for this user.
*/
@OneToMany
@OneToMany
(
mappedBy
=
"user"
)
private
List
<
UserAttribute
>
userAttributes
;
/**
...
...
src/main/java/org/legrog/entities/UserAttribute.java
View file @
92ed08f
...
...
@@ -16,6 +16,7 @@ public class UserAttribute {
* The linked user.
*/
@ManyToOne
@JoinColumn
(
name
=
"USER_ID"
)
private
User
user
;
/**
...
...
@@ -49,6 +50,7 @@ public class UserAttribute {
* The linked property.
*/
@ManyToOne
@JoinColumn
(
name
=
"USER_PROPERTY_ID"
)
private
UserProperty
userProperty
;
/**
...
...
src/main/java/org/legrog/entities/UserProperty.java
View file @
92ed08f
...
...
@@ -5,7 +5,8 @@ import javax.persistence.*;
@Entity
public
class
UserProperty
{
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
AUTO
)
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
/* Permet la population */
@Column
(
name
=
"USER_PROPERTY_ID"
)
private
int
userPropertyId
;
/**
...
...
src/main/java/org/legrog/entities/UserRole.java
View file @
92ed08f
...
...
@@ -19,7 +19,8 @@ import javax.persistence.*;
public
class
UserRole
/* extends org.roliste.data.DbEntity */
{
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
AUTO
)
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
/* Permet la population */
@Column
(
name
=
"USER_ROLE_ID"
)
private
int
userRoleId
;
/**
...
...
@@ -30,7 +31,8 @@ public class UserRole /* extends org.roliste.data.DbEntity */
/**
* The {@link User}s for this user role.
*/
@ManyToMany
@ManyToMany
(
mappedBy
=
"roles"
)
@Column
(
name
=
"USER_ID"
)
private
Set
<
User
>
users
;
/**
...
...
src/main/java/org/legrog/presentation/UpdateUserBean.java
View file @
92ed08f
...
...
@@ -3,11 +3,18 @@ package org.legrog.presentation;
import
org.legrog.application.SharedService
;
import
org.legrog.application.UserService
;
import
org.legrog.entities.*
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
javax.annotation.PostConstruct
;
import
javax.enterprise.context.RequestScoped
;
import
javax.faces.bean.ManagedProperty
;
import
javax.faces.context.ExternalContext
;
import
javax.faces.context.FacesContext
;
import
javax.inject.Inject
;
import
javax.inject.Named
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
...
...
@@ -19,6 +26,7 @@ public class UpdateUserBean {
@Inject
private
SharedService
sharedService
;
@ManagedProperty
(
"#{param.userId}"
)
private
int
userId
;
private
String
username
;
...
...
@@ -97,6 +105,37 @@ public class UpdateUserBean {
return
"success"
;
}
public
String
prepareUpdate
(
int
userId
)
{
ExternalContext
externalContext
=
FacesContext
.
getCurrentInstance
().
getExternalContext
();
Logger
logger
=
LoggerFactory
.
getLogger
(
UpdateUserBean
.
class
);
logger
.
info
(
"prepareUpdate"
);
logger
.
info
(
"userId ="
+
userId
);
if
(
userId
!=
0
)
{
User
user
=
userService
.
findUserById
(
userId
);
if
(
user
!=
null
)
{
activated
=
user
.
isActivated
();
anonymous
=
user
.
isAnonymous
();
userAttributes
=
user
.
getAttributes
();
criticProvider
=
user
.
isCriticProvider
();
displayNameMask
=
user
.
getDisplayNameMask
();
email
=
user
.
getEmail
();
firstName
=
user
.
getFirstName
();
lastName
=
user
.
getLastName
();
nickName
=
user
.
getNickName
();
presentation
=
user
.
getPresentation
();
roles
=
user
.
getRoles
();
if
(
roles
==
null
)
{
roles
=
new
ArrayList
<
UserRole
>();
}
username
=
user
.
getUsername
();
visible
=
user
.
isVisible
();
return
"updateUser.xhtml"
;
}
}
return
"listUsers.xhtml"
;
}
public
String
update
()
{
User
user
=
userService
.
findUserById
(
userId
);
user
.
setActivated
(
activated
);
...
...
@@ -198,6 +237,8 @@ public class UpdateUserBean {
@PostConstruct
public
void
init
()
{
Logger
logger
=
LoggerFactory
.
getLogger
(
UpdateUserBean
.
class
);
logger
.
info
(
"init"
);
allDisplayNameMasks
=
sharedService
.
getAllDisplayNameMasks
();
availableUserRoles
=
sharedService
.
getAvailableUserRoles
();
availableUserProperties
=
sharedService
.
getAvailableUserProperties
();
...
...
src/main/webapp/WEB-INF/classes/import.sql
View file @
92ed08f
...
...
@@ -20,9 +20,16 @@ INSERT INTO UserProperty VALUES (2, 'avatar', 'Lien vers une icône ou une photo
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
);
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
);
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
);
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
);
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
);
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
);
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
);
INSERT
INTO
UserTable_UserRole
VALUES
(
1
,
2
);
INSERT
INTO
UserTable_UserRole
VALUES
(
2
,
2
);
INSERT
INTO
UserTable_UserRole
VALUES
(
3
,
2
);
INSERT
INTO
UserTable_UserRole
VALUES
(
4
,
2
);
INSERT
INTO
UserTable_UserRole
VALUES
(
5
,
2
);
INSERT
INTO
UserTable_UserRole
VALUES
(
6
,
2
);
INSERT
INTO
UserTable_UserRole
VALUES
(
5
,
4
);
...
...
src/main/webapp/listUsers.xhtml
View file @
92ed08f
...
...
@@ -61,9 +61,8 @@
</h:commandLink>-->
</p:column>
<p:column>
<h:commandLink
action=
"
add
"
>
<h:commandLink
action=
"
#{updateUserBean.prepareUpdate(user.userId)}
"
>
<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}"
>
...
...
Please
register
or
login
to post a comment