Search in sources :

Example 1 with ExporterSpreadsheet

use of org.gephi.io.exporter.plugin.ExporterSpreadsheet in project gephi by gephi.

the class UIExporterSpreadsheetPanel method setup.

public void setup(ExporterSpreadsheet exporter) {
    ExporterSpreadsheet.ExportTable tableToExport = exporter.getTableToExport();
    if (tableToExport != null) {
        tableComboBox.setSelectedIndex(tableToExport == ExporterSpreadsheet.ExportTable.NODES ? 0 : 1);
    }
    ProjectController projectController = Lookup.getDefault().lookup(ProjectController.class);
    graphModel = projectController.getCurrentWorkspace().getLookup().lookup(GraphModel.class);
    refreshColumns();
}
Also used : ExporterSpreadsheet(org.gephi.io.exporter.plugin.ExporterSpreadsheet) GraphModel(org.gephi.graph.api.GraphModel) ProjectController(org.gephi.project.api.ProjectController)

Example 2 with ExporterSpreadsheet

use of org.gephi.io.exporter.plugin.ExporterSpreadsheet in project gephi by gephi.

the class SpreadsheetNGTest method checkNodesSpreadsheet.

private void checkNodesSpreadsheet() throws IOException {
    File tmpFile = File.createTempFile(testName, ".csv");
    Writer writer = new OutputStreamWriter(new FileOutputStream(tmpFile), "UTF-8");
    ExporterSpreadsheet exporter = new ExporterSpreadsheet();
    exporter.setWorkspace(workspace);
    exporter.setTableToExport(ExporterSpreadsheet.ExportTable.NODES);
    exporter.setWriter(writer);
    exporter.execute();
    String result = Files.readFile(tmpFile).trim().replace("\r", "");
    String expected = Files.readFile(SpreadsheetNGTest.class.getResourceAsStream("/org/gephi/io/importer/plugin/file/spreadsheet/expected/" + testName + "_nodes.csv")).trim();
    Assert.assertEquals(result, expected);
}
Also used : ExporterSpreadsheet(org.gephi.io.exporter.plugin.ExporterSpreadsheet) FileOutputStream(java.io.FileOutputStream) OutputStreamWriter(java.io.OutputStreamWriter) File(java.io.File) OutputStreamWriter(java.io.OutputStreamWriter) Writer(java.io.Writer)

Example 3 with ExporterSpreadsheet

use of org.gephi.io.exporter.plugin.ExporterSpreadsheet in project gephi by gephi.

the class SpreadsheetNGTest method checkEdgesSpreadsheet.

private void checkEdgesSpreadsheet(boolean ignoreId) throws IOException {
    File tmpFile = File.createTempFile(testName, ".csv");
    Writer writer = new OutputStreamWriter(new FileOutputStream(tmpFile), "UTF-8");
    ExporterSpreadsheet exporter = new ExporterSpreadsheet();
    exporter.setWorkspace(workspace);
    exporter.setTableToExport(ExporterSpreadsheet.ExportTable.EDGES);
    exporter.setWriter(writer);
    if (ignoreId) {
        Table edgeTable = graphController.getGraphModel(workspace).getEdgeTable();
        LinkedHashSet<String> columnIdsToExport = new LinkedHashSet<>();
        for (Column column : edgeTable) {
            if (!column.getId().equals("id")) {
                columnIdsToExport.add(column.getId());
            }
        }
        exporter.setColumnIdsToExport(columnIdsToExport);
    }
    exporter.execute();
    String result = Files.readFile(tmpFile).trim().replace("\r", "");
    String expected = Files.readFile(SpreadsheetNGTest.class.getResourceAsStream("/org/gephi/io/importer/plugin/file/spreadsheet/expected/" + testName.replace("_AutoDetectImporter", "") + "_edges.csv")).trim();
    Assert.assertEquals(result, expected);
}
Also used : LinkedHashSet(java.util.LinkedHashSet) Table(org.gephi.graph.api.Table) ExporterSpreadsheet(org.gephi.io.exporter.plugin.ExporterSpreadsheet) Column(org.gephi.graph.api.Column) FileOutputStream(java.io.FileOutputStream) OutputStreamWriter(java.io.OutputStreamWriter) File(java.io.File) OutputStreamWriter(java.io.OutputStreamWriter) Writer(java.io.Writer)

Aggregations

ExporterSpreadsheet (org.gephi.io.exporter.plugin.ExporterSpreadsheet)3 File (java.io.File)2 FileOutputStream (java.io.FileOutputStream)2 OutputStreamWriter (java.io.OutputStreamWriter)2 Writer (java.io.Writer)2 LinkedHashSet (java.util.LinkedHashSet)1 Column (org.gephi.graph.api.Column)1 GraphModel (org.gephi.graph.api.GraphModel)1 Table (org.gephi.graph.api.Table)1 ProjectController (org.gephi.project.api.ProjectController)1