From 44afc36434096c81c08e82f549308ff9633a1c26 Mon Sep 17 00:00:00 2001 From: Lukas Forer Date: Sun, 17 Sep 2023 11:26:02 +0200 Subject: [PATCH] Extended binded lists --- .../server/responses/PropertyResponse.java | 24 ++++++++++++++++--- .../responses/WdlParameterInputResponse.java | 24 +++++++++---------- 2 files changed, 32 insertions(+), 16 deletions(-) diff --git a/src/main/java/cloudgene/mapred/server/responses/PropertyResponse.java b/src/main/java/cloudgene/mapred/server/responses/PropertyResponse.java index fc3282cb..b190077b 100644 --- a/src/main/java/cloudgene/mapred/server/responses/PropertyResponse.java +++ b/src/main/java/cloudgene/mapred/server/responses/PropertyResponse.java @@ -69,12 +69,30 @@ public static List buildWithValues(Map values) { return response; } - public static PropertyResponse build(String key, String value, Map values) { + public static List buildWithValues(List values) { + List response = new Vector(); + + for (Map object : values) { + if (object.containsKey("id") && object.containsKey("name")) { + System.out.println(object); + response.add(PropertyResponse.build(object.get("id").toString(), object.get("name").toString())); + } + } + + return response; + } + + public static PropertyResponse build(String key, String value, Object values) { PropertyResponse response = new PropertyResponse(); response.setKey(key); response.setLabel(value); - List responseWithValues = buildWithValues(values); - response.setValues(responseWithValues); + if (values instanceof Map) { + List responseWithValues = buildWithValues((Map) values); + response.setValues(responseWithValues); + } else if (values instanceof List) { + List responseWithValues = buildWithValues((List) values); + response.setValues(responseWithValues); + } return response; } diff --git a/src/main/java/cloudgene/mapred/server/responses/WdlParameterInputResponse.java b/src/main/java/cloudgene/mapred/server/responses/WdlParameterInputResponse.java index a1375320..5402635f 100644 --- a/src/main/java/cloudgene/mapred/server/responses/WdlParameterInputResponse.java +++ b/src/main/java/cloudgene/mapred/server/responses/WdlParameterInputResponse.java @@ -136,7 +136,7 @@ public String getEmptySelection() { public void setEmptySelection(String emptySelection) { this.emptySelection = emptySelection; } - + public List getValues() { return values; } @@ -169,7 +169,6 @@ public void setLabel(String label) { this.label = label; } - public static WdlParameterInputResponse build(WdlParameterInput input, List apps) { WdlParameterInputResponse response = new WdlParameterInputResponse(); response.setId(input.getId()); @@ -211,17 +210,16 @@ public static WdlParameterInputResponse build(WdlParameterInput input, List propertyResponses = new ArrayList(); for (WdlApp app : apps) { - if (category != null && !category.isEmpty()) { - if (app.getCategory() != null && app.getCategory().equals(category)) { - Map values = (Map) app.getProperties().get(property); - PropertyResponse propertyResponse = PropertyResponse.build("apps@" + app.getId(), app.getName(), - values); - propertyResponses.add(propertyResponse); - } - - } else { - // TODO:!! + if (category == null || category.isEmpty()) { + continue; } + if (app.getCategory() == null || !app.getCategory().equals(category)) { + continue; + } + Object values = app.getProperties().get(property); + PropertyResponse propertyResponse = PropertyResponse.build("apps@" + app.getId(), app.getName(), + values); + propertyResponses.add(propertyResponse); } response.setValues(propertyResponses); @@ -275,7 +273,7 @@ public static List build(List inpu for (WdlParameterInput input : inputs) { if (input.isVisible()) { - response.add(WdlParameterInputResponse.build(input, apps)); + response.add(WdlParameterInputResponse.build(input, apps)); } } return response;