From 7e2f21767ba8b4cb200283e686339e9d00767083 Mon Sep 17 00:00:00 2001 From: Ludovic Claude <ludovic.claude54@gmail.com> Date: Mon, 14 Mar 2016 19:45:01 +0100 Subject: [PATCH] Update mining api, configurable workflow url Change endpoint from /request/{algo} to /mining, Add configuration workflow.miningUrl in application.yml --- config/application.yml | 2 ++ .../{WorkflowApi.java => MiningApi.java} | 28 ++++++++----------- 2 files changed, 13 insertions(+), 17 deletions(-) rename src/main/java/org/hbp/mip/controllers/{WorkflowApi.java => MiningApi.java} (82%) diff --git a/config/application.yml b/config/application.yml index da656fbf3..654d56e08 100644 --- a/config/application.yml +++ b/config/application.yml @@ -38,3 +38,5 @@ server: session: timeout: 2592000 +workflow: + miningUrl: http://hbpfed1.chuv.ch:8087/mining diff --git a/src/main/java/org/hbp/mip/controllers/WorkflowApi.java b/src/main/java/org/hbp/mip/controllers/MiningApi.java similarity index 82% rename from src/main/java/org/hbp/mip/controllers/WorkflowApi.java rename to src/main/java/org/hbp/mip/controllers/MiningApi.java index afd38e46f..89f690272 100644 --- a/src/main/java/org/hbp/mip/controllers/WorkflowApi.java +++ b/src/main/java/org/hbp/mip/controllers/MiningApi.java @@ -5,6 +5,7 @@ package org.hbp.mip.controllers; import io.swagger.annotations.*; +import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; @@ -19,29 +20,22 @@ import java.io.InputStreamReader; import java.net.URL; @RestController -@RequestMapping(value = "/workflow/{algo}") -@Api(value = "/workflow/{algo}", description = "Forward workflow API") -public class WorkflowApi { +@RequestMapping(value = "/mining") +@Api(value = "/mining", description = "Forward mining API") +public class MiningApi { - @ApiOperation(value = "Send a request to the workflow", response = String.class) + @Value("#{'${workflow.miningUrl:http://localhost:8087/mining}'}") + private String miningUrl; + + @ApiOperation(value = "Send a request to the workflow for data mining", response = String.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Success") }) @RequestMapping(method = RequestMethod.POST) - public ResponseEntity<String> postWorkflow( - @ApiParam(value = "algo", required = true) @PathVariable("algo") String algo, + public ResponseEntity<String> postMining( @RequestBody @ApiParam(value = "Model to create", required = true) String query ) throws Exception { StringBuilder results = new StringBuilder(); - int code = 0; - - if(algo.equals("glr")) - { - code = sendPost("https://mip.humanbrainproject.eu/services/request", query, results); - } - else if(algo.equals("anv")) - { - results.append("not implemented"); - } + int code = sendPost(miningUrl, query, results); return new ResponseEntity<>(results.toString(), HttpStatus.valueOf(code)); } @@ -66,7 +60,7 @@ public class WorkflowApi { int respCode = con.getResponseCode(); - BufferedReader in = null; + BufferedReader in; if(respCode == 200) { in = new BufferedReader(new InputStreamReader(con.getInputStream())); } -- GitLab