Index: lams_common/conf/hibernate/mappings/org/lamsfoundation/lams/tool/ToolImportSupport.hbm.xml =================================================================== diff -u --- lams_common/conf/hibernate/mappings/org/lamsfoundation/lams/tool/ToolImportSupport.hbm.xml (revision 0) +++ lams_common/conf/hibernate/mappings/org/lamsfoundation/lams/tool/ToolImportSupport.hbm.xml (revision 2b636f4e834cd0b45c00bb3abf6a6b5e5f3161c8) @@ -0,0 +1,71 @@ + + + + + + + + + @hibernate.class + table="lams_tool_import_support" + + true + + + + @hibernate.id + generator-class="identity" + type="java.lang.Long" + column="id" + + + + + + + + + @hibernate.property + column="installed_tool_signature" + length="15" + not-null="true" + + + + + + @hibernate.property + column="supports_tool_signature" + length="50" + not-null="true" + + + + + Index: lams_common/db/model/lams_11.clay =================================================================== diff -u -rd65ab06923c55ee76432bad9507f933ec442a671 -r2b636f4e834cd0b45c00bb3abf6a6b5e5f3161c8 --- lams_common/db/model/lams_11.clay (.../lams_11.clay) (revision d65ab06923c55ee76432bad9507f933ec442a671) +++ lams_common/db/model/lams_11.clay (.../lams_11.clay) (revision 2b636f4e834cd0b45c00bb3abf6a6b5e5f3161c8) @@ -1644,8 +1644,8 @@ - + @@ -1657,8 +1657,8 @@ - + @@ -1670,8 +1670,8 @@ - + @@ -1683,8 +1683,8 @@ - + @@ -4166,8 +4166,8 @@ - + @@ -5112,6 +5112,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Index: lams_common/db/sql/create_lams_11_tables.sql =================================================================== diff -u -rd65ab06923c55ee76432bad9507f933ec442a671 -r2b636f4e834cd0b45c00bb3abf6a6b5e5f3161c8 --- lams_common/db/sql/create_lams_11_tables.sql (.../create_lams_11_tables.sql) (revision d65ab06923c55ee76432bad9507f933ec442a671) +++ lams_common/db/sql/create_lams_11_tables.sql (.../create_lams_11_tables.sql) (revision 2b636f4e834cd0b45c00bb3abf6a6b5e5f3161c8) @@ -862,3 +862,12 @@ , iso_code VARCHAR(2) NOT NULL UNIQUE , PRIMARY KEY (country_id) )TYPE=InnoDB; + +CREATE TABLE lams_tool_import_support ( + id BIGINT(20) NOT NULL AUTO_INCREMENT + , installed_tool_signature VARCHAR(15) NOT NULL + , supports_tool_signature VARCHAR(50) NOT NULL + , PRIMARY KEY (id) +)TYPE=InnoDB; + + Index: lams_common/db/sql/insert_types_data.sql =================================================================== diff -u -r5ccfef13d3dcbc9cb3544ccab5a343dc9389a602 -r2b636f4e834cd0b45c00bb3abf6a6b5e5f3161c8 --- lams_common/db/sql/insert_types_data.sql (.../insert_types_data.sql) (revision 5ccfef13d3dcbc9cb3544ccab5a343dc9389a602) +++ lams_common/db/sql/insert_types_data.sql (.../insert_types_data.sql) (revision 2b636f4e834cd0b45c00bb3abf6a6b5e5f3161c8) @@ -203,4 +203,25 @@ INSERT INTO lams_country VALUES (3, 'CN'); INSERT INTO lams_language VALUES (1, 'en'); -INSERT INTO lams_language VALUES (2, 'zh'); \ No newline at end of file +INSERT INTO lams_language VALUES (2, 'zh'); + +-- which current tool supports the old 1.0.x tools? +INSERT INTO lams_tool_import_support VALUES (1, 'lafrum11', 'messageboard'); +INSERT INTO lams_tool_import_support VALUES (2, 'lamc11', 'simpleassessment'); +INSERT INTO lams_tool_import_support VALUES (3, 'lanb11', 'noticeboard'); +INSERT INTO lams_tool_import_support VALUES (4, 'lanb11', 'htmlnb'); +INSERT INTO lams_tool_import_support VALUES (5, 'laqa11', 'qa'); +INSERT INTO lams_tool_import_support VALUES (6, 'lasbmt11', 'reportsubmission'); +INSERT INTO lams_tool_import_support VALUES (7, 'lachat11', 'chat'); +INSERT INTO lams_tool_import_support VALUES (8, 'larsrc11', 'urlcontent'); +INSERT INTO lams_tool_import_support VALUES (9, 'larsrc11', 'filecontent'); +INSERT INTO lams_tool_import_support VALUES (10, 'larsrc11', 'singleresource'); +INSERT INTO lams_tool_import_support VALUES (11, 'lavote11', 'ranking'); +INSERT INTO lams_tool_import_support VALUES (12, 'lantbk11', 'journal'); +-- private static final String TOOLDATA_TAGS_LOMS = "loms"; +-- private static final String TOOLDATA_TAGS_RPT_MARK= "reportmarking"; +-- private static final String TOOLDATA_TAGS_GROUPING = "group"; +-- private static final String TOOLDATA_TAGS_GROUPREPORTING = "groupreporting"; +-- private static final String TOOLDATA_TAGS_SIMPLE_ASSESSMENT = ; +-- private static final String TOOLDATA_TAGS_IMAGEGALLERY = "imagegallery"; +-- private static final String TOOLDATA_TAGS_IMAGERANKING = "imageranking"; Index: lams_common/src/java/org/lamsfoundation/lams/commonContext.xml =================================================================== diff -u -r28cb89c7a2c83239db0370b3911eee3195de4f23 -r2b636f4e834cd0b45c00bb3abf6a6b5e5f3161c8 --- lams_common/src/java/org/lamsfoundation/lams/commonContext.xml (.../commonContext.xml) (revision 28cb89c7a2c83239db0370b3911eee3195de4f23) +++ lams_common/src/java/org/lamsfoundation/lams/commonContext.xml (.../commonContext.xml) (revision 2b636f4e834cd0b45c00bb3abf6a6b5e5f3161c8) @@ -63,6 +63,7 @@ org/lamsfoundation/lams/tool/Tool.hbm.xml org/lamsfoundation/lams/tool/ToolContent.hbm.xml org/lamsfoundation/lams/tool/ToolSession.hbm.xml + org/lamsfoundation/lams/tool/ToolImportSupport.hbm.xml org/lamsfoundation/lams/workspace/WorkspaceFolderContent.hbm.xml @@ -146,12 +147,14 @@ + + Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/Activity.java =================================================================== diff -u -rf54a6e1be7de8bc955a21a6d2f804070e353079f -r2b636f4e834cd0b45c00bb3abf6a6b5e5f3161c8 --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/Activity.java (.../Activity.java) (revision f54a6e1be7de8bc955a21a6d2f804070e353079f) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/Activity.java (.../Activity.java) (revision 2b636f4e834cd0b45c00bb3abf6a6b5e5f3161c8) @@ -37,6 +37,7 @@ import org.lamsfoundation.lams.learningdesign.dto.AuthoringActivityDTO; import org.lamsfoundation.lams.learningdesign.dto.LibraryActivityDTO; import org.lamsfoundation.lams.learningdesign.dto.ProgressActivityDTO; +import org.lamsfoundation.lams.learningdesign.dto.ValidationErrorDTO; import org.lamsfoundation.lams.usermanagement.User; import org.lamsfoundation.lams.util.MessageService; import org.lamsfoundation.lams.util.Nullable; @@ -855,7 +856,7 @@ * Validate activity * */ - public Vector validateActivity(MessageService messageService) { + public Vector validateActivity(MessageService messageService) { return null; } Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/service/ExportToolContentService.java =================================================================== diff -u -raf3482c543226c31df3bd7e9fab43c0d5b28eb29 -r2b636f4e834cd0b45c00bb3abf6a6b5e5f3161c8 --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/service/ExportToolContentService.java (.../ExportToolContentService.java) (revision af3482c543226c31df3bd7e9fab43c0d5b28eb29) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/service/ExportToolContentService.java (.../ExportToolContentService.java) (revision 2b636f4e834cd0b45c00bb3abf6a6b5e5f3161c8) @@ -82,6 +82,7 @@ import org.lamsfoundation.lams.learningdesign.dao.IActivityDAO; import org.lamsfoundation.lams.learningdesign.dao.IGroupingDAO; import org.lamsfoundation.lams.learningdesign.dao.ILearningDesignDAO; +import org.lamsfoundation.lams.learningdesign.dao.ILearningLibraryDAO; import org.lamsfoundation.lams.learningdesign.dao.ILicenseDAO; import org.lamsfoundation.lams.learningdesign.dao.ITransitionDAO; import org.lamsfoundation.lams.learningdesign.dto.AuthoringActivityDTO; @@ -94,6 +95,7 @@ import org.lamsfoundation.lams.tool.ToolContentManager; import org.lamsfoundation.lams.tool.dao.IToolContentDAO; import org.lamsfoundation.lams.tool.dao.IToolDAO; +import org.lamsfoundation.lams.tool.dao.IToolImportSupportDAO; import org.lamsfoundation.lams.tool.exception.ToolException; import org.lamsfoundation.lams.usermanagement.User; import org.lamsfoundation.lams.usermanagement.WorkspaceFolder; @@ -143,6 +145,8 @@ private IGroupingDAO groupingDAO; private ITransitionDAO transitionDAO; private ILearningDesignDAO learningDesignDAO; + private ILearningLibraryDAO learningLibraryDAO; + private IToolImportSupportDAO toolImportSupportDAO; /** * Class to sort activity DTO according to the rule: Paretns is before their children. @@ -441,8 +445,22 @@ /** + * Import 1.0.2 learning design * @return learningDesingID * @throws ExportToolContentException + * @see org.lamsfoundation.lams.authoring.service.IExportToolContentService.importLearningDesign102(String, User, WorkspaceFolder) + */ + public Long importLearningDesign102(String ldWddxPacket, User importer, Integer workspaceFolderUid + , List toolsErrorMsgs) throws ImportToolContentException { + WorkspaceFolder folder = null; //getWorkspaceFolderForDesign(importer, workspaceFolderUid); + LD102Importer oldImporter = new LD102Importer(getLearningDesignService(), baseDAO, learningLibraryDAO, activityDAO, toolDAO, toolImportSupportDAO, toolContentDAO, toolsErrorMsgs); + return oldImporter.storeLDDataWDDX(ldWddxPacket, importer, folder); + } + + + /** + * @return learningDesingID + * @throws ExportToolContentException * @see org.lamsfoundation.lams.authoring.service.IExportToolContentService.importLearningDesign(String) */ public Long importLearningDesign(String learningDesignPath, User importer, Integer workspaceFolderUid @@ -489,21 +507,7 @@ } } - // if workspaceFolderUid == null use the user's default folder - WorkspaceFolder folder = null; - if ( workspaceFolderUid != null ) { - folder = (WorkspaceFolder)baseDAO.find(WorkspaceFolder.class,workspaceFolderUid); - } - if ( folder == null && importer.getWorkspace() != null) { - folder = importer.getWorkspace().getDefaultFolder(); - } - if ( folder == null ) { - String error = "Unable to save design in a folder - folder not found. Input folder uid="+workspaceFolderUid+ - " user's default folder "+importer.getWorkspace(); - log.error(error); - throw new ImportToolContentException(error); - } - + WorkspaceFolder folder = getWorkspaceFolderForDesign(importer, workspaceFolderUid); return saveLearningDesign(ldDto,importer,folder,toolMapper); }catch (ToolException e) { @@ -515,6 +519,23 @@ } } + private WorkspaceFolder getWorkspaceFolderForDesign(User importer, Integer workspaceFolderUid) throws ImportToolContentException { + // if workspaceFolderUid == null use the user's default folder + WorkspaceFolder folder = null; + if ( workspaceFolderUid != null ) { + folder = (WorkspaceFolder)baseDAO.find(WorkspaceFolder.class,workspaceFolderUid); + } + if ( folder == null && importer.getWorkspace() != null) { + folder = importer.getWorkspace().getDefaultFolder(); + } + if ( folder == null ) { + String error = "Unable to save design in a folder - folder not found. Input folder uid="+workspaceFolderUid+ + " user's default folder "+importer.getWorkspace(); + log.error(error); + throw new ImportToolContentException(error); + } + return folder; + } /** * Import tool content */ @@ -1108,5 +1129,11 @@ act.getActivityTypeId().intValue()== Activity.PARALLEL_ACTIVITY_TYPE || act.getActivityTypeId().intValue()== Activity.OPTIONS_ACTIVITY_TYPE; } + public void setToolImportSupportDAO(IToolImportSupportDAO toolImportSupportDAO) { + this.toolImportSupportDAO = toolImportSupportDAO; + } + public void setLearningLibraryDAO(ILearningLibraryDAO learningLibraryDAO) { + this.learningLibraryDAO = learningLibraryDAO; + } } Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/service/IExportToolContentService.java =================================================================== diff -u -r4377cb222ae6df564b855687aeddb23f9a380a45 -r2b636f4e834cd0b45c00bb3abf6a6b5e5f3161c8 --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/service/IExportToolContentService.java (.../IExportToolContentService.java) (revision 4377cb222ae6df564b855687aeddb23f9a380a45) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/service/IExportToolContentService.java (.../IExportToolContentService.java) (revision 2b636f4e834cd0b45c00bb3abf6a6b5e5f3161c8) @@ -95,4 +95,14 @@ Object importToolContent(String toolContentPath, IToolContentHandler toolContentHandler) throws ImportToolContentException; + + /** + * Import 1.0.2 learning design + * @return learningDesingID + * @throws ExportToolContentException + * @see org.lamsfoundation.lams.authoring.service.IExportToolContentService.importLearningDesign102(String, User, WorkspaceFolder) + */ + public Long importLearningDesign102(String ldWddxPacket, User importer, Integer workspaceFolderUid + , List toolsErrorMsgs) throws ImportToolContentException; + } Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/service/ILearningDesignService.java =================================================================== diff -u -r03392c988a23f5e9129967f8ae692488213632fe -r2b636f4e834cd0b45c00bb3abf6a6b5e5f3161c8 --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/service/ILearningDesignService.java (.../ILearningDesignService.java) (revision 03392c988a23f5e9129967f8ae692488213632fe) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/service/ILearningDesignService.java (.../ILearningDesignService.java) (revision 2b636f4e834cd0b45c00bb3abf6a6b5e5f3161c8) @@ -27,6 +27,7 @@ import org.lamsfoundation.lams.learningdesign.LearningDesign; import org.lamsfoundation.lams.learningdesign.dto.LearningDesignDTO; +import org.lamsfoundation.lams.learningdesign.dto.ValidationErrorDTO; /** * @author Mitchell Seaton @@ -48,6 +49,6 @@ * @param learningDesign * @return list of validation errors */ - public Vector validateLearningDesign(LearningDesign learningDesign); + public Vector validateLearningDesign(LearningDesign learningDesign); } Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/service/LD102Importer.java =================================================================== diff -u --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/service/LD102Importer.java (revision 0) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/service/LD102Importer.java (revision 2b636f4e834cd0b45c00bb3abf6a6b5e5f3161c8) @@ -0,0 +1,1503 @@ +/**************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2.0 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ + +/* $Id$ */ +package org.lamsfoundation.lams.learningdesign.service; + +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Hashtable; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.Vector; + +import org.apache.log4j.Logger; +import org.lamsfoundation.lams.dao.IBaseDAO; +import org.lamsfoundation.lams.learningdesign.Activity; +import org.lamsfoundation.lams.learningdesign.Grouping; +import org.lamsfoundation.lams.learningdesign.GroupingActivity; +import org.lamsfoundation.lams.learningdesign.LearningDesign; +import org.lamsfoundation.lams.learningdesign.LearningLibrary; +import org.lamsfoundation.lams.learningdesign.ToolActivity; +import org.lamsfoundation.lams.learningdesign.Transition; +import org.lamsfoundation.lams.learningdesign.dao.IActivityDAO; +import org.lamsfoundation.lams.learningdesign.dao.ILearningLibraryDAO; +import org.lamsfoundation.lams.learningdesign.dto.ValidationErrorDTO; +import org.lamsfoundation.lams.tool.Tool; +import org.lamsfoundation.lams.tool.ToolContent; +import org.lamsfoundation.lams.tool.ToolImportSupport; +import org.lamsfoundation.lams.tool.dao.IToolContentDAO; +import org.lamsfoundation.lams.tool.dao.IToolDAO; +import org.lamsfoundation.lams.tool.dao.IToolImportSupportDAO; +import org.lamsfoundation.lams.usermanagement.User; +import org.lamsfoundation.lams.usermanagement.WorkspaceFolder; +import org.lamsfoundation.lams.util.wddx.WDDXProcessor; +import org.lamsfoundation.lams.util.wddx.WDDXProcessorConversionException; + +/** Create a learning design from the LAMS 1.0.x WDDX packet. Used by the Import action. */ +public class LD102Importer { + + private Logger log = Logger.getLogger(LD102Importer.class); + private ILearningDesignService learningDesignService = null; + private IBaseDAO baseDAO = null; + private ILearningLibraryDAO learningLibraryDAO = null; + private IActivityDAO activityDAO = null; + private IToolDAO toolDAO = null; + private IToolImportSupportDAO toolImportSupportDAO = null; + private IToolContentDAO toolContentDAO = null; + + private LearningDesign ldInProgress = null; + private String originalPacket = null; + private List toolsErrorMsgs; + private Date createDate = new Date(); + + // store the groupings between tasks and groups for processing at the end of a packet - + // can't do it as we go as the groupings may not be set up yet! Also use it to validate + // if the grouping is already available before it is used. + // should contain the task id (Integer) as the key and the grouping ids (Integer) as the value + // when we have more than one group, make the data a Vector? + private Map m_groupingsToDo = null; + + // put aside all the transitions as we find them and process them after the activities. + private List transitionsToDo = new ArrayList(); + // as we create an activity, stick it in this map so we can find it quickly later (ie while processing transitions). Key is the UI ID + private Map newActivityMap = new HashMap(); + // we are "losing" a level of activity when we combined activity and task levels, so need to keep the relationships for getting the + // right activity for a transition. Key is parent ui id, value is the child ui id + private Map flattenedActivityMap = new HashMap(); + // images to use for each tool, based on the library activities in the database. Key is tool id, value is url. + private Map libraryActivityUiImages; + + /** The value to be past back and forth with the 1.0.x authoring tool to indicate a null value for a numeric id */ + private static final Long NUMERIC_NULL_VALUE_LONG = new Long(-1); + /** The value to be past back and forth with the 1.0.x authoring tool to indicate a null value for a numeric id */ + private static final Integer NUMERIC_NULL_VALUE_INTEGER = new Integer(-1); + + private static final String LD_OBJECT_TYPE = "LearningDesign"; + private static final String ABSTRACT_TASK_OBJECT_TYPE = "task"; + private static final String MULTI_TASK_OBJECT_TYPE = "Multitask"; + private static final String TRANSITION_OBJECT_TYPE = "transition"; + private static final String ACTIVITY_OBJECT_TYPE = "Activity"; + private static final String OPTIONAL_OBJECT_TYPE = "optionalactivity"; + private static final String CONTENT_OBJECT_TYPE = "content"; + + private static final String TOOLDATA_TAGS_TYPE_AUTHORING = "authoring"; + private static final String TOOLDATA_TAGS_JOURNAL = "journal"; + private static final String TOOLDATA_TAGS_NOTICEBOARD = "noticeboard"; + private static final String TOOLDATA_TAGS_MESSAGEBOARD = "messageboard"; + private static final String TOOLDATA_TAGS_LOMS = "loms"; + private static final String TOOLDATA_TAGS_CHAT = "chat"; + private static final String TOOLDATA_TAGS_RPT_SUBMIT= "reportsubmission"; + private static final String TOOLDATA_TAGS_RPT_MARK= "reportmarking"; + private static final String TOOLDATA_TAGS_GROUPING = "group"; + private static final String TOOLDATA_TAGS_GROUPREPORTING = "groupreporting"; + private static final String TOOLDATA_TAGS_RANKING = "ranking"; + private static final String TOOLDATA_TAGS_QUESTIONANSWER = "qa"; + private static final String TOOLDATA_TAGS_SIMPLE_ASSESSMENT = "simpleassessment"; + private static final String TOOLDATA_TAGS_URLCONTENT = "urlcontent"; + private static final String TOOLDATA_TAGS_FILECONTENT = "filecontent"; + private static final String TOOLDATA_TAGS_HTMLNOTICBOARD = "htmlnb"; + private static final String TOOLDATA_TAGS_SINGLE_RESOURCE = "singleresource"; + private static final String TOOLDATA_TAGS_IMAGEGALLERY = "imagegallery"; + private static final String TOOLDATA_TAGS_IMAGERANKING = "imageranking"; + + public LD102Importer(ILearningDesignService learningDesignService, IBaseDAO baseDAO, + ILearningLibraryDAO learningLibraryDAO, IActivityDAO activityDAO, IToolDAO toolDAO, + IToolImportSupportDAO toolImportSupportDAO, IToolContentDAO toolContentDAO, List toolsErrorMsgs) { + this.learningDesignService = learningDesignService; + this.baseDAO = baseDAO; + this.learningLibraryDAO = learningLibraryDAO; + this.activityDAO = activityDAO; + this.toolDAO = toolDAO; + this.toolImportSupportDAO = toolImportSupportDAO; + this.toolContentDAO = toolContentDAO; + this.toolsErrorMsgs = toolsErrorMsgs; + if ( toolsErrorMsgs == null ) { + log.warn("The list toolsErrorMsgs supplied is null so any warnings will be logged but won't appear in the user's screen."); + toolsErrorMsgs = new ArrayList(); + } + + this.libraryActivityUiImages = getLibraryActivityUiImages(); + } + + public void setLearningDesignService(ILearningDesignService learningDesignService) { + this.learningDesignService = learningDesignService; + } + public void setBaseDAO (IBaseDAO baseDAO) { + this.baseDAO = baseDAO; + } + public void setToolDAO (IToolDAO toolDAO) { + this.toolDAO = toolDAO; + } + public void setToolImportSupportDAO ( + IToolImportSupportDAO toolImportSupportDAO) { + this.toolImportSupportDAO = toolImportSupportDAO; + } + public void setToolContentDAO(IToolContentDAO toolContentDAO) { + this.toolContentDAO = toolContentDAO; + } + + public void setActivityDAO(IActivityDAO activityDAO) { + this.activityDAO = activityDAO; + } + public void setLearningLibraryDAO(ILearningLibraryDAO learningLibraryDAO) { + this.learningLibraryDAO = learningLibraryDAO; + } + /** + * Checks whether the hashtable contains the key specified by key + * If the key exists, returns true, otherwise return false. + * @param table The hashtable to check + * @param key The key to find + * @return + */ + private boolean keyExists(Hashtable table, String key) + { + if (table.containsKey(key)) + return true; + else + return false; + } + + protected static boolean isTask(String objectType) { + if ( objectType!=null && + ( objectType.equalsIgnoreCase(ABSTRACT_TASK_OBJECT_TYPE) + || objectType.equalsIgnoreCase(MULTI_TASK_OBJECT_TYPE) ) ) + return true; + else + return false; + } + + protected static boolean isSimpleTask(String objectType, String toolType) { + if ( objectType!=null && toolType!=null + && objectType.equalsIgnoreCase(ABSTRACT_TASK_OBJECT_TYPE) + && ! toolType.equalsIgnoreCase(TOOLDATA_TAGS_GROUPING) ) + return true; + else + return false; + } + + protected static boolean isMultiTask(String objectType, String toolType) { + return ( objectType==null ? false : objectType.equalsIgnoreCase(MULTI_TASK_OBJECT_TYPE)); + } + + protected static boolean isGroupingToolTask(String objectType, String toolType) { + if ( objectType!=null && toolType!=null + && objectType.equalsIgnoreCase(ABSTRACT_TASK_OBJECT_TYPE) + && toolType.equalsIgnoreCase(TOOLDATA_TAGS_GROUPING) ) + return true; + else + return false; + } + + protected static boolean isTransition(String objectType) { + return ( objectType==null ? false : objectType.equalsIgnoreCase(TRANSITION_OBJECT_TYPE)); + } + + protected static boolean isActivity(String objectType) { + return ( objectType==null ? false : objectType.equalsIgnoreCase(ACTIVITY_OBJECT_TYPE)); + } + + protected static boolean isOptionalActivity(String objectType) { + return ( objectType==null ? false : objectType.equalsIgnoreCase(OPTIONAL_OBJECT_TYPE)); + } + + protected static boolean isContent(String objectType) { + return ( objectType==null ? false : objectType.equalsIgnoreCase(CONTENT_OBJECT_TYPE)); + } + + protected static boolean isLearningDesign(String objectType) { + return ( objectType==null ? false : objectType.trim().equalsIgnoreCase(LD_OBJECT_TYPE)); + } + + protected static String getExpectedActivityTransition () + { + return("Wrong format for data - object type expected is" + + ACTIVITY_OBJECT_TYPE + + " or " + + OPTIONAL_OBJECT_TYPE + + " or " + + TRANSITION_OBJECT_TYPE); + } + + protected static String getExpectedActivity () + { + return("Wrong format for data - object type expected is" + ACTIVITY_OBJECT_TYPE); + } + + protected static String getExpectedOptionalActivity () + { + return("Wrong format for data - object type expected is" + OPTIONAL_OBJECT_TYPE); + } + + protected static String getExpectedContent () + { + return("Wrong format for data - object type expected is" + CONTENT_OBJECT_TYPE); + } + + protected static String getExpectedTaskTransition () + { + return("Wrong format for data - object type expected is" + + ABSTRACT_TASK_OBJECT_TYPE + + " or " + + MULTI_TASK_OBJECT_TYPE + + " or " + + TRANSITION_OBJECT_TYPE); + } + + protected static String getExpectedTask () + { + return("Wrong format for data - object type expected is" + + ABSTRACT_TASK_OBJECT_TYPE + + " or " + + MULTI_TASK_OBJECT_TYPE); + } + + /** Guaranteed not to return null - use when putting values into hash table + */ + private String getValue( String possValue ) + { + return ( possValue==null ? "" : possValue ); + } + + /* Check that the WDDX packet doesn't contain any invalid "" strings + * returns true if they do exist */ + private boolean containsNulls(String packet) + { + if (packet.indexOf("") != -1) + return true; + else + return false; + } + + + public Long storeLDDataWDDX(String ldWddxPacket, User importer, WorkspaceFolder folder) throws ImportToolContentException + { + originalPacket = ldWddxPacket; + + if (importer == null) + { + throw new ImportToolContentException("Importer is missing"); + } + + if (containsNulls(ldWddxPacket)) + { + log.error("Unable to process WDDX packet from client due to containing '' - this would cause WDDX to crash."); + log.error("Packet was " + ldWddxPacket); + throw new ImportToolContentException("Invalid packet format - contains nulls. See log for details."); + } + + Hashtable ldHashTable = null; + + if (log.isDebugEnabled()) + log.debug("Request received to import 1.0.x learning design data" + ldWddxPacket); + + try { + ldHashTable = (Hashtable) WDDXProcessor.deserialize(ldWddxPacket); + } catch (Exception e){ + log.error("Unable to process the imported packet: ", e); + log.error("Packet was " + ldWddxPacket); + throw new ImportToolContentException("Invalid import data format - unable to deserialise packet. See log for details."); + } + + if (ldHashTable == null) { + log.error("WDDX packet is empty. Packet was " + ldWddxPacket); + throw new ImportToolContentException("Invalid packet format - no details in packet. See log for details."); + } + + else if (isLearningDesign((String) ldHashTable.get(WDDXTAGS102.OBJECT_TYPE))){ + + processLearningDesign(ldHashTable, importer, folder); + + Vector listOfValidationErrorDTOs = learningDesignService.validateLearningDesign(ldInProgress); + if (listOfValidationErrorDTOs.size() > 0) { + ldInProgress.setValidDesign(Boolean.FALSE); + log.info("Imported learning design is invalid. New learning design id "+ldInProgress.getLearningDesignId()+" title "); + for ( ValidationErrorDTO dto : listOfValidationErrorDTOs ) { + log.info("Learning design id "+ldInProgress.getLearningDesignId()+" validation error "+dto); + } + } + else { + ldInProgress.setValidDesign(Boolean.TRUE); + } + baseDAO.update(ldInProgress); + } + + else { + log.error("Packet is not a learning design packet. Packet was " + ldWddxPacket); + throw new ImportToolContentException("Invalid packet format - it is not a learning design packet. See log for details."); + } + + return(ldInProgress != null ? ldInProgress.getLearningDesignId() : null); + + } + + /** + * Add a message to the error message list about this but keep going - want to make this importer import as much as it possibly can rather + * than giving up. + * @param e + */ + private void handleWDDXProcessorConversionException(WDDXProcessorConversionException e) { + log.error("Unable to process the imported packet properly due to a WDDXProcessorConversionException - will continue with the design in case future parts okay.", e); + log.error("Packet was " + originalPacket); + toolsErrorMsgs.add("Invalid import data format - WDDX caused an exception. Some data from the design will have been lost. See log for more details."); + } + + private void processLearningDesign(Hashtable newLdHashTable, User importer, WorkspaceFolder folder) + { + + // put the learning design in a member variable - the updating of the tasks and + // activities needs to get to the content, but its a pain to keep passing everything around! + createLearningDesign(newLdHashTable, importer, folder); + baseDAO.insert(ldInProgress); + + m_groupingsToDo = new HashMap(); + + Vector newContent = (Vector) newLdHashTable.get(WDDXTAGS102.LD_CONTENT); + if ( newContent != null ) + { + processContent(newContent); + } + + // activities + Vector newActivitiesTransitions = (Vector) newLdHashTable.get(WDDXTAGS102.LD_ACTTRAN); + Set optionalActivitiesToProcess = null; + if ( newActivitiesTransitions == null ) + { + // log warning - no activities found in learning design. + log.warn("No activities or transitions were found for #"+ldInProgress.getLearningDesignId()); + } + else + { + optionalActivitiesToProcess = processActivitiesTransitions(newActivitiesTransitions); + } + + // processOptionalActivities(optionalActivitiesToProcess); + ldInProgress.setFirstActivity(ldInProgress.calculateFirstActivity()); + + // all activities are set up so now we can do the transitions + for ( Hashtable transTable: transitionsToDo ) { + processTransition(transTable); + } + + // now set up the task -> grouping defn links. Can't be done earlier as there + // are cross references +// setGroupToTaskLinks(); // throws an Exception explaining any inconsistencies + + // finally set all the dummy output tasks to be replaced with dynamic content +// setOutputTasksAsReplaceWithDynamic(); + baseDAO.update(ldInProgress); + + } + + /** + * Create the main learning design object from this Learning design DTO object. It also following our + * import rules: + *
  • lams_license - all details null as 1.0.x doesn't support licenses
  • + *
  • lams_copy_type - Set to 1.This indicates it is "normal" design.
  • + *
  • lams_workspace_folder - An input parameters to let user choose import workspace
  • + *
  • User - The person who execute import action
  • + *
  • OriginalLearningDesign - set to null
  • + * + * Sets ldInProgress to the new learning design. + */ + private void createLearningDesign(Hashtable newLdHashTable, User importer, WorkspaceFolder folder) { + + LearningDesign ld = new LearningDesign(); + + ld.setLearningDesignId(null); + ld.setLearningDesignUIID(null); + ld.setDescription((String) newLdHashTable.get(WDDXTAGS102.DESCRIPTION)); + ld.setTitle((String) newLdHashTable.get(WDDXTAGS102.TITLE)); + ld.setHelpText((String) newLdHashTable.get(WDDXTAGS102.LD_HELPTEXT)); + + ld.setValidDesign(Boolean.FALSE); + ld.setReadOnly(Boolean.FALSE); + ld.setDateReadOnly(null); + ld.setOfflineInstructions(null); + ld.setOnlineInstructions(null); + + try { + ld.setMaxID(WDDXProcessor.convertToInt("Max ID", newLdHashTable.get(WDDXTAGS102.LD_MAXID)) ); + } catch ( WDDXProcessorConversionException e) { + handleWDDXProcessorConversionException(e); + } + + ld.setUser(importer); + if(folder != null) + ldInProgress.setWorkspaceFolder(folder); + + ld.setCopyTypeID(LearningDesign.COPY_TYPE_NONE); + ld.setCreateDateTime(createDate); + ld.setLastModifiedDateTime(createDate); + ld.setVersion((String) newLdHashTable.get(WDDXTAGS102.LD_VERSION)); + ld.setLastModifiedDateTime(createDate); + + ld.setDuration(null); + ld.setLicenseText(null); + ld.setLicense(null); + ld.setLessonOrgID(null); + ld.setLessonOrgName(null); + ld.setLessonID(null); + ld.setLessonName(null); + ld.setLessonStartDateTime(null); + + ldInProgress = ld; + } + /* Go through all the simple tasks and set any output contents as "to be replaced + * with dynamic content at runtime". + */ + protected void setOutputTasksAsReplaceWithDynamic() + throws Exception + { + // get a map of all the simple tasks by id. + // use the map to iterate over all the output tasks +/* Hashtable tasksMap = ldInProgress.allTasksWithContent(true); + Collection simpleTasks = tasksMap.values(); + if ( simpleTasks != null ) + { + Iterator iter = simpleTasks.iterator(); + Map contentMap = m_contentUtil.getCurrentContentsAsMapBySid(); + while ( iter.hasNext() ) + { + SimpleTaskVO task = (SimpleTaskVO) iter.next(); + Long outputContentSid = task.getOutputContentSid(); + if ( outputContentSid != null ) + { + Content content = (Content) contentMap.get(outputContentSid); + content.setReplaceWithDynamic(true); + m_contentUtil.updateContent(content); + } + } + } */ + } + + /** Process the activities and transitions. Returns a list of optional Activities yet to + * be processed. + */ + protected Set processActivitiesTransitions(List newActivitiesTransitions) + { + Set newOptionalActivities = new HashSet(); + + Iterator tempIterator = newActivitiesTransitions.iterator(); + while ( tempIterator.hasNext() ) + { + Hashtable clientObj = (Hashtable) tempIterator.next(); + + // check that it is the object we expect + String objectType = (String) clientObj.get(WDDXTAGS102.OBJECT_TYPE); + if ( ! ( isActivity(objectType) || isTransition(objectType) || isOptionalActivity(objectType) ) ) + { + String message = getExpectedActivityTransition()+ " received "+ objectType + ". The matching activity/transition will be skipped. Object is "+clientObj; + log.warn(message); + toolsErrorMsgs.add(message); + } + + try { + Integer objId = WDDXProcessor.convertToInteger("Activity/Transition ID", clientObj.get(WDDXTAGS102.LD_ITEM_ID) ); + if ( NUMERIC_NULL_VALUE_INTEGER.equals(objId) ) + { + String message = "Id value for activity/transition is internal null value. The activity/transition may not appear in the correct place in the sequence. Activity/transition is "+clientObj; + log.warn(message); + toolsErrorMsgs.add(message); + } + + if ( isActivity(objectType) ) + { + processActivity(clientObj, objId); + } + else if ( isOptionalActivity(objectType) ) + { + // put aside for processing later. + newOptionalActivities.add(clientObj); + } + else + { + transitionsToDo.add(clientObj); + } + + } catch (WDDXProcessorConversionException e) { + handleWDDXProcessorConversionException(e); + } + + } + + return newOptionalActivities; + + } + + private void processActivity(Hashtable activityDetails, Integer activityUIID) throws WDDXProcessorConversionException { + +// Long activityUIID = ui_id; +// Long systemID = WDDXProcessor.convertToLong(activityDetails,WDDXTAGS102.SID); + Long nextTransition; + nextTransition = WDDXProcessor.convertToLong(activityDetails,WDDXTAGS102.FOLLOWING_TRANSITION); + Integer xCoOrd = WDDXProcessor.convertToInteger(activityDetails,WDDXTAGS102.ACT_X); + Integer yCoOrd = WDDXProcessor.convertToInteger(activityDetails,WDDXTAGS102.ACT_Y); +// Long firstTask = WDDXProcessor.convertToLong(activityDetails,WDDXTAGS102.ACT_FIRSTTASK); +// String libraryID = WDDXProcessor.convertToString(activityDetails,WDDXTAGS102.ACT_LIBRARY_ID); +// String title = WDDXProcessor.convertToString(activityDetails,WDDXTAGS102.TITLE); +// String description = WDDXProcessor.convertToString(activityDetails,WDDXTAGS102.DESCRIPTION); + List taskTransitions = (List)activityDetails.get(WDDXTAGS102.ACT_TASKTRAN); + + Activity activity = null; + if ( taskTransitions.size()==1 ) { + // easiest case - this is really a single activity + Hashtable task = (Hashtable) taskTransitions.get(0); + activity = createActivityFromTask(task, nextTransition, xCoOrd, yCoOrd); + } else { + // TODO parallel and optional + } + + if ( activity != null ) { + newActivityMap.put(activity.getActivityUIID(), activity); + flattenedActivityMap.put(activityUIID, activity.getActivityUIID()); + } + + } + + private Activity createActivityFromTask(Hashtable taskDetails, Long nextTransition, Integer xCoOrd, Integer yCoOrd) throws WDDXProcessorConversionException { + + String objectType = (String) taskDetails.get(WDDXTAGS102.OBJECT_TYPE); + String toolType = (String) taskDetails.get(WDDXTAGS102.TASK_TOOLTYPE); + Activity activity = null; + + if ( isMultiTask(objectType, toolType) ) + { + toolsErrorMsgs.add("Hit a multitask - not yet implemented."); + activity.setActivityTypeId(Activity.PARALLEL_ACTIVITY_TYPE); + activity.setActivityCategoryID(Activity.CATEGORY_SYSTEM); +// TODO activity = new OptionsActivity(); +// TODO activity = new ParallelActivity(); + } + else if ( isGroupingToolTask(objectType, toolType) ) + { + activity = new GroupingActivity(); + activity.setActivityTypeId(Activity.GROUPING_ACTIVITY_TYPE); + activity.setActivityCategoryID(Activity.CATEGORY_SYSTEM); + toolsErrorMsgs.add("Hit a grouping task - not yet implemented."); + } + else + { + activity = setupToolActivity(taskDetails); + } + + if ( activity != null ) { + + if (keyExists(taskDetails, WDDXTAGS102.LD_ITEM_ID)) { + activity.setActivityUIID(WDDXProcessor.convertToInteger(taskDetails,WDDXTAGS102.LD_ITEM_ID)); + } else { + String message = "Id value for task is missing. The activity may not appear in the correct place in the sequence. Activity is "+taskDetails; + log.warn(message); + toolsErrorMsgs.add(message); + } + + if (keyExists(taskDetails, WDDXTAGS102.DESCRIPTION)) + activity.setDescription(WDDXProcessor.convertToString(taskDetails,WDDXTAGS102.DESCRIPTION)); + if (keyExists(taskDetails, WDDXTAGS102.TITLE)) + activity.setTitle(WDDXProcessor.convertToString(taskDetails,WDDXTAGS102.TITLE)); + + activity.setXcoord(xCoOrd); + activity.setYcoord(yCoOrd); + activity.setHelpText(null); + + updateGroupingValue(taskDetails.get(WDDXTAGS102.TASK_GROUPING), activity); + activity.setGroupingSupportType(Activity.GROUPING_SUPPORT_OPTIONAL); + + // TODO if (keyExists(activityDetails, WDDXTAGS.ORDER_ID)) + // activity.setOrderId(WDDXProcessor.convertToInteger(activityDetails,WDDXTAGS.ORDER_ID)); + + activity.setDefineLater(Boolean.FALSE); + activity.setLearningDesign(ldInProgress); + activity.setCreateDateTime(createDate); + activity.setRunOffline(Boolean.FALSE); + + baseDAO.insert(activity); + } + + return activity; + } + + private ToolActivity setupToolActivity(Hashtable taskDetails) { + ToolActivity activity = new ToolActivity(); + activity.setActivityTypeId(Activity.TOOL_ACTIVITY_TYPE); + activity.setActivityCategoryID(Activity.CATEGORY_CONTENT); + + // first, find the matching new tool and set up the tool, tool content details. + + String toolType = (String) taskDetails.get(WDDXTAGS102.TASK_TOOLTYPE); + List toolsSupportingSignature = toolImportSupportDAO.getToolSignatureWhichSupports(toolType); + Tool tool = null; + Iterator iter = toolsSupportingSignature.iterator(); + while ( iter.hasNext() && tool == null ) { + ToolImportSupport support = (ToolImportSupport) iter.next(); + tool = toolDAO.getToolBySignature(support.getInstalledToolSignature()); + if ( tool != null && ! tool.isValid() ) { + // if not valid then not installed properly so don't use it! + tool = null; + } + } + + if ( tool == null ) { + String message = "Unable to find a tool that supports the activity "+taskDetails.get(WDDXTAGS102.TITLE)+". This activity will be skipped. Activity is "+taskDetails; + log.warn(message); + toolsErrorMsgs.add(message); + return null; + } + + ToolContent newContent = new ToolContent(tool); + toolContentDAO.saveToolContent(newContent); + + activity.setTool(tool); + activity.setToolContentId(newContent.getToolContentId()); + + // Now find an icon for the activity. The icon is in the activity tables so look for a library activity that matches this tool. + // It may not always find the right icon if there is more than one possible match but its a start! + activity.setLibraryActivityUiImage(libraryActivityUiImages.get(tool.getToolId())); + return activity; + } + + private void clearGrouping(Activity activity) { + activity.setGrouping(null); + activity.setGroupingUIID(null); + activity.setApplyGrouping(false); + } + + private void setGrouping(Activity activity, Grouping grouping, Integer groupingUIID) { + activity.setGrouping(grouping); + activity.setGroupingUIID(groupingUIID); + activity.setApplyGrouping(true); + } + +/* private void buildGroupingActivity(GroupingActivity groupingActivity,Hashtable activityDetails) + throws WDDXProcessorConversionException, ObjectExtractorException { + *//** + * read the createGroupingUUID, get the Grouping Object, and set CreateGrouping to that object + *//* + Integer createGroupingUIID = WDDXProcessor.convertToInteger(activityDetails,WDDXTAGS.CREATE_GROUPING_UIID); + Grouping grouping = groupings.get(createGroupingUIID); + if (grouping!=null) + { + groupingActivity.setCreateGrouping(grouping); + groupingActivity.setCreateGroupingUIID(createGroupingUIID); + } + + SystemTool systemTool = systemToolDAO.getSystemToolByID(SystemTool.GROUPING); + groupingActivity.setSystemTool(systemTool); + + Hashtable groupingDetails = (Hashtable) activityDetails.get(WDDXTAGS.GROUPING_DTO); + if( groupingDetails != null ){ + Grouping grouping = extractGroupingObject(groupingDetails); + groupingActivity.setCreateGrouping(grouping); + groupingActivity.setCreateGroupingUIID(grouping.getGroupingUIID()); + } else { + groupingActivity.setCreateGrouping(null); + groupingActivity.setCreateGroupingUIID(null); + } + } + + private void buildOptionsActivity(OptionsActivity optionsActivity,Hashtable activityDetails) throws WDDXProcessorConversionException{ + if (keyExists(activityDetails, WDDXTAGS.MAX_OPTIONS)) + optionsActivity.setMaxNumberOfOptions(WDDXProcessor.convertToInteger(activityDetails,WDDXTAGS.MAX_OPTIONS)); + if (keyExists(activityDetails, WDDXTAGS.MIN_OPTIONS)) + optionsActivity.setMinNumberOfOptions(WDDXProcessor.convertToInteger(activityDetails,WDDXTAGS.MIN_OPTIONS)); + if (keyExists(activityDetails, WDDXTAGS.OPTIONS_INSTRUCTIONS)) + optionsActivity.setOptionsInstructions(WDDXProcessor.convertToString(activityDetails,WDDXTAGS.OPTIONS_INSTRUCTIONS)); + } + private void buildParallelActivity(ParallelActivity activity,Hashtable activityDetails) throws WDDXProcessorConversionException{ + } + private void buildSequenceActivity(SequenceActivity activity,Hashtable activityDetails) throws WDDXProcessorConversionException{ + + } + private void buildGateActivity(Object activity,Hashtable activityDetails) throws WDDXProcessorConversionException{ + if(activity instanceof SynchGateActivity) + buildSynchGateActivity((SynchGateActivity)activity,activityDetails); + else if (activity instanceof PermissionGateActivity) + buildPermissionGateActivity((PermissionGateActivity)activity,activityDetails); + else + buildScheduleGateActivity((ScheduleGateActivity)activity,activityDetails); + GateActivity gateActivity = (GateActivity)activity ; + gateActivity.setGateActivityLevelId(WDDXProcessor.convertToInteger(activityDetails,WDDXTAGS.GATE_ACTIVITY_LEVEL_ID)); + gateActivity.setGateOpen(WDDXProcessor.convertToBoolean(activityDetails,WDDXTAGS.GATE_OPEN)); + + } + private void buildSynchGateActivity(SynchGateActivity activity,Hashtable activityDetails) throws WDDXProcessorConversionException{ + SystemTool systemTool = systemToolDAO.getSystemToolByID(SystemTool.SYNC_GATE); + activity.setSystemTool(systemTool); + } +*/ + + /** Get the grouping value for a particular task. Could be "c" for class or a number + * which is the ui id of the related grouping task. Signify class in database as not grouped. + */ + protected void updateGroupingValue(Object groupingId, Activity activity) + { + if ( log.isDebugEnabled()) + log.debug("updateGroupingValue: groupingId"+(groupingId!=null?groupingId.toString():"null") + + " task "+ activity.toString()); + + Integer grouping = null; + if ( groupingId != null ) + { + try { + grouping = WDDXProcessor.convertToInteger("Grouping ID", groupingId); + } catch ( Exception e) {} + } + + if ( grouping != null ) + { + m_groupingsToDo.put(activity.getActivityUIID(), grouping); + log.debug("Is grouped activity, id="+grouping); + } + else + { + clearGrouping(activity); + log.debug("Is class activity"); + } + } + /* + * get the content's sid based on the internal learning design id - used by + * updateSimpleTask. Match on the creationToolKey field in the content object + * Throws an exception if there was a "valid" creationToolKey value but the content + * could not be found. + + private Long getContentSid( Long creationToolKey ) + throws Exception + { + if ( creationToolKey == null || creationToolKey.equals(LDWDDXValueObjectFactory.NUMERIC_NULL_VALUE_LONG) ) + return null; + + Map currentContents = m_contentUtil.getCurrentContentsAsMapByCreationToolKey(); + Content content = (Content) currentContents.get(creationToolKey.toString()); + if ( content == null ){ + if ( log.isDebugEnabled()) + log.debug("Content missing - looking for creationToolKey "+creationToolKey); + + throw new Exception("There is something wrong in the learning design you are trying to save. " + + "If you are importing it, it may contain Share Resources that has a reference to an uploaded file. "+ + "Currently LAMS does not support export/import designs with a file resource. "+ + "(Missing: creationToolKey="+creationToolKey+")"); + } + + return ( content.getSid() ); + } + + *//** Update the grouping task and the related group definition. This is the task that + * triggers the creation of a group. *//* + protected void updateGroupingTask(PersistenceSession session, Hashtable clientObj, GroupingTaskVO groupTask, Integer objId) + throws Exception + { + // update the values shared with simple task + updateSimpleTask(clientObj, groupTask); + + // set up matching GroupDefnVO if needed + GroupDefnVO groupDefn = groupTask.getGroupDefn(); + if ( groupDefn == null ) + { + groupDefn = new GroupDefnVO(); + storeInSession(session, groupDefn); + groupTask.setGroupDefn(groupDefn); + } + groupTask.getGroupDefn().setId(objId.intValue()); + + // found the matching content object and store link to that! + Integer contentId = WDDXProcessor.convertToInteger("Group Defn Content Id", clientObj.get(WDDXTAGS102.TASK_INPUT_CONTENT) ); + if ( contentId != null ) + { + Map contentMap = m_contentUtil.getCurrentContentsAsMapByCreationToolKey(); + Content content = (Content) contentMap.get(contentId.toString()); + groupDefn.setDefnContentSid(content.getSid()); + } + } + + */ + + /** Process the content from the WDDX packet. In 1.0.x, the content was managed by the + * content manager. In 2.x it is managed by the tools. So we go through the content vector + * and build up a list of all the tool content. Then as we go through the activities + * we will call the tool to set up its content. + * @throws WDDXProcessorConversionException + */ + protected void processContent(List newContent) { + + // cycle through content from the packet. Update existing ones, add new ones + // don't have delete support at the moment. + Iterator iterator = newContent.iterator(); + while ( iterator.hasNext() ) + { + Hashtable clientObj = (Hashtable) iterator.next(); + + if ( clientObj == null ) + { + log.warn("Packet contains invalid content - one of the content objects is null!"); + log.warn("Content list is"+newContent.toString()); + toolsErrorMsgs.add("Packet contained an empty content object. See log for more details."); + } + + // check that it is the object we expect + String objectType = (String) clientObj.get(WDDXTAGS102.OBJECT_TYPE); + if ( ! isContent(objectType) ) { + String message = getExpectedContent()+ " received "+ objectType + ". The matching activity will be missing its content. Object is "+clientObj; + log.warn(message); + toolsErrorMsgs.add(message); + } + + try { + Integer objId = WDDXProcessor.convertToInteger("Content ID", clientObj.get(WDDXTAGS102.LD_ITEM_ID) ); + if ( NUMERIC_NULL_VALUE_INTEGER.equals(objId) ) { + String message = "Id value for content is internal null value. The matching activity will be missing its content. Content is "+clientObj; + log.warn(message); + toolsErrorMsgs.add(message); + } + + // TODO convert the content object to something we can use. + /* ContentConverter converter = new ContentConverter(); + aContent = converter.createNewContentObject((String) clientObj.get(WDDXTAGS102.CONTENT_TYPE)); + // create the content object in the database, get updated version + aContent = m_contentUtil.insertContent(aContent); + converter.convertToDBData(clientObj, aContent, objId); + m_contentUtil.updateContent(aContent); + */ + } catch ( WDDXProcessorConversionException e) { + handleWDDXProcessorConversionException(e); + } + } + } + + + /** Process the optional activities + *//* + protected void processOptionalActivities(PersistenceSession session, Set newOptionalActivities ) + throws Exception + { + + if ( ldInProgress.getOptionalActivities() == null ) + { + ldInProgress.setOptionalActivities(new HashSet()); + } + + if ( newOptionalActivities == null ) + return; + + // after processing the optional activities, this set will contain all the ids + // of the "desired" ones. Any other optional activities whose + // ids don't appear in this set are then due to be deleted. + Set idsUpdated = new HashSet(); + + Iterator tempIterator = newOptionalActivities.iterator(); + while ( tempIterator.hasNext() ) + { + Hashtable clientObj = (Hashtable) tempIterator.next(); + + // check that it is the object we expect + String objectType = (String) clientObj.get(WDDXTAGS102.OBJECT_TYPE); + if ( ! isOptionalActivity(objectType) ) + { + throw new Exception(getExpectedOptionalActivity() + + " received "+ objectType + ". Unable to store ."); + } + + Integer objId = WDDXProcessor.convertToInteger("Optional Activity ID", clientObj.get(WDDXTAGS102.LD_ITEM_ID) ); + if ( LDWDDXValueObjectFactory.NUMERIC_NULL_VALUE_INTEGER.equals(objId) ) + { + throw new Exception("Id for optional activity is the internal null value. Optional activity is"+clientObj.toString()); + } + + OptionalActivityDefnVO optAct = ldInProgress.selectOptionalActivity(objId.intValue()); + if ( optAct == null ) { + optAct = new OptionalActivityDefnVO(); + storeInSession(session, optAct); + ldInProgress.getOptionalActivities().add(optAct); + } + updateOptionalActivity(session, clientObj, objId, optAct); + m_allItems.put(objId, optAct); + idsUpdated.add(objId); + + } + + // now delete all the old, untouched optional activities + tempIterator = ldInProgress.getOptionalActivities().iterator(); + while ( tempIterator.hasNext() ) + { + OptionalActivityDefnVO activity = (OptionalActivityDefnVO) tempIterator.next(); + Integer activityId = new Integer(activity.getId()); + if ( ! idsUpdated.contains(activityId) ) + { + log.debug("Removing optional activity as no longer needed in design #" + +ldInProgress.getSid()+" activity: "+activity.toString()); + tempIterator.remove(); + deleteOptionalActivity(session, activity); + } + } + + + } + + + + + *//** Update a multitask - this will contain inner tasks + *//* + protected void updateMultiTask(PersistenceSession session, Hashtable clientObj, MultiTaskVO multiTask, Integer objId) + throws Exception + { + Integer taskId = WDDXProcessor.convertToInteger("InputContentTask", + clientObj.get(WDDXTAGS102.MTASK_INPUT_CONTENT_TASK)); + if ( ! LDWDDXValueObjectFactory.NUMERIC_NULL_VALUE_INTEGER.equals(objId) ) + multiTask.setInputContentTask(taskId); + else + multiTask.setInputContentTask(null); + + taskId = WDDXProcessor.convertToInteger("OutputContentTask", + clientObj.get(WDDXTAGS102.MTASK_OUTPUT_CONTENT_TASK)); + if ( ! LDWDDXValueObjectFactory.NUMERIC_NULL_VALUE_INTEGER.equals(objId) ) + multiTask.setOutputContentTask(taskId); + else + multiTask.setOutputContentTask(null); + + multiTask.setTaskOrderOnScreen((String)clientObj.get(WDDXTAGS102.MTASK_SUBTASK_ORDER)); + + Set subTasks = multiTask.getSubTasks(); + if ( subTasks == null ) { + subTasks = new HashSet(); + multiTask.setSubTasks(subTasks); + subTasks = multiTask.getSubTasks(); + } + + List subTasksWDDX = (List)clientObj.get(WDDXTAGS102.MTASK_SUBTASKS); + if ( subTasksWDDX != null ) + { + Iterator iter = subTasksWDDX.iterator(); + while ( iter.hasNext() ) + { + + Hashtable subTaskWDDX = (Hashtable) iter.next(); + + String objectType = (String) subTaskWDDX.get(WDDXTAGS102.OBJECT_TYPE); + if ( ! isTask(objectType) ) + { + throw new Exception(getExpectedTask() + "received " + objectType ); + } + taskId = WDDXProcessor.convertToInteger("Task ID", subTaskWDDX.get(WDDXTAGS102.LD_ITEM_ID) ); + AbstractTaskVO subTask = multiTask.selectTaskById(taskId.intValue()); + if ( subTask == null ) { + subTask = createNewTask( subTaskWDDX ); + storeInSession(session,subTask); + subTasks.add(subTask); + } + + updateTask(session, subTaskWDDX, subTask, taskId ); + + } + } + + } + + + */ + + /** Links the tasks that are done as a group to the group definition. + *

    + * throws exception with any errors + *//* + protected void setGroupToTaskLinks() throws Exception + { + if ( log.isDebugEnabled() ) + log.debug("setGroupToTaskLinks: m_groupingsToDo="+(m_groupingsToDo!=null?m_groupingsToDo.toString():"null")); + + if ( m_groupingsToDo == null || m_groupingsToDo.isEmpty()) + return; + + Map allTasksById = ldInProgress.allTasks(false); + Set keys = m_groupingsToDo.keySet(); + Iterator linksToProcess = keys.iterator(); + while ( linksToProcess.hasNext() ) + { + Integer taskId = (Integer) linksToProcess.next(); + AbstractTaskVO task = (AbstractTaskVO) allTasksById.get(taskId); + if ( task == null ) + { + String message = "Assigning grouping definition to a task. Internal error task not found. Task sid = "+taskId; + log.error(message); + throw new Exception (message); + } + + Integer groupingTaskId = (Integer) m_groupingsToDo.get(taskId); + + log.debug("Processing group link, task id="+taskId+" groupingTaskId "+groupingTaskId); + + Object obj = null; + GroupingTaskVO groupingtask = null; + try { + obj = allTasksById.get(groupingTaskId); + groupingtask = (GroupingTaskVO) obj; + } catch ( ClassCastException cce ) + { + String message = "Assigning grouping definition to a task. Grouping task not correct type. Task id = "+groupingTaskId + +" expected to be grouping task, got "+obj.toString() + +" Was trying to find grouping task for task "+task.toString(); + log.error(message); + throw new Exception (message); + } + + if ( groupingtask == null ) + { + String message = "Assigning grouping definition to a task. Matching grouping task not found. " + + "Looking for grouping task " + + groupingTaskId + + " for task " + + task.toString(); + log.error(message); + throw new Exception (message); + } + + GroupDefnVO groupDefn = groupingtask.getGroupDefn(); + if ( groupDefn == null ) + { + String message = "Assigning grouping definition to a task. Matching grouping task missing grouping defn. " + + "Grouping task " + + groupingtask.toString() + + " for task " + + task.toString(); + log.error(message); + throw new Exception (message); + } + + if ( log.isDebugEnabled() ) + log.debug("Adding group definition to groupsForTask. GroupDefn="+groupDefn); + + + // finally, all is well so add definition link to task. Really should be + // validating that the the grouping task is done first in the sequence but + // haven't implemented that yet! + if ( task.getGroupsForTask() == null ) + { + task.setGroupsForTask(new HashSet()); + } + + task.getGroupsForTask().add(groupDefn); + + if ( log.isDebugEnabled() ) + log.debug("GroupsForTask is now ="+task.getGroupsForTask()); + + } + } + + */ + + /** + * @param clientObj - hashtable from WDDX + * @param ui_id - Flash assigned id. + * @param transition - transition to update + */ + protected void processTransition( Hashtable clientObj) { + + try { + Transition transition = new Transition(); + transition.setTransitionUIID(WDDXProcessor.convertToInteger("Transition ID", clientObj.get(WDDXTAGS102.LD_ITEM_ID))); + transition.setCreateDateTime(createDate); + + String completion = (String)clientObj.get(WDDXTAGS102.TRANSITION_COMPLETIONTYPE); + if ( WDDXTAGS102.TRANSITION_COMPLETION_SYNCRONIZE.equals(completion)) { + // TODO create synchronise gate + } else if ( completion != null && completion.length() > 0 ) { + // TODO create permission gate + } + + Integer toActivity = WDDXProcessor.convertToInteger("ToTaskActivities",clientObj.get(WDDXTAGS102.TRANSITION_TO_TASKS)); + if ( ! NUMERIC_NULL_VALUE_INTEGER.equals(toActivity) ) { + Activity activity = getMatchingActivity(toActivity); + if ( activity != null ) { + transition.setToUIID(activity.getActivityUIID()); + transition.setToActivity(activity); + activity.setTransitionTo(transition); + } + } + if ( transition.getToActivity() == null ) { + String msg = "Can't find matching activity "+toActivity+" for transition. Transition will be missing in the design. Transition "+clientObj; + log.error(msg); + toolsErrorMsgs.add(msg); + return; + } + + Integer fromActivity = WDDXProcessor.convertToInteger("FromTaskActivities",clientObj.get(WDDXTAGS102.TRANSITION_FROM_TASKS)); + if ( ! NUMERIC_NULL_VALUE_INTEGER.equals(fromActivity) ) { + Activity activity = getMatchingActivity(fromActivity); + if ( activity != null ) { + transition.setFromUIID(activity.getActivityUIID()); + transition.setFromActivity(activity); + activity.setTransitionFrom(transition); + } + } + if ( transition.getFromActivity() == null ) { + String msg = "Can't find matching activity "+fromActivity+" for transition. Transition will be missing in the design. Transition "+clientObj; + log.error(msg); + toolsErrorMsgs.add(msg); + return; + } + + transition.setLearningDesign(ldInProgress); + ldInProgress.getTransitions().add(transition); + baseDAO.insert(transition); + + } catch ( WDDXProcessorConversionException e ) { + handleWDDXProcessorConversionException(e); + } + } + + /** 1.0.x has tasks within activities, so the UIID on the 2.0 activity is the UIID of the task but the transition may be looking for + * the UIID of the outer activity. So when we go looking for an activity we look for either the activity based on the activity or the + * "child" task. + * @param uiID + * @return + */ + private Activity getMatchingActivity(Integer uiID) { + + Activity activity = newActivityMap.get(uiID); + if ( activity == null ) { + Integer childActivityId = flattenedActivityMap.get(uiID); + if ( childActivityId!=null ) { + activity = newActivityMap.get(childActivityId); + } + } + return activity; + } +/* + protected void processTaskTransitions(PersistenceSession session, List newTT, ActivityDefnVO activity ) + throws Exception + { + Set currentTasks = activity.getTasks(); + Set currentTransitions = activity.getTransitions(); + + // much the same again - cycle through tasks and transitions. Update existing ones, add new ones + + Iterator iterator = newTT.iterator(); + while ( iterator.hasNext() ) + { + Hashtable clientObj = (Hashtable) iterator.next(); + + // check that it is the object we expect + String objectType = (String) clientObj.get(WDDXTAGS102.OBJECT_TYPE); + if ( ! ( isTask(objectType) || isTransition(objectType)) ) + { + throw new Exception(getExpectedTaskTransition()+ " received " + objectType ); + } + + Integer objId = WDDXProcessor.convertToInteger("Task/Transition ID", clientObj.get(WDDXTAGS102.LD_ITEM_ID) ); + if ( LDWDDXValueObjectFactory.NUMERIC_NULL_VALUE_INTEGER.equals(objId) ) + throw new Exception("Id value for task/transition is internal null value. Task/transition is "+clientObj.toString()); + + if ( isTask(objectType) ) { + AbstractTaskVO task = activity.selectTaskById(objId.intValue()); + if ( task == null ) { + task = createNewTask( clientObj ); + storeInSession(session,task); + currentTasks.add(task); + } + updateTask(session, clientObj, task, objId ); + m_allItems.put(objId, task); + } else { + TransitionDefnVO transition = activity.selectTransitionbyId(objId.intValue()); + if ( transition == null ) { + transition = new TransitionDefnVO(); + storeInSession(session,transition); + currentTransitions.add(transition); + } + updateTransition(clientObj, objId, transition); + m_allItems.put(objId, transition); + } + } + + } + + *//** + * update Optional Activity (OptionalActivityDefnVO) + * @param clientObj - hashtable from WDDX + * @param objId - internal id within learning design. will be 0 or 1 for library activities + * @param activity - optional activity to update + *//* + protected void updateOptionalActivity(PersistenceSession session, Hashtable clientObj,Integer objId, + OptionalActivityDefnVO optAct) + throws Exception + { + optAct.setId(objId.intValue()); + optAct.setDescription((String)clientObj.get(WDDXTAGS102.DESCRIPTION)); + optAct.setTitle((String)clientObj.get(WDDXTAGS102.TITLE)); + + Integer toTask = WDDXProcessor.convertToInteger("Minimum number activities to complete", + clientObj.get(WDDXTAGS102.OPTACT_MIN_NUMBER_COMPLETE)); + optAct.setMinNumberComplete(toTask); + + optAct.setXcoordStart(WDDXProcessor.convertToInteger("X co-ord start", + clientObj.get(WDDXTAGS102.OPTACT_X_START))); + optAct.setYcoordStart(WDDXProcessor.convertToInteger("Y co-ord start", + clientObj.get(WDDXTAGS102.OPTACT_Y_START))); + optAct.setXcoordEnd(WDDXProcessor.convertToInteger("X co-ord start", + clientObj.get(WDDXTAGS102.OPTACT_X_END))); + optAct.setYcoordEnd(WDDXProcessor.convertToInteger("Y co-ord start", + clientObj.get(WDDXTAGS102.OPTACT_Y_END))); + + + // activites, min # to compelte + Set activities = optAct.getActivities(); + if ( activities == null ) + { + optAct.setActivities(new HashSet()); + } + + Vector activityIds = (Vector) clientObj.get(WDDXTAGS102.OPTACT_ACTIVITIES); + if ( activityIds != null ) + { + Iterator iter = activityIds.iterator(); + while ( iter.hasNext()) + { + Integer id = WDDXProcessor.convertToInteger("Activity ID in Optional Activity", iter.next()); + ActivityDefnVO act = ldInProgress.selectActivity(id.intValue()); + if ( act == null ) + { + log.error("Unable to find activity object to match optional activity definition. Optional activity is " + +optAct.toString() +" looking for activity id " +id); + throw new Exception("Unable to find activity object to match optional activity definition. " + +" Optional activity id is "+ + +optAct.getId() +" looking for activity id " +id); + } + + optAct.getActivities().add(act); + } + } + + // now create/update the dummy task used at runtime (never passed to authoring client) + updateDummyTask(session, optAct); + + } + + + ******************************* Library routines ********************** + + *//** + * Store an activity in a library + *//* + protected ClientStatusMessage processLibraryActivity(Hashtable libHashTable, Long userId) + throws NamingException, SQLException + { + LibraryDefnVO lib = null; + ClientStatusMessage result = null; + Long libId = null; + + PersistenceSession session = new PersistenceSession(); + boolean okayToSave = true; + + try { + // convert id to int; if fails due to format or not existing, then + // assume we use the "default" library + try { + libId = WDDXProcessor.convertToLong("Library Id",libHashTable.get(WDDXTAGS102.SID)); + } catch ( Exception e) { + // don't care - assume not valid! + } + + lib = LDWDDXValueObjectFactory.findCreateLibrary( session, libId, userId ); + storeLibraryActivity(session, libHashTable, lib, userId); + result = new ClientStatusMessage(ClientStatusMessage.RECEIVED, + " stored okay", lib.getSid().toString() ); + } catch (Exception e) { + result = new ClientStatusMessage(ClientStatusMessage.ERROR, + "Error occured while storing activity sequence. Unable to store sequence. "+e.getMessage(), + ( lib!=null ? lib.getSid().toString() : "") ); + log.error("Error occured while storing activity sequence. Unable to store sequence. Trying to store"+ + ( lib!=null ? lib.getSid().toString() : "") , e); + okayToSave = false; + } + + try { + if(okayToSave){ + session.flush(); + session.close(); + session = null; + } + } catch ( Exception e) + { + log.error("Error occured while saving / closing the database connection. Data may not be saved.",e); + result = new ClientStatusMessage(ClientStatusMessage.ERROR, + "Error occured while saving / closing the database connection. Data may not be saved. "+e.getMessage(), + ( lib!=null ? lib.getSid().toString() : "") ); + } + + return(result); + } + + private void storeLibraryActivity(PersistenceSession session, Hashtable newLibHashTable, LibraryDefnVO lib, Long userId) + throws RuntimeException, Exception + { + Set packages = lib.getLibraryPackages(); + if ( packages == null ) + { + // do the create, set and reload fiddle due to hibernate replacing + // my collection with its own collection. + packages = new HashSet(); + lib.setLibraryPackages(packages); + packages = lib.getLibraryPackages(); + } + + Vector newPackages = (Vector) newLibHashTable.get(WDDXTAGS102.LIB_PACKAGES); + if ( newPackages == null ) + { + // log warning - no packages found in library + log.warn("No packages were found for #"+lib.getSid()); + } + else + { + + String value = (String) newLibHashTable.get(WDDXTAGS102.DESCRIPTION); + if ( value != null && value.length() > 0 ) + { + lib.setDescription(value); + } + value = (String) newLibHashTable.get(WDDXTAGS102.TITLE); + if ( value != null && value.length() > 0 ) + { + lib.setTitle(value); + } + + // cycle through packages. Update existing ones, add new ones + // don't have delete support at the moment. + + Iterator tempIterator = newPackages.iterator(); + while ( tempIterator.hasNext() ) + { + Hashtable clientObj = (Hashtable) tempIterator.next(); + + // check that it is the object we expect + String objectType = (String) clientObj.get(WDDXTAGS102.OBJECT_TYPE); + if ( ! isLibraryPackage(objectType) ) + { + throw new Exception( getExpectedLibraryPackage() + " received "+ objectType + ". Unable to store ."); + } + + Long sid = null; + try { + sid = WDDXProcessor.convertToLong("Package Sid", clientObj.get(WDDXTAGS102.SID) ); + } catch (Exception e) { + // if fails to convert, then assume new... + } + + LearningDesignDefnVO packageToUpdate = null; + packageToUpdate = lib.selectPackage(sid); + + if ( packageToUpdate == null ) + { + packageToUpdate = new LearningDesignDefnVO(LearningDesignDefnVO.LIBPACKAGE_OBJECT_TYPE); + storeInSession(session,packageToUpdate); + packages.add(packageToUpdate); + } + + Long id = null; + try { + id = WDDXProcessor.convertToLong("Package ID", + clientObj.get(WDDXTAGS102.LD_ITEM_ID) ); + } catch (Exception e) { + } + if ( id == null ) + { + id = new Long(0); + } + + updateLearningDesign(session, clientObj, id, packageToUpdate, userId); + } + } + } + + *//** Create/Update a dummy task (stored using setDummyTask) + * @param optAct - Optional Activity that this dummy task belongs. + *//* + public void updateDummyTask(PersistenceSession session, OptionalActivityDefnVO optAct) throws Exception + { + OptionalActivityDummyTaskVO result = optAct.getDummyTask(); + + if ( result == null ) { + result = new OptionalActivityDummyTaskVO(); + } + result.setCompletion(""); + result.setDescription(optAct.getDescription()); + if ( result.getGroupsForTask() == null ) + { + result.setGroupsForTask(new HashSet()); + } + result.setId(optAct.getId()); + result.setTitle(optAct.getTitle()); + + if ( result.getSubFirstTasks() == null ) + { + result.setSubFirstTasks(new HashSet()); + } + result.getSubFirstTasks().clear(); + + if ( optAct.getActivities() != null ) + { + Iterator iter = optAct.getActivities().iterator(); + while ( iter.hasNext()) + { + ActivityDefnVO activity = (ActivityDefnVO) iter.next(); + AbstractTaskVO task = activity.getFirstTask(); + if ( task != null ) + { + result.getSubFirstTasks().add(task); + } + } + } + result.setOptionalActivity(optAct); + + storeInSession(session,result); + //session.flush(); + + optAct.setDummyTask(result); + } +*/ + + /** Get all the tool icons based on the library activities + * @return Map of tool icons - key is tool id, value is url. */ + private Map getLibraryActivityUiImages() { + + HashMap imageURLS = new HashMap(); + Iterator iterator = learningLibraryDAO.getAllLearningLibraries().iterator(); + while(iterator.hasNext()){ + LearningLibrary learningLibrary = (LearningLibrary)iterator.next(); + List templateActivities = activityDAO.getActivitiesByLibraryID(learningLibrary.getLearningLibraryId()); + Iterator actIterator = templateActivities.iterator(); + while ( actIterator.hasNext() ) { + Activity activity = (Activity) actIterator.next(); + if ( activity.isToolActivity() ) { + ToolActivity toolActivity = (ToolActivity) activityDAO.getActivityByActivityId(activity.getActivityId(), ToolActivity.class); + Tool tool = toolActivity.getTool(); + if ( ! imageURLS.containsKey(tool.getToolId()) ) { + imageURLS.put(tool.getToolId(), activity.getLibraryActivityUiImage()); + } + } + } + } + return imageURLS; + } +} Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/service/LearningDesignService.java =================================================================== diff -u -r6633f5d5c7844c27582a9b323fead87fac99dfd5 -r2b636f4e834cd0b45c00bb3abf6a6b5e5f3161c8 --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/service/LearningDesignService.java (.../LearningDesignService.java) (revision 6633f5d5c7844c27582a9b323fead87fac99dfd5) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/service/LearningDesignService.java (.../LearningDesignService.java) (revision 2b636f4e834cd0b45c00bb3abf6a6b5e5f3161c8) @@ -23,26 +23,19 @@ /* $$Id$$ */ package org.lamsfoundation.lams.learningdesign.service; -import org.apache.log4j.Logger; -import org.lamsfoundation.lams.learningdesign.dao.hibernate.ActivityDAO; -import org.lamsfoundation.lams.learningdesign.dao.hibernate.GroupingDAO; -import org.lamsfoundation.lams.learningdesign.dao.hibernate.LearningDesignDAO; -import org.lamsfoundation.lams.learningdesign.dao.hibernate.LearningLibraryDAO; -import org.lamsfoundation.lams.learningdesign.dao.hibernate.LicenseDAO; -import org.lamsfoundation.lams.learningdesign.dao.hibernate.TransitionDAO; -import org.lamsfoundation.lams.learningdesign.dto.LearningDesignDTO; -import org.lamsfoundation.lams.learningdesign.dto.ValidationErrorDTO; +import java.util.Iterator; +import java.util.Set; +import java.util.Vector; + import org.lamsfoundation.lams.learningdesign.Activity; -import org.lamsfoundation.lams.learningdesign.GateActivity; import org.lamsfoundation.lams.learningdesign.Grouping; import org.lamsfoundation.lams.learningdesign.LearningDesign; import org.lamsfoundation.lams.learningdesign.OptionsActivity; import org.lamsfoundation.lams.learningdesign.Transition; -import java.util.Iterator; -import java.util.Set; -import java.util.Vector; - -import org.lamsfoundation.lams.tool.dao.hibernate.ToolDAO; +import org.lamsfoundation.lams.learningdesign.dao.hibernate.ActivityDAO; +import org.lamsfoundation.lams.learningdesign.dao.hibernate.LearningDesignDAO; +import org.lamsfoundation.lams.learningdesign.dto.LearningDesignDTO; +import org.lamsfoundation.lams.learningdesign.dto.ValidationErrorDTO; import org.lamsfoundation.lams.util.MessageService; /** @@ -111,10 +104,10 @@ * @param learningDesign * @return list of validation errors */ - public Vector validateLearningDesign(LearningDesign learningDesign) + public Vector validateLearningDesign(LearningDesign learningDesign) { - Vector listOfValidationErrorDTOs = new Vector(); // initialises the list of validation messages. + Vector listOfValidationErrorDTOs = new Vector(); // initialises the list of validation messages. validateActivityTransitionRules(learningDesign.getParentActivities(), learningDesign.getTransitions(), listOfValidationErrorDTOs); validateGeneral(learningDesign.getActivities(), listOfValidationErrorDTOs); @@ -136,11 +129,11 @@ * @param topLevelActivities * @param transitions */ - private void validateActivityTransitionRules(Set topLevelActivities, Set transitions, Vector listOfValidationErrorDTOs) + private void validateActivityTransitionRules(Set topLevelActivities, Set transitions, Vector listOfValidationErrorDTOs) { validateTransitions(transitions, listOfValidationErrorDTOs); - Vector noInputTransition = new Vector(); //a list to hold the activities which have no input transition - Vector noOuputTransition = new Vector(); //a list to hold the activities which have no output transition + Vector noInputTransition = new Vector(); //a list to hold the activities which have no input transition + Vector noOuputTransition = new Vector(); //a list to hold the activities which have no output transition int numOfTopLevelActivities = topLevelActivities.size(); Iterator activityIterator = topLevelActivities.iterator(); @@ -194,7 +187,7 @@ * the ValidationErrorDTO is added to the list of validation messages. * @param transitions the set of transitions to iterate through and validate */ - private void validateTransitions(Set transitions, Vector listOfValidationErrorDTOs) + private void validateTransitions(Set transitions, Vector listOfValidationErrorDTOs) { Iterator i = transitions.iterator(); while (i.hasNext()) @@ -220,7 +213,7 @@ * @param activity The Activity to validate * @param numOfActivities The number of activities in the learning design. */ - private void checkActivityForTransition(Activity activity, int numOfActivities, Vector listOfValidationErrorDTOs) + private void checkActivityForTransition(Activity activity, int numOfActivities, Vector listOfValidationErrorDTOs) { //if one activity, then shouldnt have any transitions Transition inputTransition = activity.getTransitionTo(); @@ -246,7 +239,7 @@ * * @param activities */ - private void validateGeneral(Set activities, Vector listOfValidationErrorDTOs) + private void validateGeneral(Set activities, Vector listOfValidationErrorDTOs) { Iterator activityIterator = activities.iterator(); while (activityIterator.hasNext()) @@ -256,7 +249,7 @@ validateGroupingIfGroupingIsApplied(activity, listOfValidationErrorDTOs); validateOptionalActivity(activity, listOfValidationErrorDTOs); validateOptionsActivityOrderId(activity, listOfValidationErrorDTOs); - Vector activityErrors = (Vector)activity.validateActivity(messageService); + Vector activityErrors = activity.validateActivity(messageService); if(activityErrors != null && !activityErrors.isEmpty()) listOfValidationErrorDTOs.addAll(activityErrors); } @@ -273,7 +266,7 @@ * * @param activity */ - private void checkIfGroupingRequired(Activity activity, Vector listOfValidationErrorDTOs) + private void checkIfGroupingRequired(Activity activity, Vector listOfValidationErrorDTOs) { Integer groupingSupportType = activity.getGroupingSupportType(); @@ -303,7 +296,7 @@ * * @param parentActivity */ - private void validateOptionalActivity(Activity parentActivity, Vector listOfValidationErrorDTOs) + private void validateOptionalActivity(Activity parentActivity, Vector listOfValidationErrorDTOs) { if (parentActivity.isOptionsActivity()) Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/service/WDDXTAGS102.java =================================================================== diff -u --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/service/WDDXTAGS102.java (revision 0) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/service/WDDXTAGS102.java (revision 2b636f4e834cd0b45c00bb3abf6a6b5e5f3161c8) @@ -0,0 +1,221 @@ +/**************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2.0 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ + +/* $Id$ */ +package org.lamsfoundation.lams.learningdesign.service; + +/** + * WDDX tags used in LAMS 1.0.2 + */ +public class WDDXTAGS102 { + + public static final String OBJECT_TYPE = "objectType"; + public static final String DESCRIPTION = "description"; + public static final String TITLE = "title"; + public static final String LD_ITEM_ID = "id"; + public static final String SID = "sid"; + public static final String DELETE = "delete"; // delete this object (and sub objects) + + public static final String DATE_PATTERN = "yyyy-MM-dd HH:mm:ss Z"; + + // The transition following this activity or task. Applicable only to task and + // activity. + public static final String FOLLOWING_TRANSITION = "nextTransition"; + + // learning design specific tags + public static final String LD_MAXID = "maxId"; + public static final String LD_ID = "LDId"; + public static final String LD_ACTTRAN = "activitiesTransitions"; + public static final String LD_CONTENT = "content"; + public static final String LD_FIRSTACT = "firstActivity"; + + public static final String LD_VERSION = "lamsVersion"; + + public static final String LD_READONLY = "readOnly"; // read only as it has been run. + public static final String LD_READACCESS_STATUS = "readAccessStatus"; // read only access based on privilege. boolean value + public static final String LD_READACCESS_DESC = "readAccessDesc"; // "private", "global" or organisation name + public static final String LD_READACCESS_ID = "readAccess"; // public, private or organisation id + public static final String LD_WRITEACCESS_STATUS = "writeAccessStatus"; // write acess read based on privilege. boolean value + public static final String LD_WRITEACCESS_DESC = "writeAccessDesc"; // "private", "global" or organisation name + public static final String LD_WRITEACCESS_ID = "writeAccess"; // public, private or organisation id + public static final String LD_HELPTEXT = "helpText"; + + public static final String PRIVATE_VALUE="Private"; + public static final String GLOBAL_VALUE="Globally available"; + + // activity specific tags + public static final String ACT_LIBRARY_ID = "libId"; + public static final String ACT_TASKTRAN = "tasksTransitions"; + public static final String ACT_FIRSTTASK = "firstTask"; + public static final String ACT_X = "x"; + public static final String ACT_Y = "y"; + + // task specific tags + public static final String TASK_COMPLETION = "completion"; + public static final String TASK_TOOLTYPE = "toolType"; + public static final String TASK_INPUT_CONTENT = "inputContent"; + public static final String TASK_OUTPUT_CONTENT = "outputContent"; + public static final String TASK_GROUPING = "grouping"; + public static final String TASK_GROUPING_CLASS_VALUE = "c"; + + // multi task specific tags + public static final String MTASK_SUBTASKS = "subTasks"; + public static final String MTASK_INPUT_CONTENT_TASK = "inputContentTask"; + public static final String MTASK_OUTPUT_CONTENT_TASK = "outputContentTask"; + public static final String MTASK_SUBTASK_ORDER = "taskOrder"; + + // transition specific tags + public static final String TRANSITION_COMPLETIONTYPE = "completionType"; + public static final String TRANSITION_FROM_TASKS = "fromTasks"; + public static final String TRANSITION_TO_TASKS = "toTasks"; + + /** Transition is based on multiple learners completing a task (synchronize) + * or a teacher controlling the transition (synchronize_teacher) + * - this should be used for TransitionVODefn and subclasses */ + public static final String TRANSITION_COMPLETION_SYNCRONIZE = "synchronize"; + public static final String TRANSITION_COMPLETION_SYNCRONIZE_TEACHER = "synchronize_teacher"; + public static final String TRANSITION_COMPLETION_SYNCRONIZE_BOTH = "synchronize_both"; + + // library specific tags + public static final String LIB_PACKAGES = "packages"; + public static final String LIB_ACTIVITIES = "activities"; + + // ld list specific tags + public static final String LD_LIST = "list"; + + // content specific tags + public static final String CONTENT_BODY = "body"; + public static final String CONTENT_SHOW_USER = "contentShowUser"; // boolean + public static final String CONTENT_DEFINE_LATER = "contentDefineLater"; // boolean + + // contentType is based on the content class used - doesn't persist + public static final String CONTENT_TYPE = "contentType"; + public static final String CONTENT_NUMGROUPS = "number_groups"; + public static final String CONTENT_MINNUM_GROUP = "min_number_in_group"; + public static final String CONTENT_MAXNUM_GROUP = "max_number_in_group"; + + // Ranking tool tags + public static final String CONTENT_VOTE_MAXCHOOSE = "maxChoose"; + public static final String CONTENT_VOTE_METHOD = "voteMethod"; // equal vote or preferential + public static final String CONTENT_VOTE_NOMINATIONS = "nominations"; + public static final String CONTENT_VOTE_ALLOW_POLL_NOMINATIONS = "nominatePollTime"; // allow nomination or not (Boolean) + public static final String CONTENT_VOTE_PROGRESSIVE_DISPLAY = "progressive_display"; + + // url content + public static final String CONTENT_URL_MIN_NUMBER_COMPLETE = "minNumberComplete"; + public static final String CONTENT_URL_RUNTIME_STAFF_SUBMIT_URL = "runtimeSubmissionStaffURL"; + public static final String CONTENT_URL_RUNTIME_LEARNER_SUBMIT_URL = "runtimeSubmissionLearnerURL"; + public static final String CONTENT_URL_RUNTIME_STAFF_SUBMIT_FILE = "runtimeSubmissionStaffFile"; + public static final String CONTENT_URL_RUNTIME_LEARNER_SUBMIT_FILE = "runtimeSubmissionLearnerFile"; + public static final String CONTENT_URL_URLS = "urls"; + + public static final String CONTENT_URL_URL_SHOWBUTTONS = "showbuttons"; + public static final String CONTENT_URL_URL_VIEW_ORDER = "order"; + public static final String CONTENT_URL_URL_TITLE = "title"; + public static final String CONTENT_URL_URL_URL = "url"; + public static final String CONTENT_URL_URL_DOWNLOAD = "download"; // boolean: Author prefers that the content is downloaded. Only applicable to file content. + public static final String CONTENT_URL_URL_TYPE= "resourcetype"; // see URLContent TYPE_* fields + public static final String CONTENT_URL_URL_INSTRUCTION_ARRAY = "instructions"; + public static final String CONTENT_URL_INSTRUCTION = "instruction"; + + // message content + public static final String CONTENT_MB_TERMINATION_TYPE = "terminationType"; // type string + public static final String CONTENT_MB_DURATION_DAYS = "durationInDays"; // type string + public static final String CONTENT_MB_POSTING_NOTIFIED = "isPostingNotified"; // type boolean + public static final String CONTENT_MB_POSTING_MODERATED = "isPostingModerated"; // type boolean + public static final String CONTENT_MB_NEW_TOPIC_ALLOWED = "isNewTopicAllowed"; //type boolean + public static final String CONTENT_MB_REUSABLE = "isReusable"; //type boolean + public static final String CONTENT_MB_TOPICS = "topics"; // array + + public static final String CONTENT_MB_TOPIC_TITLE = "title"; // string + public static final String CONTENT_MB_TOPIC_SUBJECT = "subject"; // string + public static final String CONTENT_MB_TOPIC_MESSAGE = "message"; // string + public static final String CONTENT_MB_TOPIC_NUMBER = "number"; // number + + // Simple Questions content + public static final String CONTENT_Q_SHOW_FEEDBACK = "showfeedback"; // boolean + public static final String CONTENT_Q_ALLOW_REDO = "allowredo"; // integer + public static final String CONTENT_Q_MIN_PASSMARK = "minpassmark"; // integer + public static final String CONTENT_Q_SHOW_TOP_USERNAMES= "showtopusernames"; // boolean + public static final String CONTENT_Q_ORDER = "order"; // integer + public static final String CONTENT_Q_QUESTION_INFO = "questionanswers"; // string + public static final String CONTENT_Q_QUESTION = "question"; // string + public static final String CONTENT_Q_FEEDBACK = "feedback"; // string + public static final String CONTENT_Q_CANDIDATES = "candidates"; // array of string + public static final String CONTENT_Q_ANSWER = "answer"; // string + + // optional activity fields + public static final String OPTACT_MIN_NUMBER_COMPLETE = "minNumberComplete"; + public static final String OPTACT_ACTIVITIES = "activities"; + public static final String OPTACT_X_START = "x"; + public static final String OPTACT_Y_START = "y"; + public static final String OPTACT_X_END = "xEnd"; + public static final String OPTACT_Y_END = "yEnd"; + + // for file upload - SingleResource, HTMLNoticeboard, Image tools + public static final String DIRECTORY_NAME = "directoryName"; + + // ImageGallery task tags (extended from Content.java) + public static final String CONTENT_IMGG_DIRECTORY = DIRECTORY_NAME; + public static final String CONTENT_IMGG_TITLE = TITLE; + public static final String CONTENT_IMGG_BODY = CONTENT_BODY; + public static final String CONTENT_IMGG_DEFINE_LATER = CONTENT_DEFINE_LATER; //Bolean + public static final String CONTENT_IMGG_GROUPING = TASK_GROUPING; + public static final String CONTENT_IMGG_SHOW_USER = CONTENT_SHOW_USER; + public static final String CONTENT_IMGG_MAX_IMAGES = "maxImages"; + public static final String CONTENT_IMGG_ALLOW_SEARCH = "allowSearch"; // Boolean + public static final String CONTENT_IMGG_SEARCH_URL = "searchURL"; + public static final String CONTENT_IMGG_ALLOW_URL = "allowURL"; // Boolean + public static final String CONTENT_IMGG_ALLOW_UPLOAD = "allowUpload"; + public static final String CONTENT_IMGG_IMAGES = CONTENT_URL_URLS; + // ImageGallery images array (also used by ImageRanking) + public static final String CONTENT_IMGG_IMAGE_SID = SID; + public static final String CONTENT_IMGG_IMAGE_TITLE = TITLE; + public static final String CONTENT_IMGG_IMAGE_COMMENTS = "comments"; + public static final String CONTENT_IMGG_IMAGE_VIEW_ORDER = "order"; + public static final String CONTENT_IMGG_IMAGE_DATECREATED = "dateCreated"; + public static final String CONTENT_IMGG_IMAGE_DATEUPDATED = "dateUpdated"; + public static final String CONTENT_IMGG_IMAGE_TYPE = "type"; // "resourceType", values are "externalurl" or "file" + public static final String CONTENT_IMGG_IMAGE_URL = "url"; + public static final String CONTENT_IMGG_IMAGE_FILENAME = "filename"; + public static final String CONTENT_IMGG_IMAGE_PATH = "path"; + public static final String CONTENT_IMGG_IMAGE_OWNERID = "ownerId"; + public static final String CONTENT_IMGG_IMAGE_OWNERNAME = "owerName"; + // Additional field to use the image array for ImageRanking (runtime only) + public static final String CONTENT_IMGR_IMAGE_IS_SELECTED = "isSelected"; + + // ImageRanking task tags (extended from Content.java) + public static final String CONTENT_IMGR_DIRECTORY = DIRECTORY_NAME; + public static final String CONTENT_IMGR_TITLE = TITLE; + public static final String CONTENT_IMGR_BODY = CONTENT_BODY; // this is the description + public static final String CONTENT_IMGR_DEFINE_LATER = CONTENT_DEFINE_LATER; //Bolean + public static final String CONTENT_IMGR_GROUPING = TASK_GROUPING; + public static final String CONTENT_IMGR_SHOW_USER = CONTENT_SHOW_USER; + public static final String CONTENT_IMGR_MAX_VOTE = CONTENT_VOTE_MAXCHOOSE; + public static final String CONTENT_IMGR_PROGRESSIVE_DISPLAY = CONTENT_VOTE_PROGRESSIVE_DISPLAY; // Boolean + public static final String CONTENT_IMGR_IMAGES = CONTENT_URL_URLS; + // ImageRanking images array - same as the ImageGallery images array + + + +} Index: lams_common/src/java/org/lamsfoundation/lams/tool/ToolImportSupport.java =================================================================== diff -u --- lams_common/src/java/org/lamsfoundation/lams/tool/ToolImportSupport.java (revision 0) +++ lams_common/src/java/org/lamsfoundation/lams/tool/ToolImportSupport.java (revision 2b636f4e834cd0b45c00bb3abf6a6b5e5f3161c8) @@ -0,0 +1,132 @@ +/**************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2.0 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ +/* $$Id$$ */ +package org.lamsfoundation.lams.tool; + +import java.io.Serializable; + +import org.apache.commons.lang.builder.EqualsBuilder; +import org.apache.commons.lang.builder.HashCodeBuilder; +import org.apache.commons.lang.builder.ToStringBuilder; + + +/** + * When importing data, which "tool signatures" does a tool support. This maps the + * 1.0.2 tool types to 2.0 tool signatures, and may be used for 2.1 tool versions to automatically + * support 2.0 tool data, even if the tools themselves have changed. + * + * @hibernate.class table="lams_tool_import_support" + */ +public class ToolImportSupport implements Serializable { + + private static final long serialVersionUID = -6212324577067151495L; + + /** identifier field */ + private Long id; + + /** persistent field */ + private String installedToolSignature; + + /** persistent field */ + private String supportsToolSignature; + + /** full constructor */ + public ToolImportSupport(Long id, + String installedToolSignature, + String supportsToolSignature) + { + this.id = id; + this.installedToolSignature = installedToolSignature; + this.supportsToolSignature = supportsToolSignature; + + } + + /** default constructor */ + public ToolImportSupport() { + } + + + /** + * @hibernate.id generator-class="identity" type="java.lang.Long" + * column="id" + */ + public Long getId() { + return this.id; + } + + public void setId(Long id) { + this.id = id; + } + + /** + * @hibernate.property column="installed_tool_signature" + length="15" + not-null="true" + */ + public String getInstalledToolSignature() { + return this.installedToolSignature; + } + + public void setInstalledToolSignature(String installedToolSignature) { + this.installedToolSignature = installedToolSignature; + } + + /** + * @hibernate.property column="supports_tool_signature" + length="50" + not-null="true" + */ + public String getSupportsToolSignature() { + return this.supportsToolSignature; + } + + public void setSupportsToolSignature(String supportsToolSignature) { + this.supportsToolSignature = supportsToolSignature; + } + + public String toString() { + return new ToStringBuilder(this) + .append("id", getId()) + .append("installedToolSignature", getInstalledToolSignature()) + .append("supportsToolSignature", getSupportsToolSignature()) + .toString(); + } + + public boolean equals(Object other) { + if ( (this == other ) ) return true; + if ( !(other instanceof ToolImportSupport) ) return false; + ToolImportSupport castOther = (ToolImportSupport) other; + return new EqualsBuilder() + .append(this.getId(), castOther.getId()) + .append(this.getInstalledToolSignature(), castOther.getInstalledToolSignature()) + .append(this.getSupportsToolSignature(), castOther.getSupportsToolSignature()) + .isEquals(); + } + + public int hashCode() { + return new HashCodeBuilder() + .append(getId()) + .toHashCode(); + } + +} Index: lams_common/src/java/org/lamsfoundation/lams/tool/dao/IToolImportSupportDAO.java =================================================================== diff -u --- lams_common/src/java/org/lamsfoundation/lams/tool/dao/IToolImportSupportDAO.java (revision 0) +++ lams_common/src/java/org/lamsfoundation/lams/tool/dao/IToolImportSupportDAO.java (revision 2b636f4e834cd0b45c00bb3abf6a6b5e5f3161c8) @@ -0,0 +1,32 @@ +/**************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2.0 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ +/* $$Id$$ */ +package org.lamsfoundation.lams.tool.dao; + +import java.util.List; + +public interface IToolImportSupportDAO +{ + /** Get all the ToolImportSupport objects which record support for the given old tool signature */ + public List getToolSignatureWhichSupports(String oldToolSignature); +} Index: lams_common/src/java/org/lamsfoundation/lams/tool/dao/hibernate/ToolImportSupportDAO.java =================================================================== diff -u --- lams_common/src/java/org/lamsfoundation/lams/tool/dao/hibernate/ToolImportSupportDAO.java (revision 0) +++ lams_common/src/java/org/lamsfoundation/lams/tool/dao/hibernate/ToolImportSupportDAO.java (revision 2b636f4e834cd0b45c00bb3abf6a6b5e5f3161c8) @@ -0,0 +1,52 @@ +/**************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2.0 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ +/* $$Id$$ */ +package org.lamsfoundation.lams.tool.dao.hibernate; + +import java.util.List; + +import org.hibernate.HibernateException; +import org.hibernate.Session; +import org.lamsfoundation.lams.tool.dao.IToolImportSupportDAO; +import org.springframework.orm.hibernate3.HibernateCallback; +import org.springframework.orm.hibernate3.support.HibernateDaoSupport; + +public class ToolImportSupportDAO extends HibernateDaoSupport implements IToolImportSupportDAO +{ + private static final String LOAD_BY_OLD_SIG = "from tis in class ToolImportSupport where tis.supportsToolSignature=:supportsToolSignature"; + + /** Get all the ToolImportSupport objects which record support for the given old tool signature */ + public List getToolSignatureWhichSupports(final String oldToolSignature) { + return (List) getHibernateTemplate().execute(new HibernateCallback() + { + public Object doInHibernate(Session session) throws HibernateException + { + return session.createQuery(LOAD_BY_OLD_SIG) + .setString("supportsToolSignature",oldToolSignature) + .list(); + } + }); + + } + +} Index: lams_common/src/java/org/lamsfoundation/lams/toolApplicationContext.xml =================================================================== diff -u -r27fbc8140e958c21edc3aabcdf5579bea45a08c6 -r2b636f4e834cd0b45c00bb3abf6a6b5e5f3161c8 --- lams_common/src/java/org/lamsfoundation/lams/toolApplicationContext.xml (.../toolApplicationContext.xml) (revision 27fbc8140e958c21edc3aabcdf5579bea45a08c6) +++ lams_common/src/java/org/lamsfoundation/lams/toolApplicationContext.xml (.../toolApplicationContext.xml) (revision 2b636f4e834cd0b45c00bb3abf6a6b5e5f3161c8) @@ -12,6 +12,9 @@ + + +