columnsList.add(addAttributeColumn(nodesTable, columnNames[i], columnTypes[i]));
}
}
//Create nodes:
GraphElementsController gec = Lookup.getDefault().lookup(GraphElementsController.class);
Graph graph = Lookup.getDefault().lookup(GraphController.class).getModel().getGraph();
String id = null;
Node node;
Attributes nodeAttributes;
reader = new CsvReader(new FileInputStream(file), separator, charset);
reader.readHeaders();
while (reader.readRecord()) {
//Prepare the correct node to assign the attributes:
if (idColumn != null) {
id = reader.get(idColumn);
if (id == null || id.isEmpty()) {
node = gec.createNode(null);//id null or empty, assign one
} else {
graph.readLock();
node = graph.getNode(id);
graph.readUnlock();
if (node != null) {//Node with that id already in graph
if (assignNewNodeIds) {
node = gec.createNode(null);
}
} else {
node = gec.createNode(null, id);//New id in the graph
}
}
} else {
node = gec.createNode(null);
}
//Assign attributes to the current node:
nodeAttributes = node.getNodeData().getAttributes();
for (AttributeColumn column : columnsList) {
setAttributeValue(reader.get(column.getTitle()), nodeAttributes, column);