Exception when duplicating workspace through GraphModel.pushFrom()

Bug #686116 reported by Sébastien Heymann
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Gephi
Won't Fix
Undecided
Mathieu Bastian
Toolkit
Won't Fix
Undecided
Unassigned

Bug Description

Way to reproduce with the toolkit:

1. Follow http://wiki.gephi.org/index.php/Toolkit_-_Metrics_over_time
2. Add the following code to copy a subgraph into a new workspace:

Graph currentGraphView = dynamicGraph.getSnapshotGraph(subinterval);

final Workspace newWorkspace = pc.newWorkspace(pc.getCurrentProject());
GraphModel gm = Lookup.getDefault().lookup(GraphController.class).getModel(newWorkspace);
gm.pushFrom(currentGraphView);

An exception is raised:

java.lang.IllegalArgumentException: The column doesn't exist
        at org.gephi.data.attributes.AttributeRowImpl.setValue(AttributeRowImpl.java:73)
        at org.gephi.graph.dhns.core.DuplicateManager.duplicateNodeData(DuplicateManager.java:186)
        at org.gephi.graph.dhns.core.DuplicateManager.duplicate(DuplicateManager.java:62)
        at org.gephi.graph.dhns.core.Dhns.pushFrom(Dhns.java:429)
        at org.cnrs.lip6.radarmetrics.Application.execute(Application.java:149)
        at org.cnrs.lip6.radarmetrics.Main.main(Main.java:44)

With the debugger, I found that it occurs with the parameters:
index=2
value=TimeInterval

So basically:
NodeDataImpl.getAttributes() returns a row that is unknown by AttributeTableImpl.getColumn().

Tags: workspace
Changed in gephi:
milestone: none → 0.7beta
tags: added: workspace
Revision history for this message
Sébastien Heymann (sebastien.heymann) wrote :

Another code to reproduce the bug, assuming that the CSV file contains an edge list:

//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);

GraphModel gm = Lookup.getDefault().lookup(GraphController.class).getModel(workspace);

final Workspace newWorkspace = pc.newWorkspace(pc.getCurrentProject());
GraphModel newGm = Lookup.getDefault().lookup(GraphController.class).getModel(newWorkspace);
newGm.pushFrom(gm.getGraph());

Changed in gephi:
assignee: nobody → Mathieu Bastian (mathieu.bastian)
Revision history for this message
Mathieu Bastian (mathieu.bastian) wrote :

Mainly for modularity reasons, you know that graph and attributes are separated in gephi. You may also know that you can write attribute values only if the column exists; and has therefore been created somehow.

The pushFrom method fails here because the columns haven't been created in the new workspace. Its a pity it doesn't take this classic issue in account and raise a proper exception.

Anyway, do that to duplicate the attribute model in the new workspace:

AttributeModel sourceAttributeModel = attributeController.getModel(currentWorkspace);
AttributeModel destAttributeModel = attributeController.getModel(newWorkspace);
destAttributeModel.mergeModel(sourceAttributeModel);

Revision history for this message
Sébastien Heymann (sebastien.heymann) wrote :

Thanks, it solved the issue!

Changed in gephi:
status: New → Won't Fix
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.