Search in sources :

Example 1 with SimpleCSVExporter

use of com.mercedesbenz.sechub.developertools.admin.importer.SimpleCSVExporter in project sechub by mercedes-benz.

the class ExportJSONToCSVAdapterDialogAction method execute.

@Override
protected void execute(ActionEvent e) throws Exception {
    /* convert to rows */
    String json = getMappingUI().getJSON();
    List<CSVRow> rows = csvSupport.toCSVRows(MappingData.fromString(json));
    /* select */
    String defaultPath = ConfigurationSetup.SECHUB_MASS_OPERATION_PARENTDIRECTORY.getStringValue(System.getProperty("user.home"));
    File defaultFile = new File(defaultPath, getMappingUI().getMappingId() + ".csv");
    File file = getDialogUI().getContext().getDialogUI().selectFile(defaultFile.getAbsolutePath());
    if (file == null) {
        return;
    }
    /* export */
    SimpleCSVExporter exporter = new SimpleCSVExporter();
    exporter.exportCSVFile(file, rows, 3);
    /* inform */
    getDialogUI().getContext().getOutputUI().output("Exported to CSV file:" + file.getAbsolutePath());
}
Also used : SimpleCSVExporter(com.mercedesbenz.sechub.developertools.admin.importer.SimpleCSVExporter) CSVRow(com.mercedesbenz.sechub.developertools.admin.importer.CSVRow) File(java.io.File)

Aggregations

CSVRow (com.mercedesbenz.sechub.developertools.admin.importer.CSVRow)1 SimpleCSVExporter (com.mercedesbenz.sechub.developertools.admin.importer.SimpleCSVExporter)1 File (java.io.File)1