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
c6b68ab9
Commit
c6b68ab9
authored
8 years ago
by
Mirco Nasuti
Browse files
Options
Downloads
Patches
Plain Diff
fix double quoted-prettified json in experiments API
parent
ae18943a
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
src/main/java/eu/hbp/mip/controllers/ExperimentApi.java
+4
-4
4 additions, 4 deletions
src/main/java/eu/hbp/mip/controllers/ExperimentApi.java
src/main/java/eu/hbp/mip/model/Experiment.java
+33
-5
33 additions, 5 deletions
src/main/java/eu/hbp/mip/model/Experiment.java
with
37 additions
and
9 deletions
src/main/java/eu/hbp/mip/controllers/ExperimentApi.java
+
4
−
4
View file @
c6b68ab9
...
...
@@ -101,7 +101,7 @@ public class ExperimentApi {
}
}
catch
(
MalformedURLException
mue
)
{
LOGGER
.
trace
(
mue
.
getMessage
());
}
// ignore
return
new
ResponseEntity
<>(
gson
.
toJson
(
experiment
),
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
gson
.
toJson
(
experiment
.
jsonify
()
),
HttpStatus
.
OK
);
}
@ApiOperation
(
value
=
"get an experiment"
,
response
=
Experiment
.
class
)
...
...
@@ -126,7 +126,7 @@ public class ExperimentApi {
return
new
ResponseEntity
<>(
"Not found"
,
HttpStatus
.
NOT_FOUND
);
}
return
new
ResponseEntity
<>(
gson
.
toJson
(
experiment
),
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
gson
.
toJson
(
experiment
.
jsonify
()
),
HttpStatus
.
OK
);
}
@ApiOperation
(
value
=
"Mark an experiment as viewed"
,
response
=
Experiment
.
class
)
...
...
@@ -154,7 +154,7 @@ public class ExperimentApi {
LOGGER
.
info
(
"Experiment updated (marked as viewed)"
);
return
new
ResponseEntity
<>(
gson
.
toJson
(
experiment
),
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
gson
.
toJson
(
experiment
.
jsonify
()
),
HttpStatus
.
OK
);
}
@ApiOperation
(
value
=
"Mark an experiment as shared"
,
response
=
Experiment
.
class
)
...
...
@@ -282,7 +282,7 @@ public class ExperimentApi {
LOGGER
.
info
(
"Experiment updated (marked as shared)"
);
return
new
ResponseEntity
<>(
gson
.
toJson
(
experiment
),
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
gson
.
toJson
(
experiment
.
jsonify
()
),
HttpStatus
.
OK
);
}
private
void
sendExperiment
(
Experiment
experiment
)
throws
MalformedURLException
{
...
...
This diff is collapsed.
Click to expand it.
src/main/java/eu/hbp/mip/model/Experiment.java
+
33
−
5
View file @
c6b68ab9
package
eu.hbp.mip.model
;
import
com.google.gson.Gson
;
import
com.google.gson.GsonBuilder
;
import
com.google.gson.JsonArray
;
import
com.google.gson.JsonObject
;
import
com.google.gson.*
;
import
com.google.gson.annotations.Expose
;
import
org.apache.log4j.Logger
;
import
org.hibernate.annotations.Cascade
;
import
javax.persistence.*
;
import
java.util.*
;
import
java.util.Date
;
import
java.util.LinkedList
;
import
java.util.List
;
import
java.util.UUID
;
/**
* Created by habfast on 21/04/16.
...
...
@@ -137,6 +137,34 @@ public class Experiment {
return
new
Gson
().
toJson
(
queryElements
);
}
public
JsonObject
jsonify
()
{
JsonObject
exp
=
new
Gson
().
toJsonTree
(
this
).
getAsJsonObject
();
JsonParser
parser
=
new
JsonParser
();
if
(
this
.
algorithms
!=
null
)
{
exp
.
remove
(
"algorithms"
);
JsonArray
jsonAlgorithms
=
parser
.
parse
(
this
.
algorithms
).
getAsJsonArray
();
exp
.
add
(
"algorithms"
,
jsonAlgorithms
);
}
if
(
this
.
validations
!=
null
)
{
exp
.
remove
(
"validations"
);
JsonArray
jsonValidations
=
parser
.
parse
(
this
.
validations
).
getAsJsonArray
();
exp
.
add
(
"validations"
,
jsonValidations
);
}
if
(
this
.
result
!=
null
)
{
exp
.
remove
(
"result"
);
JsonArray
jsonResult
=
parser
.
parse
(
this
.
result
).
getAsJsonArray
();
exp
.
add
(
"result"
,
jsonResult
);
}
return
exp
;
}
public
String
getValidations
()
{
return
validations
;
}
...
...
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