Index: lams_build/lib/lams/lams.jar =================================================================== diff -u -rbab1a8a3e84314de4488aaedc063b39f806ce2c5 -r708bd4d049ae0a59d70c964ef2f864d2b7a352e6 Binary files differ Index: lams_common/src/java/org/lamsfoundation/lams/notebook/dao/INotebookEntryDAO.java =================================================================== diff -u -r38a6c414e30497d03559a85b5c33155e4a2fc22e -r708bd4d049ae0a59d70c964ef2f864d2b7a352e6 --- lams_common/src/java/org/lamsfoundation/lams/notebook/dao/INotebookEntryDAO.java (.../INotebookEntryDAO.java) (revision 38a6c414e30497d03559a85b5c33155e4a2fc22e) +++ lams_common/src/java/org/lamsfoundation/lams/notebook/dao/INotebookEntryDAO.java (.../INotebookEntryDAO.java) (revision 708bd4d049ae0a59d70c964ef2f864d2b7a352e6) @@ -31,21 +31,21 @@ public interface INotebookEntryDAO { - void saveOrUpdate(NotebookEntry nb); + void saveOrUpdate(NotebookEntry nb); - NotebookEntry get(Long uid); + NotebookEntry get(Long uid); - List get(Integer userID); + List get(Integer userID); - List get(Integer userID, Integer idType); - - List get(Integer userID, Long lessonID); + List get(Integer userID, Integer idType); - List get(Long id, Integer idType, Integer userID); - - List get(Long id, Integer idType, String signature, - Integer userID); - - List get(Long id, Integer idType, String signature); + List get(Integer userID, Long lessonID); -} + List get(Long id, Integer idType, Integer userID); + + List get(Long id, Integer idType, String signature, Integer userID); + + List get(Long id, Integer idType, String signature); + + void delete(NotebookEntry notebookEntry); +} \ No newline at end of file Index: lams_common/src/java/org/lamsfoundation/lams/notebook/dao/hibernate/NotebookEntryDAO.java =================================================================== diff -u -r5ad7a601fa0abc84a024e8b075349a47c5421fd5 -r708bd4d049ae0a59d70c964ef2f864d2b7a352e6 --- lams_common/src/java/org/lamsfoundation/lams/notebook/dao/hibernate/NotebookEntryDAO.java (.../NotebookEntryDAO.java) (revision 5ad7a601fa0abc84a024e8b075349a47c5421fd5) +++ lams_common/src/java/org/lamsfoundation/lams/notebook/dao/hibernate/NotebookEntryDAO.java (.../NotebookEntryDAO.java) (revision 708bd4d049ae0a59d70c964ef2f864d2b7a352e6) @@ -34,58 +34,73 @@ @Repository public class NotebookEntryDAO extends LAMSBaseDAO implements INotebookEntryDAO { - - private static final String SQL_QUERY_FIND_ENTRY_BY_EXTERNAL_ID_SIG = "from " + NotebookEntry.class.getName() - + " where external_id=? and external_id_type=? and external_signature=? and user_id=?" - + " order by create_date desc"; - private static final String SQL_QUERY_FIND_ENTRY_BY_EXTERNAL_ID_SIG_ALL = "from " + NotebookEntry.class.getName() - + " where external_id=? and external_id_type=? and external_signature=?" - + " order by user_id asc, create_date desc"; - private static final String SQL_QUERY_FIND_ENTRY_BY_EXTERNAL_ID = "from " + NotebookEntry.class.getName() - + " where external_id=? and external_id_type=? and user_id=?" - + " order by create_date desc"; - private static final String SQL_QUERY_FIND_ENTRY_BY_USER_ID = "from " + NotebookEntry.class.getName() - + " where user_id=?"; - private static final String SQL_QUERY_FIND_ENTRY_BY_EXTERNAL_ID_TYPE = "from " + NotebookEntry.class.getName() - + " where user_id=? and external_id_type=?" - + " order by external_signature desc, create_date desc"; - - public void saveOrUpdate(NotebookEntry notebookEntry) { - insertOrUpdate(notebookEntry); - this.getSession().flush(); - } - public List get(Long id, Integer idType, String signature, Integer userID) { - return (List)(doFind(SQL_QUERY_FIND_ENTRY_BY_EXTERNAL_ID_SIG, new Object[]{id, idType, signature, userID})); - } - - public List get(Long id, Integer idType, String signature) { - return (List)(doFind(SQL_QUERY_FIND_ENTRY_BY_EXTERNAL_ID_SIG_ALL, new Object[]{id, idType, signature})); - } - - public List get(Long id, Integer idType, Integer userID) { - return (List)(doFind(SQL_QUERY_FIND_ENTRY_BY_EXTERNAL_ID, new Object[]{id, idType, userID})); - } + private static final String SQL_QUERY_FIND_ENTRY_BY_EXTERNAL_ID_SIG = "from " + NotebookEntry.class.getName() + + " where external_id=? and external_id_type=? and external_signature=? and user_id=?" + + " order by create_date desc"; + private static final String SQL_QUERY_FIND_ENTRY_BY_EXTERNAL_ID_SIG_ALL = "from " + NotebookEntry.class.getName() + + " where external_id=? and external_id_type=? and external_signature=?" + + " order by user_id asc, create_date desc"; + private static final String SQL_QUERY_FIND_ENTRY_BY_EXTERNAL_ID = "from " + NotebookEntry.class.getName() + + " where external_id=? and external_id_type=? and user_id=?" + " order by create_date desc"; + private static final String SQL_QUERY_FIND_ENTRY_BY_USER_ID = "from " + NotebookEntry.class.getName() + + " where user_id=?"; + private static final String SQL_QUERY_FIND_ENTRY_BY_EXTERNAL_ID_TYPE = "from " + NotebookEntry.class.getName() + + " where user_id=? and external_id_type=?" + " order by external_signature desc, create_date desc"; - public NotebookEntry get(Long uid) { - if (uid != null) { - Object o = getSession().get(NotebookEntry.class, uid); - return (NotebookEntry)o; - } else { - return null; - } - } + @Override + public void saveOrUpdate(NotebookEntry notebookEntry) { + insertOrUpdate(notebookEntry); + this.getSession().flush(); + } - public List get(Integer userID) { - return (List)(doFind(SQL_QUERY_FIND_ENTRY_BY_USER_ID, userID)); - } + @Override + public List get(Long id, Integer idType, String signature, Integer userID) { + return (List) (doFind(NotebookEntryDAO.SQL_QUERY_FIND_ENTRY_BY_EXTERNAL_ID_SIG, + new Object[] { id, idType, signature, userID })); + } - public List get(Integer userID, Integer idType) { - return (List)(doFind(SQL_QUERY_FIND_ENTRY_BY_EXTERNAL_ID_TYPE, new Object[]{userID, idType})); + @Override + public List get(Long id, Integer idType, String signature) { + return (List) (doFind(NotebookEntryDAO.SQL_QUERY_FIND_ENTRY_BY_EXTERNAL_ID_SIG_ALL, + new Object[] { id, idType, signature })); + } + + @Override + public List get(Long id, Integer idType, Integer userID) { + return (List) (doFind(NotebookEntryDAO.SQL_QUERY_FIND_ENTRY_BY_EXTERNAL_ID, + new Object[] { id, idType, userID })); + } + + @Override + public NotebookEntry get(Long uid) { + if (uid != null) { + Object o = getSession().get(NotebookEntry.class, uid); + return (NotebookEntry) o; + } else { + return null; } - - public List get(Integer userID, Long lessonID) { - // TODO need to write hql query for lessionID and userID - return null; - } -} + } + + @Override + public List get(Integer userID) { + return (List) (doFind(NotebookEntryDAO.SQL_QUERY_FIND_ENTRY_BY_USER_ID, userID)); + } + + @Override + public List get(Integer userID, Integer idType) { + return (List) (doFind(NotebookEntryDAO.SQL_QUERY_FIND_ENTRY_BY_EXTERNAL_ID_TYPE, + new Object[] { userID, idType })); + } + + @Override + public List get(Integer userID, Long lessonID) { + // TODO need to write hql query for lessionID and userID + return null; + } + + @Override + public void delete(NotebookEntry notebookEntry) { + getSession().delete(notebookEntry); + } +} \ No newline at end of file Index: lams_common/src/java/org/lamsfoundation/lams/notebook/service/CoreNotebookService.java =================================================================== diff -u -r79381211a4954af09243728ea6467c57a28aca13 -r708bd4d049ae0a59d70c964ef2f864d2b7a352e6 --- lams_common/src/java/org/lamsfoundation/lams/notebook/service/CoreNotebookService.java (.../CoreNotebookService.java) (revision 79381211a4954af09243728ea6467c57a28aca13) +++ lams_common/src/java/org/lamsfoundation/lams/notebook/service/CoreNotebookService.java (.../CoreNotebookService.java) (revision 708bd4d049ae0a59d70c964ef2f864d2b7a352e6) @@ -25,25 +25,22 @@ package org.lamsfoundation.lams.notebook.service; +import java.util.ArrayList; import java.util.Date; import java.util.List; -import java.util.ArrayList; import java.util.TreeMap; import org.apache.log4j.Logger; import org.lamsfoundation.lams.dao.IBaseDAO; import org.lamsfoundation.lams.lesson.Lesson; import org.lamsfoundation.lams.notebook.dao.INotebookEntryDAO; import org.lamsfoundation.lams.notebook.model.NotebookEntry; +import org.lamsfoundation.lams.usermanagement.User; import org.lamsfoundation.lams.usermanagement.service.IUserManagementService; import org.lamsfoundation.lams.util.MessageService; -import org.lamsfoundation.lams.usermanagement.User; -import org.lamsfoundation.lams.usermanagement.Role; +public class CoreNotebookService implements ICoreNotebookService { - -public class CoreNotebookService implements ICoreNotebookService, IExtendedCoreNotebookService{ - private static Logger log = Logger.getLogger(CoreNotebookService.class); private INotebookEntryDAO notebookEntryDAO; @@ -54,22 +51,23 @@ protected MessageService messageService; - public Long createNotebookEntry(Long id, Integer idType, String signature, - Integer userID, String title, String entry) { + @Override + public Long createNotebookEntry(Long id, Integer idType, String signature, Integer userID, String title, + String entry) { User user = (User)getUserManagementService().findById(User.class, userID); - NotebookEntry notebookEntry = new NotebookEntry(id, idType, signature, - user, title, entry, new Date()); + NotebookEntry notebookEntry = new NotebookEntry(id, idType, signature, user, title, entry, new Date()); saveOrUpdateNotebookEntry(notebookEntry); return notebookEntry.getUid(); } + @Override public TreeMap> getEntryByLesson(Integer userID, Integer idType) { TreeMap> entryMap = new TreeMap>(); List list = getEntry(userID, idType); for (NotebookEntry entry : list) { if(entryMap.containsKey(entry.getExternalID())) { - String lessonName = (String) entryMap.get(entry.getExternalID()).get(0).getLessonName(); + String lessonName = entryMap.get(entry.getExternalID()).get(0).getLessonName(); entry.setLessonName(lessonName); entryMap.get(entry.getExternalID()).add(entry); } else { @@ -86,48 +84,52 @@ return entryMap; } + @Override public List getEntry(Long id, Integer idType, String signature, Integer userID) { return notebookEntryDAO.get(id, idType, signature, userID); } /** - * Add the SQL needed to look up entries for a given tool. Expects a valid string buffer to be supplied. - * This allows a tool to get the single matching entry (assuming the tool has only created one notebook entry - * for each learner in each session) for the teacher to view. This is an efficient way to get the - * entries at the same time as retrieving the tool data, rather than making a separate lookup. - * Note - if there is more than on row for each tool/session/learner, then the tool will end up with a - * cross product against the learner record and you will get one row in the learner + notebook result for each - * notebook entry. + * Add the SQL needed to look up entries for a given tool. Expects a valid string buffer to be supplied. This allows + * a tool to get the single matching entry (assuming the tool has only created one notebook entry for each learner + * in each session) for the teacher to view. This is an efficient way to get the entries at the same time as + * retrieving the tool data, rather than making a separate lookup. Note - if there is more than on row for each + * tool/session/learner, then the tool will end up with a cross product against the learner record and you will get + * one row in the learner + notebook result for each notebook entry. * * May only be used for entries where the external_id_type = CoreNotebookConstants.NOTEBOOK_TOOL * * The parameters are strings, and the SQL is built up rather than using parameters as either sessionIdString or * userIdString may be the name of a field you are joining on. Typically the sessionId will be a number as the tool * would be requesting the entries for only one session but the user field will need to be a reference to a column - * in the user table so that it can get entries for more than one user. If you wanted multiple users across - * multiple sessions, then the sessionId would need to refer to the column in the user/session table. + * in the user table so that it can get entries for more than one user. If you wanted multiple users across multiple + * sessions, then the sessionId would need to refer to the column in the user/session table. * * If you only want an entry for one user, use getEntry(id, idIdType, signature, userID); * - * The return values are the entry for the select clause (will always have a leading but no trailing comma and - * an alias of notebookEntry) and the sql join clause, which should go with any other join clauses. + * The return values are the entry for the select clause (will always have a leading but no trailing comma and an + * alias of notebookEntry) and the sql join clause, which should go with any other join clauses. * * To make sure it always returns the same number of objects add the select clause like this: * queryText.append(notebookEntryStrings != null ? notebookEntryStrings[0] : ", NULL notebookEntry"); * - * Then if there is isn't a notebookEntry to return, it still returns a notebookEntry column, which translates - * to null. So you can return a collection like List irrespective of whether - * or not the notebook entries (the Strings) are needed. + * Then if there is isn't a notebookEntry to return, it still returns a notebookEntry column, which translates to + * null. So you can return a collection like List irrespective of whether or not the + * notebook entries (the Strings) are needed. * * Finally, as it will be returning the notebook entry as a separate field in select clause, set up the sql -> java * object translation using ".addScalar("notebookEntry", Hibernate.STRING)". * - * @param sessionIdString Session identifier, usually the toolSessionId - * @param toolSignature Tool's string signature (without any quotes) e.g. lantbk11 - * @param userIdString User identifier field string e.g. + * @param sessionIdString + * Session identifier, usually the toolSessionId + * @param toolSignature + * Tool's string signature (without any quotes) e.g. lantbk11 + * @param userIdString + * User identifier field string e.g. * @return String[] { partial select string, join clause } * */ + @Override public String[] getNotebookEntrySQLStrings(String sessionIdString, String toolSignature, String userIdString) { StringBuilder buf = new StringBuilder(" LEFT JOIN lams_notebook_entry entry ON entry.external_id="); buf.append(sessionIdString); @@ -140,30 +142,27 @@ return new String[] { ", entry.entry notebookEntry ", buf.toString() }; } + @Override public List getEntry(Long id, Integer idType, String signature) { return notebookEntryDAO.get(id, idType, signature); } + @Override public List getEntry(Long id, Integer idType, Integer userID) { return notebookEntryDAO.get(id, idType, userID); } - public List getEntry(Integer userID) { - return notebookEntryDAO.get(userID); - } - + @Override public List getEntry(Integer userID, Integer idType) { return notebookEntryDAO.get(userID, idType); } - public List getEntry(Integer userID, Long lessonID) { - return notebookEntryDAO.get(userID, lessonID); - } - + @Override public NotebookEntry getEntry(Long uid) { return notebookEntryDAO.get(uid); } + @Override public void updateEntry(Long uid, String title, String entry) { NotebookEntry ne = getEntry(uid); if (ne != null) { @@ -172,19 +171,26 @@ ne.setLastModified(new Date()); saveOrUpdateNotebookEntry(ne); } else { - log.debug("updateEntry: uid " + uid + "does not exist"); + CoreNotebookService.log.debug("updateEntry: uid " + uid + "does not exist"); } } + @Override public void updateEntry(NotebookEntry notebookEntry) { notebookEntry.setLastModified(new Date()); saveOrUpdateNotebookEntry(notebookEntry); } + @Override public void saveOrUpdateNotebookEntry(NotebookEntry notebookEntry) { notebookEntryDAO.saveOrUpdate(notebookEntry); } + @Override + public void deleteEntry(NotebookEntry notebookEntry) { + notebookEntryDAO.delete(notebookEntry); + } + /* ********** Used by Spring to "inject" the linked objects ************* */ public void setNotebookEntryDAO(INotebookEntryDAO notebookEntryDAO) { @@ -197,12 +203,14 @@ /** * - * @param IUserManagementService The userManagementService to set. + * @param IUserManagementService + * The userManagementService to set. */ public void setUserManagementService(IUserManagementService userManagementService) { this.userManagementService = userManagementService; } + @Override public IUserManagementService getUserManagementService() { return userManagementService; } @@ -217,6 +225,7 @@ /** * Get i18n MessageService */ + @Override public MessageService getMessageService() { return this.messageService; } Index: lams_common/src/java/org/lamsfoundation/lams/notebook/service/ICoreNotebookService.java =================================================================== diff -u -r79381211a4954af09243728ea6467c57a28aca13 -r708bd4d049ae0a59d70c964ef2f864d2b7a352e6 --- lams_common/src/java/org/lamsfoundation/lams/notebook/service/ICoreNotebookService.java (.../ICoreNotebookService.java) (revision 79381211a4954af09243728ea6467c57a28aca13) +++ lams_common/src/java/org/lamsfoundation/lams/notebook/service/ICoreNotebookService.java (.../ICoreNotebookService.java) (revision 708bd4d049ae0a59d70c964ef2f864d2b7a352e6) @@ -28,15 +28,13 @@ import java.util.List; import java.util.TreeMap; -import org.lamsfoundation.lams.usermanagement.User; import org.lamsfoundation.lams.notebook.model.NotebookEntry; import org.lamsfoundation.lams.usermanagement.service.IUserManagementService; import org.lamsfoundation.lams.util.MessageService; public interface ICoreNotebookService { - Long createNotebookEntry(Long id, Integer idType, String signature, - Integer userID, String title, String entry); + Long createNotebookEntry(Long id, Integer idType, String signature, Integer userID, String title, String entry); TreeMap> getEntryByLesson(Integer userID, Integer idType); @@ -48,6 +46,8 @@ List getEntry(Long id, Integer idType, Integer userID); + List getEntry(Integer userID, Integer idType); + NotebookEntry getEntry(Long uid); void updateEntry(Long uid, String title, String entry); @@ -59,4 +59,6 @@ IUserManagementService getUserManagementService(); MessageService getMessageService(); + + void deleteEntry(NotebookEntry entry); } Fisheye: Tag 708bd4d049ae0a59d70c964ef2f864d2b7a352e6 refers to a dead (removed) revision in file `lams_common/src/java/org/lamsfoundation/lams/notebook/service/IExtendedCoreNotebookService.java'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_common/src/java/org/lamsfoundation/lams/tool/ToolContentManager.java =================================================================== diff -u -r0aae4208886026f429f05b458b79c14f8d7030d4 -r708bd4d049ae0a59d70c964ef2f864d2b7a352e6 --- lams_common/src/java/org/lamsfoundation/lams/tool/ToolContentManager.java (.../ToolContentManager.java) (revision 0aae4208886026f429f05b458b79c14f8d7030d4) +++ lams_common/src/java/org/lamsfoundation/lams/tool/ToolContentManager.java (.../ToolContentManager.java) (revision 708bd4d049ae0a59d70c964ef2f864d2b7a352e6) @@ -26,7 +26,6 @@ import java.util.SortedMap; import org.lamsfoundation.lams.tool.exception.DataMissingException; -import org.lamsfoundation.lams.tool.exception.SessionDataExistsException; import org.lamsfoundation.lams.tool.exception.ToolException; /** @@ -67,29 +66,17 @@ public void resetDefineLater(Long toolContentId) throws DataMissingException, ToolException; /** - * Remove tool's content according specified the content id. It will be needed by lams to modify the learning - * design. + * Remove tool's content according specified the content id. * * If the tool content includes files in the content repository then the files should be removed from the - * repository. + * repository. If no matching data exists, the tool should return without throwing an exception. * - * If session data for this toolContentId exists and removeSessionData = true, then the tool should delete the - * session data as well as the content data. - * - * If session data for this toolContentId exists and removeSessionData = false, then the tool should throw - * SessionDataExists. - * - * If no matching data exists, the tool should return without throwing an exception. - * * @param toolContentId * the requested tool content id. - * @param removeSessionData - * should it remove any related session data? * @throws ToolException * if any other error occurs */ - public void removeToolContent(Long toolContentId, boolean removeSessionData) - throws SessionDataExistsException, ToolException; + public void removeToolContent(Long toolContentId) throws ToolException; /** * Removes content previously added by the given user. Index: lams_common/src/java/org/lamsfoundation/lams/tool/service/LamsCoreToolService.java =================================================================== diff -u -r2e5d858e9dd95ddc9aa092c307b2039c9cb62930 -r708bd4d049ae0a59d70c964ef2f864d2b7a352e6 --- lams_common/src/java/org/lamsfoundation/lams/tool/service/LamsCoreToolService.java (.../LamsCoreToolService.java) (revision 2e5d858e9dd95ddc9aa092c307b2039c9cb62930) +++ lams_common/src/java/org/lamsfoundation/lams/tool/service/LamsCoreToolService.java (.../LamsCoreToolService.java) (revision 708bd4d049ae0a59d70c964ef2f864d2b7a352e6) @@ -259,7 +259,7 @@ public void notifyToolToDeleteContent(ToolActivity toolActivity) throws ToolException { try { ToolContentManager contentManager = (ToolContentManager) findToolService(toolActivity.getTool()); - contentManager.removeToolContent(toolActivity.getToolContentId(), true); + contentManager.removeToolContent(toolActivity.getToolContentId()); } catch (NoSuchBeanDefinitionException e) { String message = "A tool which is defined in the database appears to missing from the classpath. Unable to delete the tool content. ToolActivity " + toolActivity; Index: lams_common/src/java/org/lamsfoundation/lams/web/filter/TransactionRetryInterceptor.java =================================================================== diff -u -r9610bd2008149c17e9269c6daf9dbf7a917528ac -r708bd4d049ae0a59d70c964ef2f864d2b7a352e6 --- lams_common/src/java/org/lamsfoundation/lams/web/filter/TransactionRetryInterceptor.java (.../TransactionRetryInterceptor.java) (revision 9610bd2008149c17e9269c6daf9dbf7a917528ac) +++ lams_common/src/java/org/lamsfoundation/lams/web/filter/TransactionRetryInterceptor.java (.../TransactionRetryInterceptor.java) (revision 708bd4d049ae0a59d70c964ef2f864d2b7a352e6) @@ -61,9 +61,13 @@ } } catch (DataIntegrityViolationException e) { exception = e; + if (exception.getCause() instanceof ConstraintViolationException) { + TransactionRetryInterceptor.log.error("Schema error", exception); + } processException(e, invocation, attempt); } catch (ConstraintViolationException e) { exception = e; + TransactionRetryInterceptor.log.error("Schema error", exception); processException(e, invocation, attempt); } catch (CannotAcquireLockException e) { exception = e; Index: lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/NotebookAction.java =================================================================== diff -u -rd578eb0e78e1723052d35e825b00b5c735fe2f7a -r708bd4d049ae0a59d70c964ef2f864d2b7a352e6 --- lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/NotebookAction.java (.../NotebookAction.java) (revision d578eb0e78e1723052d35e825b00b5c735fe2f7a) +++ lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/NotebookAction.java (.../NotebookAction.java) (revision 708bd4d049ae0a59d70c964ef2f864d2b7a352e6) @@ -21,291 +21,260 @@ * **************************************************************** */ -/* $$Id$$ */ +/* $$Id$$ */ package org.lamsfoundation.lams.learning.web.action; +import java.io.IOException; import java.util.List; import java.util.TreeMap; -import java.lang.Integer; -import java.io.IOException; -import java.io.PrintWriter; - import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.log4j.Logger; import org.apache.struts.action.ActionForm; -import org.apache.struts.action.DynaActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; - -import org.lamsfoundation.lams.web.action.LamsDispatchAction; -import org.springframework.web.context.WebApplicationContext; -import org.springframework.web.context.support.WebApplicationContextUtils; - -import org.lamsfoundation.lams.learning.web.util.ActivityMapping; -import org.lamsfoundation.lams.notebook.service.CoreNotebookConstants; -import org.lamsfoundation.lams.notebook.service.ICoreNotebookService; -import org.lamsfoundation.lams.notebook.service.IExtendedCoreNotebookService; -import org.lamsfoundation.lams.notebook.model.NotebookEntry; - +import org.apache.struts.action.DynaActionForm; import org.lamsfoundation.lams.learning.service.ICoreLearnerService; import org.lamsfoundation.lams.learning.service.LearnerServiceProxy; - -import org.lamsfoundation.lams.usermanagement.User; -import org.lamsfoundation.lams.usermanagement.exception.UserAccessDeniedException; -import org.lamsfoundation.lams.web.util.AttributeNames; import org.lamsfoundation.lams.learning.web.util.LearningWebUtil; import org.lamsfoundation.lams.lesson.Lesson; +import org.lamsfoundation.lams.notebook.model.NotebookEntry; +import org.lamsfoundation.lams.notebook.service.CoreNotebookConstants; +import org.lamsfoundation.lams.notebook.service.ICoreNotebookService; +import org.lamsfoundation.lams.usermanagement.User; +import org.lamsfoundation.lams.usermanagement.exception.UserAccessDeniedException; import org.lamsfoundation.lams.util.WebUtil; - import org.lamsfoundation.lams.util.audit.IAuditService; +import org.lamsfoundation.lams.web.action.LamsDispatchAction; +import org.lamsfoundation.lams.web.util.AttributeNames; +import org.springframework.web.context.WebApplicationContext; +import org.springframework.web.context.support.WebApplicationContextUtils; - -/** +/** * * @author M Seaton * - * ----------------XDoclet Tags-------------------- + * ----------------XDoclet Tags-------------------- * - * @struts:action name="NotebookForm" path="/notebook" - * parameter="method" - * validate="false" - * + * @struts:action name="NotebookForm" path="/notebook" parameter="method" validate="false" + * * @struts.action-forward name = "viewAll" path = ".notebookViewAll" * @struts.action-forward name= "viewSingle" path = ".notebookViewSingle" * @struts.action-forward name= "viewJournals" path = ".notebookViewJournals" * @struts.action-forward name = "addNew" path = ".notebookAddNew" - * @struts.action-forward name = "saveSuccess" path = ".notebookSaveSuccess" - * ----------------XDoclet Tags-------------------- + * @struts.action-forward name = "saveSuccess" path = ".notebookSaveSuccess" ----------------XDoclet + * Tags-------------------- * */ -public class NotebookAction extends LamsDispatchAction -{ - //--------------------------------------------------------------------- +public class NotebookAction extends LamsDispatchAction { + // --------------------------------------------------------------------- // Instance variables - //--------------------------------------------------------------------- - private static Logger log = Logger.getLogger(NotebookAction.class); + // --------------------------------------------------------------------- + private static Logger log = Logger.getLogger(NotebookAction.class); - private static IAuditService auditService; - - private static final String VIEW_ALL = "viewAll"; - private static final String VIEW_SINGLE = "viewSingle"; - private static final String VIEW_JOURNALS = "viewJournals"; - private static final String ADD_NEW = "addNew"; - private static final String SAVE_SUCCESS = "saveSuccess"; + private static IAuditService auditService; - public ICoreNotebookService getNotebookService(){ - WebApplicationContext webContext = WebApplicationContextUtils.getRequiredWebApplicationContext(this.getServlet().getServletContext()); - return (IExtendedCoreNotebookService) webContext.getBean(CoreNotebookConstants.NOTEBOOK_SERVICE_BEAN_NAME); + private static final String VIEW_ALL = "viewAll"; + private static final String VIEW_SINGLE = "viewSingle"; + private static final String VIEW_JOURNALS = "viewJournals"; + private static final String ADD_NEW = "addNew"; + private static final String SAVE_SUCCESS = "saveSuccess"; + + public ICoreNotebookService getNotebookService() { + WebApplicationContext webContext = WebApplicationContextUtils + .getRequiredWebApplicationContext(this.getServlet().getServletContext()); + return (ICoreNotebookService) webContext.getBean(CoreNotebookConstants.NOTEBOOK_SERVICE_BEAN_NAME); + } + + /** + * View all notebook entries + */ + public ActionForward viewAll(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { + + // initialize service object + ICoreNotebookService notebookService = getNotebookService(); + + DynaActionForm notebookForm = (DynaActionForm) actionForm; + + // getting requested object according to coming parameters + Integer learnerID = LearningWebUtil.getUserId(); + + // lessonID + Long lessonID = (Long) notebookForm.get(AttributeNames.PARAM_LESSON_ID); + + // get all notebook entries for the learner + + TreeMap> entries = notebookService.getEntryByLesson(learnerID, + CoreNotebookConstants.SCRATCH_PAD); + + request.getSession().setAttribute("entries", entries.values()); + request.setAttribute("lessonID", lessonID); + + return mapping.findForward(NotebookAction.VIEW_ALL); + + } + + /** + * View all journals entries from a lesson call + */ + public ActionForward viewAllJournals(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { + + // List of Journal entries + List journals = null; + + DynaActionForm notebookForm = (DynaActionForm) actionForm; + + // lesson service + ICoreLearnerService learnerService = LearnerServiceProxy.getLearnerService(getServlet().getServletContext()); + + // getting requested object according to coming parameters + Integer userID = LearningWebUtil.getUserId(); + + // lessonID + Long lessonID = (Long) notebookForm.get(AttributeNames.PARAM_LESSON_ID); + Lesson lesson = learnerService.getLesson(lessonID); + + // check user has permission + User user = (User) LearnerServiceProxy.getUserManagementService(getServlet().getServletContext()) + .findById(User.class, userID); + + if ((lesson.getUser() != null) && lesson.getUser().getUserId().equals(userID)) { + journals = getJournals(lesson.getLessonId()); } - - /** - * View all notebook entries - */ - public ActionForward viewAll( - ActionMapping mapping, - ActionForm actionForm, - HttpServletRequest request, - HttpServletResponse response) - throws IOException, ServletException { - // initialize service object - IExtendedCoreNotebookService notebookService = (IExtendedCoreNotebookService) getNotebookService(); - - DynaActionForm notebookForm = (DynaActionForm)actionForm; - - // getting requested object according to coming parameters - Integer learnerID = LearningWebUtil.getUserId(); - - // lessonID - Long lessonID = (Long) notebookForm.get(AttributeNames.PARAM_LESSON_ID); - - // get all notebook entries for the learner - - - TreeMap> entries = notebookService.getEntryByLesson(learnerID, CoreNotebookConstants.SCRATCH_PAD); - - request.getSession().setAttribute("entries", entries.values()); - request.setAttribute("lessonID", lessonID); - - return mapping.findForward(VIEW_ALL); - + if ((lesson == null) || (lesson.getLessonClass() == null) || !lesson.getLessonClass().isStaffMember(user)) { + throw new UserAccessDeniedException( + "User " + userID + " may not retrieve journal entries for lesson " + lesson.getLessonId()); + } else if (journals == null) { + journals = getJournals(lesson.getLessonId()); } - - - /** - * View all journals entries from a lesson call - */ - public ActionForward viewAllJournals( - ActionMapping mapping, - ActionForm actionForm, - HttpServletRequest request, - HttpServletResponse response) - throws IOException, ServletException { - - // List of Journal entries - List journals = null; - - DynaActionForm notebookForm = (DynaActionForm)actionForm; - - // lesson service - ICoreLearnerService learnerService = LearnerServiceProxy.getLearnerService(getServlet().getServletContext()); - // getting requested object according to coming parameters - Integer userID = LearningWebUtil.getUserId(); - - // lessonID - Long lessonID = (Long) notebookForm.get(AttributeNames.PARAM_LESSON_ID); - Lesson lesson = learnerService.getLesson(lessonID); - - // check user has permission - User user = (User)LearnerServiceProxy.getUserManagementService(getServlet().getServletContext()).findById(User.class,userID); - - if ( lesson.getUser() != null && lesson.getUser().getUserId().equals(userID) ) { - journals = getJournals(lesson.getLessonId()); - } - - if ( lesson == null || lesson.getLessonClass()==null || !lesson.getLessonClass().isStaffMember(user) ) { - throw new UserAccessDeniedException("User "+userID+" may not retrieve journal entries for lesson "+lesson.getLessonId()); - } else if(journals == null){ - journals = getJournals(lesson.getLessonId()); - } - - request.getSession().setAttribute("journals", journals); - request.setAttribute("lessonID", lessonID); - - return mapping.findForward(VIEW_JOURNALS); + request.getSession().setAttribute("journals", journals); + request.setAttribute("lessonID", lessonID); + + return mapping.findForward(NotebookAction.VIEW_JOURNALS); + } + + /** + * + * @param lessonID + * Lesson to get the journals from. + * @return List of Journal entries + */ + private List getJournals(Long lessonID) { + // initialize service object + ICoreNotebookService notebookService = getNotebookService(); + + if (lessonID == null) { + return null; } - - /** - * - * @param lessonID Lesson to get the journals from. - * @return List of Journal entries - */ - private List getJournals(Long lessonID) { - // initialize service object - ICoreNotebookService notebookService = (ICoreNotebookService) getNotebookService(); - - if(lessonID == null) - return null; - - return notebookService.getEntry(lessonID, CoreNotebookConstants.SCRATCH_PAD, CoreNotebookConstants.JOURNAL_SIG); - + + return notebookService.getEntry(lessonID, CoreNotebookConstants.SCRATCH_PAD, CoreNotebookConstants.JOURNAL_SIG); + + } + + /** + * View single notebook entry + */ + public ActionForward viewEntry(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { + + // initialize service object + ICoreNotebookService notebookService = getNotebookService(); + + DynaActionForm notebookForm = (DynaActionForm) actionForm; + Long uid = (Long) notebookForm.get("uid"); + String mode = WebUtil.readStrParam(request, "mode", true); + + NotebookEntry entry = notebookService.getEntry(uid); + + if (mode != null) { + request.setAttribute("mode", mode); } - - /** - * View single notebook entry - */ - public ActionForward viewEntry( - ActionMapping mapping, - ActionForm actionForm, - HttpServletRequest request, - HttpServletResponse response) - throws IOException, ServletException { - // initialize service object - IExtendedCoreNotebookService notebookService = (IExtendedCoreNotebookService) getNotebookService(); - - DynaActionForm notebookForm = (DynaActionForm)actionForm; - Long uid = (Long) notebookForm.get("uid"); - String mode = WebUtil.readStrParam(request, "mode", true); - - - NotebookEntry entry = notebookService.getEntry(uid); - - if(mode != null) - request.setAttribute("mode", mode); - - if(entry != null) - request.setAttribute("entry", entry); - - return mapping.findForward(VIEW_SINGLE); + if (entry != null) { + request.setAttribute("entry", entry); } - - - - /** - * - */ - public ActionForward processNewEntry( - ActionMapping mapping, - ActionForm actionForm, - HttpServletRequest request, - HttpServletResponse response) - throws IOException, ServletException { - - // initialize service object - ICoreNotebookService notebookService = (ICoreNotebookService) getNotebookService(); - - DynaActionForm notebookForm = (DynaActionForm)actionForm; - Long id = (Long) notebookForm.get(AttributeNames.PARAM_LESSON_ID); - String title = (String) notebookForm.get("title"); - String entry = (String) notebookForm.get("entry"); - String signature = (String) notebookForm.get("signature"); - Integer userID = LearningWebUtil.getUserId(); - - notebookService.createNotebookEntry(id, CoreNotebookConstants.SCRATCH_PAD, signature, - userID, title, entry); - - boolean skipViewAll = WebUtil.readBooleanParam(request, "skipViewAll", false); - return skipViewAll ? null : viewAll(mapping, actionForm, request, response); + + return mapping.findForward(NotebookAction.VIEW_SINGLE); + } + + /** + * + */ + public ActionForward processNewEntry(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { + + // initialize service object + ICoreNotebookService notebookService = getNotebookService(); + + DynaActionForm notebookForm = (DynaActionForm) actionForm; + Long id = (Long) notebookForm.get(AttributeNames.PARAM_LESSON_ID); + String title = (String) notebookForm.get("title"); + String entry = (String) notebookForm.get("entry"); + String signature = (String) notebookForm.get("signature"); + Integer userID = LearningWebUtil.getUserId(); + + notebookService.createNotebookEntry(id, CoreNotebookConstants.SCRATCH_PAD, signature, userID, title, entry); + + boolean skipViewAll = WebUtil.readBooleanParam(request, "skipViewAll", false); + return skipViewAll ? null : viewAll(mapping, actionForm, request, response); + } + + /** + * + */ + public ActionForward updateEntry(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { + + // initialize service object + ICoreNotebookService notebookService = getNotebookService(); + + // get form data + DynaActionForm notebookForm = (DynaActionForm) actionForm; + Long uid = (Long) notebookForm.get("uid"); + Long id = (Long) notebookForm.get(AttributeNames.PARAM_LESSON_ID); + String title = (String) notebookForm.get("title"); + String entry = (String) notebookForm.get("entry"); + String signature = (String) notebookForm.get("signature"); + + // get existing entry to edit + NotebookEntry entryObj = notebookService.getEntry(uid); + + // check entry is being edited by it's owner + Integer userID = LearningWebUtil.getUserId(); + if (userID != entryObj.getUser().getUserId()) { + // throw exception } - - /** - * - */ - public ActionForward updateEntry( - ActionMapping mapping, - ActionForm actionForm, - HttpServletRequest request, - HttpServletResponse response) - throws IOException, ServletException { - - // initialize service object - ICoreNotebookService notebookService = (ICoreNotebookService) getNotebookService(); - - // get form data - DynaActionForm notebookForm = (DynaActionForm)actionForm; - Long uid = (Long) notebookForm.get("uid"); - Long id = (Long) notebookForm.get(AttributeNames.PARAM_LESSON_ID); - String title = (String) notebookForm.get("title"); - String entry = (String) notebookForm.get("entry"); - String signature = (String) notebookForm.get("signature"); - - - // get existing entry to edit - NotebookEntry entryObj = notebookService.getEntry(uid); - - // check entry is being edited by it's owner - Integer userID = LearningWebUtil.getUserId(); - if(userID != entryObj.getUser().getUserId()) { - // throw exception - } - - //update entry - entryObj.setTitle(title); - entryObj.setEntry(entry); - entryObj.setExternalSignature(signature); - - notebookService.updateEntry(entryObj); - - return viewAll(mapping, actionForm, request, response); - + + // update entry + entryObj.setTitle(title); + entryObj.setEntry(entry); + entryObj.setExternalSignature(signature); + + notebookService.updateEntry(entryObj); + + return viewAll(mapping, actionForm, request, response); + + } + + /** + * Get AuditService bean. + * + * @return + */ + private IAuditService getAuditService() { + if (NotebookAction.auditService == null) { + WebApplicationContext ctx = WebApplicationContextUtils + .getRequiredWebApplicationContext(getServlet().getServletContext()); + NotebookAction.auditService = (IAuditService) ctx.getBean("auditService"); } - - /** - * Get AuditService bean. - * @return - */ - private IAuditService getAuditService(){ - if(auditService==null){ - WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(getServlet().getServletContext()); - auditService = (IAuditService) ctx.getBean("auditService"); - } - return auditService; - } - + return NotebookAction.auditService; + } + } \ No newline at end of file Index: lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/IMonitoringService.java =================================================================== diff -u -r2e5d858e9dd95ddc9aa092c307b2039c9cb62930 -r708bd4d049ae0a59d70c964ef2f864d2b7a352e6 --- lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/IMonitoringService.java (.../IMonitoringService.java) (revision 2e5d858e9dd95ddc9aa092c307b2039c9cb62930) +++ lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/IMonitoringService.java (.../IMonitoringService.java) (revision 708bd4d049ae0a59d70c964ef2f864d2b7a352e6) @@ -342,9 +342,14 @@ * @param userId * checks that the user is a staff member for this lesson */ - void removeLesson(long lessonId, Integer userId) throws UserAccessDeniedException; + void removeLesson(long lessonId, Integer userId) throws SecurityException; /** + * Removes the lesson and all referenced resources (learning design, tool content etc.) from the database. + */ + void removeLessonPermanently(long lessonId, Integer userId) throws SecurityException; + + /** * Set the gate to open to let all the learners through. This learning service is triggerred by the system * scheduler. Will return true GateActivity (or subclass) object, rather than a hibernate proxy. This is needed so * that the class can be returned to the web layer for proper handling. Index: lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/MonitoringService.java =================================================================== diff -u -reb8cf79579303048eefce860e543f36186d3ce10 -r708bd4d049ae0a59d70c964ef2f864d2b7a352e6 --- lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/MonitoringService.java (.../MonitoringService.java) (revision eb8cf79579303048eefce860e543f36186d3ce10) +++ lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/MonitoringService.java (.../MonitoringService.java) (revision 708bd4d049ae0a59d70c964ef2f864d2b7a352e6) @@ -54,6 +54,8 @@ import org.lamsfoundation.lams.learning.service.ICoreLearnerService; import org.lamsfoundation.lams.learning.web.bean.GateActivityDTO; import org.lamsfoundation.lams.learningdesign.Activity; +import org.lamsfoundation.lams.learningdesign.BranchActivityEntry; +import org.lamsfoundation.lams.learningdesign.BranchCondition; import org.lamsfoundation.lams.learningdesign.BranchingActivity; import org.lamsfoundation.lams.learningdesign.ChosenGrouping; import org.lamsfoundation.lams.learningdesign.ComplexActivity; @@ -88,7 +90,10 @@ import org.lamsfoundation.lams.monitoring.quartz.job.FinishScheduleLessonJob; import org.lamsfoundation.lams.monitoring.quartz.job.OpenScheduleGateJob; import org.lamsfoundation.lams.monitoring.quartz.job.StartScheduleLessonJob; +import org.lamsfoundation.lams.notebook.model.NotebookEntry; +import org.lamsfoundation.lams.notebook.service.CoreNotebookConstants; import org.lamsfoundation.lams.security.ISecurityService; +import org.lamsfoundation.lams.tool.ToolContent; import org.lamsfoundation.lams.tool.ToolSession; import org.lamsfoundation.lams.tool.exception.LamsToolServiceException; import org.lamsfoundation.lams.tool.service.ILamsCoreToolService; @@ -938,7 +943,68 @@ setLessonState(requestedLesson, Lesson.REMOVED_STATE); } + @SuppressWarnings("unchecked") @Override + public void removeLessonPermanently(long lessonId, Integer userId) { + securityService.isLessonMonitor(lessonId, userId, "remove lesson permanently", true); + + Lesson lesson = lessonDAO.getLesson(lessonId); + LearningDesign learningDesign = lesson.getLearningDesign(); + + // remove lesson resources + lessonDAO.deleteByProperty(LogEvent.class, "lessonId", lessonId); + lessonDAO.deleteByProperty(ToolSession.class, "lesson.lessonId", lessonId); + Map notebookProperties = new TreeMap(); + notebookProperties.put("externalID", lessonId); + notebookProperties.put("externalSignature", CoreNotebookConstants.SCRATCH_PAD_SIG); + lessonDAO.deleteByProperties(NotebookEntry.class, notebookProperties); + lessonDAO.deleteLesson(lesson); + + // remove each Tool activity content + // It has to be done before removing BranchEntries as fetching Tool content + // in its own transaction would re-add connected BranchEntries (Hibernate error) + Set systemActivities = new HashSet(); + for (Activity activity : (Set) learningDesign.getActivities()) { + // get the real object, not the proxy + activity = activityDAO.getActivityByActivityId(activity.getActivityId()); + if (activity.isToolActivity()) { + ToolActivity toolActivity = (ToolActivity) activity; + // delete content of each tool + lamsCoreToolService.notifyToolToDeleteContent(toolActivity); + // possible nonthreadsafe access to session!!! + lessonDAO.flush(); + Long toolContentId = toolActivity.getToolContentId(); + lessonDAO.deleteById(ToolContent.class, toolContentId); + } else { + systemActivities.add(activity); + } + } + + // remove branching and grouping resources + for (Activity activity : systemActivities) { + if (activity.isBranchingActivity()) { + BranchingActivity branchingActivity = (BranchingActivity) activity; + Grouping grouping = branchingActivity.getGrouping(); + groupingDAO.delete(grouping); + + for (BranchActivityEntry entry : branchingActivity.getBranchActivityEntries()) { + BranchCondition condition = entry.getCondition(); + if (condition != null) { + lessonDAO.deleteById(BranchCondition.class, condition.getConditionId()); + } + } + } else if (activity.isGroupingActivity()) { + GroupingActivity groupingActivity = (GroupingActivity) activity; + Grouping grouping = groupingActivity.getCreateGrouping(); + groupingDAO.delete(grouping); + } + } + + // finally remove the learning design + lessonDAO.delete(learningDesign); + } + + @Override public Boolean setLearnerPortfolioAvailable(long lessonId, Integer userId, Boolean isLearnerExportAvailable) { securityService.isLessonMonitor(lessonId, userId, "set learner portfolio available", true); @@ -2365,7 +2431,8 @@ } @Override - public List getLearnersByActivities(Long[] activityIds, Integer limit, Integer offset, boolean orderAscending) { + public List getLearnersByActivities(Long[] activityIds, Integer limit, Integer offset, + boolean orderAscending) { return learnerProgressDAO.getLearnersByActivities(activityIds, limit, offset, orderAscending); } Index: lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/MonitoringAction.java =================================================================== diff -u -re792686590e18cb45bf74fccc941450caff22470 -r708bd4d049ae0a59d70c964ef2f864d2b7a352e6 --- lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/MonitoringAction.java (.../MonitoringAction.java) (revision e792686590e18cb45bf74fccc941450caff22470) +++ lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/MonitoringAction.java (.../MonitoringAction.java) (revision 708bd4d049ae0a59d70c964ef2f864d2b7a352e6) @@ -579,13 +579,22 @@ */ public ActionForward removeLesson(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, JSONException, ServletException { - long lessonId = WebUtil.readLongParam(request, AttributeNames.PARAM_LESSON_ID); + Integer userId = getUserId(); + boolean permanently = WebUtil.readBooleanParam(request, "permanently", false); + + if (permanently) { + getMonitoringService().removeLessonPermanently(lessonId, userId); + response.setContentType("text/plain;charset=utf-8"); + response.getWriter().print("OK"); + return null; + } + JSONObject jsonObject = new JSONObject(); try { // if this method throws an Exception, there will be no removeLesson=true in the JSON reply - getMonitoringService().removeLesson(lessonId, getUserId()); + getMonitoringService().removeLesson(lessonId, userId); jsonObject.put("removeLesson", true); } catch (Exception e) { Index: lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/service/AssessmentServiceImpl.java =================================================================== diff -u -rc266dd394246bd6178c2e0bb971f3d0eb74095c5 -r708bd4d049ae0a59d70c964ef2f864d2b7a352e6 --- lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/service/AssessmentServiceImpl.java (.../AssessmentServiceImpl.java) (revision c266dd394246bd6178c2e0bb971f3d0eb74095c5) +++ lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/service/AssessmentServiceImpl.java (.../AssessmentServiceImpl.java) (revision 708bd4d049ae0a59d70c964ef2f864d2b7a352e6) @@ -41,7 +41,6 @@ import java.util.regex.Pattern; import org.apache.commons.collections.CollectionUtils; -import org.apache.commons.lang.StringEscapeUtils; import org.apache.commons.lang.StringUtils; import org.apache.log4j.Logger; import org.apache.tomcat.util.json.JSONArray; @@ -99,7 +98,6 @@ import org.lamsfoundation.lams.tool.assessment.util.AssessmentToolContentHandler; import org.lamsfoundation.lams.tool.assessment.util.SequencableComparator; import org.lamsfoundation.lams.tool.exception.DataMissingException; -import org.lamsfoundation.lams.tool.exception.SessionDataExistsException; import org.lamsfoundation.lams.tool.exception.ToolException; import org.lamsfoundation.lams.tool.service.ILamsToolService; import org.lamsfoundation.lams.usermanagement.Organisation; @@ -295,8 +293,8 @@ } @Override - public List getPagedUsersBySession(Long sessionId, int page, int size, String sortBy, String sortOrder, - String searchString) { + public List getPagedUsersBySession(Long sessionId, int page, int size, String sortBy, + String sortOrder, String searchString) { return assessmentUserDao.getPagedUsersBySession(sessionId, page, size, sortBy, sortOrder, searchString); } @@ -1698,15 +1696,19 @@ } @Override - public void removeToolContent(Long toolContentId, boolean removeSessionData) - throws SessionDataExistsException, ToolException { + public void removeToolContent(Long toolContentId) throws ToolException { Assessment assessment = assessmentDao.getByContentId(toolContentId); - if (removeSessionData) { - List list = assessmentSessionDao.getByContentId(toolContentId); - Iterator iter = list.iterator(); - while (iter.hasNext()) { - AssessmentSession session = (AssessmentSession) iter.next(); - assessmentSessionDao.delete(session); + if (assessment == null) { + AssessmentServiceImpl.log + .warn("Can not remove the tool content as it does not exist, ID: " + toolContentId); + return; + } + + for (AssessmentSession session : assessmentSessionDao.getByContentId(toolContentId)) { + List entries = coreNotebookService.getEntry(session.getSessionId(), + CoreNotebookConstants.NOTEBOOK_TOOL, AssessmentConstants.TOOL_SIGNATURE); + for (NotebookEntry entry : entries) { + coreNotebookService.deleteEntry(entry); } } assessmentDao.delete(assessment); @@ -1738,7 +1740,7 @@ assessmentDao.removeObject(NotebookEntry.class, entry.getUid()); } - if (session.getGroupLeader() != null && session.getGroupLeader().getUid().equals(user.getUid())) { + if ((session.getGroupLeader() != null) && session.getGroupLeader().getUid().equals(user.getUid())) { session.setGroupLeader(null); } @@ -2019,7 +2021,8 @@ assessment.setReflectOnActivity(JsonUtil.opt(toolContentJSON, RestTags.REFLECT_ON_ACTIVITY, Boolean.FALSE)); assessment.setShuffled(JsonUtil.opt(toolContentJSON, "shuffled", Boolean.FALSE)); assessment.setTimeLimit(JsonUtil.opt(toolContentJSON, "timeLimit", 0)); - assessment.setUseSelectLeaderToolOuput(JsonUtil.opt(toolContentJSON, RestTags.USE_SELECT_LEADER_TOOL_OUTPUT, Boolean.FALSE)); + assessment.setUseSelectLeaderToolOuput( + JsonUtil.opt(toolContentJSON, RestTags.USE_SELECT_LEADER_TOOL_OUTPUT, Boolean.FALSE)); // submission deadline set in monitoring if (toolContentJSON.has("overallFeedback")) { @@ -2142,9 +2145,11 @@ // TODO Implement REST support for all types and then remove checkType method void checkType(short type) throws JSONException { - if (type != AssessmentConstants.QUESTION_TYPE_ESSAY && type != AssessmentConstants.QUESTION_TYPE_MULTIPLE_CHOICE) { + if ((type != AssessmentConstants.QUESTION_TYPE_ESSAY) + && (type != AssessmentConstants.QUESTION_TYPE_MULTIPLE_CHOICE)) { throw new JSONException( - "Assessment Tool does not support REST Authoring for anything but Essay Type and Multiple Choice. Found type " + type); + "Assessment Tool does not support REST Authoring for anything but Essay Type and Multiple Choice. Found type " + + type); } // public static final short QUESTION_TYPE_MATCHING_PAIRS = 2; // public static final short QUESTION_TYPE_SHORT_ANSWER = 3; Index: lams_tool_bbb/src/java/org/lamsfoundation/lams/tool/bbb/service/BbbService.java =================================================================== diff -u -r0aae4208886026f429f05b458b79c14f8d7030d4 -r708bd4d049ae0a59d70c964ef2f864d2b7a352e6 --- lams_tool_bbb/src/java/org/lamsfoundation/lams/tool/bbb/service/BbbService.java (.../BbbService.java) (revision 0aae4208886026f429f05b458b79c14f8d7030d4) +++ lams_tool_bbb/src/java/org/lamsfoundation/lams/tool/bbb/service/BbbService.java (.../BbbService.java) (revision 708bd4d049ae0a59d70c964ef2f864d2b7a352e6) @@ -44,6 +44,7 @@ import org.lamsfoundation.lams.learningdesign.service.IExportToolContentService; import org.lamsfoundation.lams.learningdesign.service.ImportToolContentException; import org.lamsfoundation.lams.notebook.model.NotebookEntry; +import org.lamsfoundation.lams.notebook.service.CoreNotebookConstants; import org.lamsfoundation.lams.notebook.service.ICoreNotebookService; import org.lamsfoundation.lams.tool.ToolContentManager; import org.lamsfoundation.lams.tool.ToolOutput; @@ -62,7 +63,6 @@ import org.lamsfoundation.lams.tool.bbb.util.BbbUtil; import org.lamsfoundation.lams.tool.bbb.util.Constants; import org.lamsfoundation.lams.tool.exception.DataMissingException; -import org.lamsfoundation.lams.tool.exception.SessionDataExistsException; import org.lamsfoundation.lams.tool.exception.ToolException; import org.lamsfoundation.lams.tool.service.ILamsToolService; import org.lamsfoundation.lams.usermanagement.User; @@ -195,9 +195,22 @@ } @Override - public void removeToolContent(Long toolContentId, boolean removeSessionData) - throws SessionDataExistsException, ToolException { - // TODO Auto-generated method stub + public void removeToolContent(Long toolContentId) throws ToolException { + Bbb bbb = getBbbByContentId(toolContentId); + if (bbb == null) { + BbbService.logger.warn("Can not remove the tool content as it does not exist, ID: " + toolContentId); + return; + } + + for (BbbSession session : bbb.getBbbSessions()) { + List entries = coreNotebookService.getEntry(session.getSessionId(), + CoreNotebookConstants.NOTEBOOK_TOOL, Constants.TOOL_SIGNATURE); + for (NotebookEntry entry : entries) { + coreNotebookService.deleteEntry(entry); + } + } + + bbbDAO.delete(bbb); } @Override Index: lams_tool_chat/src/java/org/lamsfoundation/lams/tool/chat/service/ChatService.java =================================================================== diff -u -r0aae4208886026f429f05b458b79c14f8d7030d4 -r708bd4d049ae0a59d70c964ef2f864d2b7a352e6 --- lams_tool_chat/src/java/org/lamsfoundation/lams/tool/chat/service/ChatService.java (.../ChatService.java) (revision 0aae4208886026f429f05b458b79c14f8d7030d4) +++ lams_tool_chat/src/java/org/lamsfoundation/lams/tool/chat/service/ChatService.java (.../ChatService.java) (revision 708bd4d049ae0a59d70c964ef2f864d2b7a352e6) @@ -68,7 +68,6 @@ import org.lamsfoundation.lams.tool.chat.util.ChatException; import org.lamsfoundation.lams.tool.chat.util.ChatMessageFilter; import org.lamsfoundation.lams.tool.exception.DataMissingException; -import org.lamsfoundation.lams.tool.exception.SessionDataExistsException; import org.lamsfoundation.lams.tool.exception.ToolException; import org.lamsfoundation.lams.tool.service.ILamsToolService; import org.lamsfoundation.lams.usermanagement.User; @@ -243,12 +242,26 @@ chatDAO.saveOrUpdate(chat); } + @SuppressWarnings("unchecked") @Override - public void removeToolContent(Long toolContentId, boolean removeSessionData) - throws SessionDataExistsException, ToolException { - // TODO Auto-generated method stub - } + public void removeToolContent(Long toolContentId) throws ToolException { + Chat chat = chatDAO.getByContentId(toolContentId); + if (chat == null) { + ChatService.logger.warn("Can not remove the tool content as it does not exist, ID: " + toolContentId); + return; + } + for (ChatSession session : (Set) chat.getChatSessions()) { + List entries = coreNotebookService.getEntry(session.getSessionId(), + CoreNotebookConstants.NOTEBOOK_TOOL, ChatConstants.TOOL_SIGNATURE); + for (NotebookEntry entry : entries) { + coreNotebookService.deleteEntry(entry); + } + } + + chatDAO.delete(chat); + } + @Override @SuppressWarnings("unchecked") public void removeLearnerContent(Long toolContentId, Integer userId) throws ToolException { Index: lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/service/DacoServiceImpl.java =================================================================== diff -u -r0aae4208886026f429f05b458b79c14f8d7030d4 -r708bd4d049ae0a59d70c964ef2f864d2b7a352e6 --- lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/service/DacoServiceImpl.java (.../DacoServiceImpl.java) (revision 0aae4208886026f429f05b458b79c14f8d7030d4) +++ lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/service/DacoServiceImpl.java (.../DacoServiceImpl.java) (revision 708bd4d049ae0a59d70c964ef2f864d2b7a352e6) @@ -77,7 +77,6 @@ import org.lamsfoundation.lams.tool.daco.model.DacoUser; import org.lamsfoundation.lams.tool.daco.util.DacoToolContentHandler; import org.lamsfoundation.lams.tool.exception.DataMissingException; -import org.lamsfoundation.lams.tool.exception.SessionDataExistsException; import org.lamsfoundation.lams.tool.exception.ToolException; import org.lamsfoundation.lams.tool.service.ILamsToolService; import org.lamsfoundation.lams.usermanagement.User; @@ -777,13 +776,18 @@ } @Override - public void removeToolContent(Long toolContentId, boolean removeSessionData) - throws SessionDataExistsException, ToolException { + public void removeToolContent(Long toolContentId) throws ToolException { Daco daco = dacoDao.getByContentId(toolContentId); - if (removeSessionData) { - List list = dacoSessionDao.getByContentId(toolContentId); - for (DacoSession session : list) { - dacoSessionDao.deleteBySessionId(session.getSessionId()); + if (daco == null) { + DacoServiceImpl.log.warn("Can not remove the tool content as it does not exist, ID: " + toolContentId); + return; + } + + for (DacoSession session : dacoSessionDao.getByContentId(toolContentId)) { + List entries = coreNotebookService.getEntry(session.getSessionId(), + CoreNotebookConstants.NOTEBOOK_TOOL, DacoConstants.TOOL_SIGNATURE); + for (NotebookEntry entry : entries) { + coreNotebookService.deleteEntry(entry); } } dacoDao.removeObject(Daco.class, daco.getUid()); Index: lams_tool_eadventure/src/java/org/eucm/lams/tool/eadventure/service/EadventureServiceImpl.java =================================================================== diff -u -r0aae4208886026f429f05b458b79c14f8d7030d4 -r708bd4d049ae0a59d70c964ef2f864d2b7a352e6 --- lams_tool_eadventure/src/java/org/eucm/lams/tool/eadventure/service/EadventureServiceImpl.java (.../EadventureServiceImpl.java) (revision 0aae4208886026f429f05b458b79c14f8d7030d4) +++ lams_tool_eadventure/src/java/org/eucm/lams/tool/eadventure/service/EadventureServiceImpl.java (.../EadventureServiceImpl.java) (revision 708bd4d049ae0a59d70c964ef2f864d2b7a352e6) @@ -97,7 +97,6 @@ import org.lamsfoundation.lams.tool.ToolSessionExportOutputData; import org.lamsfoundation.lams.tool.ToolSessionManager; import org.lamsfoundation.lams.tool.exception.DataMissingException; -import org.lamsfoundation.lams.tool.exception.SessionDataExistsException; import org.lamsfoundation.lams.tool.exception.ToolException; import org.lamsfoundation.lams.tool.service.ILamsToolService; import org.lamsfoundation.lams.usermanagement.User; @@ -263,7 +262,7 @@ return content; } - //TODO revisar + // TODO revisar /* public List getAuthoredItems(Long eadventureUid) { return eadventureItemDao.getAuthoringItems(eadventureUid); }*/ @@ -308,7 +307,7 @@ Iterator it = eadExpressions.iterator(); while (it.hasNext()) { EadventureExpression expression = it.next(); - // expression.setCondition_uid(condUID); + // expression.setCondition_uid(condUID); eadventureExpressionDao.saveObject(expression); } } @@ -328,8 +327,8 @@ Iterator it = eadConditions.iterator(); while (it.hasNext()) { EadventureCondition cond = it.next(); - // Set expList = cond.getEadListExpression(); - // cond.setEadListExpression(null); + // Set expList = cond.getEadListExpression(); + // cond.setEadListExpression(null); eadventureConditionDao.saveObject(cond); // saveOrUpdateEadventureExpressions(expList, cond.getUid()); // cond.setEadListExpression(expList); @@ -348,7 +347,7 @@ } - //TODO revisar!!!!!! Monitoring + // TODO revisar!!!!!! Monitoring @Override public List exportBySessionId(Long sessionId, Long userId) { EadventureSession session = eadventureSessionDao.getSessionBySessionId(sessionId); @@ -361,12 +360,12 @@ Eadventure ead = session.getEadventure(); Summary sum = new Summary(session.getSessionId(), session.getSessionName(), ead, false); - //List userList = getUserListBySessionItem(session.getSessionId(), ead.getUid()); + // List userList = getUserListBySessionItem(session.getSessionId(), ead.getUid()); boolean[] existList = new boolean[1]; String[] reportList = new String[1]; EadventureUser eadUser = eadventureUserDao.getUserByUserIDAndSessionID(userId, sessionId); - //TODO doble acceso a vistit log... (aqui y en getUserListBySessionItem) + // TODO doble acceso a vistit log... (aqui y en getUserListBySessionItem) EadventureItemVisitLog log = getEadventureItemLog(ead.getUid(), userId); eadUser.setAccessDate(log.getAccessDate()); EadventureVars var = getEadventureVars(log.getUid(), EadventureConstants.VAR_NAME_REPORT); @@ -385,14 +384,14 @@ sum.setExistList(existList); sum.setReportList(reportList); - //TODO ver si tiene sentido que sea una lista + // TODO ver si tiene sentido que sea una lista ArrayList list = new ArrayList(); list.add(sum); return list; } - //TODO revisar!!!!!! Monitoring + // TODO revisar!!!!!! Monitoring @Override public List exportByContentId(Long contentId) { Eadventure eadventure = eadventureDao.getByContentId(contentId); @@ -410,7 +409,7 @@ int numberOfFinishedLearners = 0; int i = 0; for (EadventureUser eadUser : userList) { - //TODO doble acceso a vistit log... (aqui y en getUserListBySessionItem) + // TODO doble acceso a vistit log... (aqui y en getUserListBySessionItem) EadventureItemVisitLog log = getEadventureItemLog(eadventure.getUid(), eadUser.getUserId()); EadventureVars var = getEadventureVars(log.getUid(), EadventureConstants.VAR_NAME_REPORT); @@ -532,7 +531,7 @@ return nextUrl; } - //TODO revisar!!!! monitoring + // TODO revisar!!!! monitoring @Override public List getSummary(Long contentId) { List groupList = new ArrayList(); @@ -556,7 +555,7 @@ int numberOfFinishedLearners = 0; int i = 0; for (EadventureUser eadUser : userList) { - //TODO doble acceso a vistit log... (aqui y en getUserListBySessionItem) + // TODO doble acceso a vistit log... (aqui y en getUserListBySessionItem) EadventureItemVisitLog log = getEadventureItemLog(eadventure.getUid(), eadUser.getUserId()); EadventureVars var = getEadventureVars(log.getUid(), EadventureConstants.VAR_NAME_REPORT); @@ -626,11 +625,11 @@ user.setAccessDate(visit.getAccessDate()); userList.add(user); } - //List userList = null; + // List userList = null; return userList; } - //TODO revisar Monitoring!!! + // TODO revisar Monitoring!!! @Override public void setItemVisible(Long itemUid, boolean visible) { /*EadventureItem item = eadventureItemDao.getByUid(itemUid); @@ -760,7 +759,7 @@ ead.setFileName(fileName); // parse parameters.xml file, and create the eadParams - //TODO reportar bien el error cuando no se produce xk no es un e-Ad file + // TODO reportar bien el error cuando no se produce xk no es un e-Ad file HashMap params = InputOutputReader .getOutputParameterList(packageDirectory + "//" + EadventureConstants.PARAMETERS_FILE_NAME); // chek if its a real e-adventure package @@ -783,7 +782,8 @@ EadventureServiceImpl.log.error(key + " ha sido subido con exito!!!!!!"); } - //add default params (this are not included in the params file at eAd LAMS export due to they always have to appear) + // add default params (this are not included in the params file at eAd LAMS export due to they always have + // to appear) eadParam.addAll(getDefaultParams()); ead.setParams(eadParam); @@ -822,7 +822,7 @@ * @return */ - //TODO creo que vga a sobrar + // TODO creo que vga a sobrar private String findWebsiteInitialItem(String packageDirectory) { File file = new File(packageDirectory); if (!file.isDirectory()) { @@ -927,7 +927,7 @@ // set EadventureToolContentHandler as null to avoid copy file node in repository again. toolContentObj = Eadventure.newInstance(toolContentObj, toolContentId); try { - //TODO revisar!! + // TODO revisar!! exportContentService.registerFileClassForExport(Eadventure.class.getName(), "fileUuid", "fileVersionId"); exportContentService.exportToolContent(toolContentId, toolContentObj, eadventureToolContentHandler, rootPath); @@ -944,7 +944,7 @@ // register version filter class exportContentService.registerImportVersionFilterClass(EadventureImportContentVersionFilter.class); - //TODO revisar + // TODO revisar exportContentService.registerFileClassForImport(Eadventure.class.getName(), "fileUuid", "fileVersionId", "fileName", "fileType", null, "initialItem"); @@ -970,13 +970,13 @@ user.setEadventure(toolContentObj); } toolContentObj.setCreatedBy(user); - //TODO revisar!! que no falte nada al objeto de EAD + // TODO revisar!! que no falte nada al objeto de EAD // reset all eadventureItem createBy user /*Set items = toolContentObj.getEadventureItems(); for (EadventureItem item : items) { item.setCreateBy(user); }*/ - //TODO ver si esto es correcto: + // TODO ver si esto es correcto: Set par = toolContentObj.getParams(); List listPar = new ArrayList(par); for (Object o : listPar) { @@ -1048,7 +1048,7 @@ Eadventure toContent = Eadventure.newInstance(eadventure, toContentId); eadventureDao.saveObject(toContent); - //TODO no hace nada... pero comprobar que no de problema + // TODO no hace nada... pero comprobar que no de problema // save eadventure items as well /*Set items = toContent.getEadventureItems(); if (items != null) { @@ -1078,7 +1078,7 @@ public boolean isContentEdited(Long toolContentId) { return getEadventureByContentId(toolContentId).isDefineLater(); } - + @Override public boolean isReadOnly(Long toolContentId) { for (EadventureSession session : eadventureSessionDao.getByContentId(toolContentId)) { @@ -1089,19 +1089,23 @@ return false; } - + @Override - public void removeToolContent(Long toolContentId, boolean removeSessionData) - throws SessionDataExistsException, ToolException { + public void removeToolContent(Long toolContentId) throws ToolException { Eadventure eadventure = eadventureDao.getByContentId(toolContentId); - if (removeSessionData) { - List list = eadventureSessionDao.getByContentId(toolContentId); - Iterator iter = list.iterator(); - while (iter.hasNext()) { - EadventureSession session = (EadventureSession) iter.next(); - eadventureSessionDao.delete(session); + if (eadventure == null) { + EadventureServiceImpl.log + .warn("Can not remove the tool content as it does not exist. ID: " + toolContentId); + } + + for (EadventureSession session : eadventureSessionDao.getByContentId(toolContentId)) { + List entries = coreNotebookService.getEntry(session.getSessionId(), + CoreNotebookConstants.NOTEBOOK_TOOL, EadventureConstants.TOOL_SIGNATURE); + for (NotebookEntry entry : entries) { + coreNotebookService.deleteEntry(entry); } } + eadventureDao.delete(eadventure); } @@ -1215,7 +1219,7 @@ @Override public void forceCompleteUser(Long toolSessionId, User user) { - //no actions required + // no actions required } /* ===============Methods implemented from ToolContentImport102Manager =============== */ @@ -1265,7 +1269,7 @@ // Eadventure 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. - //TODO nos cargamos la parte de los items.... comprobar que se pase todo bien y no de ning�n problema + // TODO nos cargamos la parte de los items.... comprobar que se pase todo bien y no de ning�n problema /* Vector urls = (Vector) importValues.get(ToolContentImport102Manager.CONTENT_URL_URLS); SortedMap items = new TreeMap(); if (urls != null) { @@ -1434,7 +1438,7 @@ return getLessonService().getMonitorsByToolSessionId(sessionId); } - //TODO Resultado de la actualizaci�n a la brach de release 2.3.5, ver si afecta!!! + // TODO Resultado de la actualizaci�n a la brach de release 2.3.5, ver si afecta!!! /*public Class[] getSupportedToolOutputDefinitionClasses(int definitionType) { return getEadventureOutputFactory().getSupportedDefinitionClasses(definitionType); @@ -1478,7 +1482,7 @@ Set eadV = visitLog.getEadventureVars(); if (!eadV.isEmpty()) { List eadventureVars = new ArrayList(eadV); - //TODO comprobar si no lo tengo que meter con comparator para que salga en orden + // TODO comprobar si no lo tengo que meter con comparator para que salga en orden Iterator it = condition.getEadListExpression().iterator(); String previousOp = null; while (it.hasNext()) { @@ -1513,11 +1517,11 @@ } } } else { - //There aren't vars set for this user and session + // There aren't vars set for this user and session result = false; } } else { - //there is no such a condition + // there is no such a condition result = false; } @@ -1526,7 +1530,7 @@ private boolean checkExpression(EadventureExpression expr, List eadventureVars) { EadventureVars firstVar = getVarByName(expr.getFirstOp().getName(), eadventureVars); - // firstVar.setType(expr.getFirstOp().getType()); + // firstVar.setType(expr.getFirstOp().getType()); EadventureVars secVar = null; String operator = expr.getExpresionOp(); String value = expr.getValueIntroduced(); @@ -1586,33 +1590,37 @@ } - //TODO IMPORRRRRRRRRRRRRRRTANTE!!!!!!!!!!!!!!! el par�metro toolContentID que estamos pasando es realmente toolSessionID!!!! - //@Override + // TODO IMPORRRRRRRRRRRRRRRTANTE!!!!!!!!!!!!!!! el par�metro toolContentID que estamos pasando es realmente + // toolSessionID!!!! + // @Override @Override public boolean setAppletInput(String name, String value, String userId, String toolContentID) { - //TODO restart when + // TODO restart when EadventureServiceImpl.log.error("EEEEEEEEEEEEEEEEEE " + name); EadventureServiceImpl.log.error("EEEEEEEEEEEEEEEEEE " + value); - //EadventureServiceImpl.log.error("USER ID "+ userId); + // EadventureServiceImpl.log.error("USER ID "+ userId); EadventureServiceImpl.log.error("TOOL SESION ID " + toolContentID); EadventureServiceImpl.log.error("OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOEEEEEEEEEEEEEEEE"); - //TODO Ahora recuperamos la session para sacar el EAD!!! pero a�adir el toolContentId para que sea mas sencillo!!! - //TODO user va a sobrar!! con el userID que ya se nos pasa por par�metro vamos sobraos!! - //EadventureUser user = eadventureUserDao.getUserByUserIDAndContentID(Long.parseLong(userId), Long.parseLong(toolContentID)); - //EadventureUser user = eadventureUserDao.getUserByUserIDAndSessionID(Long.parseLong(userId), Long.parseLong(toolContentID)); - //eadventureUserDao.getUserByUserIDAndSessionID(Long.parseLong(userId), Long.parseLong(toolSessionID)); + // TODO Ahora recuperamos la session para sacar el EAD!!! pero a�adir el toolContentId para que sea mas + // sencillo!!! + // TODO user va a sobrar!! con el userID que ya se nos pasa por par�metro vamos sobraos!! + // EadventureUser user = eadventureUserDao.getUserByUserIDAndContentID(Long.parseLong(userId), + // Long.parseLong(toolContentID)); + // EadventureUser user = eadventureUserDao.getUserByUserIDAndSessionID(Long.parseLong(userId), + // Long.parseLong(toolContentID)); + // eadventureUserDao.getUserByUserIDAndSessionID(Long.parseLong(userId), Long.parseLong(toolSessionID)); EadventureServiceImpl.log.error("USER ID " + userId); EadventureSession eadSession = eadventureSessionDao.getSessionBySessionId(Long.parseLong(toolContentID)); - //Eadventure ead = eadventureDao.getByContentId(Long.parseLong(toolContentID)); + // Eadventure ead = eadventureDao.getByContentId(Long.parseLong(toolContentID)); EadventureItemVisitLog log = eadventureItemVisitDao.getEadventureItemLog(eadSession.getEadventure().getUid(), Long.parseLong(userId)); EadventureVars var = eadventureVarsDao.getEadventureVars(log.getUid(), name); if (var == null) { var = new EadventureVars(); var.setName(name); var.setVisitLog(log); - //Get the type from the params list + // Get the type from the params list var.setType(eadventureParamDao.getEadventureParamTypeByNameAndEadContentID(name, eadSession.getEadventure().getUid())); } @@ -1626,7 +1634,7 @@ return changeButton; } - //@Override + // @Override @Override public void setReportInput(String name, String value, String userId, String toolSessionID) { // TODO Auto-generated method stub @@ -1638,7 +1646,7 @@ return null; } - //@Override + // @Override @Override public EadventureItemVisitLog getEadventureItemLog(Long itemUid, Long userId) { Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/service/ForumService.java =================================================================== diff -u -rbec5d3437f63b02dcce242c16cddfe49b88daa8d -r708bd4d049ae0a59d70c964ef2f864d2b7a352e6 --- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/service/ForumService.java (.../ForumService.java) (revision bec5d3437f63b02dcce242c16cddfe49b88daa8d) +++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/service/ForumService.java (.../ForumService.java) (revision 708bd4d049ae0a59d70c964ef2f864d2b7a352e6) @@ -80,7 +80,6 @@ import org.lamsfoundation.lams.tool.ToolSessionExportOutputData; import org.lamsfoundation.lams.tool.ToolSessionManager; import org.lamsfoundation.lams.tool.exception.DataMissingException; -import org.lamsfoundation.lams.tool.exception.SessionDataExistsException; import org.lamsfoundation.lams.tool.exception.ToolException; import org.lamsfoundation.lams.tool.forum.dto.AverageRatingDTO; import org.lamsfoundation.lams.tool.forum.dto.MessageDTO; @@ -527,13 +526,14 @@ public ForumUser getUserByUserAndSession(Long userId, Long sessionId) { return forumUserDao.getByUserIdAndSessionId(userId, sessionId); } - + @Override - public List getUsersForTablesorter(final Long sessionId, int page, int size, int sorting, String searchString, - boolean getNotebookEntries) { - return forumUserDao.getUsersForTablesorter(sessionId, page, size, sorting, searchString, getNotebookEntries, coreNotebookService); + public List getUsersForTablesorter(final Long sessionId, int page, int size, int sorting, + String searchString, boolean getNotebookEntries) { + return forumUserDao.getUsersForTablesorter(sessionId, page, size, sorting, searchString, getNotebookEntries, + coreNotebookService); } - + @Override public int getCountUsersBySession(Long sessionId, String searchString) { return forumUserDao.getCountUsersBySession(sessionId, searchString); @@ -884,23 +884,26 @@ forum.setContentInUse(false); } + @SuppressWarnings("unchecked") @Override - public void removeToolContent(Long toolContentId, boolean removeSessionData) - throws SessionDataExistsException, ToolException { + public void removeToolContent(Long toolContentId) throws ToolException { Forum forum = forumDao.getByContentId(toolContentId); - if (removeSessionData) { - List list = forumToolSessionDao.getByContentId(toolContentId); - Iterator iter = list.iterator(); - while (iter.hasNext()) { - ForumToolSession session = (ForumToolSession) iter.next(); - forumToolSessionDao.delete(session); + if (forum == null) { + ForumService.log.warn("Can not remove the tool content as it does not exist, ID: " + toolContentId); + return; + } + + for (ForumToolSession session : (List) forumToolSessionDao.getByContentId(toolContentId)) { + List entries = coreNotebookService.getEntry(session.getSessionId(), + CoreNotebookConstants.NOTEBOOK_TOOL, ForumConstants.TOOL_SIGNATURE); + for (NotebookEntry entry : entries) { + coreNotebookService.deleteEntry(entry); } } forumDao.delete(forum); } @Override - @SuppressWarnings("unchecked") public void removeLearnerContent(Long toolContentId, Integer userId) throws ToolException { if (ForumService.log.isDebugEnabled()) { ForumService.log.debug( @@ -1618,8 +1621,10 @@ forum.setInstructions(toolContentJSON.getString(RestTags.INSTRUCTIONS)); forum.setAllowAnonym(JsonUtil.opt(toolContentJSON, "allowAnonym", Boolean.FALSE)); - forum.setAllowEdit(JsonUtil.opt(toolContentJSON, "allowEdit", Boolean.TRUE)); // defaults to true in the default entry in the db - forum.setAllowNewTopic(JsonUtil.opt(toolContentJSON, "allowNewTopic", Boolean.TRUE)); // defaults to true in the default entry in the db + forum.setAllowEdit(JsonUtil.opt(toolContentJSON, "allowEdit", Boolean.TRUE)); // defaults to true in the default + // entry in the db + forum.setAllowNewTopic(JsonUtil.opt(toolContentJSON, "allowNewTopic", Boolean.TRUE)); // defaults to true in the + // default entry in the db forum.setAllowRateMessages(JsonUtil.opt(toolContentJSON, "allowRateMessages", Boolean.FALSE)); forum.setAllowRichEditor(JsonUtil.opt(toolContentJSON, RestTags.ALLOW_RICH_TEXT_EDITOR, Boolean.FALSE)); forum.setAllowUpload(JsonUtil.opt(toolContentJSON, "allowUpload", Boolean.FALSE)); @@ -1628,7 +1633,8 @@ forum.setLimitedMaxCharacters(JsonUtil.opt(toolContentJSON, "limitedMaxCharacters", Boolean.TRUE)); forum.setLimitedMinCharacters(JsonUtil.opt(toolContentJSON, "limitedMinCharacters", Boolean.FALSE)); forum.setLockWhenFinished(JsonUtil.opt(toolContentJSON, "lockWhenFinished", Boolean.FALSE)); - forum.setMaxCharacters(JsonUtil.opt(toolContentJSON, "maxCharacters", 5000)); // defaults to 5000 chars in the default entry in the db. + forum.setMaxCharacters(JsonUtil.opt(toolContentJSON, "maxCharacters", 5000)); // defaults to 5000 chars in the + // default entry in the db. forum.setMaximumRate(JsonUtil.opt(toolContentJSON, "maximumRate", 0)); forum.setMaximumReply(JsonUtil.opt(toolContentJSON, "maximumReply", 0)); forum.setMinCharacters(JsonUtil.opt(toolContentJSON, "minCharacters", 0)); Index: lams_tool_gmap/src/java/org/lamsfoundation/lams/tool/gmap/service/GmapService.java =================================================================== diff -u -r0aae4208886026f429f05b458b79c14f8d7030d4 -r708bd4d049ae0a59d70c964ef2f864d2b7a352e6 --- lams_tool_gmap/src/java/org/lamsfoundation/lams/tool/gmap/service/GmapService.java (.../GmapService.java) (revision 0aae4208886026f429f05b458b79c14f8d7030d4) +++ lams_tool_gmap/src/java/org/lamsfoundation/lams/tool/gmap/service/GmapService.java (.../GmapService.java) (revision 708bd4d049ae0a59d70c964ef2f864d2b7a352e6) @@ -54,7 +54,6 @@ import org.lamsfoundation.lams.tool.ToolSessionExportOutputData; import org.lamsfoundation.lams.tool.ToolSessionManager; import org.lamsfoundation.lams.tool.exception.DataMissingException; -import org.lamsfoundation.lams.tool.exception.SessionDataExistsException; import org.lamsfoundation.lams.tool.exception.ToolException; import org.lamsfoundation.lams.tool.gmap.dao.IGmapConfigItemDAO; import org.lamsfoundation.lams.tool.gmap.dao.IGmapDAO; @@ -218,9 +217,22 @@ } @Override - public void removeToolContent(Long toolContentId, boolean removeSessionData) - throws SessionDataExistsException, ToolException { - // TODO Auto-generated method stub + public void removeToolContent(Long toolContentId) throws ToolException { + Gmap gmap = gmapDAO.getByContentId(toolContentId); + if (gmap == null) { + GmapService.logger.warn("Can not remove the tool content as it does not exist, ID: " + toolContentId); + return; + } + + for (GmapSession session : gmap.getGmapSessions()) { + List entries = coreNotebookService.getEntry(session.getSessionId(), + CoreNotebookConstants.NOTEBOOK_TOOL, GmapConstants.TOOL_SIGNATURE); + for (NotebookEntry entry : entries) { + coreNotebookService.deleteEntry(entry); + } + } + + gmapDAO.delete(gmap); } @Override Index: lams_tool_images/src/java/org/lamsfoundation/lams/tool/imageGallery/service/ImageGalleryServiceImpl.java =================================================================== diff -u -rf4176ca9f5790d0805e5142947e05b6f4d05e739 -r708bd4d049ae0a59d70c964ef2f864d2b7a352e6 --- lams_tool_images/src/java/org/lamsfoundation/lams/tool/imageGallery/service/ImageGalleryServiceImpl.java (.../ImageGalleryServiceImpl.java) (revision f4176ca9f5790d0805e5142947e05b6f4d05e739) +++ lams_tool_images/src/java/org/lamsfoundation/lams/tool/imageGallery/service/ImageGalleryServiceImpl.java (.../ImageGalleryServiceImpl.java) (revision 708bd4d049ae0a59d70c964ef2f864d2b7a352e6) @@ -68,7 +68,6 @@ import org.lamsfoundation.lams.tool.ToolSessionExportOutputData; import org.lamsfoundation.lams.tool.ToolSessionManager; import org.lamsfoundation.lams.tool.exception.DataMissingException; -import org.lamsfoundation.lams.tool.exception.SessionDataExistsException; import org.lamsfoundation.lams.tool.exception.ToolException; import org.lamsfoundation.lams.tool.imageGallery.ImageGalleryConstants; import org.lamsfoundation.lams.tool.imageGallery.dao.ImageGalleryConfigItemDAO; @@ -103,8 +102,8 @@ /** * @author Andrey Balan */ -public class ImageGalleryServiceImpl implements IImageGalleryService, ToolContentManager, ToolSessionManager, - ToolContentImport102Manager { +public class ImageGalleryServiceImpl + implements IImageGalleryService, ToolContentManager, ToolSessionManager, ToolContentImport102Manager { private final static String MEDIUM_FILENAME_PREFIX = "medium_"; @@ -223,6 +222,7 @@ saveOrUpdateImageGallery(imageGallery); } + @Override public ImageVote getImageVoteByImageAndUser(Long imageUid, Long userId) { return imageVoteDao.getImageVoteByImageAndUser(imageUid, userId); } @@ -334,7 +334,7 @@ @Override public NotebookEntry getEntry(Long sessionId, Integer idType, String signature, Integer userID) { List list = coreNotebookService.getEntry(sessionId, idType, signature, userID); - if (list == null || list.isEmpty()) { + if ((list == null) || list.isEmpty()) { return null; } else { return list.get(0); @@ -374,7 +374,8 @@ } @Override - public void saveRatingCriterias(HttpServletRequest request, Collection oldCriterias, Long toolContentId) { + public void saveRatingCriterias(HttpServletRequest request, Collection oldCriterias, + Long toolContentId) { ratingService.saveRatingCriterias(request, oldCriterias, toolContentId); } @@ -411,9 +412,10 @@ } final Long USER_ID = -1L; final boolean IS_COMMENTS_BY_OTHER_USERS_REQUIRED = true; - // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!TODO calculate average ratings based on one session data - itemRatingDtos = getRatingCriteriaDtos(contentId, itemIds, - IS_COMMENTS_BY_OTHER_USERS_REQUIRED, USER_ID); + // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!TODO calculate average ratings based on one + // session data + itemRatingDtos = getRatingCriteriaDtos(contentId, itemIds, IS_COMMENTS_BY_OTHER_USERS_REQUIRED, + USER_ID); } for (ImageGalleryItem image : groupImages) { @@ -472,7 +474,8 @@ for (ImageGalleryUser user : users) { //create UserContribution - UserImageContributionDTO userContribution = new UserImageContributionDTO(session.getSessionName(), user); + UserImageContributionDTO userContribution = new UserImageContributionDTO(session.getSessionName(), + user); if (imageGallery.isAllowVote()) { int numberOfVotesForImage = imageVoteDao.getNumImageVotesByImageUid(image.getUid(), @@ -481,7 +484,7 @@ boolean isVotedForThisImage = false; ImageVote imageVote = imageVoteDao.getImageVoteByImageAndUser(image.getUid(), user.getUserId()); - if (imageVote != null && imageVote.isVoted()) { + if ((imageVote != null) && imageVote.isVoted()) { isVotedForThisImage = true; } userContribution.setVotedForThisImage(isVotedForThisImage); @@ -491,7 +494,8 @@ // userContribution.setNumberRatings(((Long) ratingForGroup[0]).intValue()); // userContribution.setAverageRating(((Float) ratingForGroup[1]).floatValue()); -// ImageRating rating = imageRatingDao.getImageRatingByImageAndUser(image.getUid(), user.getUserId()); + // ImageRating rating = imageRatingDao.getImageRatingByImageAndUser(image.getUid(), + // user.getUserId()); // if (rating != null) { // userContribution.setRating(rating.getRating()); // } @@ -617,7 +621,8 @@ String fileName = file.getFileName(); - ImageGalleryConfigItem mediumImageDimensionsKey = getConfigItem(ImageGalleryConfigItem.KEY_MEDIUM_IMAGE_DIMENSIONS); + ImageGalleryConfigItem mediumImageDimensionsKey = getConfigItem( + ImageGalleryConfigItem.KEY_MEDIUM_IMAGE_DIMENSIONS); int mediumImageDimensions = Integer.parseInt(mediumImageDimensionsKey.getConfigValue()); // Read the original image from the repository @@ -632,7 +637,8 @@ file.getContentType()); image.setMediumFileUuid(mediumNodeKey.getUuid()); - ImageGalleryConfigItem thumbnailImageDimensionsKey = getConfigItem(ImageGalleryConfigItem.KEY_THUMBNAIL_IMAGE_DIMENSIONS); + ImageGalleryConfigItem thumbnailImageDimensionsKey = getConfigItem( + ImageGalleryConfigItem.KEY_THUMBNAIL_IMAGE_DIMENSIONS); int thumbnailImageDimensions = Integer.parseInt(thumbnailImageDimensionsKey.getConfigValue()); // Read the original image from the repository @@ -648,17 +654,17 @@ image.setThumbnailFileUuid(thumbnailNodeKey.getUuid()); } catch (RepositoryCheckedException e) { - ImageGalleryServiceImpl.log.error(messageService.getMessage("error.msg.repository.checked.exception") + ":" - + e.toString()); - throw new UploadImageGalleryFileException(messageService - .getMessage("error.msg.repository.checked.exception")); + ImageGalleryServiceImpl.log + .error(messageService.getMessage("error.msg.repository.checked.exception") + ":" + e.toString()); + throw new UploadImageGalleryFileException( + messageService.getMessage("error.msg.repository.checked.exception")); } catch (NumberFormatException e) { - ImageGalleryServiceImpl.log.error(messageService.getMessage("error.msg.number.format.exception") + ":" - + e.toString()); + ImageGalleryServiceImpl.log + .error(messageService.getMessage("error.msg.number.format.exception") + ":" + e.toString()); throw new UploadImageGalleryFileException(messageService.getMessage("error.msg.number.format.exception")); } catch (IOException e) { - ImageGalleryServiceImpl.log.error(messageService.getMessage("error.msg.io.exception.resizing") + ":" - + e.toString()); + ImageGalleryServiceImpl.log + .error(messageService.getMessage("error.msg.io.exception.resizing") + ":" + e.toString()); throw new ImageGalleryException(messageService.getMessage("error.msg.io.exception.resizing")); } } @@ -838,8 +844,8 @@ Object toolPOJO = exportContentService.importToolContent(toolContentPath, imageGalleryToolContentHandler, fromVersion, toVersion); if (!(toolPOJO instanceof ImageGallery)) { - throw new ImportToolContentException("Import ImageGallery tool content failed. Deserialized object is " - + toolPOJO); + throw new ImportToolContentException( + "Import ImageGallery tool content failed. Deserialized object is " + toolPOJO); } ImageGallery toolContentObj = (ImageGallery) toolPOJO; @@ -955,29 +961,36 @@ } @Override - public void removeToolContent(Long toolContentId, boolean removeSessionData) throws SessionDataExistsException, - ToolException { + public void removeToolContent(Long toolContentId) throws ToolException { ImageGallery imageGallery = imageGalleryDao.getByContentId(toolContentId); - if (removeSessionData) { - List list = imageGallerySessionDao.getByContentId(toolContentId); - Iterator iter = list.iterator(); - while (iter.hasNext()) { - ImageGallerySession session = (ImageGallerySession) iter.next(); - imageGallerySessionDao.delete(session); + if (imageGallery == null) { + ImageGalleryServiceImpl.log + .warn("Can not remove the tool content as it does not exist, ID: " + toolContentId); + return; + } + + for (ImageGallerySession session : imageGallerySessionDao.getByContentId(toolContentId)) { + List entries = coreNotebookService.getEntry(session.getSessionId(), + CoreNotebookConstants.NOTEBOOK_TOOL, ImageGalleryConstants.TOOL_SIGNATURE); + for (NotebookEntry entry : entries) { + coreNotebookService.deleteEntry(entry); } } + imageGalleryDao.delete(imageGallery); } @Override @SuppressWarnings("unchecked") public void removeLearnerContent(Long toolContentId, Integer userId) throws ToolException { - if (log.isDebugEnabled()) { - log.debug("Removing Image Gallery content for user ID " + userId + " and toolContentId " + toolContentId); + if (ImageGalleryServiceImpl.log.isDebugEnabled()) { + ImageGalleryServiceImpl.log.debug( + "Removing Image Gallery content for user ID " + userId + " and toolContentId " + toolContentId); } ImageGallery gallery = imageGalleryDao.getByContentId(toolContentId); if (gallery == null) { - log.warn("Did not find activity with toolContentId: " + toolContentId + " to remove learner content"); + ImageGalleryServiceImpl.log + .warn("Did not find activity with toolContentId: " + toolContentId + " to remove learner content"); return; } @@ -1058,13 +1071,14 @@ } @Override - public ToolSessionExportOutputData exportToolSession(Long toolSessionId) throws DataMissingException, ToolException { + public ToolSessionExportOutputData exportToolSession(Long toolSessionId) + throws DataMissingException, ToolException { return null; } @Override - public ToolSessionExportOutputData exportToolSession(List toolSessionIds) throws DataMissingException, - ToolException { + public ToolSessionExportOutputData exportToolSession(List toolSessionIds) + throws DataMissingException, ToolException { return null; } @@ -1093,12 +1107,14 @@ /** * Import the data for a 1.0.2 Noticeboard or HTMLNoticeboard */ + @Override 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 { + @Override + public void setReflectiveData(Long toolContentId, String title, String description) + throws ToolException, DataMissingException { ImageGallery toolContentObj = getImageGalleryByContentId(toolContentId); if (toolContentObj == null) { @@ -1211,6 +1227,7 @@ return contentId; } + @Override public Class[] getSupportedToolOutputDefinitionClasses(int definitionType) { return getImageGalleryOutputFactory().getSupportedDefinitionClasses(definitionType); } Index: lams_tool_imscc/src/java/org/lamsfoundation/lams/tool/commonCartridge/service/CommonCartridgeServiceImpl.java =================================================================== diff -u -r0aae4208886026f429f05b458b79c14f8d7030d4 -r708bd4d049ae0a59d70c964ef2f864d2b7a352e6 --- lams_tool_imscc/src/java/org/lamsfoundation/lams/tool/commonCartridge/service/CommonCartridgeServiceImpl.java (.../CommonCartridgeServiceImpl.java) (revision 0aae4208886026f429f05b458b79c14f8d7030d4) +++ lams_tool_imscc/src/java/org/lamsfoundation/lams/tool/commonCartridge/service/CommonCartridgeServiceImpl.java (.../CommonCartridgeServiceImpl.java) (revision 708bd4d049ae0a59d70c964ef2f864d2b7a352e6) @@ -87,7 +87,6 @@ import org.lamsfoundation.lams.tool.commonCartridge.util.CommonCartridgeToolContentHandler; import org.lamsfoundation.lams.tool.commonCartridge.util.ReflectDTOComparator; import org.lamsfoundation.lams.tool.exception.DataMissingException; -import org.lamsfoundation.lams.tool.exception.SessionDataExistsException; import org.lamsfoundation.lams.tool.exception.ToolException; import org.lamsfoundation.lams.tool.service.ILamsToolService; import org.lamsfoundation.lams.usermanagement.User; @@ -946,15 +945,19 @@ } @Override - public void removeToolContent(Long toolContentId, boolean removeSessionData) - throws SessionDataExistsException, ToolException { + public void removeToolContent(Long toolContentId) throws ToolException { CommonCartridge commonCartridge = commonCartridgeDao.getByContentId(toolContentId); - if (removeSessionData) { - List list = commonCartridgeSessionDao.getByContentId(toolContentId); - Iterator iter = list.iterator(); - while (iter.hasNext()) { - CommonCartridgeSession session = (CommonCartridgeSession) iter.next(); - commonCartridgeSessionDao.delete(session); + if (commonCartridge == null) { + CommonCartridgeServiceImpl.log + .warn("Can not remove the tool content as it does not exist, ID: " + toolContentId); + return; + } + + for (CommonCartridgeSession session : commonCartridgeSessionDao.getByContentId(toolContentId)) { + List entries = coreNotebookService.getEntry(session.getSessionId(), + CoreNotebookConstants.NOTEBOOK_TOOL, CommonCartridgeConstants.TOOL_SIGNATURE); + for (NotebookEntry entry : entries) { + coreNotebookService.deleteEntry(entry); } } commonCartridgeDao.delete(commonCartridge); Index: lams_tool_kaltura/src/java/org/lamsfoundation/lams/tool/kaltura/service/KalturaService.java =================================================================== diff -u -r0aae4208886026f429f05b458b79c14f8d7030d4 -r708bd4d049ae0a59d70c964ef2f864d2b7a352e6 --- lams_tool_kaltura/src/java/org/lamsfoundation/lams/tool/kaltura/service/KalturaService.java (.../KalturaService.java) (revision 0aae4208886026f429f05b458b79c14f8d7030d4) +++ lams_tool_kaltura/src/java/org/lamsfoundation/lams/tool/kaltura/service/KalturaService.java (.../KalturaService.java) (revision 708bd4d049ae0a59d70c964ef2f864d2b7a352e6) @@ -50,7 +50,6 @@ import org.lamsfoundation.lams.tool.ToolSessionExportOutputData; import org.lamsfoundation.lams.tool.ToolSessionManager; import org.lamsfoundation.lams.tool.exception.DataMissingException; -import org.lamsfoundation.lams.tool.exception.SessionDataExistsException; import org.lamsfoundation.lams.tool.exception.ToolException; import org.lamsfoundation.lams.tool.kaltura.dao.IKalturaCommentDAO; import org.lamsfoundation.lams.tool.kaltura.dao.IKalturaDAO; @@ -233,9 +232,24 @@ kalturaDao.saveOrUpdate(kaltura); } + @SuppressWarnings("unchecked") @Override - public void removeToolContent(Long toolContentId, boolean removeSessionData) - throws SessionDataExistsException, ToolException { + public void removeToolContent(Long toolContentId) throws ToolException { + Kaltura kaltura = kalturaDao.getByContentId(toolContentId); + if (kaltura == null) { + KalturaService.logger.warn("Can not remove the tool content as it does not exist, ID: " + toolContentId); + return; + } + + for (KalturaSession session : (Set) kaltura.getKalturaSessions()) { + List entries = coreNotebookService.getEntry(session.getSessionId(), + CoreNotebookConstants.NOTEBOOK_TOOL, KalturaConstants.TOOL_SIGNATURE); + for (NotebookEntry entry : entries) { + coreNotebookService.deleteEntry(entry); + } + } + + kalturaDao.delete(kaltura); } @Override Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/IMcService.java =================================================================== diff -u -r1a02559e19419af9991eaeb9363f809355b39bc7 -r708bd4d049ae0a59d70c964ef2f864d2b7a352e6 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/IMcService.java (.../IMcService.java) (revision 1a02559e19419af9991eaeb9363f809355b39bc7) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/IMcService.java (.../IMcService.java) (revision 708bd4d049ae0a59d70c964ef2f864d2b7a352e6) @@ -128,9 +128,6 @@ void copyToolContent(Long fromContentId, Long toContentId) throws ToolException; - void removeToolContent(Long toolContentId, boolean removeSessionData) throws SessionDataExistsException, - ToolException; - boolean existsSession(Long toolSessionId); void createToolSession(Long toolSessionId, String toolSessionName, Long toolContentId) throws ToolException; Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/McServicePOJO.java =================================================================== diff -u -rbab1a8a3e84314de4488aaedc063b39f806ce2c5 -r708bd4d049ae0a59d70c964ef2f864d2b7a352e6 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/McServicePOJO.java (.../McServicePOJO.java) (revision bab1a8a3e84314de4488aaedc063b39f806ce2c5) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/McServicePOJO.java (.../McServicePOJO.java) (revision 708bd4d049ae0a59d70c964ef2f864d2b7a352e6) @@ -74,7 +74,6 @@ import org.lamsfoundation.lams.tool.ToolSessionExportOutputData; import org.lamsfoundation.lams.tool.ToolSessionManager; import org.lamsfoundation.lams.tool.exception.DataMissingException; -import org.lamsfoundation.lams.tool.exception.SessionDataExistsException; import org.lamsfoundation.lams.tool.exception.ToolException; import org.lamsfoundation.lams.tool.mc.McAppConstants; import org.lamsfoundation.lams.tool.mc.McApplicationException; @@ -1237,38 +1236,24 @@ } } + @SuppressWarnings("unchecked") @Override - public void removeToolContent(Long toolContentId, boolean removeSessionData) - throws SessionDataExistsException, ToolException { - - if (toolContentId == null) { - McServicePOJO.logger.error("toolContentId is null"); - throw new ToolException("toolContentId is missing"); + public void removeToolContent(Long toolContentId) throws ToolException { + McContent mcContent = mcContentDAO.findMcContentById(toolContentId); + if (mcContent == null) { + McServicePOJO.logger.warn("Can not remove the tool content as it does not exist, ID: " + toolContentId); + return; } - McContent mcContent = mcContentDAO.findMcContentById(toolContentId); - - if (mcContent != null) { - Iterator sessionIterator = mcContent.getMcSessions().iterator(); - while (sessionIterator.hasNext()) { - if (removeSessionData == false) { - throw new SessionDataExistsException(); - } - - McSession mcSession = (McSession) sessionIterator.next(); - - Iterator sessionUsersIterator = mcSession.getMcQueUsers().iterator(); - while (sessionUsersIterator.hasNext()) { - McQueUsr mcQueUsr = (McQueUsr) sessionUsersIterator.next(); - - mcUsrAttemptDAO.removeAllUserAttempts(mcQueUsr.getUid()); - } + for (McSession session : (Set) mcContent.getMcSessions()) { + List entries = coreNotebookService.getEntry(session.getMcSessionId(), + CoreNotebookConstants.NOTEBOOK_TOOL, McAppConstants.MY_SIGNATURE); + for (NotebookEntry entry : entries) { + coreNotebookService.deleteEntry(entry); } - mcContentDAO.removeMcById(toolContentId); - } else { - McServicePOJO.logger.error("Warning!!!, We should have not come here. mcContent is null."); - throw new ToolException("toolContentId is missing"); } + + mcContentDAO.delete(mcContent); } @Override Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaServicePOJO.java =================================================================== diff -u -r8afb8434b5d3f27f2ff413a62b02c92b6cc32f24 -r708bd4d049ae0a59d70c964ef2f864d2b7a352e6 --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaServicePOJO.java (.../QaServicePOJO.java) (revision 8afb8434b5d3f27f2ff413a62b02c92b6cc32f24) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaServicePOJO.java (.../QaServicePOJO.java) (revision 708bd4d049ae0a59d70c964ef2f864d2b7a352e6) @@ -68,7 +68,6 @@ import org.lamsfoundation.lams.tool.ToolSessionExportOutputData; import org.lamsfoundation.lams.tool.ToolSessionManager; import org.lamsfoundation.lams.tool.exception.DataMissingException; -import org.lamsfoundation.lams.tool.exception.SessionDataExistsException; import org.lamsfoundation.lams.tool.exception.ToolException; import org.lamsfoundation.lams.tool.qa.QaAppConstants; import org.lamsfoundation.lams.tool.qa.QaCondition; @@ -308,9 +307,10 @@ } @Override - public List getResponsesForTablesorter(final Long toolContentId, final Long qaSessionId, final Long questionId, - final Long excludeUserId, int page, int size, int sorting, String searchString) { - return qaUsrRespDAO.getResponsesForTablesorter(toolContentId, qaSessionId, questionId, excludeUserId, page, size, sorting, searchString); + public List getResponsesForTablesorter(final Long toolContentId, final Long qaSessionId, + final Long questionId, final Long excludeUserId, int page, int size, int sorting, String searchString) { + return qaUsrRespDAO.getResponsesForTablesorter(toolContentId, qaSessionId, questionId, excludeUserId, page, + size, sorting, searchString); } @Override @@ -549,43 +549,24 @@ } + @SuppressWarnings("unchecked") @Override - public void removeToolContent(Long toolContentID, boolean removeSessionData) - throws SessionDataExistsException, ToolException { - if (toolContentID == null) { - throw new ToolException("toolContentID is missing"); + public void removeToolContent(Long toolContentId) throws ToolException { + QaContent qaContent = qaDAO.getQaByContentId(toolContentId.longValue()); + if (qaContent == null) { + QaServicePOJO.logger.warn("Can not remove the tool content as it does not exist, ID: " + toolContentId); + return; } - QaContent qaContent = qaDAO.getQaByContentId(toolContentID.longValue()); - - if (qaContent != null) { - Iterator sessionIterator = qaContent.getQaSessions().iterator(); - while (sessionIterator.hasNext()) { - if (removeSessionData == false) { - QaServicePOJO.logger.error("removeSessionData is false, throwing SessionDataExistsException."); - throw new SessionDataExistsException(); - } - - QaSession qaSession = (QaSession) sessionIterator.next(); - - Iterator sessionUsersIterator = qaSession.getQaQueUsers().iterator(); - while (sessionUsersIterator.hasNext()) { - QaQueUsr qaQueUsr = (QaQueUsr) sessionUsersIterator.next(); - - Iterator sessionUsersResponsesIterator = qaQueUsr.getQaUsrResps().iterator(); - while (sessionUsersResponsesIterator.hasNext()) { - QaUsrResp qaUsrResp = (QaUsrResp) sessionUsersResponsesIterator.next(); - removeUserResponse(qaUsrResp); - } - } + for (QaSession session : (Set) qaContent.getQaSessions()) { + List entries = coreNotebookService.getEntry(session.getQaSessionId(), + CoreNotebookConstants.NOTEBOOK_TOOL, QaAppConstants.MY_SIGNATURE); + for (NotebookEntry entry : entries) { + coreNotebookService.deleteEntry(entry); } - - // removed all existing responses of toolContent with toolContentID - qaDAO.removeQa(toolContentID); - } else { - QaServicePOJO.logger.error("Warning!!!, We should have not come here. qaContent is null."); - throw new ToolException("toolContentID is missing"); } + + qaDAO.removeQa(toolContentId); } @Override Index: lams_tool_larsrc/src/java/org/lamsfoundation/lams/tool/rsrc/service/ResourceServiceImpl.java =================================================================== diff -u -r08265d215705dc3f7e56e5cb4793bd28045a778b -r708bd4d049ae0a59d70c964ef2f864d2b7a352e6 --- lams_tool_larsrc/src/java/org/lamsfoundation/lams/tool/rsrc/service/ResourceServiceImpl.java (.../ResourceServiceImpl.java) (revision 08265d215705dc3f7e56e5cb4793bd28045a778b) +++ lams_tool_larsrc/src/java/org/lamsfoundation/lams/tool/rsrc/service/ResourceServiceImpl.java (.../ResourceServiceImpl.java) (revision 708bd4d049ae0a59d70c964ef2f864d2b7a352e6) @@ -79,17 +79,16 @@ import org.lamsfoundation.lams.tool.ToolSessionExportOutputData; import org.lamsfoundation.lams.tool.ToolSessionManager; import org.lamsfoundation.lams.tool.exception.DataMissingException; -import org.lamsfoundation.lams.tool.exception.SessionDataExistsException; import org.lamsfoundation.lams.tool.exception.ToolException; import org.lamsfoundation.lams.tool.rsrc.ResourceConstants; import org.lamsfoundation.lams.tool.rsrc.dao.ResourceDAO; import org.lamsfoundation.lams.tool.rsrc.dao.ResourceItemDAO; import org.lamsfoundation.lams.tool.rsrc.dao.ResourceItemVisitDAO; import org.lamsfoundation.lams.tool.rsrc.dao.ResourceSessionDAO; import org.lamsfoundation.lams.tool.rsrc.dao.ResourceUserDAO; -import org.lamsfoundation.lams.tool.rsrc.dto.SessionDTO; -import org.lamsfoundation.lams.tool.rsrc.dto.ResourceItemDTO; import org.lamsfoundation.lams.tool.rsrc.dto.ReflectDTO; +import org.lamsfoundation.lams.tool.rsrc.dto.ResourceItemDTO; +import org.lamsfoundation.lams.tool.rsrc.dto.SessionDTO; import org.lamsfoundation.lams.tool.rsrc.dto.VisitLogDTO; import org.lamsfoundation.lams.tool.rsrc.ims.IContentPackageConverter; import org.lamsfoundation.lams.tool.rsrc.ims.IMSManifestException; @@ -588,8 +587,8 @@ @Override public List getPagedVisitLogsBySessionAndItem(Long sessionId, Long itemUid, int page, int size, String sortBy, String sortOrder, String searchString) { - return resourceItemVisitDao.getPagedVisitLogsBySessionAndItem(sessionId, itemUid, page, size, sortBy, - sortOrder, searchString); + return resourceItemVisitDao.getPagedVisitLogsBySessionAndItem(sessionId, itemUid, page, size, sortBy, sortOrder, + searchString); } @Override @@ -982,15 +981,18 @@ } @Override - public void removeToolContent(Long toolContentId, boolean removeSessionData) - throws SessionDataExistsException, ToolException { + public void removeToolContent(Long toolContentId) throws ToolException { Resource resource = resourceDao.getByContentId(toolContentId); - if (removeSessionData) { - List list = resourceSessionDao.getByContentId(toolContentId); - Iterator iter = list.iterator(); - while (iter.hasNext()) { - ResourceSession session = (ResourceSession) iter.next(); - resourceSessionDao.delete(session); + if (resource == null) { + ResourceServiceImpl.log.warn("Can not remove the tool content as it does not exist, ID: " + toolContentId); + return; + } + + for (ResourceSession session : resourceSessionDao.getByContentId(toolContentId)) { + List entries = coreNotebookService.getEntry(session.getSessionId(), + CoreNotebookConstants.NOTEBOOK_TOOL, ResourceConstants.TOOL_SIGNATURE); + for (NotebookEntry entry : entries) { + coreNotebookService.deleteEntry(entry); } } resourceDao.delete(resource); Index: lams_tool_leader/src/java/org/lamsfoundation/lams/tool/leaderselection/service/LeaderselectionService.java =================================================================== diff -u -r0aae4208886026f429f05b458b79c14f8d7030d4 -r708bd4d049ae0a59d70c964ef2f864d2b7a352e6 --- lams_tool_leader/src/java/org/lamsfoundation/lams/tool/leaderselection/service/LeaderselectionService.java (.../LeaderselectionService.java) (revision 0aae4208886026f429f05b458b79c14f8d7030d4) +++ lams_tool_leader/src/java/org/lamsfoundation/lams/tool/leaderselection/service/LeaderselectionService.java (.../LeaderselectionService.java) (revision 708bd4d049ae0a59d70c964ef2f864d2b7a352e6) @@ -46,6 +46,7 @@ import org.lamsfoundation.lams.learningdesign.service.IExportToolContentService; import org.lamsfoundation.lams.learningdesign.service.ImportToolContentException; import org.lamsfoundation.lams.notebook.model.NotebookEntry; +import org.lamsfoundation.lams.notebook.service.CoreNotebookConstants; import org.lamsfoundation.lams.notebook.service.ICoreNotebookService; import org.lamsfoundation.lams.rest.RestTags; import org.lamsfoundation.lams.rest.ToolRestManager; @@ -56,7 +57,6 @@ import org.lamsfoundation.lams.tool.ToolSessionExportOutputData; import org.lamsfoundation.lams.tool.ToolSessionManager; import org.lamsfoundation.lams.tool.exception.DataMissingException; -import org.lamsfoundation.lams.tool.exception.SessionDataExistsException; import org.lamsfoundation.lams.tool.exception.ToolException; import org.lamsfoundation.lams.tool.leaderselection.dao.ILeaderselectionDAO; import org.lamsfoundation.lams.tool.leaderselection.dao.ILeaderselectionSessionDAO; @@ -198,9 +198,24 @@ leaderselectionDAO.saveOrUpdate(content); } + @SuppressWarnings("unchecked") @Override - public void removeToolContent(Long toolContentId, boolean removeSessionData) - throws SessionDataExistsException, ToolException { + public void removeToolContent(Long toolContentId) throws ToolException { + Leaderselection content = leaderselectionDAO.getByContentId(toolContentId); + if (content == null) { + LeaderselectionService.logger + .warn("Can not remove the tool content as it does not exist, ID: " + toolContentId); + return; + } + for (LeaderselectionSession session : (Set) content.getLeaderselectionSessions()) { + List entries = coreNotebookService.getEntry(session.getSessionId(), + CoreNotebookConstants.NOTEBOOK_TOOL, LeaderselectionConstants.TOOL_SIGNATURE); + for (NotebookEntry entry : entries) { + coreNotebookService.deleteEntry(entry); + } + } + + leaderselectionDAO.delete(content); } @Override Index: lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/service/MindmapService.java =================================================================== diff -u -r0aae4208886026f429f05b458b79c14f8d7030d4 -r708bd4d049ae0a59d70c964ef2f864d2b7a352e6 --- lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/service/MindmapService.java (.../MindmapService.java) (revision 0aae4208886026f429f05b458b79c14f8d7030d4) +++ lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/service/MindmapService.java (.../MindmapService.java) (revision 708bd4d049ae0a59d70c964ef2f864d2b7a352e6) @@ -42,6 +42,7 @@ import org.lamsfoundation.lams.learningdesign.service.IExportToolContentService; import org.lamsfoundation.lams.learningdesign.service.ImportToolContentException; import org.lamsfoundation.lams.notebook.model.NotebookEntry; +import org.lamsfoundation.lams.notebook.service.CoreNotebookConstants; import org.lamsfoundation.lams.notebook.service.ICoreNotebookService; import org.lamsfoundation.lams.rest.RestTags; import org.lamsfoundation.lams.rest.ToolRestManager; @@ -398,10 +399,24 @@ mindmapDAO.saveOrUpdate(mindmap); } + @SuppressWarnings("unchecked") @Override - public void removeToolContent(Long toolContentId, boolean removeSessionData) - throws SessionDataExistsException, ToolException { - // TODO Auto-generated method stub + public void removeToolContent(Long toolContentId) throws SessionDataExistsException, ToolException { + Mindmap mindmap = mindmapDAO.getByContentId(toolContentId); + if (mindmap == null) { + MindmapService.logger.warn("Can not remove the tool content as it does not exist, ID: " + toolContentId); + return; + } + + for (MindmapSession session : (Set) mindmap.getMindmapSessions()) { + List entries = coreNotebookService.getEntry(session.getSessionId(), + CoreNotebookConstants.NOTEBOOK_TOOL, MindmapConstants.TOOL_SIGNATURE); + for (NotebookEntry entry : entries) { + coreNotebookService.deleteEntry(entry); + } + } + + mindmapDAO.delete(mindmap); } @Override Index: lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/service/NoticeboardServicePOJO.java =================================================================== diff -u -r0aae4208886026f429f05b458b79c14f8d7030d4 -r708bd4d049ae0a59d70c964ef2f864d2b7a352e6 --- lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/service/NoticeboardServicePOJO.java (.../NoticeboardServicePOJO.java) (revision 0aae4208886026f429f05b458b79c14f8d7030d4) +++ lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/service/NoticeboardServicePOJO.java (.../NoticeboardServicePOJO.java) (revision 708bd4d049ae0a59d70c964ef2f864d2b7a352e6) @@ -53,7 +53,6 @@ import org.lamsfoundation.lams.tool.ToolSessionExportOutputData; import org.lamsfoundation.lams.tool.ToolSessionManager; import org.lamsfoundation.lams.tool.exception.DataMissingException; -import org.lamsfoundation.lams.tool.exception.SessionDataExistsException; import org.lamsfoundation.lams.tool.exception.ToolException; import org.lamsfoundation.lams.tool.noticeboard.NbApplicationException; import org.lamsfoundation.lams.tool.noticeboard.NoticeboardConstants; @@ -329,15 +328,22 @@ } @Override - public void removeToolContent(Long toolContentId, boolean removeSessionData) - throws SessionDataExistsException, ToolException { - NoticeboardContent nbContent = getAndCheckIDandObject(toolContentId); - // if session data exist and removeSessionData=false, throw an exception - if (!nbContent.getNbSessions().isEmpty() && !removeSessionData) { - throw new SessionDataExistsException( - "Delete failed: There is session data that belongs to this tool content id"); + public void removeToolContent(Long toolContentId) throws ToolException { + NoticeboardContent nbContent = retrieveNoticeboard(toolContentId); + if (nbContent == null) { + NoticeboardServicePOJO.log + .warn("Can not remove the tool content as it does not exist, ID: " + toolContentId); + return; } + for (NoticeboardSession session : nbContent.getNbSessions()) { + List entries = coreNotebookService.getEntry(session.getNbSessionId(), + CoreNotebookConstants.NOTEBOOK_TOOL, NoticeboardConstants.TOOL_SIGNATURE); + for (NotebookEntry entry : entries) { + coreNotebookService.deleteEntry(entry); + } + } + removeNoticeboard(toolContentId); } Index: lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/service/NotebookService.java =================================================================== diff -u -r0aae4208886026f429f05b458b79c14f8d7030d4 -r708bd4d049ae0a59d70c964ef2f864d2b7a352e6 --- lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/service/NotebookService.java (.../NotebookService.java) (revision 0aae4208886026f429f05b458b79c14f8d7030d4) +++ lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/service/NotebookService.java (.../NotebookService.java) (revision 708bd4d049ae0a59d70c964ef2f864d2b7a352e6) @@ -42,6 +42,7 @@ import org.lamsfoundation.lams.learningdesign.service.IExportToolContentService; import org.lamsfoundation.lams.learningdesign.service.ImportToolContentException; import org.lamsfoundation.lams.notebook.model.NotebookEntry; +import org.lamsfoundation.lams.notebook.service.CoreNotebookConstants; import org.lamsfoundation.lams.notebook.service.ICoreNotebookService; import org.lamsfoundation.lams.rest.RestTags; import org.lamsfoundation.lams.rest.ToolRestManager; @@ -52,7 +53,6 @@ import org.lamsfoundation.lams.tool.ToolSessionExportOutputData; import org.lamsfoundation.lams.tool.ToolSessionManager; import org.lamsfoundation.lams.tool.exception.DataMissingException; -import org.lamsfoundation.lams.tool.exception.SessionDataExistsException; import org.lamsfoundation.lams.tool.exception.ToolException; import org.lamsfoundation.lams.tool.notebook.dao.INotebookDAO; import org.lamsfoundation.lams.tool.notebook.dao.INotebookSessionDAO; @@ -203,10 +203,24 @@ notebook.setDefineLater(false); notebookDAO.saveOrUpdate(notebook); } - + @Override - public void removeToolContent(Long toolContentId, boolean removeSessionData) - throws SessionDataExistsException, ToolException { + public void removeToolContent(Long toolContentId) throws ToolException { + Notebook notebook = notebookDAO.getByContentId(toolContentId); + if (notebook == null) { + NotebookService.logger.warn("Can not remove the tool content as it does not exist, ID: " + toolContentId); + return; + } + + for (NotebookSession session : (Set) notebook.getNotebookSessions()) { + List entries = coreNotebookService.getEntry(session.getSessionId(), + CoreNotebookConstants.NOTEBOOK_TOOL, NotebookConstants.TOOL_SIGNATURE); + for (NotebookEntry entry : entries) { + coreNotebookService.deleteEntry(entry); + } + } + + notebookDAO.delete(notebook); } @Override Index: lams_tool_pixlr/src/java/org/lamsfoundation/lams/tool/pixlr/service/PixlrService.java =================================================================== diff -u -r0aae4208886026f429f05b458b79c14f8d7030d4 -r708bd4d049ae0a59d70c964ef2f864d2b7a352e6 --- lams_tool_pixlr/src/java/org/lamsfoundation/lams/tool/pixlr/service/PixlrService.java (.../PixlrService.java) (revision 0aae4208886026f429f05b458b79c14f8d7030d4) +++ lams_tool_pixlr/src/java/org/lamsfoundation/lams/tool/pixlr/service/PixlrService.java (.../PixlrService.java) (revision 708bd4d049ae0a59d70c964ef2f864d2b7a352e6) @@ -255,9 +255,22 @@ } @Override - public void removeToolContent(Long toolContentId, boolean removeSessionData) - throws SessionDataExistsException, ToolException { - // TODO Auto-generated method stub + public void removeToolContent(Long toolContentId) throws SessionDataExistsException, ToolException { + Pixlr pixlr = pixlrDAO.getByContentId(toolContentId); + if (pixlr == null) { + PixlrService.logger.warn("Can not remove the tool content as it does not exist, ID: " + toolContentId); + return; + } + + for (PixlrSession session : pixlr.getPixlrSessions()) { + List entries = coreNotebookService.getEntry(session.getSessionId(), + CoreNotebookConstants.NOTEBOOK_TOOL, PixlrConstants.TOOL_SIGNATURE); + for (NotebookEntry entry : entries) { + coreNotebookService.deleteEntry(entry); + } + } + + pixlrDAO.delete(pixlr); } @Override Index: lams_tool_preview/src/java/org/lamsfoundation/lams/tool/peerreview/service/PeerreviewServiceImpl.java =================================================================== diff -u -r9fc998daa072351bbb64ed9d16a1c571c8136b64 -r708bd4d049ae0a59d70c964ef2f864d2b7a352e6 --- lams_tool_preview/src/java/org/lamsfoundation/lams/tool/peerreview/service/PeerreviewServiceImpl.java (.../PeerreviewServiceImpl.java) (revision 9fc998daa072351bbb64ed9d16a1c571c8136b64) +++ lams_tool_preview/src/java/org/lamsfoundation/lams/tool/peerreview/service/PeerreviewServiceImpl.java (.../PeerreviewServiceImpl.java) (revision 708bd4d049ae0a59d70c964ef2f864d2b7a352e6) @@ -63,7 +63,6 @@ import org.lamsfoundation.lams.tool.ToolSessionExportOutputData; import org.lamsfoundation.lams.tool.ToolSessionManager; import org.lamsfoundation.lams.tool.exception.DataMissingException; -import org.lamsfoundation.lams.tool.exception.SessionDataExistsException; import org.lamsfoundation.lams.tool.exception.ToolException; import org.lamsfoundation.lams.tool.peerreview.PeerreviewConstants; import org.lamsfoundation.lams.tool.peerreview.dao.PeerreviewDAO; @@ -249,8 +248,8 @@ if (entry != null) { ReflectDTO ref = new ReflectDTO(user); ref.setReflect(entry.getEntry()); - Date postedDate = (entry.getLastModified() != null) ? entry.getLastModified() : entry - .getCreateDate(); + Date postedDate = (entry.getLastModified() != null) ? entry.getLastModified() + : entry.getCreateDate(); ref.setDate(postedDate); reflections.add(ref); } @@ -263,8 +262,8 @@ } @Override - public List getUsersForTablesorter(final Long toolSessionId, final Long excludeUserId, - int page, int size, int sorting) { + public List getUsersForTablesorter(final Long toolSessionId, final Long excludeUserId, int page, + int size, int sorting) { return peerreviewUserDao.getUsersForTablesorter(toolSessionId, excludeUserId, page, size, sorting); } @@ -283,7 +282,7 @@ @Override public NotebookEntry getEntry(Long sessionId, Integer idType, String signature, Integer userID) { List list = coreNotebookService.getEntry(sessionId, idType, signature, userID); - if (list == null || list.isEmpty()) { + if ((list == null) || list.isEmpty()) { return null; } else { return list.get(0); @@ -355,7 +354,8 @@ } catch (Throwable e) { creatingUsersForSessionIds.remove(toolSessionId); String message = e.getMessage() != null ? e.getMessage() : e.getClass().getName(); - log.error("Exception thrown creating Peer Review users for session " + toolSessionId + " user id: " + PeerreviewServiceImpl.log + .error("Exception thrown creating Peer Review users for session " + toolSessionId + " user id: " + (currentUser != null ? currentUser.getUserId().toString() : "null") + "; " + message, e); e.printStackTrace(); throw (e); @@ -536,30 +536,37 @@ } @Override - public void removeToolContent(Long toolContentId, boolean removeSessionData) throws SessionDataExistsException, - ToolException { + public void removeToolContent(Long toolContentId) throws ToolException { Peerreview peerreview = peerreviewDao.getByContentId(toolContentId); - if (removeSessionData) { - List list = peerreviewSessionDao.getByContentId(toolContentId); - Iterator iter = list.iterator(); - while (iter.hasNext()) { - PeerreviewSession session = (PeerreviewSession) iter.next(); - peerreviewSessionDao.delete(session); + if (peerreview == null) { + PeerreviewServiceImpl.log + .warn("Can not remove the tool content as it does not exist, ID: " + toolContentId); + return; + } + + for (PeerreviewSession session : peerreviewSessionDao.getByContentId(toolContentId)) { + List entries = coreNotebookService.getEntry(session.getSessionId(), + CoreNotebookConstants.NOTEBOOK_TOOL, PeerreviewConstants.TOOL_SIGNATURE); + for (NotebookEntry entry : entries) { + coreNotebookService.deleteEntry(entry); } } + peerreviewDao.delete(peerreview); } @Override @SuppressWarnings("unchecked") public void removeLearnerContent(Long toolContentId, Integer userId) throws ToolException { - if (log.isDebugEnabled()) { - log.debug("Removing Peerreview content for user ID " + userId + " and toolContentId " + toolContentId); + if (PeerreviewServiceImpl.log.isDebugEnabled()) { + PeerreviewServiceImpl.log + .debug("Removing Peerreview content for user ID " + userId + " and toolContentId " + toolContentId); } Peerreview peerreview = peerreviewDao.getByContentId(toolContentId); if (peerreview == null) { - log.warn("Did not find activity with toolContentId: " + toolContentId + " to remove learner content"); + PeerreviewServiceImpl.log + .warn("Did not find activity with toolContentId: " + toolContentId + " to remove learner content"); return; } @@ -618,7 +625,8 @@ } @Override - public void saveRatingCriterias(HttpServletRequest request, Collection oldCriterias, Long toolContentId) { + public void saveRatingCriterias(HttpServletRequest request, Collection oldCriterias, + Long toolContentId) { ratingService.saveRatingCriterias(request, oldCriterias, toolContentId); } @@ -633,7 +641,8 @@ } @Override - public List getRatingCriteriaDtos(Long contentId, Collection itemIds, boolean isCommentsByOtherUsersRequired, Long userId) { + public List getRatingCriteriaDtos(Long contentId, Collection itemIds, + boolean isCommentsByOtherUsersRequired, Long userId) { return ratingService.getRatingCriteriaDtos(contentId, itemIds, isCommentsByOtherUsersRequired, userId); } @@ -649,7 +658,8 @@ userId); if (isCountUsersRatedEachItem) { - Map itemIdToRatedUsersCountMap = ratingService.countUsersRatedEachItem(contentId, itemIds, userId.intValue()); + Map itemIdToRatedUsersCountMap = ratingService.countUsersRatedEachItem(contentId, itemIds, + userId.intValue()); for (ItemRatingDTO itemRatingDTO : itemRatingDTOs) { Long itemId = itemRatingDTO.getItemId(); @@ -668,13 +678,14 @@ } @Override - public ToolSessionExportOutputData exportToolSession(Long toolSessionId) throws DataMissingException, ToolException { + public ToolSessionExportOutputData exportToolSession(Long toolSessionId) + throws DataMissingException, ToolException { return null; } @Override - public ToolSessionExportOutputData exportToolSession(List toolSessionIds) throws DataMissingException, - ToolException { + public ToolSessionExportOutputData exportToolSession(List toolSessionIds) + throws DataMissingException, ToolException { return null; } @@ -705,8 +716,9 @@ } /** 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 { + @Override + public void setReflectiveData(Long toolContentId, String title, String description) + throws ToolException, DataMissingException { Peerreview toolContentObj = getPeerreviewByContentId(toolContentId); if (toolContentObj == null) { @@ -718,6 +730,7 @@ toolContentObj.setReflectInstructions(description); } + @Override public Class[] getSupportedToolOutputDefinitionClasses(int definitionType) { return null; } Index: lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/service/SubmitFilesService.java =================================================================== diff -u -r0aae4208886026f429f05b458b79c14f8d7030d4 -r708bd4d049ae0a59d70c964ef2f864d2b7a352e6 --- lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/service/SubmitFilesService.java (.../SubmitFilesService.java) (revision 0aae4208886026f429f05b458b79c14f8d7030d4) +++ lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/service/SubmitFilesService.java (.../SubmitFilesService.java) (revision 708bd4d049ae0a59d70c964ef2f864d2b7a352e6) @@ -79,7 +79,6 @@ import org.lamsfoundation.lams.tool.ToolSessionExportOutputData; import org.lamsfoundation.lams.tool.ToolSessionManager; import org.lamsfoundation.lams.tool.exception.DataMissingException; -import org.lamsfoundation.lams.tool.exception.SessionDataExistsException; import org.lamsfoundation.lams.tool.exception.ToolException; import org.lamsfoundation.lams.tool.sbmt.SubmissionDetails; import org.lamsfoundation.lams.tool.sbmt.SubmitFilesContent; @@ -215,23 +214,22 @@ } @Override - public void removeToolContent(Long toolContentId, boolean removeSessionData) throws SessionDataExistsException { + public void removeToolContent(Long toolContentId) throws ToolException { SubmitFilesContent submitFilesContent = submitFilesContentDAO.getContentByID(toolContentId); - if (submitFilesContent != null) { - // if session data exist and removeSessionData=false, throw an exception - List submissionData = submitFilesSessionDAO.getSubmitFilesSessionByContentID(toolContentId); - if (!((submissionData == null) || submissionData.isEmpty()) && !removeSessionData) { - throw new SessionDataExistsException( - "Delete failed: There is session data that belongs to this tool content id"); - } else if (submissionData != null) { - Iterator iter = submissionData.iterator(); - while (iter.hasNext()) { - SubmitFilesSession element = (SubmitFilesSession) iter.next(); - removeToolSession(element); - } + if (submitFilesContent == null) { + SubmitFilesService.log.warn("Can not remove the tool content as it does not exist, ID: " + toolContentId); + return; + } + + for (SubmitFilesSession session : submitFilesSessionDAO.getSubmitFilesSessionByContentID(toolContentId)) { + List entries = coreNotebookService.getEntry(session.getSessionID(), + CoreNotebookConstants.NOTEBOOK_TOOL, SbmtConstants.TOOL_SIGNATURE); + for (NotebookEntry entry : entries) { + coreNotebookService.deleteEntry(entry); } - submitFilesContentDAO.delete(submitFilesContent); } + + submitFilesContentDAO.delete(submitFilesContent); } @Override Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/service/ScratchieServiceImpl.java =================================================================== diff -u -r0aae4208886026f429f05b458b79c14f8d7030d4 -r708bd4d049ae0a59d70c964ef2f864d2b7a352e6 --- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/service/ScratchieServiceImpl.java (.../ScratchieServiceImpl.java) (revision 0aae4208886026f429f05b458b79c14f8d7030d4) +++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/service/ScratchieServiceImpl.java (.../ScratchieServiceImpl.java) (revision 708bd4d049ae0a59d70c964ef2f864d2b7a352e6) @@ -66,7 +66,6 @@ import org.lamsfoundation.lams.tool.ToolSessionExportOutputData; import org.lamsfoundation.lams.tool.ToolSessionManager; import org.lamsfoundation.lams.tool.exception.DataMissingException; -import org.lamsfoundation.lams.tool.exception.SessionDataExistsException; import org.lamsfoundation.lams.tool.exception.ToolException; import org.lamsfoundation.lams.tool.scratchie.ScratchieConstants; import org.lamsfoundation.lams.tool.scratchie.dao.ScratchieAnswerVisitDAO; @@ -1777,19 +1776,23 @@ return false; } - + @Override - public void removeToolContent(Long toolContentId, boolean removeSessionData) - throws SessionDataExistsException, ToolException { + public void removeToolContent(Long toolContentId) throws ToolException { Scratchie scratchie = scratchieDao.getByContentId(toolContentId); - if (removeSessionData) { - List list = scratchieSessionDao.getByContentId(toolContentId); - Iterator iter = list.iterator(); - while (iter.hasNext()) { - ScratchieSession session = (ScratchieSession) iter.next(); - scratchieSessionDao.delete(session); + if (scratchie == null) { + ScratchieServiceImpl.log.warn("Can not remove the tool content as it does not exist, ID: " + toolContentId); + return; + } + + for (ScratchieSession session : scratchieSessionDao.getByContentId(toolContentId)) { + List entries = coreNotebookService.getEntry(session.getSessionId(), + CoreNotebookConstants.NOTEBOOK_TOOL, ScratchieConstants.TOOL_SIGNATURE); + for (NotebookEntry entry : entries) { + coreNotebookService.deleteEntry(entry); } } + scratchieDao.delete(scratchie); } Index: lams_tool_scribe/src/java/org/lamsfoundation/lams/tool/scribe/service/ScribeService.java =================================================================== diff -u -r0aae4208886026f429f05b458b79c14f8d7030d4 -r708bd4d049ae0a59d70c964ef2f864d2b7a352e6 --- lams_tool_scribe/src/java/org/lamsfoundation/lams/tool/scribe/service/ScribeService.java (.../ScribeService.java) (revision 0aae4208886026f429f05b458b79c14f8d7030d4) +++ lams_tool_scribe/src/java/org/lamsfoundation/lams/tool/scribe/service/ScribeService.java (.../ScribeService.java) (revision 708bd4d049ae0a59d70c964ef2f864d2b7a352e6) @@ -54,7 +54,6 @@ import org.lamsfoundation.lams.tool.ToolSessionExportOutputData; import org.lamsfoundation.lams.tool.ToolSessionManager; import org.lamsfoundation.lams.tool.exception.DataMissingException; -import org.lamsfoundation.lams.tool.exception.SessionDataExistsException; import org.lamsfoundation.lams.tool.exception.ToolException; import org.lamsfoundation.lams.tool.scribe.dao.IScribeDAO; import org.lamsfoundation.lams.tool.scribe.dao.IScribeHeadingDAO; @@ -203,10 +202,24 @@ scribeDAO.saveOrUpdate(scribe); } + @SuppressWarnings("unchecked") @Override - public void removeToolContent(Long toolContentId, boolean removeSessionData) - throws SessionDataExistsException, ToolException { - // TODO Auto-generated method stub + public void removeToolContent(Long toolContentId) throws ToolException { + Scribe scribe = scribeDAO.getByContentId(toolContentId); + if (scribe == null) { + ScribeService.logger.warn("Can not remove the tool content as it does not exist, ID: " + toolContentId); + return; + } + + for (ScribeSession session : (Set) scribe.getScribeSessions()) { + List entries = coreNotebookService.getEntry(session.getSessionId(), + CoreNotebookConstants.NOTEBOOK_TOOL, ScribeConstants.TOOL_SIGNATURE); + for (NotebookEntry entry : entries) { + coreNotebookService.deleteEntry(entry); + } + } + + scribeDAO.delete(scribe); } @Override Index: lams_tool_spreadsheet/src/java/org/lamsfoundation/lams/tool/spreadsheet/service/SpreadsheetServiceImpl.java =================================================================== diff -u -r0d10b0f6afaf65b7d04a5c2fa54688962f4b9379 -r708bd4d049ae0a59d70c964ef2f864d2b7a352e6 --- lams_tool_spreadsheet/src/java/org/lamsfoundation/lams/tool/spreadsheet/service/SpreadsheetServiceImpl.java (.../SpreadsheetServiceImpl.java) (revision 0d10b0f6afaf65b7d04a5c2fa54688962f4b9379) +++ lams_tool_spreadsheet/src/java/org/lamsfoundation/lams/tool/spreadsheet/service/SpreadsheetServiceImpl.java (.../SpreadsheetServiceImpl.java) (revision 708bd4d049ae0a59d70c964ef2f864d2b7a352e6) @@ -27,7 +27,6 @@ import java.util.Date; import java.util.HashMap; import java.util.Hashtable; -import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; @@ -50,7 +49,6 @@ import org.lamsfoundation.lams.tool.ToolSessionExportOutputData; import org.lamsfoundation.lams.tool.ToolSessionManager; import org.lamsfoundation.lams.tool.exception.DataMissingException; -import org.lamsfoundation.lams.tool.exception.SessionDataExistsException; import org.lamsfoundation.lams.tool.exception.ToolException; import org.lamsfoundation.lams.tool.service.ILamsToolService; import org.lamsfoundation.lams.tool.spreadsheet.SpreadsheetConstants; @@ -101,11 +99,13 @@ // Service method // ******************************************************************************* + @Override public Spreadsheet getSpreadsheetByContentId(Long contentId) { Spreadsheet rs = spreadsheetDao.getByContentId(contentId); return rs; } + @Override public Spreadsheet getDefaultContent(Long contentId) throws SpreadsheetApplicationException { if (contentId == null) { String error = messageService.getMessage("error.msg.default.content.not.find"); @@ -120,31 +120,38 @@ return content; } + @Override public void saveOrUpdateUser(SpreadsheetUser spreadsheetUser) { spreadsheetUserDao.saveObject(spreadsheetUser); } + @Override public void saveOrUpdateUserModifiedSpreadsheet(UserModifiedSpreadsheet userModifiedSpreadsheet) { userModifiedSpreadsheetDao.saveObject(userModifiedSpreadsheet); } + @Override public SpreadsheetUser getUserByIDAndContent(Long userId, Long contentId) { return spreadsheetUserDao.getUserByUserIDAndContentID(userId, contentId); } + @Override public SpreadsheetUser getUserByIDAndSession(Long userId, Long sessionId) { return spreadsheetUserDao.getUserByUserIDAndSessionID(userId, sessionId); } + @Override public List getUserListBySessionId(Long sessionId) { List userList = spreadsheetUserDao.getBySessionID(sessionId); return userList; } + @Override public void saveOrUpdateSpreadsheet(Spreadsheet spreadsheet) { spreadsheetDao.saveObject(spreadsheet); } + @Override public List exportForLearner(Long sessionId, SpreadsheetUser learner) { SpreadsheetSession session = spreadsheetSessionDao.getSessionBySessionId(sessionId); if (session == null) { @@ -205,6 +212,7 @@ // return itemList; } + @Override public List exportForTeacher(Long contentId) { Spreadsheet spreadsheet = spreadsheetDao.getByContentId(contentId); List summaryList = new ArrayList(); @@ -238,6 +246,7 @@ return summaryList; } + @Override public Spreadsheet getSpreadsheetBySessionId(Long sessionId) { SpreadsheetSession session = spreadsheetSessionDao.getSessionBySessionId(sessionId); // to skip CGLib problem @@ -246,14 +255,17 @@ return res; } + @Override public SpreadsheetSession getSessionBySessionId(Long sessionId) { return spreadsheetSessionDao.getSessionBySessionId(sessionId); } + @Override public void saveOrUpdateSpreadsheetSession(SpreadsheetSession resSession) { spreadsheetSessionDao.saveObject(resSession); } + @Override public String finishToolSession(Long toolSessionId, Long userId) throws SpreadsheetApplicationException { SpreadsheetUser user = spreadsheetUserDao.getUserByUserIDAndSessionID(userId, toolSessionId); user.setSessionFinished(true); @@ -274,6 +286,7 @@ return nextUrl; } + @Override public List getSummary(Long contentId) { Spreadsheet spreadsheet = spreadsheetDao.getByContentId(contentId); @@ -293,16 +306,18 @@ } @Override - public List getUsersForTablesorter(final Long sessionId, int page, int size, int sorting, String searchString, boolean getNotebookEntries) { - return spreadsheetUserDao.getUsersForTablesorter(sessionId, page, size, sorting, searchString, getNotebookEntries, coreNotebookService); + public List getUsersForTablesorter(final Long sessionId, int page, int size, int sorting, + String searchString, boolean getNotebookEntries) { + return spreadsheetUserDao.getUsersForTablesorter(sessionId, page, size, sorting, searchString, + getNotebookEntries, coreNotebookService); } @Override public int getCountUsersBySession(Long sessionId, String searchString) { return spreadsheetUserDao.getCountUsersBySession(sessionId, searchString); } - + @Override public List getStatistics(Long contentId) { List sessionList = spreadsheetSessionDao.getByContentId(contentId); @@ -329,6 +344,7 @@ return statisticList; } + @Override public Map> getReflectList(Long contentId, boolean setEntry) { Map> map = new HashMap>(); @@ -359,15 +375,17 @@ return map; } + @Override public Long createNotebookEntry(Long sessionId, Integer notebookToolType, String toolSignature, Integer userId, String entryText) { return coreNotebookService.createNotebookEntry(sessionId, notebookToolType, toolSignature, userId, "", entryText); } + @Override public NotebookEntry getEntry(Long sessionId, Integer idType, String signature, Integer userID) { List list = coreNotebookService.getEntry(sessionId, idType, signature, userID); - if (list == null || list.isEmpty()) { + if ((list == null) || list.isEmpty()) { return null; } else { return list.get(0); @@ -377,25 +395,29 @@ /** * @param notebookEntry */ + @Override public void updateEntry(NotebookEntry notebookEntry) { coreNotebookService.updateEntry(notebookEntry); } + @Override public SpreadsheetUser getUser(Long uid) { return (SpreadsheetUser) spreadsheetUserDao.getObject(SpreadsheetUser.class, uid); } + @Override public void releaseMarksForSession(Long sessionId) { List users = spreadsheetUserDao.getBySessionID(sessionId); for (SpreadsheetUser user : users) { - if (user.getUserModifiedSpreadsheet() != null && user.getUserModifiedSpreadsheet().getMark() != null) { + if ((user.getUserModifiedSpreadsheet() != null) && (user.getUserModifiedSpreadsheet().getMark() != null)) { SpreadsheetMark mark = user.getUserModifiedSpreadsheet().getMark(); mark.setDateMarksReleased(new Date()); spreadsheetMarkDao.saveObject(mark); } } } + @Override public boolean isGroupedActivity(long toolContentID) { return toolService.isGroupedActivity(toolContentID); } @@ -437,6 +459,7 @@ this.messageService = messageService; } + @Override public MessageService getMessageService() { return messageService; } @@ -562,6 +585,7 @@ spreadsheetDao.saveObject(toContent); } + @Override public String getToolContentTitle(Long toolContentId) { return getSpreadsheetByContentId(toolContentId).getTitle(); } @@ -593,24 +617,38 @@ } @Override - public void removeToolContent(Long toolContentId, boolean removeSessionData) - throws SessionDataExistsException, ToolException { + public void removeToolContent(Long toolContentId) throws ToolException { Spreadsheet spreadsheet = spreadsheetDao.getByContentId(toolContentId); - if (removeSessionData) { - List list = spreadsheetSessionDao.getByContentId(toolContentId); - Iterator iter = list.iterator(); - while (iter.hasNext()) { - SpreadsheetSession session = (SpreadsheetSession) iter.next(); - spreadsheetSessionDao.delete(session); + if (spreadsheet == null) { + SpreadsheetServiceImpl.log + .warn("Can not remove the tool content as it does not exist, ID: " + toolContentId); + return; + } + + for (SpreadsheetSession session : spreadsheetSessionDao.getByContentId(toolContentId)) { + // this can not be done via DB cascade + List users = spreadsheetUserDao.getBySessionID(session.getSessionId()); + for (SpreadsheetUser user : users) { + UserModifiedSpreadsheet modified = user.getUserModifiedSpreadsheet(); + if (modified != null) { + userModifiedSpreadsheetDao.removeObject(UserModifiedSpreadsheet.class, modified.getUid()); + } } + + List entries = coreNotebookService.getEntry(session.getSessionId(), + CoreNotebookConstants.NOTEBOOK_TOOL, SpreadsheetConstants.TOOL_SIGNATURE); + for (NotebookEntry entry : entries) { + coreNotebookService.deleteEntry(entry); + } } spreadsheetDao.delete(spreadsheet); } @Override public void removeLearnerContent(Long toolContentId, Integer userId) throws ToolException { - if (log.isDebugEnabled()) { - log.debug("Removing Spreadsheet contents for user ID " + userId + " and toolContentId " + toolContentId); + if (SpreadsheetServiceImpl.log.isDebugEnabled()) { + SpreadsheetServiceImpl.log.debug( + "Removing Spreadsheet contents for user ID " + userId + " and toolContentId " + toolContentId); } List sessions = spreadsheetSessionDao.getByContentId(toolContentId); @@ -747,6 +785,7 @@ this.coreNotebookService = coreNotebookService; } + @Override public Class[] getSupportedToolOutputDefinitionClasses(int definitionType) { return null; } Index: lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/service/SurveyServiceImpl.java =================================================================== diff -u -r0aae4208886026f429f05b458b79c14f8d7030d4 -r708bd4d049ae0a59d70c964ef2f864d2b7a352e6 --- lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/service/SurveyServiceImpl.java (.../SurveyServiceImpl.java) (revision 0aae4208886026f429f05b458b79c14f8d7030d4) +++ lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/service/SurveyServiceImpl.java (.../SurveyServiceImpl.java) (revision 708bd4d049ae0a59d70c964ef2f864d2b7a352e6) @@ -62,7 +62,6 @@ import org.lamsfoundation.lams.tool.ToolSessionExportOutputData; import org.lamsfoundation.lams.tool.ToolSessionManager; import org.lamsfoundation.lams.tool.exception.DataMissingException; -import org.lamsfoundation.lams.tool.exception.SessionDataExistsException; import org.lamsfoundation.lams.tool.exception.ToolException; import org.lamsfoundation.lams.tool.service.ILamsToolService; import org.lamsfoundation.lams.tool.survey.SurveyConstants; @@ -799,15 +798,18 @@ } @Override - public void removeToolContent(Long toolContentId, boolean removeSessionData) - throws SessionDataExistsException, ToolException { + public void removeToolContent(Long toolContentId) throws ToolException { Survey survey = surveyDao.getByContentId(toolContentId); - if (removeSessionData) { - List list = surveySessionDao.getByContentId(toolContentId); - Iterator iter = list.iterator(); - while (iter.hasNext()) { - SurveySession session = (SurveySession) iter.next(); - surveySessionDao.delete(session); + if (survey == null) { + SurveyServiceImpl.log.warn("Can not remove the tool content as it does not exist, ID: " + toolContentId); + return; + } + + for (SurveySession session : surveySessionDao.getByContentId(toolContentId)) { + List entries = coreNotebookService.getEntry(session.getSessionId(), + CoreNotebookConstants.NOTEBOOK_TOOL, SurveyConstants.TOOL_SIGNATURE); + for (NotebookEntry entry : entries) { + coreNotebookService.deleteEntry(entry); } } surveyDao.delete(survey); Index: lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/service/TaskListServiceImpl.java =================================================================== diff -u -r0aae4208886026f429f05b458b79c14f8d7030d4 -r708bd4d049ae0a59d70c964ef2f864d2b7a352e6 --- lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/service/TaskListServiceImpl.java (.../TaskListServiceImpl.java) (revision 0aae4208886026f429f05b458b79c14f8d7030d4) +++ lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/service/TaskListServiceImpl.java (.../TaskListServiceImpl.java) (revision 708bd4d049ae0a59d70c964ef2f864d2b7a352e6) @@ -54,7 +54,6 @@ import org.lamsfoundation.lams.tool.ToolSessionExportOutputData; import org.lamsfoundation.lams.tool.ToolSessionManager; import org.lamsfoundation.lams.tool.exception.DataMissingException; -import org.lamsfoundation.lams.tool.exception.SessionDataExistsException; import org.lamsfoundation.lams.tool.exception.ToolException; import org.lamsfoundation.lams.tool.service.ILamsToolService; import org.lamsfoundation.lams.tool.taskList.TaskListConstants; @@ -813,15 +812,18 @@ } @Override - public void removeToolContent(Long toolContentId, boolean removeSessionData) - throws SessionDataExistsException, ToolException { + public void removeToolContent(Long toolContentId) throws ToolException { TaskList taskList = taskListDao.getByContentId(toolContentId); - if (removeSessionData) { - List list = taskListSessionDao.getByContentId(toolContentId); - Iterator iter = list.iterator(); - while (iter.hasNext()) { - TaskListSession session = (TaskListSession) iter.next(); - taskListSessionDao.delete(session); + if (taskList == null) { + TaskListServiceImpl.log.warn("Can not remove the tool content as it does not exist, ID: " + toolContentId); + return; + } + + for (TaskListSession session : taskListSessionDao.getByContentId(toolContentId)) { + List entries = coreNotebookService.getEntry(session.getSessionId(), + CoreNotebookConstants.NOTEBOOK_TOOL, TaskListConstants.TOOL_SIGNATURE); + for (NotebookEntry entry : entries) { + coreNotebookService.deleteEntry(entry); } } taskListDao.delete(taskList); Index: lams_tool_videorecorder/src/java/org/lamsfoundation/lams/tool/videoRecorder/service/VideoRecorderService.java =================================================================== diff -u -r0aae4208886026f429f05b458b79c14f8d7030d4 -r708bd4d049ae0a59d70c964ef2f864d2b7a352e6 --- lams_tool_videorecorder/src/java/org/lamsfoundation/lams/tool/videoRecorder/service/VideoRecorderService.java (.../VideoRecorderService.java) (revision 0aae4208886026f429f05b458b79c14f8d7030d4) +++ lams_tool_videorecorder/src/java/org/lamsfoundation/lams/tool/videoRecorder/service/VideoRecorderService.java (.../VideoRecorderService.java) (revision 708bd4d049ae0a59d70c964ef2f864d2b7a352e6) @@ -38,6 +38,7 @@ import org.lamsfoundation.lams.learningdesign.service.IExportToolContentService; import org.lamsfoundation.lams.learningdesign.service.ImportToolContentException; import org.lamsfoundation.lams.notebook.model.NotebookEntry; +import org.lamsfoundation.lams.notebook.service.CoreNotebookConstants; import org.lamsfoundation.lams.notebook.service.ICoreNotebookService; import org.lamsfoundation.lams.tool.ToolContentImport102Manager; import org.lamsfoundation.lams.tool.ToolContentManager; @@ -46,7 +47,6 @@ import org.lamsfoundation.lams.tool.ToolSessionExportOutputData; import org.lamsfoundation.lams.tool.ToolSessionManager; import org.lamsfoundation.lams.tool.exception.DataMissingException; -import org.lamsfoundation.lams.tool.exception.SessionDataExistsException; import org.lamsfoundation.lams.tool.exception.ToolException; import org.lamsfoundation.lams.tool.service.ILamsToolService; import org.lamsfoundation.lams.tool.videoRecorder.dao.IVideoRecorderCommentDAO; @@ -224,10 +224,25 @@ videoRecorderDAO.saveOrUpdate(videoRecorder); } + @SuppressWarnings("unchecked") @Override - public void removeToolContent(Long toolContentId, boolean removeSessionData) - throws SessionDataExistsException, ToolException { - // TODO Auto-generated method stub + public void removeToolContent(Long toolContentId) throws ToolException { + VideoRecorder videoRecorder = videoRecorderDAO.getByContentId(toolContentId); + if (videoRecorder == null) { + VideoRecorderService.logger + .warn("Can not remove the tool content as it does not exist, ID: " + toolContentId); + return; + } + + for (VideoRecorderSession session : (Set) videoRecorder.getVideoRecorderSessions()) { + List entries = coreNotebookService.getEntry(session.getSessionId(), + CoreNotebookConstants.NOTEBOOK_TOOL, VideoRecorderConstants.TOOL_SIGNATURE); + for (NotebookEntry entry : entries) { + coreNotebookService.deleteEntry(entry); + } + } + + videoRecorderDAO.delete(videoRecorder); } @Override Index: lams_tool_vote/conf/hibernate/mappings/org/lamsfoundation/lams/tool/vote/pojos/VoteUsrAttempt.hbm.xml =================================================================== diff -u -rc7798d2b81a0595194a5e905ef6c33e372ad8007 -r708bd4d049ae0a59d70c964ef2f864d2b7a352e6 --- lams_tool_vote/conf/hibernate/mappings/org/lamsfoundation/lams/tool/vote/pojos/VoteUsrAttempt.hbm.xml (.../VoteUsrAttempt.hbm.xml) (revision c7798d2b81a0595194a5e905ef6c33e372ad8007) +++ lams_tool_vote/conf/hibernate/mappings/org/lamsfoundation/lams/tool/vote/pojos/VoteUsrAttempt.hbm.xml (.../VoteUsrAttempt.hbm.xml) (revision 708bd4d049ae0a59d70c964ef2f864d2b7a352e6) @@ -36,18 +36,6 @@ - - - - ) voteContent.getVoteSessions()) { + List entries = coreNotebookService.getEntry(session.getVoteSessionId(), + CoreNotebookConstants.NOTEBOOK_TOOL, VoteAppConstants.MY_SIGNATURE); + for (NotebookEntry entry : entries) { + coreNotebookService.deleteEntry(entry); } - // removed all existing responses of toolContent with toolContentID - voteContentDAO.removeVoteById(toolContentID); - } else { - VoteServicePOJO.logger.error("Warning!!!, We should have not come here. voteContent is null."); - throw new ToolException("toolContentID is missing"); } + + voteContentDAO.delete(voteContent); } @SuppressWarnings("unchecked") Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteMonitoringStarterAction.java =================================================================== diff -u -r5b17b810b5302c90b2daf6a5866bf4f6e85bef6a -r708bd4d049ae0a59d70c964ef2f864d2b7a352e6 --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteMonitoringStarterAction.java (.../VoteMonitoringStarterAction.java) (revision 5b17b810b5302c90b2daf6a5866bf4f6e85bef6a) +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteMonitoringStarterAction.java (.../VoteMonitoringStarterAction.java) (revision 708bd4d049ae0a59d70c964ef2f864d2b7a352e6) @@ -77,6 +77,7 @@ public class VoteMonitoringStarterAction extends Action implements VoteAppConstants { static Logger logger = Logger.getLogger(VoteMonitoringStarterAction.class.getName()); + @Override public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException, VoteApplicationException { VoteUtils.cleanUpUserExceptions(request); @@ -95,7 +96,7 @@ return validateParameters; } - //initialiseMonitoringData + // initialiseMonitoringData voteGeneralMonitoringDTO.setRequestLearningReport(new Boolean(false).toString()); /* we have made sure TOOL_CONTENT_ID is passed */ @@ -105,7 +106,7 @@ if (voteContent == null) { VoteUtils.cleanUpUserExceptions(request); voteGeneralMonitoringDTO.setUserExceptionContentDoesNotExist(new Boolean(true).toString()); - return (mapping.findForward(ERROR_LIST)); + return (mapping.findForward(VoteAppConstants.ERROR_LIST)); } voteGeneralMonitoringDTO.setActivityTitle(voteContent.getTitle()); @@ -120,8 +121,8 @@ * get the nominations section is needed for the Edit tab's View Only mode, starts here */ SessionMap sessionMap = new SessionMap(); - sessionMap.put(ACTIVITY_TITLE_KEY, voteContent.getTitle()); - sessionMap.put(ACTIVITY_INSTRUCTIONS_KEY, voteContent.getInstructions()); + sessionMap.put(VoteAppConstants.ACTIVITY_TITLE_KEY, voteContent.getTitle()); + sessionMap.put(VoteAppConstants.ACTIVITY_INSTRUCTIONS_KEY, voteContent.getInstructions()); voteMonitoringForm.setHttpSessionID(sessionMap.getSessionID()); request.getSession().setAttribute(sessionMap.getSessionID(), sessionMap); @@ -141,8 +142,8 @@ } } - request.setAttribute(LIST_QUESTION_DTO, listQuestionDTO); - sessionMap.put(LIST_QUESTION_DTO, listQuestionDTO); + request.setAttribute(VoteAppConstants.LIST_QUESTION_DTO, listQuestionDTO); + sessionMap.put(VoteAppConstants.LIST_QUESTION_DTO, listQuestionDTO); /* this section is related to summary tab. Starts here. */ @@ -153,7 +154,7 @@ } String userExceptionNoToolSessions = voteGeneralMonitoringDTO.getUserExceptionNoToolSessions(); - + Set questions = voteContent.getVoteQueContents(); List listMonitoredAnswersContainerDTO = new LinkedList(); @@ -171,7 +172,7 @@ List> listMonitoredAttemptsContainerDTO = new LinkedList>(); - //populateToolSessionsId + // populateToolSessionsId List sessionIds = voteService.getSessionsFromContent(voteContent); Map summaryToolSessions = new TreeMap(new VoteComparator()); int mapIndex = 1; @@ -198,15 +199,15 @@ } } } - -// //create data for All sessions in total -// if (summaryToolSessions.size() > 1) { -// Map sessionUsersAttempts = populateSessionUsersAttempts(request, -// voteContent, voteSession.getVoteSessionId(), users, questionUid, isUserNamesVisible, -// isLearnerRequest, userId, voteService); -// listMonitoredAttemptsContainerDTO.add(sessionUsersAttempts); -// } + // //create data for All sessions in total + // if (summaryToolSessions.size() > 1) { + // Map sessionUsersAttempts = populateSessionUsersAttempts(request, + // voteContent, voteSession.getVoteSessionId(), users, questionUid, isUserNamesVisible, + // isLearnerRequest, userId, voteService); + // listMonitoredAttemptsContainerDTO.add(sessionUsersAttempts); + // } + Map questionAttemptData = new TreeMap(new VoteComparator()); Iterator listIterator = listMonitoredAttemptsContainerDTO.iterator(); Long mapIndex2 = new Long(1); @@ -222,8 +223,8 @@ } /* ends here. */ - List userEnteredNominations = voteService.getOpenVotes( - voteContent.getUid(), null, null); + List userEnteredNominations = voteService.getOpenVotes(voteContent.getUid(), null, + null); voteGeneralMonitoringDTO.setListMonitoredAnswersContainerDto(listMonitoredAnswersContainerDTO); voteGeneralMonitoringDTO.setListUserEntries(userEnteredNominations); @@ -245,7 +246,7 @@ if (!voteContent.getVoteSessions().isEmpty()) { request.setAttribute(VoteAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); if (userExceptionNoToolSessions.equals("true")) { - //there are no online student activity but there are reflections + // there are no online student activity but there are reflections request.setAttribute(VoteAppConstants.NO_SESSIONS_NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); } } else { @@ -260,7 +261,7 @@ VoteSession voteSession = (VoteSession) iteratorSession.next(); if (voteSession != null) { - if (voteSession.getSessionStatus().equals(COMPLETED)) { + if (voteSession.getSessionStatus().equals(VoteAppConstants.COMPLETED)) { ++countSessionComplete; } @@ -277,7 +278,7 @@ VoteStatsDTO voteStatsDTO = new VoteStatsDTO(); voteStatsDTO.setCountAllUsers(new Integer(countAllUsers).toString()); voteStatsDTO.setCountSessionComplete(new Integer(countSessionComplete).toString()); - request.setAttribute(VOTE_STATS_DTO, voteStatsDTO); + request.setAttribute(VoteAppConstants.VOTE_STATS_DTO, voteStatsDTO); // setting up the advanced summary for LDEV-1662 request.setAttribute("useSelectLeaderToolOuput", voteContent.isUseSelectLeaderToolOuput()); @@ -322,12 +323,11 @@ List sessionDTOs = voteService.getSessionDTOs(new Long(toolContentID)); voteGeneralMonitoringDTO.setSessionDTOs(sessionDTOs); - + boolean isGroupedActivity = voteService.isGroupedActivity(new Long(toolContentID)); request.setAttribute("isGroupedActivity", isGroupedActivity); - - //refreshStatsData + // refreshStatsData /* it is possible that no users has ever logged in for the activity yet */ int countAllUsers2 = voteService.getTotalNumberOfUsers(); if (countAllUsers2 == 0) { @@ -339,10 +339,10 @@ List reflectionsContainerDTO = voteService.getReflectionData(voteContent, null); request.setAttribute(VoteAppConstants.REFLECTIONS_CONTAINER_DTO, reflectionsContainerDTO); - + return mapping.findForward(VoteAppConstants.LOAD_MONITORING); } - + private static Map populateSessionUsersAttempts(HttpServletRequest request, VoteContent voteContent, Long sessionId, List listUsers, String questionUid, boolean isLearnerRequest, Long userId, IVoteService voteService) { @@ -400,7 +400,7 @@ // summary reporting case 2 // just populating data normally just like monitoring summary, except that the data is ony for a // specific session - String userID = (String) request.getSession().getAttribute(USER_ID); + String userID = (String) request.getSession().getAttribute(VoteAppConstants.USER_ID); VoteQueUsr voteQueUsr = voteService.getUserById(new Long(userID).longValue()); while (itUsers.hasNext()) { @@ -427,7 +427,7 @@ VoteQueContent voteQueContent = voteUsrResp.getVoteQueContent(); String entry = voteQueContent.getQuestion(); - String questionUid2 = voteUsrResp.getVoteQueContentId().toString(); + String questionUid2 = voteUsrResp.getVoteQueContent().getUid().toString(); VoteSession localUserSession = voteUsrResp.getVoteQueUsr().getVoteSession(); if (voteContent.getVoteContentId().toString() @@ -477,7 +477,7 @@ VoteQueContent voteQueContent = voteUsrResp.getVoteQueContent(); String entry = voteQueContent.getQuestion(); - String voteQueContentId = voteUsrResp.getVoteQueContentId().toString(); + String voteQueContentId = voteUsrResp.getVoteQueContent().getUid().toString(); VoteSession localUserSession = voteUsrResp.getVoteQueUsr().getVoteSession(); if (voteContent.getVoteContentId().toString() @@ -500,7 +500,8 @@ } - Map mapMonitoredUserContainerDTO = MonitoringUtil.convertToVoteMonitoredUserDTOMap(listMonitoredUserContainerDTO); + Map mapMonitoredUserContainerDTO = MonitoringUtil + .convertToVoteMonitoredUserDTOMap(listMonitoredUserContainerDTO); return mapMonitoredUserContainerDTO; } @@ -511,14 +512,14 @@ if ((strToolContentId == null) || (strToolContentId.length() == 0)) { VoteUtils.cleanUpUserExceptions(request); - return (mapping.findForward(ERROR_LIST)); + return (mapping.findForward(VoteAppConstants.ERROR_LIST)); } else { try { voteMonitoringForm.setToolContentID(strToolContentId); } catch (NumberFormatException e) { - logger.error("add error.numberFormatException to ActionMessages."); + VoteMonitoringStarterAction.logger.error("add error.numberFormatException to ActionMessages."); VoteUtils.cleanUpUserExceptions(request); - return (mapping.findForward(ERROR_LIST)); + return (mapping.findForward(VoteAppConstants.ERROR_LIST)); } } return null; Index: lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/service/WikiService.java =================================================================== diff -u -r0aae4208886026f429f05b458b79c14f8d7030d4 -r708bd4d049ae0a59d70c964ef2f864d2b7a352e6 --- lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/service/WikiService.java (.../WikiService.java) (revision 0aae4208886026f429f05b458b79c14f8d7030d4) +++ lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/service/WikiService.java (.../WikiService.java) (revision 708bd4d049ae0a59d70c964ef2f864d2b7a352e6) @@ -299,9 +299,22 @@ } @Override - public void removeToolContent(Long toolContentId, boolean removeSessionData) - throws SessionDataExistsException, ToolException { - // TODO Auto-generated method stub + public void removeToolContent(Long toolContentId) throws SessionDataExistsException, ToolException { + Wiki wiki = wikiDAO.getByContentId(toolContentId); + if (wiki == null) { + WikiService.logger.warn("Can not remove the tool content as it does not exist, ID: " + toolContentId); + return; + } + + for (WikiSession session : wiki.getWikiSessions()) { + List entries = coreNotebookService.getEntry(session.getSessionId(), + CoreNotebookConstants.NOTEBOOK_TOOL, WikiConstants.TOOL_SIGNATURE); + for (NotebookEntry entry : entries) { + coreNotebookService.deleteEntry(entry); + } + } + + wikiDAO.delete(wiki); } @Override Index: lams_tool_wookie/src/java/org/lamsfoundation/lams/tool/wookie/service/WookieService.java =================================================================== diff -u -r0aae4208886026f429f05b458b79c14f8d7030d4 -r708bd4d049ae0a59d70c964ef2f864d2b7a352e6 --- lams_tool_wookie/src/java/org/lamsfoundation/lams/tool/wookie/service/WookieService.java (.../WookieService.java) (revision 0aae4208886026f429f05b458b79c14f8d7030d4) +++ lams_tool_wookie/src/java/org/lamsfoundation/lams/tool/wookie/service/WookieService.java (.../WookieService.java) (revision 708bd4d049ae0a59d70c964ef2f864d2b7a352e6) @@ -46,7 +46,6 @@ import org.lamsfoundation.lams.tool.ToolSessionExportOutputData; import org.lamsfoundation.lams.tool.ToolSessionManager; import org.lamsfoundation.lams.tool.exception.DataMissingException; -import org.lamsfoundation.lams.tool.exception.SessionDataExistsException; import org.lamsfoundation.lams.tool.exception.ToolException; import org.lamsfoundation.lams.tool.service.ILamsToolService; import org.lamsfoundation.lams.tool.wookie.dao.IWookieConfigItemDAO; @@ -281,8 +280,22 @@ } @Override - public void removeToolContent(Long toolContentId, boolean removeSessionData) - throws SessionDataExistsException, ToolException { + public void removeToolContent(Long toolContentId) throws ToolException { + Wookie wookie = wookieDAO.getByContentId(toolContentId); + if (wookie == null) { + WookieService.logger.warn("Can not remove the tool content as it does not exist, ID: " + toolContentId); + return; + } + + for (WookieSession session : wookie.getWookieSessions()) { + List entries = coreNotebookService.getEntry(session.getSessionId(), + CoreNotebookConstants.NOTEBOOK_TOOL, WookieConstants.TOOL_SIGNATURE); + for (NotebookEntry entry : entries) { + coreNotebookService.deleteEntry(entry); + } + } + + wookieDAO.delete(wookie); } @Override