Skip to content

Commit

Permalink
Merge pull request #68 from CBIIT/add-acl-to-fileOverview
Browse files Browse the repository at this point in the history
Added acl return value to fileOverview
  • Loading branch information
n2iw authored Aug 23, 2022
2 parents 278340f + 36bb50d commit b9608c2
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
21 changes: 18 additions & 3 deletions src/main/java/gov/nih/nci/bento/model/PrivateESDataFetcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,8 @@ private List<Map<String, Object>> fileOverview(Map<String, Object> params) throw
new String[]{"file_description", "file_description"},
new String[]{"file_format", "file_format"},
new String[]{"file_size", "file_size"},
new String[]{"diagnosis", "diagnoses"}
new String[]{"diagnosis", "diagnoses"},
new String[]{"acl", "acl"}
};

String defaultSort = "file_name"; // Default sort order
Expand All @@ -365,10 +366,24 @@ private List<Map<String, Object>> fileOverview(Map<String, Object> params) throw
Map.entry("file_description", "file_description"),
Map.entry("file_format", "file_format"),
Map.entry("file_size", "file_size"),
Map.entry("diagnosis", "diagnoses")
Map.entry("diagnosis", "diagnoses"),
Map.entry("acl", "acl")
);

return overview(FILES_END_POINT, params, PROPERTIES, defaultSort, mapping);
List<Map<String, Object>> result = overview(FILES_END_POINT, params, PROPERTIES, defaultSort, mapping);
final String ACL_KEY = "acl";
try{
for(Map<String, Object> resultElement: result){
String acl = (String) resultElement.get(ACL_KEY);
String[] acls = acl.replaceAll("\\]|\\[|'|\"", "").split(",");
resultElement.put(ACL_KEY, acls);
}
}
catch(ClassCastException | NullPointerException ex){
logger.error("Error occurred when splitting acl into String array");
}

return result;
}

private List<Map<String, Object>> overview(String endpoint, Map<String, Object> params, String[][] properties, String defaultSort, Map<String, String> mapping) throws IOException {
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/graphql/bento-private-es-schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ type FileOverview2 {
file_format: String
file_size: Float
diagnosis: String
acl: [String]
}

type SearchResult {
Expand Down
4 changes: 3 additions & 1 deletion src/main/resources/yaml/es_indices_bento.yml
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,8 @@ Indices:
type: keyword
age_at_index:
type: integer

acl:
type: keyword
# Cypher query will be used to retrieve data from Neo4j, and index into Elasticsearch
cypher_query: "
MATCH (ss:study_subject)<-[*..2]-(parent)<--(f:file)
Expand All @@ -329,6 +330,7 @@ Indices:
f.file_format AS file_format_gs,
f.file_size AS file_size,
f.md5sum AS md5sum,
f.acl AS acl,
toInteger(split(f.file_id,'-')[2]) AS file_id_num,
ss.disease_subtype AS diagnoses,
sf.grouped_recurrence_score AS rc_scores,
Expand Down

0 comments on commit b9608c2

Please sign in to comment.