From efceb4b82217977893c46cdcd60be85878ee9ac2 Mon Sep 17 00:00:00 2001
From: juanf <juanf>
Date: Wed, 4 Feb 2015 15:52:05 +0000
Subject: [PATCH] SSDM-1070 : PAPER - OPENBIS - Migrate Manage Properties
 YeastLab (Configurable)

SVN: 33392
---
 .../drop-boxes/stellingmigration/managed.py   |  4 +++
 .../drop-boxes/stellingmigration/migration.py | 36 ++++++++++++-------
 2 files changed, 27 insertions(+), 13 deletions(-)

diff --git a/plasmid/source/core-plugins/stellingmigration/1/dss/drop-boxes/stellingmigration/managed.py b/plasmid/source/core-plugins/stellingmigration/1/dss/drop-boxes/stellingmigration/managed.py
index 0fc50a64e4d..1a993a1bc76 100644
--- a/plasmid/source/core-plugins/stellingmigration/1/dss/drop-boxes/stellingmigration/managed.py
+++ b/plasmid/source/core-plugins/stellingmigration/1/dss/drop-boxes/stellingmigration/managed.py
@@ -26,6 +26,10 @@ configuration["PCR"] = {
                           "ENZYMES" : {"NAME" : False }
                          };
 
+configuration["POMBE"] = {
+                          "PLASMIDS" : {"RELATIONSHIP" : False, "ANNOTATION" : False }
+                         };
+
 #Global Variables
 annotableType = "<REPLACE_WITH_ANNOTABLE_TYPE>"
 server = CommonServiceProvider.getCommonServer()
diff --git a/plasmid/source/core-plugins/stellingmigration/1/dss/drop-boxes/stellingmigration/migration.py b/plasmid/source/core-plugins/stellingmigration/1/dss/drop-boxes/stellingmigration/migration.py
index aeff2ca7997..7b12048b2e6 100644
--- a/plasmid/source/core-plugins/stellingmigration/1/dss/drop-boxes/stellingmigration/migration.py
+++ b/plasmid/source/core-plugins/stellingmigration/1/dss/drop-boxes/stellingmigration/migration.py
@@ -55,6 +55,13 @@ definitions = {
                                      "ENZYMES" : {
                                                     "name" : "NAME"
                                                     }
+                                    },
+               "POMBE" : 
+                                    { 
+                                     "PLASMIDS" : {
+                                                    "rel" : "RELATIONSHIP",
+                                                    "annotation" : "ANNOTATION"
+                                                    }
                                     }
 };
 
@@ -101,22 +108,25 @@ def translate(tr, sample, properties):
             if '<root>' in propertyValue:
                 oldAnnotationsRoot = ET.fromstring(propertyValue)
         except Exception:
-            print "Exception on " + sample.code + " " + property
+            print "[ERROR - PROCESSING PROPERTY_CODE] " + sample.code + " " + property
         
         if oldAnnotationsRoot is not None:
             for child in oldAnnotationsRoot:
-                    newAnnotationsNode = ET.SubElement(newAnnotationsRoot, "Sample")
-                    permId = child.attrib["permId"]
-                    print sample.code + " " + permId
-                    newAnnotationsNode.attrib["permId"] = permId
-                    linkedSample = getSampleByPermId(tr, permId)
-                    newAnnotationsNode.attrib["identifier"] = linkedSample.getSampleIdentifier()
-                    
-                    for oldName in propertyDefinitions:
-                        newName = propertyDefinitions[oldName]
-                        value = getValueOrNull(child.attrib, oldName)
-                        if(value is not None):
-                            newAnnotationsNode.attrib[newName] = value
+                    try:
+                        newAnnotationsNode = ET.SubElement(newAnnotationsRoot, "Sample")
+                        permId = child.attrib["permId"]
+                        print "[INFO - PROCESSING PERM_ID] " + sample.code + " " + permId
+                        newAnnotationsNode.attrib["permId"] = permId
+                        linkedSample = getSampleByPermId(tr, permId)
+                        newAnnotationsNode.attrib["identifier"] = linkedSample.getSampleIdentifier()
+                        
+                        for oldName in propertyDefinitions:
+                            newName = propertyDefinitions[oldName]
+                            value = getValueOrNull(child.attrib, oldName)
+                            if(value is not None):
+                                newAnnotationsNode.attrib[newName] = value
+                    except Exception:
+                        print "[ERROR - PROCESSING PERM_ID] " + sample.code + " " + permId
     save(tr, sample, "ANNOTATIONS_STATE", ET.tostring(newAnnotationsRoot, encoding='utf-8'))
 
 def save(tr, sample, property, propertyValue):
-- 
GitLab