Index: lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/TaskListConstants.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/TaskListConstants.java,v diff -u -r1.5 -r1.6 --- lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/TaskListConstants.java 28 Mar 2008 02:21:28 -0000 1.5 +++ lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/TaskListConstants.java 31 Mar 2008 06:09:45 -0000 1.6 @@ -63,7 +63,7 @@ public static final String ATTR_NEXT_ACTIVITY_URL = "nextActivityUrl"; public static final String ATTR_SUMMARY = "summary"; public static final String ATTR_TASK_SUMMARY = "taskSummary"; - public static final String ATTR_EXPORT_DTO_LIST = "exportDTOList"; + public static final String ATTR_TASK_SUMMARY_LIST = "taskSummaryList"; public static final String ATTR_USER_LIST = "userList"; public static final String ATTR_FINISH_LOCK = "finishedLock"; public static final String ATTR_SESSION_MAP_ID = "sessionMapID"; Fisheye: Tag 1.2 refers to a dead (removed) revision in file `lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/dto/AttachmentDTO.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.2 refers to a dead (removed) revision in file `lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/dto/CommentDTO.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.2 refers to a dead (removed) revision in file `lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/dto/ExportDTO.java'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/dto/Summary.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/dto/Attic/Summary.java,v diff -u -r1.3 -r1.4 --- lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/dto/Summary.java 28 Mar 2008 02:21:27 -0000 1.3 +++ lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/dto/Summary.java 31 Mar 2008 06:09:45 -0000 1.4 @@ -24,12 +24,9 @@ /* $Id$ */ package org.lamsfoundation.lams.tool.taskList.dto; -import java.util.ArrayList; import java.util.List; import org.lamsfoundation.lams.tool.taskList.model.TaskListItem; -import org.lamsfoundation.lams.tool.taskList.model.TaskListItemAttachment; -import org.lamsfoundation.lams.tool.taskList.model.TaskListItemComment; import org.lamsfoundation.lams.tool.taskList.model.TaskListUser; /** Index: lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/dto/TaskSummary.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/dto/Attic/TaskSummary.java,v diff -u -r1.1 -r1.2 --- lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/dto/TaskSummary.java 28 Mar 2008 02:21:27 -0000 1.1 +++ lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/dto/TaskSummary.java 31 Mar 2008 06:09:45 -0000 1.2 @@ -23,12 +23,9 @@ /* $Id$ */ package org.lamsfoundation.lams.tool.taskList.dto; -import java.util.ArrayList; -import java.util.Date; import java.util.List; import org.lamsfoundation.lams.tool.taskList.model.TaskListItem; -import org.lamsfoundation.lams.tool.taskList.model.TaskListUser; /** * DTO object intented to be used in a task summary page (monitoring). Contains @@ -41,9 +38,9 @@ private TaskListItem taskListItem; - private TaskSummaryItem[] taskSummaryItems; + private List taskSummaryItems; - public TaskSummary(TaskListItem taskListItem, TaskSummaryItem[] taskSummaryItems) { + public TaskSummary(TaskListItem taskListItem, List taskSummaryItems) { this.taskListItem = taskListItem; this.taskSummaryItems = taskSummaryItems; @@ -60,10 +57,12 @@ this.taskListItem = taskListItem; } - public TaskSummaryItem[] getTaskSummaryItems() { + public List getTaskSummaryItems() { return taskSummaryItems; } - + public List setTaskSummaryItems(List taskSummaryItems) { + return this.taskSummaryItems = taskSummaryItems; + } } \ No newline at end of file Index: lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/dto/TaskSummaryItem.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/dto/Attic/TaskSummaryItem.java,v diff -u -r1.1 -r1.2 --- lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/dto/TaskSummaryItem.java 28 Mar 2008 02:21:27 -0000 1.1 +++ lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/dto/TaskSummaryItem.java 31 Mar 2008 06:09:45 -0000 1.2 @@ -80,9 +80,16 @@ public List getComments() { return comments; } + public void setComments(List comments) { + this.comments = comments; + } + public List getAttachments() { return attachments; } - + public void setAttachments(List attachments) { + this.attachments = attachments; + } + } \ No newline at end of file Index: lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/model/TaskList.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/model/TaskList.java,v diff -u -r1.3 -r1.4 --- lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/model/TaskList.java 14 Mar 2008 08:01:00 -0000 1.3 +++ lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/model/TaskList.java 31 Mar 2008 06:09:45 -0000 1.4 @@ -38,10 +38,15 @@ import org.lamsfoundation.lams.tool.taskList.util.TaskListToolContentHandler; /** - * TaskList + * The main entity class of TaskList tool. Contains all the data related to the whole tool. + * * @author Dapeng Ni + * @author Andrey Balan * * @hibernate.class table="tl_latask10_taskList" + */ +/** + * @author Administrator * */ public class TaskList implements Cloneable{ @@ -88,7 +93,6 @@ /** * Default contruction method. - * */ public TaskList(){ attachments = new HashSet(); @@ -98,6 +102,7 @@ // ********************************************************** // Function method for TaskList // ********************************************************** + public static TaskList newInstance(TaskList defaultContent, Long contentId, TaskListToolContentHandler taskListToolContentHandler) { TaskList toContent = new TaskList(); defaultContent.toolContentHandler = taskListToolContentHandler; @@ -114,6 +119,7 @@ } return toContent; } + public Object clone(){ TaskList taskList = null; @@ -155,6 +161,7 @@ return taskList; } + public boolean equals(Object o) { if (this == o) return true; @@ -195,6 +202,9 @@ this.setUpdated(new Date(now)); } + /** + * Method to support exporting. + */ public void toDTO(){ onlineFileList = new ArrayList(); offlineFileList = new ArrayList(); @@ -208,9 +218,11 @@ } } } + //********************************************************** - // get/set methods + // Get/set methods //********************************************************** + /** * Returns the object's creation date * @@ -250,7 +262,9 @@ } /** - * @return Returns the userid of the user who created the Share taskList. + * Returns id of a user created the taskList. + * + * @return id of a user * * @hibernate.many-to-one * cascade="save-update" @@ -262,25 +276,38 @@ } /** - * @param createdBy The userid of the user who created this Share taskList. + * Sets id of a user created the taskList. + * + * @param createdBy id of a user */ public void setCreatedBy(TaskListUser createdBy) { this.createdBy = createdBy; } - /** - * @hibernate.id column="uid" generator-class="native" - */ + /** + * Returns TaskList id. + * + * @return tasklist id + * + * @hibernate.id column="uid" generator-class="native" + */ public Long getUid() { return uid; } + /** + * Sets TaskList id. + * + * @param uid tasklist id + */ public void setUid(Long uid) { this.uid = uid; } /** - * @return Returns the title. + * Returns the tasklist title. + * + * @return tasklist title. * * @hibernate.property * column="title" @@ -291,34 +318,39 @@ } /** - * @param title The title to set. + * Sets the tasklist title + * + * @param title tasklist title */ public void setTitle(String title) { this.title = title; } /** - * @return Returns the runOffline. + * Returns either the tasklist should run offline. + * + * @return runOffline flag * * @hibernate.property * column="run_offline" - * */ public boolean getRunOffline() { return runOffline; } /** + * Sets if the tasklist should run offline. + * * @param runOffline The forceOffLine to set. - * - * */ public void setRunOffline(boolean forceOffline) { this.runOffline = forceOffline; } /** - * @return Returns the instructions set by the teacher. + * Returns tasklist instructions set by teacher. + * + * @return tasklist instructions set by teacher * * @hibernate.property * column="instructions" @@ -328,12 +360,19 @@ return instructions; } + /** + * Sets tasklist instructions. Usually done by teacher. + * + * @param instructions tasklist instructions + */ public void setInstructions(String instructions) { this.instructions = instructions; } /** - * @return Returns the onlineInstructions set by the teacher. + * Returns tasklist onlineInstructions set by teacher. + * + * @return tasklist onlineInstructions set by teacher * * @hibernate.property * column="online_instructions" @@ -343,12 +382,19 @@ return onlineInstructions; } + /** + * Sets tasklist instructions. Usually done by teacher. + * + * @param onlineInstructions tasklist onlineInstructions + */ public void setOnlineInstructions(String onlineInstructions) { this.onlineInstructions = onlineInstructions; } /** - * @return Returns the onlineInstructions set by the teacher. + * Returns tasklist offlineInstructions set by teacher. + * + * @return tasklist offlineInstructions set by teacher * * @hibernate.property * column="offline_instructions" @@ -358,133 +404,203 @@ return offlineInstructions; } + /** + * Sets tasklist offlineInstructions. Usually done by teacher. + * + * @param instructions tasklist offlineInstructions + */ public void setOfflineInstructions(String offlineInstructions) { this.offlineInstructions = offlineInstructions; } /** + * Returns a set of Attachments belong to this tasklist. * + * @return a set of Attachments belong to this tasklist. + * * @hibernate.set lazy="true" * cascade="all" * inverse="false" * order-by="create_date desc" * @hibernate.collection-key column="taskList_uid" * @hibernate.collection-one-to-many * class="org.lamsfoundation.lams.tool.taskList.model.TaskListAttachment" - * - * @return a set of Attachments to this Message. */ public Set getAttachments() { return attachments; } - /* - * @param attachments The attachments to set. + /** + * Sets a set of Attachments belong to this tasklist + * + * @param attachments The attachments to set */ public void setAttachments(Set attachments) { this.attachments = attachments; } /** + * Return set of TaskListItems * + * @return set of TaskListItems * * @hibernate.set lazy="true" * inverse="false" * cascade="all" * order-by="sequence_id asc" * @hibernate.collection-key column="taskList_uid" * @hibernate.collection-one-to-many class="org.lamsfoundation.lams.tool.taskList.model.TaskListItem" - * - * @return */ public Set getTaskListItems() { return taskListItems; } + + /** + * Sets set of TaskListItems. + * + * @param taskListItems set of TaskListItems + */ public void setTaskListItems(Set taskListItems) { this.taskListItems= taskListItems; } - /** + * Checks whether this tasklist is in use. + * + * @return + * * @hibernate.property column="content_in_use" - * @return */ public boolean isContentInUse() { return contentInUse; } + /** + * Sets whether this tasklist in use or not. + * + * @param contentInUse whether this tasklist in use or not + */ public void setContentInUse(boolean contentInUse) { this.contentInUse = contentInUse; } + /** + * Returns whether this tasklist should be defined later. + * + * @return whether this tasklist should be defined later + * * @hibernate.property column="define_later" - * @return */ public boolean isDefineLater() { return defineLater; } + /** + * Sets whether this tasklist should be defined later or not. + * + * @param defineLater boolean described whether this tasklist should be defined later or not + */ public void setDefineLater(boolean defineLater) { this.defineLater = defineLater; } + /** + * Returns ContentId + * + * @return ContentId + * * @hibernate.property column="content_id" unique="true" - * @return */ public Long getContentId() { return contentId; } + /** + * Sets ContentId. + * + * @param contentId ContentId + */ public void setContentId(Long contentId) { this.contentId = contentId; } /** - * @return Returns the lockWhenFinished. + * Returns if the tasklist should be locked after being finished or not. + * + * @return if the tasklist should be locked after being finished or not * * @hibernate.property * column="lock_when_finished" - * */ public boolean getLockWhenFinished() { return lockWhenFinished; } + /** - * @param lockWhenFinished Set to true to lock the taskList for finished users. + * Set if the tasklist should be locked after being finished or not. + * + * @param lockWhenFinished boolean describing should the tasklist be locked after being finished or not */ public void setLockWhenFinished(boolean lockWhenFinished) { this.lockWhenFinished = lockWhenFinished; } /** + * Returns if learners are allowed to contribute tasks. + * + * @return whether learners are allowed to contribute tasks + * * @hibernate.property column="allow_contribute_tasks" - * @return */ public boolean isAllowContributeTasks() { return allowContributeTasks; } + + /** + * Sets whether learners are allowed to contribute tasks. + * + * @param allowContributeTasks boolean describing whether learners are allowed to contribute tasks + */ public void setAllowContributeTasks(boolean allowContributeTasks) { this.allowContributeTasks = allowContributeTasks; } /** + * Returns whether the learners should be verified by monitor before they can finish tasklist. + * + * @return whether the learners should be verified by monitor before they can finish tasklist + * * @hibernate.property column="is_monitor_verification_required" - * @return */ public boolean isMonitorVerificationRequired() { return monitorVerificationRequired; } + + /** + * Sets whether the learners should be verified by monitor before they can finish tasklist. + * + * @param monitorVerificationRequired boolean describing whether the learners should be verified by monitor before they can finish tasklist + */ public void setMonitorVerificationRequired(boolean monitorVerificationRequired) { this.monitorVerificationRequired = monitorVerificationRequired; } /** + * Returns if the tasks should be done in a sequential order. + * + * @return if the tasks should be done in a sequential order + * * @hibernate.property column="is_sequential_order" - * @return */ public boolean isSequentialOrder() { return sequentialOrder; } + + /** + * Sets if the tasks should be done in a sequential order. + * + * @param sequentialOrder if the tasks should be done in a sequential order + */ public void setSequentialOrder(boolean sequentialOrder) { this.sequentialOrder = sequentialOrder; } Index: lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/model/TaskListItem.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/model/TaskListItem.java,v diff -u -r1.6 -r1.7 --- lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/model/TaskListItem.java 14 Mar 2008 08:01:00 -0000 1.6 +++ lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/model/TaskListItem.java 31 Mar 2008 06:09:45 -0000 1.7 @@ -23,20 +23,14 @@ /* $$Id$$ */ package org.lamsfoundation.lams.tool.taskList.model; -import java.util.ArrayList; import java.util.Date; -import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; -import java.util.List; import java.util.Set; -import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.builder.EqualsBuilder; import org.apache.commons.lang.builder.HashCodeBuilder; import org.apache.log4j.Logger; -import org.lamsfoundation.lams.contentrepository.client.IToolContentHandler; -import org.lamsfoundation.lams.tool.taskList.util.TaskListToolContentHandler; /** * TaskList @@ -71,7 +65,7 @@ private String parentTaskName; //Set of uploaded files - private Set uploadedFileList; + private Set attachments; //Set of user comments private Set comments; @@ -83,7 +77,7 @@ * */ public TaskListItem(){ - uploadedFileList = new HashSet(); + attachments = new HashSet(); comments = new HashSet(); } @@ -98,16 +92,16 @@ taskListItem.setUid(null); //clone set of taskListItemsAttachment - if(uploadedFileList != null){ - Iterator iter = uploadedFileList.iterator(); + if(attachments != null){ + Iterator iter = attachments.iterator(); Set set = new HashSet(); while(iter.hasNext()){ TaskListItemAttachment file = (TaskListItemAttachment)iter.next(); TaskListItemAttachment newFile = (TaskListItemAttachment) file.clone(); //just clone old file without duplicate it in repository set.add(newFile); } - taskListItem.uploadedFileList = set; + taskListItem.attachments = set; } //clone set of taskListItemsComment @@ -339,11 +333,11 @@ * * @return a set of Attachments to this TaskListItem. */ - public Set getUploadedFileList() { - return uploadedFileList; + public Set getAttachments() { + return attachments; } - public void setUploadedFileList(Set uploadedFileList) { - this.uploadedFileList = uploadedFileList; + public void setAttachments(Set attachments) { + this.attachments = attachments; } /** Index: lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/model/TaskListItemAttachment.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/model/TaskListItemAttachment.java,v diff -u -r1.3 -r1.4 --- lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/model/TaskListItemAttachment.java 14 Mar 2008 08:01:00 -0000 1.3 +++ lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/model/TaskListItemAttachment.java 31 Mar 2008 06:09:45 -0000 1.4 @@ -51,6 +51,9 @@ private Date created; private TaskListUser createBy; + //*************** NON Persist Field (only for exporting) ******************** + private String attachmentLocalUrl; + // ********************************************************** // Function method for TaskListItemAttachment // ********************************************************** @@ -144,7 +147,6 @@ this.fileName = name; } - /** * @hibernate.property column="file_uuid" * @return @@ -181,4 +183,11 @@ public void setCreateBy(TaskListUser createBy) { this.createBy = createBy; } + + public String getAttachmentLocalUrl() { + return attachmentLocalUrl; + } + public void setAttachmentLocalUrl(String attachmentLocalUrl) { + this.attachmentLocalUrl = attachmentLocalUrl; + } } Index: lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/model/TaskListItemComment.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/model/TaskListItemComment.java,v diff -u -r1.3 -r1.4 --- lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/model/TaskListItemComment.java 14 Mar 2008 08:01:00 -0000 1.3 +++ lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/model/TaskListItemComment.java 31 Mar 2008 06:09:45 -0000 1.4 @@ -36,7 +36,7 @@ * @hibernate.class table="tl_latask10_item_comment" * */ -public class TaskListItemComment { +public class TaskListItemComment implements Cloneable{ private static final Logger log = Logger.getLogger(TaskListItemComment.class); Fisheye: Tag 1.2 refers to a dead (removed) revision in file `lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/model/start.jsp'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/service/ITaskListService.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/service/ITaskListService.java,v diff -u -r1.6 -r1.7 --- lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/service/ITaskListService.java 28 Mar 2008 02:21:26 -0000 1.6 +++ lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/service/ITaskListService.java 31 Mar 2008 06:09:45 -0000 1.7 @@ -30,7 +30,6 @@ import org.apache.struts.upload.FormFile; import org.lamsfoundation.lams.notebook.model.NotebookEntry; -import org.lamsfoundation.lams.tool.taskList.dto.ExportDTO; import org.lamsfoundation.lams.tool.taskList.dto.ReflectDTO; import org.lamsfoundation.lams.tool.taskList.dto.Summary; import org.lamsfoundation.lams.tool.taskList.dto.TaskSummary; @@ -42,22 +41,25 @@ import org.lamsfoundation.lams.tool.taskList.model.TaskListUser; /** - * @author Dapeng.Ni + * Interface that defines the contract that all TaskLisk service providers must follow. * - * Interface that defines the contract that all ShareTaskLisk2 service provider must follow. + * @author Dapeng.Ni + * @author Andrey Balan */ public interface ITaskListService { - /** * Get TaskList by toolContentID. + * * @param contentId * @return */ TaskList getTaskListByContentId(Long contentId); + /** * Get a cloned copy of tool default tool content (TaskList) and assign the toolContentId of that copy as the * given contentId + * * @param contentId * @return * @throws TaskListApplicationException @@ -66,12 +68,15 @@ /** * Get list of taskList items by given taskListUid. These taskList items must be created by author. + * * @param taskListUid * @return */ List getAuthoredItems(Long taskListUid); + /** * Upload instruciton file into repository. + * * @param file * @param type * @return @@ -96,130 +101,170 @@ * Create a new user in database. */ void createUser(TaskListUser taskListUser); + /** * Get user by given userID and toolContentID. + * * @param long1 * @return */ TaskListUser getUserByIDAndContent(Long userID, Long contentId); /** * Get user by sessionID and UserID + * * @param long1 * @param sessionId * @return */ TaskListUser getUserByIDAndSession(Long long1, Long sessionId); + + /** + * Get user list by sessionId and itemUid + * + * @param sessionId + * @param uid + * @return + */ + List getUserListBySessionItem(Long sessionId, Long itemUid); + /** + * Get user by UID + * + * @param uid + * @return + */ + TaskListUser getUser(Long uid); //********** Repository methods *********************** /** - * Delete file from repository. + * Delete file from the repository. + * + * @param fileUuid + * @param fileVersionId + * @throws TaskListApplicationException */ void deleteFromRepository(Long fileUuid, Long fileVersionId) throws TaskListApplicationException ; /** * Save or update taskList into database. + * * @param TaskList */ void saveOrUpdateTaskList(TaskList TaskList); + /** * Delete reource attachment(i.e., offline/online instruction file) from database. This method does not * delete the file from repository. * * @param attachmentUid */ void deleteTaskListAttachment(Long attachmentUid); + /** * Delete resoruce item from database. + * * @param uid */ void deleteTaskListItem(Long uid); /** - * Return all reource items within the given toolSessionID. + * Return all resource items within the given toolSessionID. + * * @param sessionId * @return */ List getTaskListItemsBySessionId(Long sessionId); + /** * Get taskList which is relative with the special toolSession. + * * @param sessionId * @return */ TaskList getTaskListBySessionId(Long sessionId); + /** - * Get taskList toolSession by toolSessionId - * @param sessionId + * Get taskList with the specified itemUid. + * + * @param itemUid * @return */ - TaskListSession getTaskListSessionBySessionId(Long sessionId); - + TaskListItem getTaskListItemByUid(Long itemUid); + /** - * Save or update taskList session. - * @param resSession + * Save/update current TaskListItem. + * + * @param item current TaskListItem + * @return */ - void saveOrUpdateTaskListSession(TaskListSession resSession); + public void saveOrUpdateTaskListItem(TaskListItem item); + /** + * Fill in taskListItemList's complete flags. + * + * @param taskListItemList + * @param user + */ void retrieveComplete(SortedSet taskListItemList, TaskListUser user); - void setItemComplete(Long taskListItemUid, Long userId , Long sessionId); - void setItemAccess(Long taskListItemUid, Long userId, Long sessionId); -// /** -// * the reqired number minus the count of view of the given user. -// * @param userUid -// * @return -// */ -// int checkMiniView(Long toolSessionId, Long userId); + /** - * If success return next activity's url, otherwise return null. - * @param toolSessionId + * Mark taskListItem as completed. + * + * @param taskListItemUid * @param userId - * @return + * @param sessionId */ - String finishToolSession(Long toolSessionId, Long userId) throws TaskListApplicationException; - - TaskListItem getTaskListItemByUid(Long itemUid); - + void setItemComplete(Long taskListItemUid, Long userId , Long sessionId); + + /** - * Return monitoring summary for the specified TaskList. - * @param contentId specified TaskList uid - * @return + * Creates a new TaskListItemVisitLog describing access to specifeid taskListItem. + * + * @param taskListItemUid Uid of the specified taskListItem + * @param userId Id of a user who accessed this taskListItem + * @param sessionId id of a session during which it occured */ - Summary getSummary(Long contentId); + void setItemAccess(Long taskListItemUid, Long userId, Long sessionId); /** - * Return monitoring task summary for the specified TaskListItem. + * Get taskList toolSession by toolSessionId * - * @param contentId toolContenId - * @param taskListItemUid specified TaskListItem uid + * @param sessionId * @return */ - TaskSummary getTaskSummary(Long contentId, Long taskListItemUid); + TaskListSession getTaskListSessionBySessionId(Long sessionId); - List getUserListBySessionItem(Long sessionId, Long itemUid); - /** - * Get taskList item Summary list according to sessionId, and userLogin. - * - * @param sessionId - * @param userLogin login of the user which portfolio is being exported - * + * Save or update taskList session. + * + * @param resSession + */ + void saveOrUpdateTaskListSession(TaskListSession resSession); + + /** + * If success return next activity's url, otherwise return null. + * + * @param toolSessionId + * @param userId * @return */ - public List exportBySessionId(Long sessionId, String userLogin); - public List> exportByContentId(Long contentId); + String finishToolSession(Long toolSessionId, Long userId) throws TaskListApplicationException; /** * Create refection entry into notebook tool. + * * @param sessionId * @param notebook_tool * @param tool_signature * @param userId * @param entryText */ public Long createNotebookEntry(Long sessionId, Integer notebookToolType, String toolSignature, Integer userId, String entryText); + /** * Get reflection entry from notebook tool. + * * @param sessionId * @param idType * @param signature @@ -235,19 +280,49 @@ /** * Get Reflect DTO list grouped by sessionID. + * * @param contentId * @return */ Map> getReflectList(Long contentId); + + //********** Export methods *********************** + /** - * Get user by UID - * @param uid + * Make an export for the specified learner. + * + * @param sessionId + * @param learner user which portfolio is being exported + * * @return */ - TaskListUser getUser(Long uid); + public List exportForLearner(Long contentUid, TaskListUser learner); - public void saveOrUpdateTaskListItem(TaskListItem item); -// Summary getSummary(Long contentId, String null1); + /** + * Make an export for the whole TaskList. + * + * @param contentUid + * @return + */ + public List exportForTeacher(Long contentUid); + + /** + * Return summary for the specified TaskList. Used in monitoring. + * + * @param contentId specified TaskList uid + * @return + */ + Summary getSummary(Long contentId); + + /** + * Return task summary for the specified TaskListItem. Used in monitoring. + * + * @param contentId toolContenId + * @param taskListItemUid specified TaskListItem uid + * @return + */ + TaskSummary getTaskSummary(Long contentId, Long taskListItemUid); + } Index: lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/service/TaskListApplicationException.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/service/Attic/TaskListApplicationException.java,v diff -u -r1.1 -r1.2 --- lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/service/TaskListApplicationException.java 28 Feb 2008 03:50:18 -0000 1.1 +++ lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/service/TaskListApplicationException.java 31 Mar 2008 06:09:45 -0000 1.2 @@ -23,26 +23,25 @@ /* $$Id$$ */ package org.lamsfoundation.lams.tool.taskList.service; +/** + * @author Andrey Balan + */ public class TaskListApplicationException extends Exception{ public TaskListApplicationException() { super(); - } public TaskListApplicationException(String message, Throwable cause) { super(message, cause); - } public TaskListApplicationException(String message) { super(message); - } public TaskListApplicationException(Throwable cause) { super(cause); - } } Index: lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/service/TaskListServiceImpl.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/service/TaskListServiceImpl.java,v diff -u -r1.5 -r1.6 --- lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/service/TaskListServiceImpl.java 28 Mar 2008 02:21:26 -0000 1.5 +++ lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/service/TaskListServiceImpl.java 31 Mar 2008 06:09:45 -0000 1.6 @@ -45,7 +45,6 @@ import org.apache.commons.lang.StringUtils; import org.apache.log4j.Logger; import org.apache.struts.upload.FormFile; -import org.hibernate.collection.PersistentSet; import org.lamsfoundation.lams.contentrepository.AccessDeniedException; import org.lamsfoundation.lams.contentrepository.ICredentials; import org.lamsfoundation.lams.contentrepository.ITicket; @@ -82,7 +81,6 @@ import org.lamsfoundation.lams.tool.taskList.dao.TaskListItemVisitDAO; import org.lamsfoundation.lams.tool.taskList.dao.TaskListSessionDAO; import org.lamsfoundation.lams.tool.taskList.dao.TaskListUserDAO; -import org.lamsfoundation.lams.tool.taskList.dto.ExportDTO; import org.lamsfoundation.lams.tool.taskList.dto.ReflectDTO; import org.lamsfoundation.lams.tool.taskList.dto.Summary; import org.lamsfoundation.lams.tool.taskList.dto.TaskSummary; @@ -96,7 +94,6 @@ import org.lamsfoundation.lams.tool.taskList.model.TaskListSession; import org.lamsfoundation.lams.tool.taskList.model.TaskListUser; import org.lamsfoundation.lams.tool.taskList.util.TaskListToolContentHandler; -import org.lamsfoundation.lams.usermanagement.Role; import org.lamsfoundation.lams.usermanagement.User; import org.lamsfoundation.lams.usermanagement.dto.UserDTO; import org.lamsfoundation.lams.usermanagement.service.IUserManagementService; @@ -107,14 +104,12 @@ import org.lamsfoundation.lams.util.wddx.WDDXProcessorConversionException; /** + * Class implements org.lamsfoundation.lams.tool.taskList.service.ITaskListService. * - * @author Dapeng.Ni - * + * @author Dapeng.Ni + * @author Andrey Balan + * @see org.lamsfoundation.lams.tool.taskList.service.ITaskListService */ -/** - * @author Administrator - * - */ public class TaskListServiceImpl implements ITaskListService,ToolContentManager, ToolSessionManager, ToolContentImport102Manager { static Logger log = Logger.getLogger(TaskListServiceImpl.class.getName()); private TaskListDAO taskListDao; @@ -137,91 +132,13 @@ private IExportToolContentService exportContentService; private ICoreNotebookService coreNotebookService; - - private class ReflectDTOComparator implements Comparator{ - public int compare(ReflectDTO o1, ReflectDTO o2) { - - if(o1 != null && o2 != null){ - return o1.getFullName().compareTo(o2.getFullName()); - }else if(o1 != null) - return 1; - else - return -1; - } - } - //******************************************************************************* - // Service method + // Methods implements ITaskListService. //******************************************************************************* - /** Try to get the file. If forceLogin = false and an access denied exception occurs, call this method - * again to get a new ticket and retry file lookup. If forceLogin = true and it then fails - * then throw exception. - * @param uuid - * @param versionId - * @param relativePath - * @param attemptCount - * @return file node - * @throws ImscpApplicationException - */ - private IVersionedNode getFile(Long uuid, Long versionId, String relativePath) throws TaskListApplicationException { - - ITicket tic = getRepositoryLoginTicket(); - - try { - - return repositoryService.getFileItem(tic, uuid, versionId, relativePath); - - } catch (AccessDeniedException e) { - - String error = "Unable to access repository to get file uuid "+uuid - +" version id "+versionId - +" path " + relativePath+"."; - - error = error+"AccessDeniedException: "+e.getMessage()+" Unable to retry further."; - log.error(error); - throw new TaskListApplicationException(error,e); - - } catch (Exception e) { - - String error = "Unable to access repository to get file uuid "+uuid - +" version id "+versionId - +" path " + relativePath+"." - +" Exception: "+e.getMessage(); - log.error(error); - throw new TaskListApplicationException(error,e); - - } - } + /** - * This method verifies the credentials of the TaskList Tool and gives it - * the Ticket to login and access the Content Repository. - * - * A valid ticket is needed in order to access the content from the - * repository. This method would be called evertime the tool needs to - * upload/download files from the content repository. - * - * @return ITicket The ticket for repostory access - * @throws TaskListApplicationException + * {@inheritDoc} */ - private ITicket getRepositoryLoginTicket() throws TaskListApplicationException { - ICredentials credentials = new SimpleCredentials( - taskListToolContentHandler.getRepositoryUser(), - taskListToolContentHandler.getRepositoryId()); - try { - ITicket ticket = repositoryService.login(credentials, - taskListToolContentHandler.getRepositoryWorkspaceName()); - return ticket; - } catch (AccessDeniedException ae) { - throw new TaskListApplicationException("Access Denied to repository." - + ae.getMessage()); - } catch (WorkspaceNotFoundException we) { - throw new TaskListApplicationException("Workspace not found." - + we.getMessage()); - } catch (LoginException e) { - throw new TaskListApplicationException("Login failed." + e.getMessage()); - } - } - public TaskList getTaskListByContentId(Long contentId) { TaskList rs = taskListDao.getByContentId(contentId); if(rs == null){ @@ -230,6 +147,9 @@ return rs; } + /** + * {@inheritDoc} + */ public TaskList getDefaultContent(Long contentId) throws TaskListApplicationException { if (contentId == null) { @@ -245,11 +165,16 @@ return content; } + /** + * {@inheritDoc} + */ public List getAuthoredItems(Long taskListUid) { return taskListItemDao.getAuthoringItems(taskListUid); } - + /** + * {@inheritDoc} + */ public TaskListAttachment uploadInstructionFile(FormFile uploadFile, String fileType) throws UploadTaskListFileException { if(uploadFile == null || StringUtils.isEmpty(uploadFile.getFileName())) throw new UploadTaskListFileException(messageService.getMessage("error.msg.upload.file.not.found",new Object[]{uploadFile})); @@ -267,6 +192,9 @@ return file; } + /** + * {@inheritDoc} + */ public TaskListItemAttachment uploadTaskListItemFile(FormFile uploadFile, String fileType, TaskListUser user) throws UploadTaskListFileException { if(uploadFile == null || StringUtils.isEmpty(uploadFile.getFileName())) throw new UploadTaskListFileException(messageService.getMessage("error.msg.upload.file.not.found",new Object[]{uploadFile})); @@ -286,22 +214,37 @@ return file; } + /** + * {@inheritDoc} + */ public void createUser(TaskListUser taskListUser) { taskListUserDao.saveObject(taskListUser); } + /** + * {@inheritDoc} + */ public TaskListUser getUserByIDAndContent(Long userId, Long contentId) { - return (TaskListUser) taskListUserDao.getUserByUserIDAndContentID(userId,contentId); - } + + /** + * {@inheritDoc} + */ public TaskListUser getUserByIDAndSession(Long userId, Long sessionId) { - return (TaskListUser) taskListUserDao.getUserByUserIDAndSessionID(userId,sessionId); - } + + /** + * {@inheritDoc} + */ + public TaskListUser getUser(Long uid){ + return (TaskListUser) taskListUserDao.getObject(TaskListUser.class, uid); + } - + /** + * {@inheritDoc} + */ public void deleteFromRepository(Long fileUuid, Long fileVersionId) throws TaskListApplicationException { ITicket ticket = getRepositoryLoginTicket(); try { @@ -313,30 +256,44 @@ } } - + /** + * {@inheritDoc} + */ public void saveOrUpdateTaskList(TaskList taskList) { taskListDao.saveObject(taskList); } - + /** + * {@inheritDoc} + */ public void deleteTaskListAttachment(Long attachmentUid) { taskListAttachmentDao.removeObject(TaskListAttachment.class, attachmentUid); } + /** + * {@inheritDoc} + */ public void deleteTaskListItemAttachment(Long attachmentUid) { taskListItemAttachmentDao.removeObject(TaskListItemAttachment.class, attachmentUid); } - + /** + * {@inheritDoc} + */ public void saveOrUpdateTaskListItem(TaskListItem item) { taskListItemDao.saveObject(item); } - + /** + * {@inheritDoc} + */ public void deleteTaskListItem(Long uid) { taskListItemDao.removeObject(TaskListItem.class,uid); } + /** + * {@inheritDoc} + */ public List getTaskListItemsBySessionId(Long sessionId) { TaskListSession session = taskListSessionDao.getSessionBySessionId(sessionId); if(session == null){ @@ -353,90 +310,66 @@ return items; } - public List exportBySessionId(Long sessionId, String userLogin) { - TaskListSession session = taskListSessionDao.getSessionBySessionId(sessionId); - if(session == null){ - log.error("Failed get TaskListSession by ID [" +sessionId + "]"); - return null; - } - //initial taskList items list - List itemList = new ArrayList(); - Set resList = session.getTaskList().getTaskListItems(); - for(TaskListItem item:resList){ - //if item is create by author - if(item.isCreateByAuthor()){ - ExportDTO exportDTO = new ExportDTO(session.getSessionName(), item, false, userLogin); - itemList.add(exportDTO); - } - } - //get this session's all taskList items - Set sessList =session.getTaskListItems(); - for(TaskListItem item:sessList){ - //to skip all item create by author - if(!item.isCreateByAuthor()){ - ExportDTO exportDTO = new ExportDTO(session.getSessionName(), item, false, userLogin); - itemList.add(exportDTO); - } - } - - return itemList; - } - - public List> exportByContentId(Long contentId) { - TaskList taskList = taskListDao.getByContentId(contentId); - List> groupList = new ArrayList(); - - //create init taskList items list - List initList = new ArrayList(); - groupList.add(initList); - Set resList = taskList.getTaskListItems(); - for(TaskListItem item:resList){ - if(item.isCreateByAuthor()){ - ExportDTO exportDTO = new ExportDTO(null,item,true); - initList.add(exportDTO); - } - } - - //session by session - List sessionList = taskListSessionDao.getByContentId(contentId); - for(TaskListSession session:sessionList){ - List group = new ArrayList(); - //get this session's all taskList items - Set sessList =session.getTaskListItems(); - for(TaskListItem item:sessList){ - //to skip all item create by author - if(!item.isCreateByAuthor()){ - ExportDTO exportDTO = new ExportDTO(session.getSessionName(),item,false); - group.add(exportDTO); - } - } - if(group.size() == 0){ - group.add(new ExportDTO(session.getSessionName(),null,false)); - } - groupList.add(group); - } - - return groupList; - } + /** + * {@inheritDoc} + */ public TaskList getTaskListBySessionId(Long sessionId){ TaskListSession session = taskListSessionDao.getSessionBySessionId(sessionId); //to skip CGLib problem Long contentId = session.getTaskList().getContentId(); TaskList res = taskListDao.getByContentId(contentId); return res; } + + /** + * {@inheritDoc} + */ + public TaskListItem getTaskListItemByUid(Long itemUid) { + return taskListItemDao.getByUid(itemUid); + } + + /** + * {@inheritDoc} + */ public TaskListSession getTaskListSessionBySessionId(Long sessionId) { return taskListSessionDao.getSessionBySessionId(sessionId); } - + /** + * {@inheritDoc} + */ public void saveOrUpdateTaskListSession(TaskListSession resSession) { taskListSessionDao.saveObject(resSession); } + + /** + * {@inheritDoc} + */ + public String finishToolSession(Long toolSessionId, Long userId) throws TaskListApplicationException { + TaskListUser user = taskListUserDao.getUserByUserIDAndSessionID(userId, toolSessionId); + user.setSessionFinished(true); + taskListUserDao.saveObject(user); + +// TaskListSession session = taskListSessionDao.getSessionBySessionId(toolSessionId); +// session.setStatus(TaskListConstants.COMPLETED); +// taskListSessionDao.saveObject(session); + + String nextUrl = null; + try { + nextUrl = this.leaveToolSession(toolSessionId,userId); + } catch (DataMissingException e) { + throw new TaskListApplicationException(e); + } catch (ToolException e) { + throw new TaskListApplicationException(e); + } + return nextUrl; + } - + /** + * {@inheritDoc} + */ public void retrieveComplete(SortedSet taskListItemList, TaskListUser user) { for(TaskListItem item:taskListItemList){ TaskListItemVisitLog log = taskListItemVisitDao.getTaskListItemLog(item.getUid(),user.getUserId()); @@ -447,7 +380,9 @@ } } - + /** + * {@inheritDoc} + */ public void setItemComplete(Long taskListItemUid, Long userId, Long sessionId) { TaskListItemVisitLog log = taskListItemVisitDao.getTaskListItemLog(taskListItemUid,userId); if(log == null){ @@ -463,7 +398,9 @@ taskListItemVisitDao.saveObject(log); } - + /** + * {@inheritDoc} + */ public void setItemAccess(Long taskListItemUid, Long userId, Long sessionId){ TaskListItemVisitLog log = taskListItemVisitDao.getTaskListItemLog(taskListItemUid,userId); if(log == null){ @@ -480,29 +417,9 @@ } - public String finishToolSession(Long toolSessionId, Long userId) throws TaskListApplicationException { - TaskListUser user = taskListUserDao.getUserByUserIDAndSessionID(userId, toolSessionId); - user.setSessionFinished(true); - taskListUserDao.saveObject(user); - -// TaskListSession session = taskListSessionDao.getSessionBySessionId(toolSessionId); -// session.setStatus(TaskListConstants.COMPLETED); -// taskListSessionDao.saveObject(session); - - String nextUrl = null; - try { - nextUrl = this.leaveToolSession(toolSessionId,userId); - } catch (DataMissingException e) { - throw new TaskListApplicationException(e); - } catch (ToolException e) { - throw new TaskListApplicationException(e); - } - return nextUrl; - } - public TaskListItem getTaskListItemByUid(Long itemUid) { - return taskListItemDao.getByUid(itemUid); - } + + /** * {@inheritDoc} @@ -575,61 +492,124 @@ } } - TaskSummaryItem[] taskSummaryItems = new TaskSummaryItem[userList.size()]; + List taskSummaryItems = new ArrayList(); for (int i = 0; i < userList.size(); i++) { TaskListUser user = userList.get(i); - taskSummaryItems[i] = new TaskSummaryItem(); - taskSummaryItems[i].setUser(user); + TaskSummaryItem taskSummaryItem = new TaskSummaryItem(); + taskSummaryItems.add(taskSummaryItem); + taskSummaryItem.setUser(user); TaskListItemVisitLog visitLog = taskListItemVisitDao.getTaskListItemLog(taskListItem.getUid(), user.getUserId()); //If TaskListItemVisitLog exists then fill up taskSummaryItem otherwise put false in a completed field if (visitLog !=null) { - taskSummaryItems[i].setCompleted(visitLog.isComplete()); - if (visitLog.isComplete()) taskSummaryItems[i].setDate(visitLog.getAccessDate()); + taskSummaryItem.setCompleted(visitLog.isComplete()); + if (visitLog.isComplete()) taskSummaryItem.setDate(visitLog.getAccessDate()); //fill up with comments and attachments made by this user Set itemComments = taskListItem.getComments(); for(TaskListItemComment comment : itemComments) { - if (user.equals(comment.getCreateBy())) taskSummaryItems[i].getComments().add(comment); + if (user.equals(comment.getCreateBy())) taskSummaryItem.getComments().add(comment); } - Set itemAttachments = taskListItem.getUploadedFileList(); + Set itemAttachments = taskListItem.getAttachments(); for(TaskListItemAttachment attachment : itemAttachments) { - if (user.equals(attachment.getCreateBy())) taskSummaryItems[i].getAttachments().add(attachment); + if (user.equals(attachment.getCreateBy())) taskSummaryItem.getAttachments().add(attachment); } } else { - taskSummaryItems[i].setCompleted(false); + taskSummaryItem.setCompleted(false); } } TaskSummary taskSummary = new TaskSummary(taskListItem, taskSummaryItems); return taskSummary; } - - /** + + /** * {@inheritDoc} */ - public Map> getReflectList(Long contentId){ - Map> map = new HashMap>(); - + public List exportForTeacher(Long contentId) { + TaskList taskList = taskListDao.getByContentId(contentId); + ArrayList itemList = new ArrayList(); + itemList.addAll(taskList.getTaskListItems()); + + //retrieve all the sessions associated with this taskList List sessionList = taskListSessionDao.getByContentId(contentId); - for(TaskListSession session:sessionList){ - Long sessionId = session.getSessionId(); - boolean hasRefection = session.getTaskList().isReflectOnActivity(); - Set list = new TreeSet(this.new ReflectDTOComparator()); - //get all users in this session - List users = taskListUserDao.getBySessionID(sessionId); - for(TaskListUser user : users){ - ReflectDTO ref = new ReflectDTO(user); - ref.setHasRefection(hasRefection); - list.add(ref); + //create the list containing all taskListItems + for(TaskListSession session:sessionList) { + Set newItems = session.getTaskListItems(); + for(TaskListItem item : newItems) { + if (!itemList.contains(item)) itemList.add(item); } - map.put(sessionId, list); } - return map; + List taskSummaries = new ArrayList(); + for(TaskListItem item:itemList) { + taskSummaries.add(getTaskSummary(contentId, item.getUid())); + } + + return taskSummaries; } + + /** + * {@inheritDoc} + */ + public List exportForLearner(Long sessionId, TaskListUser learner) { + Long contentId = getTaskListBySessionId(sessionId).getContentId(); + + TaskList taskList = taskListDao.getByContentId(contentId); + ArrayList itemList = new ArrayList(); + itemList.addAll(taskList.getTaskListItems()); + + //retrieve all the sessions associated with this taskList + List sessionList = taskListSessionDao.getByContentId(contentId); + //create the list containing all taskListItems + for(TaskListSession session:sessionList) { + Set newItems = session.getTaskListItems(); + for(TaskListItem item : newItems) { + if (!itemList.contains(item)) itemList.add(item); + } + } + + List taskSummaries = new ArrayList(); + for(TaskListItem item:itemList) { + taskSummaries.add(getTaskSummary(contentId, item.getUid())); + } + + //get rid of information that is not allowed to be shown to the current user + for(TaskSummary taskSummary:taskSummaries) { + + //get rid of taskSummaryItems belong to another users + List newTaskSummaryItems = new ArrayList(); + for(TaskSummaryItem taskSummaryItem:taskSummary.getTaskSummaryItems()) { + if (learner.equals(taskSummaryItem.getUser())) newTaskSummaryItems.add(taskSummaryItem); + } + taskSummary.setTaskSummaryItems(newTaskSummaryItems); + + //get rid of TaskListItemComments and TaskListItemAttachments belong to another users + if (taskSummary.getTaskListItem().isCommentsAllowed() && !taskSummary.getTaskListItem().getShowCommentsToAll()) { + TaskSummaryItem taskSummaryItem = taskSummary.getTaskSummaryItems().get(0); + + List newComments = new ArrayList(); + for(TaskListItemComment comment:taskSummaryItem.getComments()) { + if (learner.equals(comment.getCreateBy())) newComments.add(comment); + } + taskSummaryItem.setComments(newComments); + + List newAttachments = new ArrayList(); + for(TaskListItemAttachment attachment:taskSummaryItem.getAttachments()) { + if (learner.equals(attachment.getCreateBy())) newAttachments.add(attachment); + } + taskSummaryItem.setAttachments(newAttachments); + } + } + + return taskSummaries; + } + + /** + * {@inheritDoc} + */ public List getUserListBySessionItem(Long sessionId, Long itemUid) { List logList = taskListItemVisitDao.getTaskListItemLogBySession(sessionId,itemUid); List userList = new ArrayList(logList.size()); @@ -641,9 +621,16 @@ return userList; } + /** + * {@inheritDoc} + */ public Long createNotebookEntry(Long sessionId, Integer notebookToolType, String toolSignature, Integer userId, String entryText) { return coreNotebookService.createNotebookEntry(sessionId, notebookToolType, toolSignature, userId, "", entryText); } + + /** + * {@inheritDoc} + */ public NotebookEntry getEntry(Long sessionId, Integer idType, String signature, Integer userID){ List list = coreNotebookService.getEntry(sessionId, idType, signature, userID); if (list == null || list.isEmpty()) { @@ -653,116 +640,41 @@ } } - /** - * @param notebookEntry + /** + * {@inheritDoc} */ public void updateEntry(NotebookEntry notebookEntry) { coreNotebookService.updateEntry(notebookEntry); } - public TaskListUser getUser(Long uid){ - return (TaskListUser) taskListUserDao.getObject(TaskListUser.class, uid); - } - //***************************************************************************** - // private methods - //***************************************************************************** - private TaskList getDefaultTaskList() throws TaskListApplicationException { - Long defaultTaskListId = getToolDefaultContentIdBySignature(TaskListConstants.TOOL_SIGNATURE); - TaskList defaultTaskList = getTaskListByContentId(defaultTaskListId); - if(defaultTaskList == null) - { - String error=messageService.getMessage("error.msg.default.content.not.find"); - log.error(error); - throw new TaskListApplicationException(error); - } - - return defaultTaskList; - } - private Long getToolDefaultContentIdBySignature(String toolSignature) throws TaskListApplicationException - { - Long contentId = null; - contentId=new Long(toolService.getToolDefaultContentIdBySignature(toolSignature)); - if (contentId == null) - { - String error=messageService.getMessage("error.msg.default.content.not.find"); - log.error(error); - throw new TaskListApplicationException(error); - } - return contentId; - } - /** - * Process an uploaded file. - * - * @throws TaskListApplicationException - * @throws FileNotFoundException - * @throws IOException - * @throws RepositoryCheckedException - * @throws InvalidParameterException - */ - private NodeKey processFile(FormFile file, String fileType) throws UploadTaskListFileException { - NodeKey node = null; - if (file!= null && !StringUtils.isEmpty(file.getFileName())) { - String fileName = file.getFileName(); - try { - node = taskListToolContentHandler.uploadFile(file.getInputStream(), fileName, - file.getContentType(), fileType); - } catch (InvalidParameterException e) { - throw new UploadTaskListFileException (messageService.getMessage("error.msg.invaid.param.upload")); - } catch (FileNotFoundException e) { - throw new UploadTaskListFileException (messageService.getMessage("error.msg.file.not.found")); - } catch (RepositoryCheckedException e) { - throw new UploadTaskListFileException (messageService.getMessage("error.msg.repository")); - } catch (IOException e) { - throw new UploadTaskListFileException (messageService.getMessage("error.msg.io.exception")); + /** + * {@inheritDoc} + */ + public Map> getReflectList(Long contentId){ + Map> map = new HashMap>(); + + List sessionList = taskListSessionDao.getByContentId(contentId); + for(TaskListSession session:sessionList){ + Long sessionId = session.getSessionId(); + boolean hasRefection = session.getTaskList().isReflectOnActivity(); + Set list = new TreeSet(this.new ReflectDTOComparator()); + //get all users in this session + List users = taskListUserDao.getBySessionID(sessionId); + for(TaskListUser user : users){ + ReflectDTO ref = new ReflectDTO(user); + ref.setHasRefection(hasRefection); + list.add(ref); } - } - return node; - } - private NodeKey processPackage(String packageDirectory, String initFile) throws UploadTaskListFileException { - NodeKey node = null; - try { - node = taskListToolContentHandler.uploadPackage(packageDirectory, initFile); - } catch (InvalidParameterException e) { - throw new UploadTaskListFileException (messageService.getMessage("error.msg.invaid.param.upload")); - } catch (RepositoryCheckedException e) { - throw new UploadTaskListFileException (messageService.getMessage("error.msg.repository")); + map.put(sessionId, list); } - return node; - } - - /** - * Find out default.htm/html or index.htm/html in the given directory folder - * @param packageDirectory - * @return - */ - private String findWebsiteInitialItem(String packageDirectory) { - File file = new File(packageDirectory); - if(!file.isDirectory()) - return null; - File[] initFiles = file.listFiles(new FileFilter(){ - public boolean accept(File pathname) { - if(pathname == null || pathname.getName() == null) - return false; - String name = pathname.getName(); - if(name.endsWith("default.html") - ||name.endsWith("default.htm") - ||name.endsWith("index.html") - ||name.endsWith("index.htm")) - return true; - return false; - } - }); - if(initFiles != null && initFiles.length > 0) - return initFiles[0].getName(); - else - return null; + return map; } - - + //***************************************************************************** - // set methods for Spring Bean + // Set methods for Spring Bean //***************************************************************************** + public void setAuditService(IAuditService auditService) { this.auditService = auditService; } @@ -803,9 +715,35 @@ public void setTaskListItemVisitDao(TaskListItemVisitDAO taskListItemVisitDao) { this.taskListItemVisitDao = taskListItemVisitDao; } + + /* =================================================================================== */ + public IExportToolContentService getExportContentService() { + return exportContentService; + } + + public void setExportContentService(IExportToolContentService exportContentService) { + this.exportContentService = exportContentService; + } + + public IUserManagementService getUserManagementService() { + return userManagementService; + } + + public void setUserManagementService(IUserManagementService userManagementService) { + this.userManagementService = userManagementService; + } + + public ICoreNotebookService getCoreNotebookService() { + return coreNotebookService; + } + + public void setCoreNotebookService(ICoreNotebookService coreNotebookService) { + this.coreNotebookService = coreNotebookService; + } + //******************************************************************************* - //ToolContentManager, ToolSessionManager methods + // Methods implementing ToolContentManager, ToolSessionManager //******************************************************************************* public void exportToolContent(Long toolContentId, String rootPath) throws DataMissingException, ToolException { @@ -825,23 +763,27 @@ toolContentObj.setToolContentHandler(null); toolContentObj.setOfflineFileList(null); toolContentObj.setOnlineFileList(null); + Set taskListItems = toolContentObj.getTaskListItems(); + for (TaskListItem taskListItem : taskListItems) { + taskListItem.setComments(null); + taskListItem.setAttachments(null); + } + try { exportContentService.registerFileClassForExport(TaskListAttachment.class.getName(),"fileUuid","fileVersionId"); - exportContentService.registerFileClassForExport(TaskListItem.class.getName(),"fileUuid","fileVersionId"); exportContentService.exportToolContent( toolContentId, toolContentObj,taskListToolContentHandler, rootPath); } catch (ExportToolContentException e) { throw new ToolException(e); } } - + /** + * {@inheritDoc} + */ public void importToolContent(Long toolContentId, Integer newUserUid, String toolContentPath ,String fromVersion,String toVersion) throws ToolException { try { - exportContentService.registerFileClassForImport(TaskListAttachment.class.getName() - ,"fileUuid","fileVersionId","fileName","fileType",null,null); - exportContentService.registerFileClassForImport(TaskListItem.class.getName() - ,"fileUuid","fileVersionId","fileName","fileType",null,"initialItem"); + exportContentService.registerFileClassForImport(TaskListAttachment.class.getName(),"fileUuid","fileVersionId","fileName","fileType",null,null); Object toolPOJO = exportContentService.importToolContent(toolContentPath,taskListToolContentHandler,fromVersion,toVersion); if(!(toolPOJO instanceof TaskList)) @@ -882,7 +824,9 @@ return new TreeMap(); } - + /** + * {@inheritDoc} + */ public void copyToolContent(Long fromContentId, Long toContentId) throws ToolException { if (toContentId == null) throw new ToolException( @@ -914,7 +858,9 @@ } } - + /** + * {@inheritDoc} + */ public void setAsDefineLater(Long toolContentId, boolean value) throws DataMissingException, ToolException { TaskList taskList = taskListDao.getByContentId(toolContentId); if(taskList == null){ @@ -923,7 +869,9 @@ taskList.setDefineLater(value); } - + /** + * {@inheritDoc} + */ public void setAsRunOffline(Long toolContentId, boolean value) throws DataMissingException, ToolException { TaskList taskList = taskListDao.getByContentId(toolContentId); if(taskList == null){ @@ -932,7 +880,9 @@ taskList.setRunOffline(value); } - + /** + * {@inheritDoc} + */ public void removeToolContent(Long toolContentId, boolean removeSessionData) throws SessionDataExistsException, ToolException { TaskList taskList = taskListDao.getByContentId(toolContentId); if(removeSessionData){ @@ -946,7 +896,9 @@ taskListDao.delete(taskList); } - + /** + * {@inheritDoc} + */ public void createToolSession(Long toolSessionId, String toolSessionName, Long toolContentId) throws ToolException { TaskListSession session = new TaskListSession(); session.setSessionId(toolSessionId); @@ -956,7 +908,9 @@ taskListSessionDao.saveObject(session); } - + /** + * {@inheritDoc} + */ public String leaveToolSession(Long toolSessionId, Long learnerId) throws DataMissingException, ToolException { if(toolSessionId == null){ log.error("Fail to leave tool Session based on null tool session id."); @@ -980,17 +934,23 @@ return learnerService.completeToolSession(toolSessionId,learnerId); } - + /** + * {@inheritDoc} + */ public ToolSessionExportOutputData exportToolSession(Long toolSessionId) throws DataMissingException, ToolException { return null; } - + /** + * {@inheritDoc} + */ public ToolSessionExportOutputData exportToolSession(List toolSessionIds) throws DataMissingException, ToolException { return null; } - + /** + * {@inheritDoc} + */ public void removeToolSession(Long toolSessionId) throws DataMissingException, ToolException { taskListSessionDao.deleteBySessionId(toolSessionId); } @@ -999,8 +959,7 @@ * 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) */ - public SortedMap getToolOutput(List names, - Long toolSessionId, Long learnerId) { + public SortedMap getToolOutput(List names, Long toolSessionId, Long learnerId) { return new TreeMap(); } @@ -1013,119 +972,18 @@ return null; } - /* ===============Methods implemented from ToolContentImport102Manager =============== */ + //******************************************************************************* + // Methods implementing ToolContentImport102Manager + //******************************************************************************* - /** - * Import the data for a 1.0.2 Noticeboard or HTMLNoticeboard - */ - public void import102ToolContent(Long toolContentId, UserDTO user, Hashtable importValues) - { - Date now = new Date(); - TaskList toolContentObj = new TaskList(); - - try { - toolContentObj.setTitle((String)importValues.get(ToolContentImport102Manager.CONTENT_TITLE)); - toolContentObj.setContentId(toolContentId); - toolContentObj.setContentInUse(Boolean.FALSE); - toolContentObj.setCreated(now); - toolContentObj.setDefineLater(Boolean.FALSE); - toolContentObj.setInstructions(WebUtil.convertNewlines((String)importValues.get(ToolContentImport102Manager.CONTENT_BODY))); - toolContentObj.setOfflineInstructions(null); - toolContentObj.setOnlineInstructions(null); - toolContentObj.setRunOffline(Boolean.FALSE); - toolContentObj.setUpdated(now); - toolContentObj.setReflectOnActivity(Boolean.FALSE); - toolContentObj.setReflectInstructions(null); - - //TODO ????????????????????????????????????? -// toolContentObj.setRunAuto(Boolean.FALSE); -// Boolean bool = WDDXProcessor.convertToBoolean(importValues, ToolContentImport102Manager.CONTENT_URL_RUNTIME_LEARNER_SUBMIT_FILE); -// toolContentObj.setAllowAddFiles(bool != null ? bool : Boolean.TRUE); -// bool = WDDXProcessor.convertToBoolean(importValues, ToolContentImport102Manager.CONTENT_URL_RUNTIME_LEARNER_SUBMIT_URL); -// toolContentObj.setAllowAddUrls(bool != null ? bool : Boolean.TRUE); -// Integer minToComplete = WDDXProcessor.convertToInteger(importValues, ToolContentImport102Manager.CONTENT_URL_MIN_NUMBER_COMPLETE); -// toolContentObj.setMiniViewTaskListNumber(minToComplete != null ? minToComplete.intValue() : 0); -// bool = WDDXProcessor.convertToBoolean(importValues, ToolContentImport102Manager.CONTENT_URL_RUNTIME_LEARNER_SUBMIT_URL); -// toolContentObj.setLockWhenFinished(Boolean.FALSE); -// toolContentObj.setRunAuto(Boolean.FALSE); - - // leave as empty, no need to set them to anything. - //toolContentObj.setAttachments(attachments); - -/* unused entries from 1.0.2 - [directoryName=] no equivalent in 2.0 - [runtimeSubmissionStaffFile=true] no equivalent in 2.0 - [contentShowUser=false] no equivalent in 2.0 - [isHTML=false] no equivalent in 2.0 - [showbuttons=false] no equivalent in 2.0 - [isReusable=false] not used in 1.0.2 (would be lock when finished) -*/ - TaskListUser ruser = new TaskListUser(); - ruser.setUserId(new Long(user.getUserID().longValue())); - ruser.setFirstName(user.getFirstName()); - ruser.setLastName(user.getLastName()); - ruser.setLoginName(user.getLogin()); - createUser(ruser); - toolContentObj.setCreatedBy(ruser); - - // TaskList Items. They are ordered on the screen by create date so they need to be saved in the right order. - // So read them all in first, then go through and assign the dates in the correct order and then save. - Vector tasks = (Vector) importValues.get(ToolContentImport102Manager.CONTENT_URL_URLS); - SortedMap items = new TreeMap(); - if ( tasks != null ) { - int dummySequenceNumber = tasks.size(); // dummy number in case we can't convert question order - Iterator iter = tasks.iterator(); - while ( iter.hasNext() ) { - Hashtable urlMap = (Hashtable) iter.next(); - Integer itemOrder = WDDXProcessor.convertToInteger(urlMap, ToolContentImport102Manager.CONTENT_URL_URL_VIEW_ORDER); - TaskListItem item = new TaskListItem(); - item.setSequenceId(itemOrder!=null?itemOrder.intValue():dummySequenceNumber++); - item.setTitle((String) urlMap.get(ToolContentImport102Manager.CONTENT_TITLE)); - item.setCreateBy(ruser); - item.setCreateByAuthor(true); - -// String taskListType = (String) urlMap.get(ToolContentImport102Manager.CONTENT_URL_URL_TYPE); -// if ( ToolContentImport102Manager.URL_RESOURCE_TYPE_URL.equals(taskListType) ) { -// item.setType(TaskListConstants.RESOURCE_TYPE_URL); -// item.setUrl((String) urlMap.get(ToolContentImport102Manager.CONTENT_URL_URL_URL)); -// item.setOpenUrlNewWindow(false); -// } else { -// throw new ToolException("Invalid shared taskList type. Type was "+taskListType); -// } - - items.put(itemOrder, item); - } - } - - Iterator iter = items.values().iterator(); - Date itemDate = null; - while ( iter.hasNext() ) { - if ( itemDate != null ) { - try { - Thread.sleep(1000); - } catch (Exception e) {} - } - itemDate = new Date(); - - TaskListItem item = (TaskListItem) iter.next(); - item.setCreateDate(itemDate); - toolContentObj.getTaskListItems().add(item); - } - - } catch (WDDXProcessorConversionException e) { - log.error("Unable to content for activity "+toolContentObj.getTitle()+"properly due to a WDDXProcessorConversionException.",e); - throw new ToolException("Invalid import data format for activity "+toolContentObj.getTitle()+"- WDDX caused an exception. Some data from the design will have been lost. See log for more details."); - } - - taskListDao.saveObject(toolContentObj); - - - } + * Import the data for a 1.0.2 Noticeboard or HTMLNoticeboard. Was left only + * for the reasons of implementing ToolContentImport102Manager interface. + */ + public void import102ToolContent(Long toolContentId, UserDTO user, Hashtable importValues) { } /** Set the description, throws away the title value as this is not supported in 2.0 */ - public void setReflectiveData(Long toolContentId, String title, String description) - throws ToolException, DataMissingException { + public void setReflectiveData(Long toolContentId, String title, String description) throws ToolException, DataMissingException { TaskList toolContentObj = getTaskListByContentId(toolContentId); if ( toolContentObj == null ) { @@ -1138,36 +996,180 @@ toolContentObj.setReflectInstructions(description); } + //***************************************************************************** + // Private methods + //***************************************************************************** - /* =================================================================================== */ - - public IExportToolContentService getExportContentService() { - return exportContentService; + private TaskList getDefaultTaskList() throws TaskListApplicationException { + Long defaultTaskListId = getToolDefaultContentIdBySignature(TaskListConstants.TOOL_SIGNATURE); + TaskList defaultTaskList = getTaskListByContentId(defaultTaskListId); + if(defaultTaskList == null) + { + String error=messageService.getMessage("error.msg.default.content.not.find"); + log.error(error); + throw new TaskListApplicationException(error); + } + + return defaultTaskList; } - - - public void setExportContentService(IExportToolContentService exportContentService) { - this.exportContentService = exportContentService; + + private Long getToolDefaultContentIdBySignature(String toolSignature) throws TaskListApplicationException { + Long contentId = null; + contentId=new Long(toolService.getToolDefaultContentIdBySignature(toolSignature)); + if (contentId == null) + { + String error=messageService.getMessage("error.msg.default.content.not.find"); + log.error(error); + throw new TaskListApplicationException(error); + } + return contentId; + } + + /** + * Process an uploaded file. + * + * @throws TaskListApplicationException + * @throws FileNotFoundException + * @throws IOException + * @throws RepositoryCheckedException + * @throws InvalidParameterException + */ + private NodeKey processFile(FormFile file, String fileType) throws UploadTaskListFileException { + NodeKey node = null; + if (file!= null && !StringUtils.isEmpty(file.getFileName())) { + String fileName = file.getFileName(); + try { + node = taskListToolContentHandler.uploadFile(file.getInputStream(), fileName, + file.getContentType(), fileType); + } catch (InvalidParameterException e) { + throw new UploadTaskListFileException (messageService.getMessage("error.msg.invaid.param.upload")); + } catch (FileNotFoundException e) { + throw new UploadTaskListFileException (messageService.getMessage("error.msg.file.not.found")); + } catch (RepositoryCheckedException e) { + throw new UploadTaskListFileException (messageService.getMessage("error.msg.repository")); + } catch (IOException e) { + throw new UploadTaskListFileException (messageService.getMessage("error.msg.io.exception")); + } + } + return node; + } + + private NodeKey processPackage(String packageDirectory, String initFile) throws UploadTaskListFileException { + NodeKey node = null; + try { + node = taskListToolContentHandler.uploadPackage(packageDirectory, initFile); + } catch (InvalidParameterException e) { + throw new UploadTaskListFileException (messageService.getMessage("error.msg.invaid.param.upload")); + } catch (RepositoryCheckedException e) { + throw new UploadTaskListFileException (messageService.getMessage("error.msg.repository")); + } + return node; } - - public IUserManagementService getUserManagementService() { - return userManagementService; + /** + * Find out default.htm/html or index.htm/html in the given directory folder + * @param packageDirectory + * @return + */ + private String findWebsiteInitialItem(String packageDirectory) { + File file = new File(packageDirectory); + if(!file.isDirectory()) + return null; + + File[] initFiles = file.listFiles(new FileFilter(){ + public boolean accept(File pathname) { + if(pathname == null || pathname.getName() == null) + return false; + String name = pathname.getName(); + if(name.endsWith("default.html") + ||name.endsWith("default.htm") + ||name.endsWith("index.html") + ||name.endsWith("index.htm")) + return true; + return false; + } + }); + if(initFiles != null && initFiles.length > 0) + return initFiles[0].getName(); + else + return null; } - - public void setUserManagementService(IUserManagementService userManagementService) { - this.userManagementService = userManagementService; + private class ReflectDTOComparator implements Comparator{ + public int compare(ReflectDTO o1, ReflectDTO o2) { + + if(o1 != null && o2 != null){ + return o1.getFullName().compareTo(o2.getFullName()); + }else if(o1 != null) + return 1; + else + return -1; + } } - - - public ICoreNotebookService getCoreNotebookService() { - return coreNotebookService; + + //******************************************************************************* + // Service method + //******************************************************************************* + /** Try to get the file. If forceLogin = false and an access denied exception occurs, call this method + * again to get a new ticket and retry file lookup. If forceLogin = true and it then fails + * then throw exception. + * @param uuid + * @param versionId + * @param relativePath + * @param attemptCount + * @return file node + * @throws ImscpApplicationException + */ + private IVersionedNode getFile(Long uuid, Long versionId, String relativePath) throws TaskListApplicationException { + + ITicket tic = getRepositoryLoginTicket(); + + try { + return repositoryService.getFileItem(tic, uuid, versionId, relativePath); + } catch (AccessDeniedException e) { + + String error = "Unable to access repository to get file uuid "+uuid + +" version id "+versionId + +" path " + relativePath+"."; + + error = error+"AccessDeniedException: "+e.getMessage()+" Unable to retry further."; + log.error(error); + throw new TaskListApplicationException(error,e); + + } catch (Exception e) { + + String error = "Unable to access repository to get file uuid "+uuid + +" version id "+versionId + +" path " + relativePath+"." + +" Exception: "+e.getMessage(); + log.error(error); + throw new TaskListApplicationException(error,e); + + } } - - - public void setCoreNotebookService(ICoreNotebookService coreNotebookService) { - this.coreNotebookService = coreNotebookService; + + /** + * This method verifies the credentials of the TaskList Tool and gives it + * the Ticket to login and access the Content Repository. + * + * A valid ticket is needed in order to access the content from the + * repository. This method would be called evertime the tool needs to + * upload/download files from the content repository. + * + * @return ITicket The ticket for repostory access + * @throws TaskListApplicationException + */ + private ITicket getRepositoryLoginTicket() throws TaskListApplicationException { + ICredentials credentials = new SimpleCredentials(taskListToolContentHandler.getRepositoryUser(), taskListToolContentHandler.getRepositoryId()); + try { + ITicket ticket = repositoryService.login(credentials, taskListToolContentHandler.getRepositoryWorkspaceName()); + return ticket; + } catch (AccessDeniedException ae) { + throw new TaskListApplicationException("Access Denied to repository." + ae.getMessage()); + } catch (WorkspaceNotFoundException we) { + throw new TaskListApplicationException("Workspace not found." + we.getMessage()); + } catch (LoginException e) { + throw new TaskListApplicationException("Login failed." + e.getMessage()); + } } - } Index: lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/service/TaskListServiceProxy.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/service/TaskListServiceProxy.java,v diff -u -r1.1 -r1.2 --- lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/service/TaskListServiceProxy.java 28 Feb 2008 03:50:18 -0000 1.1 +++ lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/service/TaskListServiceProxy.java 31 Mar 2008 06:09:45 -0000 1.2 @@ -31,43 +31,36 @@ import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.support.WebApplicationContextUtils; - - - /** - * @author Dapeng.Ni - * *

This class act as the proxy between web layer and service layer. It is * designed to decouple the presentation logic and business logic completely. * In this way, the presentation tier will no longer be aware of the changes in * service layer. Therefore we can feel free to switch the business logic * implementation.

+ * + * @author Dapeng.Ni */ -public class TaskListServiceProxy -{ +public class TaskListServiceProxy { + /** * Return the domain service object. It will delegate to the Spring * helper method to retrieve the proper bean from Spring bean factory. * @param servletContext the servletContext for current application * @return Shared taskList service object. */ - public static final ITaskListService getTaskListService(ServletContext servletContext) - { + public static final ITaskListService getTaskListService(ServletContext servletContext) { return (ITaskListService)getTaskListDomainService(servletContext); } - public static final ToolSessionManager getSessionManager(ServletContext servletContext) - { + public static final ToolSessionManager getSessionManager(ServletContext servletContext) { return (ToolSessionManager)getTaskListDomainService(servletContext); } - public static final ToolContentManager getContentManager(ServletContext servletContext) - { + public static final ToolContentManager getContentManager(ServletContext servletContext) { return (ToolContentManager)getTaskListDomainService(servletContext); } - private static Object getTaskListDomainService(ServletContext servletContext) - { + private static Object getTaskListDomainService(ServletContext servletContext) { WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext); return wac.getBean(TaskListConstants.RESOURCE_SERVICE); } Index: lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/service/UploadTaskListFileException.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/service/UploadTaskListFileException.java,v diff -u -r1.1 -r1.2 --- lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/service/UploadTaskListFileException.java 28 Feb 2008 03:50:18 -0000 1.1 +++ lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/service/UploadTaskListFileException.java 31 Mar 2008 06:09:45 -0000 1.2 @@ -23,26 +23,27 @@ /* $$Id$$ */ package org.lamsfoundation.lams.tool.taskList.service; +/** + * Exception that is thrown during TaskListFile uploading. + * + * @author Administrator + */ public class UploadTaskListFileException extends Exception{ public UploadTaskListFileException() { super(); - } public UploadTaskListFileException(String message, Throwable cause) { super(message, cause); - } public UploadTaskListFileException(String message) { super(message); - } public UploadTaskListFileException(Throwable cause) { super(cause); - } } Index: lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/util/TaskListItemAttachmentComparator.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/util/TaskListItemAttachmentComparator.java,v diff -u -r1.1 -r1.2 --- lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/util/TaskListItemAttachmentComparator.java 7 Mar 2008 01:57:40 -0000 1.1 +++ lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/util/TaskListItemAttachmentComparator.java 31 Mar 2008 06:09:45 -0000 1.2 @@ -28,9 +28,9 @@ import org.lamsfoundation.lams.tool.taskList.model.TaskListItemAttachment; /** + * Comparator for TaskListItemAttachment. * * @author Andrey Balan - * */ public class TaskListItemAttachmentComparator implements Comparator { Index: lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/util/TaskListItemCommentComparator.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/util/TaskListItemCommentComparator.java,v diff -u -r1.1 -r1.2 --- lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/util/TaskListItemCommentComparator.java 7 Mar 2008 01:57:40 -0000 1.1 +++ lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/util/TaskListItemCommentComparator.java 31 Mar 2008 06:09:45 -0000 1.2 @@ -28,9 +28,9 @@ import org.lamsfoundation.lams.tool.taskList.model.TaskListItemComment; /** + * Comparator for TaskListItemComment. * * @author Andrey Balan - * */ public class TaskListItemCommentComparator implements Comparator { Index: lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/util/TaskListItemComparator.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/util/TaskListItemComparator.java,v diff -u -r1.1 -r1.2 --- lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/util/TaskListItemComparator.java 28 Feb 2008 03:50:18 -0000 1.1 +++ lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/util/TaskListItemComparator.java 31 Mar 2008 06:09:45 -0000 1.2 @@ -3,13 +3,17 @@ import java.util.Comparator; import org.lamsfoundation.lams.tool.taskList.model.TaskListItem; + /** + * Comparator for TaskListItem. * - * @author steven - * + * @author Andrey Balan */ public class TaskListItemComparator implements Comparator { + /** + * {@inheritDoc} + */ public int compare(TaskListItem o1, TaskListItem o2) { if(o1 != null && o2 != null){ return o1.getSequenceId() - o2.getSequenceId(); Index: lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/util/TaskListToolContentHandler.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/util/TaskListToolContentHandler.java,v diff -u -r1.1 -r1.2 --- lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/util/TaskListToolContentHandler.java 28 Feb 2008 03:50:18 -0000 1.1 +++ lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/util/TaskListToolContentHandler.java 31 Mar 2008 06:09:45 -0000 1.2 @@ -37,30 +37,27 @@ //sharedtaskList private static char[] repositoryId = {'l','a','m','s','-','s','h','a','r','e','d','r','e','s','o','u','r','c','e','s'}; - /** - * - */ public TaskListToolContentHandler() { super(); } - /* (non-Javadoc) - * @see org.lamsfoundation.lams.contentrepository.client.ToolContentHandler#getRepositoryWorkspaceName() - */ + /** + * {@inheritDoc} + */ public String getRepositoryWorkspaceName() { return repositoryWorkspaceName; } - /* (non-Javadoc) - * @see org.lamsfoundation.lams.contentrepository.client.ToolContentHandler#getRepositoryUser() - */ + /** + * {@inheritDoc} + */ public String getRepositoryUser() { return repositoryUser; } - /* (non-Javadoc) - * @see org.lamsfoundation.lams.contentrepository.client.ToolContentHandler#getRepositoryId() - */ + /** + * {@inheritDoc} + */ public char[] getRepositoryId() { return repositoryId; } Index: lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/util/TaskListWebUtils.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/util/TaskListWebUtils.java,v diff -u -r1.1 -r1.2 --- lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/util/TaskListWebUtils.java 28 Feb 2008 03:50:18 -0000 1.1 +++ lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/util/TaskListWebUtils.java 31 Mar 2008 06:09:45 -0000 1.2 @@ -24,16 +24,13 @@ /* $$Id$$ */ package org.lamsfoundation.lams.tool.taskList.util; - - - /** * Contains helper methods used by the Action Servlets * * @author Anthony Sukkar - * */ public class TaskListWebUtils { // We leave this blank for future use + } Index: lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/web/action/ViewItemAction.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/web/action/Attic/ViewItemAction.java,v diff -u -r1.5 -r1.6 --- lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/web/action/ViewItemAction.java 14 Mar 2008 08:01:00 -0000 1.5 +++ lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/web/action/ViewItemAction.java 31 Mar 2008 06:09:45 -0000 1.6 @@ -152,7 +152,7 @@ //init taskList item list SortedSet attachmentList = getAttachmentList(sessionMap); - Set dbAttachments = item.getUploadedFileList(); + Set dbAttachments = item.getAttachments(); attachmentList.clear(); if(dbAttachments != null){ for(TaskListItemAttachment comment : dbAttachments){ @@ -250,10 +250,10 @@ //finally persist taskListPO again TaskListItem httpSessionItem = (TaskListItem) sessionMap.get(TaskListConstants.ATTR_TASK_LIST_ITEM); TaskListItem dbItem = service.getTaskListItemByUid(httpSessionItem.getUid()); - Set dbAttachments = dbItem.getUploadedFileList(); + Set dbAttachments = dbItem.getAttachments(); if(dbAttachments == null){ dbAttachments = new HashSet(); - dbItem.setUploadedFileList(dbAttachments); + dbItem.setAttachments(dbAttachments); } dbAttachments.add(att); service.saveOrUpdateTaskListItem(dbItem); Index: lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/web/form/TaskListItemForm.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/web/form/TaskListItemForm.java,v diff -u -r1.4 -r1.5 --- lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/web/form/TaskListItemForm.java 9 Mar 2008 11:06:28 -0000 1.4 +++ lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/web/form/TaskListItemForm.java 31 Mar 2008 06:09:45 -0000 1.5 @@ -25,7 +25,6 @@ import org.apache.struts.action.ActionForm; import org.apache.struts.upload.FormFile; -import org.lamsfoundation.lams.tool.taskList.model.TaskListItemComment; /** * TaskList Item Form. * @struts.form name="taskListItemForm" Index: lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/web/servlet/ExportServlet.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/web/servlet/ExportServlet.java,v diff -u -r1.2 -r1.3 --- lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/web/servlet/ExportServlet.java 14 Mar 2008 08:01:00 -0000 1.2 +++ lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/web/servlet/ExportServlet.java 31 Mar 2008 06:09:45 -0000 1.3 @@ -26,7 +26,6 @@ package org.lamsfoundation.lams.tool.taskList.web.servlet; import java.io.File; -import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -38,9 +37,10 @@ import org.apache.log4j.Logger; import org.lamsfoundation.lams.tool.ToolAccessMode; import org.lamsfoundation.lams.tool.taskList.TaskListConstants; -import org.lamsfoundation.lams.tool.taskList.dto.AttachmentDTO; -import org.lamsfoundation.lams.tool.taskList.dto.ExportDTO; +import org.lamsfoundation.lams.tool.taskList.dto.TaskSummary; +import org.lamsfoundation.lams.tool.taskList.dto.TaskSummaryItem; import org.lamsfoundation.lams.tool.taskList.model.TaskList; +import org.lamsfoundation.lams.tool.taskList.model.TaskListItemAttachment; import org.lamsfoundation.lams.tool.taskList.model.TaskListSession; import org.lamsfoundation.lams.tool.taskList.model.TaskListUser; import org.lamsfoundation.lams.tool.taskList.service.ITaskListService; @@ -59,6 +59,7 @@ * package. * * @author Steve.Ni + * @author Andrey Balan * * @version $Revision$ */ @@ -71,9 +72,12 @@ private TaskListToolContentHandler handler; + /** + * {@inheritDoc} + */ public String doExport(HttpServletRequest request, HttpServletResponse response, String directoryName, Cookie[] cookies) { -// initial sessionMap + //initial sessionMap SessionMap sessionMap = new SessionMap(); request.getSession().setAttribute(sessionMap.getSessionID(), sessionMap); @@ -97,6 +101,9 @@ return FILENAME; } + /** + * {@inheritDoc} + */ protected String doOfflineExport(HttpServletRequest request, HttpServletResponse response, String directoryName, Cookie[] cookies) { if (toolContentID == null && toolSessionID == null) { logger.error("Tool content Id or and session Id are null. Unable to activity title"); @@ -117,7 +124,17 @@ return super.doOfflineExport(request, response, directoryName, cookies); } - public void learner(HttpServletRequest request, HttpServletResponse response, String directoryName, Cookie[] cookies, HashMap sessionMap) + /** + * Internal method to make an export for specified learner. + * + * @param request + * @param response + * @param directoryName + * @param cookies + * @param sessionMap + * @throws TaskListApplicationException + */ + private void learner(HttpServletRequest request, HttpServletResponse response, String directoryName, Cookie[] cookies, HashMap sessionMap) throws TaskListApplicationException { ITaskListService service = TaskListServiceProxy.getTaskListService(getServletContext()); @@ -144,19 +161,25 @@ throw new TaskListApplicationException(error); } + List taskSummaries = service.exportForLearner(toolSessionID, learner); - List group = service.exportBySessionId(toolSessionID, learner.getLoginName()); - - saveFileToLocal(group, directoryName); + saveFileToLocal(taskSummaries, directoryName); - List groupList = new ArrayList(); - if(group.size() > 0) - groupList.add(group); sessionMap.put(TaskListConstants.ATTR_TITLE, content.getTitle()); - sessionMap.put(TaskListConstants.ATTR_EXPORT_DTO_LIST, groupList); + sessionMap.put(TaskListConstants.ATTR_TASK_SUMMARY_LIST, taskSummaries); } - public void teacher(HttpServletRequest request, HttpServletResponse response, String directoryName, Cookie[] cookies, HashMap sessionMap) + /** + * Internal method to make an export for the whole TaskList. + * + * @param request + * @param response + * @param directoryName + * @param cookies + * @param sessionMap + * @throws TaskListApplicationException + */ + private void teacher(HttpServletRequest request, HttpServletResponse response, String directoryName, Cookie[] cookies, HashMap sessionMap) throws TaskListApplicationException { ITaskListService service = TaskListServiceProxy.getTaskListService(getServletContext()); @@ -174,43 +197,59 @@ logger.error(error); throw new TaskListApplicationException(error); } - List> groupList = service.exportByContentId(toolContentID); - - if(groupList != null) - for (List list : groupList) { - saveFileToLocal(list, directoryName); - } + + List taskSummaries = service.exportForTeacher(toolContentID); + + saveFileToLocal(taskSummaries, directoryName); + // put it into HTTPSession sessionMap.put(TaskListConstants.ATTR_TITLE, content.getTitle()); - sessionMap.put(TaskListConstants.ATTR_EXPORT_DTO_LIST, groupList); + sessionMap.put(TaskListConstants.ATTR_TASK_SUMMARY_LIST, taskSummaries); } - private void saveFileToLocal(List exportDTOs, String directoryName) { + /** + * Create download links for every attachment. + * + * @param taskSummaries + * @param directoryName + */ + private void saveFileToLocal(List taskSummaries, String directoryName) { handler = getToolContentHandler(); - for (ExportDTO exportDTO : exportDTOs) { - for (AttachmentDTO attachment : exportDTO.getAttachmentDTOs()) { - try{ - int idx= 1; - String userName = attachment.getCreatedBy(); - String localDir; - while(true){ - localDir = FileUtil.getFullPath(directoryName,userName + "/" + idx); - File local = new File(localDir); - if(!local.exists()){ - local.mkdirs(); - break; + + //save all the attachments + for (TaskSummary taskSummary : taskSummaries) { + for (TaskSummaryItem taskSummaryItem : taskSummary.getTaskSummaryItems()) { + for (TaskListItemAttachment attachment : taskSummaryItem.getAttachments()) { + try{ + int idx= 1; + String userName = attachment.getCreateBy().getLoginName(); + String localDir; + while(true){ + localDir = FileUtil.getFullPath(directoryName,userName + "/" + idx); + File local = new File(localDir); + if(!local.exists()){ + local.mkdirs(); + break; + } + idx++; } - idx++; + attachment.setAttachmentLocalUrl(userName + "/" + idx + "/" + attachment.getFileUuid() + '.' + FileUtil.getFileExtension(attachment.getFileName())); + handler.saveFile(attachment.getFileUuid(), FileUtil.getFullPath(directoryName, attachment.getAttachmentLocalUrl())); + } catch (Exception e) { + logger.error("Export forum topic attachment failed: " + e.toString()); } - attachment.setAttachmentLocalUrl(userName + "/" + idx + "/" + attachment.getFileUuid() + '.' + FileUtil.getFileExtension(attachment.getFileName())); - handler.saveFile(attachment.getFileUuid(), FileUtil.getFullPath(directoryName, attachment.getAttachmentLocalUrl())); - } catch (Exception e) { - logger.error("Export forum topic attachment failed: " + e.toString()); } } } + +// //save two pictures describing either the taskLisiItem is done or not +// handler.saveFile(attachment.getFileUuid(), FileUtil.getFullPath(directoryName, "images/completeitem.gif")); +// handler.saveFile(attachment.getFileUuid(), FileUtil.getFullPath(directoryName, "images/incompleteitem.gif")); } + /** + * {@inheritDoc} + */ private TaskListToolContentHandler getToolContentHandler() { if ( handler == null ) { WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(this.getServletContext()); Index: lams_tool_task/web/pages/export/exportportfolio.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_task/web/pages/export/exportportfolio.jsp,v diff -u -r1.2 -r1.3 --- lams_tool_task/web/pages/export/exportportfolio.jsp 14 Mar 2008 08:01:00 -0000 1.2 +++ lams_tool_task/web/pages/export/exportportfolio.jsp 31 Mar 2008 06:09:45 -0000 1.3 @@ -3,7 +3,7 @@ "http://www.w3.org/TR/html4/loose.dtd"> - + @@ -33,113 +33,12 @@

${title}

- - - - <%-- display group name on first row--%> - - - - - - - - - + + + +
- - - - - - ${item.sessionName} - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - -
-
- -
-
- ${item.itemTitle} - - ${item.username} - - - -
- - - - - - - - - - - - - -
- - ${comment.createdBy} - - - -
-
- -
-
-
- -
    - -
  • - - - - [${file.createdBy}] - -
  • -
    -
-
-
+ <%@ include file="summaryTask.jsp"%> +
Index: lams_tool_task/web/pages/export/summaryTask.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_task/web/pages/export/Attic/summaryTask.jsp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ lams_tool_task/web/pages/export/summaryTask.jsp 31 Mar 2008 06:09:45 -0000 1.1 @@ -0,0 +1,109 @@ + + +
+

+ +

+ + + () + +
+
+ + +
    + +
  • + (: ${item.parentTaskName}) +
  • +
    + + +
  • + +
  • +
    +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + ? + + + + +
+ ${taskSummaryItem.user.loginName} + + + + + + + + + + + + + + +
    + +
  • + +
  • +
    + + +
  • + + + + + + +
  • +
    + +
+ + + + +
+

+