Commit bdfbf052 authored by Daniel Lehmberg's avatar Daniel Lehmberg
Browse files

Merge branches 'change_dataprocessing_text' and 'master' of gitlab.lrz.de:vadere/vadere

parents 12046d17 2a34665d
......@@ -51,7 +51,7 @@ DataProcessingView.msgFileEmpty=File name can't be empty
DataProcessingView.msgFileInUse=File name is already in use
DataProcessingView.dialogInvalidFile.label=Invalid file name
DataProcessingView.dialogOutputDataKeySelection.label=Data Key
DataProcessingView.dialogOutputHeaderSelection.label=Header
DataProcessingView.dialogOutputIndicesSelection.label=Index
ProgressPanelDone.text=Done
ProgressPanelWorking.text=Working...
......@@ -325,7 +325,7 @@ Tab.Model.insertModelNameSubMenu.title=Main models
Tab.Pedestrians.title=Pedestrians
Tab.Topography.title=Topography
Tab.Event.title=Events
Tab.OutputProcessors.title=Data processing GUI
Tab.OutputProcessors.title=Data processing
Tab.TopographyCreator.title=Topography creator
Tab.PostVisualization.title=Post-Visualization
......
......@@ -50,7 +50,7 @@ DataProcessingView.msgFileEmpty=Datei darf nicht leer sein
DataProcessingView.msgFileInUse=Dateiname bereits vorhanden
DataProcessingView.dialogInvalidFile.label=Ung\u00FCltiger Dateiname
DataProcessingView.dialogOutputDataKeySelection.label=Rubrik
DataProcessingView.dialogOutputHeaderSelection.label=Kopfzeile
DataProcessingView.dialogOutputIndicesSelection.label=index
ProgressPanelDone.text=Fertig
ProgressPanelWorking.text=Arbeite...
......
......@@ -580,11 +580,11 @@ class DataProcessingView extends JPanel implements IJsonView {
c.gridx = 0;
c.gridy = 2;
panel.add(new JLabel(Messages.getString("DataProcessingView.dialogOutputHeaderSelection.label")+":"), c);
panel.add(new JLabel(Messages.getString("DataProcessingView.dialogOutputIndicesSelection.label")+":"), c);
c.gridx = 1;
c.gridy = 2;
panel.add(new JLabel(outputFile.getHeader()), c);
panel.add(new JLabel(outputFile.getIndices()), c);
c.gridx = 0;
c.gridy = 3;
......
......@@ -29,7 +29,12 @@ import java.util.stream.Stream;
*/
public abstract class OutputFile<K extends DataKey<K>> {
private String[] keyHeaders;
//Note: Only header information from data keys are written in this, therefore, these are the indices
// Each processor attached to this processor itself attaches also headers, but they are not listed in this
// attribute.
private String[] dataIndices;
/**
* The file name without the path to the file
......@@ -48,8 +53,8 @@ public abstract class OutputFile<K extends DataKey<K>> {
private VadereWriterFactory writerFactory;
private VadereWriter writer;
protected OutputFile(final String... keyHeaders) {
this.keyHeaders = keyHeaders;
protected OutputFile(final String... dataIndices) {
this.dataIndices = dataIndices;
this.dataProcessors = new ArrayList<>();
this.writerFactory = VadereWriterFactory.getFileWriterFactory();
}
......@@ -84,7 +89,7 @@ public abstract class OutputFile<K extends DataKey<K>> {
if (!isEmpty()) {
try (VadereWriter out = writerFactory.create(absoluteFileName)) {
writer = out;
printHeader(out);
printIndices(out);
this.dataProcessors.stream().flatMap(p -> p.getKeys().stream())
.distinct().sorted()
......@@ -101,16 +106,16 @@ public abstract class OutputFile<K extends DataKey<K>> {
return this.dataProcessors.isEmpty();
}
private List<String> getFieldHeaders() {
return composeLine(keyHeaders, p -> Arrays.stream(p.getHeaders()));
private List<String> getDataIndices() {
return composeLine(dataIndices, p -> Arrays.stream(p.getHeaders()));
}
public void printHeader(VadereWriter out) {
writeLine(out, getFieldHeaders());
public void printIndices(VadereWriter out) {
writeLine(out, getDataIndices());
}
public String getHeader() {
return String.join(this.separator, getFieldHeaders());
public String getIndices() {
return String.join(this.separator, getDataIndices());
}
private void printRow(final VadereWriter out, final K key) {
......@@ -133,7 +138,7 @@ public abstract class OutputFile<K extends DataKey<K>> {
}
/**
* Return the column headers as string or the empty array.
* Return the column indices as string or the empty array.
*/
public String[] toStrings(K key) {
return new String[]{key.toString()};
......
......@@ -40,19 +40,19 @@ public class TestOutputFileAfterMultipleRuns {
@Test()
public void testFileFormatAfterMultipleSimulationRuns() {
ArrayList<String> headerAfterFirstRun = new ArrayList<>();
ArrayList<String> headerAfterSecondRun = new ArrayList<>();
ArrayList<String> indicesAfterFirstRun = new ArrayList<>();
ArrayList<String> indicesAfterSecondRun = new ArrayList<>();
ProcessorManager manager = testScenario.getDataProcessingJsonManager()
.createProcessorManager(mainModel);
manager.initOutputFiles();
List<OutputFile<?>> outputFiles = testScenario.getDataProcessingJsonManager().getOutputFiles();
outputFiles.forEach(f -> headerAfterFirstRun.add(f.getHeader()));
outputFiles.forEach(f -> indicesAfterFirstRun.add(f.getIndices()));
manager.initOutputFiles();
outputFiles.forEach(f -> headerAfterSecondRun.add(f.getHeader()));
outputFiles.forEach(f -> indicesAfterSecondRun.add(f.getIndices()));
assertEquals("Duplicated Processors in OutputFile after multiple Simulations",
headerAfterFirstRun, headerAfterSecondRun);
indicesAfterFirstRun, indicesAfterSecondRun);
}
}
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