Skip to content

Commit

Permalink
add more small corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosuc3m committed Oct 1, 2024
1 parent c1f5936 commit 5ddf27d
Showing 1 changed file with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -121,7 +122,8 @@ protected static ModelDescriptorV04 buildModelDescription(Map<String, Object> 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);
Expand Down Expand Up @@ -263,9 +265,9 @@ private void addBioEngine() throws ModelSpecsException {

private static String findID(Map<String, Object> yamlElements) {

if (yamlElements.get("config") instanceof Map) {
if (yamlElements.get("config") != null && yamlElements.get("config") instanceof Map) {
Map<String, Object> configMap = (Map<String, Object>) yamlElements.get("config");
if (configMap.get("bioimageio") instanceof Map) {
if (configMap.get("bioimageio") != null && configMap.get("bioimageio") instanceof Map) {
Map<String, Object> bioimageMap = (Map<String, Object>) configMap.get("bioimageio");
if (bioimageMap.get("nickname") != null)
return (String) bioimageMap.get("nickname");
Expand All @@ -274,6 +276,17 @@ private static String findID(Map<String, Object> yamlElements) {
return (String) yamlElements.get("id");
}

private static String findOldID(Map<String, Object> yamlElements) {

if (yamlElements.get("config") != null && yamlElements.get("config") instanceof Map) {
Map<String, Object> configMap = (Map<String, Object>) 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<String>
* is actually a List<String>
Expand Down

0 comments on commit 5ddf27d

Please sign in to comment.