While attempting to import a database from Neo4j to Gephi, I get the following error:
Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Long
at org.gephi.neo4j.plugin.impl.Neo4jDelegateProviderImpl.getNodeAttributeValue(Neo4jDelegateProviderImpl.java:37)
at org.gephi.data.attributes.AttributeValueImpl.getValue(AttributeValueImpl.java:81)
at org.gephi.data.attributes.AttributeValueImpl.equals(AttributeValueImpl.java:103)
at org.gephi.data.attributes.AttributeRowImpl.setValue(AttributeRowImpl.java:153)
at org.gephi.data.attributes.AttributeRowImpl.setValue(AttributeRowImpl.java:141)
at org.gephi.data.attributes.AttributeRowImpl.setValue(AttributeRowImpl.java:128)
at org.gephi.data.attributes.AttributeRowImpl.setValue(AttributeRowImpl.java:110)
at org.gephi.neo4j.plugin.impl.GraphModelImportConverter.fillGephiNodeDataWithNeoNodeData(GraphModelImportConverter.java:160)
at org.gephi.neo4j.plugin.impl.GraphModelImportConverter.createGephiNodeFromNeoNode(GraphModelImportConverter.java:135)
at org.gephi.neo4j.plugin.impl.Neo4jImporterImpl.processNode(Neo4jImporterImpl.java:181)
at org.gephi.neo4j.plugin.impl.Neo4jImporterImpl.importNodes(Neo4jImporterImpl.java:175)
at org.gephi.neo4j.plugin.impl.Neo4jImporterImpl.importGraph(Neo4jImporterImpl.java:159)
at org.gephi.neo4j.plugin.impl.Neo4jImporterImpl.doImport(Neo4jImporterImpl.java:137)
at org.gephi.neo4j.plugin.impl.Neo4jImporterImpl.importDatabase(Neo4jImporterImpl.java:131)
at org.gephi.neo4j.plugin.impl.Neo4jImporterImpl.importDatabase(Neo4jImporterImpl.java:91)
at main.algo(main.java:62)
at main.main(main.java:42)
My source:
graphDb = new EmbeddedGraphDatabase (DB_PATH);
owned_addresses = graphDb.index().forNodes("nodes");
final long ownerId = 1;
// Import by traversing the entire ownership network along the "transfers" edges
System.out.println("Importing Ownership Network from Neo4j Database...");
final Collection<RelationshipDescription> relationshipDescription = new ArrayList<RelationshipDescription>();
relationshipDescription.add(new RelationshipDescription(RelTypes.KNOWS, Direction.BOTH));
//relationshipDescription.add(new RelationshipDescription(GraphBuilder.OwnerRelTypes.transfers, Direction.BOTH));
final Neo4jImporter importer = new Neo4jImporterImpl();
// Load the graph in memory
importer.importDatabase(graphDb, ownerId, TraversalOrder.BREADTH_FIRST, Integer.MAX_VALUE, relationshipDescription);
// Grab the graph that was loaded from the importer
final ProjectController projectController = Lookup.getDefault().lookup(ProjectController.class);
final Workspace workspace = projectController.getCurrentWorkspace();
final GraphModel graph = Lookup.getDefault().lookup(GraphController.class).getModel(workspace);
System.out.println("Graph Imported. Nodes: " + graph.getDirectedGraph().getNodeCount() + "Edges: " + graph.getDirectedGraph().getEdgeCount());
// Layout
final ForceAtlas2 layout = new ForceAtlas2(new ForceAtlas2Builder());
layout.setGraphModel(graph);
The data base was generated as follows:
graphDb = new EmbeddedGraphDatabase(DB_PATH);
Transaction tx = graphDb.beginTx();
try {
myFirstNode = graphDb.createNode();
myFirstNode.setProperty("name", "Hellooo");
mySecondNode = graphDb.createNode();
mySecondNode.setProperty("name", "Hellooo2");
myRelationship = myFirstNode.createRelationshipTo(mySecondNode, RelTypes.KNOWS);
myRelationship.setProperty("relationship-type", "knows");
myString = myFirstNode.getProperty("name").toString() + " "+ myRelationship.getProperty("relationship-type").toString()+" "+ mySecondNode.getProperty("name").toString();
System.out.println(myString);
tx.success();
} finally {
tx.finish();
}
Thank you!
Alan.