Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/Group.java =================================================================== RCS file: /usr/local/cvsroot/lams_common/src/java/org/lamsfoundation/lams/learningdesign/Group.java,v diff -u -r1.24 -r1.25 --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/Group.java 9 Apr 2008 03:14:39 -0000 1.24 +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/Group.java 27 May 2008 02:32:41 -0000 1.25 @@ -374,18 +374,12 @@ return entry; } - /** Remove the branch with which this group is associated. + /** + * Remove the branch with which this group is associated. + * Actually calls the SequenceActivity to do the removal as it is the SequenceActivity that has the hibernate cascade. + * So its the activity that must be saved, not the group. Method left here to make it easier to find. */ public void removeGroupFromBranch(SequenceActivity branch) { - if ( getBranchActivities() != null ) { - Iterator iter = getBranchActivities().iterator(); - while (iter.hasNext()) { - BranchActivityEntry object = (BranchActivityEntry) iter.next(); - if ( object.getBranchSequenceActivity().equals(branch) ) { - iter.remove(); - } - } - } - // branch.getGroupsForBranch().remove(this); + branch.removeGroupFromBranch(this); } } Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/SequenceActivity.java =================================================================== RCS file: /usr/local/cvsroot/lams_common/src/java/org/lamsfoundation/lams/learningdesign/SequenceActivity.java,v diff -u -r1.41 -r1.42 --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/SequenceActivity.java 31 Jan 2008 04:41:32 -0000 1.41 +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/SequenceActivity.java 27 May 2008 02:32:40 -0000 1.42 @@ -260,5 +260,21 @@ return listOfValidationErrors; } + /** + * Remove the entry mapping the given group to this branch. + * Need to remove it from the branch end, as it is the branch end that + * has the all-delete-orphan cascade (LDEV-1766) + */ + public void removeGroupFromBranch(Group group) { + if ( getBranchEntries() != null ) { + Iterator iter = getBranchEntries().iterator(); + while (iter.hasNext()) { + BranchActivityEntry object = (BranchActivityEntry) iter.next(); + if ( object.getGroup().equals(group) ) { + iter.remove(); + } + } + } + } }