Index: lams_central/src/java/org/lamsfoundation/lams/authoring/ObjectExtractor.java =================================================================== RCS file: /usr/local/cvsroot/lams_central/src/java/org/lamsfoundation/lams/authoring/ObjectExtractor.java,v diff -u -r1.64 -r1.65 --- lams_central/src/java/org/lamsfoundation/lams/authoring/ObjectExtractor.java 23 Jan 2008 03:37:30 -0000 1.64 +++ lams_central/src/java/org/lamsfoundation/lams/authoring/ObjectExtractor.java 1 Feb 2008 06:24:36 -0000 1.65 @@ -149,8 +149,9 @@ protected HashMap groups = new HashMap(); protected HashMap branchEntries = new HashMap(); protected HashMap defaultActivityMap = new HashMap(); - /* can't delete as we go as they are linked to other items - keep a list and delete at the end. */ - protected Set groupingsToDelete = new HashSet(); + /* can't delete as we go as they are linked to other items and have no way of knowing from the packet which ones + * will need to be deleted, so start off assuming all need to be deleted and remove the ones we want to keep. */ + protected HashMap groupingsToDelete = new HashMap(); protected LearningDesign learningDesign = null; protected Date modificationDate = null; /* cache of system tools so we aren't going back to the db all the time */ @@ -448,6 +449,7 @@ while (iter.hasNext()) { Grouping grouping = (Grouping) iter.next(); groupings.put(grouping.getGroupingUIID(), grouping); + groupingsToDelete.put(grouping.getGroupingUIID(),grouping); } } @@ -474,7 +476,7 @@ /** Delete the old unneeded groupings. Won't be done via a cascade */ private void deleteUnwantedGroupings() { - for ( Grouping grouping: groupingsToDelete) { + for ( Grouping grouping: groupingsToDelete.values()) { groupingDAO.delete(grouping); } } @@ -555,13 +557,17 @@ } Grouping grouping = groupings.get(groupingUUID); - // check that the grouping type is still okay - if not get rid of the old hibernate object. - if ( grouping != null && ! grouping.getGroupingTypeId().equals(groupingTypeID) ) { - groupings.remove(grouping.getGroupingUIID()); - groupingsToDelete.add(grouping); - grouping = null; + // check that the grouping type is still okay - if it is we keep the grouping otherwise + // we get rid of the old hibernate object. + if ( grouping != null ) { + if ( grouping.getGroupingTypeId().equals(groupingTypeID) ) { + groupingsToDelete.remove(groupingUUID); + } else { + groupings.remove(grouping.getGroupingUIID()); + grouping = null; + } } - + if (grouping == null) { Object object = Grouping.getGroupingInstance(groupingTypeID); grouping = (Grouping)object;