From 0d628bdf2150d03d8734e8f2bc47b6e08758b76b Mon Sep 17 00:00:00 2001
From: anttil <anttil>
Date: Tue, 3 Jul 2012 08:31:58 +0000
Subject: [PATCH] BIS-51 / SP-139: Bugfix: Unnecessary calls to
 RelationshipService.assignSampleToContainer() and
 RelationshipService.removeSampleFromContainer()

SVN: 25983
---
 .../business/bo/AbstractSampleBusinessObject.java      | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/AbstractSampleBusinessObject.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/AbstractSampleBusinessObject.java
index 1d19a61716c..50dc030cfca 100644
--- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/AbstractSampleBusinessObject.java
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/AbstractSampleBusinessObject.java
@@ -210,6 +210,16 @@ abstract class AbstractSampleBusinessObject extends AbstractSampleIdentifierBusi
         final SamplePE containerPE =
                 tryGetValidNotContainedSample(containerIdentifier, sampleIdentifier, defaultSpace);
 
+        if (samplePE.getContainer() == null && containerPE == null)
+        {
+            return;
+        }
+
+        if (samplePE.getContainer() != null && samplePE.getContainer().equals(containerPE))
+        {
+            return;
+        }
+
         if (containerPE == null)
         {
             relationshipService.removeSampleFromContainer(session, IdentifierHelper
-- 
GitLab