();
- if (keyExists(activityDetails, WDDXTAGS.GROUPING_SUPPORT_TYPE)) {
- activity.setGroupingSupportType(WDDXProcessor.convertToInteger(
- activityDetails, WDDXTAGS.GROUPING_SUPPORT_TYPE));
+ if (transitionsList != null) {
+ Iterator iterator = transitionsList.iterator();
+ while (iterator.hasNext()) {
+ Hashtable transitionDetails = (Hashtable) iterator.next();
+ Transition transition = extractTransitionObject(transitionDetails);
+ // Check if transition actually exists. extractTransitionObject
+ // returns null
+ // if neither the to/from activity exists.
+ if (transition != null) {
+ transitionDAO.insertOrUpdate(transition);
+ newMap.put(transition.getTransitionUIID(), transition);
}
+ }
+ }
- if (keyExists(activityDetails, WDDXTAGS.STOP_AFTER_ACTIVITY)) {
- activity.setStopAfterActivity(WDDXProcessor.convertToBoolean(
- activityDetails, WDDXTAGS.STOP_AFTER_ACTIVITY));
- }
-
- return activity;
+ // clean up the links for any old transitions.
+ Iterator iter = learningDesign.getTransitions().iterator();
+ while (iter.hasNext()) {
+ Transition element = (Transition) iter.next();
+ Integer uiID = element.getTransitionUIID();
+ Transition match = newMap.get(uiID);
+ if (match == null) {
+ // transition is no more, clean up the old activity links
+ cleanupTransition(element);
+ }
}
+ // clear the old set and reset up the transition set. Done this way to
+ // keep the Hibernate cascading happy.
+ // this means we don't have to manually remove the transition object.
+ // Note: This will leave orphan content in the tool tables. It can be
+ // removed by the tool content cleaning job,
+ // which may be run from the admin screen or via a cron job.
+ learningDesign.getTransitions().clear();
+ learningDesign.getTransitions().addAll(newMap.values());
- private Integer getCoord(Hashtable details, String wddxtag)
- throws WDDXProcessorConversionException {
- Integer coord = null;
- if (keyExists(details, wddxtag)) {
- coord = WDDXProcessor.convertToInteger(details, wddxtag);
- }
- return coord == null || coord >= 0 ? coord
- : ObjectExtractor.DEFAULT_COORD;
+ learningDesignDAO.insertOrUpdate(learningDesign);
+
+ }
+
+ public Activity extractActivityObject(Hashtable activityDetails) throws WDDXProcessorConversionException,
+ ObjectExtractorException {
+
+ // it is assumed that the activityUUID will always be sent by flash.
+ Integer activityUUID = WDDXProcessor.convertToInteger(activityDetails, WDDXTAGS.ACTIVITY_UIID);
+ Activity activity = null;
+ Integer activityTypeID = WDDXProcessor.convertToInteger(activityDetails, WDDXTAGS.ACTIVITY_TYPE_ID);
+ if (activityTypeID == null) {
+ throw new ObjectExtractorException("activityTypeID missing");
}
- private void clearGrouping(Activity activity) {
- activity.setGrouping(null);
- activity.setGroupingUIID(null);
- activity.setApplyGrouping(false);
+ // get the activity with the particular activity uuid, if null, then new
+ // object needs to be created.
+ Activity existingActivity = activityDAO.getActivityByUIID(activityUUID, learningDesign);
+ if (existingActivity != null && !existingActivity.getActivityTypeId().equals(activityTypeID)) {
+ existingActivity = null;
}
- private void setGrouping(Activity activity, Grouping grouping,
- Integer groupingUIID) {
- activity.setGrouping(grouping);
- activity.setGroupingUIID(groupingUIID);
- activity.setApplyGrouping(true);
+ if (existingActivity != null) {
+ activity = existingActivity;
+ } else {
+ activity = Activity.getActivityInstance(activityTypeID.intValue());
}
+ processActivityType(activity, activityDetails);
- private void processActivityType(Activity activity,
- Hashtable activityDetails) throws WDDXProcessorConversionException,
- ObjectExtractorException {
- if (activity.isGroupingActivity()) {
- buildGroupingActivity((GroupingActivity) activity, activityDetails);
- }
- else if (activity.isToolActivity()) {
- buildToolActivity((ToolActivity) activity, activityDetails);
- }
- else if (activity.isGateActivity()) {
- buildGateActivity(activity, activityDetails);
- }
- else {
- buildComplexActivity((ComplexActivity) activity, activityDetails);
- }
+ if (keyExists(activityDetails, WDDXTAGS.ACTIVITY_TYPE_ID)) {
+ activity.setActivityTypeId(WDDXProcessor.convertToInteger(activityDetails, WDDXTAGS.ACTIVITY_TYPE_ID));
}
+ if (keyExists(activityDetails, WDDXTAGS.ACTIVITY_UIID)) {
+ activity.setActivityUIID(WDDXProcessor.convertToInteger(activityDetails, WDDXTAGS.ACTIVITY_UIID));
+ }
+ if (keyExists(activityDetails, WDDXTAGS.DESCRIPTION)) {
+ activity.setDescription(WDDXProcessor.convertToString(activityDetails, WDDXTAGS.DESCRIPTION));
+ }
+ if (keyExists(activityDetails, WDDXTAGS.ACTIVITY_TITLE)) {
+ activity.setTitle(WDDXProcessor.convertToString(activityDetails, WDDXTAGS.ACTIVITY_TITLE));
+ }
+ if (keyExists(activityDetails, WDDXTAGS.HELP_TEXT)) {
+ activity.setHelpText(WDDXProcessor.convertToString(activityDetails, WDDXTAGS.HELP_TEXT));
+ }
- private void buildComplexActivity(ComplexActivity activity,
- Hashtable activityDetails) throws WDDXProcessorConversionException,
- ObjectExtractorException {
- // clear all the children - will be built up again by
- // parseActivitiesToMatchUpParentActivityByParentUIID
- // we don't use all-delete-orphan on the activities relationship so we
- // can do this clear.
- activity.getActivities().clear();
+ activity.setXcoord(getCoord(activityDetails, WDDXTAGS.XCOORD));
+ activity.setYcoord(getCoord(activityDetails, WDDXTAGS.YCOORD));
- activity.setDefaultActivity(null);
- Integer defaultActivityMapUIID = WDDXProcessor.convertToInteger(
- activityDetails, WDDXTAGS.DEFAULT_ACTIVITY_UIID);
- if (defaultActivityMapUIID != null) {
- defaultActivityMap.put(defaultActivityMapUIID, activity);
+ if (keyExists(activityDetails, WDDXTAGS.GROUPING_UIID)) {
+ Integer groupingUIID = WDDXProcessor.convertToInteger(activityDetails, WDDXTAGS.GROUPING_UIID);
+ if (groupingUIID != null) {
+ Grouping grouping = groupings.get(groupingUIID);
+ if (grouping != null) {
+ setGrouping(activity, grouping, groupingUIID);
+ } else {
+ log.warn("Unable to find matching grouping for groupingUIID" + groupingUIID + ". Activity UUID"
+ + activityUUID + " will not be grouped.");
+ clearGrouping(activity);
}
+ } else {
+ clearGrouping(activity);
+ }
+ } else {
+ clearGrouping(activity);
+ }
- if (activity instanceof OptionsActivity) {
- buildOptionsActivity((OptionsActivity) activity, activityDetails);
- }
- else if (activity instanceof ParallelActivity) {
- buildParallelActivity((ParallelActivity) activity, activityDetails);
- }
- else if (activity instanceof BranchingActivity) {
- buildBranchingActivity((BranchingActivity) activity,
- activityDetails);
- }
- else {
- buildSequenceActivity((SequenceActivity) activity, activityDetails);
- }
+ if (keyExists(activityDetails, WDDXTAGS.ORDER_ID)) {
+ activity.setOrderId(WDDXProcessor.convertToInteger(activityDetails, WDDXTAGS.ORDER_ID));
}
+ if (keyExists(activityDetails, WDDXTAGS.DEFINE_LATER)) {
+ activity.setDefineLater(WDDXProcessor.convertToBoolean(activityDetails, WDDXTAGS.DEFINE_LATER));
+ }
- private void buildBranchingActivity(BranchingActivity branchingActivity,
- Hashtable activityDetails) throws WDDXProcessorConversionException,
- ObjectExtractorException {
- if (branchingActivity.isChosenBranchingActivity()) {
- branchingActivity
- .setSystemTool(getSystemTool(SystemTool.TEACHER_CHOSEN_BRANCHING));
- }
- else if (branchingActivity.isGroupBranchingActivity()) {
- branchingActivity
- .setSystemTool(getSystemTool(SystemTool.GROUP_BASED_BRANCHING));
- }
- else if (branchingActivity.isToolBranchingActivity()) {
- branchingActivity
- .setSystemTool(getSystemTool(SystemTool.TOOL_BASED_BRANCHING));
- }
+ activity.setLearningDesign(learningDesign);
- branchingActivity.setStartXcoord(getCoord(activityDetails,
- WDDXTAGS.START_XCOORD));
- branchingActivity.setStartYcoord(getCoord(activityDetails,
- WDDXTAGS.START_YCOORD));
- branchingActivity.setEndXcoord(getCoord(activityDetails,
- WDDXTAGS.END_XCOORD));
- branchingActivity.setEndYcoord(getCoord(activityDetails,
- WDDXTAGS.END_YCOORD));
+ if (keyExists(activityDetails, WDDXTAGS.LEARNING_LIBRARY_ID)) {
+ Long learningLibraryID = WDDXProcessor.convertToLong(activityDetails, WDDXTAGS.LEARNING_LIBRARY_ID);
+ if (learningLibraryID != null) {
+ LearningLibrary library = learningLibraryDAO.getLearningLibraryById(learningLibraryID);
+ activity.setLearningLibrary(library);
+ } else {
+ activity.setLearningLibrary(null);
+ }
}
- 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 = getSystemTool(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); }
- */
+ // Set creation date based on the server timezone, not the client.
+ if (activity.getCreateDateTime() == null) {
+ activity.setCreateDateTime(modificationDate);
}
- 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));
- }
+ if (keyExists(activityDetails, WDDXTAGS.RUN_OFFLINE)) {
+ activity.setRunOffline(WDDXProcessor.convertToBoolean(activityDetails, WDDXTAGS.RUN_OFFLINE));
}
+ if (keyExists(activityDetails, WDDXTAGS.ACTIVITY_CATEGORY_ID)) {
+ activity.setActivityCategoryID(WDDXProcessor.convertToInteger(activityDetails,
+ WDDXTAGS.ACTIVITY_CATEGORY_ID));
+ }
+ if (keyExists(activityDetails, WDDXTAGS.LIBRARY_IMAGE)) {
+ activity.setLibraryActivityUiImage(WDDXProcessor.convertToString(activityDetails, WDDXTAGS.LIBRARY_IMAGE));
+ }
- private void buildParallelActivity(ParallelActivity activity,
- Hashtable activityDetails) throws WDDXProcessorConversionException {
+ if (keyExists(activityDetails, WDDXTAGS.GROUPING_SUPPORT_TYPE)) {
+ activity.setGroupingSupportType(WDDXProcessor.convertToInteger(activityDetails,
+ WDDXTAGS.GROUPING_SUPPORT_TYPE));
}
- private void buildSequenceActivity(SequenceActivity activity,
- Hashtable activityDetails) throws WDDXProcessorConversionException {
- activity.setSystemTool(getSystemTool(SystemTool.SEQUENCE));
+ if (keyExists(activityDetails, WDDXTAGS.STOP_AFTER_ACTIVITY)) {
+ activity
+ .setStopAfterActivity(WDDXProcessor.convertToBoolean(activityDetails, WDDXTAGS.STOP_AFTER_ACTIVITY));
}
- private void buildToolActivity(ToolActivity toolActivity,
- Hashtable activityDetails) throws WDDXProcessorConversionException {
- if (log.isDebugEnabled()) {
- log.debug("In tool activity UUID"
- + activityDetails.get(WDDXTAGS.ACTIVITY_UIID)
- + " tool content id="
- + activityDetails.get(WDDXTAGS.TOOL_CONTENT_ID));
- }
- if (keyExists(activityDetails, WDDXTAGS.TOOL_CONTENT_ID)) {
- toolActivity.setToolContentId(WDDXProcessor.convertToLong(
- activityDetails, WDDXTAGS.TOOL_CONTENT_ID));
- }
+ return activity;
+ }
- if (keyExists(activityDetails, WDDXTAGS.TOOL_ID)) {
- Tool tool = toolDAO.getToolByID(WDDXProcessor.convertToLong(
- activityDetails, WDDXTAGS.TOOL_ID));
- toolActivity.setTool(tool);
- }
+ private Integer getCoord(Hashtable details, String wddxtag) throws WDDXProcessorConversionException {
+ Integer coord = null;
+ if (keyExists(details, wddxtag)) {
+ coord = WDDXProcessor.convertToInteger(details, wddxtag);
}
+ return coord == null || coord >= 0 ? coord : ObjectExtractor.DEFAULT_COORD;
+ }
- 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 if (activity instanceof SystemGateActivity) {
- buildSystemGateActivity((SystemGateActivity) activity,
- activityDetails);
- }
- else if (activity instanceof ConditionGateActivity) {
- buildConditionGateActivity((ConditionGateActivity) 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 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 buildSynchGateActivity(SynchGateActivity activity,
- Hashtable activityDetails) throws WDDXProcessorConversionException {
- activity.setSystemTool(getSystemTool(SystemTool.SYNC_GATE));
+ private void processActivityType(Activity activity, Hashtable activityDetails)
+ throws WDDXProcessorConversionException, ObjectExtractorException {
+ if (activity.isGroupingActivity()) {
+ buildGroupingActivity((GroupingActivity) activity, activityDetails);
+ } else if (activity.isToolActivity()) {
+ buildToolActivity((ToolActivity) activity, activityDetails);
+ } else if (activity.isGateActivity()) {
+ buildGateActivity(activity, activityDetails);
+ } else {
+ buildComplexActivity((ComplexActivity) activity, activityDetails);
}
+ }
- private void buildPermissionGateActivity(PermissionGateActivity activity,
- Hashtable activityDetails) throws WDDXProcessorConversionException {
- activity.setSystemTool(getSystemTool(SystemTool.PERMISSION_GATE));
- }
+ private void buildComplexActivity(ComplexActivity activity, Hashtable activityDetails)
+ throws WDDXProcessorConversionException, ObjectExtractorException {
+ // clear all the children - will be built up again by
+ // parseActivitiesToMatchUpParentActivityByParentUIID
+ // we don't use all-delete-orphan on the activities relationship so we
+ // can do this clear.
+ activity.getActivities().clear();
- private void buildSystemGateActivity(SystemGateActivity activity,
- Hashtable activityDetails) throws WDDXProcessorConversionException {
- activity.setSystemTool(getSystemTool(SystemTool.SYSTEM_GATE));
+ activity.setDefaultActivity(null);
+ Integer defaultActivityMapUIID = WDDXProcessor
+ .convertToInteger(activityDetails, WDDXTAGS.DEFAULT_ACTIVITY_UIID);
+ if (defaultActivityMapUIID != null) {
+ defaultActivityMap.put(defaultActivityMapUIID, activity);
}
- 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 = getSystemTool(SystemTool.SCHEDULE_GATE);
- activity.setSystemTool(systemTool);
+ if (activity instanceof OptionsActivity) {
+ buildOptionsActivity((OptionsActivity) activity, activityDetails);
+ } else if (activity instanceof ParallelActivity) {
+ buildParallelActivity((ParallelActivity) activity, activityDetails);
+ } else if (activity instanceof BranchingActivity) {
+ buildBranchingActivity((BranchingActivity) activity, activityDetails);
+ } else {
+ buildSequenceActivity((SequenceActivity) activity, activityDetails);
}
+ }
- private void createLessonClass(LessonClass lessonClass,
- Hashtable groupingDetails) throws WDDXProcessorConversionException {
- if (keyExists(groupingDetails, WDDXTAGS.STAFF_GROUP_ID)) {
- Group group = groupDAO.getGroupById(WDDXProcessor.convertToLong(
- groupingDetails, WDDXTAGS.STAFF_GROUP_ID));
- if (group != null) {
- lessonClass.setStaffGroup(group);
- }
- }
+ private void buildBranchingActivity(BranchingActivity branchingActivity, Hashtable activityDetails)
+ throws WDDXProcessorConversionException, ObjectExtractorException {
+ if (branchingActivity.isChosenBranchingActivity()) {
+ branchingActivity.setSystemTool(getSystemTool(SystemTool.TEACHER_CHOSEN_BRANCHING));
+ } else if (branchingActivity.isGroupBranchingActivity()) {
+ branchingActivity.setSystemTool(getSystemTool(SystemTool.GROUP_BASED_BRANCHING));
+ } else if (branchingActivity.isToolBranchingActivity()) {
+ branchingActivity.setSystemTool(getSystemTool(SystemTool.TOOL_BASED_BRANCHING));
}
+ branchingActivity.setStartXcoord(getCoord(activityDetails, WDDXTAGS.START_XCOORD));
+ branchingActivity.setStartYcoord(getCoord(activityDetails, WDDXTAGS.START_YCOORD));
+ branchingActivity.setEndXcoord(getCoord(activityDetails, WDDXTAGS.END_XCOORD));
+ branchingActivity.setEndYcoord(getCoord(activityDetails, WDDXTAGS.END_YCOORD));
+ }
+
+ private void buildGroupingActivity(GroupingActivity groupingActivity, Hashtable activityDetails)
+ throws WDDXProcessorConversionException, ObjectExtractorException {
/**
- * Create the transition from a WDDX based hashtable. It is easier to go
- * straight to the data object rather than going via the DTO, as the DTO
- * returns the special null values from the getter methods. This makes it
- * hard to set up the transaction object from the transitionDTO.
- *
- * Assumes that all the activities have been read and are in the
- * newActivityMap. The toActivity and fromActivity are only set if the
- * activity exists in the newActivityMap. If this leaves the transition with
- * no to/from activities then null is returned.
- *
- * @param transitionDetails
- * @throws WDDXProcessorConversionException
+ * read the createGroupingUUID, get the Grouping Object, and set CreateGrouping to that object
*/
- private Transition extractTransitionObject(Hashtable transitionDetails)
- throws WDDXProcessorConversionException {
+ Integer createGroupingUIID = WDDXProcessor.convertToInteger(activityDetails, WDDXTAGS.CREATE_GROUPING_UIID);
+ Grouping grouping = groupings.get(createGroupingUIID);
+ if (grouping != null) {
+ groupingActivity.setCreateGrouping(grouping);
+ groupingActivity.setCreateGroupingUIID(createGroupingUIID);
+ }
- Integer transitionUUID = WDDXProcessor.convertToInteger(
- transitionDetails, WDDXTAGS.TRANSITION_UIID);
- if (transitionUUID == null) {
- throw new WDDXProcessorConversionException(
- "Transition is missing its UUID " + transitionDetails);
- }
+ SystemTool systemTool = getSystemTool(SystemTool.GROUPING);
+ groupingActivity.setSystemTool(systemTool);
- Integer toUIID = WDDXProcessor.convertToInteger(transitionDetails,
- WDDXTAGS.TO_ACTIVITY_UIID);
- if (toUIID == null) {
- throw new WDDXProcessorConversionException(
- "Transition is missing its toUUID " + transitionDetails);
- }
+ /*
+ * 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); }
+ */
+ }
- Integer fromUIID = WDDXProcessor.convertToInteger(transitionDetails,
- WDDXTAGS.FROM_ACTIVITY_UIID);
- if (fromUIID == null) {
- throw new WDDXProcessorConversionException(
- "Transition is missing its fromUUID " + transitionDetails);
- }
+ 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));
+ }
+ }
- Transition transition = null;
- Transition existingTransition = findTransition(transitionUUID, toUIID,
- fromUIID);
+ private void buildParallelActivity(ParallelActivity activity, Hashtable activityDetails)
+ throws WDDXProcessorConversionException {
+ }
- if (existingTransition == null) {
- transition = new Transition();
- }
- else {
- transition = existingTransition;
- }
+ private void buildSequenceActivity(SequenceActivity activity, Hashtable activityDetails)
+ throws WDDXProcessorConversionException {
+ activity.setSystemTool(getSystemTool(SystemTool.SEQUENCE));
+ }
- transition.setTransitionUIID(transitionUUID);
+ private void buildToolActivity(ToolActivity toolActivity, Hashtable activityDetails)
+ throws WDDXProcessorConversionException {
+ if (log.isDebugEnabled()) {
+ log.debug("In tool activity UUID" + activityDetails.get(WDDXTAGS.ACTIVITY_UIID) + " tool content id="
+ + activityDetails.get(WDDXTAGS.TOOL_CONTENT_ID));
+ }
+ if (keyExists(activityDetails, WDDXTAGS.TOOL_CONTENT_ID)) {
+ toolActivity.setToolContentId(WDDXProcessor.convertToLong(activityDetails, WDDXTAGS.TOOL_CONTENT_ID));
+ }
- Activity toActivity = newActivityMap.get(toUIID);
- if (toActivity != null) {
- transition.setToActivity(toActivity);
- transition.setToUIID(toUIID);
- // update the transitionTo property for the activity
- toActivity.setTransitionTo(transition);
- }
- else {
- transition.setToActivity(null);
- transition.setToUIID(null);
- }
+ if (keyExists(activityDetails, WDDXTAGS.TOOL_ID)) {
+ Tool tool = toolDAO.getToolByID(WDDXProcessor.convertToLong(activityDetails, WDDXTAGS.TOOL_ID));
+ toolActivity.setTool(tool);
+ }
+ }
- Activity fromActivity = newActivityMap.get(fromUIID);
- if (fromActivity != null) {
- transition.setFromActivity(fromActivity);
- transition.setFromUIID(fromUIID);
- // update the transitionFrom property for the activity
- fromActivity.setTransitionFrom(transition);
- }
- else {
- transition.setFromActivity(null);
- transition.setFromUIID(null);
- }
+ 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 if (activity instanceof SystemGateActivity) {
+ buildSystemGateActivity((SystemGateActivity) activity, activityDetails);
+ } else if (activity instanceof ConditionGateActivity) {
+ buildConditionGateActivity((ConditionGateActivity) 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));
- transition.setDescription(WDDXProcessor.convertToString(
- transitionDetails, WDDXTAGS.DESCRIPTION));
- transition.setTitle(WDDXProcessor.convertToString(transitionDetails,
- WDDXTAGS.TITLE));
+ }
- // Set creation date based on the server timezone, not the client.
- if (transition.getCreateDateTime() == null) {
- transition.setCreateDateTime(modificationDate);
- }
+ private void buildSynchGateActivity(SynchGateActivity activity, Hashtable activityDetails)
+ throws WDDXProcessorConversionException {
+ activity.setSystemTool(getSystemTool(SystemTool.SYNC_GATE));
+ }
- if (transition.getToActivity() != null
- && transition.getFromActivity() != null) {
- transition.setLearningDesign(learningDesign);
- return transition;
- }
- else {
- // One of the to/from is missing, can't store this transition. Make
- // sure we clean up the related activities
- cleanupTransition(transition);
- transition.setLearningDesign(null);
- return null;
- }
+ private void buildPermissionGateActivity(PermissionGateActivity activity, Hashtable activityDetails)
+ throws WDDXProcessorConversionException {
+ activity.setSystemTool(getSystemTool(SystemTool.PERMISSION_GATE));
+ }
+
+ private void buildSystemGateActivity(SystemGateActivity activity, Hashtable activityDetails)
+ throws WDDXProcessorConversionException {
+ 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 = getSystemTool(SystemTool.SCHEDULE_GATE);
+ activity.setSystemTool(systemTool);
+ }
+
+ private void createLessonClass(LessonClass lessonClass, Hashtable groupingDetails)
+ throws WDDXProcessorConversionException {
+ if (keyExists(groupingDetails, WDDXTAGS.STAFF_GROUP_ID)) {
+ Group group = groupDAO.getGroupById(WDDXProcessor.convertToLong(groupingDetails, WDDXTAGS.STAFF_GROUP_ID));
+ if (group != null) {
+ lessonClass.setStaffGroup(group);
+ }
}
+ }
- /**
- * Wipe out any links fromany activities that may be linked to it (e.g. the
- * case where a transition has an from activity but not a too activity.
- * These cases should be picked up by Flash, but just in case.
- */
- private void cleanupTransition(Transition transition) {
- if (transition.getFromActivity().getTransitionFrom().equals(transition)) {
- transition.getFromActivity().setTransitionFrom(null);
- }
- if (transition.getToActivity().getTransitionTo().equals(transition)) {
- transition.getToActivity().setTransitionTo(null);
- }
+ /**
+ * Create the transition from a WDDX based hashtable. It is easier to go straight to the data object rather than
+ * going via the DTO, as the DTO returns the special null values from the getter methods. This makes it hard to set
+ * up the transaction object from the transitionDTO.
+ *
+ * Assumes that all the activities have been read and are in the newActivityMap. The toActivity and fromActivity are
+ * only set if the activity exists in the newActivityMap. If this leaves the transition with no to/from activities
+ * then null is returned.
+ *
+ * @param transitionDetails
+ * @throws WDDXProcessorConversionException
+ */
+ private Transition extractTransitionObject(Hashtable transitionDetails) throws WDDXProcessorConversionException {
+
+ Integer transitionUUID = WDDXProcessor.convertToInteger(transitionDetails, WDDXTAGS.TRANSITION_UIID);
+ if (transitionUUID == null) {
+ throw new WDDXProcessorConversionException("Transition is missing its UUID " + transitionDetails);
}
- /**
- * Search in learning design for existing object. Can't go to database as
- * that will trigger a Flush, and we haven't updated the rest of the design,
- * so this would trigger a "deleted object would be re-saved by cascade"
- * error.
- *
- * Check both the UUID for a match, and the to and from for a match. If the
- * user deletes a transition then redraws it between the same activities,
- * then inserting a new one in the db will trigger a duplicate key
- * exception. So we need to reuse any that have the same to/from.
- */
- private Transition findTransition(Integer transitionUUID, Integer toUIID,
- Integer fromUIID) {
- Transition existingTransition = null;
- Set transitions = learningDesign.getTransitions();
- Iterator iter = transitions.iterator();
- while (existingTransition == null && iter.hasNext()) {
- Transition element = (Transition) iter.next();
- if (transitionUUID != null
- && transitionUUID.equals(element.getTransitionUIID())) {
- existingTransition = element;
- }
- else if (toUIID != null && toUIID.equals(element.getToUIID())
- && fromUIID != null
- && fromUIID.equals(element.getFromUIID())) {
- existingTransition = element;
- }
- }
- return existingTransition;
+ Integer toUIID = WDDXProcessor.convertToInteger(transitionDetails, WDDXTAGS.TO_ACTIVITY_UIID);
+ if (toUIID == null) {
+ throw new WDDXProcessorConversionException("Transition is missing its toUUID " + transitionDetails);
}
- /**
- * 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;
- }
+ Integer fromUIID = WDDXProcessor.convertToInteger(transitionDetails, WDDXTAGS.FROM_ACTIVITY_UIID);
+ if (fromUIID == null) {
+ throw new WDDXProcessorConversionException("Transition is missing its fromUUID " + transitionDetails);
}
- public void setMode(Integer mode) {
- this.mode = mode;
+ Transition transition = null;
+ Transition existingTransition = findTransition(transitionUUID, toUIID, fromUIID);
+
+ if (existingTransition == null) {
+ transition = new Transition();
+ } else {
+ transition = existingTransition;
}
- public Integer getMode() {
- return mode;
+ transition.setTransitionUIID(transitionUUID);
+
+ Activity toActivity = newActivityMap.get(toUIID);
+ if (toActivity != null) {
+ transition.setToActivity(toActivity);
+ transition.setToUIID(toUIID);
+ // update the transitionTo property for the activity
+ toActivity.setTransitionTo(transition);
+ } else {
+ transition.setToActivity(null);
+ transition.setToUIID(null);
}
- /**
- * Parses the mappings used for branching. They map groups to the sequence
- * activities that form a branch within a branching activity.
- *
- * Must be done after all the other parsing as we need to match up
- * activities and groups.
- *
- * Will also delete any old (now unused) mappings
- *
- * @param branchMappingsList
- * @throws WDDXProcessorConversionException
- */
+ Activity fromActivity = newActivityMap.get(fromUIID);
+ if (fromActivity != null) {
+ transition.setFromActivity(fromActivity);
+ transition.setFromUIID(fromUIID);
+ // update the transitionFrom property for the activity
+ fromActivity.setTransitionFrom(transition);
+ } else {
+ transition.setFromActivity(null);
+ transition.setFromUIID(null);
+ }
- private void parseBranchMappings(List branchMappingsList)
- throws WDDXProcessorConversionException {
- if (branchMappingsList != null) {
- Iterator iterator = branchMappingsList.iterator();
- while (iterator.hasNext()) {
- extractBranchActivityEntry((Hashtable) iterator.next());
- }
- }
+ transition.setDescription(WDDXProcessor.convertToString(transitionDetails, WDDXTAGS.DESCRIPTION));
+ transition.setTitle(WDDXProcessor.convertToString(transitionDetails, WDDXTAGS.TITLE));
- // now go through and delete any old branch mappings that are no longer
- // used.
- // need to remove them from their collections to make sure it isn't
- // accidently re-added.
- Iterator iter = oldbranchActivityEntryList.iterator();
- while (iter.hasNext()) {
- BranchActivityEntry oldEntry = (BranchActivityEntry) iter.next();
- SequenceActivity sequenceActivity = oldEntry
- .getBranchSequenceActivity();
- if (sequenceActivity != null) {
- sequenceActivity.getBranchEntries().remove(oldEntry);
- }
- Group group = oldEntry.getGroup();
- if (group != null) {
- group.getBranchActivities().remove(oldEntry);
- }
- activityDAO.delete(oldEntry);
- }
+ // Set creation date based on the server timezone, not the client.
+ if (transition.getCreateDateTime() == null) {
+ transition.setCreateDateTime(modificationDate);
}
- @SuppressWarnings("unchecked")
- /**
- * Get the BranchActivityEntry details. This may be either for group based
- * branching, or it may be for tool output based branching
- */
- private BranchActivityEntry extractBranchActivityEntry(Hashtable details)
- throws WDDXProcessorConversionException {
+ if (transition.getToActivity() != null && transition.getFromActivity() != null) {
+ transition.setLearningDesign(learningDesign);
+ return transition;
+ } else {
+ // One of the to/from is missing, can't store this transition. Make
+ // sure we clean up the related activities
+ cleanupTransition(transition);
+ transition.setLearningDesign(null);
+ return null;
+ }
+ }
- Long entryId = WDDXProcessor.convertToLong(details,
- WDDXTAGS.BRANCH_ACTIVITY_ENTRY_ID);
- Integer entryUIID = WDDXProcessor.convertToInteger(details,
- WDDXTAGS.BRANCH_ACTIVITY_ENTRY_UIID);
- if (entryUIID == null) {
- throw new WDDXProcessorConversionException(
- "Group based branch mapping entry is missing its UUID. Entry "
- + details);
- }
+ /**
+ * Wipe out any links fromany activities that may be linked to it (e.g. the case where a transition has an from
+ * activity but not a too activity. These cases should be picked up by Flash, but just in case.
+ */
+ private void cleanupTransition(Transition transition) {
+ if (transition.getFromActivity().getTransitionFrom().equals(transition)) {
+ transition.getFromActivity().setTransitionFrom(null);
+ }
+ if (transition.getToActivity().getTransitionTo().equals(transition)) {
+ transition.getToActivity().setTransitionTo(null);
+ }
+ }
- Integer sequenceActivityUIID = WDDXProcessor.convertToInteger(details,
- WDDXTAGS.BRANCH_SEQUENCE_ACTIVITY_UIID);
- Integer branchingActivityUIID = WDDXProcessor.convertToInteger(details,
- WDDXTAGS.BRANCH_ACTIVITY_UIID);
+ /**
+ * Search in learning design for existing object. Can't go to database as that will trigger a Flush, and we haven't
+ * updated the rest of the design, so this would trigger a "deleted object would be re-saved by cascade" error.
+ *
+ * Check both the UUID for a match, and the to and from for a match. If the user deletes a transition then redraws
+ * it between the same activities, then inserting a new one in the db will trigger a duplicate key exception. So we
+ * need to reuse any that have the same to/from.
+ */
+ private Transition findTransition(Integer transitionUUID, Integer toUIID, Integer fromUIID) {
+ Transition existingTransition = null;
+ Set transitions = learningDesign.getTransitions();
+ Iterator iter = transitions.iterator();
+ while (existingTransition == null && iter.hasNext()) {
+ Transition element = (Transition) iter.next();
+ if (transitionUUID != null && transitionUUID.equals(element.getTransitionUIID())) {
+ existingTransition = element;
+ } else if (toUIID != null && toUIID.equals(element.getToUIID()) && fromUIID != null
+ && fromUIID.equals(element.getFromUIID())) {
+ existingTransition = element;
+ }
+ }
+ return existingTransition;
+ }
- Activity branchingActivity = newActivityMap.get(branchingActivityUIID);
- if (branchingActivity == null) {
- throw new WDDXProcessorConversionException(
- "Branching Activity listed in the branch mapping list is missing. Mapping entry UUID "
- + entryUIID
- + " branchingActivityUIID "
- + branchingActivityUIID);
- }
- if (!branchingActivity.isBranchingActivity()
- && !branchingActivity.isConditionGate()) {
- throw new WDDXProcessorConversionException(
- "Activity listed in the branch mapping list is not a branching activity nor a condition gate. Mapping entry UUID "
- + entryUIID
- + " branchingActivityUIID "
- + branchingActivityUIID);
- }
- // sequence activity is null for a condition gate
- SequenceActivity sequenceActivity = null;
- if (!branchingActivity.isConditionGate()) {
- Activity activity = newActivityMap.get(sequenceActivityUIID);
- if (activity == null) {
- throw new WDDXProcessorConversionException(
- "Sequence Activity listed in the branch mapping list is missing. Mapping entry UUID "
- + entryUIID
- + " sequenceActivityUIID "
- + sequenceActivityUIID);
- }
- else if (!activity.isSequenceActivity()) {
- throw new WDDXProcessorConversionException(
- "Activity listed in the branch mapping list is not a sequence activity. Mapping entry UUID "
- + entryUIID
- + " sequenceActivityUIID "
- + sequenceActivityUIID);
- }
- else {
- sequenceActivity = (SequenceActivity) activity;
- }
- }
+ /**
+ * 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;
+ }
+ }
- // If the mapping was created at runtime, there will be an ID but no IU
- // ID field.
- // If it was created in authoring, will have a UI ID and may or may not
- // have an ID.
- // So try to match up on UI ID first, failing that match on ID. Then the
- // worst case, which is the mapping
- // is created at runtime but then modified in authoring (and has has a
- // new UI ID added) is handled.
- BranchActivityEntry uiid_match = null;
- BranchActivityEntry id_match = null;
- Iterator iter = null;
- if (sequenceActivity != null) {
- if (sequenceActivity.getBranchEntries() != null) {
- iter = sequenceActivity.getBranchEntries().iterator();
- }
- }
- else {
- iter = ((ConditionGateActivity) branchingActivity)
- .getOpeningGateBranchEntries().iterator();
- }
+ public void setMode(Integer mode) {
+ this.mode = mode;
+ }
- if (iter != null) {
- while (uiid_match == null && iter.hasNext()) {
- BranchActivityEntry possibleEntry = (BranchActivityEntry) iter
- .next();
- if (entryUIID.equals(possibleEntry.getEntryUIID())) {
- uiid_match = possibleEntry;
- }
- if (entryId != null
- && entryId.equals(possibleEntry.getEntryId())) {
- id_match = possibleEntry;
- }
- }
- }
+ public Integer getMode() {
+ return mode;
+ }
- BranchActivityEntry entry = uiid_match != null ? uiid_match : id_match;
+ /**
+ * Parses the mappings used for branching. They map groups to the sequence activities that form a branch within a
+ * branching activity.
+ *
+ * Must be done after all the other parsing as we need to match up activities and groups.
+ *
+ * Will also delete any old (now unused) mappings
+ *
+ * @param branchMappingsList
+ * @throws WDDXProcessorConversionException
+ */
- // Does it exist already? If it does, remove it from the "old" set
- // (which is used for doing deletions later).
- oldbranchActivityEntryList.remove(entry);
+ private void parseBranchMappings(List branchMappingsList) throws WDDXProcessorConversionException {
+ if (branchMappingsList != null) {
+ Iterator iterator = branchMappingsList.iterator();
+ while (iterator.hasNext()) {
+ extractBranchActivityEntry((Hashtable) iterator.next());
+ }
+ }
- BranchCondition condition = extractCondition((Hashtable) details
- .get(WDDXTAGS.BRANCH_CONDITION), entry);
+ // now go through and delete any old branch mappings that are no longer
+ // used.
+ // need to remove them from their collections to make sure it isn't
+ // accidently re-added.
+ Iterator iter = oldbranchActivityEntryList.iterator();
+ while (iter.hasNext()) {
+ BranchActivityEntry oldEntry = (BranchActivityEntry) iter.next();
+ SequenceActivity sequenceActivity = oldEntry.getBranchSequenceActivity();
+ if (sequenceActivity != null) {
+ sequenceActivity.getBranchEntries().remove(oldEntry);
+ }
+ Group group = oldEntry.getGroup();
+ if (group != null) {
+ group.getBranchActivities().remove(oldEntry);
+ }
+ activityDAO.delete(oldEntry);
+ }
+ }
- Integer groupUIID = WDDXProcessor.convertToInteger(details,
- WDDXTAGS.GROUP_UIID);
- Group group = null;
- if (groupUIID != null) {
- group = groups.get(groupUIID);
- if (group == null) {
- throw new WDDXProcessorConversionException(
- "Group listed in the branch mapping list is missing. Mapping entry UUID "
- + entryUIID + " groupUIID " + groupUIID);
- }
- }
+ @SuppressWarnings("unchecked")
+ /**
+ * Get the BranchActivityEntry details. This may be either for group based branching, or it may be for tool output
+ * based branching
+ */
+ private BranchActivityEntry extractBranchActivityEntry(Hashtable details) throws WDDXProcessorConversionException {
- if (condition == null && group == null) {
- throw new WDDXProcessorConversionException(
- "Branch mapping has neither a group or a condition. Not a valid mapping. "
- + details);
- }
+ Long entryId = WDDXProcessor.convertToLong(details, WDDXTAGS.BRANCH_ACTIVITY_ENTRY_ID);
+ Integer entryUIID = WDDXProcessor.convertToInteger(details, WDDXTAGS.BRANCH_ACTIVITY_ENTRY_UIID);
+ if (entryUIID == null) {
+ throw new WDDXProcessorConversionException("Group based branch mapping entry is missing its UUID. Entry "
+ + details);
+ }
- if (entry == null) {
- if (condition != null) {
- entry = condition.allocateBranchToCondition(entryUIID,
- sequenceActivity, branchingActivity);
- }
- else {
- entry = group
- .allocateBranchToGroup(entryUIID, sequenceActivity,
- (BranchingActivity) branchingActivity);
- }
- }
- else {
- entry.setEntryUIID(entryUIID);
- entry.setBranchSequenceActivity(sequenceActivity);
- entry.setBranchingActivity(branchingActivity);
- }
+ Integer sequenceActivityUIID = WDDXProcessor.convertToInteger(details, WDDXTAGS.BRANCH_SEQUENCE_ACTIVITY_UIID);
+ Integer branchingActivityUIID = WDDXProcessor.convertToInteger(details, WDDXTAGS.BRANCH_ACTIVITY_UIID);
- entry.setGroup(group);
- entry.setCondition(condition);
- if (sequenceActivity != null) {
- if (sequenceActivity.getBranchEntries() == null) {
- sequenceActivity.setBranchEntries(new HashSet());
- }
- sequenceActivity.getBranchEntries().add(entry);
- activityDAO.update(sequenceActivity);
- }
+ Activity branchingActivity = newActivityMap.get(branchingActivityUIID);
+ if (branchingActivity == null) {
+ throw new WDDXProcessorConversionException(
+ "Branching Activity listed in the branch mapping list is missing. Mapping entry UUID " + entryUIID
+ + " branchingActivityUIID " + branchingActivityUIID);
+ }
+ if (!branchingActivity.isBranchingActivity() && !branchingActivity.isConditionGate()) {
+ throw new WDDXProcessorConversionException(
+ "Activity listed in the branch mapping list is not a branching activity nor a condition gate. Mapping entry UUID "
+ + entryUIID + " branchingActivityUIID " + branchingActivityUIID);
+ }
+ // sequence activity is null for a condition gate
+ SequenceActivity sequenceActivity = null;
+ if (!branchingActivity.isConditionGate()) {
+ Activity activity = newActivityMap.get(sequenceActivityUIID);
+ if (activity == null) {
+ throw new WDDXProcessorConversionException(
+ "Sequence Activity listed in the branch mapping list is missing. Mapping entry UUID "
+ + entryUIID + " sequenceActivityUIID " + sequenceActivityUIID);
+ } else if (!activity.isSequenceActivity()) {
+ throw new WDDXProcessorConversionException(
+ "Activity listed in the branch mapping list is not a sequence activity. Mapping entry UUID "
+ + entryUIID + " sequenceActivityUIID " + sequenceActivityUIID);
+ } else {
+ sequenceActivity = (SequenceActivity) activity;
+ }
+ }
- if (group != null) {
- groupingDAO.update(group);
- }
+ // If the mapping was created at runtime, there will be an ID but no IU
+ // ID field.
+ // If it was created in authoring, will have a UI ID and may or may not
+ // have an ID.
+ // So try to match up on UI ID first, failing that match on ID. Then the
+ // worst case, which is the mapping
+ // is created at runtime but then modified in authoring (and has has a
+ // new UI ID added) is handled.
+ BranchActivityEntry uiid_match = null;
+ BranchActivityEntry id_match = null;
+ Iterator iter = null;
+ if (sequenceActivity != null) {
+ if (sequenceActivity.getBranchEntries() != null) {
+ iter = sequenceActivity.getBranchEntries().iterator();
+ }
+ } else {
+ iter = ((ConditionGateActivity) branchingActivity).getOpeningGateBranchEntries().iterator();
+ }
- return entry;
+ if (iter != null) {
+ while (uiid_match == null && iter.hasNext()) {
+ BranchActivityEntry possibleEntry = (BranchActivityEntry) iter.next();
+ if (entryUIID.equals(possibleEntry.getEntryUIID())) {
+ uiid_match = possibleEntry;
+ }
+ if (entryId != null && entryId.equals(possibleEntry.getEntryId())) {
+ id_match = possibleEntry;
+ }
+ }
}
- /**
- * @param details
- * @param entry
- * @return
- * @throws WDDXProcessorConversionException
- */
- private BranchCondition extractCondition(Hashtable conditionTable,
- BranchActivityEntry entry) throws WDDXProcessorConversionException {
+ BranchActivityEntry entry = uiid_match != null ? uiid_match : id_match;
- BranchCondition condition = null;
+ // Does it exist already? If it does, remove it from the "old" set
+ // (which is used for doing deletions later).
+ oldbranchActivityEntryList.remove(entry);
- if (conditionTable != null && conditionTable.size() > 0) {
+ BranchCondition condition = extractCondition((Hashtable) details.get(WDDXTAGS.BRANCH_CONDITION), entry);
- Long conditionID = WDDXProcessor.convertToLong(conditionTable,
- WDDXTAGS.CONDITION_ID);
- if (entry != null) {
- condition = entry.getCondition();
- }
- if (condition != null && conditionID != null
- && !condition.getConditionId().equals(conditionID)) {
- log
- .warn("Unexpected behaviour: condition supplied in WDDX packet has a different ID to matching branch activity entry in the database. Dropping old database condition."
- + " Old db condition "
- + condition
- + " new entry in WDDX " + conditionTable);
- condition = null; // Hibernate should dispose of it
- // automatically via the cascade
- }
+ Integer groupUIID = WDDXProcessor.convertToInteger(details, WDDXTAGS.GROUP_UIID);
+ Group group = null;
+ if (groupUIID != null) {
+ group = groups.get(groupUIID);
+ if (group == null) {
+ throw new WDDXProcessorConversionException(
+ "Group listed in the branch mapping list is missing. Mapping entry UUID " + entryUIID
+ + " groupUIID " + groupUIID);
+ }
+ }
- Integer conditionUIID = WDDXProcessor.convertToInteger(
- conditionTable, WDDXTAGS.CONDITION_UIID);
- if (conditionUIID == null) {
- throw new WDDXProcessorConversionException(
- "Condition is missing its UUID: " + conditionTable);
- }
+ if (condition == null && group == null) {
+ throw new WDDXProcessorConversionException(
+ "Branch mapping has neither a group or a condition. Not a valid mapping. " + details);
+ }
- String endValue = WDDXProcessor.convertToString(conditionTable,
- WDDXTAGS.CONDITION_END_VALUE);
+ if (entry == null) {
+ if (condition != null) {
+ entry = condition.allocateBranchToCondition(entryUIID, sequenceActivity, branchingActivity);
+ } else {
+ entry = group.allocateBranchToGroup(entryUIID, sequenceActivity, (BranchingActivity) branchingActivity);
+ }
+ } else {
+ entry.setEntryUIID(entryUIID);
+ entry.setBranchSequenceActivity(sequenceActivity);
+ entry.setBranchingActivity(branchingActivity);
+ }
- 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),
- endValue, WDDXProcessor.convertToString(conditionTable,
- WDDXTAGS.CONDITION_EXACT_MATCH_VALUE));
- }
- else {
- condition.setConditionUIID(conditionUIID);
- condition.setDisplayName(WDDXProcessor.convertToString(
- conditionTable, WDDXTAGS.CONDITION_DISPLAY_NAME));
- 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));
- condition.setStartValue(WDDXProcessor.convertToString(
- conditionTable, WDDXTAGS.CONDITION_START_VALUE));
- condition.setType(WDDXProcessor.convertToString(conditionTable,
- WDDXTAGS.CONDITION_TYPE));
- }
- }
- return condition;
+ entry.setGroup(group);
+ entry.setCondition(condition);
+ if (sequenceActivity != null) {
+ if (sequenceActivity.getBranchEntries() == null) {
+ sequenceActivity.setBranchEntries(new HashSet());
+ }
+ sequenceActivity.getBranchEntries().add(entry);
+ activityDAO.update(sequenceActivity);
}
- 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;
+ if (group != null) {
+ groupingDAO.update(group);
}
- private void createLearnerChoiceGrouping(
- LearnerChoiceGrouping learnerChoiceGrouping,
- Hashtable groupingDetails) throws WDDXProcessorConversionException {
+ return entry;
+ }
- Integer numLearnersPerGroup = WDDXProcessor.convertToInteger(
- groupingDetails, WDDXTAGS.LEARNERS_PER_GROUP);
- if (numLearnersPerGroup != null && numLearnersPerGroup.intValue() > 0) {
- learnerChoiceGrouping.setLearnersPerGroup(numLearnersPerGroup);
- learnerChoiceGrouping.setNumberOfGroups(null);
- learnerChoiceGrouping.setEqualNumberOfLearnersPerGroup(null);
+ /**
+ * @param details
+ * @param entry
+ * @return
+ * @throws WDDXProcessorConversionException
+ */
+ private BranchCondition extractCondition(Hashtable conditionTable, BranchActivityEntry entry)
+ throws WDDXProcessorConversionException {
+
+ BranchCondition condition = null;
+
+ if (conditionTable != null && conditionTable.size() > 0) {
+
+ Long conditionID = WDDXProcessor.convertToLong(conditionTable, WDDXTAGS.CONDITION_ID);
+ if (entry != null) {
+ condition = entry.getCondition();
+ }
+ if (condition != null && conditionID != null && !condition.getConditionId().equals(conditionID)) {
+ log
+ .warn("Unexpected behaviour: condition supplied in WDDX packet has a different ID to matching branch activity entry in the database. Dropping old database condition."
+ + " Old db condition " + condition + " new entry in WDDX " + conditionTable);
+ condition = null; // Hibernate should dispose of it
+ // automatically via the cascade
+ }
+
+ Integer conditionUIID = WDDXProcessor.convertToInteger(conditionTable, WDDXTAGS.CONDITION_UIID);
+ if (conditionUIID == null) {
+ throw new WDDXProcessorConversionException("Condition is missing its UUID: " + conditionTable);
+ }
+ String conditionType = WDDXProcessor.convertToString(conditionTable, WDDXTAGS.CONDITION_TYPE);
+
+ if (BranchCondition.OUTPUT_TYPE_COMPLEX.equals(conditionType)
+ || BranchCondition.OUTPUT_TYPE_STRING.equals(conditionType)) {
+ if (condition == null) {
+ // This is different than "conditionID" !!!
+ Long newConditionID = WDDXProcessor.convertToLong(conditionTable, "conditionId");
+ BranchCondition originalCondition = branchActivityEntryDAO.getConditionByID(newConditionID);
+ if (originalCondition == null) {
+ log.error("Could not find condition with given ID: " + conditionID);
+ } else {
+ condition = (BranchCondition) originalCondition.clone();
+ condition.setConditionUIID(conditionUIID);
+ }
}
else {
- Integer numGroups = WDDXProcessor.convertToInteger(groupingDetails,
- WDDXTAGS.NUMBER_OF_GROUPS);
- if (numGroups != null && numGroups.intValue() > 0) {
- learnerChoiceGrouping.setNumberOfGroups(numGroups);
- }
- else {
- learnerChoiceGrouping.setNumberOfGroups(null);
- }
- learnerChoiceGrouping.setLearnersPerGroup(null);
- Boolean equalNumberOfLearnersPerGroup = WDDXProcessor
- .convertToBoolean(groupingDetails,
- WDDXTAGS.EQUAL_NUMBER_OF_LEARNERS_PER_GROUP);
- if (equalNumberOfLearnersPerGroup != null) {
- learnerChoiceGrouping
- .setEqualNumberOfLearnersPerGroup(equalNumberOfLearnersPerGroup);
- }
+ condition.setConditionUIID(conditionUIID);
}
+
+ } else 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), 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.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));
+ condition.setStartValue(WDDXProcessor.convertToString(conditionTable, WDDXTAGS.CONDITION_START_VALUE));
+ condition.setType(WDDXProcessor.convertToString(conditionTable, WDDXTAGS.CONDITION_TYPE));
+ }
}
+ return condition;
+ }
- private void buildConditionGateActivity(ConditionGateActivity activity,
- Hashtable activityDetails) throws WDDXProcessorConversionException {
- activity.setSystemTool(getSystemTool(SystemTool.CONDITION_GATE));
+ 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;
+ }
+
+ private void createLearnerChoiceGrouping(LearnerChoiceGrouping learnerChoiceGrouping, Hashtable groupingDetails)
+ throws WDDXProcessorConversionException {
+
+ Integer numLearnersPerGroup = WDDXProcessor.convertToInteger(groupingDetails, WDDXTAGS.LEARNERS_PER_GROUP);
+ if (numLearnersPerGroup != null && numLearnersPerGroup.intValue() > 0) {
+ learnerChoiceGrouping.setLearnersPerGroup(numLearnersPerGroup);
+ learnerChoiceGrouping.setNumberOfGroups(null);
+ learnerChoiceGrouping.setEqualNumberOfLearnersPerGroup(null);
+ } else {
+ Integer numGroups = WDDXProcessor.convertToInteger(groupingDetails, WDDXTAGS.NUMBER_OF_GROUPS);
+ if (numGroups != null && numGroups.intValue() > 0) {
+ learnerChoiceGrouping.setNumberOfGroups(numGroups);
+ } else {
+ learnerChoiceGrouping.setNumberOfGroups(null);
+ }
+ learnerChoiceGrouping.setLearnersPerGroup(null);
+ Boolean equalNumberOfLearnersPerGroup = WDDXProcessor.convertToBoolean(groupingDetails,
+ WDDXTAGS.EQUAL_NUMBER_OF_LEARNERS_PER_GROUP);
+ if (equalNumberOfLearnersPerGroup != null) {
+ learnerChoiceGrouping.setEqualNumberOfLearnersPerGroup(equalNumberOfLearnersPerGroup);
+ }
+ }
+ }
+
+ private void buildConditionGateActivity(ConditionGateActivity activity, Hashtable activityDetails)
+ throws WDDXProcessorConversionException {
+ activity.setSystemTool(getSystemTool(SystemTool.CONDITION_GATE));
+ }
}
\ No newline at end of file
Index: lams_common/.classpath
===================================================================
diff -u -r3590714b9dfaa2eeee7dcacaa1e76db4f1f45d23 -r542b83631b403e37429fce3bb928f2800c5cd9b8
--- lams_common/.classpath (.../.classpath) (revision 3590714b9dfaa2eeee7dcacaa1e76db4f1f45d23)
+++ lams_common/.classpath (.../.classpath) (revision 542b83631b403e37429fce3bb928f2800c5cd9b8)
@@ -10,10 +10,6 @@
-
-
-
-
Index: lams_common/conf/hibernate/mappings/org/lamsfoundation/lams/learningdesign/BranchActivityEntry.hbm.xml
===================================================================
diff -u -r3590714b9dfaa2eeee7dcacaa1e76db4f1f45d23 -r542b83631b403e37429fce3bb928f2800c5cd9b8
--- lams_common/conf/hibernate/mappings/org/lamsfoundation/lams/learningdesign/BranchActivityEntry.hbm.xml (.../BranchActivityEntry.hbm.xml) (revision 3590714b9dfaa2eeee7dcacaa1e76db4f1f45d23)
+++ lams_common/conf/hibernate/mappings/org/lamsfoundation/lams/learningdesign/BranchActivityEntry.hbm.xml (.../BranchActivityEntry.hbm.xml) (revision 542b83631b403e37429fce3bb928f2800c5cd9b8)
@@ -38,7 +38,7 @@
-
Index: lams_common/db/model/lams_11.clay
===================================================================
diff -u -r44cd820aae2478d1f77a2008b90fcea6cab6baba -r542b83631b403e37429fce3bb928f2800c5cd9b8
--- lams_common/db/model/lams_11.clay (.../lams_11.clay) (revision 44cd820aae2478d1f77a2008b90fcea6cab6baba)
+++ lams_common/db/model/lams_11.clay (.../lams_11.clay) (revision 542b83631b403e37429fce3bb928f2800c5cd9b8)
@@ -1,18 +1,18 @@
-
+
-
+
-
+
-
+
-
+
@@ -25,7 +25,7 @@
-
+
@@ -38,26 +38,26 @@
-
+
-
+
-
+
-
+
@@ -66,17 +66,17 @@
-
+
-
+
-
+
@@ -89,27 +89,27 @@
-
+
-
+
-
+
-
+
@@ -122,27 +122,27 @@
-
+
-
+
-
-
+
+
-
+
@@ -155,27 +155,27 @@
-
+
-
+
-
+
-
+
@@ -188,7 +188,7 @@
-
+
@@ -201,26 +201,26 @@
-
+
-
+
-
+
-
+
@@ -233,7 +233,7 @@
-
+
@@ -246,7 +246,7 @@
-
+
@@ -259,7 +259,7 @@
-
+
@@ -272,7 +272,7 @@
-
+
@@ -285,7 +285,7 @@
-
+
@@ -298,7 +298,7 @@
-
+
@@ -311,7 +311,7 @@
-
+
@@ -324,7 +324,7 @@
-
+
@@ -337,7 +337,7 @@
-
+
@@ -350,7 +350,7 @@
-
+
@@ -363,7 +363,7 @@
-
+
@@ -376,7 +376,7 @@
-
+
@@ -389,13 +389,13 @@
-
+
-
+
@@ -408,7 +408,7 @@
-
+
@@ -421,7 +421,7 @@
-
+
@@ -434,13 +434,13 @@
-
+
-
+
@@ -453,7 +453,7 @@
-
+
@@ -466,7 +466,7 @@
-
+
@@ -479,7 +479,7 @@
-
+
@@ -492,7 +492,7 @@
-
+
@@ -505,7 +505,7 @@
-
+
@@ -518,7 +518,7 @@
-
+
@@ -531,26 +531,26 @@
-
+
-
+
-
+
-
+
@@ -563,7 +563,7 @@
-
+
@@ -576,7 +576,7 @@
-
+
@@ -589,14 +589,14 @@
-
+
-
+
@@ -609,7 +609,7 @@
-
+
@@ -622,7 +622,7 @@
-
+
@@ -635,7 +635,7 @@
-
+
@@ -648,7 +648,7 @@
-
+
@@ -661,7 +661,7 @@
-
+
@@ -674,7 +674,7 @@
-
+
@@ -687,7 +687,7 @@
-
+
@@ -700,7 +700,7 @@
-
+
@@ -714,90 +714,90 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -806,33 +806,33 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -845,27 +845,27 @@
-
+
-
+
-
+
-
+
@@ -878,7 +878,7 @@
-
+
@@ -891,20 +891,20 @@
-
+
-
+
-
+
@@ -917,7 +917,7 @@
-
+
@@ -930,7 +930,7 @@
-
+
@@ -943,7 +943,7 @@
-
+
@@ -956,13 +956,13 @@
-
+
-
+
@@ -975,25 +975,25 @@
-
+
-
+
-
+
-
+
@@ -1006,13 +1006,13 @@
-
+
-
+
@@ -1032,7 +1032,7 @@
-
+
@@ -1045,7 +1045,7 @@
-
+
@@ -1058,7 +1058,7 @@
-
+
@@ -1071,26 +1071,26 @@
-
+
-
+
-
+
-
+
@@ -1103,7 +1103,7 @@
-
+
@@ -1116,7 +1116,7 @@
-
+
@@ -1130,41 +1130,41 @@
-
+
-
+
-
+
-
+
-
+
-
+
@@ -1173,25 +1173,25 @@
-
+
-
+
-
+
-
+
-
+
@@ -1204,14 +1204,14 @@
-
+
-
+
@@ -1224,7 +1224,7 @@
-
+
@@ -1237,7 +1237,7 @@
-
+
@@ -1251,13 +1251,13 @@
-
+
-
+
@@ -1266,17 +1266,17 @@
-
+
-
-
+
+
-
+
@@ -1289,7 +1289,7 @@
-
+
@@ -1302,7 +1302,7 @@
-
+
@@ -1315,7 +1315,7 @@
-
+
@@ -1328,7 +1328,7 @@
-
+
@@ -1341,7 +1341,7 @@
-
+
@@ -1354,7 +1354,7 @@
-
+
@@ -1368,13 +1368,13 @@
-
+
-
+
@@ -1383,17 +1383,17 @@
-
+
-
+
-
+
@@ -1406,20 +1406,20 @@
-
+
-
+
-
+
@@ -1432,26 +1432,26 @@
-
+
-
+
-
+
-
+
@@ -1464,7 +1464,7 @@
-
+
@@ -1477,20 +1477,20 @@
-
+
-
+
-
+
@@ -1503,7 +1503,7 @@
-
+
@@ -1516,7 +1516,7 @@
-
+
@@ -1529,13 +1529,13 @@
-
+
-
+
@@ -1548,7 +1548,7 @@
-
+
@@ -1562,33 +1562,33 @@
-
+
-
+
-
+
-
+
-
+
@@ -1597,25 +1597,25 @@
-
+
-
+
-
+
-
+
-
+
@@ -1628,28 +1628,28 @@
-
+
-
+
-
+
-
+
@@ -1662,7 +1662,7 @@
-
+
@@ -1675,13 +1675,13 @@
-
+
-
+
@@ -1694,7 +1694,7 @@
-
+
@@ -1707,7 +1707,7 @@
-
+
@@ -1720,7 +1720,7 @@
-
+
@@ -1733,7 +1733,7 @@
-
+
@@ -1746,7 +1746,7 @@
-
+
@@ -1759,7 +1759,7 @@
-
+
@@ -1772,7 +1772,7 @@
-
+
@@ -1785,54 +1785,54 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -1841,25 +1841,25 @@
-
+
-
+
-
+
-
+
-
+
@@ -1872,39 +1872,39 @@
-
+
-
+
-
+
-
+
-
+
-
+
@@ -1917,44 +1917,44 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -1967,126 +1967,126 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -2099,13 +2099,13 @@
-
+
-
+
@@ -2118,7 +2118,7 @@
-
+
@@ -2131,7 +2131,7 @@
-
+
@@ -2144,7 +2144,7 @@
-
+
@@ -2157,14 +2157,14 @@
-
+
-
+
@@ -2177,7 +2177,7 @@
-
+
@@ -2190,7 +2190,7 @@
-
+
@@ -2203,13 +2203,13 @@
-
+
-
+
@@ -2223,41 +2223,41 @@
-
+
-
+
-
+
-
+
-
+
-
+
@@ -2266,33 +2266,33 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -2305,7 +2305,7 @@
-
+
@@ -2318,7 +2318,7 @@
-
+
@@ -2332,20 +2332,20 @@
-
+
-
+
-
+
@@ -2354,21 +2354,21 @@
-
+
-
+
-
+
-
+
@@ -2381,7 +2381,7 @@
-
+
@@ -2394,7 +2394,7 @@
-
+
@@ -2408,20 +2408,20 @@
-
+
-
+
-
+
@@ -2430,21 +2430,21 @@
-
+
-
+
-
+
-
+
@@ -2457,7 +2457,7 @@
-
+
@@ -2470,7 +2470,7 @@
-
+
@@ -2483,28 +2483,28 @@
-
+
-
+
-
+
-
+
@@ -2514,11 +2514,11 @@
-
+
-
+
@@ -2531,7 +2531,7 @@
-
+
@@ -2544,14 +2544,14 @@
-
+
-
+
@@ -2564,19 +2564,19 @@
-
+
-
+
-
+
@@ -2590,20 +2590,20 @@
-
+
-
+
-
+
@@ -2612,17 +2612,17 @@
-
+
-
+
-
+
@@ -2635,7 +2635,7 @@
-
+
@@ -2648,7 +2648,7 @@
-
+
@@ -2661,26 +2661,26 @@
-
+
-
+
-
+
-
+
@@ -2693,7 +2693,7 @@
-
+
@@ -2706,7 +2706,7 @@
-
+
@@ -2719,31 +2719,31 @@
-
+
-
+
-
+
-
+
-
+
@@ -2756,7 +2756,7 @@
-
+
@@ -2769,7 +2769,7 @@
-
+
@@ -2782,7 +2782,7 @@
-
+
@@ -2796,41 +2796,41 @@
-
+
-
+
-
+
-
+
-
+
-
+
@@ -2840,11 +2840,11 @@
-
+
-
+
@@ -2857,7 +2857,7 @@
-
+
@@ -2870,7 +2870,7 @@
-
+
@@ -2883,7 +2883,7 @@
-
+
@@ -2896,7 +2896,7 @@
-
+
@@ -2909,19 +2909,19 @@
-
+
-
+
-
+
@@ -2934,7 +2934,7 @@
-
+
@@ -2947,7 +2947,7 @@
-
+
@@ -2960,7 +2960,7 @@
-
+
@@ -2974,41 +2974,41 @@
-
+
-
+
-
+
-
+
-
+
-
+
@@ -3017,18 +3017,18 @@
-
+
-
+
-
+
@@ -3048,21 +3048,21 @@
-
+
-
+
-
+
@@ -3083,7 +3083,7 @@
-
+
@@ -3096,7 +3096,7 @@
-
+
@@ -3109,7 +3109,7 @@
-
+
@@ -3122,7 +3122,7 @@
-
+
@@ -3135,7 +3135,7 @@
-
+
@@ -3148,112 +3148,112 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -3267,29 +3267,29 @@
-
+
-
+
-
+
-
+
-
+
@@ -3299,11 +3299,11 @@
-
+
-
+
@@ -3316,7 +3316,7 @@
-
+
@@ -3329,7 +3329,7 @@
-
+
@@ -3342,7 +3342,7 @@
-
+
@@ -3355,7 +3355,7 @@
-
+
@@ -3368,13 +3368,13 @@
-
+
-
+
@@ -3387,7 +3387,7 @@
-
+
@@ -3400,61 +3400,61 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -3464,11 +3464,11 @@
-
+
-
+
@@ -3481,7 +3481,7 @@
-
+
@@ -3495,21 +3495,21 @@
-
+
-
+
-
+
@@ -3519,11 +3519,11 @@
-
+
-
+
@@ -3536,7 +3536,7 @@
-
+
@@ -3550,21 +3550,21 @@
-
+
-
+
-
+
@@ -3574,11 +3574,11 @@
-
+
-
+
@@ -3591,27 +3591,27 @@
-
+
-
+
-
+
-
+
@@ -3624,7 +3624,7 @@
-
+
@@ -3638,21 +3638,21 @@
-
+
-
+
-
+
@@ -3662,11 +3662,11 @@
-
+
-
+
@@ -3679,27 +3679,27 @@
-
+
-
+
-
+
-
+
@@ -3712,7 +3712,7 @@
-
+
@@ -3726,13 +3726,13 @@
-
+
-
+
@@ -3742,11 +3742,11 @@
-
+
-
+
@@ -3759,7 +3759,7 @@
-
+
@@ -3772,7 +3772,7 @@
-
+
@@ -3786,19 +3786,19 @@
-
+
-
+
-
+
@@ -3808,11 +3808,11 @@
-
+
-
+
@@ -3825,7 +3825,7 @@
-
+
@@ -3839,19 +3839,19 @@
-
+
-
+
-
+
@@ -3861,11 +3861,11 @@
-
+
-
+
@@ -3878,27 +3878,27 @@
-
+
-
+
-
+
-
+
@@ -3911,28 +3911,28 @@
-
+
-
+
-
+
-
+
@@ -3945,27 +3945,27 @@
-
+
-
+
-
+
-
+
@@ -3978,27 +3978,27 @@
-
+
-
+
-
+
-
+
@@ -4011,15 +4011,15 @@
-
+
-
+
@@ -4034,7 +4034,7 @@
-
+
@@ -4047,15 +4047,15 @@
-
+
-
+
@@ -4069,7 +4069,7 @@
-
+
@@ -4082,34 +4082,34 @@
-
+
-
+
-
+
-
+
-
+
@@ -4122,7 +4122,7 @@
-
+
@@ -4135,7 +4135,7 @@
-
+
@@ -4149,20 +4149,20 @@
-
+
-
+
-
+
@@ -4179,7 +4179,7 @@
-
+
@@ -4192,7 +4192,7 @@
-
+
@@ -4205,7 +4205,7 @@
-
+
@@ -4218,13 +4218,13 @@
-
+
-
+
@@ -4238,13 +4238,13 @@
-
+
-
+
@@ -4254,11 +4254,11 @@
-
+
-
+
@@ -4271,7 +4271,7 @@
-
+
@@ -4284,21 +4284,21 @@
-
+
-
+
-
+
@@ -4312,13 +4312,13 @@
-
+
-
+
@@ -4332,7 +4332,7 @@
-
+
@@ -4345,7 +4345,7 @@
-
+
@@ -4358,27 +4358,27 @@
-
+
-
+
-
+
-
+
@@ -4391,7 +4391,7 @@
-
+
@@ -4405,13 +4405,13 @@
-
+
-
+
@@ -4421,11 +4421,11 @@
-
+
-
+
@@ -4438,27 +4438,27 @@
-
+
-
+
-
+
-
+
@@ -4471,27 +4471,27 @@
-
+
-
+
-
+
-
+
@@ -4504,7 +4504,7 @@
-
+
@@ -4517,7 +4517,7 @@
-
+
@@ -4530,13 +4530,13 @@
-
+
-
+
@@ -4549,21 +4549,21 @@
-
+
-
+
-
+
@@ -4573,11 +4573,11 @@
-
+
-
+
@@ -4590,27 +4590,27 @@
-
+
-
+
-
+
-
+
@@ -4623,7 +4623,7 @@
-
+
@@ -4636,33 +4636,33 @@
-
+
-
+
-
+
-
+
-
+
@@ -4675,7 +4675,7 @@
-
+
@@ -4688,7 +4688,7 @@
-
+
@@ -4701,41 +4701,41 @@
-
+
-
+
-
+
-
+
-
+
-
+
@@ -4745,11 +4745,11 @@
-
+
-
+
@@ -4762,27 +4762,27 @@
-
+
-
+
-
+
-
+
@@ -4795,21 +4795,21 @@
-
+
-
+
-
+
@@ -4822,7 +4822,7 @@
-
+
@@ -4835,21 +4835,21 @@
-
+
-
+
-
+
@@ -4859,11 +4859,11 @@
-
+
-
+
@@ -4876,7 +4876,7 @@
-
+
@@ -4889,28 +4889,28 @@
-
+
-
+
-
+
-
+
@@ -4924,13 +4924,13 @@
-
+
-
+
@@ -4946,7 +4946,7 @@
-
+
@@ -4959,7 +4959,7 @@
-
+
@@ -4973,13 +4973,13 @@
-
+
-
+
@@ -4993,7 +4993,7 @@
-
+
@@ -5019,92 +5019,92 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -5118,7 +5118,7 @@
-
+
@@ -5131,29 +5131,29 @@
-
+
-
+
-
+
-
+
@@ -5163,7 +5163,7 @@
-
+
@@ -5176,7 +5176,7 @@
-
+
@@ -5189,7 +5189,7 @@
-
+
@@ -5203,20 +5203,20 @@
-
+
-
+
-
+
@@ -5226,11 +5226,11 @@
-
+
-
+
@@ -5243,27 +5243,27 @@
-
+
-
+
-
+
-
+
@@ -5276,7 +5276,7 @@
-
+
@@ -5289,7 +5289,7 @@
-
+
@@ -5303,20 +5303,20 @@
-
+
-
+
-
+
@@ -5326,11 +5326,11 @@
-
+
-
+
@@ -5343,55 +5343,55 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -5404,22 +5404,22 @@
-
+
-
+
-
+
@@ -5431,42 +5431,42 @@
-
+
-
+
-
+
-
+
-
+
-
+
@@ -5480,7 +5480,7 @@
-
+
@@ -5492,7 +5492,7 @@
-
+
@@ -5505,7 +5505,7 @@
-
+
@@ -5518,7 +5518,7 @@
-
+
@@ -5531,7 +5531,7 @@
-
+
@@ -5544,7 +5544,7 @@
-
+
@@ -5557,7 +5557,7 @@
-
+
@@ -5571,34 +5571,34 @@
-
+
-
+
-
+
-
+
-
+
@@ -5609,10 +5609,10 @@
A LAMS learning activity may have one or more input activities.
-
+
-
+
@@ -5625,7 +5625,7 @@
-
+
@@ -5639,25 +5639,25 @@
-
+
-
+
-
+
-
+
@@ -5667,11 +5667,11 @@
-
+
-
+
@@ -5684,7 +5684,7 @@
-
+
@@ -5697,7 +5697,7 @@
-
+
@@ -5710,62 +5710,62 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -5778,7 +5778,7 @@
-
+
@@ -5792,13 +5792,13 @@
-
+
-
+
@@ -5808,11 +5808,11 @@
-
+
-
+
@@ -5825,7 +5825,7 @@
-
+
@@ -5838,38 +5838,38 @@
-
+
-
+
-
+
-
+
-
+
-
+
@@ -5882,7 +5882,7 @@
-
+
@@ -5895,7 +5895,7 @@
-
+
@@ -5908,7 +5908,7 @@
-
+
@@ -5921,7 +5921,7 @@
-
+
@@ -5934,33 +5934,33 @@
-
+
-
+
-
+
-
+
-
+
@@ -5970,11 +5970,11 @@
-
+
-
+
@@ -5987,21 +5987,21 @@
-
+
-
+
-
+
@@ -6014,7 +6014,7 @@
-
+
@@ -6027,40 +6027,40 @@
-
+
-
+
-
+
-
+
-
+
-
+
@@ -6072,17 +6072,17 @@
-
+
-
+
-
+
@@ -6092,29 +6092,87 @@
-
+
-
+
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: lams_common/src/java/org/lamsfoundation/lams/commonContext.xml
===================================================================
diff -u -rf27e4add424636db794f56d68dddea0fc4e1d7d2 -r542b83631b403e37429fce3bb928f2800c5cd9b8
--- lams_common/src/java/org/lamsfoundation/lams/commonContext.xml (.../commonContext.xml) (revision f27e4add424636db794f56d68dddea0fc4e1d7d2)
+++ lams_common/src/java/org/lamsfoundation/lams/commonContext.xml (.../commonContext.xml) (revision 542b83631b403e37429fce3bb928f2800c5cd9b8)
@@ -15,74 +15,83 @@
-
+
- org/lamsfoundation/lams/usermanagement/AuthenticationMethod.hbm.xml
- org/lamsfoundation/lams/usermanagement/AuthenticationMethodType.hbm.xml
- org/lamsfoundation/lams/usermanagement/Organisation.hbm.xml
- org/lamsfoundation/lams/usermanagement/OrganisationState.hbm.xml
- org/lamsfoundation/lams/usermanagement/OrganisationType.hbm.xml
- org/lamsfoundation/lams/usermanagement/Role.hbm.xml
- org/lamsfoundation/lams/usermanagement/Privilege.hbm.xml
- org/lamsfoundation/lams/usermanagement/RolePrivilege.hbm.xml
- org/lamsfoundation/lams/usermanagement/User.hbm.xml
- org/lamsfoundation/lams/usermanagement/ForgotPasswordRequest.hbm.xml
- org/lamsfoundation/lams/usermanagement/UserOrganisation.hbm.xml
- org/lamsfoundation/lams/usermanagement/UserOrganisationCollapsed.hbm.xml
- org/lamsfoundation/lams/usermanagement/UserOrganisationRole.hbm.xml
- org/lamsfoundation/lams/usermanagement/Workspace.hbm.xml
- org/lamsfoundation/lams/usermanagement/WorkspaceFolder.hbm.xml
- org/lamsfoundation/lams/usermanagement/WorkspaceWorkspaceFolder.hbm.xml
- org/lamsfoundation/lams/usermanagement/SupportedLocale.hbm.xml
+ classpath:org/lamsfoundation/lams/usermanagement/AuthenticationMethod.hbm.xml
+ classpath:org/lamsfoundation/lams/usermanagement/AuthenticationMethodType.hbm.xml
+ classpath:org/lamsfoundation/lams/usermanagement/Organisation.hbm.xml
+ classpath:org/lamsfoundation/lams/usermanagement/OrganisationState.hbm.xml
+ classpath:org/lamsfoundation/lams/usermanagement/OrganisationType.hbm.xml
+ classpath:org/lamsfoundation/lams/usermanagement/Role.hbm.xml
+ classpath:org/lamsfoundation/lams/usermanagement/Privilege.hbm.xml
+ classpath:org/lamsfoundation/lams/usermanagement/RolePrivilege.hbm.xml
+ classpath:org/lamsfoundation/lams/usermanagement/User.hbm.xml
+ classpath:org/lamsfoundation/lams/usermanagement/ForgotPasswordRequest.hbm.xml
+ classpath:org/lamsfoundation/lams/usermanagement/UserOrganisation.hbm.xml
+ classpath:org/lamsfoundation/lams/usermanagement/UserOrganisationCollapsed.hbm.xml
+ classpath:org/lamsfoundation/lams/usermanagement/UserOrganisationRole.hbm.xml
+ classpath:org/lamsfoundation/lams/usermanagement/Workspace.hbm.xml
+ classpath:org/lamsfoundation/lams/usermanagement/WorkspaceFolder.hbm.xml
+ classpath:org/lamsfoundation/lams/usermanagement/WorkspaceWorkspaceFolder.hbm.xml
+ classpath:org/lamsfoundation/lams/usermanagement/SupportedLocale.hbm.xml
- org/lamsfoundation/lams/learningdesign/Activity.hbm.xml
- org/lamsfoundation/lams/learningdesign/BranchActivityEntry.hbm.xml
- org/lamsfoundation/lams/learningdesign/BranchCondition.hbm.xml
- org/lamsfoundation/lams/learningdesign/Group.hbm.xml
- org/lamsfoundation/lams/learningdesign/Grouping.hbm.xml
- org/lamsfoundation/lams/learningdesign/LearningDesign.hbm.xml
- org/lamsfoundation/lams/learningdesign/Competence.hbm.xml
- org/lamsfoundation/lams/learningdesign/CompetenceMapping.hbm.xml
- org/lamsfoundation/lams/learningdesign/LearningLibrary.hbm.xml
- org/lamsfoundation/lams/learningdesign/Transition.hbm.xml
- org/lamsfoundation/lams/learningdesign/License.hbm.xml
+ classpath:org/lamsfoundation/lams/learningdesign/Activity.hbm.xml
+ classpath:org/lamsfoundation/lams/learningdesign/BranchActivityEntry.hbm.xml
+ classpath:org/lamsfoundation/lams/learningdesign/BranchCondition.hbm.xml
+ classpath:org/lamsfoundation/lams/learningdesign/Group.hbm.xml
+ classpath:org/lamsfoundation/lams/learningdesign/Grouping.hbm.xml
+ classpath:org/lamsfoundation/lams/learningdesign/LearningDesign.hbm.xml
+ classpath:org/lamsfoundation/lams/learningdesign/Competence.hbm.xml
+ classpath:org/lamsfoundation/lams/learningdesign/CompetenceMapping.hbm.xml
+ classpath:org/lamsfoundation/lams/learningdesign/LearningLibrary.hbm.xml
+ classpath:org/lamsfoundation/lams/learningdesign/Transition.hbm.xml
+ classpath:org/lamsfoundation/lams/learningdesign/License.hbm.xml
- org/lamsfoundation/lams/lesson/LearnerProgress.hbm.xml
- org/lamsfoundation/lams/lesson/Lesson.hbm.xml
+ classpath:org/lamsfoundation/lams/lesson/LearnerProgress.hbm.xml
+ classpath:org/lamsfoundation/lams/lesson/Lesson.hbm.xml
- org/lamsfoundation/lams/tool/SystemTool.hbm.xml
- 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
+ classpath:org/lamsfoundation/lams/tool/SystemTool.hbm.xml
+ classpath:org/lamsfoundation/lams/tool/Tool.hbm.xml
+ classpath:org/lamsfoundation/lams/tool/ToolContent.hbm.xml
+ classpath:org/lamsfoundation/lams/tool/ToolSession.hbm.xml
+ classpath:org/lamsfoundation/lams/tool/ToolImportSupport.hbm.xml
- org/lamsfoundation/lams/workspace/WorkspaceFolderContent.hbm.xml
+ classpath:org/lamsfoundation/lams/workspace/WorkspaceFolderContent.hbm.xml
- org/lamsfoundation/lams/themes/CSSProperty.hbm.xml
- org/lamsfoundation/lams/themes/CSSStyle.hbm.xml
- org/lamsfoundation/lams/themes/CSSThemeVisualElement.hbm.xml
+ classpath:org/lamsfoundation/lams/themes/CSSProperty.hbm.xml
+ classpath:org/lamsfoundation/lams/themes/CSSStyle.hbm.xml
+ classpath:org/lamsfoundation/lams/themes/CSSThemeVisualElement.hbm.xml
- org/lamsfoundation/lams/notebook/model/NotebookEntry.hbm.xml
+ classpath:org/lamsfoundation/lams/notebook/model/NotebookEntry.hbm.xml
- org/lamsfoundation/lams/events/Event.hbm.xml
- org/lamsfoundation/lams/events/Subscription.hbm.xml
+ classpath:org/lamsfoundation/lams/events/Event.hbm.xml
+ classpath:org/lamsfoundation/lams/events/Subscription.hbm.xml
- org/lamsfoundation/lams/config/ConfigurationItem.hbm.xml
+ classpath:org/lamsfoundation/lams/config/ConfigurationItem.hbm.xml
- org/lamsfoundation/lams/integration/ExtServerOrgMap.hbm.xml
- org/lamsfoundation/lams/integration/ExtCourseClassMap.hbm.xml
- org/lamsfoundation/lams/integration/ExtUserUseridMap.hbm.xml
+ classpath:org/lamsfoundation/lams/integration/ExtServerOrgMap.hbm.xml
+ classpath:org/lamsfoundation/lams/integration/ExtCourseClassMap.hbm.xml
+ classpath:org/lamsfoundation/lams/integration/ExtUserUseridMap.hbm.xml
+
+
+
+ classpath*:org/lamsfoundation/lams/tool/qa/*.hbm.xml
+ classpath:org/lamsfoundation/lams/tool/notebook/model/Notebook.hbm.xml
+ classpath:org/lamsfoundation/lams/tool/notebook/model/NotebookSession.hbm.xml
+ classpath:org/lamsfoundation/lams/tool/notebook/model/NotebookUser.hbm.xml
+ classpath:org/lamsfoundation/lams/tool/notebook/model/NotebookAttachment.hbm.xml
+ classpath:org/lamsfoundation/lams/tool/notebook/model/NotebookCondition.hbm.xml
Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/BranchCondition.java
===================================================================
diff -u -r3538b4ae424da479962e98b7528ad22b44cdd368 -r542b83631b403e37429fce3bb928f2800c5cd9b8
--- lams_common/src/java/org/lamsfoundation/lams/learningdesign/BranchCondition.java (.../BranchCondition.java) (revision 3538b4ae424da479962e98b7528ad22b44cdd368)
+++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/BranchCondition.java (.../BranchCondition.java) (revision 542b83631b403e37429fce3bb928f2800c5cd9b8)
@@ -41,6 +41,16 @@
*/
public class BranchCondition implements Comparable {
+ public static final String OUTPUT_TYPE_STRING = "OUTPUT_STRING";
+
+ public static final String OUTPUT_TYPE_BOOLEAN = "OUTPUT_BOOLEAN";
+
+ public static final String OUTPUT_TYPE_DOUBLE = "OUTPUT_DOUBLE";
+
+ public static final String OUTPUT_TYPE_LONG = "OUTPUT_LONG";
+
+ public static final String OUTPUT_TYPE_COMPLEX = "OUTPUT_COMPLEX";
+
private static Logger log = Logger.getLogger(BranchCondition.class);
protected Long conditionId;
@@ -211,6 +221,11 @@
exactMatchValue);
}
+ @Override
+ public Object clone() {
+ return new BranchCondition(null, null, orderId, name, displayName, type, startValue, endValue, exactMatchValue);
+ }
+
public int compareTo(Object arg0) {
BranchCondition other = (BranchCondition) arg0;
return new CompareToBuilder().append(orderId, other.getOrderId()).append(conditionId, other.getConditionId())
@@ -243,47 +258,47 @@
}
public boolean exactMatchMet(ToolOutputValue outputValue) {
- if ("OUTPUT_LONG".equals(type)) {
+ if (BranchCondition.OUTPUT_TYPE_LONG.equals(type)) {
Long exactMatchObj = exactMatchValue != null ? convertToLong(exactMatchValue) : null;
Long actualValue = outputValue.getLong();
return actualValue != null && actualValue.equals(exactMatchObj);
- } else if ("OUTPUT_DOUBLE".equals(type)) {
+ } else if (BranchCondition.OUTPUT_TYPE_DOUBLE.equals(type)) {
Double exactMatchObj = exactMatchValue != null ? Double.parseDouble(exactMatchValue) : null;
Double actualValue = outputValue.getDouble();
return actualValue != null && actualValue.equals(exactMatchObj);
- } else if ("OUTPUT_BOOLEAN".equals(type)) {
+ } else if (BranchCondition.OUTPUT_TYPE_BOOLEAN.equals(type)) {
Boolean exactMatchObj = exactMatchValue != null ? Boolean.parseBoolean(exactMatchValue) : null;
Boolean actualValue = outputValue.getBoolean();
return actualValue != null && actualValue.equals(exactMatchObj);
- } else if ("OUTPUT_STRING".equals(type)) {
+ } else if (BranchCondition.OUTPUT_TYPE_STRING.equals(type)) {
Double actualValue = outputValue.getDouble();
return actualValue != null && actualValue.equals(exactMatchValue);
}
return false;
}
public boolean inRange(ToolOutputValue outputValue) {
- if ("OUTPUT_LONG".equals(type)) {
+ if (BranchCondition.OUTPUT_TYPE_LONG.equals(type)) {
Long startValueLong = startValue != null ? convertToLong(startValue) : null;
Long endValueLong = endValue != null ? convertToLong(endValue) : null;
Long actualValue = outputValue.getLong();
return actualValue != null && (startValueLong == null || actualValue.compareTo(startValueLong) >= 0)
&& (endValueLong == null || actualValue.compareTo(endValueLong) <= 0);
- } else if ("OUTPUT_DOUBLE".equals(type)) {
+ } else if (BranchCondition.OUTPUT_TYPE_DOUBLE.equals(type)) {
Double startValueDouble = startValue != null ? Double.parseDouble(startValue) : null;
Double endValueDouble = endValue != null ? Double.parseDouble(endValue) : null;
Double actualValue = outputValue.getDouble();
return actualValue != null && (startValueDouble == null || actualValue.compareTo(startValueDouble) >= 0)
&& (endValueDouble == null || actualValue.compareTo(endValueDouble) <= 0);
- } else if ("OUTPUT_BOOLEAN".equals(type)) {
+ } else if (BranchCondition.OUTPUT_TYPE_BOOLEAN.equals(type)) {
// this is a nonsense, but we'll code it just in case. What order is a boolean? True greater than false?
Boolean startValueBoolean = startValue != null ? Boolean.parseBoolean(startValue) : null;
Boolean endValueBoolean = endValue != null ? Boolean.parseBoolean(endValue) : null;
Boolean actualValue = outputValue.getBoolean();
return actualValue != null && (startValueBoolean == null || actualValue.compareTo(startValueBoolean) >= 0)
&& (endValueBoolean == null || actualValue.compareTo(endValueBoolean) <= 0);
- } else if ("OUTPUT_STRING".equals(type)) {
+ } else if (BranchCondition.OUTPUT_TYPE_STRING.equals(type)) {
String actualValue = outputValue.getString();
return actualValue != null && (startValue == null || actualValue.compareTo(startValue) >= 0)
&& (endValue == null || actualValue.compareTo(endValue) <= 0);
@@ -353,17 +368,16 @@
}
private Comparable getTypedValue(String untypedValue) {
- if ("OUTPUT_LONG".equals(type)) {
+ if (BranchCondition.OUTPUT_TYPE_LONG.equals(type)) {
return convertToLong(untypedValue);
- } else if ("OUTPUT_DOUBLE".equals(type)) {
+ } else if (BranchCondition.OUTPUT_TYPE_DOUBLE.equals(type)) {
return Double.parseDouble(untypedValue);
- } else if ("OUTPUT_BOOLEAN".equals(type)) {
+ } else if (BranchCondition.OUTPUT_TYPE_BOOLEAN.equals(type)) {
return Boolean.parseBoolean(untypedValue);
- } else if ("OUTPUT_STRING".equals(type)) {
+ } else if (BranchCondition.OUTPUT_TYPE_STRING.equals(type)) {
return untypedValue;
} else {
return null;
}
}
-
-}
+}
\ No newline at end of file
Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/TextSearchCondition.java
===================================================================
diff -u -r3590714b9dfaa2eeee7dcacaa1e76db4f1f45d23 -r542b83631b403e37429fce3bb928f2800c5cd9b8
--- lams_common/src/java/org/lamsfoundation/lams/learningdesign/TextSearchCondition.java (.../TextSearchCondition.java) (revision 3590714b9dfaa2eeee7dcacaa1e76db4f1f45d23)
+++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/TextSearchCondition.java (.../TextSearchCondition.java) (revision 542b83631b403e37429fce3bb928f2800c5cd9b8)
@@ -24,9 +24,11 @@
package org.lamsfoundation.lams.learningdesign;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.lamsfoundation.lams.learningdesign.dto.BranchConditionDTO;
import org.lamsfoundation.lams.tool.ToolOutput;
@@ -61,9 +63,25 @@
// ---- non-persistent fields ----------
/**
- * Regular expression that divides a string into single words.
+ * Regular expression that divides a string into single words. The meaning is "one or more whitespace characters or
+ * beginnings of a line or ends of a line".
*/
- public static final String WORD_DELIMITER_REGEX = "\\s";
+ private static final String WORD_DELIMITER_REGEX = "(?:\\s|$|^)+";
+ /**
+ * Integer that sets flags for regex pattern matching.
+ */
+ private static final int PATTERN_MATCHING_OPTIONS = Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE
+ | Pattern.MULTILINE;
+ /**
+ * A regular expression pattern that matches HTML tags.
+ */
+ public static final String HTML_TAG_REGEX = "\\<.*?>";
+ /**
+ * A regular expression pattern that matches end-of-line HTML tags. If needed, it can extented to
+ * (?:
|
|
|
)
. Right now FCKeditor creates only the first option.
+ */
+ public static final String BR_TAG_REGEX = "
";
+
private static Logger log = Logger.getLogger(TextSearchCondition.class);
/**
* Were the strings provided by user parsed into practical collections of words.
@@ -74,9 +92,10 @@
*/
protected List allWordsCondition = new ArrayList();
/**
- * Same as {@link #phrase}. Created for
+ * Property {@link #phrase} divided into words. Although we are looking for the whole phrase, spaces between words
+ * should be divided into something more regex'y.
*/
- protected String phraseCondition;
+ protected List phraseCondition;
/**
* Property {@link #anyWords} divided into words.
*/
@@ -153,7 +172,7 @@
return phrase;
}
- public String getPhraseCondition() {
+ public List getPhraseCondition() {
return phraseCondition;
}
@@ -163,8 +182,7 @@
}
/**
- * Checks if the given text contain the words provided in the condition parameters. The search is done by using
- * lower case both text and paramaters.
+ * Checks if the given text contain the words provided in the condition parameters (case insensitive).
*
* @param text
* string to check
@@ -174,35 +192,61 @@
if (text == null) {
return false;
}
+ // we parse the condition strings to more useful arrays of words
if (!conditionsParsed) {
parseConditionStrings();
}
- String lowerCaseText = text.toLowerCase();
+
+ Pattern regexPattern = null;
+ StringBuilder stringPattern = null;
+ Matcher matcher = null;
+ // For each condition type we build a regular expression and try to find it in the text.
if (getExcludedWordsCondition() != null) {
+ stringPattern = new StringBuilder();
for (String excludedWord : getExcludedWordsCondition()) {
- if (lowerCaseText.contains(excludedWord)) {
- return false;
- }
+ stringPattern.append("(?:").append(TextSearchCondition.WORD_DELIMITER_REGEX).append(
+ Pattern.quote(excludedWord)).append(TextSearchCondition.WORD_DELIMITER_REGEX).append(")|");
}
+ stringPattern.deleteCharAt(stringPattern.length() - 1);
+ regexPattern = Pattern.compile(stringPattern.toString(), TextSearchCondition.PATTERN_MATCHING_OPTIONS);
+ matcher = regexPattern.matcher(text);
+ if (matcher.find()) {
+ return false;
+ }
}
if (getAnyWordsCondition() != null) {
- boolean wordFound = false;
+ stringPattern = new StringBuilder();
+
for (String word : getAnyWordsCondition()) {
- if (lowerCaseText.contains(word)) {
- wordFound = true;
- break;
- }
+ stringPattern.append("(?:").append(TextSearchCondition.WORD_DELIMITER_REGEX)
+ .append(Pattern.quote(word)).append(TextSearchCondition.WORD_DELIMITER_REGEX).append(")|");
}
- if (!wordFound) {
+ stringPattern.deleteCharAt(stringPattern.length() - 1);
+ regexPattern = Pattern.compile(stringPattern.toString(), TextSearchCondition.PATTERN_MATCHING_OPTIONS);
+ matcher = regexPattern.matcher(text);
+ if (!matcher.find()) {
return false;
}
}
- if (getPhraseCondition() != null && !lowerCaseText.contains(getPhraseCondition())) {
- return false;
+ if (getPhraseCondition() != null) {
+ stringPattern = new StringBuilder(TextSearchCondition.WORD_DELIMITER_REGEX);
+ for (String word : getPhraseCondition()) {
+ stringPattern.append(Pattern.quote(word)).append(TextSearchCondition.WORD_DELIMITER_REGEX);
+ }
+ regexPattern = Pattern.compile(stringPattern.toString(), TextSearchCondition.PATTERN_MATCHING_OPTIONS);
+ matcher = regexPattern.matcher(text);
+ if (!matcher.find()) {
+ return false;
+ }
}
+
if (getAllWordsCondition() != null) {
for (String word : getAllWordsCondition()) {
- if (!lowerCaseText.contains(word)) {
+ stringPattern = new StringBuilder(TextSearchCondition.WORD_DELIMITER_REGEX).append(Pattern.quote(word))
+ .append(TextSearchCondition.WORD_DELIMITER_REGEX);
+ regexPattern = Pattern.compile(stringPattern.toString(), TextSearchCondition.PATTERN_MATCHING_OPTIONS);
+ matcher = regexPattern.matcher(text);
+ if (!matcher.find()) {
return false;
}
}
@@ -227,46 +271,11 @@
*/
public void parseConditionStrings(String allWordsString, String phraseString, String anyWordsString,
String excludedWordsString) {
-
conditionsParsed = true;
- String trimmed = null;
- String[] splited = null;
- if (allWordsString != null) {
- trimmed = allWordsString.trim();
- splited = trimmed.split(TextSearchCondition.WORD_DELIMITER_REGEX);
- for (int index = 0; index < splited.length; index++) {
- splited[index] = splited[index].toLowerCase();
- }
-
- setAllWordsCondition(Arrays.asList(splited));
- } else {
- setAllWordsCondition(null);
- }
- if (phraseString != null) {
- trimmed = phraseString.trim();
- setPhraseCondition(trimmed.toLowerCase());
- }
-
- if (anyWordsString != null) {
- trimmed = anyWordsString.trim();
- splited = trimmed.split(TextSearchCondition.WORD_DELIMITER_REGEX);
- for (int index = 0; index < splited.length; index++) {
- splited[index] = splited[index].toLowerCase();
- }
- setAnyWordsCondition(Arrays.asList(splited));
- } else {
- setAnyWordsCondition(null);
- }
- if (excludedWordsString != null) {
- trimmed = excludedWordsString.trim();
- splited = trimmed.split(TextSearchCondition.WORD_DELIMITER_REGEX);
- for (int index = 0; index < splited.length; index++) {
- splited[index] = splited[index].toLowerCase();
- }
- setExcludedWordsCondition(Arrays.asList(splited));
- } else {
- setExcludedWordsCondition(null);
- }
+ setAllWordsCondition(splitSentence(allWordsString));
+ setPhraseCondition(splitSentence(phraseString));
+ setAnyWordsCondition(splitSentence(anyWordsString));
+ setExcludedWordsCondition(splitSentence(excludedWordsString));
}
/**
@@ -300,7 +309,7 @@
conditionsParsed = false;
}
- public void setPhraseCondition(String phraseCondition) {
+ public void setPhraseCondition(List phraseCondition) {
this.phraseCondition = phraseCondition;
}
@@ -323,4 +332,41 @@
protected void setExcludedWordsCondition(List excludedWordsCondition) {
this.excludedWordsCondition = excludedWordsCondition;
}
+
+ /**
+ * Splits the given string into words using configured delimiter.
+ *
+ * @param sentence
+ * string to split
+ * @return list of non-empty words
+ */
+ private List splitSentence(String sentence) {
+ List list = null;
+ if (!StringUtils.isEmpty(sentence)) {
+ String[] splitted = sentence.trim().split(TextSearchCondition.WORD_DELIMITER_REGEX);
+ list = new ArrayList(splitted.length);
+ // we don't need empty words
+ for (String word : splitted) {
+ if (!StringUtils.isEmpty(word)) {
+ list.add(word);
+ }
+ }
+ if (list.isEmpty()) {
+ list = null;
+ }
+ }
+ return list;
+ }
+
+ /**
+ * Strips HTML tags and leave "pure" text. Useful for FCKeditor created text.
+ *
+ * @param text
+ * string to process
+ * @return string after stripping
+ */
+ public static String removeHTMLtags(String text) {
+ return text == null ? null : text.replaceAll(TextSearchCondition.BR_TAG_REGEX, " ").replaceAll(
+ TextSearchCondition.HTML_TAG_REGEX, "");
+ }
}
\ No newline at end of file
Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/TextSearchConditionComparator.java
===================================================================
diff -u
--- lams_common/src/java/org/lamsfoundation/lams/learningdesign/TextSearchConditionComparator.java (revision 0)
+++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/TextSearchConditionComparator.java (revision 542b83631b403e37429fce3bb928f2800c5cd9b8)
@@ -0,0 +1,49 @@
+/****************************************************************
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA
+ *
+ * http://www.gnu.org/licenses/gpl.txt
+ * ****************************************************************
+ */
+
+/* $Id$ */
+package org.lamsfoundation.lams.learningdesign;
+
+import java.util.Comparator;
+
+
+/**
+ * Comparator for TextSearchCondition
. Only the order ID is compared.
+ *
+ * @author Marcin Cieslak
+ * @see org.lamsfoundation.lams.learningdesign.TextSearchCondition
+ */
+public class TextSearchConditionComparator implements Comparator {
+
+ /**
+ * {@inheritDoc}
+ */
+ public int compare(TextSearchCondition o1, TextSearchCondition o2) {
+ if (o1 != null && o2 != null) {
+ return o1.getOrderId() - o2.getOrderId();
+ } else if (o1 != null) {
+ return 1;
+ } else {
+ return -1;
+ }
+ }
+}
\ No newline at end of file
Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/dao/IBranchActivityEntryDAO.java
===================================================================
diff -u -r87ec6bd0708e9da634182eacca8c74e442bc748f -r542b83631b403e37429fce3bb928f2800c5cd9b8
--- lams_common/src/java/org/lamsfoundation/lams/learningdesign/dao/IBranchActivityEntryDAO.java (.../IBranchActivityEntryDAO.java) (revision 87ec6bd0708e9da634182eacca8c74e442bc748f)
+++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/dao/IBranchActivityEntryDAO.java (.../IBranchActivityEntryDAO.java) (revision 542b83631b403e37429fce3bb928f2800c5cd9b8)
@@ -26,18 +26,20 @@
import java.util.List;
import org.lamsfoundation.lams.learningdesign.BranchActivityEntry;
+import org.lamsfoundation.lams.learningdesign.BranchCondition;
/**
* @author fiona
- *
+ *
*/
public interface IBranchActivityEntryDAO {
- /**
- * Returns the list of BranchActivityEntries applicable for the given learning design, determined via the sequence
- * activities (which form the related branches)
- */
- public abstract List getEntriesByLearningDesign(
- Long learningDesignId);
+ /**
+ * Returns the list of BranchActivityEntries applicable for the given learning design, determined via the sequence
+ * activities (which form the related branches)
+ */
+ public abstract List getEntriesByLearningDesign(Long learningDesignId);
+ BranchCondition getConditionByID(Long conditionID);
+
}
\ No newline at end of file
Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/dao/hibernate/BranchActivityEntryDAO.java
===================================================================
diff -u -r87ec6bd0708e9da634182eacca8c74e442bc748f -r542b83631b403e37429fce3bb928f2800c5cd9b8
--- lams_common/src/java/org/lamsfoundation/lams/learningdesign/dao/hibernate/BranchActivityEntryDAO.java (.../BranchActivityEntryDAO.java) (revision 87ec6bd0708e9da634182eacca8c74e442bc748f)
+++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/dao/hibernate/BranchActivityEntryDAO.java (.../BranchActivityEntryDAO.java) (revision 542b83631b403e37429fce3bb928f2800c5cd9b8)
@@ -27,21 +27,35 @@
import org.lamsfoundation.lams.dao.hibernate.BaseDAO;
import org.lamsfoundation.lams.learningdesign.BranchActivityEntry;
+import org.lamsfoundation.lams.learningdesign.BranchCondition;
import org.lamsfoundation.lams.learningdesign.SequenceActivity;
import org.lamsfoundation.lams.learningdesign.dao.IBranchActivityEntryDAO;
public class BranchActivityEntryDAO extends BaseDAO implements IBranchActivityEntryDAO {
-
- private final static String ENTRIES_FOR_LEARNING_DESIGN = "select entry from "
- + BranchActivityEntry.class.getName() + " entry, " + SequenceActivity.class.getName() + " sequenceActivity "
- + " where sequenceActivity.learningDesign.id = ? "
- + " and entry.branchSequenceActivity = sequenceActivity";
- /* (non-Javadoc)
- * @see org.lamsfoundation.lams.learningdesign.dao.hibernate.IBranchActivityEntryDAO#getEntriesByLearningDesign(java.lang.Long)
- */
- public List getEntriesByLearningDesign(Long learningDesignId){
- return (List) this.getHibernateTemplate().find(ENTRIES_FOR_LEARNING_DESIGN,learningDesignId);
+ private final static String ENTRIES_FOR_LEARNING_DESIGN = "select entry from "
+ + BranchActivityEntry.class.getName() + " entry, " + SequenceActivity.class.getName()
+ + " sequenceActivity " + " where sequenceActivity.learningDesign.id = ? "
+ + " and entry.branchSequenceActivity = sequenceActivity";
+
+ private final static String CONDITION_BY_ID = "FROM " + BranchCondition.class.getName()
+ + " con WHERE con.conditionId = ?";
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.lamsfoundation.lams.learningdesign.dao.hibernate.IBranchActivityEntryDAO#getEntriesByLearningDesign(java.lang.Long)
+ */
+ public List getEntriesByLearningDesign(Long learningDesignId) {
+ return this.getHibernateTemplate().find(BranchActivityEntryDAO.ENTRIES_FOR_LEARNING_DESIGN, learningDesignId);
}
-}
+ public BranchCondition getConditionByID(Long conditionID) {
+ List result = this.getHibernateTemplate().find(BranchActivityEntryDAO.CONDITION_BY_ID,
+ conditionID);
+ if (result == null || result.isEmpty()) {
+ return null;
+ }
+ return result.get(0);
+ }
+}
\ No newline at end of file
Index: lams_common/src/java/org/lamsfoundation/lams/tool/service/ILamsCoreToolService.java
===================================================================
diff -u -r7063c259a54239643a9ef50c3bb36ca9f6e7fbb5 -r542b83631b403e37429fce3bb928f2800c5cd9b8
--- lams_common/src/java/org/lamsfoundation/lams/tool/service/ILamsCoreToolService.java (.../ILamsCoreToolService.java) (revision 7063c259a54239643a9ef50c3bb36ca9f6e7fbb5)
+++ lams_common/src/java/org/lamsfoundation/lams/tool/service/ILamsCoreToolService.java (.../ILamsCoreToolService.java) (revision 542b83631b403e37429fce3bb928f2800c5cd9b8)
@@ -23,7 +23,6 @@
/* $$Id$$ */
package org.lamsfoundation.lams.tool.service;
-
import java.util.List;
import java.util.Set;
import java.util.SortedMap;
@@ -35,317 +34,376 @@
import org.lamsfoundation.lams.tool.ToolOutput;
import org.lamsfoundation.lams.tool.ToolOutputDefinition;
import org.lamsfoundation.lams.tool.ToolSession;
-import org.lamsfoundation.lams.tool.ToolSessionManager;
import org.lamsfoundation.lams.tool.exception.DataMissingException;
import org.lamsfoundation.lams.tool.exception.LamsToolServiceException;
import org.lamsfoundation.lams.tool.exception.ToolException;
import org.lamsfoundation.lams.usermanagement.User;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
/**
- * This interface defines the service that lams tool package offers to other
- * lams core modules, such as, lams_learning, lams_authoring, lams_monitoring.
+ *
+ * This interface defines the service that lams tool package offers to other lams core modules, such as, lams_learning,
+ * lams_authoring, lams_monitoring.
+ *
*
- * It doesn't have the tool service that will be called by the tool.
+ *
+ * It doesn't have the tool service that will be called by the tool.
+ *
*
*
* @author Jacky Fang
- * @since 2005-3-17
+ * @since 2005-3-17
* @version 1.1
*/
-public interface ILamsCoreToolService
-{
+public interface ILamsCoreToolService {
/**
- * Creates a LAMS ToolSession for a learner and activity. Checks
- * to see if an appropriate tool session exists for each learner
- * before creating the tool session.
+ * Creates a LAMS ToolSession for a learner and activity. Checks to see if an appropriate tool session exists for
+ * each learner before creating the tool session.
*
- * If an appropriate tool session already exists for a learner, then
- * it returns null.
+ * If an appropriate tool session already exists for a learner, then it returns null.
*
- * Sets up the tool session based on the groupingSupportType.
+ * Sets up the tool session based on the groupingSupportType.
+ *
* @see org.lamsfoundation.lams.learningdesign.ToolActivity#createToolSessionForActivity(org.lamsfoundation.lams.usermanagement.User,org.lamsfoundation.lams.lesson.Lesson)
- *
- * @param learner the learner who is running the activity.
- * @param activity the requested activity.
+ *
+ * @param learner
+ * the learner who is running the activity.
+ * @param activity
+ * the requested activity.
* @return toolSession if a new one created, null otherwise.
*/
- public ToolSession createToolSession(User learner, ToolActivity activity,Lesson lesson) throws LamsToolServiceException;
+ public ToolSession createToolSession(User learner, ToolActivity activity, Lesson lesson)
+ throws LamsToolServiceException;
/**
- * Creates LAMS ToolSessions for a set of learners and activity. Checks
- * to see if an appropriate tool session exists for each learner
- * before creating the tool session.
+ * Creates LAMS ToolSessions for a set of learners and activity. Checks to see if an appropriate tool session exists
+ * for each learner before creating the tool session.
*
- * If an appropriate tool session already exists for a learner, then
- * it does not include the tool session in the returned set.
+ * If an appropriate tool session already exists for a learner, then it does not include the tool session in the
+ * returned set.
*
- * @param learners the learners who are running the activity.
- * @param activity the requested activity.
+ *
+ * @param learners
+ * the learners who are running the activity.
+ * @param activity
+ * the requested activity.
* @return toolSessions set of newly created ToolSessions
*/
- public Set createToolSessions(Set learners, ToolActivity activity,Lesson lesson) throws LamsToolServiceException;
+ public Set createToolSessions(Set learners, ToolActivity activity, Lesson lesson) throws LamsToolServiceException;
/**
- * Returns the previously created ToolSession for a learner and activity.
- * It is queried base on learner.
- * @param learner the learner who owns the tool session.
- * @param activity the activity that associate with the tool session.
+ * Returns the previously created ToolSession for a learner and activity. It is queried base on learner.
+ *
+ * @param learner
+ * the learner who owns the tool session.
+ * @param activity
+ * the activity that associate with the tool session.
* @return the requested tool session.
- * @throws LamsToolServiceException the known error condition when we
- * are getting the tool session
+ * @throws LamsToolServiceException
+ * the known error condition when we are getting the tool session
*/
public ToolSession getToolSessionByLearner(User learner, Activity activity) throws LamsToolServiceException;
-
+
/**
* Returns the tool session according to tool session id.
- * @param toolSessionId the requested tool session id.
+ *
+ * @param toolSessionId
+ * the requested tool session id.
* @return the tool session object
*/
public ToolSession getToolSessionById(Long toolSessionId);
-
+
/**
- * Get the lams tool session based on activity. It search through all
- * the tool sessions that linked to the requested activity and return
- * the tool session with requested learner information.
+ * Get the lams tool session based on activity. It search through all the tool sessions that linked to the requested
+ * activity and return the tool session with requested learner information.
*
- * @param learner the requested learner
- * @param toolActivity the requested activity.
+ * @param learner
+ * the requested learner
+ * @param toolActivity
+ * the requested activity.
* @return the tool session.
- * @throws LamsToolServiceException the known error condition when we
- * are getting the tool session
+ * @throws LamsToolServiceException
+ * the known error condition when we are getting the tool session
*/
- public ToolSession getToolSessionByActivity(User learner, ToolActivity toolActivity)throws LamsToolServiceException;
-
+ public ToolSession getToolSessionByActivity(User learner, ToolActivity toolActivity)
+ throws LamsToolServiceException;
+
/**
- * Notify tools to create their tool sessions in their own tables.
- * @param toolSession the tool session generated by lams.
- * @param activity the activity correspondent to that tool session.
+ * Notify tools to create their tool sessions in their own tables.
+ *
+ * @param toolSession
+ * the tool session generated by lams.
+ * @param activity
+ * the activity correspondent to that tool session.
*/
- public void notifyToolsToCreateSession(ToolSession toolSession, ToolActivity activity)
- throws ToolException;
-
+ public void notifyToolsToCreateSession(ToolSession toolSession, ToolActivity activity) throws ToolException;
+
/**
- * Calls the tool to copy the content for an activity. Used when copying a learning design.
- * If it is a preview lesson, we don't want to set define later - we will sidestep this in the progress engine.
+ * Calls the tool to copy the content for an activity. Used when copying a learning design. If it is a preview
+ * lesson, we don't want to set define later - we will sidestep this in the progress engine.
*
- * @param toolActivity the tool activity defined in the design.
- * @param setDefineLater whether or not to set the define later flag.
- * @param customCSV custom comma-separated values used for tool adapters
- * @throws DataMissingException, ToolException
+ * @param toolActivity
+ * the tool activity defined in the design.
+ * @param setDefineLater
+ * whether or not to set the define later flag.
+ * @param customCSV
+ * custom comma-separated values used for tool adapters
+ * @throws DataMissingException,
+ * ToolException
* @see org.lamsfoundation.lams.tool.service.ILamsCoreToolService#notifyToolToCopyContent(org.lamsfoundation.lams.learningdesign.ToolActivity)
*/
- public Long notifyToolToCopyContent(ToolActivity toolActivity, boolean setDefineLater, String customCSV)
- throws DataMissingException, ToolException;
-
+ public Long notifyToolToCopyContent(ToolActivity toolActivity, boolean setDefineLater, String customCSV)
+ throws DataMissingException, ToolException;
+
/**
* Calls the tool to set up the define later and run offline flags.
*
- * This method is a subset of the functionality of notifyToolToCopyContent(ToolActivity toolActivity, boolean setDefineLater);
- * so if you call notifyToolToCopyContent then you don't need to call this method. It is a separate method used by Live Edit.
+ * This method is a subset of the functionality of notifyToolToCopyContent(ToolActivity toolActivity, boolean
+ * setDefineLater); so if you call notifyToolToCopyContent then you don't need to call this method. It is a separate
+ * method used by Live Edit.
*
- * @param toolActivity the tool activity defined in the design.
- * @throws DataMissingException, ToolException
+ * @param toolActivity
+ * the tool activity defined in the design.
+ * @throws DataMissingException,
+ * ToolException
* @see org.lamsfoundation.lams.tool.service.ILamsCoreToolService#notifyToolToCopyContent(org.lamsfoundation.lams.learningdesign.ToolActivity)
*/
- public Long notifyToolOfStatusFlags(ToolActivity toolActivity)
- throws DataMissingException, ToolException;
+ public Long notifyToolOfStatusFlags(ToolActivity toolActivity) throws DataMissingException, ToolException;
/**
- * Calls the tool to copy the content for an activity. Used when copying an activity in authoring. Can't
- * use the notifyToolToCopyContent(ToolActivity, boolean) version in authoring as the tool activity won't
- * exist if the user hasn't saved the sequence yet. But the tool content (as that is saved by the
- * tool) may already exist.
+ * Calls the tool to copy the content for an activity. Used when copying an activity in authoring. Can't use the
+ * notifyToolToCopyContent(ToolActivity, boolean) version in authoring as the tool activity won't exist if the user
+ * hasn't saved the sequence yet. But the tool content (as that is saved by the tool) may already exist.
*
- * This doesn't set the define later and run offline flags from the design - it only copies the content
- * stored in the tool.
+ * This doesn't set the define later and run offline flags from the design - it only copies the content stored in
+ * the tool.
*
- * @param toolContentId the content to be copied.
- * @param customCSV the customCSV required if this is a tooladapter tool, otherwise null
- * @throws DataMissingException, ToolException
+ * @param toolContentId
+ * the content to be copied.
+ * @param customCSV
+ * the customCSV required if this is a tooladapter tool, otherwise null
+ * @throws DataMissingException,
+ * ToolException
* @see org.lamsfoundation.lams.tool.service.ILamsCoreToolService#notifyToolToCopyContent(org.lamsfoundation.lams.learningdesign.ToolActivity)
*/
- public Long notifyToolToCopyContent(Long toolContentId, String customCSV)
- throws DataMissingException, ToolException;
+ public Long notifyToolToCopyContent(Long toolContentId, String customCSV) throws DataMissingException,
+ ToolException;
+
/**
- * Ask a tool to delete a tool content. If any related tool session data exists then it should
- * be deleted.
+ * Ask a tool to delete a tool content. If any related tool session data exists then it should be deleted.
*
- * @param toolActivity the tool activity defined in the design.
- * @throws ToolException
+ * @param toolActivity
+ * the tool activity defined in the design.
+ * @throws ToolException
*/
public void notifyToolToDeleteContent(ToolActivity toolActivity) throws ToolException;
/**
- * Ask a tool for its OutputDefinitions, based on the given toolContentId. If the tool doesn't
- * have any content matching the toolContentId then it should create the OutputDefinitions based
- * on the tool's default content.
+ * Ask a tool for its OutputDefinitions, based on the given toolContentId. If the tool doesn't have any content
+ * matching the toolContentId then it should create the OutputDefinitions based on the tool's default content.
*
- * This functionality relies on a method added to the Tool Contract in LAMS 2.1, so if the tool
- * doesn't support the required method, it writes out an error to the log but doesn't throw
- * an exception - just returns an empty map.
- *
+ * This functionality relies on a method added to the Tool Contract in LAMS 2.1, so if the tool doesn't support the
+ * required method, it writes out an error to the log but doesn't throw an exception - just returns an empty map.
+ *
* @param toolContentId
* @return SortedMap of ToolOutputDefinitions with the key being the name of each definition
- * @throws ToolException
+ * @throws ToolException
*/
- public SortedMap getOutputDefinitionsFromTool(Long toolContentId) throws ToolException;
-
+ public SortedMap getOutputDefinitionsFromTool(Long toolContentId)
+ throws ToolException;
+
/**
- * Ask a tool for one particular ToolOutput, based on the given toolSessionId. If the tool doesn't
- * have any content matching the toolSessionId then should return an "empty" but valid set of data. e.g
- * an empty mark would be 0.
+ * Ask a tool for one particular ToolOutput, based on the given toolSessionId. If the tool doesn't have any content
+ * matching the toolSessionId then should return an "empty" but valid set of data. e.g an empty mark would be 0.
*
* This functionality relies on a method added to the Tool Contract in LAMS 2.1.
*
- * @throws ToolException
+ * @throws ToolException
*/
- public ToolOutput getOutputFromTool(String conditionName, Long toolSessionId, Integer learnerId) throws ToolException;
-
+ public ToolOutput getOutputFromTool(String conditionName, Long toolSessionId, Integer learnerId)
+ throws ToolException;
+
/**
- * Ask a tool for one particular ToolOutput, based on the given toolSessionId. If the tool doesn't
- * have any content matching the toolSessionId then should return an "empty" but valid set of data. e.g
- * an empty mark would be 0.
+ * Ask a tool for one particular ToolOutput, based on the given toolSessionId. If the tool doesn't have any content
+ * matching the toolSessionId then should return an "empty" but valid set of data. e.g an empty mark would be 0.
*
* This functionality relies on a method added to the Tool Contract in LAMS 2.1.
*
- * @throws ToolException
+ * @throws ToolException
*/
- public ToolOutput getOutputFromTool(String conditionName, ToolSession toolSession, Integer learnerId) throws ToolException;
-
+ public ToolOutput getOutputFromTool(String conditionName, ToolSession toolSession, Integer learnerId)
+ throws ToolException;
+
/**
- * Ask a tool for a set of ToolOutputs, based on the given toolSessionId.
+ * Ask a tool for a set of ToolOutputs, based on the given toolSessionId.
*
- * If conditionName array is null, then return all the outputs for the tool, otherwise just restrict the
- * outputs to the given list. If it is empty, then no outputs will be returned.
+ * If conditionName array is null, then return all the outputs for the tool, otherwise just restrict the outputs to
+ * the given list. If it is empty, then no outputs will be returned.
*
- * If the learnerId is null, then return the outputs based on all learners in that toolSession. If the
- * output is nonsense for all learners, then return an "empty" but valid answer. For example, for a mark
- * you might return 0.
+ * If the learnerId is null, then return the outputs based on all learners in that toolSession. If the output is
+ * nonsense for all learners, then return an "empty" but valid answer. For example, for a mark you might return 0.
*
- * If there isn't any content matching the toolSessionId then should return an "empty" but valid set of data. e.g
- * an empty mark would be 0.
+ * If there isn't any content matching the toolSessionId then should return an "empty" but valid set of data. e.g an
+ * empty mark would be 0.
*
* This functionality relies on a method added to the Tool Contract in LAMS 2.1.
*
- * @throws ToolException
+ * @throws ToolException
*/
- public SortedMap getOutputFromTool(List names, Long toolSessionId, Integer learnerId) throws ToolException;
-
+ public SortedMap getOutputFromTool(List names, Long toolSessionId, Integer learnerId)
+ throws ToolException;
+
/**
- * Ask a tool for a set of ToolOutputs, based on the given toolSessionId.
+ * Ask a tool for a set of ToolOutputs, based on the given toolSessionId.
*
- * If conditionName array is null, then return all the outputs for the tool, otherwise just restrict the
- * outputs to the given list. If it is empty, then no outputs will be returned.
+ * If conditionName array is null, then return all the outputs for the tool, otherwise just restrict the outputs to
+ * the given list. If it is empty, then no outputs will be returned.
*
- * If the learnerId is null, then return the outputs based on all learners in that toolSession. If the
- * output is nonsense for all learners, then return an "empty" but valid answer. For example, for a mark
- * you might return 0.
+ * If the learnerId is null, then return the outputs based on all learners in that toolSession. If the output is
+ * nonsense for all learners, then return an "empty" but valid answer. For example, for a mark you might return 0.
*
- * If there isn't any content matching the toolSessionId then should return an "empty" but valid set of data. e.g
- * an empty mark would be 0.
+ * If there isn't any content matching the toolSessionId then should return an "empty" but valid set of data. e.g an
+ * empty mark would be 0.
*
* This functionality relies on a method added to the Tool Contract in LAMS 2.1.
*
- * @throws ToolException
+ * @throws ToolException
*/
- public SortedMap getOutputFromTool(List names, ToolSession toolSession, Integer learnerId) throws ToolException;
+ public SortedMap getOutputFromTool(List names, ToolSession toolSession,
+ Integer learnerId) throws ToolException;
/**
* Update the tool session data.
- * @param toolSession the new tool session object.
+ *
+ * @param toolSession
+ * the new tool session object.
*/
public void updateToolSession(ToolSession toolSession);
/**
* Return tool activity url for a learner. See also getToolPreviewURL, getToolLearnerProgressURL
- * @param lesson id - needed for the SystemToolActivities
- * @param activity the requested activity - should be either a ToolActivity or a SystemToolActivity
- * @param learner the current learner.
+ *
+ * @param lesson
+ * id - needed for the SystemToolActivities
+ * @param activity
+ * the requested activity - should be either a ToolActivity or a SystemToolActivity
+ * @param learner
+ * the current learner.
* @return the tool access url with tool session id or activity id
*/
public String getToolLearnerURL(Long lessonID, Activity activity, User learner) throws LamsToolServiceException;
/**
- * Return tool activity url for running a tool in preview mode. See also getToolLearnerURL, getToolLearnerProgressURL
- * @param lesson id - needed for the SystemToolActivities
- * @param activity the requested activity - should be either a ToolActivity or a SystemToolActivity
- * @param learner the current learner.
+ * Return tool activity url for running a tool in preview mode. See also getToolLearnerURL,
+ * getToolLearnerProgressURL
+ *
+ * @param lesson
+ * id - needed for the SystemToolActivities
+ * @param activity
+ * the requested activity - should be either a ToolActivity or a SystemToolActivity
+ * @param learner
+ * the current learner.
* @return the tool access url with tool session id or activity id
*/
- public String getToolLearnerPreviewURL(Long lessonID, Activity activity, User learner) throws LamsToolServiceException;
+ public String getToolLearnerPreviewURL(Long lessonID, Activity activity, User learner)
+ throws LamsToolServiceException;
/**
* Return tool activity url for running a tool in preview mode. See also getToolLearnerURL, getToolPreviewURL
- * @param lesson id - needed for the SystemToolActivities
- * @param activity the requested activity - should be either a ToolActivity or a SystemToolActivity
- * @param learner the current learner.
+ *
+ * @param lesson
+ * id - needed for the SystemToolActivities
+ * @param activity
+ * the requested activity - should be either a ToolActivity or a SystemToolActivity
+ * @param learner
+ * the current learner.
* @return the tool access url with tool session id or activity id
*/
- public String getToolLearnerProgressURL(Long lessonID, Activity activity, User learner) throws LamsToolServiceException;
+ public String getToolLearnerProgressURL(Long lessonID, Activity activity, User learner)
+ throws LamsToolServiceException;
/**
- * Return tool activity url for monitoring.
- * @param lesson id - needed for the SystemToolActivities
- * @param activity the requested activity - should be either a ToolActivity or a SystemToolActivity
+ * Return tool activity url for monitoring.
+ *
+ * @param lesson
+ * id - needed for the SystemToolActivities
+ * @param activity
+ * the requested activity - should be either a ToolActivity or a SystemToolActivity
* @return the tool access url with tool session id or activity id
*/
public String getToolMonitoringURL(Long lessonID, Activity activity) throws LamsToolServiceException;
/**
* Return the contribution url for monitoring.
- * @param lesson id - needed for the SystemToolActivities
- * @param activity the requested activity - should be either a ToolActivity or a SystemToolActivity
+ *
+ * @param lesson
+ * id - needed for the SystemToolActivities
+ * @param activity
+ * the requested activity - should be either a ToolActivity or a SystemToolActivity
* @return the tool access url with tool session id or activity id
*/
public String getToolContributionURL(Long lessonID, Activity activity) throws LamsToolServiceException;
/**
- * Return the define later url for monitoring.
- * @param activity the requested activity - must be a a ToolActivity. System Activities don't support define later.
+ * Return the define later url for monitoring.
+ *
+ * @param activity
+ * the requested activity - must be a a ToolActivity. System Activities don't support define later.
* @return the tool access url with tool content id
*/
public String getToolDefineLaterURL(ToolActivity activity) throws LamsToolServiceException;
/**
- * Return the moderate url for monitoring.
- * @param activity the requested activity - must be a a ToolActivity. System Activities don't support moderation.
+ * Return the moderate url for monitoring.
+ *
+ * @param activity
+ * the requested activity - must be a a ToolActivity. System Activities don't support moderation.
* @return the tool access url with tool content id
*/
public String getToolModerateURL(ToolActivity activity) throws LamsToolServiceException;
/**
* Get all the tool sessions for a lesson. The resulting list is not sorted.
- * @return list of ToolSession objects
+ *
+ * @return list of ToolSession objects
*/
public List getToolSessionsByLesson(Lesson lesson);
-
-
+
/**
- * Delete a tool session. Calls the tool to delete its session details and then
- * deletes the main tool session record. If the tool throws an exception, the main
- * tool session record is still deleted.
+ * Delete a tool session. Calls the tool to delete its session details and then deletes the main tool session
+ * record. If the tool throws an exception, the main tool session record is still deleted.
*/
public void deleteToolSession(ToolSession toolSession);
/**
- * Setup target tool url with tool session id parameter based on the tool
- * activity and learner.
+ *
+ * Setup target tool url with tool session id parameter based on the tool activity and learner.
+ *
*
- * @param activity the activity that requested tool session belongs to.
- * @param learner the user who invloved the tool session.
- * @param toolURL the target url.
+ * @param activity
+ * the activity that requested tool session belongs to.
+ * @param learner
+ * the user who invloved the tool session.
+ * @param toolURL
+ * the target url.
* @throws LamsToolServiceException
* @return the url with tool session id.
*/
- public String setupToolURLWithToolSession(ToolActivity activity,User learner,String toolURL) throws LamsToolServiceException;
-
+ public String setupToolURLWithToolSession(ToolActivity activity, User learner, String toolURL)
+ throws LamsToolServiceException;
+
/**
- * Setup target tool url with tool content id parameter based on the tool
- * activity and learner.
- * @param activity the requested activity.
- * @param toolURL the target url
+ *
+ * Setup target tool url with tool content id parameter based on the tool activity and learner.
+ *
+ *
+ * @param activity
+ * the requested activity.
+ * @param toolURL
+ * the target url
* @return the url with tool content id.
*/
- public String setupToolURLWithToolContent(ToolActivity activity,String toolURL);
+ public String setupToolURLWithToolContent(ToolActivity activity, String toolURL);
+
+ public Object findToolService(Tool tool) throws NoSuchBeanDefinitionException;
}
Index: lams_common/src/java/org/lamsfoundation/lams/tool/service/LamsCoreToolService.java
===================================================================
diff -u -r1acf9b895293f09b11caf05e6f76d939be4010af -r542b83631b403e37429fce3bb928f2800c5cd9b8
--- lams_common/src/java/org/lamsfoundation/lams/tool/service/LamsCoreToolService.java (.../LamsCoreToolService.java) (revision 1acf9b895293f09b11caf05e6f76d939be4010af)
+++ lams_common/src/java/org/lamsfoundation/lams/tool/service/LamsCoreToolService.java (.../LamsCoreToolService.java) (revision 542b83631b403e37429fce3bb928f2800c5cd9b8)
@@ -779,7 +779,7 @@
* @throws NoSuchBeanDefinitionException
* if the tool is not the classpath or the supplied service name is wrong.
*/
- private Object findToolService(Tool tool) throws NoSuchBeanDefinitionException {
+ public Object findToolService(Tool tool) throws NoSuchBeanDefinitionException {
return context.getBean(tool.getServiceName());
}