Index: lams_central/src/java/org/lamsfoundation/lams/authoring/ObjectExtractor.java =================================================================== diff -u -r115aaeddeedd191d23a5bac9be3f3350e95d3ff3 -r36c95f28c887810cf5c22f0434a8852d26fbb068 --- lams_central/src/java/org/lamsfoundation/lams/authoring/ObjectExtractor.java (.../ObjectExtractor.java) (revision 115aaeddeedd191d23a5bac9be3f3350e95d3ff3) +++ lams_central/src/java/org/lamsfoundation/lams/authoring/ObjectExtractor.java (.../ObjectExtractor.java) (revision 36c95f28c887810cf5c22f0434a8852d26fbb068) @@ -68,6 +68,7 @@ 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.BranchConditionDTO; import org.lamsfoundation.lams.lesson.LessonClass; import org.lamsfoundation.lams.tool.SystemTool; import org.lamsfoundation.lams.tool.Tool; @@ -153,6 +154,8 @@ protected Set groupingsToDelete = new HashSet(); protected LearningDesign learningDesign = null; protected Date modificationDate = null; + /* cache of system tools so we aren't going back to the db all the time */ + protected HashMap systemTools = new HashMap(); protected Logger log = Logger.getLogger(ObjectExtractor.class); @@ -962,14 +965,15 @@ else buildSequenceActivity((SequenceActivity)activity,activityDetails); } + private void buildBranchingActivity(BranchingActivity branchingActivity,Hashtable activityDetails) throws WDDXProcessorConversionException, ObjectExtractorException { if ( branchingActivity.isChosenBranchingActivity() ) { - branchingActivity.setSystemTool(systemToolDAO.getSystemToolByID(SystemTool.TEACHER_CHOSEN_BRANCHING)); + branchingActivity.setSystemTool(getSystemTool(SystemTool.TEACHER_CHOSEN_BRANCHING)); } else if ( branchingActivity.isGroupBranchingActivity() ) { - branchingActivity.setSystemTool(systemToolDAO.getSystemToolByID(SystemTool.GROUP_BASED_BRANCHING)); + branchingActivity.setSystemTool(getSystemTool(SystemTool.GROUP_BASED_BRANCHING)); } else if ( branchingActivity.isToolBranchingActivity() ) { - branchingActivity.setSystemTool(systemToolDAO.getSystemToolByID(SystemTool.TOOL_BASED_BRANCHING)); + branchingActivity.setSystemTool(getSystemTool(SystemTool.TOOL_BASED_BRANCHING)); } branchingActivity.setStartXcoord(WDDXProcessor.convertToInteger(activityDetails, WDDXTAGS.START_XCOORD)); @@ -991,7 +995,7 @@ groupingActivity.setCreateGroupingUIID(createGroupingUIID); } - SystemTool systemTool = systemToolDAO.getSystemToolByID(SystemTool.GROUPING); + SystemTool systemTool = getSystemTool(SystemTool.GROUPING); groupingActivity.setSystemTool(systemTool); /*Hashtable groupingDetails = (Hashtable) activityDetails.get(WDDXTAGS.GROUPING_DTO); @@ -1015,6 +1019,7 @@ private void buildParallelActivity(ParallelActivity activity,Hashtable activityDetails) throws WDDXProcessorConversionException{ } private void buildSequenceActivity(SequenceActivity activity,Hashtable activityDetails) throws WDDXProcessorConversionException{ + activity.setSystemTool(getSystemTool(SystemTool.SEQUENCE)); } private void buildToolActivity(ToolActivity toolActivity,Hashtable activityDetails) throws WDDXProcessorConversionException{ @@ -1033,7 +1038,7 @@ } } private void buildGateActivity(Object activity,Hashtable activityDetails) throws WDDXProcessorConversionException{ - if(activity instanceof SynchGateActivity) + if(activity instanceof SynchGateActivity) buildSynchGateActivity((SynchGateActivity)activity,activityDetails); else if (activity instanceof PermissionGateActivity) buildPermissionGateActivity((PermissionGateActivity)activity,activityDetails); @@ -1047,23 +1052,20 @@ } private void buildSynchGateActivity(SynchGateActivity activity,Hashtable activityDetails) throws WDDXProcessorConversionException{ - SystemTool systemTool = systemToolDAO.getSystemToolByID(SystemTool.SYNC_GATE); - activity.setSystemTool(systemTool); + activity.setSystemTool(getSystemTool(SystemTool.SYNC_GATE)); } private void buildPermissionGateActivity(PermissionGateActivity activity,Hashtable activityDetails) throws WDDXProcessorConversionException{ - SystemTool systemTool = systemToolDAO.getSystemToolByID(SystemTool.PERMISSION_GATE); - activity.setSystemTool(systemTool); + activity.setSystemTool(getSystemTool(SystemTool.PERMISSION_GATE)); } private void buildSystemGateActivity(SystemGateActivity activity,Hashtable activityDetails) throws WDDXProcessorConversionException{ - SystemTool systemTool = systemToolDAO.getSystemToolByID(SystemTool.SYSTEM_GATE); - activity.setSystemTool(systemTool); + activity.setSystemTool(getSystemTool(SystemTool.SYSTEM_GATE)); } private void buildScheduleGateActivity(ScheduleGateActivity activity,Hashtable activityDetails) throws WDDXProcessorConversionException{ //activity.setGateStartDateTime(WDDXProcessor.convertToDate(activityDetails,WDDXTAGS.GATE_START_DATE)); //activity.setGateEndDateTime(WDDXProcessor.convertToDate(activityDetails,WDDXTAGS.GATE_END_DATE)); activity.setGateStartTimeOffset(WDDXProcessor.convertToLong(activityDetails,WDDXTAGS.GATE_START_OFFSET)); activity.setGateEndTimeOffset(WDDXProcessor.convertToLong(activityDetails,WDDXTAGS.GATE_END_OFFSET)); - SystemTool systemTool = systemToolDAO.getSystemToolByID(SystemTool.SCHEDULE_GATE); + SystemTool systemTool = getSystemTool(SystemTool.SCHEDULE_GATE); activity.setSystemTool(systemTool); } @@ -1398,19 +1400,24 @@ throw new WDDXProcessorConversionException("Condition is missing its UUID: "+conditionTable); } + String endValue = WDDXProcessor.convertToString(conditionTable,WDDXTAGS.CONDITION_END_VALUE); + if ( BranchConditionDTO.MAX_FOR_FLASH.equals(endValue) ) { + endValue = null; + } + if ( condition == null ) { condition = new BranchCondition(null, conditionUIID, WDDXProcessor.convertToInteger(conditionTable,WDDXTAGS.ORDER_ID), WDDXProcessor.convertToString(conditionTable,WDDXTAGS.CONDITION_NAME), WDDXProcessor.convertToString(conditionTable,WDDXTAGS.CONDITION_DISPLAY_NAME), WDDXProcessor.convertToString(conditionTable,WDDXTAGS.CONDITION_TYPE), WDDXProcessor.convertToString(conditionTable,WDDXTAGS.CONDITION_START_VALUE), - WDDXProcessor.convertToString(conditionTable,WDDXTAGS.CONDITION_END_VALUE), + endValue, WDDXProcessor.convertToString(conditionTable,WDDXTAGS.CONDITION_EXACT_MATCH_VALUE) ); } else { condition.setConditionUIID(conditionUIID); condition.setDisplayName(WDDXProcessor.convertToString(conditionTable,WDDXTAGS.CONDITION_DISPLAY_NAME)); - condition.setEndValue(WDDXProcessor.convertToString(conditionTable,WDDXTAGS.CONDITION_END_VALUE)); + condition.setEndValue(endValue); condition.setExactMatchValue(WDDXProcessor.convertToString(conditionTable,WDDXTAGS.CONDITION_EXACT_MATCH_VALUE) ); condition.setName(WDDXProcessor.convertToString(conditionTable,WDDXTAGS.CONDITION_NAME)); condition.setOrderId(WDDXProcessor.convertToInteger(conditionTable,WDDXTAGS.ORDER_ID)); @@ -1421,6 +1428,18 @@ return condition; } + private SystemTool getSystemTool(Long systemToolId) { + SystemTool tool = systemTools.get(systemToolId); + if ( tool == null ) { + tool = systemToolDAO.getSystemToolByID(systemToolId); + if ( tool != null ) { + systemTools.put(systemToolId, tool); + } else { + log.error("ObjectExtractor: Unable to find matching system tool for id "+systemToolId); + } + } + return tool; + } } Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/dto/BranchConditionDTO.java =================================================================== diff -u -r039707d1e936b6be92842a45e442d37db9886513 -r36c95f28c887810cf5c22f0434a8852d26fbb068 --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/dto/BranchConditionDTO.java (.../BranchConditionDTO.java) (revision 039707d1e936b6be92842a45e442d37db9886513) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/dto/BranchConditionDTO.java (.../BranchConditionDTO.java) (revision 36c95f28c887810cf5c22f0434a8852d26fbb068) @@ -36,6 +36,12 @@ */ public class BranchConditionDTO { + /** If a range is open ended e.g. starts at zero and has no end value then Flash needs a maximum value for endValue + * so that it can render a stepper. So set the max value to 9999 on the way out, and convert it back to null + * on the way in. This logic is also used for the ToolOutputDefinitionDTO. + */ + public static String MAX_FOR_FLASH = "9999"; + private Long conditionId; private Integer conditionUIID; private Integer orderID; @@ -54,8 +60,13 @@ this.name = condition.getName(); this.displayName = condition.getDisplayName(); this.type = condition.getType(); + this.startValue = condition.getStartValue(); this.endValue = condition.getEndValue(); + if ( startValue != null && endValue == null ) { + endValue = BranchConditionDTO.MAX_FOR_FLASH; + } + this.exactMatchValue = condition.getExactMatchValue(); this.toolActivityUIID = toolActivityUIID; } Index: lams_common/src/java/org/lamsfoundation/lams/tool/dto/ToolOutputDefinitionDTO.java =================================================================== diff -u -r530c208895bfea0ba15e8bd8f1c799b163c059c9 -r36c95f28c887810cf5c22f0434a8852d26fbb068 --- lams_common/src/java/org/lamsfoundation/lams/tool/dto/ToolOutputDefinitionDTO.java (.../ToolOutputDefinitionDTO.java) (revision 530c208895bfea0ba15e8bd8f1c799b163c059c9) +++ lams_common/src/java/org/lamsfoundation/lams/tool/dto/ToolOutputDefinitionDTO.java (.../ToolOutputDefinitionDTO.java) (revision 36c95f28c887810cf5c22f0434a8852d26fbb068) @@ -24,6 +24,7 @@ package org.lamsfoundation.lams.tool.dto; import org.apache.commons.lang.builder.ToStringBuilder; +import org.lamsfoundation.lams.learningdesign.dto.BranchConditionDTO; import org.lamsfoundation.lams.tool.ToolOutputDefinition; /** @@ -49,8 +50,13 @@ this.name = name; this.description = description; this.type = type; + this.startValue = startValue; this.endValue = endValue; + if ( startValue != null && endValue == null ) { + endValue = BranchConditionDTO.MAX_FOR_FLASH; + } + this.complexDefinition = complexDefinition; } @@ -59,8 +65,13 @@ this.name = definition.getName(); this.description = definition.getDescription(); this.type = (definition.getType() != null)? definition.getType().toString() : null; + this.startValue = (definition.getStartValue() != null) ? definition.getStartValue().toString() : null; this.endValue = (definition.getEndValue() != null) ? definition.getEndValue().toString() : null; + if ( startValue != null && endValue == null ) { + endValue = BranchConditionDTO.MAX_FOR_FLASH; + } + this.complexDefinition = (definition.getComplexDefinition() != null) ? definition.getComplexDefinition().toString() : null; } Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/service/ForumOutputFactory.java =================================================================== diff -u -r7ec5fb1ceecbc55268fd3a8cc5ce950eaef7e3bb -r36c95f28c887810cf5c22f0434a8852d26fbb068 --- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/service/ForumOutputFactory.java (.../ForumOutputFactory.java) (revision 7ec5fb1ceecbc55268fd3a8cc5ce950eaef7e3bb) +++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/service/ForumOutputFactory.java (.../ForumOutputFactory.java) (revision 36c95f28c887810cf5c22f0434a8852d26fbb068) @@ -50,7 +50,7 @@ Object toolContentObject) throws ToolException { TreeMap definitionMap = new TreeMap(); - ToolOutputDefinition definition = buildLongOutputDefinition(OUTPUT_NAME_LEARNER_NUM_POSTS); + ToolOutputDefinition definition = buildRangeDefinition(OUTPUT_NAME_LEARNER_NUM_POSTS, new Long(0), null); definitionMap.put(OUTPUT_NAME_LEARNER_NUM_POSTS, definition); return definitionMap;