Quelques modif et ajout de methodes dans le core
This commit is contained in:
@@ -3,6 +3,8 @@ package org.yacos.core.article;
|
|||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.GeneratedValue;
|
import javax.persistence.GeneratedValue;
|
||||||
import javax.persistence.GenerationType;
|
import javax.persistence.GenerationType;
|
||||||
@@ -77,15 +79,18 @@ public class Article implements Serializable {
|
|||||||
|
|
||||||
public Article(int reference, String title, String topic,
|
public Article(int reference, String title, String topic,
|
||||||
String url_article, String mainAuthor,
|
String url_article, String mainAuthor,
|
||||||
ArrayList<String> secondaryAuthor, int state) {
|
List<String> secondaryAuthor, int state) {
|
||||||
//this.id = reference;
|
//this.id = reference;
|
||||||
this.title = title;
|
this.title = title;
|
||||||
this.topic = topic;
|
this.topic = topic;
|
||||||
this.URL_article = url_article;
|
this.URL_article = url_article;
|
||||||
this.mainAuthor = mainAuthor;
|
this.mainAuthor = mainAuthor;
|
||||||
this.secondaryAuthors = secondaryAuthor;
|
if(secondaryAuthor != null){
|
||||||
|
this.secondaryAuthors = new ArrayList<String>(secondaryAuthor);
|
||||||
|
} else {
|
||||||
|
this.secondaryAuthors = new ArrayList<String>();
|
||||||
|
}
|
||||||
this.state = state;
|
this.state = state;
|
||||||
secondaryAuthors = new ArrayList<String>();
|
|
||||||
referees = new ArrayList<User>();
|
referees = new ArrayList<User>();
|
||||||
pcMembers = new ArrayList<User>();
|
pcMembers = new ArrayList<User>();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,7 +71,6 @@ public class ArticleManagerBean implements IArticleManager, Serializable {
|
|||||||
return (List<User>) article.getReferees();
|
return (List<User>) article.getReferees();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Preference getArticlePreferenceForUser(Article article,
|
public Preference getArticlePreferenceForUser(Article article,
|
||||||
String pcMemberLogin) {
|
String pcMemberLogin) {
|
||||||
Query query = em.createQuery("SELECT p FROM Preference p WHERE p.article.id = :articleid AND p.pcMember.id = :pcmemberlogin");
|
Query query = em.createQuery("SELECT p FROM Preference p WHERE p.article.id = :articleid AND p.pcMember.id = :pcmemberlogin");
|
||||||
@@ -102,13 +101,30 @@ public class ArticleManagerBean implements IArticleManager, Serializable {
|
|||||||
User pcMember = em.find(User.class, userLogin);
|
User pcMember = em.find(User.class, userLogin);
|
||||||
preference.setPcMember(pcMember);
|
preference.setPcMember(pcMember);
|
||||||
preference.setPreference(preferenceValue);
|
preference.setPreference(preferenceValue);
|
||||||
//c'est mal !!!
|
|
||||||
// FIXME
|
|
||||||
em.persist(preference);
|
em.persist(preference);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addOrUpdatePreference(Preference preference){
|
||||||
|
if(existsPreference(preference)){
|
||||||
|
updatePreference(preference);
|
||||||
|
} else {
|
||||||
|
addArticlePreference(preference);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updatePreference(Preference preference){
|
||||||
|
em.merge(preference);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean existsArticle(Article article) {
|
||||||
|
return em.find(Article.class, article.getId())!=null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean existsPreference(Preference preference) {
|
||||||
|
return em.find(Preference.class, preference.getId())!=null;
|
||||||
|
}
|
||||||
|
|
||||||
public EntityManager getEntityManager() {
|
public EntityManager getEntityManager() {
|
||||||
return em;
|
return em;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,9 @@ public interface IArticleManager {
|
|||||||
public Preference getArticlePreferenceForUser(Article article, String pcMemberLogin);
|
public Preference getArticlePreferenceForUser(Article article, String pcMemberLogin);
|
||||||
public void setArticlePreferences(Article article, List<Preference> preferences);
|
public void setArticlePreferences(Article article, List<Preference> preferences);
|
||||||
public void addArticlePreference(Integer article_id, String userLogin, String preferenceValue);
|
public void addArticlePreference(Integer article_id, String userLogin, String preferenceValue);
|
||||||
|
public void addOrUpdatePreference(Preference preference);
|
||||||
|
public boolean existsArticle(Article article);
|
||||||
|
public boolean existsPreference(Preference preference);
|
||||||
|
|
||||||
public List<Article> getArticles();
|
public List<Article> getArticles();
|
||||||
|
|
||||||
|
|||||||
@@ -77,6 +77,13 @@ public class Preference implements Serializable {
|
|||||||
public void setPreference(String preference) {
|
public void setPreference(String preference) {
|
||||||
this.preference = preference;
|
this.preference = preference;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PreferencePK getId(){
|
||||||
|
PreferencePK id = new PreferencePK();
|
||||||
|
id.setArticle(this.article);
|
||||||
|
id.setPcMember(this.pcMember);
|
||||||
|
return id;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,173 +1,172 @@
|
|||||||
package org.yacos.core.conferences;
|
package org.yacos.core.conferences;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.Collection;
|
||||||
import java.util.Collection;
|
import java.util.Date;
|
||||||
import java.util.Date;
|
|
||||||
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.GeneratedValue;
|
||||||
import javax.persistence.GeneratedValue;
|
import javax.persistence.GenerationType;
|
||||||
import javax.persistence.GenerationType;
|
import javax.persistence.Id;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.OneToMany;
|
||||||
import javax.persistence.OneToMany;
|
import javax.persistence.Temporal;
|
||||||
import javax.persistence.Temporal;
|
import javax.persistence.TemporalType;
|
||||||
import javax.persistence.TemporalType;
|
|
||||||
|
import org.yacos.core.article.Article;
|
||||||
import org.yacos.core.article.Article;
|
import org.yacos.core.users.Role;
|
||||||
import org.yacos.core.users.Role;
|
|
||||||
|
|
||||||
|
@Entity
|
||||||
@Entity
|
public class Conference implements Serializable{
|
||||||
public class Conference implements Serializable{
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
@Id
|
||||||
@Id
|
@GeneratedValue(strategy=GenerationType.AUTO)
|
||||||
@GeneratedValue(strategy=GenerationType.AUTO)
|
private Integer id;
|
||||||
private Integer id;
|
private String titre;
|
||||||
private String titre;
|
private String description;
|
||||||
private String description;
|
private String otherInformations;
|
||||||
private String otherInformations;
|
@Temporal(TemporalType.DATE)
|
||||||
@Temporal(TemporalType.DATE)
|
private Date dateAbstract;
|
||||||
private Date dateAbstract;
|
@Temporal(TemporalType.DATE)
|
||||||
@Temporal(TemporalType.DATE)
|
private Date dateArticle;
|
||||||
private Date dateArticle;
|
@Temporal(TemporalType.DATE)
|
||||||
@Temporal(TemporalType.DATE)
|
private Date dateEvaluation;
|
||||||
private Date dateEvaluation;
|
@Temporal(TemporalType.DATE)
|
||||||
@Temporal(TemporalType.DATE)
|
private Date dateStart;
|
||||||
private Date dateStart;
|
@Temporal(TemporalType.DATE)
|
||||||
@Temporal(TemporalType.DATE)
|
private Date dateEnd;
|
||||||
private Date dateEnd;
|
|
||||||
|
/**
|
||||||
/**
|
* Roles of users for this conference
|
||||||
* Roles of users for this conference
|
*/
|
||||||
*/
|
@OneToMany(targetEntity=Role.class,mappedBy="conference")
|
||||||
@OneToMany(targetEntity=Role.class,mappedBy="conference")
|
private Collection<Role> roles;
|
||||||
private Collection<Role> roles;
|
|
||||||
|
/*@OneToOne(targetEntity=User.class,optional=true)
|
||||||
/*@OneToOne(targetEntity=User.class,optional=true)
|
@JoinColumn(name="chairman_id",nullable=true)
|
||||||
@JoinColumn(name="chairman_id",nullable=true)
|
private User chairman;
|
||||||
private User chairman;
|
*/
|
||||||
*/
|
@OneToMany(targetEntity=Article.class,mappedBy="conference")
|
||||||
@OneToMany(targetEntity=Article.class,mappedBy="conference")
|
private Collection<Article> articles;
|
||||||
private Collection<Article> articles;
|
|
||||||
|
/**
|
||||||
/**
|
* @return the chairman
|
||||||
* @return the chairman
|
*/
|
||||||
*/
|
/*@OneToOne(targetEntity=User.class,optional=true)
|
||||||
/*@OneToOne(targetEntity=User.class,optional=true)
|
@JoinColumn(name="chairman_id",nullable=true)
|
||||||
@JoinColumn(name="chairman_id",nullable=true)
|
public User getChairman() {
|
||||||
public User getChairman() {
|
return chairman;
|
||||||
return chairman;
|
}
|
||||||
}
|
*/
|
||||||
*/
|
/**
|
||||||
/**
|
* @param chairman the chairman to set
|
||||||
* @param chairman the chairman to set
|
*/
|
||||||
*/
|
/*
|
||||||
/*
|
@OneToOne(targetEntity=User.class,optional=true)
|
||||||
@OneToOne(targetEntity=User.class,optional=true)
|
@JoinColumn(name="chairman_id",nullable=true)
|
||||||
@JoinColumn(name="chairman_id",nullable=true)
|
public void setChairman(User chairman) {
|
||||||
public void setChairman(User chairman) {
|
this.chairman = chairman;
|
||||||
this.chairman = chairman;
|
}
|
||||||
}
|
*/
|
||||||
*/
|
@Temporal(TemporalType.DATE)
|
||||||
@Temporal(TemporalType.DATE)
|
public Date getDataAbstract() {
|
||||||
public Date getDataAbstract() {
|
return dateAbstract;
|
||||||
return dateAbstract;
|
}
|
||||||
}
|
|
||||||
|
@Temporal(TemporalType.DATE)
|
||||||
@Temporal(TemporalType.DATE)
|
public void setDataAbstract(Date dataAbstract) {
|
||||||
public void setDataAbstract(Date dataAbstract) {
|
this.dateAbstract = dataAbstract;
|
||||||
this.dateAbstract = dataAbstract;
|
}
|
||||||
}
|
@Temporal(TemporalType.DATE)
|
||||||
@Temporal(TemporalType.DATE)
|
public Date getDateArticle() {
|
||||||
public Date getDateArticle() {
|
return dateArticle;
|
||||||
return dateArticle;
|
}
|
||||||
}
|
@Temporal(TemporalType.DATE)
|
||||||
@Temporal(TemporalType.DATE)
|
public void setDateArticle(Date dateArticle) {
|
||||||
public void setDateArticle(Date dateArticle) {
|
this.dateArticle = dateArticle;
|
||||||
this.dateArticle = dateArticle;
|
}
|
||||||
}
|
@Temporal(TemporalType.DATE)
|
||||||
@Temporal(TemporalType.DATE)
|
public Date getDateEnd() {
|
||||||
public Date getDateEnd() {
|
return dateEnd;
|
||||||
return dateEnd;
|
}
|
||||||
}
|
@Temporal(TemporalType.DATE)
|
||||||
@Temporal(TemporalType.DATE)
|
public void setDateEnd(Date dateEnd) {
|
||||||
public void setDateEnd(Date dateEnd) {
|
this.dateEnd = dateEnd;
|
||||||
this.dateEnd = dateEnd;
|
}
|
||||||
}
|
@Temporal(TemporalType.DATE)
|
||||||
@Temporal(TemporalType.DATE)
|
public Date getDateEvaluation() {
|
||||||
public Date getDateEvaluation() {
|
return dateEvaluation;
|
||||||
return dateEvaluation;
|
}
|
||||||
}
|
@Temporal(TemporalType.DATE)
|
||||||
@Temporal(TemporalType.DATE)
|
public void setDateEvaluation(Date dateEvaluation) {
|
||||||
public void setDateEvaluation(Date dateEvaluation) {
|
this.dateEvaluation = dateEvaluation;
|
||||||
this.dateEvaluation = dateEvaluation;
|
}
|
||||||
}
|
@Temporal(TemporalType.DATE)
|
||||||
@Temporal(TemporalType.DATE)
|
public Date getDateStart() {
|
||||||
public Date getDateStart() {
|
return dateStart;
|
||||||
return dateStart;
|
}
|
||||||
}
|
@Temporal(TemporalType.DATE)
|
||||||
@Temporal(TemporalType.DATE)
|
public void setDateStart(Date dateStart) {
|
||||||
public void setDateStart(Date dateStart) {
|
this.dateStart = dateStart;
|
||||||
this.dateStart = dateStart;
|
}
|
||||||
}
|
public String getDescription() {
|
||||||
public String getDescription() {
|
return description;
|
||||||
return description;
|
}
|
||||||
}
|
public void setDescription(String descirption) {
|
||||||
public void setDescription(String descirption) {
|
this.description = descirption;
|
||||||
this.description = descirption;
|
}
|
||||||
}
|
public String getOtherInformations() {
|
||||||
public String getOtherInformations() {
|
return otherInformations;
|
||||||
return otherInformations;
|
}
|
||||||
}
|
public void setOtherInformations(String otherInformations) {
|
||||||
public void setOtherInformations(String otherInformations) {
|
this.otherInformations = otherInformations;
|
||||||
this.otherInformations = otherInformations;
|
}
|
||||||
}
|
public String getTitre() {
|
||||||
public String getTitre() {
|
return titre;
|
||||||
return titre;
|
}
|
||||||
}
|
public void setTitre(String titre) {
|
||||||
public void setTitre(String titre) {
|
this.titre = titre;
|
||||||
this.titre = titre;
|
}
|
||||||
}
|
public Integer getId() {
|
||||||
public Integer getId() {
|
return id;
|
||||||
return id;
|
}
|
||||||
}
|
public void setId(Integer id) {
|
||||||
public void setId(Integer id) {
|
this.id = id;
|
||||||
this.id = id;
|
}
|
||||||
}
|
|
||||||
|
public Conference() {
|
||||||
public Conference() {
|
this.roles = new ArrayList<Role>();
|
||||||
this.roles = new ArrayList<Role>();
|
}
|
||||||
}
|
|
||||||
|
public Conference(String titre, String descirption, String infoComplementray, Date dataAbstract, Date dateArticle, Date dateEvaluation, Date dateStart, Date dateEnd) {
|
||||||
public Conference(String titre, String descirption, String infoComplementray, Date dataAbstract, Date dateArticle, Date dateEvaluation, Date dateStart, Date dateEnd) {
|
this();
|
||||||
this();
|
this.titre = titre;
|
||||||
this.titre = titre;
|
this.description = descirption;
|
||||||
this.description = descirption;
|
this.otherInformations = infoComplementray;
|
||||||
this.otherInformations = infoComplementray;
|
this.dateAbstract = dataAbstract;
|
||||||
this.dateAbstract = dataAbstract;
|
this.dateArticle = dateArticle;
|
||||||
this.dateArticle = dateArticle;
|
this.dateEvaluation = dateEvaluation;
|
||||||
this.dateEvaluation = dateEvaluation;
|
this.dateStart = dateStart;
|
||||||
this.dateStart = dateStart;
|
this.dateEnd = dateEnd;
|
||||||
this.dateEnd = dateEnd;
|
}
|
||||||
}
|
|
||||||
|
@OneToMany(targetEntity=Article.class,mappedBy="articles")
|
||||||
@OneToMany(targetEntity=Article.class,mappedBy="articles")
|
public void setArticles(Collection<Article> articles) {
|
||||||
public void setArticles(Collection<Article> articles) {
|
this.articles = articles;
|
||||||
this.articles = articles;
|
}
|
||||||
}
|
|
||||||
|
@OneToMany(targetEntity=Article.class,mappedBy="articles")
|
||||||
@OneToMany(targetEntity=Article.class,mappedBy="articles")
|
public Collection<Article> getArticles() {
|
||||||
public Collection<Article> getArticles() {
|
return articles;
|
||||||
return articles;
|
}
|
||||||
}
|
|
||||||
|
public Collection<Role> getRoles() {
|
||||||
public Collection<Role> getRoles() {
|
return roles;
|
||||||
return roles;
|
}
|
||||||
}
|
|
||||||
|
public void setRoles(Collection<Role> roles) {
|
||||||
public void setRoles(Collection<Role> roles) {
|
this.roles = roles;
|
||||||
this.roles = roles;
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|||||||
@@ -13,6 +13,6 @@ public interface IUserManager {
|
|||||||
public void removeUser(User user);
|
public void removeUser(User user);
|
||||||
public User getUser(String login);
|
public User getUser(String login);
|
||||||
public void UpdateUser(User user);
|
public void UpdateUser(User user);
|
||||||
public Boolean existe(User user);
|
public Boolean exists(User user);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ public class UserManagerBean implements IUserManager{
|
|||||||
* @param user
|
* @param user
|
||||||
*/
|
*/
|
||||||
public void addUser(User user) throws PKAlreadyUsedException{
|
public void addUser(User user) throws PKAlreadyUsedException{
|
||||||
if (!this.existe(user)){
|
if (!this.exists(user)){
|
||||||
em.persist(user);
|
em.persist(user);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
@@ -58,7 +58,7 @@ public class UserManagerBean implements IUserManager{
|
|||||||
em.merge(user);
|
em.merge(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean existe(User user){
|
public Boolean exists(User user){
|
||||||
return (this.getUser(user.getLogin())!= null);
|
return (this.getUser(user.getLogin())!= null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user