From 0a1954b56d39e5a565315de55d9995b6fff2264f Mon Sep 17 00:00:00 2001
From: vkovtun <viktor.kovtun@id.ethz.ch>
Date: Tue, 30 Jan 2024 11:55:07 +0100
Subject: [PATCH] BIS-999: Fixing not fetched exception when exporting with
 levels below.

---
 .../v3/executor/exporter/EntitiesFinder.java  | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/server-application-server/source/java/ch/ethz/sis/openbis/generic/server/asapi/v3/executor/exporter/EntitiesFinder.java b/server-application-server/source/java/ch/ethz/sis/openbis/generic/server/asapi/v3/executor/exporter/EntitiesFinder.java
index b24ba3eed57..3ef57e9805b 100644
--- a/server-application-server/source/java/ch/ethz/sis/openbis/generic/server/asapi/v3/executor/exporter/EntitiesFinder.java
+++ b/server-application-server/source/java/ch/ethz/sis/openbis/generic/server/asapi/v3/executor/exporter/EntitiesFinder.java
@@ -213,23 +213,28 @@ class EntitiesFinder
         final List<SamplePermId> samplePermIds = permIds.stream().map(SamplePermId::new)
                 .collect(Collectors.toList());
         final SampleFetchOptions fetchOptions = new SampleFetchOptions();
+        configureFetchOptions(fetchOptions);
+        configureFetchOptions(fetchOptions.withParents());
+        configureFetchOptions(fetchOptions.withChildren());
+
+        final DataSetFetchOptions dataSetFetchOptions = fetchOptions.withDataSets();
+        configureFetchOptions(dataSetFetchOptions);
+
+        return api.getSamples(sessionToken, samplePermIds, fetchOptions).values();
+    }
+
+    private static void configureFetchOptions(final SampleFetchOptions fetchOptions)
+    {
         final ExperimentFetchOptions experimentFetchOptions = fetchOptions.withExperiment();
         experimentFetchOptions.withProperties();
         experimentFetchOptions.withProject().withSpace();
         fetchOptions.withSpace();
         fetchOptions.withProject().withSpace();
-        fetchOptions.withParents().withProperties();
-        fetchOptions.withChildren().withProperties();
         fetchOptions.withType().withPropertyAssignments().withPropertyType();
         fetchOptions.withProperties();
         fetchOptions.withRegistrator();
         fetchOptions.withModifier();
         fetchOptions.withContainer();
-
-        final DataSetFetchOptions dataSetFetchOptions = fetchOptions.withDataSets();
-        configureFetchOptions(dataSetFetchOptions);
-
-        return api.getSamples(sessionToken, samplePermIds, fetchOptions).values();
     }
 
     private static void configureFetchOptions(final DataSetFetchOptions dataSetFetchOptions)
-- 
GitLab