diff --git a/config/application.yml b/config/application.yml index da656fbf35652e4ed0c629b933f308e21c9a22ec..654d56e08978f4108bfcc6cab75de7b888ab6589 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 afd38e46f9d4776850d644cbb572a94c29ae542c..89f69027297aeae83d9b675c8315cccabdb24de9 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())); }