//Architecture
GraphController graphController = Lookup.getDefault().lookup(GraphController.class);
GraphModel graphModel = Lookup.getDefault().lookup(GraphController.class).getGraphModel();
Graph graph = graphModel.getGraph();;
GraphFactory factory = graphModel.factory();
//Attributes - Creates columns for properties
attributeModel = graphController.getAttributeModel();
flushColumns();
//Dynamic
// if (container.getTimeFormat() != null) {
// DynamicController dynamicController = Lookup.getDefault().lookup(DynamicController.class);
// if (dynamicController != null) {
// dynamicController.setTimeFormat(container.getTimeFormat());
// }
// }
int nodeCount = 0;
//Create all nodes
for (NodeDraft draftNode : container.getNodes()) {
String id = draftNode.getId();
Node node = factory.newNode(id);
graph.addNode(node);
nodeCount++;
flushToNode(draftNode, node);
}
//Create all edges and push to data structure
int edgeCount = 0;
for (EdgeDraft draftEdge : container.getEdges()) {
String id = draftEdge.getId();
String sourceId = draftEdge.getSource().getId();
String targetId = draftEdge.getTarget().getId();
Node source = graph.getNode(sourceId);
Node target = graph.getNode(targetId);
Object type = draftEdge.getType();
int edgeType = graphModel.addEdgeType(type);
Edge edge = graph.getEdge(source, target, edgeType);
switch (container.getEdgeDefault()) {
case DIRECTED:
edge = factory.newEdge(id, source, target, edgeType, draftEdge.getWeight(), true);
break;
case UNDIRECTED:
edge = factory.newEdge(id, source, target, edgeType, draftEdge.getWeight(), false);
break;
case MIXED:
boolean directed = draftEdge.getDirection() != null && draftEdge.getDirection().equals(EdgeDirection.UNDIRECTED) ? false : true;
edge = factory.newEdge(id, source, target, edgeType, draftEdge.getWeight(), directed);
}
edgeCount++;
graph.addEdge(edge);
flushToEdge(draftEdge, edge);