use of org.eol.globi.server.util.InteractionTypeExternal in project eol-globi-data by jhpoelen.
the class SchemaController method interactionMapCsv.
protected String interactionMapCsv(Collection<InteractionTypeExternal> availableTypes) {
StringBuilder builder = new StringBuilder();
builder.append("interaction,source,target,termIRI\n");
for (InteractionTypeExternal value : availableTypes) {
builder.append(value.getLabel());
builder.append(",").append(value.getSource());
builder.append(",").append(value.getTarget());
builder.append(",").append(value.getTermIRI()).append("\n");
}
return builder.toString();
}
use of org.eol.globi.server.util.InteractionTypeExternal 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