From ebdb80b56d8569356c189d3cdffcf4e9d62964a3 Mon Sep 17 00:00:00 2001
From: juanf <juanf>
Date: Fri, 27 Feb 2015 15:17:24 +0000
Subject: [PATCH] SSDM-1564: PAPER - OPENBIS - Migration Support

SVN: 33534
---
 .../1/compatibility/managed.py                | 52 ++++++++++---------
 1 file changed, 27 insertions(+), 25 deletions(-)

diff --git a/plasmid/source/core-plugins/stellingmigration/1/compatibility/managed.py b/plasmid/source/core-plugins/stellingmigration/1/compatibility/managed.py
index f283dbee3db..fac8ecdc04c 100644
--- a/plasmid/source/core-plugins/stellingmigration/1/compatibility/managed.py
+++ b/plasmid/source/core-plugins/stellingmigration/1/compatibility/managed.py
@@ -196,7 +196,7 @@ def batchColumnNames():
     return allTypes
 
 def updateFromBatchInput(bindings):
-    #print "--------> UPDATE FROM BATCH INPUT: "
+    print "--------> UPDATE FROM BATCH INPUT: "
     elements = []
     
     #Links Configuration
@@ -206,10 +206,10 @@ def updateFromBatchInput(bindings):
                 
     for annotableSampleType in getAllAnnotableSampleTypesForType(annotableType):
         annotatedSamples = bindings.get(annotableSampleType)
-        #print "-----> TYPE: " + str(annotableSampleType) + " BINDINGS: " + str(annotatedSamples)
+        print "-----> TYPE: " + str(annotableSampleType) + " BINDINGS: " + str(annotatedSamples)
         if (annotatedSamples != None and annotatedSamples != ""):
             #Annotations
-            #print "-----> Annotations"
+            print "-----> Annotations"
             if annotableSampleType not in typesToCopyFrom:
                 for sampleLine in annotatedSamples.split("\\"):
                     propertyTypes = getPropertyTypesForSampleTypeFromAnnotableType(annotableSampleType, annotableType)
@@ -218,37 +218,39 @@ def updateFromBatchInput(bindings):
                     sampleLink = None
                     for sampleProperty in sampleLine.split(";"):
                         propertyName = sampleProperty.split(":")[0]
+                        propertyValue = sampleProperty.split(":")[1]
                         if propertyName == "identifier":
-                            propertyValue = sampleProperty.split(":")[1]
                             identifier = propertyValue
                             permId = entityInformationProvider().getSamplePermId(propertyValue)
                             sampleLink = elementFactory().createSampleLink(permId)
                             sampleLink.addAttribute(propertyName, propertyValue)
+                            sampleLink.addAttribute('sampleType', annotableSampleType)
                         elif propertyName in propertyTypes:
                             sampleLink.addAttribute(propertyName, propertyValue)
                         else:
                             raise NameError('Found invalid property: ' + propertyName + " on type " + annotableSampleType)
                     if identifier is not None:
                         elements.append(sampleLink)
-            #Links
-            #print "-----> links"
-            for typeToCopyFrom in typesToCopyFrom:
-                typeToCopy = typesToCopyFrom[typeToCopyFrom]
-                #print "-----> TYPE TO COPY FROM: " + str(typeToCopyFrom)
-                #print "-----> TYPE TO COPY: " + str(typeToCopy)
-                identifiersToCopyFrom = bindings.get(typeToCopyFrom)
-                if identifiersToCopyFrom is not None:
-                    #print "-----> IDENTIFIERS TO COPY FROM: " + str(identifiersToCopyFrom)
-                    identifiersForCopy = identifiersToCopyFrom.split(',')
-                    for identifierToCopyFrom in identifiersForCopy:
-                        #print "-----> IDENTIFIER TO COPY FROM: " + str(identifierToCopyFrom)
-                        permIdFromIdentifier = entityInformationProvider().getSamplePermId(identifierToCopyFrom)
-                        #print "-----> PERMID TO COPY FROM: " + str(permIdFromIdentifier)
-                        parentsToCopyFromPermId = entityInformationProvider().getSamplePropertyValue(permIdFromIdentifier, "ANNOTATIONS_STATE")
-                        #print "-----> ELEMENTS TO COPY: " + str(parentsToCopyFromPermId)
-                        parentElements = list(propertyConverter().convertStringToElements(parentsToCopyFromPermId))
-                        for parentAnnotation in parentElements:
-                            if parentAnnotation.getAttribute("sampleType") == typeToCopy:
-                                parentAnnotation.addAttribute("CONTAINED", identifierToCopyFrom)
-                                elements.append(parentAnnotation)
+    #Links
+    print "-----> links"
+    for typeToCopyFrom in typesToCopyFrom:
+        typeToCopy = typesToCopyFrom[typeToCopyFrom]
+        print "-----> TYPE TO COPY FROM: " + str(typeToCopyFrom)
+        print "-----> TYPE TO COPY: " + str(typeToCopy)
+        identifiersToCopyFrom = bindings.get(typeToCopyFrom)
+        if identifiersToCopyFrom is not None:
+            print "-----> IDENTIFIERS TO COPY FROM: " + str(identifiersToCopyFrom)
+            identifiersForCopy = identifiersToCopyFrom.split(',')
+            for identifierToCopyFrom in identifiersForCopy:
+                print "-----> IDENTIFIER TO COPY FROM: " + str(identifierToCopyFrom)
+                permIdFromIdentifier = entityInformationProvider().getSamplePermId(identifierToCopyFrom)
+                #print "-----> PERMID TO COPY FROM: " + str(permIdFromIdentifier)
+                parentsToCopyFromPermId = entityInformationProvider().getSamplePropertyValue(permIdFromIdentifier, "ANNOTATIONS_STATE")
+                print "-----> ELEMENTS TO COPY: " + str(parentsToCopyFromPermId)
+                parentElements = list(propertyConverter().convertStringToElements(parentsToCopyFromPermId))
+                for parentAnnotation in parentElements:
+                    if parentAnnotation.getAttribute("sampleType") == typeToCopy:
+                        parentAnnotation.addAttribute("CONTAINED", identifierToCopyFrom)
+                        print "-----> COPYING: " + str(parentAnnotation.getAttribute('identifier'))
+                        elements.append(parentAnnotation)
     property.value = propertyConverter().convertToString(elements)
\ No newline at end of file
-- 
GitLab