Search in sources :

Example 1 with ResultFormatterCSV

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);
}
Also used : ResultFormatterCSV(org.eol.globi.server.util.ResultFormatterCSV) InteractionTypeExternal(org.eol.globi.server.util.InteractionTypeExternal) CypherQuery(org.eol.globi.util.CypherQuery) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

InteractionTypeExternal (org.eol.globi.server.util.InteractionTypeExternal)1 ResultFormatterCSV (org.eol.globi.server.util.ResultFormatterCSV)1 CypherQuery (org.eol.globi.util.CypherQuery)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1