use of org.eol.globi.server.util.ResultFormatterCSV in project eol-globi-data by jhpoelen.
the class SchemaController method getInteractionTypes.
@RequestMapping(value = "/interactionTypes", method = RequestMethod.GET)
@ResponseBody
public String getInteractionTypes(HttpServletRequest request) throws IOException {
Collection<InteractionTypeExternal> availableTypes = Arrays.asList(InteractionTypeExternal.values());
if (request != null) {
if (StringUtils.isNotBlank(request.getParameter(ParamName.TAXON.getName()))) {
CypherQuery cypherQuery = CypherQueryBuilder.buildInteractionTypeQuery(request.getParameterMap());
String interactionTypes = new ResultFormatterCSV().format(CypherUtil.executeRemote(cypherQuery));
String[] interactionType = StringUtils.replace(interactionTypes, "\"", "").split("\n");
availableTypes = new HashSet<>();
for (String type : interactionType) {
InteractionTypeExternal value = CypherQueryBuilder.INTERACTION_TYPE_INTERNAL_EXTERNAL_MAP.get(type);
if (value != null) {
availableTypes.add(value);
}
}
}
}
return "csv".equals(getRequestType(request)) ? interactionMapCsv(availableTypes) : interactionMapJson(availableTypes);
}
Aggregations