Commit 38b73063 authored by Christina's avatar Christina
Browse files

before migration (V.1.11)

parent 273f4038
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;
}
}
...@@ -42,7 +42,10 @@ public enum Version { ...@@ -42,7 +42,10 @@ public enum Version {
V1_8(1, 8), V1_8(1, 8),
V1_9(1, 9), V1_9(1, 9),
V1_10(1, 10), 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 Logger logger = Logger.getLogger(Version.class);
private static final String VERSION_CONTROL_INFO_FILE = "/current_commit_hash.txt"; private static final String VERSION_CONTROL_INFO_FILE = "/current_commit_hash.txt";
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment