Skip to content
Snippets Groups Projects
Commit 63927beb authored by Manuel Spuhler's avatar Manuel Spuhler
Browse files

Generic method to perform algo without persistence

parent aac7c11f
No related branches found
No related tags found
1 merge request!5Generic method to perform algo without persistence
package eu.hbp.mip.controllers; package eu.hbp.mip.controllers;
import eu.hbp.mip.utils.HTTPUtil; import eu.hbp.mip.utils.HTTPUtil;
import com.google.gson.Gson; import com.google.gson.Gson;
...@@ -9,6 +8,8 @@ import eu.hbp.mip.model.User; ...@@ -9,6 +8,8 @@ import eu.hbp.mip.model.User;
import eu.hbp.mip.model.UserInfo; import eu.hbp.mip.model.UserInfo;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -20,6 +21,8 @@ import org.springframework.web.bind.annotation.RequestBody; ...@@ -20,6 +21,8 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.util.*; import java.util.*;
import java.io.IOException; import java.io.IOException;
...@@ -78,4 +81,25 @@ public class MiningApi { ...@@ -78,4 +81,25 @@ public class MiningApi {
return new ResponseEntity<>("Not found", HttpStatus.BAD_REQUEST); return new ResponseEntity<>("Not found", HttpStatus.BAD_REQUEST);
} }
} }
@ApiOperation(value = "Perform an non persisted algorithm on Exareme", response = String.class)
@RequestMapping(value = "/exareme/{algorithmName}", method = RequestMethod.POST)
public ResponseEntity runExaremeAlgorithm(
@RequestBody List<HashMap<String, String>> queryList,
@ApiParam(value = "algorithmName", required = true) @PathVariable("algorithmName") String algorithmName
) {
LOGGER.info("Run algo");
String query = gson.toJson(queryList);
String url = miningExaremeQueryUrl + "/" + algorithmName;
try {
StringBuilder results = new StringBuilder();
int code = HTTPUtil.sendPost(url, query, results);
return ResponseEntity.ok(gson.toJson(results.toString()));
} catch (IOException e) {
return new ResponseEntity<>("Not found", HttpStatus.BAD_REQUEST);
}
}
} }
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment