Skip to content

Commit

Permalink
Only include metadata if identifier is valid
Browse files Browse the repository at this point in the history
  • Loading branch information
apetkau committed Dec 13, 2023
1 parent c933a12 commit 5ffec13
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,17 @@ class IridaNextJSONOutput {
// private final Map<String, List<Map<Object, Object>>> files = ["global": [], "samples": []]
// private final Map<String, Map<Object, Object>> metadata = ["samples": []]

public void appendMetadata(String key, Map value) {
metadata[key] = ((Map)metadata[key]) + value
public void appendMetadata(String scope, Map data) {
if (scope in metadata.keySet()) {
Map validMetadata = data.collectEntries { k, v ->
if (k in scopeIds[scope]) {
return [(k): v]
} else {
log.trace "scope=${scope}, id=${k} is not a valid identifier. Removing from metadata."
}
}
metadata[scope] = (metadata[scope] as Map) + validMetadata
}
}

public void addId(String scope, String id) {
Expand Down

0 comments on commit 5ffec13

Please sign in to comment.