From 7304fdfe4b5901dedd0cfa29a3bc5fcdf7451cf2 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Thu, 3 Oct 2024 14:43:05 +0200 Subject: [PATCH] correct issue with old ids --- .../description/ModelDescriptorV04.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/main/java/io/bioimage/modelrunner/bioimageio/description/ModelDescriptorV04.java b/src/main/java/io/bioimage/modelrunner/bioimageio/description/ModelDescriptorV04.java index d29127e1..8a9ee23a 100644 --- a/src/main/java/io/bioimage/modelrunner/bioimageio/description/ModelDescriptorV04.java +++ b/src/main/java/io/bioimage/modelrunner/bioimageio/description/ModelDescriptorV04.java @@ -263,7 +263,8 @@ private void addBioEngine() throws ModelSpecsException { } } - private static String findID(Map yamlElements) { + @SuppressWarnings("unchecked") + private static String findID(Map yamlElements) { if (yamlElements.get("config") != null && yamlElements.get("config") instanceof Map) { Map configMap = (Map) yamlElements.get("config"); @@ -276,7 +277,8 @@ private static String findID(Map yamlElements) { return (String) yamlElements.get("id"); } - private static String findOldID(Map yamlElements) { + @SuppressWarnings("unchecked") + private static String findOldID(Map yamlElements) { if (yamlElements.get("config") != null && yamlElements.get("config") instanceof Map) { Map configMap = (Map) yamlElements.get("config"); @@ -284,7 +286,15 @@ private static String findOldID(Map yamlElements) { return (String) configMap.get("_conceptdoi"); } } - return (String) yamlElements.get("id"); + if (yamlElements.get("id") != null && yamlElements.get("id") instanceof String) { + String id = (String) yamlElements.get("id"); + if (id.length() - id.replace("/", "").length() >= 2 + && id.substring(id.indexOf("/") + 1).indexOf("/") - id.indexOf("/") > 2 ) + return id.substring(0, id.indexOf("/") + id.substring(id.indexOf("/") + 1).indexOf("/") + 1); + else + return id; + } + return null; } /**