From 4ebccdcedb69caffd8608650eb826aeb1ecdce48 Mon Sep 17 00:00:00 2001 From: labkey-jeckels Date: Sun, 13 Sep 2026 11:50:30 -0700 Subject: [PATCH 1/2] Docs and more --- .../test/util/exp/SampleTypeAPIHelper.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/org/labkey/test/util/exp/SampleTypeAPIHelper.java b/src/org/labkey/test/util/exp/SampleTypeAPIHelper.java index 45c1d4d649..5de3a606ab 100644 --- a/src/org/labkey/test/util/exp/SampleTypeAPIHelper.java +++ b/src/org/labkey/test/util/exp/SampleTypeAPIHelper.java @@ -19,6 +19,7 @@ import org.junit.Assert; import org.labkey.remoteapi.CommandException; import org.labkey.remoteapi.Connection; +import org.labkey.remoteapi.query.ContainerFilter; import org.labkey.remoteapi.query.Filter; import org.labkey.remoteapi.query.SelectRowsCommand; import org.labkey.remoteapi.query.SelectRowsResponse; @@ -201,6 +202,27 @@ public static Map getRowIdsForSamples(String containerPath, Str return rowIds; } + /** + * Row ids of every sample type named {@code sampleTypeName} that is visible from {@code containerPath}, in the + * CurrentPlusProjectAndShared scope a sample type lookup resolves against. + * + *

Manufacturing a rowId/name collision needs the id the server actually assigned, because + * {@code exp.MaterialSource.RowId} is a database-wide sequence: a hardcoded numeric sample type name collides +fix 2, 6, 7 * only when the sequence happens to cooperate. Require exactly one match as well, since a resolver reports an + * ambiguity rather than picking, and that error is swallowed by the import code. + */ + public static List getSampleTypeRowIds(String containerPath, String sampleTypeName) throws IOException, CommandException + { + SelectRowsCommand cmd = new SelectRowsCommand("exp", "SampleSets"); + cmd.setColumns(List.of("RowId")); + cmd.addFilter("Name", sampleTypeName, Filter.Operator.EQUAL); + cmd.setContainerFilter(ContainerFilter.CurrentPlusProjectAndShared); + + return cmd.execute(WebTestHelper.getRemoteApiConnection(), containerPath).getRows().stream() + .map(row -> Integer.parseInt(row.get("RowId").toString())) + .toList(); + } + /** * Get sample state IDs defined in the specified project/folder. Useful for updating sample status via API * @param containerPath Path to the project/folder where the sample statuses are defined (typically project) From d44032fffefb57156c41540fc146ad83083b20f0 Mon Sep 17 00:00:00 2001 From: labkey-jeckels Date: Mon, 14 Sep 2026 11:57:52 -0700 Subject: [PATCH 2/2] Fix stray text --- src/org/labkey/test/util/exp/SampleTypeAPIHelper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/org/labkey/test/util/exp/SampleTypeAPIHelper.java b/src/org/labkey/test/util/exp/SampleTypeAPIHelper.java index 5de3a606ab..552b66b483 100644 --- a/src/org/labkey/test/util/exp/SampleTypeAPIHelper.java +++ b/src/org/labkey/test/util/exp/SampleTypeAPIHelper.java @@ -208,7 +208,7 @@ public static Map getRowIdsForSamples(String containerPath, Str * *

Manufacturing a rowId/name collision needs the id the server actually assigned, because * {@code exp.MaterialSource.RowId} is a database-wide sequence: a hardcoded numeric sample type name collides -fix 2, 6, 7 * only when the sequence happens to cooperate. Require exactly one match as well, since a resolver reports an + * only when the sequence happens to cooperate. Require exactly one match as well, since a resolver reports an * ambiguity rather than picking, and that error is swallowed by the import code. */ public static List getSampleTypeRowIds(String containerPath, String sampleTypeName) throws IOException, CommandException