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 7abc786b authored by Mario Teixeira Parente's avatar Mario Teixeira Parente
Browse files

Rename 'Processor' base class to 'DataProcessor'

parent a2e6a08b
......@@ -11,7 +11,7 @@
"startTime" : 0.0,
"endTime" : 1.7976931348623157E308
},
"processor" : {
"dataProcessor" : {
"pedestrianWaitingTimeProcessor" : {
"attributes" : {
"waitingArea" : {
......@@ -41,7 +41,7 @@
"startTime" : 0.0,
"endTime" : 1.7976931348623157E308
},
"processor" : {
"dataProcessor" : {
"attributes" : {
"maxEvacuationTime" : 1.0,
"maxEvacuationTimeMean" : 1.0,
......
......@@ -11,7 +11,7 @@
"startTime" : 0.0,
"endTime" : 1.7976931348623157E308
},
"processor" : {
"dataProcessor" : {
"pedestrianWaitingTimeProcessor" : {
"attributes" : {
"waitingArea" : {
......@@ -41,7 +41,7 @@
"startTime" : 0.0,
"endTime" : 1.7976931348623157E308
},
"processor" : {
"dataProcessor" : {
"attributes" : {
"maxEvacuationTime" : 1.0,
"maxEvacuationTimeMean" : 1.0,
......@@ -60,7 +60,7 @@
"startTime" : 0.0,
"endTime" : 1.7976931348623157E308
},
"processor" : {
"dataProcessor" : {
"densityProcessor" : {
"attributes" : {
"scale" : 10.0,
......
......@@ -11,7 +11,7 @@
"startTime" : 0.0,
"endTime" : 1.7976931348623157E308
},
"processor" : {
"dataProcessor" : {
"pedestrianWaitingTimeProcessor" : {
"attributes" : {
"waitingArea" : {
......@@ -41,7 +41,7 @@
"startTime" : 0.0,
"endTime" : 1.7976931348623157E308
},
"processor" : {
"dataProcessor" : {
"attributes" : {
"maxEvacuationTime" : 1.0,
"maxEvacuationTimeMean" : 1.0,
......
......@@ -11,7 +11,7 @@
"startTime" : 0.0,
"endTime" : 1.7976931348623157E308
},
"processor" : {
"dataProcessor" : {
"pedestrianWaitingTimeProcessor" : {
"attributes" : {
"waitingArea" : {
......@@ -41,7 +41,7 @@
"startTime" : 0.0,
"endTime" : 1.7976931348623157E308
},
"processor" : {
"dataProcessor" : {
"attributes" : {
"maxEvacuationTime" : 1.0,
"maxEvacuationTimeMean" : 1.0,
......
......@@ -11,7 +11,7 @@
"startTime" : 0.0,
"endTime" : 1.7976931348623157E308
},
"processor" : {
"dataProcessor" : {
"pedestrianWaitingTimeProcessor" : {
"attributes" : {
"waitingArea" : {
......@@ -41,7 +41,7 @@
"startTime" : 0.0,
"endTime" : 1.7976931348623157E308
},
"processor" : {
"dataProcessor" : {
"attributes" : {
"maxEvacuationTime" : 1.0,
"maxEvacuationTimeMean" : 1.0,
......
......@@ -11,7 +11,7 @@
"startTime" : 0.0,
"endTime" : 1.7976931348623157E308
},
"processor" : {
"dataProcessor" : {
"pedestrianWaitingTimeProcessor" : {
"attributes" : {
"waitingArea" : {
......@@ -41,7 +41,7 @@
"startTime" : 0.0,
"endTime" : 1.7976931348623157E308
},
"processor" : {
"dataProcessor" : {
"attributes" : {
"maxEvacuationTime" : 1.0,
"maxEvacuationTimeMean" : 1.0,
......
......@@ -11,7 +11,7 @@
"startTime" : 0.0,
"endTime" : 1.7976931348623157E308
},
"processor" : {
"dataProcessor" : {
"attributes" : {
"maxEvacuationTime" : 34.0,
"maxEvacuationTimeMean" : 34.0,
......
......@@ -11,7 +11,7 @@
"startTime" : 0.0,
"endTime" : 1.7976931348623157E308
},
"processor" : {
"dataProcessor" : {
"attributes" : {
"maxEvacuationTime" : 34.0,
"maxEvacuationTimeMean" : 34.0,
......
......@@ -11,7 +11,7 @@
"startTime" : 0.0,
"endTime" : 1.7976931348623157E308
},
"processor" : {
"dataProcessor" : {
"attributes" : {
"maxEvacuationTime" : 70.0,
"maxEvacuationTimeMean" : 50.0,
......@@ -30,7 +30,7 @@
"startTime" : 0.0,
"endTime" : 1.7976931348623157E308
},
"processor" : {
"dataProcessor" : {
"pedestrianWaitingTimeProcessor" : {
"attributes" : {
"waitingArea" : {
......
......@@ -11,7 +11,7 @@
"startTime" : 0.0,
"endTime" : 1.7976931348623157E308
},
"processor" : {
"dataProcessor" : {
"attributes" : {
"maxEvacuationTime" : 140.0,
"maxEvacuationTimeMean" : 140.0,
......
......@@ -11,7 +11,7 @@
"startTime" : 0.0,
"endTime" : 1.7976931348623157E308
},
"processor" : {
"dataProcessor" : {
"columnNames" : [ ],
"clazz" : "PedestrianLastPositionProcessor"
}
......
......@@ -11,7 +11,7 @@
"startTime" : 0.0,
"endTime" : 1.7976931348623157E308
},
"processor" : {
"dataProcessor" : {
"pedestrianDensityProcessor" : {
"densityProcessor" : {
"attributes" : {
......@@ -52,7 +52,7 @@
"startTime" : 0.0,
"endTime" : 1.7976931348623157E308
},
"processor" : {
"dataProcessor" : {
"pedestrianDensityProcessor" : {
"densityProcessor" : {
"attributes" : {
......@@ -93,7 +93,7 @@
"startTime" : 0.0,
"endTime" : 1.7976931348623157E308
},
"processor" : {
"dataProcessor" : {
"attributes" : {
"maxEvacuationTime" : 200.0,
"maxEvacuationTimeMean" : 150.0,
......
......@@ -12,9 +12,9 @@ import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import org.vadere.simulator.projects.dataprocessing.outputfile.OutputFile;
import org.vadere.simulator.projects.dataprocessing.processor.Processor;
import org.vadere.simulator.projects.dataprocessing.processor.DataProcessor;
import org.vadere.simulator.projects.dataprocessing.store.DataProcessorStore;
import org.vadere.simulator.projects.dataprocessing.store.OutputFileStore;
import org.vadere.simulator.projects.dataprocessing.store.ProcessorStore;
import org.vadere.simulator.projects.io.JsonConverter;
import org.vadere.state.attributes.processor.AttributesProcessor;
import org.vadere.util.reflection.DynamicClassInstantiator;
......@@ -48,19 +48,19 @@ public class DataProcessingJsonManager {
public static ObjectWriter writer;
private static final DynamicClassInstantiator<OutputFile<?>> outputFileInstantiator;
private static final DynamicClassInstantiator<Processor<?, ?>> processorInstantiator;
private static final DynamicClassInstantiator<DataProcessor<?, ?>> processorInstantiator;
private List<OutputFile<?>> outputFiles;
private List<Processor<?, ?>> processors;
private List<DataProcessor<?, ?>> dataProcessors;
static {
mapper = JsonConverter.getMapper();
writer = mapper.writerWithDefaultPrettyPrinter();
SimpleModule sm = new SimpleModule();
sm.addDeserializer(ProcessorStore.class, new JsonDeserializer<ProcessorStore>() {
sm.addDeserializer(DataProcessorStore.class, new JsonDeserializer<DataProcessorStore>() {
@Override
public ProcessorStore deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
public DataProcessorStore deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
return null;
......@@ -74,7 +74,7 @@ public class DataProcessingJsonManager {
public DataProcessingJsonManager() {
this.outputFiles = new ArrayList<>();
this.processors = new ArrayList<>();
this.dataProcessors = new ArrayList<>();
}
public void addOutputFile(final OutputFileStore fileStore) {
......@@ -88,11 +88,11 @@ public class DataProcessingJsonManager {
this.outputFiles.add(file);
}
public void addProcessor(final ProcessorStore processorStore) {
Processor<?, ?> processor = processorInstantiator.createObject(processorStore.getType());
processor.setId(processorStore.getId());
processor.setAttributes(processorStore.getAttributes());
this.processors.add(processor);
public void addProcessor(final DataProcessorStore dataProcessorStore) {
DataProcessor<?, ?> dataProcessor = processorInstantiator.createObject(dataProcessorStore.getType());
dataProcessor.setId(dataProcessorStore.getId());
dataProcessor.setAttributes(dataProcessorStore.getAttributes());
this.dataProcessors.add(dataProcessor);
}
private static JsonNode serializeOutputFile(final OutputFile outputFile) {
......@@ -110,17 +110,17 @@ public class DataProcessingJsonManager {
return node;
}
private static JsonNode serializeProcessor(final Processor processor) {
private static JsonNode serializeProcessor(final DataProcessor dataProcessor) {
ObjectNode node = mapper.createObjectNode();
node.put(TYPE_KEY, processor.getClass().getName());
node.put(PROCESSORID_KEY, processor.getId());
node.put(TYPE_KEY, dataProcessor.getClass().getName());
node.put(PROCESSORID_KEY, dataProcessor.getId());
if (processor.getAttributes() != null) {
node.put(ATTRIBUTESTYPE_KEY, processor.getAttributes().getClass().getName());
if (dataProcessor.getAttributes() != null) {
node.put(ATTRIBUTESTYPE_KEY, dataProcessor.getAttributes().getClass().getName());
if (!processor.getAttributes().getClass().equals(AttributesProcessor.class)) {
node.set(ATTRIBUTES_KEY, mapper.convertValue(processor.getAttributes(), JsonNode.class));
if (!dataProcessor.getAttributes().getClass().equals(AttributesProcessor.class)) {
node.set(ATTRIBUTES_KEY, mapper.convertValue(dataProcessor.getAttributes(), JsonNode.class));
}
}
......@@ -143,7 +143,7 @@ public class DataProcessingJsonManager {
});
// part 2: processor
this.processors.forEach(proc -> {
this.dataProcessors.forEach(proc -> {
processorsArrayNode.add(serializeProcessor(proc));
});
......@@ -192,15 +192,15 @@ public class DataProcessingJsonManager {
// part 2: processor
if (processorsArrayNode != null)
for (JsonNode processorNode : processorsArrayNode) {
ProcessorStore processorStore = deserializeProcessorStore(processorNode);
manager.addProcessor(processorStore);
DataProcessorStore dataProcessorStore = deserializeProcessorStore(processorNode);
manager.addProcessor(dataProcessorStore);
}
return manager;
}
private static ProcessorStore deserializeProcessorStore(JsonNode node) {
ProcessorStore store = new ProcessorStore();
private static DataProcessorStore deserializeProcessorStore(JsonNode node) {
DataProcessorStore store = new DataProcessorStore();
store.setType(node.get(TYPE_KEY).asText());
store.setId(node.get(PROCESSORID_KEY).asInt());
......@@ -221,6 +221,6 @@ public class DataProcessingJsonManager {
}
public ProcessorManager createProcessorManager() {
return new ProcessorManager(this, this.processors, this.outputFiles);
return new ProcessorManager(this, this.dataProcessors, this.outputFiles);
}
}
......@@ -2,7 +2,7 @@ package org.vadere.simulator.projects.dataprocessing;
import org.vadere.simulator.projects.dataprocessing.store.OutputDefinitionStore;
import org.vadere.simulator.projects.dataprocessing.store.OutputFileStore;
import org.vadere.simulator.projects.dataprocessing.store.ProcessorStore;
import org.vadere.simulator.projects.dataprocessing.store.DataProcessorStore;
import java.util.Arrays;
......@@ -13,12 +13,12 @@ public final class OutputPresets {
private OutputPresets() {
this.outputDefinition = new OutputDefinitionStore();
ProcessorStore processor1 = new ProcessorStore();
DataProcessorStore processor1 = new DataProcessorStore();
processor1.setType("org.vadere.simulator.projects.dataprocessing.processor.PedestrianPositionProcessor");
processor1.setId(1);
this.outputDefinition.addProcessor(processor1);
ProcessorStore processor2 = new ProcessorStore();
DataProcessorStore processor2 = new DataProcessorStore();
processor2.setType("org.vadere.simulator.projects.dataprocessing.processor.PedestrianTargetIdProcessor");
processor2.setId(2);
this.outputDefinition.addProcessor(processor2);
......
......@@ -6,7 +6,7 @@ import com.fasterxml.jackson.databind.JsonNode;
import org.vadere.simulator.control.SimulationState;
import org.vadere.simulator.models.Model;
import org.vadere.simulator.projects.dataprocessing.outputfile.OutputFile;
import org.vadere.simulator.projects.dataprocessing.processor.Processor;
import org.vadere.simulator.projects.dataprocessing.processor.DataProcessor;
import org.vadere.util.io.IOUtils;
import java.util.LinkedHashMap;
......@@ -18,19 +18,19 @@ public class ProcessorManager {
private Model model;
private Map<Integer, Processor<?, ?>> processorMap;
private Map<Integer, DataProcessor<?, ?>> processorMap;
private List<OutputFile<?>> outputFiles;
public ProcessorManager(DataProcessingJsonManager jsonManager, List<Processor<?, ?>> processors, List<OutputFile<?>> outputFiles) {
public ProcessorManager(DataProcessingJsonManager jsonManager, List<DataProcessor<?, ?>> dataProcessors, List<OutputFile<?>> outputFiles) {
this.jsonManager = jsonManager;
this.outputFiles = outputFiles;
this.processorMap = new LinkedHashMap<>();
for (Processor<?, ?> proc : processors)
for (DataProcessor<?, ?> proc : dataProcessors)
this.processorMap.put(proc.getId(), proc);
processors.forEach(proc -> proc.init(this));
dataProcessors.forEach(proc -> proc.init(this));
}
public void setModel(Model model) {
......@@ -41,7 +41,7 @@ public class ProcessorManager {
outputFiles.forEach(file -> file.init(this));
}
public Processor<?, ?> getProcessor(int id) {
public DataProcessor<?, ?> getProcessor(int id) {
return this.processorMap.containsKey(id) ? this.processorMap.get(id) : null;
}
......
package org.vadere.simulator.projects.dataprocessing.outputfile;
import org.vadere.simulator.projects.dataprocessing.ProcessorManager;
import org.vadere.simulator.projects.dataprocessing.processor.Processor;
import org.vadere.simulator.projects.dataprocessing.processor.DataProcessor;
import java.io.FileWriter;
import java.io.IOException;
......@@ -20,13 +20,13 @@ public abstract class OutputFile<K extends Comparable<K>> {
private String fileName;
private List<Integer> processorIds;
private List<Processor<K, ?>> processors;
private List<DataProcessor<K, ?>> dataProcessors;
private String separator;
OutputFile(final String... keyHeaders) {
this.keyHeaders = keyHeaders;
this.processors = new ArrayList<>();
this.dataProcessors = new ArrayList<>();
}
public void setFileName(final String fileName) {
......@@ -35,7 +35,7 @@ public abstract class OutputFile<K extends Comparable<K>> {
public void setProcessorIds(final List<Integer> processorIds) {
this.processorIds = processorIds;
this.processors.clear();
this.dataProcessors.clear();
}
public String getSeparator() {
......@@ -48,14 +48,14 @@ public abstract class OutputFile<K extends Comparable<K>> {
@SuppressWarnings("unchecked")
public void init(final ProcessorManager manager) {
processorIds.forEach(pid -> this.processors.add((Processor<K, ?>) manager.getProcessor(pid)));
processorIds.forEach(pid -> this.dataProcessors.add((DataProcessor<K, ?>) manager.getProcessor(pid)));
}
public void write() {
try (PrintWriter out = new PrintWriter(new FileWriter(fileName))) {
printHeader(out);
this.processors.stream().flatMap(p -> p.getKeys().stream())
this.dataProcessors.stream().flatMap(p -> p.getKeys().stream())
.distinct().sorted()
.forEach(key -> printRow(out, key));
......@@ -76,10 +76,10 @@ public abstract class OutputFile<K extends Comparable<K>> {
writeLine(out, fields);
}
private List<String> composeLine(String[] keyFieldArray, @SuppressWarnings("rawtypes") Function<Processor, Stream<String>> valueFields) {
private List<String> composeLine(String[] keyFieldArray, @SuppressWarnings("rawtypes") Function<DataProcessor, Stream<String>> valueFields) {
final List<String> fields = new LinkedList<>(Arrays.asList(keyFieldArray));
final List<String> processorFields = processors.stream()
final List<String> processorFields = dataProcessors.stream()
.flatMap(valueFields)
.collect(Collectors.toList());
fields.addAll(processorFields);
......
......@@ -5,7 +5,7 @@ import org.vadere.simulator.projects.dataprocessing.datakey.TimestepDataKey;
import org.vadere.state.attributes.processor.AttributesAreaProcessor;
import org.vadere.util.geometry.shapes.VRectangle;
public abstract class AreaProcessor<V> extends Processor<TimestepDataKey, V> {
public abstract class AreaDataProcessor<V> extends DataProcessor<TimestepDataKey, V> {
private VRectangle measurementArea;
@Override
......
......@@ -3,7 +3,7 @@ package org.vadere.simulator.projects.dataprocessing.processor;
import org.vadere.simulator.control.SimulationState;
import org.vadere.simulator.projects.dataprocessing.datakey.TimestepDataKey;
public abstract class AreaDensityProcessor extends AreaProcessor<Double> {
public abstract class AreaDensityProcessor extends AreaDataProcessor<Double> {
private IAreaDensityAlgorithm densAlg;
protected void setAlgorithm(final IAreaDensityAlgorithm densAlg) {
......
......@@ -10,7 +10,7 @@ import org.vadere.util.geometry.shapes.VPoint;
import java.util.Map;
public class AreaSpeedProcessor extends AreaProcessor<Double> {
public class AreaSpeedProcessor extends AreaDataProcessor<Double> {
private PedestrianPositionProcessor pedPosProc;
private PedestrianVelocityProcessor pedVelProc;
......
......@@ -9,7 +9,7 @@ import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
public abstract class Processor<K extends Comparable<K>, V> {
public abstract class DataProcessor<K extends Comparable<K>, V> {
private int id;
private AttributesProcessor attributes;
......@@ -18,11 +18,11 @@ public abstract class Processor<K extends Comparable<K>, V> {
private int lastStep;
protected Processor() {
protected DataProcessor() {
this(new String[] { });
}
protected Processor(final String... headers) {
protected DataProcessor(final String... headers) {
this.headers = headers;
this.data = new TreeMap<>(); // TreeMap to avoid sorting data later
......
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