Index: lams_common/conf/hibernate/mappings/org/lamsfoundation/lams/tool/Tool.hbm.xml
===================================================================
diff -u -rc7798d2b81a0595194a5e905ef6c33e372ad8007 -r08975c671d19a7f4ee7351a38eaed88c8602d0c3
--- lams_common/conf/hibernate/mappings/org/lamsfoundation/lams/tool/Tool.hbm.xml (.../Tool.hbm.xml) (revision c7798d2b81a0595194a5e905ef6c33e372ad8007)
+++ lams_common/conf/hibernate/mappings/org/lamsfoundation/lams/tool/Tool.hbm.xml (.../Tool.hbm.xml) (revision 08975c671d19a7f4ee7351a38eaed88c8602d0c3)
@@ -68,6 +68,13 @@
+
+ removedActMap = new HashMap();
List activities = ldDto.getActivities();
for (AuthoringActivityDTO activity : activities) {
- fillLearningLibraryID(activity);
// skip non-tool activities
if (!activity.getActivityTypeID().equals(Activity.TOOL_ACTIVITY_TYPE)) {
+ fillLearningLibraryID(activity);
continue;
}
@@ -1394,6 +1394,10 @@
removedActMap.put(activity.getActivityID(), activity);
continue;
}
+
+ // imported Learning Library ID and one stored in current DB may not match, so fix it here
+ activity.setLearningLibraryID(newTool.getLearningLibraryId());
+
// save Tool into lams_tool table.
ToolContent newContent = new ToolContent(newTool);
toolContentDAO.saveToolContent(newContent);
@@ -2620,33 +2624,28 @@
act.setStartYcoord(actDto.getStartYCoord());
act.setEndYcoord(actDto.getEndYCoord());
}
-
+
/**
- * Guess missing Learning Library ID based on activity tool ID or description. Old exported LDs may not contain this
- * value.
+ * Guess missing Learning Library ID based on activity description. Old exported LDs may not contain this value.
*/
- @SuppressWarnings("unchecked")
private void fillLearningLibraryID(AuthoringActivityDTO activity) {
- if (activity.getLearningLibraryID() == null) {
- if (activity.getActivityTypeID().equals(Activity.TOOL_ACTIVITY_TYPE)) {
- activity.setLearningLibraryID(activity.getToolID());
- } else if (activity.getActivityTypeID().equals(Activity.PARALLEL_ACTIVITY_TYPE)) {
- String description = activity.getDescription();
- // recognise learning libraries by their word description
- for (LearningLibrary library : (List) learningLibraryDAO.getAllLearningLibraries()) {
- for (String[] keyWords : COMPLEX_LEARNING_LIBRARY_KEY_WORDS) {
- boolean found = false;
- for (String keyWord : keyWords) {
- found = description.contains(keyWord) && library.getDescription().contains(keyWord);
- if (!found) {
- break;
- }
+ if (activity.getLearningLibraryID() == null
+ && activity.getActivityTypeID().equals(Activity.PARALLEL_ACTIVITY_TYPE)) {
+ String description = activity.getDescription();
+ // recognise learning libraries by their word description
+ for (LearningLibrary library : (List) learningLibraryDAO.getAllLearningLibraries()) {
+ for (String[] keyWords : COMPLEX_LEARNING_LIBRARY_KEY_WORDS) {
+ boolean found = false;
+ for (String keyWord : keyWords) {
+ found = description.contains(keyWord) && library.getDescription().contains(keyWord);
+ if (!found) {
+ break;
}
- if (found) {
- activity.setLearningLibraryID(library.getLearningLibraryId());
- return;
- }
}
+ if (found) {
+ activity.setLearningLibraryID(library.getLearningLibraryId());
+ return;
+ }
}
}
}
Index: lams_common/src/java/org/lamsfoundation/lams/tool/Tool.java
===================================================================
diff -u -r279ab8b6c6d02f80bb949e44011343f6c7150f6e -r08975c671d19a7f4ee7351a38eaed88c8602d0c3
--- lams_common/src/java/org/lamsfoundation/lams/tool/Tool.java (.../Tool.java) (revision 279ab8b6c6d02f80bb949e44011343f6c7150f6e)
+++ lams_common/src/java/org/lamsfoundation/lams/tool/Tool.java (.../Tool.java) (revision 08975c671d19a7f4ee7351a38eaed88c8602d0c3)
@@ -107,7 +107,11 @@
/** persistent field */
private String toolVersion;
+
+ /** persistent field */
+ private Long learningLibraryId;
+
/**
* Name of the file (including the package) that contains the text strings for this activity. e.g.
* org.lamsfoundation.lams.tool.sbmt.SbmtResources.properties.
@@ -395,7 +399,15 @@
public void setToolVersion(String toolVersion) {
this.toolVersion = toolVersion;
}
+
+ public Long getLearningLibraryId() {
+ return learningLibraryId;
+ }
+ public void setLearningLibraryId(Long learningLibraryId) {
+ this.learningLibraryId = learningLibraryId;
+ }
+
public String getLanguageFile() {
return languageFile;
}