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
7a3dc737
Commit
7a3dc737
authored
2 years ago
by
ThanKarab
Browse files
Options
Downloads
Patches
Plain Diff
Added map to the exareme2 parameters conversion.
parent
dc765f63
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/hbp/mip/models/DTOs/exareme2/Exareme2AlgorithmRequestDTO.java
+21
-15
21 additions, 15 deletions
...mip/models/DTOs/exareme2/Exareme2AlgorithmRequestDTO.java
with
21 additions
and
15 deletions
src/main/java/hbp/mip/models/DTOs/exareme2/Exareme2AlgorithmRequestDTO.java
+
21
−
15
View file @
7a3dc737
package
hbp.mip.models.DTOs.exareme2
;
import
com.google.gson.JsonSyntaxException
;
import
hbp.mip.models.DTOs.ExperimentExecutionDTO
;
import
hbp.mip.utils.JsonConverters
;
import
java.util.*
;
import
java.util.stream.Collectors
;
public
record
Exareme2AlgorithmRequestDTO
(
String
request_id
,
...
...
@@ -27,12 +27,12 @@ public record Exareme2AlgorithmRequestDTO(
}
private
static
Exareme2InputDataRequestDTO
getInputData
(
List
<
ExperimentExecutionDTO
.
AlgorithmExecutionDTO
.
AlgorithmParameterExecutionDTO
>
exaremeAlgorithmRequestParamDTOs
)
{
if
(
exaremeAlgorithmRequestParamDTOs
==
null
){
if
(
exaremeAlgorithmRequestParamDTOs
==
null
)
{
return
null
;
}
Map
<
String
,
String
>
parameters
=
new
HashMap
<>();
for
(
var
parameter:
exaremeAlgorithmRequestParamDTOs
){
for
(
var
parameter
:
exaremeAlgorithmRequestParamDTOs
)
{
parameters
.
put
(
parameter
.
name
(),
parameter
.
value
());
}
...
...
@@ -66,7 +66,7 @@ public record Exareme2AlgorithmRequestDTO(
}
private
static
Map
<
String
,
Object
>
getParameters
(
List
<
ExperimentExecutionDTO
.
AlgorithmExecutionDTO
.
AlgorithmParameterExecutionDTO
>
exaremeAlgorithmRequestParamDTOs
)
{
if
(
exaremeAlgorithmRequestParamDTOs
==
null
){
if
(
exaremeAlgorithmRequestParamDTOs
==
null
)
{
return
null
;
}
...
...
@@ -82,24 +82,15 @@ public record Exareme2AlgorithmRequestDTO(
}
private
static
Map
<
String
,
Object
>
getPreprocessing
(
List
<
ExperimentExecutionDTO
.
AlgorithmExecutionDTO
.
TransformerExecutionDTO
>
exaremeTransformers
)
{
if
(
exaremeTransformers
==
null
){
if
(
exaremeTransformers
==
null
)
{
return
null
;
}
HashMap
<
String
,
Object
>
exareme2Preprocessing
=
new
HashMap
<>();
exaremeTransformers
.
forEach
(
transformer
->
{
HashMap
<
String
,
Object
>
transformerParameterDTOs
=
new
HashMap
<>();
for
(
ExperimentExecutionDTO
.
AlgorithmExecutionDTO
.
AlgorithmParameterExecutionDTO
parameter
:
transformer
.
parameters
())
{
if
(
parameter
.
name
().
equals
(
"strategies"
))
{
// TODO Add this to the proper type conversion, should handle dict as well
transformerParameterDTOs
.
put
(
parameter
.
name
(),
JsonConverters
.
convertJsonStringToObject
(
parameter
.
value
(),
HashMap
.
class
)
);
continue
;
}
for
(
ExperimentExecutionDTO
.
AlgorithmExecutionDTO
.
AlgorithmParameterExecutionDTO
parameter
:
transformer
.
parameters
())
transformerParameterDTOs
.
put
(
parameter
.
name
(),
convertStringToProperExareme2ParameterType
(
parameter
.
value
()));
}
exareme2Preprocessing
.
put
(
transformer
.
name
(),
transformerParameterDTOs
);
});
...
...
@@ -107,6 +98,9 @@ public record Exareme2AlgorithmRequestDTO(
}
private
static
Object
convertStringToProperExareme2ParameterType
(
String
str
)
{
if
(
isMap
(
str
))
return
JsonConverters
.
convertJsonStringToObject
(
str
,
Map
.
class
);
String
[]
stringValues
=
str
.
split
(
","
);
if
(
stringValues
.
length
==
0
)
return
""
;
...
...
@@ -155,6 +149,18 @@ public record Exareme2AlgorithmRequestDTO(
return
true
;
}
private
static
boolean
isMap
(
String
strMap
)
{
if
(
strMap
==
null
)
{
return
false
;
}
try
{
JsonConverters
.
convertJsonStringToObject
(
strMap
,
Map
.
class
);
}
catch
(
JsonSyntaxException
e
)
{
return
false
;
}
return
true
;
}
public
record
Exareme2InputDataRequestDTO
(
String
data_model
,
List
<
String
>
datasets
,
List
<
String
>
x
,
List
<
String
>
y
,
Exareme2FilterRequestDTO
filters
)
{
}
...
...
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