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; } /**