This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
*/
|
||||
package org.yacos.core.evaluation;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
@@ -17,7 +19,12 @@ import org.yacos.core.conferences.Conference;
|
||||
*
|
||||
*/
|
||||
@Entity
|
||||
public class Criterion {
|
||||
public class Criterion implements Serializable {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy=GenerationType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
@@ -6,13 +6,18 @@ package org.yacos.core.evaluation;
|
||||
import java.util.List;
|
||||
|
||||
import javax.ejb.Stateless;
|
||||
import javax.naming.Context;
|
||||
import javax.naming.InitialContext;
|
||||
import javax.naming.NamingException;
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceContext;
|
||||
import javax.persistence.Query;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.yacos.core.article.Article;
|
||||
import org.yacos.core.conferences.Conference;
|
||||
import org.yacos.core.conferences.ConferenceManagerBean;
|
||||
import org.yacos.core.conferences.IConferenceManager;
|
||||
import org.yacos.core.users.User;
|
||||
|
||||
/**
|
||||
* @author christiancorsano
|
||||
@@ -22,12 +27,30 @@ import org.yacos.core.conferences.ConferenceManagerBean;
|
||||
public class EvaluationManagerBean implements IEvaluationManager {
|
||||
@PersistenceContext
|
||||
EntityManager em;
|
||||
private ConferenceManagerBean cm = new ConferenceManagerBean();
|
||||
|
||||
protected final Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
private IConferenceManager cm;
|
||||
|
||||
private IConferenceManager getConferenceManager(){
|
||||
Context context;
|
||||
try {
|
||||
context = new InitialContext();
|
||||
cm = (IConferenceManager)context.lookup("ConferenceManagerBean/remote");
|
||||
} catch (NamingException e) {
|
||||
logger.error(e.getMessage());
|
||||
}
|
||||
return cm;
|
||||
}
|
||||
|
||||
public List<Criterion> getCriterions(int confId){
|
||||
ConferenceManagerBean cm = new ConferenceManagerBean();
|
||||
Conference conf = cm.getConference(confId);
|
||||
return conf.getCriterions();
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<Criterion> getCriterions(int confId){
|
||||
//Query q = em.createQuery("from Criterion");
|
||||
Query query = em.createQuery("from Criterion where conference_id = ?");
|
||||
query.setParameter(1, confId);
|
||||
return query.getResultList();
|
||||
//return q.getResultList();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@@ -37,11 +60,13 @@ public class EvaluationManagerBean implements IEvaluationManager {
|
||||
}
|
||||
|
||||
public Criterion addCriterion(String name, Integer min_rating,
|
||||
Integer max_rating, int confId) {
|
||||
Integer max_rating, int confId) {
|
||||
cm = getConferenceManager();
|
||||
Criterion crit = new Criterion();
|
||||
crit.setName(name);
|
||||
crit.setMin(min_rating);
|
||||
crit.setMax(max_rating);
|
||||
System.out.println();
|
||||
crit.setConference(cm.getConference(confId));
|
||||
em.persist(crit);
|
||||
em.flush();
|
||||
@@ -49,10 +74,38 @@ public class EvaluationManagerBean implements IEvaluationManager {
|
||||
}
|
||||
|
||||
public void updateCriterion(Criterion criterion) {
|
||||
// TODO Auto-generated method stub
|
||||
em.merge(criterion);
|
||||
em.flush();
|
||||
}
|
||||
|
||||
public void removeCriterion(int criterionId) {
|
||||
Criterion criterion = this.getCriterion(criterionId);
|
||||
em.remove(criterion);
|
||||
}
|
||||
|
||||
public Criterion getCriterion(int criterionId) {
|
||||
return em.find(Criterion.class, criterionId);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* methodes du Report
|
||||
*/
|
||||
|
||||
public Report addReport(Article article) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public List<Report> getReportsForUser(User user) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public void updateReport(Report report) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import java.util.List;
|
||||
import javax.ejb.Remote;
|
||||
|
||||
import org.yacos.core.article.Article;
|
||||
import org.yacos.core.users.User;
|
||||
|
||||
/**
|
||||
* @author christiancorsano
|
||||
@@ -20,7 +21,11 @@ public interface IEvaluationManager {
|
||||
Integer max_rating, int confId);
|
||||
public Criterion getCriterion(int criterionId);
|
||||
public void updateCriterion(Criterion criterion);
|
||||
|
||||
public List<Report> getReportsForArticle(Article article);
|
||||
public void removeCriterion(int criterionId);
|
||||
public List<Criterion> getCriterions(int confId);
|
||||
|
||||
public Report addReport(Article article);
|
||||
public void updateReport(Report report);
|
||||
public List<Report> getReportsForArticle(Article article);
|
||||
public List<Report> getReportsForUser(User user);
|
||||
}
|
||||
|
||||
@@ -126,5 +126,4 @@ public class Report {
|
||||
public void setRatings(ArrayList<Rating> ratings) {
|
||||
this.ratings = ratings;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user