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
2017-01-18 11:24:54 +0100
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
1ea63b7611889c9b01604cb776ff9eb460f1ef3d
1ea63b76
1 parent
5ed47c4d
Refactoring des comptes vers dénomination Account
Show whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
230 additions
and
228 deletions
src/main/java/org/legrog/entities/Person.java → src/main/java/org/legrog/entities/Account.java
src/main/java/org/legrog/entities/UserAttribute.java → src/main/java/org/legrog/entities/AccountAttribute.java
src/main/java/org/legrog/entities/UserPropertyRepository.java → src/main/java/org/legrog/entities/AccountAttributeRepository.java
src/main/java/org/legrog/entities/UserProperty.java → src/main/java/org/legrog/entities/AccountProperty.java
src/main/java/org/legrog/entities/UserRoleRepository.java → src/main/java/org/legrog/entities/AccountPropertyRepository.java
src/main/java/org/legrog/entities/PersonRepository.java → src/main/java/org/legrog/entities/AccountRepository.java
src/main/java/org/legrog/entities/UserRole.java → src/main/java/org/legrog/entities/AccountRole.java
src/main/java/org/legrog/entities/UserAttributeRepository.java → src/main/java/org/legrog/entities/AccountRoleRepository.java
src/main/java/org/legrog/entities/PublisherAction.java
src/main/java/org/legrog/entities/PublisherVersion.java
src/main/java/org/legrog/web/publisher/PublisherVersionView.java
src/main/java/org/legrog/web/user/ListUsersBean.java
src/main/java/org/legrog/web/user/UpdateUserBean.java
src/main/java/org/legrog/web/user/UserService.java
src/main/java/org/legrog/web/user/UserServiceSpring.java
src/main/java/org/legrog/web/user/listUsers.xhtml
src/main/java/org/legrog/web/user/listUsers_short.xhtml
src/main/java/org/legrog/web/user/updateUser.xhtml
src/main/java/org/legrog/web/xyz/SharedService.java
src/main/java/org/legrog/web/xyz/SharedServiceSpring.java
src/test/java/org/legrog/web/user/UpdatePersonBeanTest.java → src/test/java/org/legrog/web/user/UpdateAccountBeanTest.java
src/main/java/org/legrog/entities/
Person
.java
→
src/main/java/org/legrog/entities/
Account
.java
View file @
1ea63b7
...
...
@@ -11,7 +11,7 @@ import java.util.*;
Migréee depuis la v2.
*/
@Entity
public
class
Person
/* extends org.roliste.data.DbTraceableEntity */
implements
DisplayNameConfigurable
/*, DbValidationEntity */
{
public
class
Account
/* extends org.roliste.data.DbTraceableEntity */
implements
DisplayNameConfigurable
/*, DbValidationEntity */
{
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
...
...
@@ -117,23 +117,23 @@ public class Person /* extends org.roliste.data.DbTraceableEntity */ implements
private
String
email
;
/**
* The {link org.roliste.data.db.
User
Role}s for this user.
* The {link org.roliste.data.db.
Account
Role}s for this user.
*/
@ManyToMany
(
fetch
=
FetchType
.
EAGER
)
private
List
<
User
Role
>
roles
;
private
List
<
Account
Role
>
roles
;
/**
* Retrieves the list of {@link
User
Role}s for this user.
* Retrieves the list of {@link
Account
Role}s for this user.
* SHALL be used as a read-only attribute. In particular, avoid
* using {@link List#add(Object)} or {@link List#remove(Object)} on
* the returned value without caution.
* @return a {@link List} of {@link
User
Role}. Shall not be <code>null</code>.
* @return a {@link List} of {@link
Account
Role}. Shall not be <code>null</code>.
* @see #setRoles(List)
* see #addToRole(
User
Role)
* see #removeFromRole(
User
Role)
* see #addToRole(
Account
Role)
* see #removeFromRole(
Account
Role)
* hibernate.many-to-many
* column="ROLE_FK"
* class="org.roliste.data.db.
User
Role"
* class="org.roliste.data.db.
Account
Role"
* foreign-key="FK_UTILISATEURROLE_ROLEUTILISATEUR"
* @hibernate.key
* column="UTILISATEUR_FK"
...
...
@@ -146,20 +146,20 @@ public class Person /* extends org.roliste.data.DbTraceableEntity */ implements
* lazy="true"
*/
public
List
<
User
Role
>
getRoles
()
{
public
List
<
Account
Role
>
getRoles
()
{
return
roles
;
}
/**
* Lists the list of {@link
User
Role}s for this user.
* @param roles the new {@link List} of {@link
User
Role}s. Shall not be <code>null</code>.
* Lists the list of {@link
Account
Role}s for this user.
* @param roles the new {@link List} of {@link
Account
Role}s. Shall not be <code>null</code>.
* @throws NullPointerException if roles is <code>null</code>.
* @see #getRoles()
* see #addToRole(
User
Role)
* see #removeFromRole(
User
Role)
* see #addToRole(
Account
Role)
* see #removeFromRole(
Account
Role)
*/
public
void
setRoles
(
List
<
User
Role
>
roles
)
{
public
void
setRoles
(
List
<
Account
Role
>
roles
)
{
if
(
roles
==
null
)
{
throw
new
NullPointerException
(
"Impossible d'affecter un ensemble nul aux r�les d'un utilisateur"
);
...
...
@@ -168,38 +168,38 @@ public class Person /* extends org.roliste.data.DbTraceableEntity */ implements
}
/**
* Add the user to a given {@link
User
Role}s.
* @param role the new {@link
User
Role}. Ignored if <code>null</code>.
* Add the user to a given {@link
Account
Role}s.
* @param role the new {@link
Account
Role}. Ignored if <code>null</code>.
* @see #getRoles()
* @see #setRoles(List)
* @see #removeFromRole(
User
Role)
* @see #removeFromRole(
Account
Role)
*/
/*
public void addToRole(
User
Role role) {
public void addToRole(
Account
Role role) {
synchronized (this)
{
if ((role != null) && !(getRoles().contains(role)) )
{
role.get
Person
s().add(this);
role.get
Account
s().add(this);
getRoles().add(role);
}
}
}
*/
/**
* Remove the user from a given {@link
User
Role}s.
* @param role the {@link
UserRole} this {@link Person
} will lose. Ignored if <code>null</code>.
* Remove the user from a given {@link
Account
Role}s.
* @param role the {@link
AccountRole} this {@link Account
} will lose. Ignored if <code>null</code>.
* @see #getRoles()
* @see #setRoles(List)
* @see #addToRole(
User
Role)
* @see #addToRole(
Account
Role)
*/
/*
public void removeFromRole(
User
Role role) {
public void removeFromRole(
Account
Role role) {
synchronized (this)
{
if ((role != null) && (getRoles().contains(role)) )
{
role.get
Person
s().remove(this);
role.get
Account
s().remove(this);
getRoles().remove(role);
}
}
...
...
@@ -300,7 +300,7 @@ public class Person /* extends org.roliste.data.DbTraceableEntity */ implements
*/
/**
* Remove a book from user's collection.
* @param book the {@link org.roliste.data.db.BookDetails} this {@link
Person
} will lose. Ignored if <code>null</code>.
* @param book the {@link org.roliste.data.db.BookDetails} this {@link
Account
} will lose. Ignored if <code>null</code>.
* @see #getCollection()
* @see #setCollection(List)
* @see #addToCollection(BookDetails)
...
...
@@ -326,7 +326,7 @@ public class Person /* extends org.roliste.data.DbTraceableEntity */ implements
* Retrieves the list of delegations for this user.
* Each delegation is a link to a {@link org.roliste.data.db.Traceable} object.
* A user having delegation may update field values for delegated object.
* @return a {@link List} of {@link
User
Role}. Shall not be <code>null</code>. SHALL be used as a
* @return a {@link List} of {@link
Account
Role}. Shall not be <code>null</code>. SHALL be used as a
* read-only attribute. In particular, avoid using {@link List#add(Object)} or {@link List#remove(Object)}
* on the returned value without caution.
* @see #setDelegations(List)
...
...
@@ -389,7 +389,7 @@ public class Person /* extends org.roliste.data.DbTraceableEntity */ implements
*/
/**
* Remove delegation on a given {@link Traceable} from this user.
* @param object the delegation this {@link
Person
} will lose. Ignored if <code>null</code>.
* @param object the delegation this {@link
Account
} will lose. Ignored if <code>null</code>.
* @see #getDelegations()
* @see #setDelegations(List)
* @see #giveDelegation(Traceable)
...
...
@@ -426,12 +426,12 @@ public class Person /* extends org.roliste.data.DbTraceableEntity */ implements
* The list of attributes / properties for this user.
*/
@OneToMany
(
mappedBy
=
"person"
)
private
List
<
UserAttribute
>
user
Attributes
;
private
List
<
AccountAttribute
>
account
Attributes
;
/**
* Retrieve this user's attributes.
* @hibernate.one-to-many
* class="org.roliste.data.db.
User
Attribute"
* class="org.roliste.data.db.
Account
Attribute"
* @hibernate.bag
* cascade="all"
* lazy="true"
...
...
@@ -442,9 +442,9 @@ public class Person /* extends org.roliste.data.DbTraceableEntity */ implements
* @see #setAttributes(java.util.List)
*/
public
List
<
User
Attribute
>
getAttributes
()
public
List
<
Account
Attribute
>
getAttributes
()
{
return
user
Attributes
;
return
account
Attributes
;
}
/**
...
...
@@ -452,9 +452,9 @@ public class Person /* extends org.roliste.data.DbTraceableEntity */ implements
* @see #getAttributes()
*/
public
void
setAttributes
(
List
<
User
Attribute
>
attribs
)
public
void
setAttributes
(
List
<
Account
Attribute
>
attribs
)
{
this
.
user
Attributes
=
attribs
;
this
.
account
Attributes
=
attribs
;
}
/**
...
...
src/main/java/org/legrog/entities/
User
Attribute.java
→
src/main/java/org/legrog/entities/
Account
Attribute.java
View file @
1ea63b7
...
...
@@ -7,7 +7,7 @@ import javax.persistence.*;
Migréee depuis la v2.
*/
@Entity
public
class
User
Attribute
{
public
class
Account
Attribute
{
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
private
int
userAttributeId
;
...
...
@@ -17,69 +17,69 @@ public class UserAttribute {
}
/**
* The linked
person
.
* The linked
account
.
*/
@ManyToOne
private
Person
person
;
private
Account
account
;
/**
* Retrieve the
person
this attribute is attached to.
* Retrieve the
account
this attribute is attached to.
* hibernate.many-to-one
* column="ID_UTILISATEUR"
* class="org.roliste.data.db.
Person
"
* class="org.roliste.data.db.
Account
"
* not-null="true"
* access="property"
* lazy="proxy"
* properties-name="PropertyPerUser"
* foreign-key="FK_ATTRIBUTUTILISATEUR_UTILISATEUR"
* @return the {link org.roliste.data.db.
Person
} this attribute is attached to.
* @return the {link org.roliste.data.db.
Account
} this attribute is attached to.
* Shall not be <code>null</code>.
* see #set
Person(org.roliste.data.db.Person
)
* see #set
Account(org.roliste.data.db.Account
)
*/
public
Person
getPerson
()
{
return
person
;
public
Account
getAccount
()
{
return
account
;
}
/**
* Set the
person
this attribute is attached to.
* @param
person the new {link org.roliste.data.db.Person
} this attribute will be attached to. Shall not be <code>null</code>.
* @see #get
Person
()
* Set the
account
this attribute is attached to.
* @param
account the new {link org.roliste.data.db.Account
} this attribute will be attached to. Shall not be <code>null</code>.
* @see #get
Account
()
*/
public
void
set
Person
(
Person
person
)
{
this
.
person
=
person
;
public
void
set
Account
(
Account
account
)
{
this
.
account
=
account
;
}
/**
* The linked property.
*/
@ManyToOne
private
UserProperty
user
Property
;
private
AccountProperty
account
Property
;
/**
* Retrieve the property this attribute is attached to.
* hibernate.many-to-one
* column="ID_PROP"
* class="org.roliste.data.db.
User
Property"
* class="org.roliste.data.db.
Account
Property"
* not-null="true"
* access="property"
* lazy="false"
* properties-name="PropertyPerUser"
* foreign-key="FK_ATTRIBUTUTILISATEUR_PROPRIETE"
* @return the {link org.roliste.data.db.
User
Property} this attribute is attached to.
* @return the {link org.roliste.data.db.
Account
Property} this attribute is attached to.
* Shall not be <code>null</code>.
* see #setProperty(org.roliste.data.db.
User
Property)
* see #setProperty(org.roliste.data.db.
Account
Property)
*/
public
User
Property
getProperty
()
{
return
user
Property
;
public
Account
Property
getProperty
()
{
return
account
Property
;
}
/**
* Set the property this attribute is attached to.
* @param prop the new {link org.roliste.data.db.
User
Property} this attribute will be attached to. Shall not be <code>null</code>.
* @param prop the new {link org.roliste.data.db.
Account
Property} this attribute will be attached to. Shall not be <code>null</code>.
* @see #getProperty()
*/
public
void
setProperty
(
User
Property
prop
)
{
user
Property
=
prop
;
public
void
setProperty
(
Account
Property
prop
)
{
account
Property
=
prop
;
}
/**
...
...
@@ -112,14 +112,14 @@ public class UserAttribute {
}
/**
* Returns a string representation of this
person
attribute definition.
* @return a string representing this
person
attribute definition.
* Returns a string representation of this
account
attribute definition.
* @return a string representing this
account
attribute definition.
* hidden
*/
@Override
public
String
toString
()
{
return
"ID_ATTR="
+
getUserAttributeId
()
+
" ATTR_PROP="
+
user
Property
+
" ATTR_VALUE="
+
value
;
return
"ID_ATTR="
+
getUserAttributeId
()
+
" ATTR_PROP="
+
account
Property
+
" ATTR_VALUE="
+
value
;
}
}
...
...
src/main/java/org/legrog/entities/
UserProperty
Repository.java
→
src/main/java/org/legrog/entities/
AccountAttribute
Repository.java
View file @
1ea63b7
...
...
@@ -2,5 +2,5 @@ package org.legrog.entities;
import
org.springframework.data.jpa.repository.JpaRepository
;
public
interface
UserPropertyRepository
extends
JpaRepository
<
UserProperty
,
Integer
>
{
public
interface
AccountAttributeRepository
extends
JpaRepository
<
AccountAttribute
,
Integer
>
{
}
...
...
src/main/java/org/legrog/entities/
User
Property.java
→
src/main/java/org/legrog/entities/
Account
Property.java
View file @
1ea63b7
...
...
@@ -7,7 +7,7 @@ import javax.persistence.*;
Importée depuis la v2.
*/
@Entity
public
class
User
Property
{
public
class
Account
Property
{
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
/* Permet la population */
private
int
userPropertyId
;
...
...
src/main/java/org/legrog/entities/
UserRole
Repository.java
→
src/main/java/org/legrog/entities/
AccountProperty
Repository.java
View file @
1ea63b7
...
...
@@ -2,5 +2,5 @@ package org.legrog.entities;
import
org.springframework.data.jpa.repository.JpaRepository
;
public
interface
UserRoleRepository
extends
JpaRepository
<
UserRole
,
Integer
>
{
public
interface
AccountPropertyRepository
extends
JpaRepository
<
AccountProperty
,
Integer
>
{
}
...
...
src/main/java/org/legrog/entities/
Person
Repository.java
→
src/main/java/org/legrog/entities/
Account
Repository.java
View file @
1ea63b7
...
...
@@ -2,5 +2,5 @@ package org.legrog.entities;
import
org.springframework.data.jpa.repository.JpaRepository
;
public
interface
PersonRepository
extends
JpaRepository
<
Person
,
Integer
>
{
public
interface
AccountRepository
extends
JpaRepository
<
Account
,
Integer
>
{
}
...
...
src/main/java/org/legrog/entities/
User
Role.java
→
src/main/java/org/legrog/entities/
Account
Role.java
View file @
1ea63b7
...
...
@@ -7,11 +7,11 @@ import javax.persistence.*;
/**
* The database representation of a user role or group.
* A given {@link
Person} may be part of one or more {@link User
Role}.
* A given {@link
Account} may be part of one or more {@link Account
Role}.
* <br/>
* Warning: due to laziness of mapped objects, private attributes of all DB entities shall never be used directly.
* You shall always use the getter/setter methods.
* alias
User
Role
* alias
Account
Role
*
*/
/*
...
...
@@ -19,7 +19,7 @@ import javax.persistence.*;
*/
@Entity
// TODO évaluer extend v2
public
class
User
Role
/* extends org.roliste.data.DbEntity */
public
class
Account
Role
/* extends org.roliste.data.DbEntity */
{
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
...
...
@@ -31,10 +31,10 @@ public class UserRole /* extends org.roliste.data.DbEntity */
private
String
rolename
;
/**
* The {@link
Person
}s for this user role.
* The {@link
Account
}s for this user role.
*/
@ManyToMany
(
mappedBy
=
"roles"
)
private
Set
<
Person
>
person
s
;
private
Set
<
Account
>
account
s
;
/**
* Builds a new and empty user role definition.
...
...
@@ -42,12 +42,12 @@ public class UserRole /* extends org.roliste.data.DbEntity */
* <br/>
* Needed by Hibernate for Java reflection.
*/
public
User
Role
()
{
public
Account
Role
()
{
super
();
rolename
=
null
;
visible
=
true
;
// no need to synchronize this
persons
=
new
HashSet
<
Person
>();
accounts
=
new
HashSet
<
Account
>();
}
public
int
getUserRoleId
()
{
...
...
@@ -90,7 +90,7 @@ public class UserRole /* extends org.roliste.data.DbEntity */
/**
* Indicates if the role is visible.
* If not,
person
s should not be able to access the privileges
* If not,
account
s should not be able to access the privileges
* they inherit from being part of this role.
* @return the visible flag.
* @see #setVisible(boolean)
...
...
@@ -112,12 +112,12 @@ public class UserRole /* extends org.roliste.data.DbEntity */
}
/**
* Retrieves the list of {@link
Person
}s for this user role.
* Retrieves the list of {@link
Account
}s for this user role.
* SHALL be used as a read-only attribute. In particular, avoid
* using {@link Set#add(Object)} or {@link Set#remove(Object)} on
* the returned value without caution.
* @return a {@link Set} of {@link
Person
}. May be <code>null</code>.
* @see #set
Person
s(Set)
* @return a {@link Set} of {@link
Account
}. May be <code>null</code>.
* @see #set
Account
s(Set)
* hibernate.many-to-many
* column="UTILISATEUR_FK"
* class="org.roliste.data.db.Person"
...
...
@@ -132,18 +132,18 @@ public class UserRole /* extends org.roliste.data.DbEntity */
* lazy="true"
* inverse="true"
*/
public
Set
<
Person
>
getPerson
s
()
{
return
person
s
;
public
Set
<
Account
>
getAccount
s
()
{
return
account
s
;
}
/**
* Sets the list of {@link
Person
}s for this user role.
* @param
persons the new {@link Set} of {@link Person
}s. May be
* Sets the list of {@link
Account
}s for this user role.
* @param
accounts the new {@link Set} of {@link Account
}s. May be
* <code>null</code> (we don't handle the relation from this side).
* @see #get
Person
s()
* @see #get
Account
s()
*/
protected
void
set
Persons
(
Set
<
Person
>
person
s
)
{
this
.
persons
=
person
s
;
protected
void
set
Accounts
(
Set
<
Account
>
account
s
)
{
this
.
accounts
=
account
s
;
}
/**
...
...
src/main/java/org/legrog/entities/
UserAttribut
eRepository.java
→
src/main/java/org/legrog/entities/
AccountRol
eRepository.java
View file @
1ea63b7
...
...
@@ -2,5 +2,5 @@ package org.legrog.entities;
import
org.springframework.data.jpa.repository.JpaRepository
;
public
interface
UserAttributeRepository
extends
JpaRepository
<
UserAttribute
,
Integer
>
{
public
interface
AccountRoleRepository
extends
JpaRepository
<
AccountRole
,
Integer
>
{
}
\ No newline at end of file
...
...
src/main/java/org/legrog/entities/PublisherAction.java
View file @
1ea63b7
...
...
@@ -15,7 +15,7 @@ public class PublisherAction {
@Enumerated
private
ActionType
actionType
;
@ManyToOne
private
Person
publisherActionAuthor
;
private
Account
publisherActionAuthor
;
@ManyToOne
private
PublisherVersion
publisherVersion
;
...
...
@@ -25,7 +25,7 @@ public class PublisherAction {
@ManyToOne
private
Publisher
publisher
;
public
void
setPublisherActionAuthor
(
Person
publisherActionAuthor
)
{
public
void
setPublisherActionAuthor
(
Account
publisherActionAuthor
)
{
this
.
publisherActionAuthor
=
publisherActionAuthor
;
}
...
...
@@ -49,7 +49,7 @@ public class PublisherAction {
return
actionType
;
}
public
Person
getPublisherActionAuthor
()
{
public
Account
getPublisherActionAuthor
()
{
return
publisherActionAuthor
;
}
...
...
src/main/java/org/legrog/entities/PublisherVersion.java
View file @
1ea63b7
...
...
@@ -31,7 +31,7 @@ public class PublisherVersion {
private
boolean
publisherActive
;
private
String
publisherHistory
;
@ManyToOne
private
Person
publisherVersionAuthor
;
private
Account
publisherVersionAuthor
;
private
Timestamp
publisherVersionDatetime
;
public
Timestamp
getPublisherVersionDatetime
()
{
...
...
@@ -146,11 +146,11 @@ public class PublisherVersion {
this
.
publisherAddressCountry
=
publisherAddressCountry
;
}
public
Person
getPublisherVersionAuthor
()
{
public
Account
getPublisherVersionAuthor
()
{
return
publisherVersionAuthor
;
}
public
void
setPublisherVersionAuthor
(
Person
publisherVersionAuthor
)
{
public
void
setPublisherVersionAuthor
(
Account
publisherVersionAuthor
)
{
this
.
publisherVersionAuthor
=
publisherVersionAuthor
;
}
...
...
src/main/java/org/legrog/web/publisher/PublisherVersionView.java
View file @
1ea63b7
...
...
@@ -43,7 +43,7 @@ public class PublisherVersionView implements Serializable {
private
String
publisherURL
;
private
boolean
publisherActive
;
private
String
publisherHistory
;
private
transient
Person
publisherVersionAuthor
;
private
transient
Account
publisherVersionAuthor
;
private
Timestamp
publisherVersionDatetime
;
private
transient
Publisher
publisher
;
...
...
@@ -312,11 +312,11 @@ public class PublisherVersionView implements Serializable {
this
.
publisherHistory
=
publisherHistory
;
}
public
Person
getPublisherVersionAuthor
()
{
public
Account
getPublisherVersionAuthor
()
{
return
publisherVersionAuthor
;
}
public
void
setPublisherVersionAuthor
(
Person
publisherVersionAuthor
)
{
public
void
setPublisherVersionAuthor
(
Account
publisherVersionAuthor
)
{
this
.
publisherVersionAuthor
=
publisherVersionAuthor
;
}
...
...
src/main/java/org/legrog/web/user/ListUsersBean.java
View file @
1ea63b7
package
org
.
legrog
.
web
.
user
;
import
org.legrog.entities.
Person
;
import
org.legrog.entities.
Account
;
import
javax.annotation.PostConstruct
;
import
javax.enterprise.context.RequestScoped
;
...
...
@@ -14,19 +14,19 @@ public class ListUsersBean {
@Inject
private
UserService
userService
;
private
List
<
Person
>
person
s
;
private
List
<
Account
>
account
s
;
public
List
<
Person
>
getPerson
s
()
{
return
person
s
;
public
List
<
Account
>
getAccount
s
()
{
return
account
s
;
}
public
void
set
Persons
(
List
<
Person
>
person
s
)
{
this
.
persons
=
person
s
;
public
void
set
Accounts
(
List
<
Account
>
account
s
)
{
this
.
accounts
=
account
s
;
}
@PostConstruct
public
void
init
()
{
person
s
=
userService
.
getAllUsers
();
account
s
=
userService
.
getAllUsers
();
}
}
...
...
src/main/java/org/legrog/web/user/UpdateUserBean.java
View file @
1ea63b7
...
...
@@ -24,8 +24,8 @@ public class UpdateUserBean {
private
SharedService
sharedService
;
private
List
<
DisplayNameMask
>
allDisplayNameMasks
;
private
List
<
UserRole
>
availableUser
Roles
;
private
List
<
User
Property
>
availableUserProperties
;
private
List
<
AccountRole
>
availableAccount
Roles
;
private
List
<
Account
Property
>
availableUserProperties
;
@ManagedProperty
(
"#{param.userId}"
)
private
int
userId
;
...
...
@@ -37,9 +37,9 @@ public class UpdateUserBean {
private
String
email
;
private
boolean
anonymous
;
private
String
password
;
private
List
<
User
Role
>
roles
;
private
List
<
Account
Role
>
roles
;
private
String
presentation
;
private
List
<
UserAttribute
>
user
Attributes
;
private
List
<
AccountAttribute
>
account
Attributes
;
private
boolean
criticProvider
;
private
boolean
visible
;
private
boolean
activated
;
...
...
@@ -59,41 +59,41 @@ public class UpdateUserBean {
public
void
init
()
{
logger
.
info
(
"init"
);
allDisplayNameMasks
=
sharedService
.
getAllDisplayNameMasks
();
available
User
Roles
=
sharedService
.
getAvailableUserRoles
();
available
Account
Roles
=
sharedService
.
getAvailableUserRoles
();
availableUserProperties
=
sharedService
.
getAvailableUserProperties
();
}
public
String
add
()
{
Person
person
=
new
Person
();
person
.
setActivated
(
activated
);
person
.
setAnonymous
(
anonymous
);
if
(
user
Attributes
!=
null
)
{
person
.
setAttributes
(
user
Attributes
);
Account
account
=
new
Account
();
account
.
setActivated
(
activated
);
account
.
setAnonymous
(
anonymous
);
if
(
account
Attributes
!=
null
)
{
account
.
setAttributes
(
account
Attributes
);
}
person
.
setCriticProvider
(
criticProvider
);
account
.
setCriticProvider
(
criticProvider
);
if
(
displayNameMask
!=
null
)
{
person
.
setDisplayNameMask
(
displayNameMask
);
account
.
setDisplayNameMask
(
displayNameMask
);
}
else
{
person
.
setDisplayNameMask
(
DisplayNameMask
.
PRENOMNOM
);
account
.
setDisplayNameMask
(
DisplayNameMask
.
PRENOMNOM
);
}
person
.
setEmail
(
email
);
person
.
setFirstName
(
firstName
);
person
.
setLastName
(
lastName
);
account
.
setEmail
(
email
);
account
.
setFirstName
(
firstName
);
account
.
setLastName
(
lastName
);
if
(
nickName
!=
null
&&
!
nickName
.
isEmpty
())
{
person
.
setNickName
(
nickName
);
account
.
setNickName
(
nickName
);
}
person
.
setPassword
(
password
);
account
.
setPassword
(
password
);
if
(
presentation
!=
null
)
{
person
.
setPresentation
(
presentation
);
account
.
setPresentation
(
presentation
);
}
if
(
roles
!=
null
)
{
person
.
setRoles
(
roles
);
account
.
setRoles
(
roles
);
}
person
.
setUsername
(
username
);
person
.
setVisible
(
visible
);
person
.
setCreationDate
(
new
Date
());
userService
.
addUser
(
person
);
account
.
setUsername
(
username
);
account
.
setVisible
(
visible
);
account
.
setCreationDate
(
new
Date
());
userService
.
addUser
(
account
);
return
"success"
;
}
...
...
@@ -103,25 +103,25 @@ public class UpdateUserBean {
logger
.
info
(
"userId ="
+
userId
);
this
.
userId
=
userId
;
if
(
userId
!=
0
)
{
Person
person
=
userService
.
findUserById
(
userId
);
if
(
person
!=
null
)
{
activated
=
person
.
isActivated
();
anonymous
=
person
.
isAnonymous
();
userAttributes
=
person
.
getAttributes
();
criticProvider
=
person
.
isCriticProvider
();
displayNameMask
=
person
.
getDisplayNameMask
();
email
=
person
.
getEmail
();
firstName
=
person
.
getFirstName
();
lastName
=
person
.
getLastName
();
nickName
=
person
.
getNickName
();
password
=
person
.
getPassword
();
presentation
=
person
.
getPresentation
();
roles
=
person
.
getRoles
();
Account
account
=
userService
.
findUserById
(
userId
);
if
(
account
!=
null
)
{
activated
=
account
.
isActivated
();
anonymous
=
account
.
isAnonymous
();
accountAttributes
=
account
.
getAttributes
();
criticProvider
=
account
.
isCriticProvider
();
displayNameMask
=
account
.
getDisplayNameMask
();
email
=
account
.
getEmail
();
firstName
=
account
.
getFirstName
();
lastName
=
account
.
getLastName
();
nickName
=
account
.
getNickName
();
password
=
account
.
getPassword
();
presentation
=
account
.
getPresentation
();
roles
=
account
.
getRoles
();
if
(
roles
==
null
)
{
roles
=
new
ArrayList
<
User
Role
>();
roles
=
new
ArrayList
<
Account
Role
>();
}
username
=
person
.
getUsername
();
visible
=
person
.
isVisible
();
username
=
account
.
getUsername
();
visible
=
account
.
isVisible
();
return
"updateUser.xhtml"
;
}
}
...
...
@@ -132,32 +132,32 @@ public class UpdateUserBean {
logger
.
info
(
"update"
);
logger
.
info
(
"userId ="
+
userId
);
Person
person
=
userService
.
findUserById
(
userId
);
person
.
setActivated
(
activated
);
person
.
setAnonymous
(
anonymous
);
person
.
setAttributes
(
user
Attributes
);
person
.
setCriticProvider
(
criticProvider
);
person
.
setDisplayNameMask
(
displayNameMask
);
person
.
setEmail
(
email
);
person
.
setFirstName
(
firstName
);
person
.
setLastName
(
lastName
);
person
.
setNickName
(
nickName
);
person
.
setPassword
(
password
);
person
.
setPresentation
(
presentation
);
person
.
setRoles
(
roles
);
person
.
setUsername
(
username
);
person
.
setVisible
(
visible
);
userService
.
updateUser
(
person
);
Account
account
=
userService
.
findUserById
(
userId
);
account
.
setActivated
(
activated
);
account
.
setAnonymous
(
anonymous
);
account
.
setAttributes
(
account
Attributes
);
account
.
setCriticProvider
(
criticProvider
);
account
.
setDisplayNameMask
(
displayNameMask
);
account
.
setEmail
(
email
);
account
.
setFirstName
(
firstName
);
account
.
setLastName
(
lastName
);
account
.
setNickName
(
nickName
);
account
.
setPassword
(
password
);
account
.
setPresentation
(
presentation
);
account
.
setRoles
(
roles
);
account
.
setUsername
(
username
);
account
.
setVisible
(
visible
);
userService
.
updateUser
(
account
);
return
"success"
;
}
public
List
<
UserRole
>
getAvailableUser
Roles
()
{
return
available
User
Roles
;
public
List
<
AccountRole
>
getAvailableAccount
Roles
()
{
return
available
Account
Roles
;
}
public
void
setAvailable
UserRoles
(
List
<
UserRole
>
availableUser
Roles
)
{
this
.
available
UserRoles
=
availableUser
Roles
;
public
void
setAvailable
AccountRoles
(
List
<
AccountRole
>
availableAccount
Roles
)
{
this
.
available
AccountRoles
=
availableAccount
Roles
;
}
public
String
getPresentation
()
{
...
...
@@ -168,20 +168,20 @@ public class UpdateUserBean {
this
.
presentation
=
presentation
;
}
public
List
<
User
Property
>
getAvailableUserProperties
()
{
public
List
<
Account
Property
>
getAvailableUserProperties
()
{
return
availableUserProperties
;
}
public
void
setAvailableUserProperties
(
List
<
User
Property
>
availableUserProperties
)
{
public
void
setAvailableUserProperties
(
List
<
Account
Property
>
availableUserProperties
)
{
this
.
availableUserProperties
=
availableUserProperties
;
}
public
List
<
UserAttribute
>
getUser
Attributes
()
{
return
user
Attributes
;
public
List
<
AccountAttribute
>
getAccount
Attributes
()
{
return
account
Attributes
;
}
public
void
set
UserAttributes
(
List
<
UserAttribute
>
user
Attributes
)
{
this
.
userAttributes
=
user
Attributes
;
public
void
set
AccountAttributes
(
List
<
AccountAttribute
>
account
Attributes
)
{
this
.
accountAttributes
=
account
Attributes
;
}
public
boolean
isCriticProvider
()
{
...
...
@@ -304,11 +304,11 @@ public class UpdateUserBean {
this
.
password
=
password
;
}
public
List
<
User
Role
>
getRoles
()
{
public
List
<
Account
Role
>
getRoles
()
{
return
roles
;
}
public
void
setRoles
(
List
<
User
Role
>
roles
)
{
public
void
setRoles
(
List
<
Account
Role
>
roles
)
{
this
.
roles
=
roles
;
}
}
\ No newline at end of file
...
...
src/main/java/org/legrog/web/user/UserService.java
View file @
1ea63b7
package
org
.
legrog
.
web
.
user
;
import
org.legrog.entities.
Person
;
import
org.legrog.entities.
Account
;
import
java.util.List
;
public
interface
UserService
{
void
addUser
(
Person
person
);
void
addUser
(
Account
account
);
List
<
Person
>
getAllUsers
();
List
<
Account
>
getAllUsers
();
Person
findUserById
(
int
id
);
Account
findUserById
(
int
id
);
void
updateUser
(
Person
person
);
void
updateUser
(
Account
account
);
}
...
...
src/main/java/org/legrog/web/user/UserServiceSpring.java
View file @
1ea63b7
package
org
.
legrog
.
web
.
user
;
import
org.legrog.entities.
Person
;
import
org.legrog.entities.
Person
Repository
;
import
org.legrog.entities.
Account
;
import
org.legrog.entities.
Account
Repository
;
import
javax.ejb.Stateless
;
import
javax.inject.Inject
;
...
...
@@ -10,21 +10,21 @@ import java.util.List;
@Stateless
public
class
UserServiceSpring
implements
UserService
{
@Inject
PersonRepository
person
Repository
;
AccountRepository
account
Repository
;
public
void
addUser
(
Person
person
)
{
personRepository
.
save
(
person
);
public
void
addUser
(
Account
account
)
{
accountRepository
.
save
(
account
);
}
public
List
<
Person
>
getAllUsers
()
{
return
person
Repository
.
findAll
();
public
List
<
Account
>
getAllUsers
()
{
return
account
Repository
.
findAll
();
}
public
Person
findUserById
(
int
id
)
{
return
person
Repository
.
findOne
(
new
Integer
(
id
));
public
Account
findUserById
(
int
id
)
{
return
account
Repository
.
findOne
(
new
Integer
(
id
));
}
public
void
updateUser
(
Person
person
)
{
personRepository
.
save
(
person
);
public
void
updateUser
(
Account
account
)
{
accountRepository
.
save
(
account
);
}
}
\ No newline at end of file
...
...
src/main/java/org/legrog/web/user/listUsers.xhtml
View file @
1ea63b7
...
...
@@ -32,17 +32,17 @@
<div
id=
"listElements"
>
<h:commandLink
styleClass=
"fRight acLink"
action=
"add"
rendered=
"#{not empty listUsersBean.
person
s}"
>
<h:commandLink
styleClass=
"fRight acLink"
action=
"add"
rendered=
"#{not empty listUsersBean.
account
s}"
>
<img
src=
"/images/structure/vide.gif"
class=
"icAddC"
alt=
""
title=
"Crer un nouvel utilisateur"
/>
Nouvel Utilisateur
</h:commandLink>
<p:dataTable
id=
"tableElements"
rendered=
"#{not empty listUsersBean.
person
s}"
var=
"
person"
value=
"#{listUsersBean.person
s}"
<p:dataTable
id=
"tableElements"
rendered=
"#{not empty listUsersBean.
account
s}"
var=
"
account"
value=
"#{listUsersBean.account
s}"
styleClass=
"results"
rowClasses=
"altRichRow,altRow"
>
<!-- TODO Grer la pagination -->
<!-- <p:dataTable id="tableElements" rendered="#{listUsersBean.
person
s.size>0}"
var="
person" value="#{listUsersBean.person
s}" rows="#{userListMgr.pageSize}"
<!-- <p:dataTable id="tableElements" rendered="#{listUsersBean.
account
s.size>0}"
var="
account" value="#{listUsersBean.account
s}" rows="#{userListMgr.pageSize}"
styleClass="results" rowClasses="altRichRow,altRow">-->
<f:facet
name=
"header"
>
<p:dataScroller
for=
"tableElements"
...
...
@@ -61,35 +61,35 @@
</h:commandLink>-->
</p:column>
<p:column>
<h:commandLink
action=
"#{updateUserBean.prepareUpdate(
person
.userId)}"
>
<h:commandLink
action=
"#{updateUserBean.prepareUpdate(
account
.userId)}"
>
<img
src=
"/images/structure/vide.gif"
class=
"icEdit"
alt=
"Modifier"
title=
"Modifier"
/>
</h:commandLink>
</p:column>
<p:column
styleClass=
"third"
sortBy=
"#{
person
.username}"
>
<p:column
styleClass=
"third"
sortBy=
"#{
account
.username}"
>
<f:facet
name=
"header"
>
Identifiant
</f:facet>
<!-- TODO Dcider de l'avenir de traceable -->
<ui:remove>
<!-- <h:outputLink value="#{
person
.traceable.urlRewrite}">-->
<!-- <h:outputLink value="#{
account
.traceable.urlRewrite}">-->
</ui:remove>
<h:outputText
value=
"#{
person
.username}"
/>
<h:outputText
value=
"#{
account
.username}"
/>
<!-- </h:outputLink>-->
</p:column>
<p:column
styleClass=
"third"
sortBy=
"#{
person.firstName} #{person
.lastName}"
>
<p:column
styleClass=
"third"
sortBy=
"#{
account.firstName} #{account
.lastName}"
>
<f:facet
name=
"header"
>
Nom
</f:facet>
<ui:remove>
<!--<h:outputLink value="#{
person
.traceable.urlRewrite}">-->
<!--<h:outputLink value="#{
account
.traceable.urlRewrite}">-->
</ui:remove>
<h:outputText
value=
"#{
person.firstName} #{person
.lastName}"
/>
<h:outputText
value=
"#{
account.firstName} #{account
.lastName}"
/>
<!--</h:outputLink>-->
</p:column>
<p:column
styleClass=
"third"
sortBy=
"#{
person
.email}"
>
<p:column
styleClass=
"third"
sortBy=
"#{
account
.email}"
>
<f:facet
name=
"header"
>
Email
</f:facet>
<h:outputText
value=
"#{
person
.email}"
/>
<h:outputText
value=
"#{
account
.email}"
/>
</p:column>
<p:column>
<h:graphicImage
value=
"/images/structure/dVert.gif"
rendered=
"#{
person.visible and person
.activated}"
title=
"Utilisateur activ"
/>
<h:graphicImage
value=
"/images/structure/dOrange.gif"
rendered=
"#{(not
person.visible) and person
.activated}"
title=
"Utilisateur dsactiv"
/>
<h:graphicImage
value=
"/images/structure/dRouge.gif"
rendered=
"#{not
person
.activated}"
title=
"Utilisateur non enregistr"
/>
<h:graphicImage
value=
"/images/structure/dVert.gif"
rendered=
"#{
account.visible and account
.activated}"
title=
"Utilisateur activ"
/>
<h:graphicImage
value=
"/images/structure/dOrange.gif"
rendered=
"#{(not
account.visible) and account
.activated}"
title=
"Utilisateur dsactiv"
/>
<h:graphicImage
value=
"/images/structure/dRouge.gif"
rendered=
"#{not
account
.activated}"
title=
"Utilisateur non enregistr"
/>
</p:column>
<f:facet
name=
"footer"
>
<h:commandLink
action=
"add"
value=
"Crer un nouvel utilisateur"
>
...
...
@@ -99,7 +99,7 @@
</div>
<p>
<h:commandLink
action=
"add"
value=
"Crer un nouvel utilisateur"
rendered=
"#{empty listUsersBean.
person
s}"
>
rendered=
"#{empty listUsersBean.
account
s}"
>
</h:commandLink>
</p>
</h:form>
...
...
src/main/java/org/legrog/web/user/listUsers_short.xhtml
View file @
1ea63b7
...
...
@@ -12,8 +12,8 @@
</h:commandLink>
</h:form>
<ul>
<ui:repeat
value=
"#{listUsersBean.
persons}"
var=
"person
"
>
<li>
#{
person
.username}
</li>
<ui:repeat
value=
"#{listUsersBean.
accounts}"
var=
"account
"
>
<li>
#{
account
.username}
</li>
</ui:repeat>
</ul>
</f:view>
...
...
src/main/java/org/legrog/web/user/updateUser.xhtml
View file @
1ea63b7
...
...
@@ -86,7 +86,7 @@
<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.available
User
Roles}"
var=
"role"
itemLabel=
"#{role.rolename}"
/>
<f:selectItems
value=
"#{updateUserBean.available
Account
Roles}"
var=
"role"
itemLabel=
"#{role.rolename}"
/>
</h:selectManyCheckbox>
</td>
<td><h:message
errorClass=
"errorMsg"
infoClass=
"infoMsg"
for=
"roles"
/></td>
...
...
@@ -110,7 +110,7 @@
<h:outputText
value=
"#{userProperty.tag}"
/>
</h:column>
<h:column>
<h:inputText
id=
"prop_#{userProperty.name}"
value=
"#{updateUserBean.
user
Attributes[userProperty.name].value}"
style=
"width: 175px;"
>
<h:inputText
id=
"prop_#{userProperty.name}"
value=
"#{updateUserBean.
account
Attributes[userProperty.name].value}"
style=
"width: 175px;"
>
<f:validateLength
maximum=
"200"
/>
</h:inputText>
</h:column>
...
...
src/main/java/org/legrog/web/xyz/SharedService.java
View file @
1ea63b7
...
...
@@ -12,9 +12,9 @@ public interface SharedService {
List
<
DisplayNameMask
>
getAllDisplayNameMasks
();
List
<
User
Role
>
getAvailableUserRoles
();
List
<
Account
Role
>
getAvailableUserRoles
();
List
<
User
Property
>
getAvailableUserProperties
();
List
<
Account
Property
>
getAvailableUserProperties
();
Person
getCurrentUser
();
Account
getCurrentUser
();
}
\ No newline at end of file
...
...
src/main/java/org/legrog/web/xyz/SharedServiceSpring.java
View file @
1ea63b7
...
...
@@ -15,16 +15,16 @@ import java.util.Vector;
public
class
SharedServiceSpring
implements
SharedService
{
CountryRepository
countryRepository
;
UserRoleRepository
user
RoleRepository
;
UserPropertyRepository
user
PropertyRepository
;
AccountRoleRepository
account
RoleRepository
;
AccountPropertyRepository
account
PropertyRepository
;
UserService
userService
;
@Inject
public
SharedServiceSpring
(
CountryRepository
countryRepository
,
UserRoleRepository
user
RoleRepository
,
UserPropertyRepository
user
PropertyRepository
,
UserService
userService
)
{
public
SharedServiceSpring
(
CountryRepository
countryRepository
,
AccountRoleRepository
account
RoleRepository
,
AccountPropertyRepository
account
PropertyRepository
,
UserService
userService
)
{
this
.
countryRepository
=
countryRepository
;
this
.
userRoleRepository
=
user
RoleRepository
;
this
.
userPropertyRepository
=
user
PropertyRepository
;
this
.
accountRoleRepository
=
account
RoleRepository
;
this
.
accountPropertyRepository
=
account
PropertyRepository
;
this
.
userService
=
userService
;
}
...
...
@@ -52,18 +52,18 @@ public class SharedServiceSpring implements SharedService {
return
allDisplayNameMasks
;
}
public
List
<
User
Role
>
getAvailableUserRoles
()
{
return
user
RoleRepository
.
findAll
();
public
List
<
Account
Role
>
getAvailableUserRoles
()
{
return
account
RoleRepository
.
findAll
();
}
public
List
<
UserProperty
>
getAvailableUserProperties
()
{
return
user
PropertyRepository
.
findAll
();
}
public
List
<
AccountProperty
>
getAvailableUserProperties
()
{
return
account
PropertyRepository
.
findAll
();
}
public
Person
getCurrentUser
()
{
public
Account
getCurrentUser
()
{
// TODO Remplacer l'astuce par une vraie récupération de l'utilisateur
List
<
Person
>
person
s
=
userService
.
getAllUsers
();
List
<
Account
>
account
s
=
userService
.
getAllUsers
();
Random
random
=
new
Random
();
Person
person
=
persons
.
get
(
random
.
nextInt
(
person
s
.
size
()));
Account
account
=
accounts
.
get
(
random
.
nextInt
(
account
s
.
size
()));
// End TODO
return
person
;
return
account
;
}
}
...
...
src/test/java/org/legrog/web/user/Update
Person
BeanTest.java
→
src/test/java/org/legrog/web/user/Update
Account
BeanTest.java
View file @
1ea63b7
...
...
@@ -7,6 +7,8 @@ import org.junit.jupiter.api.Test;
import
org.junit.jupiter.api.extension.ExtendWith
;
import
org.junit.platform.runner.JUnitPlatform
;
import
org.junit.runner.RunWith
;
import
org.legrog.entities.AccountProperty
;
import
org.legrog.entities.AccountRole
;
import
org.legrog.entities.DisplayNameMask
;
import
org.legrog.test.MockitoExtension
;
import
org.legrog.web.xyz.SharedService
;
...
...
@@ -20,10 +22,10 @@ import static org.mockito.Mockito.when;
/**
* Created by jai on 15/11/16.
*/
@DisplayName
(
"Update
Person
Bean"
)
@DisplayName
(
"Update
Account
Bean"
)
@ExtendWith
(
MockitoExtension
.
class
)
@RunWith
(
JUnitPlatform
.
class
)
public
class
Update
Person
BeanTest
{
public
class
Update
Account
BeanTest
{
UpdateUserBean
updateUserBean
;
...
...
@@ -33,7 +35,7 @@ public class UpdatePersonBeanTest {
}
@Test
@DisplayName
(
"depends on Shared Service and
Person
Service"
)
@DisplayName
(
"depends on Shared Service and
Account
Service"
)
public
void
testDependencies
()
{
assertThat
(
updateUserBean
).
isNotNull
();
}
...
...
@@ -43,14 +45,14 @@ public class UpdatePersonBeanTest {
class
init
{
private
List
<
DisplayNameMask
>
displayNameMasks
;
private
List
<
org
.
legrog
.
entities
.
User
Property
>
userProperties
;
private
List
<
org
.
legrog
.
entities
.
UserRole
>
user
Roles
;
private
List
<
Account
Property
>
userProperties
;
private
List
<
AccountRole
>
account
Roles
;
@BeforeEach
public
void
setUp
(
@Mock
SharedService
sharedService
)
{
when
(
sharedService
.
getAllDisplayNameMasks
()).
thenReturn
(
displayNameMasks
);
when
(
sharedService
.
getAvailableUserProperties
()).
thenReturn
(
userProperties
);
when
(
sharedService
.
getAvailableUserRoles
()).
thenReturn
(
user
Roles
);
when
(
sharedService
.
getAvailableUserRoles
()).
thenReturn
(
account
Roles
);
}
@Test
...
...
@@ -59,7 +61,7 @@ public class UpdatePersonBeanTest {
updateUserBean
.
init
();
assertThat
(
updateUserBean
.
getAllDisplayNameMasks
()).
isEqualTo
(
displayNameMasks
);
assertThat
(
updateUserBean
.
getAvailableUserProperties
()).
isEqualTo
(
userProperties
);
assertThat
(
updateUserBean
.
getAvailable
UserRoles
()).
isEqualTo
(
user
Roles
);
assertThat
(
updateUserBean
.
getAvailable
AccountRoles
()).
isEqualTo
(
account
Roles
);
}
}
...
...
Please
register
or
login
to post a comment