Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
portal-backend
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
HBP Medical Informatics Platform
portal-backend
Commits
9941ffb9
Commit
9941ffb9
authored
8 years ago
by
Mirco Nasuti
Browse files
Options
Downloads
Patches
Plain Diff
add api to call exareme computations service -> POST /exareme/query/{algo}
parent
ce3eb817
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
config/application.yml
+3
-1
3 additions, 1 deletion
config/application.yml
src/main/java/org/hbp/mip/controllers/MiningApi.java
+58
-4
58 additions, 4 deletions
src/main/java/org/hbp/mip/controllers/MiningApi.java
with
61 additions
and
5 deletions
config/application.yml
+
3
−
1
View file @
9941ffb9
...
...
@@ -40,4 +40,6 @@ server:
workflow
:
miningUrl
:
http://mip.humanbrainproject.eu/services/mining
exaremeMiningUrl
:
http://hbps2.chuv.ch:9090/mining/
exaremeListAlgoUrl
:
http://hbps2.chuv.ch:9090/mining/algorithms
exaremeQueryUrl
:
http://hbps2.chuv.ch:9090/mining/query
This diff is collapsed.
Click to expand it.
src/main/java/org/hbp/mip/controllers/MiningApi.java
+
58
−
4
View file @
9941ffb9
...
...
@@ -4,6 +4,7 @@
package
org.hbp.mip.controllers
;
import
com.google.gson.JsonParser
;
import
io.swagger.annotations.*
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.http.HttpStatus
;
...
...
@@ -25,8 +26,11 @@ public class MiningApi {
@Value
(
"#{'${workflow.miningUrl:http://localhost:8087/mining}'}"
)
private
String
miningUrl
;
@Value
(
"#{'${workflow.exaremeMiningUrl:http://localhost:9090/mining}'}"
)
private
String
exaremeMiningUrl
;
@Value
(
"#{'${workflow.exaremeListAlgoUrl:http://localhost:9090/mining/algorithms}'}"
)
private
String
exaremeListAlgoUrl
;
@Value
(
"#{'${workflow.exaremeQueryUrl:http://localhost:9090/mining/query}'}"
)
private
String
exaremeQueryUrl
;
@ApiOperation
(
value
=
"Send a request to the workflow for data mining"
,
response
=
String
.
class
)
@ApiResponses
(
value
=
{
@ApiResponse
(
code
=
200
,
message
=
"Success"
)
})
...
...
@@ -51,11 +55,61 @@ public class MiningApi {
@RequestMapping
(
path
=
"/exareme/algorithms"
,
method
=
RequestMethod
.
GET
)
public
ResponseEntity
<
String
>
getExaremeAlgoList
(
)
throws
Exception
{
String
url
=
exaremeMiningUrl
+
"algorithm/"
;
try
{
StringBuilder
results
=
new
StringBuilder
();
int
code
=
sendGet
(
exaremeListAlgoUrl
,
results
);
return
new
ResponseEntity
<>(
results
.
toString
(),
HttpStatus
.
valueOf
(
code
));
}
catch
(
UnknownHostException
uhe
)
{
uhe
.
printStackTrace
();
return
new
ResponseEntity
<>(
HttpStatus
.
BAD_GATEWAY
);
}
}
@ApiOperation
(
value
=
"Send a request to the Exareme service to run an algorithm"
,
response
=
String
.
class
)
@ApiResponses
(
value
=
{
@ApiResponse
(
code
=
200
,
message
=
"Success"
)
})
@RequestMapping
(
path
=
"/exareme/query/{algo}"
,
method
=
RequestMethod
.
POST
)
public
ResponseEntity
<
String
>
postExaremeQuery
(
@ApiParam
(
value
=
"algo"
,
required
=
true
)
@PathVariable
(
"algo"
)
String
algo
,
@RequestBody
@ApiParam
(
value
=
"Query for the data mining"
,
required
=
true
)
String
query
)
throws
Exception
{
try
{
/* Launch computation */
String
url
=
exaremeQueryUrl
+
"/"
+
algo
+
"/?format=true"
;
StringBuilder
results
=
new
StringBuilder
();
int
code
=
sendGet
(
url
,
results
);
int
code
=
sendPost
(
url
,
query
,
results
);
if
(
code
<
200
||
code
>
299
)
{
return
new
ResponseEntity
<>(
results
.
toString
(),
HttpStatus
.
valueOf
(
code
));
}
JsonParser
parser
=
new
JsonParser
();
String
key
=
parser
.
parse
(
results
.
toString
()).
getAsJsonObject
().
get
(
"queryKey"
).
getAsString
();
/* Wait for result */
url
=
exaremeQueryUrl
+
"/"
+
key
+
"/status"
;
double
progress
=
0
;
while
(
progress
<
100
)
{
Thread
.
sleep
(
200
);
results
=
new
StringBuilder
();
code
=
sendPost
(
url
,
query
,
results
);
if
(
code
<
200
||
code
>
299
)
{
return
new
ResponseEntity
<>(
results
.
toString
(),
HttpStatus
.
valueOf
(
code
));
}
progress
=
parser
.
parse
(
results
.
toString
()).
getAsJsonObject
().
get
(
"status"
).
getAsDouble
();
}
/* Get result */
url
=
exaremeQueryUrl
+
"/"
+
key
+
"/result"
;
results
=
new
StringBuilder
();
code
=
sendPost
(
url
,
query
,
results
);
return
new
ResponseEntity
<>(
results
.
toString
(),
HttpStatus
.
valueOf
(
code
));
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment