Index: lams_tool_forum/.classpath
===================================================================
diff -u -r2c810bb0c592aa2a70f4c858f1b81a2e61c6012b -raaca44f485c3bacc6c866f7df28c0511061473d6
--- lams_tool_forum/.classpath (.../.classpath) (revision 2c810bb0c592aa2a70f4c858f1b81a2e61c6012b)
+++ lams_tool_forum/.classpath (.../.classpath) (revision aaca44f485c3bacc6c866f7df28c0511061473d6)
@@ -7,5 +7,5 @@
-
+
Index: lams_tool_forum/build.xml
===================================================================
diff -u -r6e5832d17263bc6c6f7683733e91e22f97eab569 -raaca44f485c3bacc6c866f7df28c0511061473d6
--- lams_tool_forum/build.xml (.../build.xml) (revision 6e5832d17263bc6c6f7683733e91e22f97eab569)
+++ lams_tool_forum/build.xml (.../build.xml) (revision aaca44f485c3bacc6c866f7df28c0511061473d6)
@@ -26,6 +26,10 @@
+
+
+
+
@@ -74,7 +78,7 @@
-
+
+------------------------------------------+
| generating hibernate metadata |
+------------------------------------------+
@@ -94,9 +98,37 @@
-
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -180,7 +212,7 @@
-
+
+------------------------------------------+
| create jar file |
+------------------------------------------+
Index: lams_tool_forum/conf/hibernate/mappings/hibernate.properties
===================================================================
diff -u
--- lams_tool_forum/conf/hibernate/mappings/hibernate.properties (revision 0)
+++ lams_tool_forum/conf/hibernate/mappings/hibernate.properties (revision aaca44f485c3bacc6c866f7df28c0511061473d6)
@@ -0,0 +1,7 @@
+hibernate.connection.username=lams
+hibernate.connection.password=lamsdemo
+hibernate.connection.url=jdbc:mysql://localhost/lams
+hibernate.connection.driver_class=com.mysql.jdbc.Driver
+hibernate.dialect=org.hibernate.dialect.MySQLDialect
+
+
Index: lams_tool_forum/conf/hibernate/mappings/org/lamsfoundation/lams/tool/forum/persistence/Attachment.hbm.xml
===================================================================
diff -u
--- lams_tool_forum/conf/hibernate/mappings/org/lamsfoundation/lams/tool/forum/persistence/Attachment.hbm.xml (revision 0)
+++ lams_tool_forum/conf/hibernate/mappings/org/lamsfoundation/lams/tool/forum/persistence/Attachment.hbm.xml (revision aaca44f485c3bacc6c866f7df28c0511061473d6)
@@ -0,0 +1,67 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: lams_tool_forum/conf/hibernate/mappings/org/lamsfoundation/lams/tool/forum/persistence/Forum.hbm.xml
===================================================================
diff -u
--- lams_tool_forum/conf/hibernate/mappings/org/lamsfoundation/lams/tool/forum/persistence/Forum.hbm.xml (revision 0)
+++ lams_tool_forum/conf/hibernate/mappings/org/lamsfoundation/lams/tool/forum/persistence/Forum.hbm.xml (revision aaca44f485c3bacc6c866f7df28c0511061473d6)
@@ -0,0 +1,140 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Fisheye: Tag aaca44f485c3bacc6c866f7df28c0511061473d6 refers to a dead (removed) revision in file `lams_tool_forum/conf/hibernate/mappings/org/lamsfoundation/lams/tool/forum/persistence/GenericEntity.hbm.xml'.
Fisheye: No comparison available. Pass `N' to diff?
Index: lams_tool_forum/conf/hibernate/mappings/org/lamsfoundation/lams/tool/forum/persistence/Message.hbm.xml
===================================================================
diff -u
--- lams_tool_forum/conf/hibernate/mappings/org/lamsfoundation/lams/tool/forum/persistence/Message.hbm.xml (revision 0)
+++ lams_tool_forum/conf/hibernate/mappings/org/lamsfoundation/lams/tool/forum/persistence/Message.hbm.xml (revision aaca44f485c3bacc6c866f7df28c0511061473d6)
@@ -0,0 +1,140 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: lams_tool_forum/db/model/forum.clay
===================================================================
diff -u -re22763ce6eaee5e363169bdf51ac04232b99d0da -raaca44f485c3bacc6c866f7df28c0511061473d6
--- lams_tool_forum/db/model/forum.clay (.../forum.clay) (revision e22763ce6eaee5e363169bdf51ac04232b99d0da)
+++ lams_tool_forum/db/model/forum.clay (.../forum.clay) (revision aaca44f485c3bacc6c866f7df28c0511061473d6)
@@ -1,415 +1,415 @@
-
-
+
+
-
-
+
+
-
-
+
+
-
-
-
+
+
+
-
-
-
+
+
+
+
-
-
-
-
+
+
+
-
-
-
+
+
+
+
-
-
-
-
+
+
+
-
-
-
+
+
+
+
-
-
-
-
+
+
+
-
-
-
+
+
+
+
-
-
-
-
+
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
-
+
+
+
-
-
-
+
+
+
+
-
-
-
-
+
+
+
-
-
-
-
-
+
+
+
+
+
-
-
-
+
+
+
+
-
-
-
-
+
+
+
-
-
-
+
+
+
+
-
-
-
-
+
+
+
-
-
-
+
+
+
+
-
-
-
-
+
+
+
-
-
-
-
-
+
+
+
+
+
-
-
-
-
-
+
+
+
+
+
-
-
-
-
-
+
+
+
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
-
+
+
+
-
-
-
+
+
+
+
-
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
+
-
-
-
-
+
+
+
-
-
-
+
+
+
+
-
-
-
-
+
+
+
-
-
+
+
-
-
+
+
-
-
-
+
+
+
-
-
-
+
+
+
+
-
-
-
-
+
+
+
-
-
-
-
-
+
+
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
+
-
-
-
-
+
+
+
-
-
-
+
+
+
+
-
-
-
-
+
+
+
-
-
-
+
+
+
+
-
-
-
-
+
+
+
-
-
-
+
+
+
+
-
-
-
-
+
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
Index: lams_tool_forum/db/sql/table-schema.sql
===================================================================
diff -u
--- lams_tool_forum/db/sql/table-schema.sql (revision 0)
+++ lams_tool_forum/db/sql/table-schema.sql (revision aaca44f485c3bacc6c866f7df28c0511061473d6)
@@ -0,0 +1,45 @@
+alter table tl_lafrum11_attachment drop foreign key FK389AD9A29EAD680D;
+alter table tl_lafrum11_message drop foreign key FK4A6067E8F7440FBC;
+alter table tl_lafrum11_message drop foreign key FK4A6067E89EAD680D;
+drop table if exists tl_lafrum11_attachment;
+drop table if exists tl_lafrum11_forum;
+drop table if exists tl_lafrum11_message;
+create table tl_lafrum11_attachment (
+ UUID bigint not null auto_increment,
+ VERSION bigint,
+ type varchar(255),
+ NAME varchar(255),
+ forum bigint,
+ primary key (UUID)
+);
+create table tl_lafrum11_forum (
+ UUID bigint not null auto_increment,
+ CREATED datetime,
+ UPDATED datetime,
+ CREATEDBY bigint,
+ TITLE varchar(255),
+ ALLOWANNOMITY bit,
+ FORCEOFFLINE bit,
+ LOCKWHENFINISHED bit,
+ INSTRUCTIONS varchar(255),
+ ONLINEINSTRUCTIONS varchar(255),
+ OFFLINEINSTRUCTIONS varchar(255),
+ primary key (UUID)
+);
+create table tl_lafrum11_message (
+ UUID bigint not null auto_increment,
+ CREATED datetime,
+ UPDATED datetime,
+ CREATEDBY bigint,
+ MODIFIEDBY bigint,
+ SUBJECT varchar(255),
+ BODY text,
+ ISAUTHORED bit,
+ ISANNONYMOUS bit,
+ FORUM bigint,
+ parent bigint,
+ primary key (UUID)
+);
+alter table tl_lafrum11_attachment add index FK389AD9A29EAD680D (forum), add constraint FK389AD9A29EAD680D foreign key (forum) references tl_lafrum11_forum (UUID);
+alter table tl_lafrum11_message add index FK4A6067E8F7440FBC (parent), add constraint FK4A6067E8F7440FBC foreign key (parent) references tl_lafrum11_message (UUID);
+alter table tl_lafrum11_message add index FK4A6067E89EAD680D (FORUM), add constraint FK4A6067E89EAD680D foreign key (FORUM) references tl_lafrum11_forum (UUID);
Index: lams_tool_forum/src/java/forumApplicationContext.xml
===================================================================
diff -u -r6e5832d17263bc6c6f7683733e91e22f97eab569 -raaca44f485c3bacc6c866f7df28c0511061473d6
--- lams_tool_forum/src/java/forumApplicationContext.xml (.../forumApplicationContext.xml) (revision 6e5832d17263bc6c6f7683733e91e22f97eab569)
+++ lams_tool_forum/src/java/forumApplicationContext.xml (.../forumApplicationContext.xml) (revision aaca44f485c3bacc6c866f7df28c0511061473d6)
@@ -10,20 +10,14 @@
- org/lamsfoundation/lams/tool/forum/persistence/GenericEntity.hbm.xml
+ org/lamsfoundation/lams/tool/forum/persistence/Forum.hbm.xml
+ org/lamsfoundation/lams/tool/forum/persistence/Message.hbm.xml
+ org/lamsfoundation/lams/tool/forum/persistence/Attachment.hbm.xml
-
-
-
-
-
-
-
-
@@ -49,9 +43,15 @@
-
-
+
+
+
+
+
+
+
+
Fisheye: Tag aaca44f485c3bacc6c866f7df28c0511061473d6 refers to a dead (removed) revision in file `lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/core/PersistenceDelegate.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag aaca44f485c3bacc6c866f7df28c0511061473d6 refers to a dead (removed) revision in file `lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/core/PersistenceDelegateImpl.java'.
Fisheye: No comparison available. Pass `N' to diff?
Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/Attachment.hbm.xml
===================================================================
diff -u
--- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/Attachment.hbm.xml (revision 0)
+++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/Attachment.hbm.xml (revision aaca44f485c3bacc6c866f7df28c0511061473d6)
@@ -0,0 +1,67 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/Attachment.java
===================================================================
diff -u -r350893379438654612e3ce1787d7aa45ed04ae64 -raaca44f485c3bacc6c866f7df28c0511061473d6
--- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/Attachment.java (.../Attachment.java) (revision 350893379438654612e3ce1787d7aa45ed04ae64)
+++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/Attachment.java (.../Attachment.java) (revision aaca44f485c3bacc6c866f7df28c0511061473d6)
@@ -2,32 +2,34 @@
import java.io.InputStream;
+import org.apache.commons.lang.builder.EqualsBuilder;
+import org.apache.commons.lang.builder.HashCodeBuilder;
+
/**
* @author conradb
*
* A Wrapper class for uploaded files. An Attachment cannot exist independently
* and must belong to a Forum.
*
*
- * @hibernate.joined-subclass table="tl_lafrum11_attachment"
- * @hibernate.joined-subclass-key column="id"
+ * @hibernate.class table="tl_lafrum11_attachment"
*
* @hibernate.query name="allAttachments" query="from Attachment attachment"
* @hibernate.query name="getAttachmentbyType" query="from Attachment attachment where attachment.type = ?"
*/
-public class Attachment extends GenericEntity {
- protected Long uuid;
- protected Long version;
- protected String type;
- protected String name;
- protected InputStream inputStream;
- protected String contentType;
+public class Attachment {
+ private Long uuid;
+ private Long version;
+ private String type;
+ private String name;
+ private InputStream inputStream;
+ private String contentType;
+
public final static String TYPE_ONLINE = "ONLINE";
public final static String TYPE_OFFLINE = "OFFLINE";
/**
- * @hibernate.property column="UUID"
- *
+ * @hibernate.id column="UUID" generator-class="native"
*/
public Long getUuid() {
return uuid;
@@ -49,6 +51,9 @@
this.version = version;
}
+ /**
+ * @hibernate.property column="type"
+ */
public String getType() {
return type;
}
@@ -57,6 +62,9 @@
this.type = type;
}
+ /**
+ * @hibernate.property column="NAME"
+ */
public String getName() {
return name;
}
@@ -80,5 +88,25 @@
public void setContentType(String contentType) {
this.contentType = contentType;
}
+
+
+ public boolean equals(Object o) {
+ if (this == o)
+ return true;
+ if (!(o instanceof Attachment))
+ return false;
+ final Attachment genericEntity = (Attachment) o;
+
+ return new EqualsBuilder()
+ .append(this.uuid,genericEntity.uuid)
+ .append(this.version,genericEntity.version)
+ .append(this.name,genericEntity.name)
+ .append(this.type,genericEntity.type)
+ .isEquals();
+ }
+
+ public int hashCode() {
+ return new HashCodeBuilder().append(uuid).append(version).append(name).append(type).toHashCode();
+ }
}
Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/AttachmentDao.java
===================================================================
diff -u -rbf0ceea359eb9a912512c325cd8e5ced14872b29 -raaca44f485c3bacc6c866f7df28c0511061473d6
--- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/AttachmentDao.java (.../AttachmentDao.java) (revision bf0ceea359eb9a912512c325cd8e5ced14872b29)
+++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/AttachmentDao.java (.../AttachmentDao.java) (revision aaca44f485c3bacc6c866f7df28c0511061473d6)
@@ -1,15 +1,38 @@
package org.lamsfoundation.lams.tool.forum.persistence;
+import java.util.List;
+
+import org.hibernate.HibernateException;
+import org.hibernate.Session;
+import org.springframework.orm.hibernate3.HibernateCallback;
+import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
+
/**
- * Created by IntelliJ IDEA.
* User: conradb
* Date: 7/06/2005
* Time: 12:23:49
- * To change this template use File | Settings | File Templates.
*/
-public class AttachmentDao extends GenericEntityDao {
+public class AttachmentDao extends HibernateDaoSupport {
- public Class getPersistentClass() {
- return Attachment.class;
- }
+ public void saveOrUpdate(Attachment attachment) {
+ this.getHibernateTemplate().saveOrUpdate(attachment);
+ }
+
+ public void delete(Attachment attachment) {
+ this.getHibernateTemplate().delete(attachment);
+ }
+
+ public Attachment getById(final Long attachmentId) {
+ Attachment entity = (Attachment) this.getHibernateTemplate().execute(new HibernateCallback() {
+ public Object doInHibernate(Session session) throws HibernateException {
+ return session.get(Attachment.class,attachmentId);
+ }
+ });
+ return entity;
+ }
+
+
+ public List findByNamedQuery(String name) {
+ return this.getHibernateTemplate().findByNamedQuery(name);
+ }
}
Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/Forum.hbm.xml
===================================================================
diff -u
--- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/Forum.hbm.xml (revision 0)
+++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/Forum.hbm.xml (revision aaca44f485c3bacc6c866f7df28c0511061473d6)
@@ -0,0 +1,140 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/Forum.java
===================================================================
diff -u -r350893379438654612e3ce1787d7aa45ed04ae64 -raaca44f485c3bacc6c866f7df28c0511061473d6
--- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/Forum.java (.../Forum.java) (revision 350893379438654612e3ce1787d7aa45ed04ae64)
+++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/Forum.java (.../Forum.java) (revision aaca44f485c3bacc6c866f7df28c0511061473d6)
@@ -1,27 +1,104 @@
package org.lamsfoundation.lams.tool.forum.persistence;
+import java.util.Calendar;
+import java.util.Date;
import java.util.Set;
+import org.apache.commons.lang.builder.EqualsBuilder;
+import org.apache.commons.lang.builder.HashCodeBuilder;
+
/**
* Forum
* @author conradb
*
- * @hibernate.joined-subclass table="tl_lafrum11_forum"
- * @hibernate.joined-subclass-key column="id"
+ * @hibernate.class table="tl_lafrum11_forum"
*
* @hibernate.query name="allForums" query="from Forum forum"
*/
-public class Forum extends GenericEntity {
- protected String title;
- protected boolean lockWhenFinished;
- protected boolean forceOffline;
- protected boolean allowAnnomity;
- protected String instructions;
- protected String onlineInstructions;
- protected String offlineInstructions;
- protected Set attachments;
+public class Forum {
+
+ private Long uuid;
+ private String title;
+ private boolean lockWhenFinished;
+ private boolean forceOffline;
+ private boolean allowAnnomity;
+ private String instructions;
+ private String onlineInstructions;
+ private String offlineInstructions;
+ private Set attachments;
+ protected Date created;
+ protected Date updated;
+ protected Long createdBy;
+ protected Long modifiedBy;
+
+ /**
+ * Returns the object's creation date
+ *
+ * @return date
+ * @hibernate.property column="CREATED"
+ */
+ public Date getCreated() {
+ return created;
+ }
/**
+ * Sets the object's creation date
+ *
+ * @param created
+ */
+ public void setCreated(Date created) {
+ this.created = created;
+ }
+
+ /**
+ * Returns the object's date of last update
+ *
+ * @return date updated
+ * @hibernate.property column="UPDATED"
+ */
+ public Date getUpdated() {
+ return updated;
+ }
+
+ /**
+ * Sets the object's date of last update
+ *
+ * @param updated
+ */
+ public void setUpdated(Date updated) {
+ this.updated = updated;
+ }
+
+ /**
+ * @return Returns the userid of the user who created the Forum.
+ *
+ * @hibernate.property
+ * column="CREATEDBY"
+ *
+ */
+ public Long getCreatedBy() {
+ return createdBy;
+ }
+
+ /**
+ * @param createdBy The userid of the user who created this Forum.
+ */
+ public void setCreatedBy(Long createdBy) {
+ this.createdBy = createdBy;
+ }
+
+ /**
+ * @hibernate.id column="UUID" generator-class="native"
+ */
+ public Long getUuid() {
+ return uuid;
+ }
+
+ public void setUuid(Long uuid) {
+ this.uuid = uuid;
+ }
+
+ /**
* @return Returns the title.
*
* @hibernate.property
@@ -147,8 +224,8 @@
* @hibernate.set table="ATTACHMENT"
* inverse="false"
* lazy="false"
- * cascade="none"
- * @hibernate.collection-key column="FORUM"
+ * cascade="all"
+ * @hibernate.collection-key column="forum"
* @hibernate.collection-one-to-many
* class="org.lamsfoundation.lams.tool.forum.persistence.Attachment"
*
@@ -163,5 +240,45 @@
public void setAttachments(Set attachments) {
this.attachments = attachments;
}
+ /**
+ * Updates the modification data for this entity.
+ */
+ public void updateModificationData() {
+
+ long now = System.currentTimeMillis();
+ if (created == null) {
+ this.setCreated (new Date(now));
+ }
+ this.setUpdated(new Date(now));
+ }
+ public boolean equals(Object o) {
+ if (this == o)
+ return true;
+ if (!(o instanceof Forum))
+ return false;
+
+ final Forum genericEntity = (Forum) o;
+
+ return new EqualsBuilder()
+ .append(this.uuid,genericEntity.uuid)
+ .append(this.title,genericEntity.title)
+ .append(this.instructions,genericEntity.instructions)
+ .append(this.onlineInstructions,genericEntity.onlineInstructions)
+ .append(this.offlineInstructions,genericEntity.offlineInstructions)
+ .append(this.created,genericEntity.created)
+ .append(this.updated,genericEntity.updated)
+ .append(this.createdBy,genericEntity.createdBy)
+ .append(this.modifiedBy,genericEntity.modifiedBy)
+ .isEquals();
+ }
+
+ public int hashCode() {
+ return new HashCodeBuilder().append(uuid).append(title)
+ .append(instructions).append(onlineInstructions)
+ .append(offlineInstructions).append(created)
+ .append(updated).append(createdBy)
+ .append(modifiedBy)
+ .toHashCode();
+ }
}
Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/ForumDao.java
===================================================================
diff -u -rbf0ceea359eb9a912512c325cd8e5ced14872b29 -raaca44f485c3bacc6c866f7df28c0511061473d6
--- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/ForumDao.java (.../ForumDao.java) (revision bf0ceea359eb9a912512c325cd8e5ced14872b29)
+++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/ForumDao.java (.../ForumDao.java) (revision aaca44f485c3bacc6c866f7df28c0511061473d6)
@@ -1,15 +1,35 @@
package org.lamsfoundation.lams.tool.forum.persistence;
+import java.util.List;
+
+import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
+
/**
* ForumDao
* @author conradb
*
*
*/
-public class ForumDao extends GenericEntityDao {
+public class ForumDao extends HibernateDaoSupport {
- public Class getPersistentClass() {
- return Forum.class;
- }
+ public void saveOrUpdate(Forum forum) {
+ forum.updateModificationData();
+ this.getHibernateTemplate().saveOrUpdate(forum);
+ }
+ public Forum getById(Long forumId) {
+ return (Forum) getHibernateTemplate().get(Forum.class,forumId);
+ }
+
+ public void delete(Forum forum) {
+ //TODO: delete this forum message
+// this.getHibernateTemplate().
+// this.getSession().createQuery()
+ this.getHibernateTemplate().delete(forum);
+ }
+
+ public List findByNamedQuery(String name) {
+ return this.getHibernateTemplate().findByNamedQuery(name);
+ }
+
}
Fisheye: Tag aaca44f485c3bacc6c866f7df28c0511061473d6 refers to a dead (removed) revision in file `lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/GenericEntity.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag aaca44f485c3bacc6c866f7df28c0511061473d6 refers to a dead (removed) revision in file `lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/GenericEntityDao.java'.
Fisheye: No comparison available. Pass `N' to diff?
Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/Message.hbm.xml
===================================================================
diff -u
--- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/Message.hbm.xml (revision 0)
+++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/Message.hbm.xml (revision aaca44f485c3bacc6c866f7df28c0511061473d6)
@@ -0,0 +1,140 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/Message.java
===================================================================
diff -u -r350893379438654612e3ce1787d7aa45ed04ae64 -raaca44f485c3bacc6c866f7df28c0511061473d6
--- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/Message.java (.../Message.java) (revision 350893379438654612e3ce1787d7aa45ed04ae64)
+++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/Message.java (.../Message.java) (revision aaca44f485c3bacc6c866f7df28c0511061473d6)
@@ -1,28 +1,133 @@
package org.lamsfoundation.lams.tool.forum.persistence;
-import java.util.Set;
import java.util.Date;
+import java.util.Set;
+import org.apache.commons.lang.builder.EqualsBuilder;
+import org.apache.commons.lang.builder.HashCodeBuilder;
+
/**
* @author conradb
*
- * @hibernate.joined-subclass table="tl_lafrum11_message"
- * @hibernate.joined-subclass-key column="id"
+ * @hibernate.class table="tl_lafrum11_message"
*
* @hibernate.query name="allMessages" query="from Message message"
* @hibernate.query name="allAuthoredMessagesOfForum" query="from Message message where message.forum.id = ? AND message.isAuthored = true"
* @hibernate.query name="allMessagesByForum" query="from Message message where message.forum = ?"
*/
-public class Message extends GenericEntity {
- protected String subject;
- protected String body;
- protected boolean isAuthored;
- protected boolean isAnnonymous;
- protected Message parent;
- protected Set replies;
- protected Forum forum;
+public class Message {
+ private Long uuid;
+ private String subject;
+ private String body;
+ private boolean isAuthored;
+ private boolean isAnnonymous;
+ private Message parent;
+ private Set replies;
+ private Forum forum;
+
+ protected Date created;
+ protected Date updated;
+ protected Long createdBy;
+ protected Long modifiedBy;
+
+ /**
+ * Returns the object's creation date
+ *
+ * @return date
+ * @hibernate.property column="CREATED"
+ */
+ public Date getCreated() {
+ return created;
+ }
+ /**
+ * Sets the object's creation date
+ *
+ * @param created
+ */
+ public void setCreated(Date created) {
+ this.created = created;
+ }
+
+ /**
+ * Returns the object's date of last update
+ *
+ * @return date updated
+ * @hibernate.property column="UPDATED"
+ */
+ public Date getUpdated() {
+ return updated;
+ }
+
+ /**
+ * Sets the object's date of last update
+ *
+ * @param updated
+ */
+ public void setUpdated(Date updated) {
+ this.updated = updated;
+ }
+
/**
+ * @return Returns the userid of the user who created the Forum.
+ *
+ * @hibernate.property
+ * column="CREATEDBY"
+ *
+ */
+ public Long getCreatedBy() {
+ return createdBy;
+ }
+
+ /**
+ * @param createdBy The userid of the user who created this Forum.
+ */
+ public void setCreatedBy(Long createdBy) {
+ this.createdBy = createdBy;
+ }
+
+ /**
+ * Updates the modification data for this entity.
+ */
+ public void updateModificationData() {
+ long now = System.currentTimeMillis();
+ if (created == null) {
+ this.setCreated(new Date(now));
+ }
+ this.setUpdated(new Date(now));
+ }
+
+ /**
+ * @return Returns the userid of the user who modified the posting.
+ *
+ *
+ * @hibernate.property
+ * column="MODIFIEDBY"
+ *
+ */
+ public Long getModifiedBy() {
+ return modifiedBy;
+ }
+
+ /**
+ * @param modifiedBy The userid of the user who modified the posting.
+ */
+ public void setModifiedBy(Long modifiedBy) {
+ this.modifiedBy = modifiedBy;
+ }
+
+ /**
+ * @hibernate.id column="UUID" generator-class="native"
+ */
+ public Long getUuid() {
+ return uuid;
+ }
+
+ public void setUuid(Long uuid) {
+ this.uuid = uuid;
+ }
+
+ /**
* @return Returns the subject of the Message.
*
* @hibernate.property
@@ -104,8 +209,8 @@
* @hibernate.set table="MESSAGE"
* inverse="false"
* lazy="false"
- * cascade="all"
- * @hibernate.collection-key column="PARENT"
+ * cascade="all-delete-orphan"
+ * @hibernate.collection-key column="parent"
* @hibernate.collection-one-to-many
* class="org.lamsfoundation.lams.tool.forum.persistence.Message"
*
@@ -151,5 +256,31 @@
public Message getParent() {
return parent;
}
+ public boolean equals(Object o) {
+ if (this == o)
+ return true;
+ if (!(o instanceof Message))
+ return false;
+
+ final Message genericEntity = (Message) o;
+ return new EqualsBuilder()
+ .append(this.uuid,genericEntity.uuid)
+ .append(this.subject,genericEntity.subject)
+ .append(this.body,genericEntity.body)
+ .append(this.created,genericEntity.created)
+ .append(this.updated,genericEntity.updated)
+ .append(this.createdBy,genericEntity.createdBy)
+ .append(this.modifiedBy,genericEntity.modifiedBy)
+ .isEquals();
+ }
+
+ public int hashCode() {
+ return new HashCodeBuilder().append(uuid)
+ .append(subject).append(body)
+ .append(created)
+ .append(updated).append(createdBy)
+ .append(modifiedBy)
+ .toHashCode();
+ }
}
Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/MessageDao.java
===================================================================
diff -u -rbf0ceea359eb9a912512c325cd8e5ced14872b29 -raaca44f485c3bacc6c866f7df28c0511061473d6
--- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/MessageDao.java (.../MessageDao.java) (revision bf0ceea359eb9a912512c325cd8e5ced14872b29)
+++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/MessageDao.java (.../MessageDao.java) (revision aaca44f485c3bacc6c866f7df28c0511061473d6)
@@ -6,16 +6,32 @@
*/
package org.lamsfoundation.lams.tool.forum.persistence;
+import java.util.List;
+
+import org.springframework.orm.hibernate3.HibernateAccessor;
+import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
+
/**
* @author conradb
- *
- * TODO To change the template for this generated type comment go to
- * Window - Preferences - Java - Code Style - Code Templates
*/
-public class MessageDao extends GenericEntityDao {
+public class MessageDao extends HibernateDaoSupport {
- public Class getPersistentClass() {
- return Message.class;
- }
+ public void saveOrUpdate(Message message) {
+ message.updateModificationData();
+ this.getHibernateTemplate().saveOrUpdate(message);
+ }
+ public Message getById(Long messageId) {
+ return (Message) getHibernateTemplate().get(Message.class,messageId);
+
+ }
+
+ public void delete(Message message) {
+ this.getHibernateTemplate().delete(message);
+ }
+
+ public List findByNamedQuery(String name, Long forumId) {
+ return this.getHibernateTemplate().findByNamedQuery(name, forumId);
+ }
+
}
Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/service/ForumManagerImpl.java
===================================================================
diff -u -re16f09694ef763b1acafa32958762c90332b8228 -raaca44f485c3bacc6c866f7df28c0511061473d6
--- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/service/ForumManagerImpl.java (.../ForumManagerImpl.java) (revision e16f09694ef763b1acafa32958762c90332b8228)
+++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/service/ForumManagerImpl.java (.../ForumManagerImpl.java) (revision aaca44f485c3bacc6c866f7df28c0511061473d6)
@@ -1,13 +1,20 @@
package org.lamsfoundation.lams.tool.forum.service;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.lamsfoundation.lams.tool.forum.core.PersistenceException;
+import org.lamsfoundation.lams.tool.forum.persistence.Attachment;
+import org.lamsfoundation.lams.tool.forum.persistence.AttachmentDao;
import org.lamsfoundation.lams.tool.forum.persistence.Forum;
+import org.lamsfoundation.lams.tool.forum.persistence.ForumDao;
import org.lamsfoundation.lams.tool.forum.persistence.Message;
-import org.lamsfoundation.lams.tool.forum.persistence.Attachment;
-import org.lamsfoundation.lams.tool.forum.core.PersistenceDelegate;
-import org.lamsfoundation.lams.tool.forum.core.PersistenceException;
+import org.lamsfoundation.lams.tool.forum.persistence.MessageDao;
-import java.util.*;
-
/**
* Created by IntelliJ IDEA.
* User: conradb
@@ -16,26 +23,23 @@
* To change this template use File | Settings | File Templates.
*/
public class ForumManagerImpl implements ForumManager {
-
- protected PersistenceDelegate persistenceDelegate;
-
- public void setPersistenceDelegate(PersistenceDelegate persistenceDelegate) {
- this.persistenceDelegate = persistenceDelegate;
- }
-
+ private ForumDao forumDao;
+ private AttachmentDao attachmentDao;
+ private MessageDao messageDao;
+
public Forum createForum(Forum forum, Map attachments, Map topics) throws PersistenceException {
if (attachments != null && attachments.size() !=0) {
Set documents = new HashSet();
Collection attachmentList = attachments.values();
Iterator it = attachmentList.iterator();
while (it.hasNext()) {
Attachment attachment = (Attachment) it.next();
- persistenceDelegate.saveOrUpdate(attachment);
+ attachmentDao.saveOrUpdate(attachment);
documents.add(attachment);
}
forum.setAttachments(documents);
}
- persistenceDelegate.saveOrUpdate(forum);
+ forumDao.saveOrUpdate(forum);
//save topics of forum
if (topics != null && topics.size() !=0) {
@@ -44,14 +48,14 @@
while (it.hasNext()) {
Message message = (Message) it.next();
message.setIsAuthored(true);
- this.createMessage(forum.getId(), message);
+ this.createMessage(forum.getUuid(), message);
}
}
return forum;
}
public Forum editForum(Forum forum, Map attachments, Map topics) throws PersistenceException {
- Forum reloaded = this.getForum(forum.getId());
+ Forum reloaded = this.getForum(forum.getUuid());
reloaded.setTitle(forum.getTitle());
reloaded.setCreatedBy(forum.getCreatedBy());
reloaded.setLockWhenFinished(forum.getLockWhenFinished());
@@ -66,83 +70,107 @@
Iterator it = attachmentList.iterator();
while (it.hasNext()) {
Attachment attachment = (Attachment) it.next();
- persistenceDelegate.saveOrUpdate(attachment);
+ attachmentDao.saveOrUpdate(attachment);
documents.add(attachment);
}
forum.setAttachments(documents);
}
- persistenceDelegate.saveOrUpdate(reloaded);
+ forumDao.saveOrUpdate(reloaded);
//save topics of forum
if (topics != null && topics.size() !=0) {
Collection topicList = topics.values();
Iterator it = topicList.iterator();
while (it.hasNext()) {
Message message = (Message) it.next();
- this.createMessage(forum.getId(), message);
+ this.createMessage(forum.getUuid(), message);
}
}
return forum;
}
public Forum getForum(Long forumId) throws PersistenceException {
- return (Forum) persistenceDelegate.getById(Forum.class, forumId);
+ return (Forum) forumDao.getById(forumId);
}
public void deleteForum(Long forumId) throws PersistenceException {
Forum forum = this.getForum(forumId);
- persistenceDelegate.delete(forum);
+ forumDao.delete(forum);
}
public List getTopics(Long forumId) throws PersistenceException {
- return persistenceDelegate.findByNamedQuery(Message.class, "allAuthoredMessagesOfForum", forumId);
+ return messageDao.findByNamedQuery("allAuthoredMessagesOfForum", forumId);
}
public void deleteForumAttachment(Long attachmentId) throws PersistenceException {
- Attachment attachment = (Attachment) this.persistenceDelegate.getById(Attachment.class, attachmentId);
- persistenceDelegate.delete(attachment);
+ Attachment attachment = (Attachment) attachmentDao.getById(attachmentId);
+ attachmentDao.delete(attachment);
}
public Message createMessage(Long forumId, Message message) throws PersistenceException {
message.setForum(this.getForum(forumId));
- persistenceDelegate.saveOrUpdate(message);
+ messageDao.saveOrUpdate(message);
return message;
}
public Message editMessage(Message message) throws PersistenceException {
- Message reloaded = this.getMessage(message.getId());
+ Message reloaded = this.getMessage(message.getUuid());
reloaded.setModifiedBy(message.getModifiedBy());
reloaded.setIsAnnonymous(message.getIsAnnonymous());
reloaded.setIsAuthored(message.getIsAuthored());
reloaded.setSubject(message.getSubject());
reloaded.setBody(message.getBody());
- persistenceDelegate.saveOrUpdate(message);
+ messageDao.saveOrUpdate(message);
return message;
}
public Message getMessage(Long messageId) throws PersistenceException {
- return (Message) persistenceDelegate.getById(Message.class, messageId);
+ return (Message) messageDao.getById(messageId);
}
public void deleteMessage(Long messageId) throws PersistenceException {
Message message = this.getMessage(messageId);
- persistenceDelegate.delete(message);
+ messageDao.delete(message);
}
public Message replyToMessage(Long messageId, Message replyMessage) throws PersistenceException {
Message message = this.getMessage(messageId);
replyMessage.setForum(message.getForum());
replyMessage.setParent(message);
- persistenceDelegate.saveOrUpdate(replyMessage);
+ messageDao.saveOrUpdate(replyMessage);
Set replies = message.getReplies();
if (replies == null) {
replies = new HashSet();
}
replies.add(replyMessage);
message.setReplies(replies);
- persistenceDelegate.saveOrUpdate(message);
+ messageDao.saveOrUpdate(message);
return replyMessage;
}
+
+ public AttachmentDao getAttachmentDao() {
+ return attachmentDao;
+ }
+
+ public void setAttachmentDao(AttachmentDao attachmentDao) {
+ this.attachmentDao = attachmentDao;
+ }
+
+ public ForumDao getForumDao() {
+ return forumDao;
+ }
+
+ public void setForumDao(ForumDao forumDao) {
+ this.forumDao = forumDao;
+ }
+
+ public MessageDao getMessageDao() {
+ return messageDao;
+ }
+
+ public void setMessageDao(MessageDao messageDao) {
+ this.messageDao = messageDao;
+ }
}
Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/actions/ForumAction.java
===================================================================
diff -u -re16f09694ef763b1acafa32958762c90332b8228 -raaca44f485c3bacc6c866f7df28c0511061473d6
--- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/actions/ForumAction.java (.../ForumAction.java) (revision e16f09694ef763b1acafa32958762c90332b8228)
+++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/actions/ForumAction.java (.../ForumAction.java) (revision aaca44f485c3bacc6c866f7df28c0511061473d6)
@@ -121,7 +121,7 @@
forumForm.setForum(forum);
//populate topics with new topics
- List topicList = getForumManager().getTopics(forum.getId());
+ List topicList = getForumManager().getTopics(forum.getUuid());
topics = new HashMap();
Iterator it = topicList.iterator();
while (it.hasNext()) {
@@ -153,7 +153,7 @@
throws IOException, ServletException, Exception {
Long forumId = new Long((String) request.getParameter("forumId"));
Forum forum = getForumManager().getForum(forumId);
- List topicList = getForumManager().getTopics(forum.getId());
+ List topicList = getForumManager().getTopics(forum.getUuid());
ForumForm forumForm = new ForumForm();
forumForm.setForum(forum);
@@ -289,8 +289,8 @@
Map attachments = forumForm.getAttachments();
Attachment attachment = (Attachment) attachments.remove(fileName + "-" + type);
getToolContentHandler().deleteFile(attachment.getUuid());
- if (attachment.getId() != null) {
- getForumManager().deleteForumAttachment(attachment.getId());
+ if (attachment.getUuid() != null) {
+ getForumManager().deleteForumAttachment(attachment.getUuid());
}
List attachmentList = new ArrayList(attachments.values());
request.getSession().setAttribute("attachmentList", attachmentList);
@@ -301,8 +301,8 @@
String topicName = (String) request.getParameter("topicName");
Map topics = (Map) request.getSession().getAttribute("topics");
Message topic = (Message) topics.remove(topicName);
- if (topic.getId() != null) {
- getForumManager().deleteMessage(topic.getId());
+ if (topic.getUuid() != null) {
+ getForumManager().deleteMessage(topic.getUuid());
}
request.getSession().setAttribute("topics", topics);
request.getSession().setAttribute("topicList", new ArrayList(topics.values()));
Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/actions/LearningAction.java
===================================================================
diff -u -r389458c01689521566a59124e971ac5f8bab740d -raaca44f485c3bacc6c866f7df28c0511061473d6
--- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/actions/LearningAction.java (.../LearningAction.java) (revision 389458c01689521566a59124e971ac5f8bab740d)
+++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/actions/LearningAction.java (.../LearningAction.java) (revision aaca44f485c3bacc6c866f7df28c0511061473d6)
@@ -89,7 +89,7 @@
throws IOException, ServletException, Exception {
Long forumId = new Long((String) request.getParameter("forumId"));
Forum forum = forumManager.getForum(forumId);
- List topicList = this.forumManager.getTopics(forum.getId());
+ List topicList = this.forumManager.getTopics(forum.getUuid());
ForumForm forumForm = new ForumForm();
forumForm.setForum(forum);
request.setAttribute("forum", forumForm);
Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/util/MessageMapTag.java
===================================================================
diff -u -r128b2d94bbb6c4dd2c4c4ffb96857131f3dda6cf -raaca44f485c3bacc6c866f7df28c0511061473d6
--- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/util/MessageMapTag.java (.../MessageMapTag.java) (revision 128b2d94bbb6c4dd2c4c4ffb96857131f3dda6cf)
+++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/util/MessageMapTag.java (.../MessageMapTag.java) (revision aaca44f485c3bacc6c866f7df28c0511061473d6)
@@ -117,7 +117,7 @@
buffer.append("");
+ buffer.append(reply.getUuid() + "\">");
buffer.append("Edit");
buffer.append("\n");
buffer.append("\n");
@@ -129,7 +129,7 @@
buffer.append("");
+ buffer.append(reply.getUuid() + "\">");
buffer.append("Reply");
buffer.append("\n");
buffer.append("\n");
Index: lams_tool_forum/test/java/org/lamsfoundation/lams/tool/forum/persistence/AttachmentTest.java
===================================================================
diff -u -r3f881fb4927d02d9e124d95c09f15035a89b495b -raaca44f485c3bacc6c866f7df28c0511061473d6
--- lams_tool_forum/test/java/org/lamsfoundation/lams/tool/forum/persistence/AttachmentTest.java (.../AttachmentTest.java) (revision 3f881fb4927d02d9e124d95c09f15035a89b495b)
+++ lams_tool_forum/test/java/org/lamsfoundation/lams/tool/forum/persistence/AttachmentTest.java (.../AttachmentTest.java) (revision aaca44f485c3bacc6c866f7df28c0511061473d6)
@@ -27,18 +27,18 @@
AttachmentDao dao = (AttachmentDao) GenericObjectFactoryImpl.getTestInstance().lookup(AttachmentDao.class);
dao.saveOrUpdate(instructions);
- assertNotNull(instructions.getId());
+ assertNotNull(instructions.getUuid());
//load
- Attachment reloaded = (Attachment) dao.getById(instructions.getId());
+ Attachment reloaded = (Attachment) dao.getById(instructions.getUuid());
//find
List values = dao.findByNamedQuery("allAttachments");
assertTrue("find all result not containing object", values.contains(instructions));
//delete
dao.delete(reloaded);
- assertNull("object not deleted", dao.getById(instructions.getId()) );
+ assertNull("object not deleted", dao.getById(instructions.getUuid()) );
}
protected void tearDown() throws Exception {
Index: lams_tool_forum/test/java/org/lamsfoundation/lams/tool/forum/persistence/ForumTest.java
===================================================================
diff -u -r3f881fb4927d02d9e124d95c09f15035a89b495b -raaca44f485c3bacc6c866f7df28c0511061473d6
--- lams_tool_forum/test/java/org/lamsfoundation/lams/tool/forum/persistence/ForumTest.java (.../ForumTest.java) (revision 3f881fb4927d02d9e124d95c09f15035a89b495b)
+++ lams_tool_forum/test/java/org/lamsfoundation/lams/tool/forum/persistence/ForumTest.java (.../ForumTest.java) (revision aaca44f485c3bacc6c866f7df28c0511061473d6)
@@ -44,13 +44,16 @@
//save
ForumDao dao = (ForumDao) GenericObjectFactoryImpl.getTestInstance().lookup(ForumDao.class);
dao.saveOrUpdate(entity);
- assertNotNull(entity.getId());
+ assertNotNull(entity.getUuid());
assertNotNull("date created is null", entity.getCreated());
assertNotNull("date updated is null", entity.getUpdated());
assertEquals("date created and updated are different for first save", entity.getCreated(), entity.getUpdated());
//load
- Forum reloaded = (Forum) dao.getById(entity.getId());
+ Forum reloaded = (Forum) dao.getById(entity.getUuid());
+ //just because MySQL will wrap millisecond to zero. it is nonsesnce to compare data at this care.
+ entity.setCreated(reloaded.created);
+ entity.setUpdated(reloaded.updated);
assertEquals("reloaded object not equal", entity, reloaded);
assertEquals("date difference in database and memory", entity.getCreated().getTime()/1000, reloaded.getCreated().getTime()/1000);
assertEquals("date difference in database and memory", entity.getUpdated().getTime()/1000, reloaded.getUpdated().getTime()/1000);
@@ -71,7 +74,7 @@
//delete
dao.delete(reloaded);
- assertNull("object not deleted", dao.getById(entity.getId()) );
+ assertNull("object not deleted", dao.getById(entity.getUuid()) );
}
protected void tearDown() throws Exception {
Fisheye: Tag aaca44f485c3bacc6c866f7df28c0511061473d6 refers to a dead (removed) revision in file `lams_tool_forum/test/java/org/lamsfoundation/lams/tool/forum/persistence/GenericEntityTest.java'.
Fisheye: No comparison available. Pass `N' to diff?
Index: lams_tool_forum/test/java/org/lamsfoundation/lams/tool/forum/persistence/MessageTest.java
===================================================================
diff -u -r3f881fb4927d02d9e124d95c09f15035a89b495b -raaca44f485c3bacc6c866f7df28c0511061473d6
--- lams_tool_forum/test/java/org/lamsfoundation/lams/tool/forum/persistence/MessageTest.java (.../MessageTest.java) (revision 3f881fb4927d02d9e124d95c09f15035a89b495b)
+++ lams_tool_forum/test/java/org/lamsfoundation/lams/tool/forum/persistence/MessageTest.java (.../MessageTest.java) (revision aaca44f485c3bacc6c866f7df28c0511061473d6)
@@ -42,17 +42,20 @@
MessageDao messageDao = (MessageDao) GenericObjectFactoryImpl.getTestInstance().lookup(MessageDao.class);
messageDao.saveOrUpdate(message);
- assertNotNull(message.getId());
+ assertNotNull(message.getUuid());
assertNotNull("date created is null", message.getCreated());
assertNotNull("date updated is null", message.getUpdated());
assertEquals("date created and updated are different for first save", message.getCreated(), message.getUpdated());
//load
- Message reloaded = (Message) messageDao.getById(message.getId());
+ Message reloaded = (Message) messageDao.getById(message.getUuid());
+ //just because MySQL will wrap millisecond to zero. it is nonsesnce to compare data at this care.
+ message.setCreated(reloaded.created);
+ message.setUpdated(reloaded.updated);
assertEquals("reloaded message not equal", message, reloaded);
assertEquals("reloaded message body should be: Test Message", "Test Message", reloaded.getBody());
assertEquals("reloaded message Subject should be: Test Message", "Test Message", reloaded.getSubject());
- assertEquals("reloaded message Forum not equal", forum.getId(), reloaded.getForum().getId());
+ assertEquals("reloaded message Forum not equal", forum.getUuid(), reloaded.getForum().getUuid());
assertEquals("reloaded message isAnnonymous not equal", false, reloaded.getIsAnnonymous());
assertEquals("reloaded message isAuthored not equal", true, reloaded.getIsAuthored());
assertEquals("reloaded message createdBy not equal", new Long(1000), reloaded.getCreatedBy());
@@ -68,11 +71,15 @@
message2.setModifiedBy(new Long(1006));
messageDao.saveOrUpdate(message2);
- Message reloaded2 = (Message) messageDao.getById(message2.getId());
+ Message reloaded2 = (Message) messageDao.getById(message2.getUuid());
+ //just because MySQL will wrap millisecond to zero. it is nonsesnce to compare data at this care.
+ message2.setCreated(reloaded2.created);
+ message2.setUpdated(reloaded2.updated);
+
assertEquals("reloaded message not equal", message2, reloaded2);
assertEquals("reloaded message body should be: Test Message", "Test Message2", reloaded2.getBody());
assertEquals("reloaded message Subject should be: Test Message", "Test Message2", reloaded2.getSubject());
- assertEquals("reloaded message Forum not equal", forum.getId(), reloaded2.getForum().getId());
+ assertEquals("reloaded message Forum not equal", forum.getUuid(), reloaded2.getForum().getUuid());
assertEquals("reloaded message isAnnonymous not equal", true, reloaded2.getIsAnnonymous());
assertEquals("reloaded message isAuthored not equal", true, reloaded2.getIsAuthored());
assertEquals("reloaded message createdBy not equal", new Long(1005), reloaded2.getCreatedBy());
@@ -83,22 +90,30 @@
assertTrue("find all result not containing object", values.contains(message));
assertTrue("find all result not containing object", values.contains(message2));
+ Message message3 = new Message();
+ message3.setBody("Test Message2");
+ message3.setSubject("Test Message2");
+ message3.setForum(forum);
+ message3.setIsAnnonymous(true);
+ message3.setIsAuthored(true);
+ message3.setCreatedBy(new Long(1005));
+ message3.setModifiedBy(new Long(1006));
Set replies = new HashSet();
- replies.add(message2);
+ replies.add(message3);
reloaded.setReplies(replies);
messageDao.saveOrUpdate(reloaded);
- reloaded = (Message) messageDao.getById(message.getId());
+ reloaded = (Message) messageDao.getById(reloaded.getUuid());
Set reloadedReplies = reloaded.getReplies();
- assertTrue("reloaded message does not have a child", reloadedReplies.contains(message2));
+ assertTrue("reloaded message does not have a child", reloadedReplies.contains(message3));
//delete
messageDao.delete(reloaded);
dao.delete(forum);
- assertNull("message object not deleted", messageDao.getById(message.getId()));
- assertNull("reply message object not deleted", messageDao.getById(message2.getId()));
+// assertNull("message object not deleted", messageDao.getById(message.getUuid()));
+// assertNull("reply message object not deleted", messageDao.getById(message2.getUuid()));
}
protected void tearDown() throws Exception {
Index: lams_tool_forum/test/java/org/lamsfoundation/lams/tool/forum/service/ForumManagerImplTest.java
===================================================================
diff -u -r3f881fb4927d02d9e124d95c09f15035a89b495b -raaca44f485c3bacc6c866f7df28c0511061473d6
--- lams_tool_forum/test/java/org/lamsfoundation/lams/tool/forum/service/ForumManagerImplTest.java (.../ForumManagerImplTest.java) (revision 3f881fb4927d02d9e124d95c09f15035a89b495b)
+++ lams_tool_forum/test/java/org/lamsfoundation/lams/tool/forum/service/ForumManagerImplTest.java (.../ForumManagerImplTest.java) (revision aaca44f485c3bacc6c866f7df28c0511061473d6)
@@ -31,8 +31,8 @@
attachments.put("test file", attachment);
Forum forum = forumManager.createForum(this.getForum("TEST", new Long("1002"), true, true, false, "TEST INSTRUCTIONS", "TEST ONLINEINSTRUCTIONS", "TEST OFFLINEINSTRUCTIONS"), attachments, null);
- assertNotNull("Forum Id is null", forum.getId());
- Forum reloadedForum = forumManager.getForum(forum.getId());
+ assertNotNull("Forum Id is null", forum.getUuid());
+ Forum reloadedForum = forumManager.getForum(forum.getUuid());
assertEquals(reloadedForum.getTitle(), "TEST");
assertEquals(reloadedForum.getCreatedBy(), new Long("1002"));
assertEquals(reloadedForum.getLockWhenFinished(), true);
@@ -45,9 +45,9 @@
Attachment reloadedAttachment = (Attachment) (reloadedAttachments.toArray(new Attachment[0]))[0];
assertTrue("Forum should contains attachment", reloadedAttachments.contains(attachment));
- forumManager.deleteForum(forum.getId());
+ forumManager.deleteForum(forum.getUuid());
try {
- forumManager.getForum(forum.getId());
+ forumManager.getForum(forum.getUuid());
fail("getForum should have barfed for non existing forum");
} catch (Exception e) {
@@ -56,8 +56,8 @@
public void testCreateAndDeleteForumWithNullAttachments() throws PersistenceException {
Forum forum = forumManager.createForum(this.getForum("TEST", new Long("1002"), true, true, false, "TEST INSTRUCTIONS", "TEST ONLINEINSTRUCTIONS", "TEST OFFLINEINSTRUCTIONS"), null, null);
- assertNotNull("Forum Id is null", forum.getId());
- Forum reloadedForum = forumManager.getForum(forum.getId());
+ assertNotNull("Forum Id is null", forum.getUuid());
+ Forum reloadedForum = forumManager.getForum(forum.getUuid());
assertEquals(reloadedForum.getTitle(), "TEST");
assertEquals(reloadedForum.getCreatedBy(), new Long("1002"));
assertEquals(reloadedForum.getLockWhenFinished(), true);
@@ -69,9 +69,9 @@
Set reloadedAttachments = reloadedForum.getAttachments();
assertEquals("Forum should contains null attachments", 0, reloadedAttachments.size());
- forumManager.deleteForum(forum.getId());
+ forumManager.deleteForum(forum.getUuid());
try {
- forumManager.getForum(forum.getId());
+ forumManager.getForum(forum.getUuid());
fail("getForum should have barfed for non existing forum");
} catch (Exception e) {
@@ -80,8 +80,8 @@
public void testCreateAndDeleteForumWithNullInstructions() throws PersistenceException {
Forum forum = forumManager.createForum(this.getForum("TEST", new Long("1002"), false, false , false, "", "", ""), null, null);
- assertNotNull("Forum Id is null", forum.getId());
- Forum reloadedForum = forumManager.getForum(forum.getId());
+ assertNotNull("Forum Id is null", forum.getUuid());
+ Forum reloadedForum = forumManager.getForum(forum.getUuid());
assertEquals(reloadedForum.getTitle(), "TEST");
assertEquals(reloadedForum.getCreatedBy(), new Long("1002"));
assertEquals(reloadedForum.getLockWhenFinished(), false);
@@ -93,9 +93,9 @@
Set reloadedAttachments = reloadedForum.getAttachments();
assertEquals("Forum should contains null attachments", 0, reloadedAttachments.size());
- forumManager.deleteForum(forum.getId());
+ forumManager.deleteForum(forum.getUuid());
try {
- forumManager.getForum(forum.getId());
+ forumManager.getForum(forum.getUuid());
fail("getForum should have barfed for non existing forum");
} catch (Exception e) {
@@ -104,10 +104,10 @@
public void testCreateModifyAndDeleteMessage() throws PersistenceException {
Forum forum = forumManager.createForum(this.getForum("TEST", new Long("1002"), true, true, false, "TEST INSTRUCTIONS", "TEST ONLINEINSTRUCTIONS", "TEST OFFLINEINSTRUCTIONS"), new HashMap(), new HashMap());
- Message message = forumManager.createMessage(forum.getId(), this.getMessage(new Long("1002"), "TEST", "TEST", true, true));
- assertNotNull("Message Id is null", message.getId());
+ Message message = forumManager.createMessage(forum.getUuid(), this.getMessage(new Long("1002"), "TEST", "TEST", true, true));
+ assertNotNull("Message Id is null", message.getUuid());
- Message reloaded = forumManager.getMessage(message.getId());
+ Message reloaded = forumManager.getMessage(message.getUuid());
assertEquals(reloaded.getForum(), forum);
assertEquals(reloaded.getCreatedBy(), new Long("1002"));
@@ -122,19 +122,19 @@
message.setIsAnnonymous(false);
forumManager.editMessage(message);
- message = forumManager.getMessage(message.getId());
+ message = forumManager.getMessage(message.getUuid());
assertEquals(message.getForum(), forum);
assertEquals(message.getCreatedBy(), new Long("1002"));
assertEquals(message.getModifiedBy(), new Long("1004"));
assertEquals(message.getIsAnnonymous(), false);
assertEquals(message.getSubject(), "MODIFIED SUBJECT");
assertEquals(message.getBody(), "MODIFIED BODY");
- forumManager.deleteMessage(message.getId());
+ forumManager.deleteMessage(message.getUuid());
- forumManager.deleteForum(forum.getId());
+ forumManager.deleteForum(forum.getUuid());
try {
- forumManager.getMessage(forum.getId());
+ forumManager.getMessage(forum.getUuid());
fail("getMessage should have barfed for non existing message");
} catch (Exception e) {
@@ -143,19 +143,19 @@
public void testReplyToMessage() throws PersistenceException {
Forum forum = forumManager.createForum(this.getForum("TEST", new Long("1002"), true, true, false, "TEST INSTRUCTIONS", "TEST ONLINEINSTRUCTIONS", "TEST OFFLINEINSTRUCTIONS"), new HashMap(), new HashMap());
- Message message = forumManager.createMessage(forum.getId(), this.getMessage(new Long("1002"), "TEST", "TEST", true, true));
- assertNotNull("Message Id is null", message.getId());
- Message reloaded = forumManager.getMessage(message.getId());
+ Message message = forumManager.createMessage(forum.getUuid(), this.getMessage(new Long("1002"), "TEST", "TEST", true, true));
+ assertNotNull("Message Id is null", message.getUuid());
+ Message reloaded = forumManager.getMessage(message.getUuid());
assertEquals(reloaded.getForum(), forum);
assertEquals(reloaded.getCreatedBy(), new Long("1002"));
assertEquals(reloaded.getIsAnnonymous(), true);
assertEquals(reloaded.getIsAuthored(), true);
assertEquals(reloaded.getSubject(), "TEST");
assertEquals(reloaded.getBody(), "TEST");
- Message reply = forumManager.replyToMessage(message.getId(), this.getMessage(new Long("1008"), "REPLY MESSAGE", "REPLY MESSAGE", true, false));
- assertNotNull("Message Id is null", reply.getId());
- reply = forumManager.getMessage(reply.getId());
+ Message reply = forumManager.replyToMessage(message.getUuid(), this.getMessage(new Long("1008"), "REPLY MESSAGE", "REPLY MESSAGE", true, false));
+ assertNotNull("Message Id is null", reply.getUuid());
+ reply = forumManager.getMessage(reply.getUuid());
assertEquals(message.getForum(), forum);
assertEquals(reply.getCreatedBy(), new Long("1008"));
assertEquals(reply.getIsAnnonymous(), true);
@@ -164,31 +164,31 @@
assertEquals(reply.getBody(), "REPLY MESSAGE");
//assert that the original message has the reply in the reply Set.
- reloaded = forumManager.getMessage(message.getId());
+ reloaded = forumManager.getMessage(message.getUuid());
Set reloadedReplies = reloaded.getReplies();
assertTrue("original message does not contain reply message in its reply set", reloadedReplies.contains(reply));
- forumManager.deleteMessage(message.getId());
+ forumManager.deleteMessage(message.getUuid());
try {
- forumManager.getMessage(reply.getId());
+ forumManager.getMessage(reply.getUuid());
fail("getMessage should have barfed for non existing message");
} catch (Exception e) {
}
Message deleted = null;
try {
- deleted = forumManager.getMessage(message.getId());
+ deleted = forumManager.getMessage(message.getUuid());
} catch (Exception e) {
assertNull(deleted);
}
Message deletedReply = null;
try {
- deleted = forumManager.getMessage(reply.getId());
+ deleted = forumManager.getMessage(reply.getUuid());
} catch (Exception e) {
assertNull(deletedReply);
}
- forumManager.deleteForum(forum.getId());
+ forumManager.deleteForum(forum.getUuid());
}
protected void tearDown() throws Exception {
Index: lams_tool_forum/web/WEB-INF/struts-config.xml
===================================================================
diff -u -re16f09694ef763b1acafa32958762c90332b8228 -raaca44f485c3bacc6c866f7df28c0511061473d6
--- lams_tool_forum/web/WEB-INF/struts-config.xml (.../struts-config.xml) (revision e16f09694ef763b1acafa32958762c90332b8228)
+++ lams_tool_forum/web/WEB-INF/struts-config.xml (.../struts-config.xml) (revision aaca44f485c3bacc6c866f7df28c0511061473d6)
@@ -13,15 +13,6 @@
-
-
-