Skip to content

Commit

Permalink
transform dot notation to camelcased parameter names. need to do the …
Browse files Browse the repository at this point in the history
…reverse right before the mongo query is run
  • Loading branch information
julie-sullivan committed Feb 24, 2020
1 parent cc265c5 commit 3aa1050
Showing 1 changed file with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,31 @@ public Map<String, String> convertMultiToMap(MultivaluedMap<String, String> m) {
return map;
}
for (Map.Entry<String, List<String>> entry : m.entrySet()) {
map.put(entry.getKey(), String.join(",", entry.getValue()));
String camelCased = convertDotToCamelCase(entry.getKey());
map.put(camelCased, String.join(",", entry.getValue()));
}
return map;
}

/**
* Converts to canelcase, e.g. transcripts.biotype --> transcriptsBiotype. It's translated back to the full path right before the
* mongo query is run.
*
* @param dotPath e.g. transcripts.biotype
* @return the string camelcased
*/
private String convertDotToCamelCase(String dotPath) {
String[] paths = dotPath.split("\\.");
StringBuilder sb = new StringBuilder();
for (String path : paths) {
if (sb.length() > 0) {
path = StringUtils.capitalize(path);
}
sb.append(path);
}
return sb.toString();
}

public void parseQueryParams() {
MultivaluedMap<String, String> multivaluedMap = uriInfo.getQueryParameters();

Expand Down

0 comments on commit 3aa1050

Please sign in to comment.