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.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
@@ -77,15 +79,18 @@ public class Article implements Serializable {
|
||||
|
||||
public Article(int reference, String title, String topic,
|
||||
String url_article, String mainAuthor,
|
||||
ArrayList<String> secondaryAuthor, int state) {
|
||||
List<String> secondaryAuthor, int state) {
|
||||
//this.id = reference;
|
||||
this.title = title;
|
||||
this.topic = topic;
|
||||
this.URL_article = url_article;
|
||||
this.mainAuthor = mainAuthor;
|
||||
this.secondaryAuthors = secondaryAuthor;
|
||||
if(secondaryAuthor != null){
|
||||
this.secondaryAuthors = new ArrayList<String>(secondaryAuthor);
|
||||
} else {
|
||||
this.secondaryAuthors = new ArrayList<String>();
|
||||
}
|
||||
this.state = state;
|
||||
secondaryAuthors = new ArrayList<String>();
|
||||
referees = new ArrayList<User>();
|
||||
pcMembers = new ArrayList<User>();
|
||||
}
|
||||
|
||||
@@ -71,7 +71,6 @@ public class ArticleManagerBean implements IArticleManager, Serializable {
|
||||
return (List<User>) article.getReferees();
|
||||
}
|
||||
|
||||
|
||||
public Preference getArticlePreferenceForUser(Article article,
|
||||
String 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);
|
||||
preference.setPcMember(pcMember);
|
||||
preference.setPreference(preferenceValue);
|
||||
//c'est mal !!!
|
||||
// FIXME
|
||||
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() {
|
||||
return em;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,6 +16,9 @@ public interface IArticleManager {
|
||||
public Preference getArticlePreferenceForUser(Article article, String pcMemberLogin);
|
||||
public void setArticlePreferences(Article article, List<Preference> preferences);
|
||||
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();
|
||||
|
||||
|
||||
@@ -77,6 +77,13 @@ public class Preference implements Serializable {
|
||||
public void setPreference(String 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;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
|
||||
import org.yacos.core.article.Article;
|
||||
import org.yacos.core.users.Role;
|
||||
|
||||
|
||||
@Entity
|
||||
public class Conference implements Serializable{
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy=GenerationType.AUTO)
|
||||
private Integer id;
|
||||
private String titre;
|
||||
private String description;
|
||||
private String otherInformations;
|
||||
@Temporal(TemporalType.DATE)
|
||||
private Date dateAbstract;
|
||||
@Temporal(TemporalType.DATE)
|
||||
private Date dateArticle;
|
||||
@Temporal(TemporalType.DATE)
|
||||
private Date dateEvaluation;
|
||||
@Temporal(TemporalType.DATE)
|
||||
private Date dateStart;
|
||||
@Temporal(TemporalType.DATE)
|
||||
private Date dateEnd;
|
||||
|
||||
/**
|
||||
* Roles of users for this conference
|
||||
*/
|
||||
@OneToMany(targetEntity=Role.class,mappedBy="conference")
|
||||
private Collection<Role> roles;
|
||||
|
||||
/*@OneToOne(targetEntity=User.class,optional=true)
|
||||
@JoinColumn(name="chairman_id",nullable=true)
|
||||
private User chairman;
|
||||
*/
|
||||
@OneToMany(targetEntity=Article.class,mappedBy="conference")
|
||||
private Collection<Article> articles;
|
||||
|
||||
/**
|
||||
* @return the chairman
|
||||
*/
|
||||
/*@OneToOne(targetEntity=User.class,optional=true)
|
||||
@JoinColumn(name="chairman_id",nullable=true)
|
||||
public User getChairman() {
|
||||
return chairman;
|
||||
}
|
||||
*/
|
||||
/**
|
||||
* @param chairman the chairman to set
|
||||
*/
|
||||
/*
|
||||
@OneToOne(targetEntity=User.class,optional=true)
|
||||
@JoinColumn(name="chairman_id",nullable=true)
|
||||
public void setChairman(User chairman) {
|
||||
this.chairman = chairman;
|
||||
}
|
||||
*/
|
||||
@Temporal(TemporalType.DATE)
|
||||
public Date getDataAbstract() {
|
||||
return dateAbstract;
|
||||
}
|
||||
|
||||
@Temporal(TemporalType.DATE)
|
||||
public void setDataAbstract(Date dataAbstract) {
|
||||
this.dateAbstract = dataAbstract;
|
||||
}
|
||||
@Temporal(TemporalType.DATE)
|
||||
public Date getDateArticle() {
|
||||
return dateArticle;
|
||||
}
|
||||
@Temporal(TemporalType.DATE)
|
||||
public void setDateArticle(Date dateArticle) {
|
||||
this.dateArticle = dateArticle;
|
||||
}
|
||||
@Temporal(TemporalType.DATE)
|
||||
public Date getDateEnd() {
|
||||
return dateEnd;
|
||||
}
|
||||
@Temporal(TemporalType.DATE)
|
||||
public void setDateEnd(Date dateEnd) {
|
||||
this.dateEnd = dateEnd;
|
||||
}
|
||||
@Temporal(TemporalType.DATE)
|
||||
public Date getDateEvaluation() {
|
||||
return dateEvaluation;
|
||||
}
|
||||
@Temporal(TemporalType.DATE)
|
||||
public void setDateEvaluation(Date dateEvaluation) {
|
||||
this.dateEvaluation = dateEvaluation;
|
||||
}
|
||||
@Temporal(TemporalType.DATE)
|
||||
public Date getDateStart() {
|
||||
return dateStart;
|
||||
}
|
||||
@Temporal(TemporalType.DATE)
|
||||
public void setDateStart(Date dateStart) {
|
||||
this.dateStart = dateStart;
|
||||
}
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
public void setDescription(String descirption) {
|
||||
this.description = descirption;
|
||||
}
|
||||
public String getOtherInformations() {
|
||||
return otherInformations;
|
||||
}
|
||||
public void setOtherInformations(String otherInformations) {
|
||||
this.otherInformations = otherInformations;
|
||||
}
|
||||
public String getTitre() {
|
||||
return titre;
|
||||
}
|
||||
public void setTitre(String titre) {
|
||||
this.titre = titre;
|
||||
}
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Conference() {
|
||||
this.roles = new ArrayList<Role>();
|
||||
}
|
||||
|
||||
public Conference(String titre, String descirption, String infoComplementray, Date dataAbstract, Date dateArticle, Date dateEvaluation, Date dateStart, Date dateEnd) {
|
||||
this();
|
||||
this.titre = titre;
|
||||
this.description = descirption;
|
||||
this.otherInformations = infoComplementray;
|
||||
this.dateAbstract = dataAbstract;
|
||||
this.dateArticle = dateArticle;
|
||||
this.dateEvaluation = dateEvaluation;
|
||||
this.dateStart = dateStart;
|
||||
this.dateEnd = dateEnd;
|
||||
}
|
||||
|
||||
@OneToMany(targetEntity=Article.class,mappedBy="articles")
|
||||
public void setArticles(Collection<Article> articles) {
|
||||
this.articles = articles;
|
||||
}
|
||||
|
||||
@OneToMany(targetEntity=Article.class,mappedBy="articles")
|
||||
public Collection<Article> getArticles() {
|
||||
return articles;
|
||||
}
|
||||
|
||||
public Collection<Role> getRoles() {
|
||||
return roles;
|
||||
}
|
||||
|
||||
public void setRoles(Collection<Role> roles) {
|
||||
this.roles = roles;
|
||||
}
|
||||
}
|
||||
package org.yacos.core.conferences;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
|
||||
import org.yacos.core.article.Article;
|
||||
import org.yacos.core.users.Role;
|
||||
|
||||
|
||||
@Entity
|
||||
public class Conference implements Serializable{
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy=GenerationType.AUTO)
|
||||
private Integer id;
|
||||
private String titre;
|
||||
private String description;
|
||||
private String otherInformations;
|
||||
@Temporal(TemporalType.DATE)
|
||||
private Date dateAbstract;
|
||||
@Temporal(TemporalType.DATE)
|
||||
private Date dateArticle;
|
||||
@Temporal(TemporalType.DATE)
|
||||
private Date dateEvaluation;
|
||||
@Temporal(TemporalType.DATE)
|
||||
private Date dateStart;
|
||||
@Temporal(TemporalType.DATE)
|
||||
private Date dateEnd;
|
||||
|
||||
/**
|
||||
* Roles of users for this conference
|
||||
*/
|
||||
@OneToMany(targetEntity=Role.class,mappedBy="conference")
|
||||
private Collection<Role> roles;
|
||||
|
||||
/*@OneToOne(targetEntity=User.class,optional=true)
|
||||
@JoinColumn(name="chairman_id",nullable=true)
|
||||
private User chairman;
|
||||
*/
|
||||
@OneToMany(targetEntity=Article.class,mappedBy="conference")
|
||||
private Collection<Article> articles;
|
||||
|
||||
/**
|
||||
* @return the chairman
|
||||
*/
|
||||
/*@OneToOne(targetEntity=User.class,optional=true)
|
||||
@JoinColumn(name="chairman_id",nullable=true)
|
||||
public User getChairman() {
|
||||
return chairman;
|
||||
}
|
||||
*/
|
||||
/**
|
||||
* @param chairman the chairman to set
|
||||
*/
|
||||
/*
|
||||
@OneToOne(targetEntity=User.class,optional=true)
|
||||
@JoinColumn(name="chairman_id",nullable=true)
|
||||
public void setChairman(User chairman) {
|
||||
this.chairman = chairman;
|
||||
}
|
||||
*/
|
||||
@Temporal(TemporalType.DATE)
|
||||
public Date getDataAbstract() {
|
||||
return dateAbstract;
|
||||
}
|
||||
|
||||
@Temporal(TemporalType.DATE)
|
||||
public void setDataAbstract(Date dataAbstract) {
|
||||
this.dateAbstract = dataAbstract;
|
||||
}
|
||||
@Temporal(TemporalType.DATE)
|
||||
public Date getDateArticle() {
|
||||
return dateArticle;
|
||||
}
|
||||
@Temporal(TemporalType.DATE)
|
||||
public void setDateArticle(Date dateArticle) {
|
||||
this.dateArticle = dateArticle;
|
||||
}
|
||||
@Temporal(TemporalType.DATE)
|
||||
public Date getDateEnd() {
|
||||
return dateEnd;
|
||||
}
|
||||
@Temporal(TemporalType.DATE)
|
||||
public void setDateEnd(Date dateEnd) {
|
||||
this.dateEnd = dateEnd;
|
||||
}
|
||||
@Temporal(TemporalType.DATE)
|
||||
public Date getDateEvaluation() {
|
||||
return dateEvaluation;
|
||||
}
|
||||
@Temporal(TemporalType.DATE)
|
||||
public void setDateEvaluation(Date dateEvaluation) {
|
||||
this.dateEvaluation = dateEvaluation;
|
||||
}
|
||||
@Temporal(TemporalType.DATE)
|
||||
public Date getDateStart() {
|
||||
return dateStart;
|
||||
}
|
||||
@Temporal(TemporalType.DATE)
|
||||
public void setDateStart(Date dateStart) {
|
||||
this.dateStart = dateStart;
|
||||
}
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
public void setDescription(String descirption) {
|
||||
this.description = descirption;
|
||||
}
|
||||
public String getOtherInformations() {
|
||||
return otherInformations;
|
||||
}
|
||||
public void setOtherInformations(String otherInformations) {
|
||||
this.otherInformations = otherInformations;
|
||||
}
|
||||
public String getTitre() {
|
||||
return titre;
|
||||
}
|
||||
public void setTitre(String titre) {
|
||||
this.titre = titre;
|
||||
}
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Conference() {
|
||||
this.roles = new ArrayList<Role>();
|
||||
}
|
||||
|
||||
public Conference(String titre, String descirption, String infoComplementray, Date dataAbstract, Date dateArticle, Date dateEvaluation, Date dateStart, Date dateEnd) {
|
||||
this();
|
||||
this.titre = titre;
|
||||
this.description = descirption;
|
||||
this.otherInformations = infoComplementray;
|
||||
this.dateAbstract = dataAbstract;
|
||||
this.dateArticle = dateArticle;
|
||||
this.dateEvaluation = dateEvaluation;
|
||||
this.dateStart = dateStart;
|
||||
this.dateEnd = dateEnd;
|
||||
}
|
||||
|
||||
@OneToMany(targetEntity=Article.class,mappedBy="articles")
|
||||
public void setArticles(Collection<Article> articles) {
|
||||
this.articles = articles;
|
||||
}
|
||||
|
||||
@OneToMany(targetEntity=Article.class,mappedBy="articles")
|
||||
public Collection<Article> getArticles() {
|
||||
return articles;
|
||||
}
|
||||
|
||||
public Collection<Role> getRoles() {
|
||||
return roles;
|
||||
}
|
||||
|
||||
public void setRoles(Collection<Role> roles) {
|
||||
this.roles = roles;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,6 @@ public interface IUserManager {
|
||||
public void removeUser(User user);
|
||||
public User getUser(String login);
|
||||
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
|
||||
*/
|
||||
public void addUser(User user) throws PKAlreadyUsedException{
|
||||
if (!this.existe(user)){
|
||||
if (!this.exists(user)){
|
||||
em.persist(user);
|
||||
}
|
||||
else{
|
||||
@@ -58,7 +58,7 @@ public class UserManagerBean implements IUserManager{
|
||||
em.merge(user);
|
||||
}
|
||||
|
||||
public Boolean existe(User user){
|
||||
public Boolean exists(User user){
|
||||
return (this.getUser(user.getLogin())!= null);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user