Commit 6cc1e7a2 authored by Benedikt Kleinmeier's avatar Benedikt Kleinmeier
Browse files

Added "TargetVersionV1_10" to remove "threatMemory" node

parent dab8187a
......@@ -34,6 +34,7 @@ public enum Version {
V1_7(1,7),
V1_8(1, 8),
V1_9(1, 9),
V1_10(1, 10),
;
......
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.entrypoints.Version;
import org.vadere.simulator.projects.migration.MigrationException;
import org.vadere.simulator.projects.migration.jsontranformation.SimpleJsonTransformation;
/**
* Remove node "threatMemory" under "scenario.topography.dynamicElements.psychologyStatus"
*/
@MigrationTransformation(targetVersionLabel = "1.10")
public class TargetVersionV1_10 extends SimpleJsonTransformation {
public TargetVersionV1_10(){
super(Version.V1_10);
}
@Override
protected void initDefaultHooks() {
addPostHookFirst(this::removeThreatMemoryNode);
addPostHookLast(this::sort);
}
public JsonNode removeThreatMemoryNode(JsonNode node) throws MigrationException {
String nodeNameToRemove = "threatMemory";
JsonNode dynamicElementsNode = path(node, "scenario/topography/dynamicElements");
if (dynamicElementsNode.isArray()) {
for (JsonNode dynamicElementNode : dynamicElementsNode) {
JsonNode psychologyStatusNode = path(dynamicElementNode, "psychologyStatus");
remove(psychologyStatusNode, nodeNameToRemove);
}
}
return node;
}
}
Markdown is supported
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