This commit is contained in:
2007-12-16 23:24:51 +00:00
parent f99039918d
commit 3f9b532c67
13 changed files with 100 additions and 37 deletions

View File

@@ -73,7 +73,7 @@ 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) { ArrayList<String> secondaryAuthor, int state) {
this.id = id; 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;

View File

@@ -1,11 +1,8 @@
package org.yacos.core.conferences; package org.yacos.core.conferences;
import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Date; import java.util.Date;
import java.util.List;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue; import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType; import javax.persistence.GenerationType;
import javax.persistence.Id; import javax.persistence.Id;
@@ -22,7 +19,7 @@ import org.yacos.core.users.User;
public class Conference { public class Conference {
@Id @Id
@GeneratedValue(strategy=GenerationType.AUTO) @GeneratedValue(strategy=GenerationType.AUTO)
private String id; private Integer id;
private String titre; private String titre;
private String description; private String description;
private String otherInformations; private String otherInformations;
@@ -121,17 +118,17 @@ public class Conference {
public void setTitre(String titre) { public void setTitre(String titre) {
this.titre = titre; this.titre = titre;
} }
public String getId() { public Integer getId() {
return id; return id;
} }
public void setId(String id) { public void setId(Integer id) {
this.id = id; this.id = id;
} }
public Conference() { public Conference() {
} }
public Conference(String id, String titre, String descirption, String infoComplementray, Date dataAbstract, Date dateArticle, Date dateEvaluation, Date dateStart, Date dateEnd) { public Conference(Integer id, String titre, String descirption, String infoComplementray, Date dataAbstract, Date dateArticle, Date dateEvaluation, Date dateStart, Date dateEnd) {
super(); super();
this.id = id; this.id = id;
this.titre = titre; this.titre = titre;

View File

@@ -1,15 +1,11 @@
package org.yacos.core.conferences; package org.yacos.core.conferences;
import javax.ejb.Stateless; import javax.ejb.Stateless;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection;
import java.util.List; import java.util.List;
import javax.persistence.EntityManager; import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext; import javax.persistence.PersistenceContext;
import org.yacos.core.article.Article; import org.yacos.core.article.Article;
import org.yacos.core.article.ArticleManagerBean;
@Stateless @Stateless
public class ConferenceManagerBean implements IConferenceManager { public class ConferenceManagerBean implements IConferenceManager {
@@ -20,6 +16,7 @@ public class ConferenceManagerBean implements IConferenceManager {
em.persist(conf); em.persist(conf);
} }
@SuppressWarnings("unchecked")
public List<Conference> getConferences() { public List<Conference> getConferences() {
return em.createQuery("from Conference conf ORDER BY conf.id").getResultList(); return em.createQuery("from Conference conf ORDER BY conf.id").getResultList();
} }

View File

@@ -22,8 +22,8 @@ public class Criterion {
@GeneratedValue(strategy=GenerationType.AUTO) @GeneratedValue(strategy=GenerationType.AUTO)
private Integer id; private Integer id;
private String name; private String name;
private Integer min; private Integer min_rating;
private Integer max; private Integer max_rating;
@ManyToOne(targetEntity=Conference.class) @ManyToOne(targetEntity=Conference.class)
@JoinColumn(name="conference_id",nullable=false) @JoinColumn(name="conference_id",nullable=false)
@@ -78,28 +78,28 @@ public class Criterion {
* @return the minimum value for this criterion * @return the minimum value for this criterion
*/ */
public Integer getMin() { public Integer getMin() {
return min; return min_rating;
} }
/** /**
* @param min the minimum value for this criterion * @param min the minimum value for this criterion
*/ */
public void setMin(Integer min) { public void setMin(Integer min) {
this.min = min; this.min_rating = min;
} }
/** /**
* @return the maximum value for this criterion * @return the maximum value for this criterion
*/ */
public Integer getMax() { public Integer getMax() {
return max; return max_rating;
} }
/** /**
* @param max the maximum value for this criterion * @param max the maximum value for this criterion
*/ */
public void setMax(Integer max) { public void setMax(Integer max) {
this.max = max; this.max_rating = max;
} }
} }

View File

@@ -3,10 +3,26 @@
*/ */
package org.yacos.core.evaluation; package org.yacos.core.evaluation;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import org.yacos.core.article.Article;
/** /**
* @author christiancorsano * @author christiancorsano
* *
*/ */
@Stateless
public class EvaluationManager implements IEvaluationManager { public class EvaluationManager implements IEvaluationManager {
@PersistenceContext
EntityManager em;
@SuppressWarnings("unchecked")
public List<Report> getReportsForArticle(Article article) {
Query q = em.createNativeQuery("from Report where article_id="+article.getId(), Report.class);
return q.getResultList();
}
} }

View File

@@ -3,10 +3,17 @@
*/ */
package org.yacos.core.evaluation; package org.yacos.core.evaluation;
import java.util.List;
import javax.ejb.Remote;
import org.yacos.core.article.Article;
/** /**
* @author christiancorsano * @author christiancorsano
* *
*/ */
@Remote
public interface IEvaluationManager { public interface IEvaluationManager {
public List<Report> getReportsForArticle(Article article);
} }

View File

@@ -4,6 +4,7 @@
package org.yacos.core.evaluation; package org.yacos.core.evaluation;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue; import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType; import javax.persistence.GenerationType;
import javax.persistence.Id; import javax.persistence.Id;
@@ -20,7 +21,7 @@ public class Rating {
@GeneratedValue(strategy=GenerationType.AUTO) @GeneratedValue(strategy=GenerationType.AUTO)
private Integer id; private Integer id;
private Integer value; private Integer value;
@ManyToOne(targetEntity=Criterion.class) @ManyToOne(targetEntity=Criterion.class,fetch=FetchType.EAGER)
@JoinColumn(name="criterion_id",nullable=false) @JoinColumn(name="criterion_id",nullable=false)
private Criterion criterion; private Criterion criterion;
@ManyToOne(targetEntity=Report.class) @ManyToOne(targetEntity=Report.class)

View File

@@ -7,6 +7,7 @@ import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue; import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType; import javax.persistence.GenerationType;
import javax.persistence.Id; import javax.persistence.Id;
@@ -28,7 +29,7 @@ public class Report {
private Integer id; private Integer id;
private String commentPCMember; private String commentPCMember;
private String commentAuthor; private String commentAuthor;
@OneToMany(targetEntity=Rating.class,mappedBy="report") @OneToMany(targetEntity=Rating.class,mappedBy="report",fetch=FetchType.EAGER)
private Collection<Rating> ratings; private Collection<Rating> ratings;
@ManyToOne(targetEntity=User.class) @ManyToOne(targetEntity=User.class)
@JoinColumn(name="referee_id",nullable=false) @JoinColumn(name="referee_id",nullable=false)

View File

@@ -2,8 +2,9 @@ package org.yacos.core.users;
import java.util.Collection; import java.util.Collection;
public interface IUserManagerBean { public interface IUsersManager {
public Collection<User> getUsers(); public Collection<User> getUsers();
public void addUser(User user); public void addUser(User user);
public void removeUser(User user); public void removeUser(User user);
public User getUser(String login);
} }

View File

@@ -1,6 +1,5 @@
package org.yacos.core.users; package org.yacos.core.users;
import javax.persistence.Basic;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.EnumType; import javax.persistence.EnumType;
import javax.persistence.Enumerated; import javax.persistence.Enumerated;
@@ -9,8 +8,6 @@ import javax.persistence.GenerationType;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.JoinColumn; import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne; import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import org.yacos.core.conferences.Conference; import org.yacos.core.conferences.Conference;
import org.yacos.core.users.RoleType.RoleTypeEnum; import org.yacos.core.users.RoleType.RoleTypeEnum;

View File

@@ -1,8 +1,6 @@
package org.yacos.core.users; package org.yacos.core.users;
import java.util.Collection; import java.util.Collection;
import java.util.Set;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.OneToMany; import javax.persistence.OneToMany;
@@ -97,7 +95,7 @@ public class User {
} }
public void addRole(Role role){ public void addRole(Role role){
// TODO roles.add(role);
} }
public void addRoleForConference(RoleType roleType, Conference conference){ public void addRoleForConference(RoleType roleType, Conference conference){
@@ -115,8 +113,7 @@ public class User {
@OneToMany(targetEntity=Role.class,mappedBy="user") @OneToMany(targetEntity=Role.class,mappedBy="user")
public Collection<Role> getRoles(){ public Collection<Role> getRoles(){
// TODO return roles;
return null;
} }
/** /**

View File

@@ -6,16 +6,23 @@ package org.yacos.core.users;
import java.util.Collection; import java.util.Collection;
import javax.ejb.Stateless; import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
/** /**
* @author christiancorsano * @author christiancorsano
* *
*/ */
@Stateless @Stateless
public class UsersManagerBean implements IUserManagerBean{ public class UsersManagerBean implements IUsersManager{
@PersistenceContext
EntityManager em;
@SuppressWarnings("unchecked")
public Collection<User> getUsers(){ public Collection<User> getUsers(){
// TODO Query query = em.createNativeQuery("from User", User.class);
return null; return query.getResultList();
} }
/** /**
@@ -23,7 +30,7 @@ public class UsersManagerBean implements IUserManagerBean{
* @param user * @param user
*/ */
public void addUser(User user){ public void addUser(User user){
// TODO em.persist(user);
} }
/** /**
@@ -31,6 +38,11 @@ public class UsersManagerBean implements IUserManagerBean{
* @param user * @param user
*/ */
public void removeUser(User user){ public void removeUser(User user){
// TODO User persistedUser = em.find(User.class, user.getLogin());
em.remove(persistedUser);
}
public User getUser(String login) {
return em.find(User.class, login);
} }
} }

View File

@@ -2,6 +2,43 @@ package org.yacos.tests.core;
import static org.junit.Assert.*; import static org.junit.Assert.*;
public class TestUser { import javax.naming.Context;
import javax.naming.InitialContext;
import org.junit.Before;
import org.junit.Test;
import org.yacos.core.users.IUsersManager;
import org.yacos.core.users.User;
public class TestUser {
private IUsersManager manager;
@Before
public void setUp() throws Exception {
Context context = new InitialContext();
manager = (IUsersManager) context.lookup("UsersManagerBean/remote");
manager.removeUser(manager.getUser("toto"));
User toto = new User();
toto.setLogin("toto");
toto.setFirstName("Toto");
toto.setLastName("John");
manager.addUser(toto);
}
@Test
public void testManagerPresence(){
assertNotNull(manager);
}
@Test
public void testUserWritingReading(){
User user = manager.getUser("toto");
assertNotNull(user);
assertEquals("toto", user.getLogin());
assertEquals("Toto", user.getLastName());
assertEquals("John", user.getFirstName());
}
} }