Skip to content

Commit

Permalink
Extended binded lists
Browse files Browse the repository at this point in the history
  • Loading branch information
lukfor committed Sep 17, 2023
1 parent cb1d646 commit 44afc36
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,30 @@ public static List<PropertyResponse> buildWithValues(Map values) {
return response;
}

public static PropertyResponse build(String key, String value, Map values) {
public static List<PropertyResponse> buildWithValues(List<Map> values) {
List<PropertyResponse> response = new Vector<PropertyResponse>();

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<PropertyResponse> responseWithValues = buildWithValues(values);
response.setValues(responseWithValues);
if (values instanceof Map) {
List<PropertyResponse> responseWithValues = buildWithValues((Map) values);
response.setValues(responseWithValues);
} else if (values instanceof List) {
List<PropertyResponse> responseWithValues = buildWithValues((List) values);
response.setValues(responseWithValues);
}
return response;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public String getEmptySelection() {
public void setEmptySelection(String emptySelection) {
this.emptySelection = emptySelection;
}

public List<PropertyResponse> getValues() {
return values;
}
Expand Down Expand Up @@ -169,7 +169,6 @@ public void setLabel(String label) {
this.label = label;
}


public static WdlParameterInputResponse build(WdlParameterInput input, List<WdlApp> apps) {
WdlParameterInputResponse response = new WdlParameterInputResponse();
response.setId(input.getId());
Expand Down Expand Up @@ -211,17 +210,16 @@ public static WdlParameterInputResponse build(WdlParameterInput input, List<WdlA
List<PropertyResponse> propertyResponses = new ArrayList<PropertyResponse>();

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);
Expand Down Expand Up @@ -275,7 +273,7 @@ public static List<WdlParameterInputResponse> build(List<WdlParameterInput> inpu

for (WdlParameterInput input : inputs) {
if (input.isVisible()) {
response.add(WdlParameterInputResponse.build(input, apps));
response.add(WdlParameterInputResponse.build(input, apps));
}
}
return response;
Expand Down

0 comments on commit 44afc36

Please sign in to comment.