Merge pull request #85 from Echtzeitsysteme/hotfix/dissscenarioload-various-fixes

Various fixes for the DissScenarioLoader
This commit is contained in:
Maximilian Kratz 2024-06-28 08:42:11 +02:00 committed by GitHub
commit e3bf3a5282
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 25 additions and 2 deletions

4
.gitignore vendored
View file

@ -141,3 +141,7 @@ org.emoflon.gips.gipsl.examples.mdvne.seq/
*.lp
org.emoflon.gips.gipsl.examples.mdvne.bwignore/
vne.scenarios/model.xmi
vne.scenarios/metrics/

View file

@ -1,6 +1,7 @@
package scenario.util;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.nio.file.Files;
@ -237,6 +238,23 @@ public class CsvUtil {
return;
}
if (format == null) {
throw new IllegalArgumentException("Given CSV format was null");
}
if (content == null || content.length == 0) {
throw new IllegalArgumentException("Given content was null or empty.");
}
// Create parent folder if it does not exist
final int lastSlash = csvPath.lastIndexOf('/');
final String parentPath = csvPath.substring(0, lastSlash);
final File parentFolder = new File(parentPath);
if (!parentFolder.exists()) {
parentFolder.mkdir();
}
// Write CSV line itself
try {
BufferedWriter out;
// If file does not exist, write header to it

View file

@ -152,11 +152,12 @@ public class DissScenarioLoad {
* Evaluation.
*/
// Print metrics before saving the model
printMetrics();
// Save model to file
ModelFacade.getInstance().persistModel();
System.out.println("=> Execution finished.");
printMetrics();
System.exit(0);
}