fixed conflicts
This commit is contained in:
commit
f245259da8
resources/db_update_scripts
src
main/java/se/su/dsv/scipro/data
dao
interfaces
jpa
dataobjects
enums
test/java/se/su/dsv/scipro
@ -152,5 +152,8 @@ INSERT INTO `FinalSeminarSettings_punishMails` (`FinalSeminarSettings_id`, `puni
|
||||
ALTER TABLE `FinalSeminarSettings_punishMails`
|
||||
ADD CONSTRAINT `FK373B1D06BB47DEDF` FOREIGN KEY (`FinalSeminarSettings_id`) REFERENCES `FinalSeminarSettings` (`id`);
|
||||
|
||||
|
||||
DROP TABLE `log_entry`;
|
||||
DROP TABLE `log`;
|
||||
DROP TABLE `log`;
|
||||
|
||||
DROP TABLE `category`, `rating`, `resource`, `resource_category`, `resource_tag`, `tag`;
|
||||
|
@ -1,15 +0,0 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package se.su.dsv.scipro.data.dao.interfaces;
|
||||
|
||||
import se.su.dsv.scipro.data.dataobjects.Category;
|
||||
|
||||
/**
|
||||
* @author Johan Aschan - aschan@dsv.su.se
|
||||
*
|
||||
*/
|
||||
public interface CategoryDao extends Dao<Category>{
|
||||
|
||||
public Category findExactCategoryQuery(final String searchQuery);
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package se.su.dsv.scipro.data.dao.interfaces;
|
||||
|
||||
import se.su.dsv.scipro.data.dataobjects.Ratable;
|
||||
|
||||
/**
|
||||
* @author Johan Aschan - aschan@dsv.su.se
|
||||
*
|
||||
*/
|
||||
|
||||
public interface RatableDao extends Dao<Ratable>{
|
||||
public int getRating(final Ratable ratable);
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package se.su.dsv.scipro.data.dao.interfaces;
|
||||
|
||||
import se.su.dsv.scipro.data.dataobjects.Rating;
|
||||
|
||||
/**
|
||||
* @author Johan Aschan - aschan@dsv.su.se
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
public interface RatingDao extends Dao<Rating>{
|
||||
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package se.su.dsv.scipro.data.dao.interfaces;
|
||||
|
||||
|
||||
import se.su.dsv.scipro.data.dataobjects.Category;
|
||||
import se.su.dsv.scipro.data.dataobjects.Resource;
|
||||
import se.su.dsv.scipro.data.dataobjects.Tag;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Johan Aschan - aschan@dsv.su.se
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
public interface ResourceDao extends Dao<Resource>{
|
||||
public List<Resource> findResourcesByTag(final Tag tag);
|
||||
public List<Resource> findResourcesByCategory(final Category category);
|
||||
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package se.su.dsv.scipro.data.dao.interfaces;
|
||||
|
||||
import se.su.dsv.scipro.data.dataobjects.Tag;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Johan Aschan - aschan@dsv.su.se
|
||||
*
|
||||
*/
|
||||
|
||||
public interface TagDao extends LazyDeleteDao<Tag> {
|
||||
|
||||
public List<Tag> findTagQuery(final String searchQuery, final int limit);
|
||||
public Tag findExactTagQuery(final String searchQuery);
|
||||
|
||||
|
||||
}
|
@ -1,46 +0,0 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package se.su.dsv.scipro.data.dao.jpa;
|
||||
|
||||
import org.springframework.orm.jpa.JpaCallback;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.CategoryDao;
|
||||
import se.su.dsv.scipro.data.dataobjects.Category;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.NoResultException;
|
||||
import javax.persistence.PersistenceException;
|
||||
import javax.persistence.TypedQuery;
|
||||
|
||||
/**
|
||||
* @author Johan Aschan - aschan@dsv.su.se
|
||||
*
|
||||
*/
|
||||
|
||||
@Repository("categoryDao")
|
||||
public class CategoryDaoJPAImp extends AbstractDaoJPAImp<Category>
|
||||
implements CategoryDao {
|
||||
|
||||
public CategoryDaoJPAImp() {
|
||||
super(Category.class);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public Category findExactCategoryQuery(final String searchQuery) {
|
||||
return getJpaTemplate().execute(new JpaCallback<Category>() {
|
||||
public Category doInJpa(EntityManager em) throws PersistenceException {
|
||||
TypedQuery<Category> query = em.createQuery("select c FROM Category c WHERE c.categoryName = '" + searchQuery +"'", Category.class);
|
||||
try {
|
||||
return query.getSingleResult();
|
||||
} catch (NoResultException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,54 +0,0 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package se.su.dsv.scipro.data.dao.jpa;
|
||||
|
||||
import org.hibernate.ejb.QueryHints;
|
||||
import org.springframework.orm.jpa.JpaCallback;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.RatableDao;
|
||||
import se.su.dsv.scipro.data.dataobjects.Ratable;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceException;
|
||||
import javax.persistence.TypedQuery;
|
||||
|
||||
/**
|
||||
* @author Johan Aschan - aschan@dsv.su.se
|
||||
*
|
||||
*/
|
||||
|
||||
@Repository("ratableDao")
|
||||
public class RatableDaoJPAImp extends AbstractDaoJPAImp<Ratable> implements
|
||||
RatableDao {
|
||||
|
||||
public RatableDaoJPAImp() {
|
||||
super(Ratable.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public int getRating(final Ratable ratable) {
|
||||
|
||||
return getJpaTemplate().execute(new JpaCallback<Integer>() {
|
||||
public Integer doInJpa(EntityManager em)
|
||||
throws PersistenceException {
|
||||
TypedQuery<Long> query = em
|
||||
.createQuery(
|
||||
"SELECT COUNT (r) FROM Rating r, Ratable rata, IN(rata.ratingList) ra WHERE r.ratingValue = se.su.dsv.scipro.data.enums.RatingValue.UP and r= ra AND rata = :ratable",
|
||||
Long.class);
|
||||
query.setParameter("ratable", ratable);
|
||||
query.setHint(QueryHints.HINT_CACHEABLE, "true");
|
||||
TypedQuery<Long> query2 = em
|
||||
.createQuery(
|
||||
"SELECT COUNT (r) FROM Rating r, Ratable rata, IN(rata.ratingList) ra WHERE r.ratingValue = se.su.dsv.scipro.data.enums.RatingValue.DOWN and r= ra AND rata = :ratable",
|
||||
Long.class);
|
||||
query2.setParameter("ratable", ratable);
|
||||
query2.setHint(QueryHints.HINT_CACHEABLE, "true");
|
||||
return (query.getSingleResult()).intValue() - (query2.getSingleResult()).intValue();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package se.su.dsv.scipro.data.dao.jpa;
|
||||
|
||||
import org.springframework.stereotype.Repository;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.RatingDao;
|
||||
import se.su.dsv.scipro.data.dataobjects.Rating;
|
||||
|
||||
/**
|
||||
* @author Johan Aschan - aschan@dsv.su.se
|
||||
*
|
||||
*/
|
||||
|
||||
@Repository("ratingDao")
|
||||
public class RatingDaoJPAImp extends AbstractDaoJPAImp<Rating>
|
||||
implements RatingDao {
|
||||
|
||||
public RatingDaoJPAImp() {
|
||||
super(Rating.class);
|
||||
}
|
||||
}
|
@ -1,62 +0,0 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package se.su.dsv.scipro.data.dao.jpa;
|
||||
|
||||
import org.springframework.orm.jpa.JpaCallback;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.ResourceDao;
|
||||
import se.su.dsv.scipro.data.dataobjects.Category;
|
||||
import se.su.dsv.scipro.data.dataobjects.Resource;
|
||||
import se.su.dsv.scipro.data.dataobjects.Tag;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.NoResultException;
|
||||
import javax.persistence.PersistenceException;
|
||||
import javax.persistence.TypedQuery;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Johan Aschan - aschan@dsv.su.se
|
||||
*
|
||||
*/
|
||||
|
||||
@Repository("resourceDao")
|
||||
public class ResourceDaoJPAImp extends AbstractDaoJPAImp<Resource>
|
||||
implements ResourceDao {
|
||||
|
||||
public ResourceDaoJPAImp() {
|
||||
super(Resource.class);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public List<Resource> findResourcesByTag(final Tag tag) {
|
||||
return getJpaTemplate().execute(new JpaCallback<List<Resource>>() {
|
||||
public List<Resource> doInJpa(EntityManager em) throws PersistenceException {
|
||||
TypedQuery<Resource> query = em.createQuery("select r FROM Resource r, Tag t WHERE t MEMBER OF r.tagList AND t =:tag", Resource.class);
|
||||
query.setParameter("tag", tag);
|
||||
try {
|
||||
return query.getResultList();
|
||||
} catch (NoResultException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public List<Resource> findResourcesByCategory(final Category category) {
|
||||
return getJpaTemplate().execute(new JpaCallback<List<Resource>>() {
|
||||
public List<Resource> doInJpa(EntityManager em) throws PersistenceException {
|
||||
TypedQuery<Resource> query = em.createQuery("select r FROM Resource r, Category c WHERE c MEMBER OF r.categoryList AND c =:category", Resource.class);
|
||||
query.setParameter("category", category);
|
||||
try {
|
||||
return query.getResultList();
|
||||
} catch (NoResultException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -1,60 +0,0 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package se.su.dsv.scipro.data.dao.jpa;
|
||||
|
||||
import org.springframework.orm.jpa.JpaCallback;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.TagDao;
|
||||
import se.su.dsv.scipro.data.dataobjects.Tag;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.NoResultException;
|
||||
import javax.persistence.PersistenceException;
|
||||
import javax.persistence.TypedQuery;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Johan Aschan - aschan@dsv.su.se
|
||||
*
|
||||
*/
|
||||
|
||||
@Repository("tagDao")
|
||||
public class TagDaoJPAImp extends LazyDeleteAbstractDaoJPAImp<Tag>
|
||||
implements TagDao {
|
||||
|
||||
public TagDaoJPAImp() {
|
||||
super(Tag.class);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public List<Tag> findTagQuery(final String searchQuery,final int limit) {
|
||||
return getJpaTemplate().execute(new JpaCallback<List<Tag>>() {
|
||||
public List<Tag> doInJpa(EntityManager em) throws PersistenceException {
|
||||
TypedQuery<Tag> query = em.createQuery("select t FROM Tag t WHERE t.tag LIKE '" + searchQuery + "%' ORDER BY t.tag ASC", Tag.class);
|
||||
query.setMaxResults(limit);
|
||||
try {
|
||||
return query.getResultList();
|
||||
} catch (NoResultException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public Tag findExactTagQuery(final String searchQuery) {
|
||||
return getJpaTemplate().execute(new JpaCallback<Tag>() {
|
||||
public Tag doInJpa(EntityManager em) throws PersistenceException {
|
||||
TypedQuery<Tag> query = em.createQuery("select t FROM Tag t WHERE t.tag = '" + searchQuery +"'", Tag.class);
|
||||
try {
|
||||
return query.getSingleResult();
|
||||
} catch (NoResultException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1,72 +0,0 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package se.su.dsv.scipro.data.dataobjects;
|
||||
|
||||
import org.hibernate.annotations.Cache;
|
||||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
|
||||
import javax.persistence.*;
|
||||
|
||||
/**
|
||||
* @author Johan Aschan - aschan@dsv.su.se
|
||||
*
|
||||
*/
|
||||
|
||||
@Entity
|
||||
@Table(name="category")
|
||||
@Cacheable(true)
|
||||
@Cache(usage= CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
|
||||
public class Category extends DomainObject{
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
private Long id;
|
||||
|
||||
@Column(unique=true)
|
||||
private String categoryName;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getCategoryName() {
|
||||
return categoryName;
|
||||
}
|
||||
|
||||
public void setCategoryName(String category) {
|
||||
this.categoryName = category;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((id == null) ? 0 : id.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
Category other = (Category) obj;
|
||||
if (id == null) {
|
||||
if (other.id != null)
|
||||
return false;
|
||||
} else if (!id.equals(other.id))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -16,10 +16,19 @@ import javax.persistence.*;
|
||||
@Table(name="comment")
|
||||
@Cacheable(true)
|
||||
@Cache(usage= CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
|
||||
public class Comment extends Ratable implements Comparable<Comment> {
|
||||
public class Comment extends DomainObject implements Comparable<Comment> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.TABLE)
|
||||
private Long id;
|
||||
|
||||
@Override
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@ManyToOne(optional=false)
|
||||
private User creator;
|
||||
@Lob
|
||||
@ -63,7 +72,7 @@ public class Comment extends Ratable implements Comparable<Comment> {
|
||||
public int compareTo(Comment o) {
|
||||
if( this == o )
|
||||
return 0;
|
||||
|
||||
|
||||
if(this.getDateCreated() != null && o.getDateCreated() != null){
|
||||
// Displaying newest comment on the bottom of the list, oldest at the top.
|
||||
if(o.getDateCreated().equals(this.getDateCreated())){
|
||||
@ -75,10 +84,7 @@ public class Comment extends Ratable implements Comparable<Comment> {
|
||||
return o.getId().compareTo(this.getId());
|
||||
if(this.comment != null && o.comment != null)
|
||||
return o.comment.compareTo(comment);
|
||||
//By now we have to conclude the two objects are basically two objects full of nulls
|
||||
//By now we have to conclude the two objects are basically two objects full of nulls
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,68 +0,0 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package se.su.dsv.scipro.data.dataobjects;
|
||||
|
||||
import org.hibernate.annotations.Cache;
|
||||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Johan Aschan - aschan@dsv.su.se
|
||||
*
|
||||
*/
|
||||
@Entity
|
||||
@Inheritance(strategy=InheritanceType.TABLE_PER_CLASS)
|
||||
@Cacheable(true)
|
||||
@Cache(usage= CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
|
||||
public abstract class Ratable extends DomainObject{
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.TABLE)
|
||||
private Long id;
|
||||
|
||||
@Override
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@OneToMany
|
||||
@JoinColumn(name = "ratingObjectId")
|
||||
private List<Rating> ratingList = new ArrayList<Rating>();
|
||||
|
||||
public List<Rating> getRatingList() {
|
||||
return ratingList;
|
||||
}
|
||||
|
||||
public void setRatingList(List<Rating> ratingList) {
|
||||
this.ratingList = ratingList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((id == null) ? 0 : id.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
Ratable other = (Ratable) obj;
|
||||
if (id == null) {
|
||||
if (other.id != null)
|
||||
return false;
|
||||
} else if (!id.equals(other.id))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,54 +0,0 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package se.su.dsv.scipro.data.dataobjects;
|
||||
|
||||
import org.hibernate.annotations.Cache;
|
||||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
import se.su.dsv.scipro.data.enums.RatingValue;
|
||||
|
||||
import javax.persistence.*;
|
||||
|
||||
/**
|
||||
* @author Johan Aschan - aschan@dsv.su.se
|
||||
*
|
||||
*/
|
||||
|
||||
@Entity
|
||||
@Table(name="rating")
|
||||
@Cacheable(true)
|
||||
@Cache(usage= CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
|
||||
public class Rating extends DomainObject{
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
private Long id;
|
||||
|
||||
@Override
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
private RatingValue ratingValue;
|
||||
|
||||
@ManyToOne
|
||||
private User user;
|
||||
|
||||
public User getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public void setUser(User user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
public RatingValue getRatingValue() {
|
||||
return ratingValue;
|
||||
}
|
||||
|
||||
public void setRatingValue(RatingValue ratingValue) {
|
||||
this.ratingValue = ratingValue;
|
||||
}
|
||||
|
||||
}
|
@ -1,132 +0,0 @@
|
||||
package se.su.dsv.scipro.data.dataobjects;
|
||||
|
||||
import org.apache.wicket.injection.web.InjectorHolder;
|
||||
import org.apache.wicket.spring.injection.annot.SpringBean;
|
||||
import org.hibernate.annotations.Cache;
|
||||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
import se.su.dsv.scipro.data.dataobjects.interfaces.Commentable;
|
||||
import se.su.dsv.scipro.repository.FileRepository;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Johan Aschan - aschan@se.su.dsv
|
||||
*
|
||||
*/
|
||||
@Entity
|
||||
@Cacheable(true)
|
||||
@Cache(usage= CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
|
||||
@Table(name="resource")
|
||||
public class Resource extends Ratable implements Commentable {
|
||||
|
||||
@SpringBean
|
||||
@Transient
|
||||
private FileRepository fileRepository;
|
||||
|
||||
@PreRemove
|
||||
public void onRemove(){
|
||||
try{
|
||||
InjectorHolder.getInjector().inject(this);
|
||||
fileRepository.delete(fileRepository.getResourcePath(this.getId()));
|
||||
} catch(RuntimeException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Lob
|
||||
private String heading;
|
||||
|
||||
@Lob
|
||||
private String embedCode;
|
||||
|
||||
@Lob
|
||||
private String info;
|
||||
|
||||
@ManyToOne(optional=false)
|
||||
private User creator;
|
||||
|
||||
private boolean important = false;
|
||||
|
||||
@ManyToMany
|
||||
private List<Tag> tagList = new ArrayList<Tag>();
|
||||
|
||||
@ManyToMany
|
||||
private List<Category> categoryList = new ArrayList<Category>();
|
||||
|
||||
@Lob
|
||||
private String link;
|
||||
|
||||
public String getLink() {
|
||||
return link;
|
||||
}
|
||||
|
||||
public void setLink(String link) {
|
||||
this.link = link;
|
||||
}
|
||||
|
||||
public List<Tag> getTagList() {
|
||||
return tagList;
|
||||
}
|
||||
|
||||
public void setTagList(List<Tag> tagList) {
|
||||
this.tagList = tagList;
|
||||
}
|
||||
|
||||
public void setHeading(String heading) {
|
||||
this.heading = heading;
|
||||
}
|
||||
|
||||
public String getHeading() {
|
||||
return heading;
|
||||
}
|
||||
|
||||
public String getInfo() {
|
||||
return info;
|
||||
}
|
||||
|
||||
public void setInfo(String info) {
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public User getCreator() {
|
||||
return creator;
|
||||
}
|
||||
|
||||
public void setCreator(User creator) {
|
||||
this.creator = creator;
|
||||
}
|
||||
|
||||
public String getEmbedCode() {
|
||||
return embedCode;
|
||||
}
|
||||
|
||||
public void setEmbedCode(String embedCode) {
|
||||
this.embedCode = embedCode;
|
||||
}
|
||||
|
||||
public boolean isImportant() {
|
||||
return important;
|
||||
}
|
||||
|
||||
public void setImportant(boolean important) {
|
||||
this.important = important;
|
||||
}
|
||||
|
||||
public List<Category> getCategoryList() {
|
||||
return categoryList;
|
||||
}
|
||||
|
||||
public void setCategoryList(List<Category> categoryList) {
|
||||
this.categoryList = categoryList;
|
||||
}
|
||||
|
||||
@Override
|
||||
final public String getCommentKey() {
|
||||
return Resource.class.getCanonicalName().toString();
|
||||
}
|
||||
|
||||
}
|
@ -1,69 +0,0 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package se.su.dsv.scipro.data.dataobjects;
|
||||
|
||||
import org.hibernate.annotations.Cache;
|
||||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
|
||||
import javax.persistence.*;
|
||||
|
||||
/**
|
||||
* @author Johan Aschan - aschan@dsv.su.se
|
||||
*
|
||||
*/
|
||||
|
||||
@Entity
|
||||
@Table(name="tag")
|
||||
@Cacheable(true)
|
||||
@Cache(usage= CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
|
||||
public class Tag extends LazyDeletableDomainObject {
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
private Long id;
|
||||
|
||||
@Column(unique=true)
|
||||
private String tag;
|
||||
|
||||
@Override
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getTag() {
|
||||
return tag;
|
||||
}
|
||||
|
||||
public void setTag(String tag) {
|
||||
this.tag = tag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((id == null) ? 0 : id.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
Tag other = (Tag) obj;
|
||||
if (id == null) {
|
||||
if (other.id != null)
|
||||
return false;
|
||||
} else if (!id.equals(other.id))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package se.su.dsv.scipro.data.enums;
|
||||
|
||||
/**
|
||||
* @author Johan Aschan - aschan@dsv.su.se
|
||||
*
|
||||
*/
|
||||
public enum RatingValue {
|
||||
UP, DOWN
|
||||
}
|
@ -57,7 +57,6 @@ public abstract class SciProTest {
|
||||
@Mock protected SupervisorDao supervisorDao;
|
||||
|
||||
@Mock protected BoardMessageDao boardMessageDao;
|
||||
@Mock protected CategoryDao categoryDao;
|
||||
@Mock protected CheckListAnswerDao checkListAnswerDao;
|
||||
@Mock protected ChecklistCategoryDao checklistCategoryDao;
|
||||
@Mock protected CheckListDao checkListDao;
|
||||
@ -87,14 +86,10 @@ public abstract class SciProTest {
|
||||
@Mock protected ProjectScheduleDao projectScheduleDao;
|
||||
@Mock protected ProjectScheduleEventDao projectScheduleEventDao;
|
||||
@Mock protected QueryableDao queryableDao;
|
||||
@Mock protected RatableDao ratableDao;
|
||||
@Mock protected RatingDao ratingDao;
|
||||
@Mock protected RecipientDao recipientDao;
|
||||
@Mock protected ResourceDao resourceDao;
|
||||
@Mock protected RoleDao roleDao;
|
||||
@Mock protected ScheduleTemplateDao scheduleTemplateDao;
|
||||
@Mock protected StringResourceDao stringResourceDao;
|
||||
@Mock protected TagDao tagDao;
|
||||
@Mock protected UserDao userDao;
|
||||
@Mock protected UsernameDao usernameDao;
|
||||
@Mock protected UserSettingsDao userSettingsDao;
|
||||
|
@ -1,42 +0,0 @@
|
||||
package se.su.dsv.scipro.dao.jpa;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.annotation.Rollback;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.CategoryDao;
|
||||
import se.su.dsv.scipro.data.dataobjects.Category;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(inheritLocations = false, locations = {
|
||||
"classpath:test-applicationContext.xml"
|
||||
})
|
||||
public class TestCategoryDaoJPA {
|
||||
|
||||
@Autowired
|
||||
private CategoryDao categoryDao;
|
||||
|
||||
private Category category;
|
||||
|
||||
@Before
|
||||
public void startTransaction() {
|
||||
|
||||
category = new Category();
|
||||
category.setCategoryName("test");
|
||||
category = categoryDao.save(category);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@Transactional
|
||||
@Rollback
|
||||
public void testFindTagQuery() {
|
||||
Assert.assertEquals(category, categoryDao.findExactCategoryQuery("test"));
|
||||
}
|
||||
|
||||
}
|
@ -1,78 +0,0 @@
|
||||
package se.su.dsv.scipro.dao.jpa;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.annotation.Rollback;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.RatableDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.RatingDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.ResourceDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.UserDao;
|
||||
import se.su.dsv.scipro.data.dataobjects.Rating;
|
||||
import se.su.dsv.scipro.data.dataobjects.Resource;
|
||||
import se.su.dsv.scipro.data.dataobjects.User;
|
||||
import se.su.dsv.scipro.data.enums.RatingValue;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(inheritLocations = false, locations = {
|
||||
"classpath:test-applicationContext.xml"
|
||||
})
|
||||
public class TestRatableDaoJPA {
|
||||
|
||||
@Autowired
|
||||
private UserDao userDao;
|
||||
|
||||
@Autowired
|
||||
private ResourceDao linkDao;
|
||||
|
||||
@Autowired
|
||||
private RatingDao ratingDao;
|
||||
|
||||
private Resource link;
|
||||
|
||||
@Autowired
|
||||
private RatableDao ratableDao;
|
||||
|
||||
@Before
|
||||
public void startTransaction(){
|
||||
|
||||
User user = new User();
|
||||
user = userDao.save(user);
|
||||
Rating rating = new Rating();
|
||||
rating.setUser(user);
|
||||
rating.setRatingValue(RatingValue.UP);
|
||||
rating = ratingDao.save(rating);
|
||||
Rating rating2 = new Rating();
|
||||
rating2.setUser(user);
|
||||
rating2.setRatingValue(RatingValue.DOWN);
|
||||
rating2 = ratingDao.save(rating2);
|
||||
|
||||
link = new Resource();
|
||||
link.setCreator(user);
|
||||
List<Rating> ratingList = new ArrayList<Rating>();
|
||||
ratingList.add(rating);
|
||||
ratingList.add(rating2);
|
||||
link.setRatingList(ratingList);
|
||||
link = linkDao.save(link);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test method for {@link se.su.dsv.scipro.data.dao.jpa.EventDaoJPAImp#findAll()}.
|
||||
*/
|
||||
@Test
|
||||
@Transactional
|
||||
@Rollback
|
||||
public void getRating() {
|
||||
Assert.assertEquals(0, ratableDao.getRating(link));
|
||||
}
|
||||
}
|
@ -1,100 +0,0 @@
|
||||
package se.su.dsv.scipro.dao.jpa;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.annotation.Rollback;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.*;
|
||||
import se.su.dsv.scipro.data.dataobjects.*;
|
||||
import se.su.dsv.scipro.data.enums.RatingValue;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(inheritLocations = false, locations = {
|
||||
"classpath:test-applicationContext.xml"
|
||||
})
|
||||
public class TestResourceDaoJPA {
|
||||
|
||||
@Autowired
|
||||
private UserDao userDao;
|
||||
|
||||
@Autowired
|
||||
private ResourceDao resourceDao;
|
||||
|
||||
@Autowired
|
||||
private RatingDao ratingDao;
|
||||
|
||||
@Autowired
|
||||
private TagDao tagDao;
|
||||
|
||||
@Autowired
|
||||
private CategoryDao categoryDao;
|
||||
|
||||
private Tag tag;
|
||||
|
||||
private Category category;
|
||||
|
||||
@Autowired
|
||||
private RatableDao ratableDao;
|
||||
|
||||
@Before
|
||||
public void startTransaction(){
|
||||
|
||||
User user = new User();
|
||||
user = userDao.save(user);
|
||||
Rating rating = new Rating();
|
||||
rating.setUser(user);
|
||||
rating.setRatingValue(RatingValue.UP);
|
||||
rating = ratingDao.save(rating);
|
||||
Rating rating2 = new Rating();
|
||||
rating2.setUser(user);
|
||||
rating2.setRatingValue(RatingValue.DOWN);
|
||||
rating2 = ratingDao.save(rating2);
|
||||
|
||||
tag = new Tag();
|
||||
tag.setTag("test");
|
||||
tag = tagDao.save(tag);
|
||||
|
||||
category = new Category();
|
||||
category.setCategoryName("test");
|
||||
category = categoryDao.save(category);
|
||||
|
||||
Resource resource = new Resource();
|
||||
resource.setCreator(user);
|
||||
List<Rating> ratingList = new ArrayList<Rating>();
|
||||
ratingList.add(rating);
|
||||
ratingList.add(rating2);
|
||||
resource.getTagList().add(tag);
|
||||
resource.getCategoryList().add(category);
|
||||
resource.setRatingList(ratingList);
|
||||
resource = resourceDao.save(resource);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test method for {@link se.su.dsv.scipro.data.dao.jpa.EventDaoJPAImp#findAll()}.
|
||||
*/
|
||||
@Test
|
||||
@Transactional
|
||||
@Rollback
|
||||
public void testFindResourcesByTag() {
|
||||
Assert.assertEquals(1, resourceDao.findResourcesByTag(tag).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Transactional
|
||||
@Rollback
|
||||
public void testFindResourcesByCategory() {
|
||||
Assert.assertEquals(1, resourceDao.findResourcesByCategory(category).size());
|
||||
}
|
||||
}
|
@ -1,54 +0,0 @@
|
||||
package se.su.dsv.scipro.dao.jpa;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.annotation.Rollback;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.TagDao;
|
||||
import se.su.dsv.scipro.data.dataobjects.Tag;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(inheritLocations = false, locations = {
|
||||
"classpath:test-applicationContext.xml"
|
||||
})
|
||||
public class TestTagDaoJPA {
|
||||
|
||||
@Autowired
|
||||
private TagDao tagDao;
|
||||
|
||||
private Tag tag;
|
||||
|
||||
|
||||
@Before
|
||||
public void startTransaction() {
|
||||
|
||||
tag = new Tag();
|
||||
tag.setTag("test");
|
||||
tag = tagDao.save(tag);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link se.su.dsv.scipro.data.dao.jpa.EventDaoJPAImp#findAll()}.
|
||||
*/
|
||||
@Test
|
||||
@Transactional
|
||||
@Rollback
|
||||
public void testFindTagQuery() {
|
||||
Assert.assertEquals(1, tagDao.findTagQuery("test", 1).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Transactional
|
||||
@Rollback
|
||||
public void testFindExactTagQuery() {
|
||||
Assert.assertEquals(tag, tagDao.findExactTagQuery("test"));
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user