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
f2c30347
Commit
f2c30347
authored
8 years ago
by
Mirco Nasuti
Browse files
Options
Downloads
Patches
Plain Diff
refactoring : try to reduce NPath complexity
parent
175620b3
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/eu/hbp/mip/model/Experiment.java
+34
-40
34 additions, 40 deletions
src/main/java/eu/hbp/mip/model/Experiment.java
with
34 additions
and
40 deletions
src/main/java/eu/hbp/mip/model/Experiment.java
+
34
−
40
View file @
f2c30347
...
...
@@ -86,65 +86,59 @@ public class Experiment {
}
public
ExperimentQuery
prepareQuery
()
{
List
<
VariableId
>
variables
=
new
LinkedList
<>();
List
<
VariableId
>
covariables
=
new
LinkedList
<>();
List
<
VariableId
>
grouping
=
new
LinkedList
<>();
List
<
Filter
>
filters
=
new
LinkedList
<>();
List
<
eu
.
hbp
.
mip
.
messages
.
external
.
Algorithm
>
algorithms
=
new
LinkedList
<>();
List
<
Validation
>
validations
=
new
LinkedList
<>();
if
(
model
==
null
||
model
.
getQuery
()
==
null
)
return
new
ExperimentQuery
(
null
,
null
,
null
,
null
,
null
,
null
);
for
(
Variable
v:
model
.
getQuery
().
getVariables
()
)
{
variables
.
add
(
new
VariableId
(
v
.
getCode
()));
}
for
(
Variable
v:
model
.
getQuery
().
getCovariables
()
)
{
covariables
.
add
(
new
VariableId
(
v
.
getCode
()));
}
for
(
Variable
v:
model
.
getQuery
().
getGrouping
()
)
{
grouping
.
add
(
new
VariableId
(
v
.
getCode
()));
}
List
<
eu
.
hbp
.
mip
.
messages
.
external
.
Algorithm
>
algorithms
=
new
LinkedList
<>();
Type
algoList
=
new
TypeToken
<
LinkedList
<
eu
.
hbp
.
mip
.
model
.
Algorithm
>>(){}.
getType
();
List
<
eu
.
hbp
.
mip
.
model
.
Algorithm
>
algos
=
new
Gson
().
fromJson
(
this
.
algorithms
,
algoList
);
for
(
eu
.
hbp
.
mip
.
model
.
Algorithm
a:
algos
)
{
HashMap
<
String
,
String
>
params
=
new
HashMap
<>();
for
(
AlgorithmParam
ap:
a
.
getParameters
()
)
{
params
=
params
.
updated
(
ap
.
getCode
(),
ap
.
getValue
());
}
algorithms
.
add
(
new
Algorithm
(
a
.
getCode
(),
a
.
getName
(),
params
));
algorithms
.
add
(
new
Algorithm
(
a
.
getCode
(),
a
.
getName
(),
algoParamsToHashMap
(
a
.
getParameters
())));
}
List
<
Validation
>
validations
=
new
LinkedList
<>();
Type
validList
=
new
TypeToken
<
LinkedList
<
eu
.
hbp
.
mip
.
model
.
ExperimentValidator
>>(){}.
getType
();
List
<
eu
.
hbp
.
mip
.
model
.
ExperimentValidator
>
valids
=
new
Gson
().
fromJson
(
this
.
validations
,
validList
);
for
(
ExperimentValidator
v:
valids
)
{
HashMap
<
String
,
String
>
params
=
new
HashMap
<>();
for
(
AlgorithmParam
ap:
v
.
getParameters
()
)
{
params
=
params
.
updated
(
ap
.
getCode
(),
ap
.
getValue
());
}
validations
.
add
(
new
Validation
(
v
.
getCode
(),
v
.
getName
(),
params
));
validations
.
add
(
new
Validation
(
v
.
getCode
(),
v
.
getName
(),
algoParamsToHashMap
(
v
.
getParameters
())));
}
Seq
<
VariableId
>
variablesSeq
=
JavaConverters
.
asScalaIteratorConverter
(
variables
.
iterator
()).
asScala
().
toSeq
().
toList
();
Seq
<
VariableId
>
covariablesSeq
=
JavaConverters
.
asScalaIteratorConverter
(
covariables
.
iterator
()).
asScala
().
toSeq
().
toList
();
Seq
<
VariableId
>
groupingSeq
=
JavaConverters
.
asScalaIteratorConverter
(
grouping
.
iterator
()).
asScala
().
toSeq
().
toList
();
Seq
<
Filter
>
filtersSeq
=
JavaConverters
.
asScalaIteratorConverter
(
filters
.
iterator
()).
asScala
().
toSeq
().
toList
();
Seq
<
Algorithm
>
algorithmsSeq
=
JavaConverters
.
asScalaIteratorConverter
(
algorithms
.
iterator
()).
asScala
().
toSeq
().
toList
();
Seq
<
Validation
>
validationsSeq
=
JavaConverters
.
asScalaIteratorConverter
(
validations
.
iterator
()).
asScala
().
toSeq
().
toList
();
Seq
<
VariableId
>
variablesSeq
=
JavaConverters
.
asScalaIteratorConverter
(
variablesToVariableIds
(
model
.
getQuery
().
getVariables
()).
iterator
()).
asScala
().
toSeq
().
toList
();
Seq
<
VariableId
>
covariablesSeq
=
JavaConverters
.
asScalaIteratorConverter
(
variablesToVariableIds
(
model
.
getQuery
().
getCovariables
()).
iterator
()).
asScala
().
toSeq
().
toList
();
Seq
<
VariableId
>
groupingSeq
=
JavaConverters
.
asScalaIteratorConverter
(
variablesToVariableIds
(
model
.
getQuery
().
getGrouping
()).
iterator
()).
asScala
().
toSeq
().
toList
();
Seq
<
Filter
>
filtersSeq
=
JavaConverters
.
asScalaIteratorConverter
(
new
LinkedList
<
Filter
>().
iterator
()).
asScala
().
toSeq
().
toList
();
Seq
<
Algorithm
>
algorithmsSeq
=
JavaConverters
.
asScalaIteratorConverter
(
algorithms
.
iterator
()).
asScala
().
toSeq
().
toList
();
Seq
<
Validation
>
validationsSeq
=
JavaConverters
.
asScalaIteratorConverter
(
validations
.
iterator
()).
asScala
().
toSeq
().
toList
();
return
new
ExperimentQuery
(
variablesSeq
,
covariablesSeq
,
groupingSeq
,
filtersSeq
,
algorithmsSeq
,
validationsSeq
);
}
private
HashMap
<
String
,
String
>
algoParamsToHashMap
(
List
<
AlgorithmParam
>
aps
)
{
HashMap
<
String
,
String
>
params
=
new
HashMap
<>();
for
(
AlgorithmParam
ap:
aps
)
{
params
=
params
.
updated
(
ap
.
getCode
(),
ap
.
getValue
());
}
return
params
;
}
private
List
<
VariableId
>
variablesToVariableIds
(
List
<
Variable
>
vars
)
{
List
<
VariableId
>
varIds
=
new
LinkedList
<>();
for
(
Variable
v:
vars
)
{
varIds
.
add
(
new
VariableId
(
v
.
getCode
()));
}
return
varIds
;
}
public
String
computeExaremeQuery
()
{
List
<
ExaremeQueryElement
>
queryElements
=
new
LinkedList
<>();
for
(
Variable
var
:
model
.
getQuery
().
getVariables
())
...
...
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