From efeb25d8c117baee72cdece8d9ddd1e22b47952d Mon Sep 17 00:00:00 2001
From: gpawel <gpawel>
Date: Thu, 3 May 2012 09:52:02 +0000
Subject: [PATCH] bugfix: weird problem related to jython threading forces us
 to compile the re pattern on the script top level (it fails in function's
 body)

SVN: 25151
---
 plasmid/resource/jython-scripts/MP-plasmid_parents.py | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/plasmid/resource/jython-scripts/MP-plasmid_parents.py b/plasmid/resource/jython-scripts/MP-plasmid_parents.py
index c539c5286e9..935b0eaf9e7 100644
--- a/plasmid/resource/jython-scripts/MP-plasmid_parents.py
+++ b/plasmid/resource/jython-scripts/MP-plasmid_parents.py
@@ -27,6 +27,9 @@ INPUT_PATTERN = """
                  # no '$': allow whitespace at the end
 """
 
+""" due to some weird jython threading issue, we need to compile the pattern outside the function body """
+inputPattern = re.compile(INPUT_PATTERN, re.VERBOSE)
+
 """relationship types shortcuts"""
 
 DEL_REL_TYPE = 'DEL'
@@ -187,7 +190,6 @@ def updateFromBatchInput(bindings):
     elements = []
     input = bindings.get('')
     if input is not None:
-        inputPattern = re.compile(INPUT_PATTERN, re.VERBOSE)
         plasmids = input.split(',')
         for p in plasmids:
             (code, g, relationship, annotation) = _group(inputPattern, p.strip())
@@ -198,8 +200,10 @@ def updateFromBatchInput(bindings):
     if parentsInput is not None:
         parents = parentsInput.split(',')
         for parent in parents:
-            permId = entityInformationProvider().getSamplePermId(SPACE, parent)
+            permId = entityInformationProvider().getSamplePermId(SPACE, parent.strip())
             parentPlasmids = entityInformationProvider().getSamplePropertyValue(permId, 'PLASMIDS')
+            if parentPlasmids is None:
+                continue
             parentElements = list(propertyConverter().convertStringToElements(parentPlasmids))
             for parentLink in parentElements:
                 elements.append(parentLink)     
-- 
GitLab