From 57de8145f34510aa0aa7a90f62e37be651e5538f Mon Sep 17 00:00:00 2001 From: mkslofstra Date: Fri, 3 May 2024 13:51:21 +0200 Subject: [PATCH] fix(info endpoint): returns number of columns in source table rather than link file --- .../org/molgenis/armadillo/storage/ArmadilloLinkFile.java | 4 ++++ .../org/molgenis/armadillo/storage/LocalStorageService.java | 2 +- .../molgenis/armadillo/storage/ArmadilloLinkFileTest.java | 6 ++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/armadillo/src/main/java/org/molgenis/armadillo/storage/ArmadilloLinkFile.java b/armadillo/src/main/java/org/molgenis/armadillo/storage/ArmadilloLinkFile.java index 79f3ccefc..7de019254 100644 --- a/armadillo/src/main/java/org/molgenis/armadillo/storage/ArmadilloLinkFile.java +++ b/armadillo/src/main/java/org/molgenis/armadillo/storage/ArmadilloLinkFile.java @@ -118,6 +118,10 @@ public String getProject() { return this.project; } + public Integer getNumberOfVariables() { + return getVariables().split(",").length; + } + public JsonObject loadFromStream(InputStream inputStream) { return JsonParser.parseReader(new InputStreamReader(inputStream)).getAsJsonObject(); } diff --git a/armadillo/src/main/java/org/molgenis/armadillo/storage/LocalStorageService.java b/armadillo/src/main/java/org/molgenis/armadillo/storage/LocalStorageService.java index f28ef28c1..60af3415f 100644 --- a/armadillo/src/main/java/org/molgenis/armadillo/storage/LocalStorageService.java +++ b/armadillo/src/main/java/org/molgenis/armadillo/storage/LocalStorageService.java @@ -219,7 +219,7 @@ private FileInfo getFileInfoForLinkFile( objectName, fileSizeWithUnit, tableDimensions.get("rows"), - tableDimensions.get("columns"), + String.valueOf(linkFile.getNumberOfVariables()), linkFile.getSourceProject() + "/" + linkFile.getSourceObject(), linkFile.getVariables().split(",")); } diff --git a/armadillo/src/test/java/org/molgenis/armadillo/storage/ArmadilloLinkFileTest.java b/armadillo/src/test/java/org/molgenis/armadillo/storage/ArmadilloLinkFileTest.java index eb01ec57d..deb20698f 100644 --- a/armadillo/src/test/java/org/molgenis/armadillo/storage/ArmadilloLinkFileTest.java +++ b/armadillo/src/test/java/org/molgenis/armadillo/storage/ArmadilloLinkFileTest.java @@ -40,6 +40,12 @@ public void testGetFileName() { assertEquals("folder/link-obj.alf", actual); } + @Test + public void testGetNumberOfVariables() { + Integer actual = alf.getNumberOfVariables(); + assertEquals(3, actual); + } + @Test public void testLoadFromStream() { InputStream inputStream = new ByteArrayInputStream(testData.getBytes());