Index: lams_common/conf/hibernate/mappings/org/lamsfoundation/lams/tool/Tool.hbm.xml
===================================================================
RCS file: /usr/local/cvsroot/lams_common/conf/hibernate/mappings/org/lamsfoundation/lams/tool/Tool.hbm.xml,v
diff -u -r1.17 -r1.18
--- lams_common/conf/hibernate/mappings/org/lamsfoundation/lams/tool/Tool.hbm.xml 5 May 2014 11:14:56 -0000 1.17
+++ lams_common/conf/hibernate/mappings/org/lamsfoundation/lams/tool/Tool.hbm.xml 23 Oct 2014 11:55:10 -0000 1.18
@@ -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
===================================================================
RCS file: /usr/local/cvsroot/lams_common/src/java/org/lamsfoundation/lams/tool/Tool.java,v
diff -u -r1.28 -r1.29
--- lams_common/src/java/org/lamsfoundation/lams/tool/Tool.java 5 May 2014 11:14:56 -0000 1.28
+++ lams_common/src/java/org/lamsfoundation/lams/tool/Tool.java 23 Oct 2014 11:55:10 -0000 1.29
@@ -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;
}