From 91dd9f895a39e7ce2ac26f722e4e542d9e6a7067 Mon Sep 17 00:00:00 2001 From: Mirco Nasuti <mirco.nasuti@chuv.ch> Date: Mon, 20 Jun 2016 11:42:46 +0200 Subject: [PATCH] add exareme GLR into mining catalog --- config/application.yml | 1 + config/application_hbps1.yml | 46 ------------------- pom.xml | 34 ++------------ .../org/hbp/mip/controllers/MiningApi.java | 25 +++++++++- .../hbp/mip/model/algorithm/Algorithm.java | 10 ++++ 5 files changed, 39 insertions(+), 77 deletions(-) delete mode 100644 config/application_hbps1.yml diff --git a/config/application.yml b/config/application.yml index d8a9f7180..6f752d822 100644 --- a/config/application.yml +++ b/config/application.yml @@ -40,6 +40,7 @@ server: timeout: 2592000 workflow: + experimentUrl: http://dockerhost:8087/experiment listMethodsUrl: http://dockerhost:8087/list-methods miningMipUrl: http://dockerhost:8087/mining miningExaremeUrl: http://hbps2.chuv.ch:9090/mining/query diff --git a/config/application_hbps1.yml b/config/application_hbps1.yml deleted file mode 100644 index d8a9f7180..000000000 --- a/config/application_hbps1.yml +++ /dev/null @@ -1,46 +0,0 @@ -# Configuration for the portal running inside a Docker container for development - -connection: - url: "jdbc:postgresql://portaldb:5432/postgres" - username: "postgres" - password: "test" - -security: - enabled: false - -hbp: - client: - clientId: 996f97c5-a3ca-460e-b18b-00df3e2be89a - clientSecret: aD0Tueb3KkNkcZqZgQbNyDWgnM95IfZ0xPCQ_6Z9dQNHXY00RIrnAD_m7sNJh1oofYSX8aHkl72MkwI0K626Ug - accessTokenUri: https://services.humanbrainproject.eu/oidc/token - userAuthorizationUri: https://services.humanbrainproject.eu/oidc/authorize - tokenName: oauth_token - authenticationScheme: query - clientAuthenticationScheme: form - # use-current-uri: false # For both production and HBPS1 deployments - # pre-established-redirect-uri: https://mip.humanbrainproject.eu/services/login/hbp # For production deployment - # pre-established-redirect-uri: http://hbps1.chuv.ch/services/login/hbp # For HBPS1 deployment - resource: - userInfoUri: https://services.humanbrainproject.eu/oidc/userinfo - -logging: - level: - org.springframework.security: DEBUG - -spring: - resources: - chain: - enabled: true - -server: - contextPath: /services - port: 8080 - use-forward-headers: true - session: - timeout: 2592000 - -workflow: - listMethodsUrl: http://dockerhost:8087/list-methods - miningMipUrl: http://dockerhost:8087/mining - miningExaremeUrl: http://hbps2.chuv.ch:9090/mining/query - diff --git a/pom.xml b/pom.xml index 74b2de554..859fadb7a 100644 --- a/pom.xml +++ b/pom.xml @@ -18,25 +18,6 @@ <relativePath /> <!-- lookup parent from repository --> </parent> <profiles> - <profile> - <id>test</id> - <properties> - <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> - <java.version>1.8</java.version> - <connection.driver_class>org.h2.Driver</connection.driver_class> - <connection.url>jdbc:h2:mem:test</connection.url> - <connection.username>root</connection.username> - <connection.password>root</connection.password> - <hibernate.dialect>org.hibernate.dialect.H2Dialect</hibernate.dialect> - <schema.deploy>true</schema.deploy> - <frontend.redirect>http://frontend/#/home</frontend.redirect> - <workflow.experimentUrl>http://hbps1.chuv.ch:8087/experiment</workflow.experimentUrl> - <workflow.listMethodsUrl>http://hbps1.chuv.ch:8087/list-methods</workflow.listMethodsUrl> - <flyway.url>${connection.url}</flyway.url> - <flyway.user>${connection.username}</flyway.user> - <flyway.password>${connection.password}</flyway.password> - </properties> - </profile> <profile> <id>prod</id> <properties> @@ -48,9 +29,7 @@ <connection.password>iaezXODVLb1e70I</connection.password> <hibernate.dialect>org.hibernate.dialect.PostgreSQL82Dialect</hibernate.dialect> <schema.deploy>false</schema.deploy> - <frontend.redirect>https://mip.humanbrainproject.eu/#/home</frontend.redirect> - <workflow.experimentUrl>http://hbps1.chuv.ch:8087/experiment</workflow.experimentUrl> - <workflow.listMethodsUrl>http://hbps1.chuv.ch:8087/list-methods</workflow.listMethodsUrl> + <frontend.redirect>https://mip.humanbrainproject.eu/home</frontend.redirect> <flyway.url>${connection.url}</flyway.url> <flyway.user>${connection.username}</flyway.user> <flyway.password>${connection.password}</flyway.password> @@ -68,10 +47,6 @@ <hibernate.dialect>org.hibernate.dialect.PostgreSQL82Dialect</hibernate.dialect> <schema.deploy>false</schema.deploy> <frontend.redirect>http://frontend/home</frontend.redirect> - <workflow.experimentUrl>http://dockerhost:8087/experiment</workflow.experimentUrl> - <workflow.listMethodsUrl>http://dockerhost:8087/list-methods</workflow.listMethodsUrl> - <workflow.miningMipUrl>http://dockerhost:8087/mining</workflow.miningMipUrl> - <workflow.miningExaremeUrl>http://dockerhost:8087/mining/query</workflow.miningExaremeUrl> <flyway.url>${connection.url}</flyway.url> <flyway.user>${connection.username}</flyway.user> <flyway.password>${connection.password}</flyway.password> @@ -89,8 +64,6 @@ <hibernate.dialect>org.hibernate.dialect.PostgreSQL82Dialect</hibernate.dialect> <schema.deploy>false</schema.deploy> <frontend.redirect>http://hbps1.chuv.ch/home</frontend.redirect> - <workflow.experimentUrl>http://hbps1.chuv.ch:8087/experiment</workflow.experimentUrl> - <workflow.listMethodsUrl>http://hbps1.chuv.ch:8087/list-methods</workflow.listMethodsUrl> <flyway.url>${connection.url}</flyway.url> <flyway.user>${connection.username}</flyway.user> <flyway.password>${connection.password}</flyway.password> @@ -189,7 +162,10 @@ <resources> <resource> <directory>src/main/resources</directory> - <includes><include>**/*.xml</include></includes> + <includes> + <include>**/*.xml</include> + <include>**/*.json</include> + </includes> <excludes><exclude>**/*.csv</exclude></excludes> <filtering>true</filtering> </resource> diff --git a/src/main/java/org/hbp/mip/controllers/MiningApi.java b/src/main/java/org/hbp/mip/controllers/MiningApi.java index cc99c1fce..157ffc733 100644 --- a/src/main/java/org/hbp/mip/controllers/MiningApi.java +++ b/src/main/java/org/hbp/mip/controllers/MiningApi.java @@ -4,15 +4,22 @@ package org.hbp.mip.controllers; +import com.google.gson.Gson; import com.google.gson.JsonParser; import io.swagger.annotations.*; +import org.hbp.mip.model.algorithm.Algorithm; +import org.hbp.mip.model.algorithm.Catalog; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; import java.io.BufferedReader; import java.io.DataOutputStream; +import java.io.InputStream; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; @@ -23,6 +30,8 @@ import java.net.UnknownHostException; @Api(value = "/mining", description = "Forward mining API") public class MiningApi { + private static final String EXAREME_ALGO_JSON_FILE="data/exareme_algorithms.json"; + @Value("#{'${workflow.listMethodsUrl:http://hbps1.chuv.ch:8087/list-methods}'}") private String listMethodsUrl; @@ -47,7 +56,19 @@ public class MiningApi { return new ResponseEntity<>(response.toString(), HttpStatus.valueOf(code)); } - return null; + Catalog catalog = new Gson().fromJson(response.toString(), Catalog.class); + for (Algorithm algo: catalog.getAlgorithms()) { + algo.setSource("ML"); + } + + InputStream is = MiningApi.class.getClassLoader().getResourceAsStream(EXAREME_ALGO_JSON_FILE); + InputStreamReader isr = new InputStreamReader(is); + BufferedReader br = new BufferedReader(isr); + Algorithm exaremeGLR = new Gson().fromJson(br, Algorithm.class); + exaremeGLR.setSource("exareme"); + catalog.getAlgorithms().add(exaremeGLR); + + return new ResponseEntity<>(new Gson().toJson(catalog), HttpStatus.valueOf(code)); } private ResponseEntity<String> postMipMining(String query) throws Exception { diff --git a/src/main/java/org/hbp/mip/model/algorithm/Algorithm.java b/src/main/java/org/hbp/mip/model/algorithm/Algorithm.java index 2b2897c08..5e0aae5de 100644 --- a/src/main/java/org/hbp/mip/model/algorithm/Algorithm.java +++ b/src/main/java/org/hbp/mip/model/algorithm/Algorithm.java @@ -33,6 +33,8 @@ public class Algorithm { private Boolean disable; + private String source; + public String getCode() { return code; @@ -105,4 +107,12 @@ public class Algorithm { public void setDisable(Boolean disable) { this.disable = disable; } + + public String getSource() { + return source; + } + + public void setSource(String source) { + this.source = source; + } } -- GitLab