Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
We have upgraded GitLab to 15.1. Due to major code changes GitLab was down for some time.
Open sidebar
vadere
vadere
Commits
38b73063
Commit
38b73063
authored
Apr 17, 2020
by
Christina
Browse files
before migration (V.1.11)
parent
273f4038
Changes
2
Hide whitespace changes
Inline
Side-by-side
VadereSimulator/src/org/vadere/simulator/projects/migration/jsontranformation/json/TargetVersionV1_12.java
0 → 100644
View file @
38b73063
package
org.vadere.simulator.projects.migration.jsontranformation.json
;
import
com.fasterxml.jackson.databind.JsonNode
;
import
org.vadere.annotation.factories.migrationassistant.MigrationTransformation
;
import
org.vadere.simulator.projects.migration.MigrationException
;
import
org.vadere.simulator.projects.migration.jsontranformation.SimpleJsonTransformation
;
import
org.vadere.util.version.Version
;
import
java.util.ArrayList
;
import
java.util.Iterator
;
import
java.util.List
;
/**
* Remove node "threatMemory" under "scenario.topography.dynamicElements.psychologyStatus"
*/
@MigrationTransformation
(
targetVersionLabel
=
"1.12"
)
public
class
TargetVersionV1_12
extends
SimpleJsonTransformation
{
public
TargetVersionV1_12
(){
super
(
Version
.
V1_12
);
}
@Override
protected
void
initDefaultHooks
()
{
addPostHookFirst
(
this
::
targetChangerUseProbabilityToChangeTargettList
);
addPostHookLast
(
this
::
sort
);
}
public
JsonNode
targetChangerUseProbabilityToChangeTargettList
(
JsonNode
node
)
throws
MigrationException
{
// targetChangers may be missing if an old scenario was never opened since the targetChangers where introduced
// This is ok, since a targetChangers node will be inserted if the scenario is read.
if
(
!
path
(
node
,
"scenario/topography/targetChangers"
).
isMissingNode
()){
Iterator
<
JsonNode
>
iter
=
iteratorTargetChangers
(
node
);
while
(
iter
.
hasNext
()){
JsonNode
changer
=
iter
.
next
();
JsonNode
probabilityToChangeTarget
=
pathMustExist
(
changer
,
"probabilityToChangeTarget"
);
if
(
probabilityToChangeTarget
.
isDouble
()){
double
val
=
probabilityToChangeTarget
.
asDouble
();
List
<
Double
>
valNew
=
new
ArrayList
<>();
valNew
.
add
(
val
);
addArrayField
(
changer
,
"probabilityToChangeTarget"
,
valNew
);
}
}
}
return
node
;
}
}
VadereUtils/src/org/vadere/util/version/Version.java
View file @
38b73063
...
...
@@ -42,7 +42,10 @@ public enum Version {
V1_8
(
1
,
8
),
V1_9
(
1
,
9
),
V1_10
(
1
,
10
),
V1_11
(
1
,
11
);
V1_11
(
1
,
11
),
V1_12
(
1
,
12
);
private
static
Logger
logger
=
Logger
.
getLogger
(
Version
.
class
);
private
static
final
String
VERSION_CONTROL_INFO_FILE
=
"/current_commit_hash.txt"
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment