@Test public void exportData() throws IOException { int numberOfRow = 2; int numberOfColumn = 1; Simulation simulation = createDummySimulation(numberOfColumn, numberOfRow); List<String> exportData = Arrays.asList(scenarioCsvImportExport.exportData(simulation).split("\r\n")); assertEquals(numberOfRow + HEADER_SIZE, exportData.size()); assertEquals("1,My scenario 1,value_1_0", exportData.get(4)); }
public String exportData(AbstractScesimModel<? extends AbstractScesimData> scesimModel) throws IOException { StringBuilder stringBuilder = new StringBuilder(); List<FactMapping> factMappings = scesimModel.getScesimModelDescriptor().getUnmodifiableFactMappings(); CSVPrinter printer = new CSVPrinter(stringBuilder, CSVFormat.DEFAULT); generateHeader(factMappings, printer); for (AbstractScesimData scesimData : scesimModel.getUnmodifiableData()) { List<Object> values = new ArrayList<>(); for (FactMapping factMapping : factMappings) { Optional<FactMappingValue> factMappingValue = scesimData.getFactMappingValue(factMapping.getFactIdentifier(), factMapping.getExpressionIdentifier()); values.add(factMappingValue.map(FactMappingValue::getRawValue).orElse("")); } printer.printRecord(values.toArray()); } printer.close(); return stringBuilder.toString(); }
ScenarioCsvImportExport { public String exportData(AbstractScesimModel<? extends AbstractScesimData> scesimModel) throws IOException { StringBuilder stringBuilder = new StringBuilder(); List<FactMapping> factMappings = scesimModel.getScesimModelDescriptor().getUnmodifiableFactMappings(); CSVPrinter printer = new CSVPrinter(stringBuilder, CSVFormat.DEFAULT); generateHeader(factMappings, printer); for (AbstractScesimData scesimData : scesimModel.getUnmodifiableData()) { List<Object> values = new ArrayList<>(); for (FactMapping factMapping : factMappings) { Optional<FactMappingValue> factMappingValue = scesimData.getFactMappingValue(factMapping.getFactIdentifier(), factMapping.getExpressionIdentifier()); values.add(factMappingValue.map(FactMappingValue::getRawValue).orElse("")); } printer.printRecord(values.toArray()); } printer.close(); return stringBuilder.toString(); } }
ScenarioCsvImportExport { public String exportData(AbstractScesimModel<? extends AbstractScesimData> scesimModel) throws IOException { StringBuilder stringBuilder = new StringBuilder(); List<FactMapping> factMappings = scesimModel.getScesimModelDescriptor().getUnmodifiableFactMappings(); CSVPrinter printer = new CSVPrinter(stringBuilder, CSVFormat.DEFAULT); generateHeader(factMappings, printer); for (AbstractScesimData scesimData : scesimModel.getUnmodifiableData()) { List<Object> values = new ArrayList<>(); for (FactMapping factMapping : factMappings) { Optional<FactMappingValue> factMappingValue = scesimData.getFactMappingValue(factMapping.getFactIdentifier(), factMapping.getExpressionIdentifier()); values.add(factMappingValue.map(FactMappingValue::getRawValue).orElse("")); } printer.printRecord(values.toArray()); } printer.close(); return stringBuilder.toString(); }  }
ScenarioCsvImportExport { public String exportData(AbstractScesimModel<? extends AbstractScesimData> scesimModel) throws IOException { StringBuilder stringBuilder = new StringBuilder(); List<FactMapping> factMappings = scesimModel.getScesimModelDescriptor().getUnmodifiableFactMappings(); CSVPrinter printer = new CSVPrinter(stringBuilder, CSVFormat.DEFAULT); generateHeader(factMappings, printer); for (AbstractScesimData scesimData : scesimModel.getUnmodifiableData()) { List<Object> values = new ArrayList<>(); for (FactMapping factMapping : factMappings) { Optional<FactMappingValue> factMappingValue = scesimData.getFactMappingValue(factMapping.getFactIdentifier(), factMapping.getExpressionIdentifier()); values.add(factMappingValue.map(FactMappingValue::getRawValue).orElse("")); } printer.printRecord(values.toArray()); } printer.close(); return stringBuilder.toString(); }  String exportData(AbstractScesimModel<? extends AbstractScesimData> scesimModel); AbstractScesimModel<T> importData(String raw, AbstractScesimModel<T> originalScesimModel); }
ScenarioCsvImportExport { public String exportData(AbstractScesimModel<? extends AbstractScesimData> scesimModel) throws IOException { StringBuilder stringBuilder = new StringBuilder(); List<FactMapping> factMappings = scesimModel.getScesimModelDescriptor().getUnmodifiableFactMappings(); CSVPrinter printer = new CSVPrinter(stringBuilder, CSVFormat.DEFAULT); generateHeader(factMappings, printer); for (AbstractScesimData scesimData : scesimModel.getUnmodifiableData()) { List<Object> values = new ArrayList<>(); for (FactMapping factMapping : factMappings) { Optional<FactMappingValue> factMappingValue = scesimData.getFactMappingValue(factMapping.getFactIdentifier(), factMapping.getExpressionIdentifier()); values.add(factMappingValue.map(FactMappingValue::getRawValue).orElse("")); } printer.printRecord(values.toArray()); } printer.close(); return stringBuilder.toString(); }  String exportData(AbstractScesimModel<? extends AbstractScesimData> scesimModel); AbstractScesimModel<T> importData(String raw, AbstractScesimModel<T> originalScesimModel); static final int HEADER_SIZE; }