@Test public void interactionTypesCSV() throws IOException { HttpServletRequest request = Mockito.mock(HttpServletRequest.class); when(request.getParameter("type")).thenReturn("csv"); String interactionTypes = new SchemaController().getInteractionTypes(request); LabeledCSVParser parser = CSVTSVUtil.createLabeledCSVParser(IOUtils.toInputStream(interactionTypes, StandardCharsets.UTF_8)); assertThat(parser.getLabels(), is(new String[]{"interaction", "source", "target", "termIRI"})); while (parser.getLine() != null) { assertThat(parser.getValueByLabel("interaction"), is(notNullValue())); assertThat(parser.getValueByLabel("source"), is(notNullValue())); assertThat(parser.getValueByLabel("target"), is(notNullValue())); assertThat(parser.getValueByLabel("termIRI"), is(notNullValue())); } }
@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<InteractionTypeExternal>(); 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); }
SchemaController { @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<InteractionTypeExternal>(); 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); } }
SchemaController { @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<InteractionTypeExternal>(); 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); }  }
SchemaController { @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<InteractionTypeExternal>(); 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); }  @RequestMapping(value = "/interactionTypes", method = RequestMethod.GET) @ResponseBody String getInteractionTypes(HttpServletRequest request); @RequestMapping(value = "/interactionFields", method = RequestMethod.GET) @ResponseBody String getInteractionFields(HttpServletRequest request); @RequestMapping(value = "/prefixes", method = RequestMethod.GET) @ResponseBody String getPrefixes(HttpServletRequest request); }
SchemaController { @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<InteractionTypeExternal>(); 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); }  @RequestMapping(value = "/interactionTypes", method = RequestMethod.GET) @ResponseBody String getInteractionTypes(HttpServletRequest request); @RequestMapping(value = "/interactionFields", method = RequestMethod.GET) @ResponseBody String getInteractionFields(HttpServletRequest request); @RequestMapping(value = "/prefixes", method = RequestMethod.GET) @ResponseBody String getPrefixes(HttpServletRequest request);  }