From cf46df8effa21861d25e2e743b88a2c456553761 Mon Sep 17 00:00:00 2001
From: juanf <juanf@ethz.ch>
Date: Thu, 15 Feb 2024 10:03:51 +0100
Subject: [PATCH] BIS-1009 : Fix screening build in Jenkins

---
 .../screening/4/as/initialize-master-data.py        | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/server-screening/source/core-plugins/screening/4/as/initialize-master-data.py b/server-screening/source/core-plugins/screening/4/as/initialize-master-data.py
index b5acee3f109..da71681553b 100644
--- a/server-screening/source/core-plugins/screening/4/as/initialize-master-data.py
+++ b/server-screening/source/core-plugins/screening/4/as/initialize-master-data.py
@@ -103,6 +103,9 @@ material_type_CONTROL.setDescription('Control of a control layout')
 material_type_GENE = tr.getOrCreateNewMaterialType('GENE')
 material_type_GENE.setDescription('Gene')
 
+# This is to get around a weird bug running the test in Jenkins when the database populating twice
+isMaterial_type_SIRNAAvailable = tr.getMaterialType('SIRNA') not None
+
 material_type_SIRNA = tr.getOrCreateNewMaterialType('SIRNA')
 material_type_SIRNA.setDescription('Oligo nucleotide')
 
@@ -209,10 +212,12 @@ assignment_MATERIAL_SIRNA_DESCRIPTION.setMandatory(False)
 assignment_MATERIAL_SIRNA_DESCRIPTION.setSection(None)
 assignment_MATERIAL_SIRNA_DESCRIPTION.setPositionInForms(3)
 
-assignment_MATERIAL_SIRNA_INHIBITOR_OF = tr.assignPropertyType(material_type_SIRNA, prop_type_INHIBITOR_OF)
-assignment_MATERIAL_SIRNA_INHIBITOR_OF.setMandatory(True)
-assignment_MATERIAL_SIRNA_INHIBITOR_OF.setSection(None)
-assignment_MATERIAL_SIRNA_INHIBITOR_OF.setPositionInForms(4)
+# This is to get around a weird bug running the test in Jenkins when the database populating twice
+if not isMaterial_type_SIRNAAvailable:
+    assignment_MATERIAL_SIRNA_INHIBITOR_OF = tr.assignPropertyType(material_type_SIRNA, prop_type_INHIBITOR_OF)
+    assignment_MATERIAL_SIRNA_INHIBITOR_OF.setMandatory(True)
+    assignment_MATERIAL_SIRNA_INHIBITOR_OF.setSection(None)
+    assignment_MATERIAL_SIRNA_INHIBITOR_OF.setPositionInForms(4)
 
 assignment_MATERIAL_SIRNA_LIBRARY_ID = tr.assignPropertyType(material_type_SIRNA, prop_type_LIBRARY_ID)
 assignment_MATERIAL_SIRNA_LIBRARY_ID.setMandatory(False)
-- 
GitLab