From fd76de441f261296232d95dc6a396eea0d796506 Mon Sep 17 00:00:00 2001
From: anttil <anttil>
Date: Mon, 16 Jul 2012 07:01:21 +0000
Subject: [PATCH] Bugfix: Consistent creation of dataset parent-child
 relationships.

SVN: 26118
---
 .../generic/server/RelationshipService.java        |  4 +++-
 .../matcher/ExternalDataHasChildrenMatcher.java    | 14 ++++++++------
 2 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/RelationshipService.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/RelationshipService.java
index 3f9a7ff90a4..377a6cea587 100644
--- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/RelationshipService.java
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/RelationshipService.java
@@ -169,7 +169,9 @@ public class RelationshipService implements IRelationshipService
     public void addParentToDataSet(IAuthSession session, DataPE data, DataPE parent)
     {
         PersonPE actor = session.tryGetPerson();
-        data.addParentRelationship(new DataSetRelationshipPE(parent, data, actor));
+        DataSetRelationshipPE relationship = new DataSetRelationshipPE(parent, data, actor);
+        data.addParentRelationship(relationship);
+        parent.addChildRelationship(relationship);
     }
 
     @Override
diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/base/matcher/ExternalDataHasChildrenMatcher.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/base/matcher/ExternalDataHasChildrenMatcher.java
index 6aff0161d2e..00de6c0d555 100644
--- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/base/matcher/ExternalDataHasChildrenMatcher.java
+++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/base/matcher/ExternalDataHasChildrenMatcher.java
@@ -16,7 +16,6 @@
 
 package ch.systemsx.cisd.openbis.systemtest.base.matcher;
 
-import java.util.Arrays;
 import java.util.HashSet;
 import java.util.Set;
 
@@ -28,13 +27,16 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ExternalData;
 public class ExternalDataHasChildrenMatcher extends TypeSafeMatcher<ExternalData>
 {
 
-    private Set<ExternalData> expectedChildren;
+    private Set<String> expectedChildren;
 
     public ExternalDataHasChildrenMatcher(ExternalData first, ExternalData... rest)
     {
-        this.expectedChildren = new HashSet<ExternalData>();
-        expectedChildren.add(first);
-        expectedChildren.addAll(Arrays.asList(rest));
+        this.expectedChildren = new HashSet<String>();
+        expectedChildren.add(first.getCode());
+        for (ExternalData d : rest)
+        {
+            expectedChildren.add(d.getCode());
+        }
     }
 
     @Override
@@ -53,7 +55,7 @@ public class ExternalDataHasChildrenMatcher extends TypeSafeMatcher<ExternalData
 
         for (ExternalData child : actual.getChildren())
         {
-            if (!expectedChildren.contains(child))
+            if (expectedChildren.contains(child.getCode()) == false)
             {
                 return false;
             }
-- 
GitLab