From 5ddf27de4a31676086706a40abf94aaf10df68f2 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Wed, 2 Oct 2024 00:29:29 +0200 Subject: [PATCH] add more small corrections --- .../description/ModelDescriptorV04.java | 19 ++++++++++++++++--- 1 file changed, 16 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 16340803..d29127e1 100644 --- a/src/main/java/io/bioimage/modelrunner/bioimageio/description/ModelDescriptorV04.java +++ b/src/main/java/io/bioimage/modelrunner/bioimageio/description/ModelDescriptorV04.java @@ -74,6 +74,7 @@ public class ModelDescriptorV04 implements ModelDescriptor private static String fromLocalKey = "fromLocalRepo"; private static String modelPathKey = "modelPath"; private String modelID; + private String newModelID; private String localModelPath; private boolean supportBioengine = false; @@ -121,7 +122,8 @@ protected static ModelDescriptorV04 buildModelDescription(Map ya modelDescription.description = (String) fieldElement; break; case "id": - modelDescription.modelID = findID(yamlElements); + modelDescription.newModelID = findID(yamlElements); + modelDescription.modelID = findOldID(yamlElements); break; case "authors": modelDescription.authors = buildAuthorElements((List) fieldElement); @@ -263,9 +265,9 @@ private void addBioEngine() throws ModelSpecsException { private static String findID(Map yamlElements) { - if (yamlElements.get("config") instanceof Map) { + if (yamlElements.get("config") != null && yamlElements.get("config") instanceof Map) { Map configMap = (Map) yamlElements.get("config"); - if (configMap.get("bioimageio") instanceof Map) { + if (configMap.get("bioimageio") != null && configMap.get("bioimageio") instanceof Map) { Map bioimageMap = (Map) configMap.get("bioimageio"); if (bioimageMap.get("nickname") != null) return (String) bioimageMap.get("nickname"); @@ -274,6 +276,17 @@ private static String findID(Map yamlElements) { return (String) yamlElements.get("id"); } + private static String findOldID(Map yamlElements) { + + if (yamlElements.get("config") != null && yamlElements.get("config") instanceof Map) { + Map configMap = (Map) yamlElements.get("config"); + if (configMap.get("_conceptdoi") != null && configMap.get("_conceptdoi") instanceof String) { + return (String) configMap.get("_conceptdoi"); + } + } + return (String) yamlElements.get("id"); + } + /** * MAke sure that an object that is supposed to be a List * is actually a List