NullPointerException on exporting dynamic GEXF file with Toolkit

Bug #686432 reported by Sébastien Heymann
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Gephi
Fix Released
Undecided
Sébastien Heymann
Toolkit
Fix Released
Undecided
Unassigned

Bug Description

I tried to export a GEXF file to check things but it crashed, trying to write:

<attributes class="node" mode="dynamic">
   <attribute id="time_interval" title="Time Interval"

With the following exception:

java.lang.NullPointerException
at org.gephi.io.exporter.plugin.ExporterGEXF.writeAttributes(ExporterGEXF.java:324)
at org.gephi.io.exporter.plugin.ExporterGEXF.writeAttributes(ExporterGEXF.java:296)
at org.gephi.io.exporter.plugin.ExporterGEXF.writeGraph(ExporterGEXF.java:251)
at org.gephi.io.exporter.plugin.ExporterGEXF.execute(ExporterGEXF.java:213)
at org.gephi.io.exporter.impl.ExportControllerImpl.exportFile(ExportControllerImpl.java:110)
at org.gephi.io.exporter.impl.ExportControllerImpl.exportFile(ExportControllerImpl.java:67)

The problem is raised at at the line:
AttributeType staticType = TypeConvertor.getStaticType(col.getType());

When col.getType() return TimeInterval, which is not a type known by TypeConvertor.getStaticType().

But it seems the problem is inside ExporterGEXF.writeAttributes() with the predicate to add a dynamic column:

if (exportDynamic && col.getType().isDynamicType() && col.getOrigin().equals(AttributeOrigin.PROPERTY) && col.getIndex() == PropertiesColumn.EDGE_WEIGHT.getIndex()) {
    dynamicCols.add(col);
}

"col.getIndex() == PropertiesColumn.EDGE_WEIGHT.getIndex()" is suspicious, as it is true for the node attribute encoding the TimeInterval.

How to reproduce using the Toolkit:

//Init a project - and therefore a workspace
ProjectController pc = Lookup.getDefault().lookup(ProjectController.class);
pc.newProject();
Workspace workspace = pc.getCurrentWorkspace();

//Get controllers and models
ImportController importController = Lookup.getDefault().lookup(ImportController.class);

//Import file
Container container;
try {
    File file = new File("1.csv");
    container = importController.importFile(file);
    container.getLoader().setEdgeDefault(EdgeDefault.DIRECTED); //Force DIRECTED
    container.setAllowAutoNode(false); //Don't create missing nodes
} catch (Exception ex) {
    ex.printStackTrace();
    return;
}

//Initialize the DynamicProcessor - which will append the container to the workspace
DynamicProcessor dynamicProcessor = new DynamicProcessor();
dynamicProcessor.setDateMode(false); //Set 'true' if you set real dates (ex: yyyy-mm-dd), it's double otherwise
dynamicProcessor.setLabelmatching(false); //Set 'true' if node matching is done on labels instead of ids

//Set date for this file
dynamicProcessor.setDate("1");

//Process the container using the DynamicProcessor
importController.process(container, dynamicProcessor, workspace);

//Export full graph
ExportController ec = Lookup.getDefault().lookup(ExportController.class);
try {
    ec.exportFile(new File("io_gexf.gexf"));
} catch (IOException ex) {
    ex.printStackTrace();
    return;
}

Tags: export
Changed in gephi:
milestone: none → 0.7beta
assignee: nobody → Cezary Bartosiak (cezary-bartosiak)
description: updated
tags: added: export
Changed in gephi:
assignee: Cezary Bartosiak (cezary-bartosiak) → Sébastien Heymann (sebastien.heymann)
status: New → Fix Committed
Changed in gephi:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.