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
1f6f2816
Commit
1f6f2816
authored
8 years ago
by
Mirco Nasuti
Browse files
Options
Downloads
Patches
Plain Diff
refactoring
parent
737ddf4d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/org/hbp/mip/controllers/MiningApi.java
+31
-39
31 additions, 39 deletions
src/main/java/org/hbp/mip/controllers/MiningApi.java
with
31 additions
and
39 deletions
src/main/java/org/hbp/mip/controllers/MiningApi.java
+
31
−
39
View file @
1f6f2816
...
@@ -85,25 +85,6 @@ public class MiningApi {
...
@@ -85,25 +85,6 @@ public class MiningApi {
String
modelSlug
=
new
JsonParser
().
parse
(
query
).
getAsJsonObject
()
String
modelSlug
=
new
JsonParser
().
parse
(
query
).
getAsJsonObject
()
.
get
(
"model"
).
getAsString
();
.
get
(
"model"
).
getAsString
();
for
(
Algorithm
algo
:
catalog
.
getAlgorithms
())
{
if
(
algo
.
getCode
().
equals
(
algoCode
))
{
if
(
algo
.
getSource
().
equals
(
ML_SOURCE
))
{
return
postMipMining
(
algoCode
,
modelSlug
);
}
else
if
(
algo
.
getSource
().
equals
(
EXAREME_SOURCE
))
{
return
postExaremeMining
(
"WP_LINEAR_REGRESSION"
,
modelSlug
);
}
}
}
return
new
ResponseEntity
<>(
HttpStatus
.
BAD_REQUEST
);
}
private
ResponseEntity
<
String
>
postMipMining
(
String
algoCode
,
String
modelSlug
)
throws
Exception
{
Session
session
=
HibernateUtil
.
getSessionFactory
().
getCurrentSession
();
Session
session
=
HibernateUtil
.
getSessionFactory
().
getCurrentSession
();
Model
model
=
null
;
Model
model
=
null
;
...
@@ -122,6 +103,25 @@ public class MiningApi {
...
@@ -122,6 +103,25 @@ public class MiningApi {
}
}
}
}
for
(
Algorithm
algo
:
catalog
.
getAlgorithms
())
{
if
(
algo
.
getCode
().
equals
(
algoCode
))
{
if
(
algo
.
getSource
().
equals
(
ML_SOURCE
))
{
return
postMipMining
(
algoCode
,
model
);
}
else
if
(
algo
.
getSource
().
equals
(
EXAREME_SOURCE
))
{
return
postExaremeMining
(
"WP_LINEAR_REGRESSION"
,
model
);
}
}
}
return
new
ResponseEntity
<>(
HttpStatus
.
BAD_REQUEST
);
}
private
ResponseEntity
<
String
>
postMipMining
(
String
algoCode
,
Model
model
)
throws
Exception
{
SimpleMiningQuery
smq
=
new
SimpleMiningQuery
();
SimpleMiningQuery
smq
=
new
SimpleMiningQuery
();
smq
.
setAlgorithm
(
algoCode
);
smq
.
setAlgorithm
(
algoCode
);
...
@@ -156,7 +156,13 @@ public class MiningApi {
...
@@ -156,7 +156,13 @@ public class MiningApi {
try
{
try
{
StringBuilder
results
=
new
StringBuilder
();
StringBuilder
results
=
new
StringBuilder
();
int
code
=
HTTPUtil
.
sendPost
(
miningMipUrl
,
new
Gson
().
toJson
(
smq
),
results
);
String
jsonQuery
=
new
Gson
().
toJson
(
smq
);
System
.
out
.
println
(
"****************************************"
);
System
.
out
.
println
(
"SimpleMining content : "
+
jsonQuery
);
System
.
out
.
println
(
"****************************************"
);
int
code
=
HTTPUtil
.
sendPost
(
miningMipUrl
,
jsonQuery
,
results
);
return
new
ResponseEntity
<>(
results
.
toString
(),
HttpStatus
.
valueOf
(
code
));
return
new
ResponseEntity
<>(
results
.
toString
(),
HttpStatus
.
valueOf
(
code
));
}
}
...
@@ -167,25 +173,7 @@ public class MiningApi {
...
@@ -167,25 +173,7 @@ public class MiningApi {
}
}
private
ResponseEntity
<
String
>
postExaremeMining
(
String
algoCode
,
String
modelSlug
)
throws
Exception
{
private
ResponseEntity
<
String
>
postExaremeMining
(
String
algoCode
,
Model
model
)
throws
Exception
{
Session
session
=
HibernateUtil
.
getSessionFactory
().
getCurrentSession
();
Model
model
=
null
;
try
{
session
.
beginTransaction
();
model
=
(
Model
)
session
.
createQuery
(
"FROM Model WHERE slug= :slug"
)
.
setString
(
"slug"
,
modelSlug
)
.
uniqueResult
();
session
.
getTransaction
().
commit
();
}
catch
(
Exception
e
)
{
if
(
session
.
getTransaction
()
!=
null
)
{
session
.
getTransaction
().
rollback
();
throw
e
;
}
}
LinkedList
<
ExaremeQueryElement
>
queryElements
=
new
LinkedList
<>();
LinkedList
<
ExaremeQueryElement
>
queryElements
=
new
LinkedList
<>();
for
(
Variable
var
:
model
.
getQuery
().
getVariables
())
for
(
Variable
var
:
model
.
getQuery
().
getVariables
())
...
@@ -227,6 +215,10 @@ public class MiningApi {
...
@@ -227,6 +215,10 @@ public class MiningApi {
String
jsonQuery
=
new
Gson
().
toJson
(
queryElements
);
String
jsonQuery
=
new
Gson
().
toJson
(
queryElements
);
System
.
out
.
println
(
"****************************************"
);
System
.
out
.
println
(
"ExaremeMining content : "
+
jsonQuery
);
System
.
out
.
println
(
"****************************************"
);
try
{
try
{
/* Launch computation */
/* Launch computation */
...
...
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