Commit 7ec93995 authored by Benedikt Kleinmeier's avatar Benedikt Kleinmeier

Renamed "FootStepMostImportantEventProcessor" to...

Renamed "FootStepMostImportantEventProcessor" to "FootStepMostImportantStimulusProcessor" and extended JSON transformation
parent 16d4593b
......@@ -54,7 +54,7 @@ public class TableTrajectoryFootStep {
public final int groupIdCol;
public final int groupSizeCol;
private final int mostImportantEventCol;
private final int mostImportantStimulusCol;
private final int salientBehaviorCol;
public static final int agentDFPedIdCol = 0;
......@@ -84,7 +84,7 @@ public class TableTrajectoryFootStep {
targetIdCol = columnNames.getTargetIdCol(dataFrame);
groupIdCol = columnNames.getGroupIdCol(dataFrame);
groupSizeCol = columnNames.getGroupSizeCol(dataFrame);
mostImportantEventCol = columnNames.getMostImportantEventCol(dataFrame);
mostImportantStimulusCol = columnNames.getMostImportantEventCol(dataFrame);
salientBehaviorCol = columnNames.getSalientBehaviorCol(dataFrame);
......@@ -137,14 +137,14 @@ public class TableTrajectoryFootStep {
pedestrian.getGroupSizes().add(groupSize);
}
if(mostImportantEventCol != ColumnNames.NOT_SET_COLUMN_INDEX_IDENTIFIER) {
String mostImportantEventClassName = row.getString(mostImportantEventCol);
Stimulus stimulus = StimulusFactory.stringToStimulus(mostImportantEventClassName);
if(mostImportantStimulusCol != ColumnNames.NOT_SET_COLUMN_INDEX_IDENTIFIER) {
String mostImportantStimulusClassName = row.getString(mostImportantStimulusCol);
Stimulus stimulus = StimulusFactory.stringToStimulus(mostImportantStimulusClassName);
pedestrian.setMostImportantStimulus(stimulus);
}
if(salientBehaviorCol != ColumnNames.NOT_SET_COLUMN_INDEX_IDENTIFIER) {
String salientBehaviorEnumName = row.getString(mostImportantEventCol);
String salientBehaviorEnumName = row.getString(mostImportantStimulusCol);
SalientBehavior salientBehavior = SalientBehavior.valueOf(salientBehaviorEnumName);
pedestrian.setSalientBehavior(salientBehavior);
}
......
......@@ -28,7 +28,7 @@ import java.util.stream.Collectors;
* For instance:
* <pre>
* ...
* if (mostImportantEvent instanceof Wait) {
* if (mostImportantStimulus instanceof Wait) {
* osmBehaviorController.wait()
* }
* ...
......
......@@ -10,13 +10,15 @@ import org.vadere.state.simulation.VTrajectory;
import java.util.Collection;
/**
* Save most important event of a pedestrian in each time step in an own column.
* Save most important stimulus of a pedestrian in each time step in an own column.
*/
@DataProcessorClass()
public class FootStepMostImportantEventProcessor extends DataProcessor<EventtimePedestrianIdKey, String> {
public class FootStepMostImportantStimulusProcessor extends DataProcessor<EventtimePedestrianIdKey, String> {
public FootStepMostImportantEventProcessor() {
super("mostImportantEvent");
public static String HEADER = "mostImportantStimulus";
public FootStepMostImportantStimulusProcessor() {
super(HEADER);
}
@Override
......@@ -25,9 +27,9 @@ public class FootStepMostImportantEventProcessor extends DataProcessor<Eventtime
for(Pedestrian p : pedestrians){
VTrajectory traj = p.getTrajectory();
String mostImportantEvent = p.getMostImportantStimulus().toStringForOutputProcessor();
String mostImportantStimulus = p.getMostImportantStimulus().toStringForOutputProcessor();
for(FootStep fs : traj.getFootSteps()){
this.putValue(new EventtimePedestrianIdKey(fs.getStartTime(), p.getId()), mostImportantEvent);
this.putValue(new EventtimePedestrianIdKey(fs.getStartTime(), p.getId()), mostImportantStimulus);
}
}
}
......
......@@ -20,7 +20,7 @@ public final class ColumnNames {
private Set<String> groupSizeKeys;
private Set<String> startTimeKeys;
private Set<String> endTimeKeys;
private Set<String> mostImportantEventKeys;
private Set<String> mostImportantStimulusKeys;
private Set<String> salientBehaviorKeys;
private List<Set<String>> keys;
......@@ -45,7 +45,7 @@ public final class ColumnNames {
targetIdKeys = new HashSet<>();
groupIdKeys = new HashSet<>();
groupSizeKeys = new HashSet<>();
mostImportantEventKeys = new HashSet<>();
mostImportantStimulusKeys = new HashSet<>();
salientBehaviorKeys = new HashSet<>();
startTimeKeys = new HashSet<>();
endTimeKeys = new HashSet<>();
......@@ -67,7 +67,7 @@ public final class ColumnNames {
targetIdKeys.add("targetId");
groupIdKeys.add("groupId");
groupSizeKeys.add("groupSize");
mostImportantEventKeys.add("mostImportantEvent");
mostImportantStimulusKeys.add("mostImportantStimulus");
salientBehaviorKeys.add("salientBehavior");
keys.add(pedestrianIdKeys);
......@@ -78,7 +78,7 @@ public final class ColumnNames {
keys.add(targetIdKeys);
keys.add(groupIdKeys);
keys.add(groupSizeKeys);
keys.add(mostImportantEventKeys);
keys.add(mostImportantStimulusKeys);
keys.add(salientBehaviorKeys);
keys.add(startTimeKeys);
keys.add(endTimeKeys);
......@@ -89,7 +89,7 @@ public final class ColumnNames {
}
public int getMostImportantEventCol(@NotNull final Table dataFrame) {
return getColId(dataFrame, mostImportantEventKeys);
return getColId(dataFrame, mostImportantStimulusKeys);
}
public int getPedestrianIdCol(@NotNull final Table dataFrame) {
......
......@@ -39,9 +39,11 @@ import org.vadere.simulator.projects.migration.jsontranformation.SimpleJsonTrans
* } ]
* </pre>
*
* Firstly, rename children nodes. Then, rename top-level "eventInfos" node.
* Firstly, rename child nodes. Then, rename top-level "eventInfos" node.
*
* Also, rename "useSalientBehavior" to "usePsychologyLayer" under
* Also, rename
* - "useSalientBehavior" to "usePsychologyLayer" under "attributesSimulation" node
* - "FootStepMostImportantEventProcessor" to "FootStepMostImportantStimulusProcessor"
*/
@MigrationTransformation(targetVersionLabel = "1.5")
public class JsonTransformationV1_4ToV1_5 extends SimpleJsonTransformation {
......@@ -63,11 +65,11 @@ public class JsonTransformationV1_4ToV1_5 extends SimpleJsonTransformation {
renameEventInfosToStimulusInfos(node);
renameMostImportantEventInDynamicElements(node);
renameUseSalientBehavior(node);
renameOutputProcessorMostImportantEvent(node);
return node;
}
private void renameTimeframes(JsonNode node) throws MigrationException {
String oldName = "eventTimeframe";
String newName = "timeframe";
......@@ -167,4 +169,23 @@ public class JsonTransformationV1_4ToV1_5 extends SimpleJsonTransformation {
}
}
private void renameOutputProcessorMostImportantEvent(JsonNode node) throws MigrationException {
String oldName = "FootStepMostImportantEventProcessor";
String newName = "FootStepMostImportantStimulusProcessor";
JsonNode processorsNode = path(node, "processWriters/processors");
if (processorsNode.isArray()) {
for (JsonNode processorNode : processorsNode) {
String key = "type";
String processorName = processorNode.get(key).asText("");
if (processorName.contains(oldName)) {
String newProcessorName = processorName.replace(oldName, newName);
changeStringValue(processorNode, key, newProcessorName);
}
}
}
}
}
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