This commit is contained in:
@@ -26,7 +26,7 @@ public interface IUserManager {
|
|||||||
// methodes lister
|
// methodes lister
|
||||||
public List<User> getUsers();
|
public List<User> getUsers();
|
||||||
public List<User> getUsers(Conference conf);
|
public List<User> getUsers(Conference conf);
|
||||||
public List<User> getUsers(Role.RoleType type);
|
public List<User> getUsers(int conf_id,Role.RoleType type);
|
||||||
/**
|
/**
|
||||||
* Create and adds a role to a user
|
* Create and adds a role to a user
|
||||||
* @param login The login of the user
|
* @param login The login of the user
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import java.util.List;
|
|||||||
import javax.persistence.CascadeType;
|
import javax.persistence.CascadeType;
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.FetchType;
|
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
import javax.persistence.OneToMany;
|
import javax.persistence.OneToMany;
|
||||||
|
|
||||||
@@ -60,7 +59,7 @@ public class User implements Serializable{
|
|||||||
* Roles for this user
|
* Roles for this user
|
||||||
*/
|
*/
|
||||||
//@OneToMany(targetEntity=Role.class,mappedBy="user",fetch=FetchType.EAGER,cascade=CascadeType.ALL)
|
//@OneToMany(targetEntity=Role.class,mappedBy="user",fetch=FetchType.EAGER,cascade=CascadeType.ALL)
|
||||||
@OneToMany(targetEntity=Role.class,mappedBy="user",cascade=CascadeType.ALL)
|
@OneToMany(cascade=CascadeType.ALL, targetEntity=Role.class,mappedBy="user")
|
||||||
private List<Role> roles;
|
private List<Role> roles;
|
||||||
|
|
||||||
@OneToMany(targetEntity=Article.class,mappedBy="mainAuthor")
|
@OneToMany(targetEntity=Article.class,mappedBy="mainAuthor")
|
||||||
@@ -141,11 +140,20 @@ public class User implements Serializable{
|
|||||||
}
|
}
|
||||||
|
|
||||||
//@OneToMany(targetEntity=Role.class,mappedBy="user",fetch=FetchType.EAGER)
|
//@OneToMany(targetEntity=Role.class,mappedBy="user",fetch=FetchType.EAGER)
|
||||||
@OneToMany(targetEntity=Role.class,mappedBy="user")
|
@OneToMany(cascade=CascadeType.ALL, targetEntity=Role.class,mappedBy="user")
|
||||||
public List<Role> getRoles(){
|
public List<Role> getRoles(){
|
||||||
return roles;
|
return roles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param roles the roles to set
|
||||||
|
*/
|
||||||
|
//@OneToMany(targetEntity=Role.class,mappedBy="user",fetch=FetchType.EAGER)
|
||||||
|
@OneToMany(cascade=CascadeType.ALL, targetEntity=Role.class,mappedBy="user")
|
||||||
|
public void setRoles(List<Role> roles) {
|
||||||
|
this.roles = roles;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the password
|
* @return the password
|
||||||
*/
|
*/
|
||||||
@@ -161,14 +169,7 @@ public class User implements Serializable{
|
|||||||
this.login = login;
|
this.login = login;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param roles the roles to set
|
|
||||||
*/
|
|
||||||
//@OneToMany(targetEntity=Role.class,mappedBy="user",fetch=FetchType.EAGER)
|
|
||||||
@OneToMany(targetEntity=Role.class,mappedBy="user")
|
|
||||||
public void setRoles(List<Role> roles) {
|
|
||||||
this.roles = roles;
|
|
||||||
}
|
|
||||||
|
|
||||||
@OneToMany(targetEntity=Article.class,mappedBy="mainAuthor")
|
@OneToMany(targetEntity=Article.class,mappedBy="mainAuthor")
|
||||||
public List<Article> getArticles() {
|
public List<Article> getArticles() {
|
||||||
|
|||||||
@@ -73,9 +73,12 @@ public class UserManagerBean implements IUserManager{
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<User> getUsers(RoleType type) {
|
@SuppressWarnings("unchecked")
|
||||||
Query query = em.createQuery("from Role role where type = ?");
|
public List<User> getUsers(int conf_id,RoleType type) {
|
||||||
|
Query query = em.createQuery("select user from User user, Role role where user.login = role.user and role.type = ? and role.conference = ?)");
|
||||||
query.setParameter(1, type);
|
query.setParameter(1, type);
|
||||||
|
Conference conference = em.find(Conference.class, conf_id);
|
||||||
|
query.setParameter(2, conference);
|
||||||
return query.getResultList();
|
return query.getResultList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user