Policy failures:
Code warning - failed on resource ArticleManagerBean.java. Reason: The import javax.transaction.HeuristicMixedException is never used, line 15 - failed on resource ArticleManagerBean.java. Reason: The import javax.transaction.HeuristicRollbackException is never used, line 16 - failed on resource ArticleManagerBean.java. Reason: The import javax.transaction.NotSupportedException is never used, line 17 - failed on resource ArticleManagerBean.java. Reason: The import javax.transaction.RollbackException is never used, line 18 - failed on resource ArticleManagerBean.java. Reason: The import javax.transaction.SystemException is never used, line 19 ... and more. Override reason: x
This commit is contained in:
@@ -249,5 +249,11 @@ public class Article implements Serializable {
|
|||||||
this.delegation = delegation;
|
this.delegation = delegation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//FIXME a tester
|
||||||
|
public boolean equals(Object obj){
|
||||||
|
if (this.getClass() == obj.getClass())
|
||||||
|
return this.id == ((Article)obj).getId();
|
||||||
|
else return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -162,7 +162,9 @@ public class ArticleManagerBean implements IArticleManager, Serializable {
|
|||||||
ut.begin();
|
ut.begin();
|
||||||
Article article = this.getArticle(articleId);
|
Article article = this.getArticle(articleId);
|
||||||
User PCMember = em.find(User.class, memberId);
|
User PCMember = em.find(User.class, memberId);
|
||||||
|
if(!article.getPcMembers().contains(PCMember)){
|
||||||
article.getPcMembers().add(PCMember);
|
article.getPcMembers().add(PCMember);
|
||||||
|
}
|
||||||
ut.commit();
|
ut.commit();
|
||||||
|
|
||||||
this.updateArticle(article);
|
this.updateArticle(article);
|
||||||
|
|||||||
@@ -34,7 +34,15 @@ public interface IUserManager {
|
|||||||
public List<User> getRefereesOFPCMemberForArticle(String PCMemberLogin, Integer articleId);
|
public List<User> getRefereesOFPCMemberForArticle(String PCMemberLogin, Integer articleId);
|
||||||
public List<User> getPCMemberForArticle(Integer articleId);
|
public List<User> getPCMemberForArticle(Integer articleId);
|
||||||
|
|
||||||
|
//speciality methodes
|
||||||
|
public Speciality getSpeciality(int SpecialityId);
|
||||||
|
public List<Speciality> getSpecialities();
|
||||||
|
public void addSpeciality(String name);
|
||||||
|
public void removeSpeciality(int specialityId);
|
||||||
|
public void addSpecialityToUser(int specialityId,String login);
|
||||||
|
public void removeSpecialityToUser(int specialityId, String login);
|
||||||
|
public List<Speciality> getSpecialitiesFromUser(String login);
|
||||||
|
public boolean existe(Speciality spe);
|
||||||
//roles methods
|
//roles methods
|
||||||
/**
|
/**
|
||||||
* Create and adds a role to a user
|
* Create and adds a role to a user
|
||||||
|
|||||||
78
YACOSCore/ejbModule/org/yacos/core/users/Speciality.java
Normal file
78
YACOSCore/ejbModule/org/yacos/core/users/Speciality.java
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
package org.yacos.core.users;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.GeneratedValue;
|
||||||
|
import javax.persistence.GenerationType;
|
||||||
|
import javax.persistence.Id;
|
||||||
|
import javax.persistence.JoinColumn;
|
||||||
|
import javax.persistence.JoinTable;
|
||||||
|
import javax.persistence.ManyToMany;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
public class Speciality implements Serializable{
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy=GenerationType.AUTO)
|
||||||
|
private int id;
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@ManyToMany(targetEntity=User.class)
|
||||||
|
@JoinTable(
|
||||||
|
name="speciality_user_map",
|
||||||
|
joinColumns=@JoinColumn(name="userId"),
|
||||||
|
inverseJoinColumns=@JoinColumn(name="specialityId")
|
||||||
|
)
|
||||||
|
private List<User> users;
|
||||||
|
|
||||||
|
|
||||||
|
public Speciality(String name) {
|
||||||
|
super();
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Speciality() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
public void setId(int id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ManyToMany(targetEntity=User.class)
|
||||||
|
@JoinTable(
|
||||||
|
name="speciality_user_map",
|
||||||
|
joinColumns=@JoinColumn(name="userId"),
|
||||||
|
inverseJoinColumns=@JoinColumn(name="specialityId")
|
||||||
|
)
|
||||||
|
public List<User> getUsers() {
|
||||||
|
return users;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ManyToMany(targetEntity=User.class)
|
||||||
|
@JoinTable(
|
||||||
|
name="speciality_user_map",
|
||||||
|
joinColumns=@JoinColumn(name="userId"),
|
||||||
|
inverseJoinColumns=@JoinColumn(name="specialityId")
|
||||||
|
)
|
||||||
|
public void setUsers(List<User> users) {
|
||||||
|
this.users = users;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -9,11 +9,14 @@ import javax.persistence.CascadeType;
|
|||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
|
import javax.persistence.JoinColumn;
|
||||||
|
import javax.persistence.JoinTable;
|
||||||
|
|
||||||
|
import javax.persistence.ManyToMany;
|
||||||
import javax.persistence.OneToMany;
|
import javax.persistence.OneToMany;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
import javax.persistence.UniqueConstraint;
|
import javax.persistence.UniqueConstraint;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A unique User of the system.
|
* A unique User of the system.
|
||||||
* The user is registered globally in the application and would be able to get different roles for
|
* The user is registered globally in the application and would be able to get different roles for
|
||||||
@@ -61,6 +64,14 @@ public class User implements Serializable{
|
|||||||
*/
|
*/
|
||||||
private String email;
|
private String email;
|
||||||
|
|
||||||
|
@ManyToMany(targetEntity=Speciality.class)
|
||||||
|
@JoinTable(
|
||||||
|
name="speciality_user_map",
|
||||||
|
joinColumns=@JoinColumn(name="specialityId"),
|
||||||
|
inverseJoinColumns=@JoinColumn(name="userId")
|
||||||
|
)
|
||||||
|
private List<Speciality> specialities;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Roles for this user
|
* Roles for this user
|
||||||
*/
|
*/
|
||||||
@@ -68,6 +79,9 @@ public class User implements Serializable{
|
|||||||
@OneToMany(cascade=CascadeType.ALL, targetEntity=Role.class,mappedBy="user")
|
@OneToMany(cascade=CascadeType.ALL, targetEntity=Role.class,mappedBy="user")
|
||||||
private List<Role> roles;
|
private List<Role> roles;
|
||||||
|
|
||||||
|
/*@OneToMany(cascade=CascadeType.ALL, targetEntity=Delegation.class, mappedBy="user")
|
||||||
|
private List<Delegation> delegation;
|
||||||
|
*/
|
||||||
public User(String login, String password, String firstName,
|
public User(String login, String password, String firstName,
|
||||||
String lastName, String organization, String email) {
|
String lastName, String organization, String email) {
|
||||||
this();
|
this();
|
||||||
@@ -125,6 +139,15 @@ public class User implements Serializable{
|
|||||||
this.email = email;
|
this.email = email;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addSpeciality(Speciality spe){
|
||||||
|
this.specialities.add(spe);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void removeSpeciality(Speciality spe){
|
||||||
|
this.specialities.remove(spe);
|
||||||
|
}
|
||||||
|
|
||||||
public void addRole(Role role){
|
public void addRole(Role role){
|
||||||
roles.add(role);
|
roles.add(role);
|
||||||
}
|
}
|
||||||
@@ -190,4 +213,36 @@ public class User implements Serializable{
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ManyToMany(targetEntity=Speciality.class)
|
||||||
|
@JoinTable(
|
||||||
|
name="speciality_user_map",
|
||||||
|
joinColumns=@JoinColumn(name="specialityId"),
|
||||||
|
inverseJoinColumns=@JoinColumn(name="userId")
|
||||||
|
)
|
||||||
|
public List<Speciality> getSpecialities() {
|
||||||
|
return specialities;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ManyToMany(targetEntity=Speciality.class)
|
||||||
|
@JoinTable(
|
||||||
|
name="speciality_user_map",
|
||||||
|
joinColumns=@JoinColumn(name="specialityId"),
|
||||||
|
inverseJoinColumns=@JoinColumn(name="userId")
|
||||||
|
)
|
||||||
|
public void setSpecialities(List<Speciality> specialities) {
|
||||||
|
this.specialities = specialities;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
@OneToMany(cascade=CascadeType.ALL, targetEntity=Delegation.class, mappedBy="user")
|
||||||
|
public List<Delegation> getDelegation() {
|
||||||
|
return delegation;
|
||||||
|
}
|
||||||
|
|
||||||
|
@OneToMany(cascade=CascadeType.ALL, targetEntity=Delegation.class, mappedBy="user")
|
||||||
|
public void setDelegation(List<Delegation> delegation) {
|
||||||
|
this.delegation = delegation;
|
||||||
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,12 +7,13 @@ package org.yacos.core.users;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.ejb.Stateless;
|
import javax.ejb.Stateless;
|
||||||
|
|
||||||
import javax.persistence.EntityManager;
|
import javax.persistence.EntityManager;
|
||||||
import javax.persistence.NoResultException;
|
import javax.persistence.NoResultException;
|
||||||
import javax.persistence.PersistenceContext;
|
import javax.persistence.PersistenceContext;
|
||||||
import javax.persistence.Query;
|
import javax.persistence.Query;
|
||||||
|
|
||||||
import org.yacos.core.article.Article;
|
|
||||||
import org.yacos.core.conferences.Conference;
|
import org.yacos.core.conferences.Conference;
|
||||||
import org.yacos.core.exceptions.PKAlreadyUsedException;
|
import org.yacos.core.exceptions.PKAlreadyUsedException;
|
||||||
import org.yacos.core.exceptions.UserEMailAlreadyExistsException;
|
import org.yacos.core.exceptions.UserEMailAlreadyExistsException;
|
||||||
@@ -114,7 +115,6 @@ public class UserManagerBean implements IUserManager{
|
|||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public List<User> getPCMemberForArticle(Integer articleId){
|
public List<User> getPCMemberForArticle(Integer articleId){
|
||||||
//select p from Paper p join p.referees r where r.login=:aLogin and p.conference=:aConf
|
|
||||||
Query query = em.createQuery("select a.pcMembers from Article a where a.id=?");
|
Query query = em.createQuery("select a.pcMembers from Article a where a.id=?");
|
||||||
query.setParameter(1, articleId);
|
query.setParameter(1, articleId);
|
||||||
return query.getResultList();
|
return query.getResultList();
|
||||||
@@ -128,6 +128,63 @@ public class UserManagerBean implements IUserManager{
|
|||||||
return query.getResultList();
|
return query.getResultList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Speciality getSpeciality(int SpecialityId){
|
||||||
|
Speciality spe = em.find(Speciality.class, SpecialityId);
|
||||||
|
return spe;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public List<Speciality> getSpecialities(){
|
||||||
|
Query query = em.createQuery("from Speciality");
|
||||||
|
return query.getResultList();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void addSpeciality(String name){
|
||||||
|
Speciality spe = new Speciality(name);
|
||||||
|
if(!existe(spe)){
|
||||||
|
em.persist(spe);
|
||||||
|
em.flush();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeSpeciality(int specialityId){
|
||||||
|
Speciality spe = em.find(Speciality.class, specialityId);
|
||||||
|
em.remove(spe);
|
||||||
|
em.flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addSpecialityToUser(int specialityId,String login){
|
||||||
|
User user = this.getUser(login);
|
||||||
|
Speciality spe = this.getSpeciality(specialityId);
|
||||||
|
user.addSpeciality(spe);
|
||||||
|
this.UpdateUser(user);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeSpecialityToUser(int specialityId, String login){
|
||||||
|
Query query = em.createQuery("delete from User u, u.specialities s WHERE s = ? and u = ?");
|
||||||
|
query.setParameter(1, this.getSpeciality(specialityId));
|
||||||
|
query.setParameter(2, this.getUser(login));
|
||||||
|
query.executeUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public List<Speciality> getSpecialitiesFromUser(String login){
|
||||||
|
Query query = em.createQuery("select user.specialities from User user WHERE user.login=?");
|
||||||
|
query.setParameter(1, login);
|
||||||
|
return query.getResultList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean existe(Speciality spe){
|
||||||
|
List<Speciality> list = this.getSpecialities();
|
||||||
|
for (Speciality spe2 : list) {
|
||||||
|
if(spe2.getName().equalsIgnoreCase(spe.getName())){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
* methodes de Roles
|
* methodes de Roles
|
||||||
|
|||||||
Reference in New Issue
Block a user