Removed messagboards classs that is not used any more,

supervisormessageboard, and made so that messageboard can be genarally
used like commentthread, they implement the same interface and made
some formatfixes.


Change-Id: I36cf3dc477c5429df69dd3a5f30af3c6a7982ad6
This commit is contained in:
joha-asc 2011-07-12 13:57:05 +02:00
parent 02ebe0a995
commit 642a69e3d7
10 changed files with 256 additions and 357 deletions

@ -1,88 +0,0 @@
/**
*
*/
package se.su.dsv.scipro.data.dataobjects;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import javax.persistence.OneToOne;
/**
* @author Johan Aschan - aschan@dsv.su.se
*
*/
@MappedSuperclass
public abstract class Board extends DomainObject{
@Id
@GeneratedValue
private Long id;
private String title;
@OneToOne
private Project project;
public Long getId() {
return id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public Project getProject() {
return project;
}
public void setProject(Project project) {
this.project = project;
}
@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;
Board other = (Board) obj;
if (id == null) {
if (other.id != null)
return false;
} else if (!id.equals(other.id))
return false;
return true;
}
}

@ -4,10 +4,16 @@
package se.su.dsv.scipro.data.dataobjects;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;
import javax.persistence.Cacheable;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
@ -26,13 +32,31 @@ import se.su.dsv.scipro.data.dataobjects.interfaces.Commentable;
@Table(name="board_message")
@Cacheable(true)
@Cache(usage= CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class BoardMessage extends Message implements Commentable {
public class BoardMessage extends DomainObject implements Commentable, Comparable<BoardMessage> {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue
private Long id;
@Lob
private String message;
@ManyToOne(optional=false)
private User fromUser;
@OneToMany
private List<BoardMessage> replyMessageList = new ArrayList<BoardMessage>(0);
@ManyToOne(optional=false)
private MessageBoard messageBoard;
@Override
public Long getId() {
return id;
}
public List<BoardMessage> getReplyMessageList() {
return replyMessageList;
@ -42,7 +66,6 @@ public class BoardMessage extends Message implements Commentable {
this.replyMessageList = replyMessageList;
}
/**
* @return the messageBoard
@ -62,5 +85,67 @@ public class BoardMessage extends Message implements Commentable {
public String getCommentKey() {
return BoardMessage.class.getCanonicalName().toString();
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public User getFromUser() {
return fromUser;
}
public void setFromUser(User fromUser) {
this.fromUser = fromUser;
}
@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;
BoardMessage other = (BoardMessage) obj;
if (id == null) {
if (other.id != null)
return false;
} else if (!id.equals(other.id))
return false;
return true;
}
@Override
public int compareTo(BoardMessage o) {
if( this == o )
return 0;
if(this.getDateCreated() != null && o.getDateCreated() != null){
//Reversed from what you might expect, because normally we want to display newest comment first in listviews
return o.getDateCreated().compareTo(this.getDateCreated());
}
if(this.getId() != null && o.getId() != null)
return this.getId().compareTo(o.getId());
if(this.message != null && o.message != null)
return message.compareTo(o.message);
//By now we have to conclude the two objects are basically two objects full of nulls
return 0;
}
}

@ -40,7 +40,7 @@ import se.su.dsv.scipro.data.dataobjects.interfaces.Commentable;
public class CommentThread extends DomainObject{
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue
private Long id;

@ -24,79 +24,82 @@ import javax.persistence.Table;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import se.su.dsv.scipro.data.dataobjects.interfaces.Commentable;
import se.su.dsv.scipro.data.enums.FinalSeminarLanguages;
/**
* @author Johan Aschan - aschan@dsv.su.se
*
* @author Johan Aschan - aschan@dsv.su.se
*
*/
@Entity
@Table(name="final_seminar")
@Table(name = "final_seminar")
@Cacheable(true)
@Cache(usage= CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class FinalSeminar extends DomainObject{
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class FinalSeminar extends DomainObject implements Commentable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue
private Long id;
@Override
public Long getId() {
return id;
}
@ManyToOne(optional=false)
@ManyToOne(optional = false)
private Project project;
@Basic(optional=false)
@Basic(optional = false)
private Date startDate;
@Basic(optional=false)
@Basic(optional = false)
private Date endDate;
@Basic(optional=false)
@Basic(optional = false)
private String room;
@OneToMany(mappedBy="finalSeminar")
@OneToMany(mappedBy = "finalSeminar")
private List<FinalSeminarActiveParticipation> activeParticipations = new ArrayList<FinalSeminarActiveParticipation>();
@OneToMany(mappedBy="finalSeminar")
@OneToMany(mappedBy = "finalSeminar")
private List<FinalSeminarOpposition> oppositions = new ArrayList<FinalSeminarOpposition>();
/*
* Cascading delete, set document to nul will delete the filedescription
* but not the actual file. Use FinarSeminarUploadController.deleteSeminarReport
* Cascading delete, set document to nul will delete the filedescription but
* not the actual file. Use FinarSeminarUploadController.deleteSeminarReport
* to delete the document
*/
@OneToOne(optional = true, orphanRemoval = true, cascade = CascadeType.ALL)
private FileDescription document;
private Date documentUploadDate;
private String turnitinId;
@Basic(optional=false)
@Basic(optional = false)
private boolean checkedForPlagirism = false;
@ManyToOne(optional = true)
private User documentUploader;
@Basic(optional = false)
@Enumerated(EnumType.STRING)
private FinalSeminarLanguages presentationLanguage = FinalSeminarLanguages.ENGLISH;
@Basic(optional = false)
@Enumerated(EnumType.STRING)
private FinalSeminarLanguages reportLanguage = FinalSeminarLanguages.ENGLISH;
/*
* Make sure that the uploader and uload date will be reset when document is null
* Make sure that the uploader and uload date will be reset when document is
* null
*/
@PreUpdate
public void checkReport(){
if(document == null){
public void checkReport() {
if (document == null) {
setDocumentUploader(null);
setDocumentUploadDate(null);
}
@ -105,13 +108,11 @@ public class FinalSeminar extends DomainObject{
public Project getProject() {
return project;
}
public void setProject(Project project) {
this.project = project;
}
public Date getEndDate() {
return endDate;
}
@ -123,19 +124,19 @@ public class FinalSeminar extends DomainObject{
public Date getStartDate() {
return startDate;
}
public void setStartDate(Date date) {
this.startDate = date;
}
public String getRoom() {
return room;
}
public void setRoom(String room) {
this.room = room;
}
public void setActiveParticipations(List<FinalSeminarActiveParticipation> activeParticipations) {
this.activeParticipations = activeParticipations;
}
@ -155,23 +156,23 @@ public class FinalSeminar extends DomainObject{
public void setDocument(FileDescription document) {
this.document = document;
}
public FileDescription getDocument() {
return document;
}
public void setDocumentUploadDate(Date documentUploadDate) {
this.documentUploadDate = documentUploadDate;
}
public Date getDocumentUploadDate() {
return documentUploadDate;
}
public void setDocumentUploader(User documentUploader) {
this.documentUploader = documentUploader;
}
public User getDocumentUploader() {
return documentUploader;
}
@ -211,11 +212,23 @@ public class FinalSeminar extends DomainObject{
}
/**
* @param checkedForPlagirism the checkedForPlagirism to set
* @param checkedForPlagirism
* the checkedForPlagirism to set
*/
public void setCheckedForPlagirism(boolean checkedForPlagirism) {
this.checkedForPlagirism = checkedForPlagirism;
}
/*
* (non-Javadoc)
*
* @see
* se.su.dsv.scipro.data.dataobjects.interfaces.Commentable#getCommentKey()
*/
@Override
final public String getCommentKey() {
return FinalSeminar.class.getCanonicalName().toString();
}
}

@ -1,109 +0,0 @@
/**
*
*/
package se.su.dsv.scipro.data.dataobjects;
import java.util.List;
import javax.persistence.Cacheable;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.Lob;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.MappedSuperclass;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
/**
* @author Johan Aschan - aschan@dsv.su.se
*
*/
@MappedSuperclass
public abstract class Message extends DomainObject implements Comparable<Message> {
@Id
@GeneratedValue(strategy = GenerationType.TABLE)
private Long id;
@Lob
private String message;
@ManyToOne(optional=false)
private User fromUser;
public Long getId() {
return id;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public User getFromUser() {
return fromUser;
}
public void setFromUser(User fromUser) {
this.fromUser = fromUser;
}
@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;
Message other = (Message) obj;
if (id == null) {
if (other.id != null)
return false;
} else if (!id.equals(other.id))
return false;
return true;
}
@Override
public int compareTo(Message o) {
if( this == o )
return 0;
if(this.getDateCreated() != null && o.getDateCreated() != null){
//Reversed from what you might expect, because normally we want to display newest comment first in listviews
return o.getDateCreated().compareTo(this.getDateCreated());
}
if(this.getId() != null && o.getId() != null)
return this.getId().compareTo(o.getId());
if(this.message != null && o.message != null)
return message.compareTo(o.message);
//By now we have to conclude the two objects are basically two objects full of nulls
return 0;
}
}

@ -5,13 +5,20 @@ package se.su.dsv.scipro.data.dataobjects;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
import javax.persistence.Basic;
import javax.persistence.Cacheable;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.PrePersist;
import javax.persistence.PreUpdate;
import javax.persistence.Table;
import org.hibernate.annotations.Cache;
@ -19,6 +26,8 @@ import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.Sort;
import org.hibernate.annotations.SortType;
import se.su.dsv.scipro.data.dataobjects.interfaces.Commentable;
/**
* @author Johan Aschan - aschan@dsv.su.se
*
@ -28,15 +37,52 @@ import org.hibernate.annotations.SortType;
@Table(name="message_board")
@Cacheable(true)
@Cache(usage= CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class MessageBoard extends Board {
public class MessageBoard extends DomainObject{
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue
private Long id;
@Override
public Long getId() {
// TODO Auto-generated method stub
return id;
}
@Basic(optional=false)
public String title;
@Basic(optional=false)
@Column(length=255)
private String commentableKey;
@Basic(optional=false)
private Long commentableId;
public MessageBoard() { }
public MessageBoard(Commentable commentable){
this.setCommentableKey(commentable.getCommentKey());
this.setCommentableId(commentable.getId());
}
@PreUpdate
@PrePersist
public void validate(){
if(getCommentableKey().length() > 255)
throw new IllegalArgumentException("CommentThread-commentableKey may not be longer than 255 characters");
}
@Sort(type=SortType.NATURAL)
@OneToMany(mappedBy="messageBoard", orphanRemoval=true, cascade=CascadeType.ALL, targetEntity=BoardMessage.class)
private SortedSet<BoardMessage> boardMessageSet = new TreeSet<BoardMessage>();
@OneToMany
private Set<User> readByUser = new TreeSet<User>();
public List<BoardMessage> getBoardMessageList() {
return new ArrayList<BoardMessage>(boardMessageSet);
}
@ -49,5 +95,60 @@ public class MessageBoard extends Board {
public void setBoardMessageSet( SortedSet<BoardMessage> boardMessageList) {
this.boardMessageSet = boardMessageList;
}
/**
* @return the commentableKey
*/
public String getCommentableKey() {
return commentableKey;
}
/**
* @param commentableKey the commentableKey to set
*/
public void setCommentableKey(String commentableKey) {
this.commentableKey = commentableKey;
}
/**
* @return the commentableId
*/
public Long getCommentableId() {
return commentableId;
}
/**
* @param commentableId the commentableId to set
*/
public void setCommentableId(Long commentableId) {
this.commentableId = commentableId;
}
/**
* @return the title
*/
public String getTitle() {
return title;
}
/**
* @param title the title to set
*/
public void setTitle(String title) {
this.title = title;
}
/* (non-Javadoc)
* @see se.su.dsv.scipro.data.dataobjects.DomainObject#getId()
*/
/**
* @return the readByUser
*/
public Set<User> getReadByUser() {
return readByUser;
}
/**
* @param readByUser the readByUser to set
*/
public void setReadByUser(Set<User> readByUser) {
this.readByUser = readByUser;
}
}

@ -29,7 +29,9 @@ import org.hibernate.annotations.CacheConcurrencyStrategy;
@Cache(usage= CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class PrivateMessage extends LazyDeletableDomainObject{
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue
private Long id;

@ -73,12 +73,7 @@ public class Project extends DomainObject implements Comparable<Project>, Iconiz
@Enumerated(EnumType.STRING)
private StateOfMind stateOfMind = StateOfMind.NEUTRAL;
@OneToOne(mappedBy="project")
private MessageBoard messageBoard;
@OneToOne(mappedBy="project")
private SupervisorMessageBoard supervisorMessageBoard;
@ManyToOne(optional=false)
private ProjectClass projectClass;
@ -173,10 +168,6 @@ public class Project extends DomainObject implements Comparable<Project>, Iconiz
return title;
}
public MessageBoard getMessageBoard() {
return messageBoard;
}
/**
* @param projectClass the projectClass to set
*/
@ -192,9 +183,6 @@ public class Project extends DomainObject implements Comparable<Project>, Iconiz
this.stateOfMind = stateOfMind;
}
public SupervisorMessageBoard getSupervisorMessageBoard() {
return supervisorMessageBoard;
}
/**
* @return the projectClass

@ -1,51 +0,0 @@
/**
*
*/
package se.su.dsv.scipro.data.dataobjects;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.Cacheable;
import javax.persistence.Entity;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
/**
* @author Johan Aschan - aschan@dsv.su.se
*
*/
@Entity
@Table(name="supervisor_board_message")
@Cacheable(true)
@Cache(usage= CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class SupervisorBoardMessage extends Message{
@ManyToOne(optional=false)
private SupervisorMessageBoard supervisorMessageBoard;
@OneToMany
private List<SupervisorBoardMessage> replyMessageList = new ArrayList<SupervisorBoardMessage>();
public SupervisorMessageBoard getSupervisorMessageBoard() {
return supervisorMessageBoard;
}
public void setSupervisorMessageBoard(
SupervisorMessageBoard supervisorMessageBoard) {
this.supervisorMessageBoard = supervisorMessageBoard;
}
public List<SupervisorBoardMessage> getReplyMessageList() {
return replyMessageList;
}
public void setReplyMessageList(List<SupervisorBoardMessage> replyMessageList) {
this.replyMessageList = replyMessageList;
}
}

@ -1,42 +0,0 @@
/**
*
*/
package se.su.dsv.scipro.data.dataobjects;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.Cacheable;
import javax.persistence.Entity;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
/**
* @author Johan Aschan - aschan@dsv.su.se
*
*/
@Entity
@Table(name = "supervisor_message_board")
@Cacheable(true)
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class SupervisorMessageBoard extends Board {
@OneToMany
private List<SupervisorBoardMessage> supervisorBoardMessageList = new ArrayList<SupervisorBoardMessage>(1);
public List<SupervisorBoardMessage> getSupervisorBoardMessageList() {
return supervisorBoardMessageList;
}
public void setSupervisorBoardMessageList(
List<SupervisorBoardMessage> supervisorBoardMessageList) {
this.supervisorBoardMessageList = supervisorBoardMessageList;
}
}