Index: lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/NoticeboardContent.java =================================================================== diff -u -rbe07c35c372d904a65581d98660e73f3b13b69db -rf76780e7823d8ac845669773cc86f5a30012159a --- lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/NoticeboardContent.java (.../NoticeboardContent.java) (revision be07c35c372d904a65581d98660e73f3b13b69db) +++ lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/NoticeboardContent.java (.../NoticeboardContent.java) (revision f76780e7823d8ac845669773cc86f5a30012159a) @@ -27,288 +27,243 @@ import java.io.Serializable; import java.util.Date; import java.util.HashSet; -import java.util.Iterator; import java.util.Set; import org.lamsfoundation.lams.contentrepository.ItemNotFoundException; -import org.lamsfoundation.lams.contentrepository.NodeKey; import org.lamsfoundation.lams.contentrepository.RepositoryCheckedException; -import org.lamsfoundation.lams.contentrepository.client.IToolContentHandler; - /** - *

Persistent noticeboard object/bean that defines the content for the noticeboard tool. - * Provides accessors and mutators to get/set noticeboard attributes

+ *

+ * Persistent noticeboard object/bean that defines the content for the noticeboard tool. Provides accessors and mutators + * to get/set noticeboard attributes + *

+ * * @hibernate.class table="tl_lanb11_content" * @author mtruong */ public class NoticeboardContent implements Serializable { - - /** identifier field */ + + /** identifier field */ private Long uid; - + /** non-nullable persistent field */ - private Long nbContentId; - - /** nullable persistent field */ - private String title; - - /** nullable persistent field */ - private String content; - - /** nullable persistent field */ - private boolean defineLater; + private Long nbContentId; - private Boolean reflectOnActivity; - - private String reflectInstructions; - - /** nullable persistent field */ - private boolean contentInUse; - - /** nullable persistent field */ - private Long creatorUserId; - - /** nullable persistent field */ - private Date dateCreated; - - /** nullable persistent field */ - private Date dateUpdated; - - /** persistent field */ - private Set nbSessions = new HashSet(); - - /** default constructor */ - public NoticeboardContent() - { - } - - /** full constructor */ - public NoticeboardContent(Long nbContentId, - String title, - String content, - boolean defineLater, - boolean reflectOnActivity, - String reflectInstructions, - boolean contentInUse, - Long creatorUserId, - Date dateCreated, - Date dateUpdated) - { - this.nbContentId = nbContentId; - this.title = title; - this.content = content; - this.defineLater = defineLater; - this.reflectOnActivity = reflectOnActivity; - this.reflectInstructions = reflectInstructions; - this.contentInUse = contentInUse; - this.creatorUserId = creatorUserId; - this.dateCreated = dateCreated; - this.dateUpdated = dateUpdated; - } - - /** - * Minimal Constructor used to initialise values for the NoticeboardContent object - * @return - */ - - public NoticeboardContent(Long nbContentId, - String title, - String content, - Date dateCreated) - { - this.nbContentId = nbContentId; - this.title = title; - this.content = content; - this.defineLater = false; - this.reflectOnActivity = false; - this.contentInUse = false; - this.creatorUserId = null; - this.dateCreated = dateCreated; - this.dateUpdated = null; - } - - - - /** - * @hibernate.property - * column="content" - * length="65535" - */ - - public String getContent() { - return content; - } + /** nullable persistent field */ + private String title; - public void setContent(String content) { - this.content = content; - } - - /** - * - * @hibernate.property - * column="creator_user_id" - * length="20" - */ - public Long getCreatorUserId() { - return creatorUserId; - } - - public void setCreatorUserId(Long creatorUserId) { - this.creatorUserId = creatorUserId; - } - - /** - * - * @hibernate.property - * column="date_created" - * length="19" + /** nullable persistent field */ + private String content; + + /** nullable persistent field */ + private boolean defineLater; + + private Boolean reflectOnActivity; + + private String reflectInstructions; + + /** nullable persistent field */ + private boolean contentInUse; + + /** nullable persistent field */ + private Long creatorUserId; + + /** nullable persistent field */ + private Date dateCreated; + + /** nullable persistent field */ + private Date dateUpdated; + + /** persistent field */ + private Set nbSessions = new HashSet(); + + /** default constructor */ + public NoticeboardContent() { + } + + /** full constructor */ + public NoticeboardContent(Long nbContentId, String title, String content, boolean defineLater, + boolean reflectOnActivity, String reflectInstructions, boolean contentInUse, Long creatorUserId, + Date dateCreated, Date dateUpdated) { + this.nbContentId = nbContentId; + this.title = title; + this.content = content; + this.defineLater = defineLater; + this.reflectOnActivity = reflectOnActivity; + this.reflectInstructions = reflectInstructions; + this.contentInUse = contentInUse; + this.creatorUserId = creatorUserId; + this.dateCreated = dateCreated; + this.dateUpdated = dateUpdated; + } + + /** + * Minimal Constructor used to initialise values for the NoticeboardContent object + * + * @return */ - public Date getDateCreated() { - return dateCreated; - } - - public void setDateCreated(Date dateCreated) { - this.dateCreated = dateCreated; - } - - /** - * - * @hibernate.property - * column="date_updated" - * length="19" + + public NoticeboardContent(Long nbContentId, String title, String content, Date dateCreated) { + this.nbContentId = nbContentId; + this.title = title; + this.content = content; + this.defineLater = false; + this.reflectOnActivity = false; + this.contentInUse = false; + this.creatorUserId = null; + this.dateCreated = dateCreated; + this.dateUpdated = null; + } + + /** + * @hibernate.property column="content" length="65535" */ - public Date getDateUpdated() { - return dateUpdated; - } - - public void setDateUpdated(Date dateUpdated) { - this.dateUpdated = dateUpdated; - } - - /** - * @hibernate.property - * column="define_later" - * length="1" + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + /** + * + * @hibernate.property column="creator_user_id" length="20" */ - public boolean isDefineLater() { - return defineLater; - } - - public void setDefineLater(boolean defineLater) { - this.defineLater = defineLater; - } - - /** - * @hibernate.property - * column="reflect_on_activity" - * length="1" + public Long getCreatorUserId() { + return creatorUserId; + } + + public void setCreatorUserId(Long creatorUserId) { + this.creatorUserId = creatorUserId; + } + + /** + * + * @hibernate.property column="date_created" length="19" */ - public boolean getReflectOnActivity() { - return reflectOnActivity; - } - - public void setReflectOnActivity(boolean reflectOnActivity) { - this.reflectOnActivity = reflectOnActivity; - } - - /** - * @hibernate.property - * column="reflect_instructions" - * length="65535" - */ - public String getReflectInstructions() { - return reflectInstructions; - } + public Date getDateCreated() { + return dateCreated; + } - public void setReflectInstructions(String reflectInstructions) { - this.reflectInstructions = reflectInstructions; - } - - /** - * @hibernate.property - * column="content_in_use" - * length="1" + public void setDateCreated(Date dateCreated) { + this.dateCreated = dateCreated; + } + + /** + * + * @hibernate.property column="date_updated" length="19" */ - + public Date getDateUpdated() { + return dateUpdated; + } + + public void setDateUpdated(Date dateUpdated) { + this.dateUpdated = dateUpdated; + } + + /** + * @hibernate.property column="define_later" length="1" + */ + public boolean isDefineLater() { + return defineLater; + } + + public void setDefineLater(boolean defineLater) { + this.defineLater = defineLater; + } + + /** + * @hibernate.property column="reflect_on_activity" length="1" + */ + public boolean getReflectOnActivity() { + return reflectOnActivity; + } + + public void setReflectOnActivity(boolean reflectOnActivity) { + this.reflectOnActivity = reflectOnActivity; + } + + /** + * @hibernate.property column="reflect_instructions" length="65535" + */ + public String getReflectInstructions() { + return reflectInstructions; + } + + public void setReflectInstructions(String reflectInstructions) { + this.reflectInstructions = reflectInstructions; + } + + /** + * @hibernate.property column="content_in_use" length="1" + */ + public boolean isContentInUse() { - return contentInUse; + return contentInUse; } + /** - * @param contentInUse The contentInUse to set. + * @param contentInUse + * The contentInUse to set. */ public void setContentInUse(boolean contentInUse) { - this.contentInUse = contentInUse; + this.contentInUse = contentInUse; } - - /** - * @hibernate.property - * column="nb_content_id" - * length="20" - * not-null="true" + + /** + * @hibernate.property column="nb_content_id" length="20" not-null="true" */ - - public Long getNbContentId() { - return nbContentId; - } - - public void setNbContentId(Long nbContentId) { - this.nbContentId = nbContentId; - } - /** - * @hibernate.set - * lazy="true" - * inverse="true" - * cascade="all-delete-orphan" - * @hibernate.collection-key - * column="nb_content_uid" - * @hibernate.collection-one-to-many - * class="org.lamsfoundation.lams.tool.noticeboard.NoticeboardSession" + + public Long getNbContentId() { + return nbContentId; + } + + public void setNbContentId(Long nbContentId) { + this.nbContentId = nbContentId; + } + + /** + * @hibernate.set lazy="true" inverse="true" cascade="all-delete-orphan" + * @hibernate.collection-key column="nb_content_uid" + * @hibernate.collection-one-to-many class="org.lamsfoundation.lams.tool.noticeboard.NoticeboardSession" */ - public Set getNbSessions() { - if (this.nbSessions == null) - { - setNbSessions(new HashSet()); - } - return nbSessions; + public Set getNbSessions() { + if (this.nbSessions == null) { + setNbSessions(new HashSet()); } - - public void setNbSessions(Set nbSessions) { - this.nbSessions = nbSessions; - } - - /** - * @hibernate.property - * column="title" - * length="65535" - */ - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - /** - * @hibernate.id - * generator-class="native" - * type="java.lang.Long" - * column="uid" - * unsaved-value="0" - */ + return nbSessions; + } + + public void setNbSessions(Set nbSessions) { + this.nbSessions = nbSessions; + } + + /** + * @hibernate.property column="title" length="65535" + */ + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + /** + * @hibernate.id generator-class="native" type="java.lang.Long" column="uid" unsaved-value="0" + */ public Long getUid() { - return uid; + return uid; } - + public void setUid(Long uid) { - this.uid = uid; + this.uid = uid; } - - /** - * Creates a new NoticeboardContent object from the supplied object. Assigns it the toContendId. + * Creates a new NoticeboardContent object from the supplied object. Assigns it the toContendId. * * @param nb * NoticeboardContent object containing the content to copy from @@ -321,8 +276,8 @@ public static NoticeboardContent newInstance(NoticeboardContent nb, Long toContentId) throws ItemNotFoundException, RepositoryCheckedException { NoticeboardContent newContent = new NoticeboardContent(toContentId, nb.getTitle(), nb.getContent(), - nb.isDefineLater(), nb.getReflectOnActivity(), nb.getReflectInstructions(), - nb.isContentInUse(), nb.getCreatorUserId(), nb.getDateCreated(), nb.getDateUpdated()); + nb.isDefineLater(), nb.getReflectOnActivity(), nb.getReflectInstructions(), nb.isContentInUse(), + nb.getCreatorUserId(), nb.getDateCreated(), nb.getDateUpdated()); return newContent; } Index: lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/NoticeboardSession.java =================================================================== diff -u -r08950e1090443c3423a3d1c587416a2fccd8bbdf -rf76780e7823d8ac845669773cc86f5a30012159a --- lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/NoticeboardSession.java (.../NoticeboardSession.java) (revision 08950e1090443c3423a3d1c587416a2fccd8bbdf) +++ lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/NoticeboardSession.java (.../NoticeboardSession.java) (revision f76780e7823d8ac845669773cc86f5a30012159a) @@ -24,248 +24,214 @@ /* $$Id$$ */ package org.lamsfoundation.lams.tool.noticeboard; -import org.lamsfoundation.lams.tool.noticeboard.NoticeboardContent; import java.io.Serializable; import java.util.Date; import java.util.HashSet; import java.util.Set; /** - *

The NoticeboardSession class represents a tool session for a noticeboard activity. - * Each tool session may represent a group of users, if grouping is used, or may - * represent one learner if there is no grouping for this particular activity. + *

+ * The NoticeboardSession class represents a tool session for a noticeboard activity. Each tool session may represent a + * group of users, if grouping is used, or may represent one learner if there is no grouping for this particular + * activity. *

*
- *

The session status has three possible status': - *

  • NOT_ATTEMPTED: which means that the tool session has been established, but no learners have reached this activity yet - *
  • INCOMPLETE: which means that a learner has reached this activity + *

    + * The session status has three possible status': + *

      + *
    • NOT_ATTEMPTED: which means that the tool session has been established, but no learners have reached this activity + * yet + *
    • INCOMPLETE: which means that a learner has reached this activity *
    • COMPLETED: The session status will never be set to complete as you don't know when this tool is going to end. - *

    + *
+ *

+ * * @author mtruong * @hibernate.class table="tl_lanb11_session" */ public class NoticeboardSession implements Serializable { - public final static String NOT_ATTEMPTED = "NOT_ATTEMPTED"; - + public final static String INCOMPLETE = "INCOMPLETE"; - + public static final String COMPLETED = "COMPLETED"; - - /** identifier field */ + + /** identifier field */ private Long uid; - - /** persistent field*/ - private Long nbSessionId; - - /** persistent field*/ - private String nbSessionName; - - /** nullable persistent field */ - private Date sessionStartDate; - - /** nullable persistent field */ - private Date sessionEndDate; - - /** nullable persistent field */ - private String sessionStatus; - - /** persistent field */ - private NoticeboardContent nbContent; - - /** persistent field */ - private Set nbUsers = new HashSet(); - - /** default constructor */ - public NoticeboardSession() - { - - } - - /** full constructor */ - public NoticeboardSession(Long nbSessionId, - String nbSessionName, - NoticeboardContent nbContent, - Date sessionStartDate, - Date sessionEndDate, - String sessionStatus) - { - this.nbSessionId = nbSessionId; - this.nbSessionName = nbSessionName; - //this.nbContentId = nbContentId; - this.nbContent = nbContent; - this.sessionStartDate = sessionStartDate; - this.sessionEndDate = sessionEndDate; - this.sessionStatus = sessionStatus; - } - - /** - * Constructor used when creating a new noticeboardSession given - * the noticeboardContent id - */ - - public NoticeboardSession(Long nbSessionId, - String nbSessionName, - NoticeboardContent nbContent, - Date sessionStartDate, - String sessionStatus) - { - this.nbSessionId = nbSessionId; - this.nbSessionName = nbSessionName; - this.nbContent = nbContent; - this.sessionStartDate = sessionStartDate; - this.sessionEndDate = null; - this.sessionStatus = sessionStatus; - } - - public NoticeboardSession(Long nbSessionId, - String nbSessionName, - NoticeboardContent nbContent) - { - this.nbSessionId = nbSessionId; - this.nbSessionName = nbSessionName; - this.nbContent = nbContent; - this.sessionStartDate = new Date(System.currentTimeMillis()); - this.sessionStatus = NoticeboardSession.INCOMPLETE; - } - - public NoticeboardSession(Long nbSessionId, String nbSessionName) - { - this.nbSessionId = nbSessionId; - this.nbSessionName = nbSessionName; - this.sessionStartDate = new Date(System.currentTimeMillis()); - this.sessionStatus = NoticeboardSession.INCOMPLETE; - } - - public NoticeboardSession(Long nbSessionId) - { - this.nbSessionId = nbSessionId; - this.sessionStartDate = new Date(System.currentTimeMillis()); - this.sessionStatus = NoticeboardSession.INCOMPLETE; - } - - /** - * @hibernate.many-to-one - * not-null="true" - * @hibernate.column name="nb_content_uid" - */ - public NoticeboardContent getNbContent() { - return nbContent; - } - - public void setNbContent(NoticeboardContent nbContent) { - this.nbContent = nbContent; - } - - /** - * @hibernate.property - * column="nb_session_id" - * length="20" - * not-null="true" - */ - public Long getNbSessionId() { - return nbSessionId; - } - - public void setNbSessionId(Long nbSessionId) { - this.nbSessionId = nbSessionId; - } - - /** - * @hibernate.property - * column="nb_session_name" - * length="255" - * not-null="true" - */ - public String getNbSessionName() { - return nbSessionName; - } - - public void setNbSessionName(String nbSessionName) { - this.nbSessionName = nbSessionName; - } - - /** - * @hibernate.property - * column="session_end_date" - * length="19" - */ - public Date getSessionEndDate() { - return sessionEndDate; - } - - public void setSessionEndDate(Date sessionEndDate) { - this.sessionEndDate = sessionEndDate; - } - - /** - * @hibernate.property - * column="session_start_date" - * length="19" - */ - public Date getSessionStartDate() { - return sessionStartDate; - } - - public void setSessionStartDate(Date sessionStartDate) { - this.sessionStartDate = sessionStartDate; - } - - /** - * @hibernate.property - * column="session_status" - * length="100" - */ - public String getSessionStatus() { - return sessionStatus; - } - - public void setSessionStatus(String sessionStatus) { - this.sessionStatus = sessionStatus; - } - - /** - * @hibernate.id - * generator-class="native" - * type="java.lang.Long" - * column="uid" - * unsaved-value="0" + + /** persistent field */ + private Long nbSessionId; + + /** persistent field */ + private String nbSessionName; + + /** nullable persistent field */ + private Date sessionStartDate; + + /** nullable persistent field */ + private Date sessionEndDate; + + /** nullable persistent field */ + private String sessionStatus; + + /** persistent field */ + private NoticeboardContent nbContent; + + /** persistent field */ + private Set nbUsers = new HashSet(); + + /** default constructor */ + public NoticeboardSession() { + + } + + /** full constructor */ + public NoticeboardSession(Long nbSessionId, String nbSessionName, NoticeboardContent nbContent, + Date sessionStartDate, Date sessionEndDate, String sessionStatus) { + this.nbSessionId = nbSessionId; + this.nbSessionName = nbSessionName; + // this.nbContentId = nbContentId; + this.nbContent = nbContent; + this.sessionStartDate = sessionStartDate; + this.sessionEndDate = sessionEndDate; + this.sessionStatus = sessionStatus; + } + + /** + * Constructor used when creating a new noticeboardSession given the noticeboardContent id */ + + public NoticeboardSession(Long nbSessionId, String nbSessionName, NoticeboardContent nbContent, + Date sessionStartDate, String sessionStatus) { + this.nbSessionId = nbSessionId; + this.nbSessionName = nbSessionName; + this.nbContent = nbContent; + this.sessionStartDate = sessionStartDate; + this.sessionEndDate = null; + this.sessionStatus = sessionStatus; + } + + public NoticeboardSession(Long nbSessionId, String nbSessionName, NoticeboardContent nbContent) { + this.nbSessionId = nbSessionId; + this.nbSessionName = nbSessionName; + this.nbContent = nbContent; + this.sessionStartDate = new Date(System.currentTimeMillis()); + this.sessionStatus = NoticeboardSession.INCOMPLETE; + } + + public NoticeboardSession(Long nbSessionId, String nbSessionName) { + this.nbSessionId = nbSessionId; + this.nbSessionName = nbSessionName; + this.sessionStartDate = new Date(System.currentTimeMillis()); + this.sessionStatus = NoticeboardSession.INCOMPLETE; + } + + public NoticeboardSession(Long nbSessionId) { + this.nbSessionId = nbSessionId; + this.sessionStartDate = new Date(System.currentTimeMillis()); + this.sessionStatus = NoticeboardSession.INCOMPLETE; + } + + /** + * @hibernate.many-to-one not-null="true" + * @hibernate.column name="nb_content_uid" + */ + public NoticeboardContent getNbContent() { + return nbContent; + } + + public void setNbContent(NoticeboardContent nbContent) { + this.nbContent = nbContent; + } + + /** + * @hibernate.property column="nb_session_id" length="20" not-null="true" + */ + public Long getNbSessionId() { + return nbSessionId; + } + + public void setNbSessionId(Long nbSessionId) { + this.nbSessionId = nbSessionId; + } + + /** + * @hibernate.property column="nb_session_name" length="255" not-null="true" + */ + public String getNbSessionName() { + return nbSessionName; + } + + public void setNbSessionName(String nbSessionName) { + this.nbSessionName = nbSessionName; + } + + /** + * @hibernate.property column="session_end_date" length="19" + */ + public Date getSessionEndDate() { + return sessionEndDate; + } + + public void setSessionEndDate(Date sessionEndDate) { + this.sessionEndDate = sessionEndDate; + } + + /** + * @hibernate.property column="session_start_date" length="19" + */ + public Date getSessionStartDate() { + return sessionStartDate; + } + + public void setSessionStartDate(Date sessionStartDate) { + this.sessionStartDate = sessionStartDate; + } + + /** + * @hibernate.property column="session_status" length="100" + */ + public String getSessionStatus() { + return sessionStatus; + } + + public void setSessionStatus(String sessionStatus) { + this.sessionStatus = sessionStatus; + } + + /** + * @hibernate.id generator-class="native" type="java.lang.Long" column="uid" unsaved-value="0" + */ public Long getUid() { - return uid; + return uid; } - + public void setUid(Long uid) { - this.uid = uid; + this.uid = uid; } - + /** - * @hibernate.set - * lazy="true" - * inverse="true" - * cascade="all-delete-orphan" - * - * @hibernate.collection-key - * column="nb_session_uid" - * @hibernate.collection-one-to-many - * class="org.lamsfoundation.lams.tool.noticeboard.NoticeboardUser" + * @hibernate.set lazy="true" inverse="true" cascade="all-delete-orphan" + * + * @hibernate.collection-key column="nb_session_uid" + * @hibernate.collection-one-to-many class="org.lamsfoundation.lams.tool.noticeboard.NoticeboardUser" */ - public Set getNbUsers() { - if (this.nbUsers == null) - { - setNbUsers(new HashSet()); - } - - return nbUsers; + public Set getNbUsers() { + if (this.nbUsers == null) { + setNbUsers(new HashSet()); + } + + return nbUsers; } + /** - * @param nbUsers The nbUsers to set. + * @param nbUsers + * The nbUsers to set. */ - public void setNbUsers(Set nbUsers) { - this.nbUsers = nbUsers; + public void setNbUsers(Set nbUsers) { + this.nbUsers = nbUsers; } - - + } Index: lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/dao/INoticeboardSessionDAO.java =================================================================== diff -u -r08950e1090443c3423a3d1c587416a2fccd8bbdf -rf76780e7823d8ac845669773cc86f5a30012159a --- lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/dao/INoticeboardSessionDAO.java (.../INoticeboardSessionDAO.java) (revision 08950e1090443c3423a3d1c587416a2fccd8bbdf) +++ lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/dao/INoticeboardSessionDAO.java (.../INoticeboardSessionDAO.java) (revision f76780e7823d8ac845669773cc86f5a30012159a) @@ -24,108 +24,101 @@ /* $$Id$$ */ package org.lamsfoundation.lams.tool.noticeboard.dao; -import java.util.List; - -import org.lamsfoundation.lams.tool.noticeboard.NoticeboardContent; import org.lamsfoundation.lams.tool.noticeboard.NoticeboardSession; import org.lamsfoundation.lams.tool.noticeboard.NoticeboardUser; - /** - *

Interface for the NoticeboardSession DAO, defines methods needed to access/modify - * noticeboard session

+ *

+ * Interface for the NoticeboardSession DAO, defines methods needed to access/modify noticeboard session + *

+ * * @author mtruong */ public interface INoticeboardSessionDAO { - - + /** - *

Return the persistent instance of a NoticeboardSession - * with the given tool session id nbSessionId, - * returns null if not found.

- * - * @param nbSessionId The tool session id - * @return the persistent instance of a NoticeboardSession or null if not found. - */ + *

+ * Return the persistent instance of a NoticeboardSession with the given tool session id nbSessionId, + * returns null if not found. + *

+ * + * @param nbSessionId + * The tool session id + * @return the persistent instance of a NoticeboardSession or null if not found. + */ public NoticeboardSession findNbSessionById(Long nbSessionId); - - + /** - *

Persist the given persistent instance of NoticeboardSession.

- * - * @param nbSession The instance of NoticeboardSession to persist. - */ + *

+ * Persist the given persistent instance of NoticeboardSession. + *

+ * + * @param nbSession + * The instance of NoticeboardSession to persist. + */ public void saveNbSession(NoticeboardSession nbSession); - + /** - *

Update the given persistent instance of NoticeboardSession.

+ *

+ * Update the given persistent instance of NoticeboardSession. + *

* - * @param nbContent The instance of NoticeboardSession to persist. + * @param nbContent + * The instance of NoticeboardSession to persist. */ public void updateNbSession(NoticeboardSession nbSession); - - + /** - *

Delete the given instance of NoticeboardSession

+ *

+ * Delete the given instance of NoticeboardSession + *

* - * @param nbSession The instance of NoticeboardSession to delete. + * @param nbSession + * The instance of NoticeboardSession to delete. */ public void removeNbSession(NoticeboardSession nbSession); - + /** - *

Delete the given instance of NoticeboardSession with the - * given tool session id nbSessionid + *

+ * Delete the given instance of NoticeboardSession with the given tool session id nbSessionid * - * @param nbSessionId The tool session Id. + * @param nbSessionId + * The tool session Id. */ public void removeNbSession(Long nbSessionId); - + /** - *

Returns the persistent instance of NoticeboardSession - * associated with the given noticeboard user, with user id userId, - * returns null if not found. + *

+ * Returns the persistent instance of NoticeboardSession associated with the given noticeboard user, with user id + * userId, returns null if not found. * - * @param userId The noticeboard user id + * @param userId + * The noticeboard user id * @return a persistent instance of NoticeboardSessions or null if not found. - */ - public NoticeboardSession getNbSessionByUser(Long userId); - + */ + public NoticeboardSession getNbSessionByUser(Long userId); + /** - *

Deletes all instances of NoticeboardUser that are associated - * with the given instance of NoticeboardSession

+ *

+ * Deletes all instances of NoticeboardUser that are associated with the given instance of NoticeboardSession + *

* - * @param nbSession The instance of NoticeboardSession in which corresponding instances of NoticeboardUser should be deleted. + * @param nbSession + * The instance of NoticeboardSession in which corresponding instances of NoticeboardUser should be + * deleted. */ - public void removeNbUsers(NoticeboardSession nbSession); + public void removeNbUsers(NoticeboardSession nbSession); /** - *

Creates and persists an instance of NoticeboardUser which is associated - * with the NoticeboardSession with tool session id nbSessionId

+ *

+ * Creates and persists an instance of NoticeboardUser which is associated with the NoticeboardSession with tool + * session id nbSessionId + *

* - * @param nbSessionId The tool session id - * @param user The instance of NoticeboardUser + * @param nbSessionId + * The tool session id + * @param user + * The instance of NoticeboardUser */ public void addNbUsers(Long nbSessionId, NoticeboardUser user); - - /** - * Returns a list of tool session ids which are associated with this - * instance of NoticeboardContent. - *

For example, if the given instance nbContent has a tool content id - * of 3, and consider an extract of the tl_lanb11_session table:

- *
 
-     * 		 ----------------------------
-     * 		 attachmentId | toolSessionId
-     * 		 ----------------------------
-     * 			1		  | 	3
-     * 			2		  | 	3
-     * 			3		  | 	3
-     * 			4 		  | 	1
-     * 		 ----------------------------
-     * 
- * Then a call to getSessionsFromContent will return a list containing the values - * 1, 2 and 3. - * @param nbContent The instance of NoticeboardContent in which you want the list of toolSessionIds - * @return a list of tool session Ids - */ - public List getSessionsFromContent(NoticeboardContent nbContent); } \ No newline at end of file Index: lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/dao/hibernate/NoticeboardSessionDAO.java =================================================================== diff -u -rccfd66f1abbfc63cd0ed0a044f89914418d67cd1 -rf76780e7823d8ac845669773cc86f5a30012159a --- lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/dao/hibernate/NoticeboardSessionDAO.java (.../NoticeboardSessionDAO.java) (revision ccfd66f1abbfc63cd0ed0a044f89914418d67cd1) +++ lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/dao/hibernate/NoticeboardSessionDAO.java (.../NoticeboardSessionDAO.java) (revision f76780e7823d8ac845669773cc86f5a30012159a) @@ -29,7 +29,6 @@ import org.hibernate.FlushMode; import org.hibernate.HibernateException; import org.hibernate.Session; -import org.lamsfoundation.lams.tool.noticeboard.NoticeboardContent; import org.lamsfoundation.lams.tool.noticeboard.NoticeboardSession; import org.lamsfoundation.lams.tool.noticeboard.NoticeboardUser; import org.lamsfoundation.lams.tool.noticeboard.dao.INoticeboardSessionDAO; @@ -39,61 +38,60 @@ /** * @author mtruong - *

Hibernate implementation for database access to Noticeboard sessions for the noticeboard tool.

+ *

+ * Hibernate implementation for database access to Noticeboard sessions for the noticeboard tool. + *

*/ public class NoticeboardSessionDAO extends HibernateDaoSupport implements INoticeboardSessionDAO { - private static final String FIND_NB_SESSION = "from " + NoticeboardSession.class.getName() + " as nb where nb.nbSessionId=?"; + private static final String FIND_NB_SESSION = "from " + NoticeboardSession.class.getName() + + " as nb where nb.nbSessionId=?"; private static final String LOAD_NBSESSION_BY_USER = "select ns from NoticeboardSession ns left join fetch " + "ns.nbUsers user where user.userId=:userId"; - private static final String GET_SESSIONS_FROM_CONTENT = "select ns.nbSessionId from NoticeboardSession ns where ns.nbContent= :nbContent"; - - /** @see org.lamsfoundation.lams.tool.noticeboard.dao.INoticeboardSessionDAO#findNbSessionById(java.lang.Long) */ - public NoticeboardSession findNbSessionById(Long nbSessionId) - { + @SuppressWarnings("unchecked") + @Override + public NoticeboardSession findNbSessionById(Long nbSessionId) { String query = "from NoticeboardSession nbS where nbS.nbSessionId=?"; - List session = getHibernateTemplate().find(query,nbSessionId); + List session = (List) getHibernateTemplate().find(query, nbSessionId); - if(session!=null && session.size() == 0) - { + if ((session != null) && (session.size() == 0)) { return null; + } else { + return session.get(0); } - else - { - return (NoticeboardSession)session.get(0); - } } /** @see org.lamsfoundation.lams.tool.noticeboard.dao.INoticeboardSessionDAO#saveNbSession(org.lamsfoundation.lams.tool.noticeboard.NoticeboardSession) */ - public void saveNbSession(NoticeboardSession nbSession) - { + @Override + public void saveNbSession(NoticeboardSession nbSession) { this.getHibernateTemplate().save(nbSession); } /** @see org.lamsfoundation.lams.tool.noticeboard.dao.INoticeboardSessionDAO#updateNbSession(org.lamsfoundation.lams.tool.noticeboard.NoticeboardSession) */ - public void updateNbSession(NoticeboardSession nbSession) - { + @Override + public void updateNbSession(NoticeboardSession nbSession) { this.getHibernateTemplate().update(nbSession); } /** @see org.lamsfoundation.lams.tool.noticeboard.dao.INoticeboardSessionDAO#removeNbSession(java.lang.Long) */ - public void removeNbSession(Long nbSessionId) - { + @SuppressWarnings("unchecked") + @Override + public void removeNbSession(Long nbSessionId) { HibernateTemplate templ = this.getHibernateTemplate(); if ( nbSessionId != null) { //String query = "from org.lamsfoundation.lams.tool.noticeboard.NoticeboardContent as nb where nb.nbContentId=?"; - List list = getSessionFactory().getCurrentSession().createQuery(FIND_NB_SESSION) + List list = getSessionFactory().getCurrentSession().createQuery(FIND_NB_SESSION) .setLong(0,nbSessionId.longValue()) .list(); - if(list != null && list.size() > 0){ + if ((list != null) && (list.size() > 0)) { NoticeboardSession nb = (NoticeboardSession) list.get(0); getSessionFactory().getCurrentSession().setFlushMode(FlushMode.AUTO); templ.delete(nb); @@ -104,53 +102,43 @@ } /** @see org.lamsfoundation.lams.tool.noticeboard.dao.INoticeboardSessionDAO#removeNbSession(org.lamsfoundation.lams.tool.noticeboard.NoticeboardSession) */ - public void removeNbSession(NoticeboardSession nbSession) - { + @Override + public void removeNbSession(NoticeboardSession nbSession) { removeNbSession(nbSession.getNbSessionId()); //this.getHibernateTemplate().delete(nbSession); } /** @see org.lamsfoundation.lams.tool.noticeboard.dao.INoticeboardSessionDAO#getNbSessionByUser(java.lang.Long) */ - public NoticeboardSession getNbSessionByUser(final Long userId) - { - return (NoticeboardSession) getHibernateTemplate().execute(new HibernateCallback() - { + @Override + public NoticeboardSession getNbSessionByUser(final Long userId) { + return (NoticeboardSession) getHibernateTemplate().execute(new HibernateCallback() { - public Object doInHibernate(Session session) throws HibernateException - { - return session.createQuery(LOAD_NBSESSION_BY_USER) - .setLong("userId", - userId.longValue()) - .uniqueResult(); + @Override + public Object doInHibernate(Session session) throws HibernateException { + return session.createQuery(NoticeboardSessionDAO.LOAD_NBSESSION_BY_USER) + .setLong("userId", userId.longValue()).uniqueResult(); } }); } /** @see org.lamsfoundation.lams.tool.noticeboard.dao.INoticeboardSessionDAO#removeNbUsers(org.lamsfoundation.lams.tool.noticeboard.NoticeboardSession) */ - public void removeNbUsers(NoticeboardSession nbSession) - { + @Override + public void removeNbUsers(NoticeboardSession nbSession) { this.getHibernateTemplate().deleteAll(nbSession.getNbUsers()); } - - /** @see org.lamsfoundation.lams.tool.noticeboard.dao.INoticeboardSessionDAO#addNbUsers(java.lang.Long, org.lamsfoundation.lams.tool.noticeboard.NoticeboardSession) */ - public void addNbUsers(Long nbSessionId, NoticeboardUser user) - { + /** + * @see org.lamsfoundation.lams.tool.noticeboard.dao.INoticeboardSessionDAO#addNbUsers(java.lang.Long, + * org.lamsfoundation.lams.tool.noticeboard.NoticeboardSession) + */ + @Override + public void addNbUsers(Long nbSessionId, NoticeboardUser user) { NoticeboardSession session = findNbSessionById(nbSessionId); user.setNbSession(session); session.getNbUsers().add(user); this.getHibernateTemplate().saveOrUpdate(user); this.getHibernateTemplate().merge(session); } - - /** @see org.lamsfoundation.lams.tool.noticeboard.dao.INoticeboardSessionDAO#getSessionsFromContent(org.lamsfoundation.lams.tool.noticeboard.NoticeboardSession) */ - public List getSessionsFromContent(NoticeboardContent nbContent) - { - return (getHibernateTemplate().findByNamedParam(GET_SESSIONS_FROM_CONTENT, - "nbContent", - nbContent)); - } - } Index: lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/service/INoticeboardService.java =================================================================== diff -u -rbe07c35c372d904a65581d98660e73f3b13b69db -rf76780e7823d8ac845669773cc86f5a30012159a --- lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/service/INoticeboardService.java (.../INoticeboardService.java) (revision be07c35c372d904a65581d98660e73f3b13b69db) +++ lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/service/INoticeboardService.java (.../INoticeboardService.java) (revision f76780e7823d8ac845669773cc86f5a30012159a) @@ -31,247 +31,280 @@ import org.lamsfoundation.lams.tool.noticeboard.NoticeboardSession; import org.lamsfoundation.lams.tool.noticeboard.NoticeboardUser; - /** * Defines the contract that the tool service provider must follow * * @author mtruong */ public interface INoticeboardService { - - //=================================================================== + + // =================================================================== // NoticeboardContent access methods - //=================================================================== - - - + // =================================================================== + /** - *

Returns the persistent instance of NoticeboardContent - * with the given tool session id nbSessionId, returns null if not found. + *

+ * Returns the persistent instance of NoticeboardContent with the given tool session id nbSessionId, + * returns null if not found. * - * @param nbSessionId The tool session id + * @param nbSessionId + * The tool session id * @return a persistent instance of NoticeboardContent or null if not found. - */ - public NoticeboardContent retrieveNoticeboardBySessionID(Long nbSessionId); - + */ + public NoticeboardContent retrieveNoticeboardBySessionID(Long nbSessionId); + /** - *

Retrieve an instance of NoticeboardContent with the given - * tool content id nbContentId

- * @param nbContentId The tool content id + *

+ * Retrieve an instance of NoticeboardContent with the given tool content id nbContentId + *

+ * + * @param nbContentId + * The tool content id * @return an instance of NoticeboardContent */ - public NoticeboardContent retrieveNoticeboard(Long nbContentId); - - - /** - *

Persist/Update the given persistent instance of NoticeboardContent.

- * - * @param nbContent The instance of NoticeboardContent to persist. - */ - public void saveNoticeboard(NoticeboardContent nbContent); - - - /** - *

Deletes all instances of NoticeboardSession that are associated - * with the given instance of NoticeboardContent

+ public NoticeboardContent retrieveNoticeboard(Long nbContentId); + + /** + *

+ * Persist/Update the given persistent instance of NoticeboardContent. + *

* - * @param nbContent The instance of NoticeboardContent in which corresponding instances of NoticeboardSession should be deleted. + * @param nbContent + * The instance of NoticeboardContent to persist. */ - public void removeNoticeboardSessionsFromContent(NoticeboardContent nbContent); - - /** - *

Delete the given instance of NoticeboardContent with the - * given tool content id nbContentId + public void saveNoticeboard(NoticeboardContent nbContent); + + /** + *

+ * Deletes all instances of NoticeboardSession that are associated with the given instance of NoticeboardContent + *

* - * @param nbContentId The tool content Id. + * @param nbContent + * The instance of NoticeboardContent in which corresponding instances of NoticeboardSession should be + * deleted. */ - public void removeNoticeboard(Long nbContentId); - - /** - *

Delete the given instance of NoticeboardContent

+ public void removeNoticeboardSessionsFromContent(NoticeboardContent nbContent); + + /** + *

+ * Delete the given instance of NoticeboardContent with the given tool content id nbContentId * - * @param nbContent The instance of NoticeboardContent to delete. + * @param nbContentId + * The tool content Id. */ + public void removeNoticeboard(Long nbContentId); + + /** + *

+ * Delete the given instance of NoticeboardContent + *

+ * + * @param nbContent + * The instance of NoticeboardContent to delete. + */ public void removeNoticeboard(NoticeboardContent nbContent); - - - //=================================================================== + + // =================================================================== // NoticeboardSession access methods - //=================================================================== + // =================================================================== /** - *

Return the persistent instance of a NoticeboardSession - * with the given tool session id nbSessionId, - * returns null if not found.

- * - * @param nbSessionId The tool session id - * @return the persistent instance of a NoticeboardSession or null if not found. - */ - public NoticeboardSession retrieveNoticeboardSession(Long nbSessionId); - + *

+ * Return the persistent instance of a NoticeboardSession with the given tool session id nbSessionId, + * returns null if not found. + *

+ * + * @param nbSessionId + * The tool session id + * @return the persistent instance of a NoticeboardSession or null if not found. + */ + public NoticeboardSession retrieveNoticeboardSession(Long nbSessionId); - /** - * Persists the new NoticeboardSession object into the database. - * - * @param nbSession the NoticeboardSession object to persist - */ - public void saveNoticeboardSession(NoticeboardSession nbSession); - - - /** - * Updates the values of the noticeboard session. - * @param nbSession - */ - public void updateNoticeboardSession(NoticeboardSession nbSession); - - /** - * Remove the noticeboard session object with session id of - * that specified in the argument. - * - * @param nbSessionId The id of the requested noticeboard object - * - */ - public void removeSession(Long nbSessionId); - - /** - *

Delete the given instance of NoticeboardSession

+ /** + * Persists the new NoticeboardSession object into the database. * - * @param nbSession The instance of NoticeboardSession to delete. + * @param nbSession + * the NoticeboardSession object to persist */ + public void saveNoticeboardSession(NoticeboardSession nbSession); + + /** + * Updates the values of the noticeboard session. + * + * @param nbSession + */ + public void updateNoticeboardSession(NoticeboardSession nbSession); + + /** + * Remove the noticeboard session object with session id of that specified in the argument. + * + * @param nbSessionId + * The id of the requested noticeboard object + * + */ + public void removeSession(Long nbSessionId); + + /** + *

+ * Delete the given instance of NoticeboardSession + *

+ * + * @param nbSession + * The instance of NoticeboardSession to delete. + */ public void removeSession(NoticeboardSession nbSession); - - + /** - *

Deletes all instances of NoticeboardUser that are associated - * with the given instance of NoticeboardSession

+ *

+ * Deletes all instances of NoticeboardUser that are associated with the given instance of NoticeboardSession + *

* - * @param nbSession The instance of NoticeboardSession in which corresponding instances of NoticeboardUser should be deleted. + * @param nbSession + * The instance of NoticeboardSession in which corresponding instances of NoticeboardUser should be + * deleted. */ - public void removeNoticeboardUsersFromSession(NoticeboardSession nbSession); - - /** - *

Returns the persistent instance of NoticeboardSession - * with the given noticeboard user iduserId, returns null if not found. + public void removeNoticeboardUsersFromSession(NoticeboardSession nbSession); + + /** + *

+ * Returns the persistent instance of NoticeboardSession with the given noticeboard user iduserId, + * returns null if not found. * - * @param userId The user id + * @param userId + * The user id * @return a persistent instance of NoticeboardSession or null if not found. - */ - public NoticeboardSession retrieveNbSessionByUserID(Long userId); - - //=================================================================== + */ + public NoticeboardSession retrieveNbSessionByUserID(Long userId); + + // =================================================================== // NoticeboardUser access methods - //=================================================================== + // =================================================================== /** - *

Return the persistent instance of a NoticeboardUser - * with the given user idnbUserId, - * returns null if not found.

- * - * @param nbUserId The user id of the instance of NoticeboardUser - * @return the persistent instance of a NoticeboardUser or null if not found. - */ - public NoticeboardUser retrieveNoticeboardUser(Long nbUserId, Long toolSessionId); - - /** - *

Return the persistent instance of a NoticeboardUser - * who has the user id userId and tool session id - * sessionId - * returns null if not found.

- * - * @param userId. The id of the learner - * @param sessionId. The tool session id to which this user belongs to. - * @return the persistent instance of a NoticeboardUser or null if not found. - */ - public NoticeboardUser retrieveNbUserBySession(Long userId, Long sessionId); - - /** - * Persists the new NoticeboardUser object into the database. - * - * @param nbUser the NoticeboardUser object to persist - */ - public void saveNoticeboardUser(NoticeboardUser nbUser); - - - /** - * Updates the values of the noticeboard user. - * @param nbUser - */ - public void updateNoticeboardUser(NoticeboardUser nbUser); - - /** - * Remove the noticeboard user object with user id of - * that specified in the argument. - * - * @param nbUserId The id of the requested noticeboard object - * @param toolSessionId The id of the nbUser's associated nbSession - * - */ - public void removeUser(Long nbUserId, Long toolSessionId); - - /** - *

Delete the given instance of NoticeboardUser

+ *

+ * Return the persistent instance of a NoticeboardUser with the given user idnbUserId, returns null if + * not found. + *

* - * @param nbUser The instance of NoticeboardUser to delete. + * @param nbUserId + * The user id of the instance of NoticeboardUser + * @return the persistent instance of a NoticeboardUser or null if not found. */ + public NoticeboardUser retrieveNoticeboardUser(Long nbUserId, Long toolSessionId); + + /** + *

+ * Return the persistent instance of a NoticeboardUser who has the user id userId and tool session id + * sessionId returns null if not found. + *

+ * + * @param userId + * . The id of the learner + * @param sessionId + * . The tool session id to which this user belongs to. + * @return the persistent instance of a NoticeboardUser or null if not found. + */ + public NoticeboardUser retrieveNbUserBySession(Long userId, Long sessionId); + + /** + * Persists the new NoticeboardUser object into the database. + * + * @param nbUser + * the NoticeboardUser object to persist + */ + public void saveNoticeboardUser(NoticeboardUser nbUser); + + /** + * Updates the values of the noticeboard user. + * + * @param nbUser + */ + public void updateNoticeboardUser(NoticeboardUser nbUser); + + /** + * Remove the noticeboard user object with user id of that specified in the argument. + * + * @param nbUserId + * The id of the requested noticeboard object + * @param toolSessionId + * The id of the nbUser's associated nbSession + * + */ + public void removeUser(Long nbUserId, Long toolSessionId); + + /** + *

+ * Delete the given instance of NoticeboardUser + *

+ * + * @param nbUser + * The instance of NoticeboardUser to delete. + */ public void removeUser(NoticeboardUser nbUser); - + /** - *

Saves the instance of NoticeboardSession to the database. - * This instance is added to the collection of sessions from - * NoticeboardContent with tool content id nbContentId

+ *

+ * Saves the instance of NoticeboardSession to the database. This instance is added to the collection of sessions + * from NoticeboardContent with tool content id nbContentId + *

* - * @param nbContentId The tool content Id - * @param session The instance of NoticeboardSession to persist + * @param nbContentId + * The tool content Id + * @param session + * The instance of NoticeboardSession to persist */ public void addSession(Long nbContentId, NoticeboardSession session); - + /** - *

Saves the instance of NoticeboardUser to the database. - * nbUser is added to the collection of users from - * NoticeboardSession with tool session id nbSessionId

+ *

+ * Saves the instance of NoticeboardUser to the database. nbUser is added to the collection of users + * from NoticeboardSession with tool session id nbSessionId + *

* - * @param nbSessionId The tool session id - * @param user The instance of NoticeboardUser to persist + * @param nbSessionId + * The tool session id + * @param user + * The instance of NoticeboardUser to persist */ public void addUser(Long nbSessionId, NoticeboardUser nbUser); - + /** - *

Retrieves a list of the session IDs from the given instance of NoticeboardContent

- * @param content - * @return list of session ids (Long) - */ - public List getSessionIdsFromContent(NoticeboardContent content); - - /** - *

Returns the number of users in this session

+ *

+ * Returns the number of users in this session + *

+ * * @param session * @return The number of users in the session */ public int getNumberOfUsersInSession(NoticeboardSession session); - + /** - *

Finds the number of learners that have participated in this tool activity - * with the given toolContentId. It finds all the toolSessionIds relating to this - * toolContentId, and calculates the number of users in each tool session(group). - * Returns the total number of users across all sessions

- * @param toolContentId + *

+ * Finds the number of learners that have participated in this tool activity with the given toolContentId. It finds + * all the toolSessionIds relating to this toolContentId, and calculates the number of users in each tool + * session(group). Returns the total number of users across all sessions + *

+ * + * @param toolContentId * @return the total number of users for this tool activity */ public int calculateTotalNumberOfUsers(Long toolContentId); /** * This method retrieves the default content id. - * @param toolSignature The tool signature which is defined in lams_tool table. + * + * @param toolSignature + * The tool signature which is defined in lams_tool table. * @return the default content id */ public Long getToolDefaultContentIdBySignature(String toolSignature); - + public Long createNotebookEntry(Long id, Integer idType, String signature, Integer userID, String entry); - + public NotebookEntry getEntry(Long id, Integer idType, String signature, Integer userID); - - public void updateEntry(NotebookEntry notebookEntry); - - public List getUsersBySession(Long sessionId); - + + public void updateEntry(NotebookEntry notebookEntry); + + public List getUsersBySession(Long sessionId); + /** * Returns whether activity is grouped and therefore it is expected more than one tool session. * Index: lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/service/NoticeboardServicePOJO.java =================================================================== diff -u -r40eb54374e84591563d8b6a679ac719dbc85c8f7 -rf76780e7823d8ac845669773cc86f5a30012159a --- lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/service/NoticeboardServicePOJO.java (.../NoticeboardServicePOJO.java) (revision 40eb54374e84591563d8b6a679ac719dbc85c8f7) +++ lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/service/NoticeboardServicePOJO.java (.../NoticeboardServicePOJO.java) (revision f76780e7823d8ac845669773cc86f5a30012159a) @@ -75,515 +75,221 @@ */ public class NoticeboardServicePOJO implements INoticeboardService, ToolContentManager, ToolSessionManager, ToolContentImport102Manager { + private static Logger log = Logger.getLogger(NoticeboardServicePOJO.class); - private NoticeboardContent nbContent; - private INoticeboardContentDAO nbContentDAO = null; - - private NoticeboardSession nbSession; - private INoticeboardSessionDAO nbSessionDAO = null; - private ILearnerService learnerService; private ILamsToolService toolService; - - private NoticeboardUser nbUser; - private INoticeboardUserDAO nbUserDAO = null; - private IToolContentHandler nbToolContentHandler = null; - private IExportToolContentService exportContentService; - private static Logger log = Logger.getLogger(NoticeboardServicePOJO.class); - + private IToolContentHandler nbToolContentHandler; private ICoreNotebookService coreNotebookService; - /* - * ============================================================================== Methods for access to - * NoticeboardContent objects ============================================================================== - */ + private INoticeboardContentDAO nbContentDAO; + private INoticeboardSessionDAO nbSessionDAO; + private INoticeboardUserDAO nbUserDAO; - /** - * @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#retrieveNoticeboard(Long) - */ + @Override public NoticeboardContent retrieveNoticeboard(Long nbContentId) throws NbApplicationException { if (nbContentId == null) { - String error = "Unable to continue. The tool content id is missing"; - NoticeboardServicePOJO.log.error(error); - throw new NbApplicationException(error); + throw new NbApplicationException("Tool content ID is missing"); } - try { - nbContent = nbContentDAO.findNbContentById(nbContentId); - - } catch (DataAccessException e) { - throw new NbApplicationException("An exception has occured when trying to retrieve noticeboard content: " - + e.getMessage(), e); - } - - return nbContent; + return nbContentDAO.findNbContentById(nbContentId); } - /** - * @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#retrieveNoticeboardBySessionID(Long) - */ + @Override public NoticeboardContent retrieveNoticeboardBySessionID(Long nbSessionId) { if (nbSessionId == null) { - String error = "Unable to continue. The tool session id is missing"; - NoticeboardServicePOJO.log.error(error); - throw new NbApplicationException(error); + throw new NbApplicationException("Tool session ID is missing"); } - try { - nbContent = nbContentDAO.getNbContentBySession(nbSessionId); - } catch (DataAccessException e) { - throw new NbApplicationException("An exception has occured when trying to retrieve noticeboard content: " - + e.getMessage(), e); - } - - return nbContent; + return nbContentDAO.getNbContentBySession(nbSessionId); } - /** - * @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#saveNoticeboard(org.lamsfoundation.lams.tool.noticeboard.NoticeboardContent) - */ + @Override public void saveNoticeboard(NoticeboardContent nbContent) { - try { - if (nbContent.getUid() == null) { - nbContentDAO.saveNbContent(nbContent); - } else { - nbContentDAO.updateNbContent(nbContent); - } - } catch (DataAccessException e) { - throw new NbApplicationException( - "EXCEPTION: An exception has occurred while trying to save the noticeboard content object: " - + e.getMessage(), e); + if (nbContent.getUid() == null) { + nbContentDAO.saveNbContent(nbContent); + } else { + nbContentDAO.updateNbContent(nbContent); } } - /** - * @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#removeNoticeboardSessions(org.lamsfoundation.lams.tool.noticeboard.NoticeboardContent) - */ + @Override public void removeNoticeboardSessionsFromContent(NoticeboardContent nbContent) { - try { - nbContent.getNbSessions().clear(); - // updateNoticeboard(nbContent); - - nbContentDAO.removeNbSessions(nbContent); - } catch (DataAccessException e) { - throw new NbApplicationException( - "EXCEPTION: An exception has occurred while trying to remove the sessions associated with this noticeboard content object: " - + e.getMessage(), e); - } - + nbContent.getNbSessions().clear(); + nbContentDAO.removeNbSessions(nbContent); } - /** - * @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#removeNoticeboard(org.lamsfoundation.lams.tool.noticeboard.NoticeboardContent) - */ + @Override public void removeNoticeboard(Long nbContentId) { if (nbContentId == null) { - String error = "Unable to continue. The tool content id is missing"; - NoticeboardServicePOJO.log.error(error); - throw new NbApplicationException(error); + throw new NbApplicationException("Tool content ID is missing"); } - - try { - nbContentDAO.removeNoticeboard(nbContentId); - } catch (DataAccessException e) { - throw new NbApplicationException( - "EXCEPTION: An exception has occurred while trying to remove this noticeboard content object: " - + e.getMessage(), e); - } + nbContentDAO.removeNoticeboard(nbContentId); } - /** - * @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#removeNoticeboard(org.lamsfoundation.lams.tool.noticeboard.NoticeboardContent) - */ + @Override public void removeNoticeboard(NoticeboardContent nbContent) { - try { - nbContentDAO.removeNoticeboard(nbContent); - } catch (DataAccessException e) { - throw new NbApplicationException( - "EXCEPTION: An exception has occurred while trying to remove this noticeboard content object: " - + e.getMessage(), e); - } + nbContentDAO.removeNoticeboard(nbContent); } - /* - * ============================================================================== Methods for access to - * NoticeboardSession objects ============================================================================== - */ - - /** - * @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#retrieveNoticeboardSession(Long) - */ + @Override public NoticeboardSession retrieveNoticeboardSession(Long nbSessionId) { if (nbSessionId == null) { - String error = "Unable to continue. The tool session id is missing"; - NoticeboardServicePOJO.log.error(error); - throw new NbApplicationException(error); + throw new NbApplicationException("Tool session ID is missing"); } - try { - nbSession = nbSessionDAO.findNbSessionById(nbSessionId); - } catch (DataAccessException e) { - throw new NbApplicationException( - "An exception has occured when trying to retrieve noticeboard session object: " + e.getMessage(), e); - } - - return nbSession; + return nbSessionDAO.findNbSessionById(nbSessionId); } - /** - * @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#saveNoticeboardSession(org.lamsfoundation.lams.tool.noticeboard.NoticeboardSession) - */ + @Override public void saveNoticeboardSession(NoticeboardSession nbSession) { - try { - NoticeboardContent content = nbSession.getNbContent(); - // content.getNbSessions().add(nbSession); - // content. - - /* updateNoticeboard(content); */ - nbSessionDAO.saveNbSession(nbSession); - } catch (DataAccessException e) { - throw new NbApplicationException( - "EXCEPTION: An exception has occurred while trying to save this noticeboard session: " - + e.getMessage(), e); - } + NoticeboardContent content = nbSession.getNbContent(); + nbSessionDAO.saveNbSession(nbSession); } - /** - * @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#updateNoticeboardSession(org.lamsfoundation.lams.tool.noticeboard.NoticeboardSession) - */ + @Override public void updateNoticeboardSession(NoticeboardSession nbSession) { - try { - nbSessionDAO.updateNbSession(nbSession); - } catch (DataAccessException e) { - throw new NbApplicationException( - "EXCEPTION: An exception has occurred while trying to update this noticeboard session: " - + e.getMessage(), e); - } + nbSessionDAO.updateNbSession(nbSession); } - /** - * @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#removeSession(Long) - */ + @Override public void removeSession(Long nbSessionId) { if (nbSessionId == null) { - String error = "Unable to continue. The tool session id is missing"; - NoticeboardServicePOJO.log.error(error); - throw new NbApplicationException(error); + throw new NbApplicationException("Tool session id is missing"); } - try { - NoticeboardSession sessionToDelete = retrieveNoticeboardSession(nbSessionId); - NoticeboardContent contentReferredBySession = sessionToDelete.getNbContent(); - // un-associate the session from content - contentReferredBySession.getNbSessions().remove(sessionToDelete); - nbSessionDAO.removeNbSession(nbSessionId); - // updateNoticeboard(contentReferredBySession); - } catch (DataAccessException e) { - throw new NbApplicationException( - "EXCEPTION: An exception has occurred while trying to remove this noticeboard session object: " - + e.getMessage(), e); - } + NoticeboardSession sessionToDelete = retrieveNoticeboardSession(nbSessionId); + NoticeboardContent contentReferredBySession = sessionToDelete.getNbContent(); + // un-associate the session from content + contentReferredBySession.getNbSessions().remove(sessionToDelete); + nbSessionDAO.removeNbSession(nbSessionId); } - /** - * @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#removeSession(org.lamsfoundation.lams.tool.noticeboard.NoticeboardSession) - */ + @Override public void removeSession(NoticeboardSession nbSession) { - try { - NoticeboardContent contentReferredBySession = nbSession.getNbContent(); - // un-associate the session from content - contentReferredBySession.getNbSessions().remove(nbSession); - - nbSessionDAO.removeNbSession(nbSession); - // updateNoticeboard(contentReferredBySession); - } catch (DataAccessException e) { - throw new NbApplicationException( - "EXCEPTION: An exception has occurred while trying to remove this noticeboard session object: " - + e.getMessage(), e); - } + NoticeboardContent contentReferredBySession = nbSession.getNbContent(); + // un-associate the session from content + contentReferredBySession.getNbSessions().remove(nbSession); + nbSessionDAO.removeNbSession(nbSession); } - /** - * @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#removeNoticeboardUsersFromSession(org.lamsfoundation.lams.tool.noticeboard.NoticeboardSession) - */ + @Override public void removeNoticeboardUsersFromSession(NoticeboardSession nbSession) { - try { - nbSession.getNbUsers().clear(); - // updateNoticeboardSession(nbSession); - - nbSessionDAO.removeNbUsers(nbSession); - } catch (DataAccessException e) { - throw new NbApplicationException( - "EXCEPTION: An exception has occurred while trying to remove the users associated with this noticeboard session instance: " - + e.getMessage(), e); - } - + nbSession.getNbUsers().clear(); + nbSessionDAO.removeNbUsers(nbSession); } - /** - * @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#retrieveNbSessionByUserID(java.lang.Long) - */ + @Override public NoticeboardSession retrieveNbSessionByUserID(Long userId) { if (userId == null) { - String error = "Unable to continue. The tool session id is missing"; - NoticeboardServicePOJO.log.error(error); - throw new NbApplicationException(error); + throw new NbApplicationException("Tool session ID is missing"); } - - try { - nbSession = nbSessionDAO.getNbSessionByUser(userId); - } catch (DataAccessException e) { - throw new NbApplicationException( - "EXCEPTION: An exception has occurred while trying to retrieve noticeboard session instance " - + e.getMessage(), e); - } - return nbSession; - + return nbSessionDAO.getNbSessionByUser(userId); } - /** @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#getSessionIdsFromContent(org.lamsfoundation.lams.tool.noticeboard.NoticeboardContent) */ - public List getSessionIdsFromContent(NoticeboardContent content) { - List list = null; - try { - list = nbSessionDAO.getSessionsFromContent(content); - } catch (DataAccessException e) { - throw new NbApplicationException( - "EXCEPTION: An exception has occurred while trying to the list of session ids from content " - + e.getMessage(), e); - } - return list; - } - - /* - * ============================================================================== Methods for access to - * NoticeboardUser objects ============================================================================== - */ - - /** - * @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#retrieveNoticeboardUser(java.lang.Long) - */ + @Override public NoticeboardUser retrieveNoticeboardUser(Long nbUserId, Long nbSessionId) { if (nbUserId == null) { - String error = "Unable to continue. The user id is missing"; - NoticeboardServicePOJO.log.error(error); - throw new NbApplicationException(error); + throw new NbApplicationException("User ID is missing"); } - try { - nbUser = nbUserDAO.getNbUser(nbUserId, nbSessionId); - } catch (DataAccessException e) { - throw new NbApplicationException("An exception has occured when trying to retrieve noticeboard user: " - + e.getMessage(), e); - } - - return nbUser; + return nbUserDAO.getNbUser(nbUserId, nbSessionId); } - /** - * @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#saveNoticeboardUser(org.lamsfoundation.lams.tool.noticeboard.NoticeboardUser) - */ + @Override public void saveNoticeboardUser(NoticeboardUser nbUser) { - try { - NoticeboardSession session = nbUser.getNbSession(); - session.getNbUsers().add(nbUser); - // updateNoticeboardSession(session); - - nbUserDAO.saveNbUser(nbUser); - } catch (DataAccessException e) { - throw new NbApplicationException( - "EXCEPTION: An exception has occurred while trying to save the noticeboard user object: " - + e.getMessage(), e); - } + NoticeboardSession session = nbUser.getNbSession(); + session.getNbUsers().add(nbUser); + nbUserDAO.saveNbUser(nbUser); } - /** - * org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#retrieveNbUserBySession(java.lang.Long, - * java.lang.Long) - */ + @Override public NoticeboardUser retrieveNbUserBySession(Long userId, Long sessionId) { - try { - nbUser = nbUserDAO.getNbUserBySession(userId, sessionId); - } catch (DataAccessException e) { - throw new NbApplicationException( - "EXCEPTION: An exception has occurred while trying to retrive the noticeboard user object: " - + e.getMessage(), e); - } - - return nbUser; + return nbUserDAO.getNbUserBySession(userId, sessionId); } - /** - * @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#updateNoticeboardUser(org.lamsfoundation.lams.tool.noticeboard.NoticeboardUser) - */ + @Override public void updateNoticeboardUser(NoticeboardUser nbUser) { - try { - nbUserDAO.updateNbUser(nbUser); - } catch (DataAccessException e) { - throw new NbApplicationException( - "EXCEPTION: An exception has occurred while trying to update the noticeboard user object: " - + e.getMessage(), e); - } + nbUserDAO.updateNbUser(nbUser); } - /** - * @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#removeUser(org.lamsfoundation.lams.tool.noticeboard.NoticeboardUser) - */ + @Override public void removeUser(NoticeboardUser nbUser) { - try { - NoticeboardSession session = nbUser.getNbSession(); - session.getNbUsers().remove(nbUser); - - nbUserDAO.removeNbUser(nbUser); - - // updateNoticeboardSession(session); - } catch (DataAccessException e) { - throw new NbApplicationException( - "EXCEPTION: An exception has occurred while trying to remove the noticeboard user object: " - + e.getMessage(), e); - } + NoticeboardSession session = nbUser.getNbSession(); + session.getNbUsers().remove(nbUser); + nbUserDAO.removeNbUser(nbUser); } - /** - * @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#removeUser(java.lang.Long) - */ + @Override public void removeUser(Long nbUserId, Long toolSessionId) { if (nbUserId == null) { - String error = "Unable to continue. The user id is missing"; - NoticeboardServicePOJO.log.error(error); - throw new NbApplicationException(error); + throw new NbApplicationException("User ID is missing"); } - try { - NoticeboardUser user = retrieveNoticeboardUser(nbUserId, toolSessionId); - NoticeboardSession session = user.getNbSession(); - session.getNbUsers().remove(user); - nbUserDAO.removeNbUser(nbUserId); - - // updateNoticeboardSession(session); - } catch (DataAccessException e) { - throw new NbApplicationException( - "EXCEPTION: An exception has occurred while trying to remove the noticeboard user object: " - + e.getMessage(), e); - } + NoticeboardUser user = retrieveNoticeboardUser(nbUserId, toolSessionId); + NoticeboardSession session = user.getNbSession(); + session.getNbUsers().remove(user); + nbUserDAO.removeNbUser(nbUserId); } - /** - * @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#addSession(java.lang.Long, - * org.lamsfoundation.lams.tool.noticeboard.NoticeboardSession) - */ + @Override public void addSession(Long nbContentId, NoticeboardSession session) { - - if (nbContentId == null || session == null) { - String error = "Unable to continue. The tool content id is missing"; - NoticeboardServicePOJO.log.error(error); - throw new NbApplicationException(error); + if ((nbContentId == null) || (session == null)) { + throw new NbApplicationException("Tool content ID or session is missing"); } - try { - nbContentDAO.addNbSession(nbContentId, session); - } catch (DataAccessException e) { - throw new NbApplicationException("EXCEPTION: An exception has occurred while trying to create session: " - + e.getMessage(), e); - } + nbContentDAO.addNbSession(nbContentId, session); } - /** - * @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#addUser(java.lang.Long, - * org.lamsfoundation.lams.tool.noticeboard.NoticeboardSession) - */ + @Override public void addUser(Long nbSessionId, NoticeboardUser user) { - if (nbSessionId == null) { - String error = "Unable to continue. The tool session id is missing"; - NoticeboardServicePOJO.log.error(error); - throw new NbApplicationException(error); + throw new NbApplicationException("Tool session ID is missing"); } - try { - nbSessionDAO.addNbUsers(nbSessionId, user); - } catch (DataAccessException e) { - throw new NbApplicationException("EXCEPTION: An exception has occurred while trying to create user: " - + e.getMessage(), e); - } + nbSessionDAO.addNbUsers(nbSessionId, user); } - /** @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#getNumberOfUsersInSession(org.lamsfoundation.lams.tool.noticeboard.oticeboardSession) */ + @Override public int getNumberOfUsersInSession(NoticeboardSession session) { - int numberOfUsers; - try { - numberOfUsers = nbUserDAO.getNumberOfUsers(session); - } catch (DataAccessException e) { - throw new NbApplicationException( - "EXCEPTION: An exception has occurred while trying to get the number of users in the session: " - + e.getMessage(), e); - } - return numberOfUsers; + return nbUserDAO.getNumberOfUsers(session); } - /** @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#calculateTotalNumberOfUsers(java.lang.Long) */ + @Override public int calculateTotalNumberOfUsers(Long toolContentId) { - if (toolContentId == null) { - String error = "Unable to continue. The tool content id is missing"; - NoticeboardServicePOJO.log.error(error); - throw new NbApplicationException(error); + throw new NbApplicationException("Tool content id is missing"); } int totalNumberOfUsers = 0; - try { - nbContent = retrieveNoticeboard(toolContentId); - List listOfSessionIds = getSessionIdsFromContent(nbContent); - - Iterator i = listOfSessionIds.iterator(); - - while (i.hasNext()) { - Long sessionId = (Long) i.next(); - int usersInThisSession = getNumberOfUsersInSession(retrieveNoticeboardSession(sessionId)); - totalNumberOfUsers = totalNumberOfUsers + usersInThisSession; - } - } catch (DataAccessException e) { - throw new NbApplicationException( - "EXCEPTION: An exception has occurred while calculating the total number of users in tool activity " - + e.getMessage(), e); + NoticeboardContent nbContent = retrieveNoticeboard(toolContentId); + for (NoticeboardSession session : nbContent.getNbSessions()) { + totalNumberOfUsers += getNumberOfUsersInSession(session); } + return totalNumberOfUsers; } - public List getUsersBySession(Long sessionId) { - - if (sessionId != null) { - try { - return nbUserDAO.getNbUsersBySession(sessionId); - } catch (DataAccessException e) { - throw new NbApplicationException( - "EXCEPTION: An exception has occurred while trying to get the list of users in the session: " - + e.getMessage(), e); - } - } else { - NoticeboardServicePOJO.log.error("Unable to continue. Session id is missing"); + @SuppressWarnings("unchecked") + @Override + public List getUsersBySession(Long sessionId) { + if (sessionId == null) { + throw new NbApplicationException("Session ID is missing"); } - return null; + return nbUserDAO.getNbUsersBySession(sessionId); } - /* - * ============================================================================== Methods for access to - * NoticeboardUser objects ============================================================================== - */ - + @Override public boolean isGroupedActivity(long toolContentID) { return toolService.isGroupedActivity(toolContentID); } - /* ===============Methods implemented from ToolContentManager =============== */ - - /** @see org.lamsfoundation.lams.tool.ToolContentManager#copyToolContent(java.lang.Long, java.lang.Long) */ + @Override public void copyToolContent(Long fromContentId, Long toContentId) throws ToolException { - if (toContentId == null) { throw new ToolException("Failed to copy Noticeboard tool content. Missing parameter: toContentId"); } if (fromContentId == null) { // use the default content Id - // fromContentId = NoticeboardConstants.DEFAULT_CONTENT_ID; fromContentId = getToolDefaultContentIdBySignature(NoticeboardConstants.TOOL_SIGNATURE); } @@ -620,12 +326,11 @@ @Override public void resetDefineLater(Long toolContentId) throws DataMissingException, ToolException { NoticeboardContent nbContent = getAndCheckIDandObject(toolContentId); - nbContent.setDefineLater(false); saveNoticeboard(nbContent); } - /** @see org.lamsfoundation.lams.tool.ToolContentManager#removeToolContent(java.lang.Long) */ + @Override public void removeToolContent(Long toolContentId, boolean removeSessionData) throws SessionDataExistsException, ToolException { NoticeboardContent nbContent = getAndCheckIDandObject(toolContentId); @@ -638,16 +343,17 @@ removeNoticeboard(toolContentId); } - @SuppressWarnings("unchecked") + @Override public void removeLearnerContent(Long toolContentId, Integer userId) throws ToolException { - if (log.isDebugEnabled()) { - log.debug("Removing Noticeboard user for user ID " + userId + " and toolContentId " + if (NoticeboardServicePOJO.log.isDebugEnabled()) { + NoticeboardServicePOJO.log.debug("Removing Noticeboard user for user ID " + userId + " and toolContentId " + toolContentId); } NoticeboardContent nbContent = nbContentDAO.findNbContentById(toolContentId); if (nbContent == null) { - log.warn("Did not find activity with toolContentId: " + toolContentId + " to remove learner content"); + NoticeboardServicePOJO.log.warn("Did not find activity with toolContentId: " + toolContentId + + " to remove learner content"); return; } @@ -681,7 +387,7 @@ private NoticeboardSession getAndCheckSessionIDandObject(Long toolSessionId) throws ToolException, DataMissingException { if (toolSessionId == null) { - throw new ToolException("Tool session ID is missing. Unable to continue"); + throw new ToolException("Tool session ID is missing."); } NoticeboardSession nbSession = retrieveNoticeboardSession(toolSessionId); @@ -692,23 +398,16 @@ return nbSession; } - /* - * private void checkSessionIDandObject(Long toolSessionId) throws ToolException, DataMissingException { if - * (toolSessionId == null) throw new ToolException("Tool session ID is missing. Unable to continue"); - * - * NoticeboardSession nbSession = retrieveNoticeboardSession(toolSessionId); if (nbSession == null) throw new - * DataMissingException("No tool session matches this tool session id"); } - */ - /** * Export the XML fragment for the tool's content, along with any files needed for the content. * * @throws DataMissingException - * if no tool content matches the toolSessionId + * if no tool content matches the toolSessionId * @throws ToolException - * if any other error occurs + * if any other error occurs */ + @Override public void exportToolContent(Long toolContentId, String rootPath) throws DataMissingException, ToolException { NoticeboardContent toolContentObj = nbContentDAO.findNbContentById(toolContentId); if (toolContentObj == null) { @@ -737,14 +436,15 @@ * Import the XML fragment for the tool's content, along with any files needed for the content. * * @throws ToolException - * if any other error occurs + * if any other error occurs */ + @Override public void importToolContent(Long toolContentId, Integer newUserUid, String toolContentPath, String fromVersion, String toVersion) throws ToolException { try { // register version filter class exportContentService.registerImportVersionFilterClass(NoticeboardImportContentVersionFilter.class); - + Object toolPOJO = exportContentService.importToolContent(toolContentPath, nbToolContentHandler, fromVersion, toVersion); if (!(toolPOJO instanceof NoticeboardContent)) { @@ -769,61 +469,55 @@ * * @return SortedMap of ToolOutputDefinitions with the key being the name of each definition */ + @Override public SortedMap getToolOutputDefinitions(Long toolContentId, int definitionType) throws ToolException { return new TreeMap(); } - + + @Override public String getToolContentTitle(Long toolContentId) { return retrieveNoticeboard(toolContentId).getTitle(); } - + + @Override public boolean isContentEdited(Long toolContentId) { return retrieveNoticeboard(toolContentId).isDefineLater(); } - - /* ===============Methods implemented from ToolSessionManager =============== */ - /** - * @see org.lamsfoundation.lams.tool.ToolSessionManager#createToolSession(java.lang.Long, java.lang.String, - * java.lang.Long) - */ + @Override public void createToolSession(Long toolSessionId, String toolSessionName, Long toolContentId) throws ToolException { - if (toolSessionId == null || toolContentId == null) { + if ((toolSessionId == null) || (toolContentId == null)) { String error = "Failed to create tool session. The tool session id or tool content id is invalid"; throw new ToolException(error); } - nbContent = retrieveNoticeboard(toolContentId); + NoticeboardContent nbContent = retrieveNoticeboard(toolContentId); NoticeboardSession nbSession = new NoticeboardSession(toolSessionId, toolSessionName, nbContent, new Date( System.currentTimeMillis()), NoticeboardSession.NOT_ATTEMPTED); nbContent.getNbSessions().add(nbSession); saveNoticeboard(nbContent); - // saveNoticeboardSession(nbSession); - } - /** - * @see org.lamsfoundation.lams.tool.ToolSessionManager#leaveToolSession(java.lang.Long, - * org.lamsfoundation.lams.usermanagement.User) - */ + @Override public String leaveToolSession(Long toolSessionId, Long learnerId) throws DataMissingException, ToolException { getAndCheckSessionIDandObject(toolSessionId); return learnerService.completeToolSession(toolSessionId, learnerId); } - /** @see org.lamsfoundation.lams.tool.ToolSessionManager#exportToolSession(java.lang.Long) */ + @Override public ToolSessionExportOutputData exportToolSession(Long toolSessionId) throws ToolException, DataMissingException { getAndCheckSessionIDandObject(toolSessionId); throw new UnsupportedOperationException("not yet implemented"); } - /** @see org.lamsfoundation.lams.tool.ToolSessionManager#exportToolSession(java.util.List) */ + @SuppressWarnings("unchecked") + @Override public ToolSessionExportOutputData exportToolSession(List toolSessionIds) throws ToolException, DataMissingException { - Iterator i = toolSessionIds.iterator(); + Iterator i = toolSessionIds.iterator(); if (i.hasNext()) { Long id = (Long) i.next(); getAndCheckSessionIDandObject(id); @@ -832,18 +526,16 @@ throw new UnsupportedOperationException("not yet implemented"); } - /** @see org.lamsfoundation.lams.tool.ToolSessionManager#removeToolSession(java.lang.Long) */ + @Override public void removeToolSession(Long toolSessionId) throws DataMissingException, ToolException { NoticeboardSession session = getAndCheckSessionIDandObject(toolSessionId); removeSession(session); } /** * Get the tool output for the given tool output names. - * - * @see org.lamsfoundation.lams.tool.ToolSessionManager#getToolOutput(java.util.List, java.lang.Long, - * java.lang.Long) */ + @Override public SortedMap getToolOutput(List names, Long toolSessionId, Long learnerId) { return new TreeMap(); } @@ -854,15 +546,15 @@ * @see org.lamsfoundation.lams.tool.ToolSessionManager#getToolOutput(java.lang.String, java.lang.Long, * java.lang.Long) */ + @Override public ToolOutput getToolOutput(String name, Long toolSessionId, Long learnerId) { return null; } - /* ===============Methods implemented from ToolContentImport102Manager =============== */ - /** * Import the data for a 1.0.2 Noticeboard or HTMLNoticeboard */ + @Override public void import102ToolContent(Long toolContentId, UserDTO user, Hashtable importValues) { Date now = new Date(); NoticeboardContent toolContentObj = new NoticeboardContent(); @@ -876,12 +568,11 @@ toolContentObj.setNbContentId(toolContentId); toolContentObj.setTitle((String) importValues.get(ToolContentImport102Manager.CONTENT_TITLE)); toolContentObj.setReflectOnActivity(false); - // leave as empty, no need to set them to anything. - // toolContentObj.setNbSessions(nbSessions); nbContentDAO.saveNbContent(toolContentObj); } /** Set the description, throws away the title value as this is not supported in 2.0 */ + @Override public void setReflectiveData(Long toolContentId, String title, String description) throws ToolException, DataMissingException { @@ -895,60 +586,27 @@ toolContentObj.setReflectInstructions(description); } - // ========================================================================================= - + @Override public Long getToolDefaultContentIdBySignature(String toolSignature) { - Long contentId = null; - contentId = new Long(toolService.getToolDefaultContentIdBySignature(toolSignature)); - if (contentId == null) { - String error = "Could not retrieve default content id for this tool"; - NoticeboardServicePOJO.log.error(error); - throw new NbApplicationException(error); - } - return contentId; + return toolService.getToolDefaultContentIdBySignature(toolSignature); } - /* =============== Used by Spring to "inject" the linked objects =============== */ - - /* - * public INoticeboardContentDAO getNbContentDAO() { return nbContentDAO; } - */ public void setNbContentDAO(INoticeboardContentDAO nbContentDAO) { this.nbContentDAO = nbContentDAO; } - - /* - * public INoticeboardSessionDAO getNbSessionDAO() { return nbSessionDAO; } - */ + public void setNbSessionDAO(INoticeboardSessionDAO nbSessionDAO) { this.nbSessionDAO = nbSessionDAO; } - - /* - * public INoticeboardUserDAO getNbUserDAO() { return nbUserDAO; } - */ + public void setNbUserDAO(INoticeboardUserDAO nbUserDAO) { this.nbUserDAO = nbUserDAO; } - /** - * @return Returns the learnerService. - */ - /* - * public ILearnerService getLearnerService() { return learnerService; } - */ - /** - * @param learnerService - * The learnerService to set. - */ public void setLearnerService(ILearnerService learnerService) { this.learnerService = learnerService; } - /** - * @param toolService - * The toolService to set. - */ public void setToolService(ILamsToolService toolService) { this.toolService = toolService; } @@ -979,27 +637,27 @@ /* =============== Wrappers Methods for Notebook Service (Reflective Option) =============== */ + @Override public Long createNotebookEntry(Long id, Integer idType, String signature, Integer userID, String entry) { return coreNotebookService.createNotebookEntry(id, idType, signature, userID, "", entry); } + @Override public NotebookEntry getEntry(Long id, Integer idType, String signature, Integer userID) { - List list = coreNotebookService.getEntry(id, idType, signature, userID); - if (list == null || list.isEmpty()) { + if ((list == null) || list.isEmpty()) { return null; } else { return list.get(0); } } - /** - * @param notebookEntry - */ + @Override public void updateEntry(NotebookEntry notebookEntry) { coreNotebookService.updateEntry(notebookEntry); } + @Override public Class[] getSupportedToolOutputDefinitionClasses(int definitionType) { return null; }