Notice to GitKraken users: A vulnerability has been found in the SSH key generation of GitKraken versions 7.6.0 to 8.0.0 (https://www.gitkraken.com/blog/weak-ssh-key-fix). If you use GitKraken and have generated a SSH key using one of these versions, please remove it both from your local workstation and from your LRZ GitLab profile.

21.10.2021, 9:00 - 11:00: Due to updates GitLab may be unavailable for some minutes between 09:00 and 11:00.

Commit b1915139 authored by Benedikt Kleinmeier's avatar Benedikt Kleinmeier
Browse files

Implemented migration "TargetVersionV1_9" to removed "perceivedThreat" node

parent a58595fa
......@@ -33,6 +33,7 @@ public enum Version {
V1_6(1,6),
V1_7(1,7),
V1_8(1, 8),
V1_9(1, 9),
;
......
......@@ -49,7 +49,7 @@ import org.vadere.simulator.projects.migration.jsontranformation.SimpleJsonTrans
* - "salientBehavior" to "selfCategory" in "dynamicElement" nodes
*
* After renaming, encapsulate two psychology-related attributes into
* a new "psychlogy" node in "dynamicElement" nodes:
* a new "psychology" node in "dynamicElement" nodes:
* - mostImportantStimulus
* - selfCategory
*
......
package org.vadere.simulator.projects.migration.jsontranformation.json;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
import com.fasterxml.jackson.databind.node.ObjectNode;
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 "perceivedThreat" under "scenario.topography.dynamicElements.psychologyStatus"
*/
@MigrationTransformation(targetVersionLabel = "1.9")
public class TargetVersionV1_9 extends SimpleJsonTransformation {
public TargetVersionV1_9(){
super(Version.V1_9);
}
@Override
protected void initDefaultHooks() {
addPostHookFirst(this::removePerceivedThreatNode);
addPostHookLast(this::sort);
}
public JsonNode removePerceivedThreatNode(JsonNode node) throws MigrationException {
String nodeNameToRemove = "perceivedThreat";
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