From f2f07e17a2330aa00db345a0f552649c3637cede Mon Sep 17 00:00:00 2001
From: felmer <franz-josef.elmer@id.ethz.ch>
Date: Wed, 8 Mar 2023 15:54:13 +0100
Subject: [PATCH] SSDM-12929: Resolver for flow experiments with plates adapted

---
 .../eln-tree/resolver-plugins/flow.py         | 30 ++++++++++++++++++-
 .../file-system-plugins/eln-tree/script.py    |  2 ++
 2 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/ui-eln-lims/src/core-plugins/eln-lims/1/dss/file-system-plugins/eln-tree/resolver-plugins/flow.py b/ui-eln-lims/src/core-plugins/eln-lims/1/dss/file-system-plugins/eln-tree/resolver-plugins/flow.py
index 0df6ce62396..40f7509e0fe 100644
--- a/ui-eln-lims/src/core-plugins/eln-lims/1/dss/file-system-plugins/eln-tree/resolver-plugins/flow.py
+++ b/ui-eln-lims/src/core-plugins/eln-lims/1/dss/file-system-plugins/eln-tree/resolver-plugins/flow.py
@@ -21,6 +21,34 @@ def addSampleChildNodes(path, samplePermId, sampleType, response, acceptor, cont
             contentNode = content.getRootNode()
             script.addDataSetFileNodes(path, dataSetCode, contentNode, response, acceptor, context)
 
-for t in ["FACS_ARIA", "INFLUX", "LSR_FORTESSA", "CYTOFLEX_S", "MOFLO_XDP", "S3E", "SONY_SH800S", "SONY_MA900"]:
+def addSampleChildNodesWithPlates(path, samplePermId, sampleType, response, acceptor, context):
+    dataSetSearchCriteria = DataSetSearchCriteria()
+    dataSetSearchCriteria.withOrOperator()
+    dataSetSearchCriteria.withSample().withPermId().thatEquals(samplePermId)
+    parentsSearchCriteria = dataSetSearchCriteria.withSample().withParents()
+    parentsSearchCriteria.withPermId().thatEquals(samplePermId)
+    fetchOptions = DataSetFetchOptions()
+    fetchOptions.withType()
+    fetchOptions.withProperties()
+    fetchOptions.withSample().withType()
+    dataSets = context.getApi().searchDataSets(context.getSessionToken(), dataSetSearchCriteria, fetchOptions).getObjects()
+    for dataSet in dataSets:
+        sampleTypeCode = dataSet.getSample().getType().getCode()
+        if not sampleTypeCode.endswith("_WELL"):
+            dataSetCode = dataSet.getCode()
+            content = context.getContentProvider().asContent(dataSetCode)
+            contentNode = content.getRootNode()
+            script.addDataSetFileNodes(path, dataSetCode, contentNode, response, acceptor, context)
+    script.addSampleSampleChildNodes(path, samplePermId, response, acceptor, context)
+
+for t in ["FACS_ARIA", "INFLUX", "MOFLO_XDP", "S3E", "SONY_SH800S", "SONY_MA900"]:
     acceptor.hideSampleType("%s_SPECIMEN" % t)
     acceptor.sampleChildrenHandlers["%s_EXPERIMENT" % t] = addSampleChildNodes
+
+for t in ["LSR_FORTESSA", "CYTOFLEX_S"]:
+    acceptor.hideSampleType("%s_SPECIMEN" % t)
+    acceptor.hideSampleType("%s_WELL" % t)
+    acceptor.hideSampleType("%s_TUBE" % t)
+    acceptor.hideSampleType("%s_TUBESET" % t)
+    acceptor.sampleChildrenHandlers["%s_EXPERIMENT" % t] = addSampleChildNodesWithPlates
+    acceptor.sampleChildrenHandlers["%s_PLATE" % t] = addSampleChildNodes
diff --git a/ui-eln-lims/src/core-plugins/eln-lims/1/dss/file-system-plugins/eln-tree/script.py b/ui-eln-lims/src/core-plugins/eln-lims/1/dss/file-system-plugins/eln-tree/script.py
index e530f7af482..8909b6834b1 100644
--- a/ui-eln-lims/src/core-plugins/eln-lims/1/dss/file-system-plugins/eln-tree/script.py
+++ b/ui-eln-lims/src/core-plugins/eln-lims/1/dss/file-system-plugins/eln-tree/script.py
@@ -315,7 +315,9 @@ def addSampleChildNodes(path, samplePermId, sampleType, response, acceptor, cont
     dataSetSearchCriteria.withSample().withPermId().thatEquals(samplePermId)
 
     listDataSets(path, dataSetSearchCriteria, True, response, acceptor, context)
+    addSampleSampleChildNodes(path, samplePermId, response, acceptor, context)
 
+def addSampleSampleChildNodes(path, samplePermId, response, acceptor, context):
     fetchOptions = SampleFetchOptions()
     fetchOptions.withExperiment()
     fetchOptions.withChildren().withType()
-- 
GitLab