DefaultGraphModel buildGraphModel() { if (this.graphModel != null) { throw new IllegalStateException("GraphModel already built!"); } this.graphModel = new DefaultGraphModel(); graphModel.addNodes(nodeModels.toArray(new NodeModel[0])); graphModel.addRelationships(relationshipModels.toArray(new RelationshipModel[0])); return graphModel; }
/** * Parses a row from the result object and transforms it into a GraphModel * * @param data the data to transform, given as a map * @return the data transformed to an {@link GraphModel} */ @Override public GraphModel adapt(Map<String, Object> data) { // These two sets keep track of which nodes and edges have already been built, so we don't redundantly // write the same node or relationship entity many times. final Set<Long> nodeIdentities = new HashSet<>(); final Set<Long> edgeIdentities = new HashSet<>(); DefaultGraphModel graphModel = new DefaultGraphModel(); for (Map.Entry<String, Object> mapEntry : data.entrySet()) { final Object value = mapEntry.getValue(); String resultKey = mapEntry.getKey(); boolean generatedNodes = AdapterUtils.describesGeneratedNode(resultKey); adaptInternal(nodeIdentities, edgeIdentities, graphModel, value, generatedNodes); } return graphModel; }
/** * Reads the next row from the result object and transforms it into a RowModel object * * @param data the data to transform, given as a map * @return @return the data transformed to an {@link RowModel} */ public GraphRowModel adapt(Map<String, Object> data) { assert (columns != null); Set<Long> nodeIdentities = new HashSet(); Set<Long> edgeIdentities = new HashSet(); GraphModel graphModel = new DefaultGraphModel(); List<String> variables = new ArrayList<>(); List<Object> values = new ArrayList<>(); // there is no guarantee that the objects in the data are ordered the same way as required by the columns // so we use the columns information to extract them in the correct order for post-processing. Iterator<String> iterator = columns.iterator(); adapt(iterator, data, graphModel, variables, values, nodeIdentities, edgeIdentities); DefaultRowModel rowModel = new DefaultRowModel(values.toArray(new Object[]{}), variables.toArray(new String[]{})); return new DefaultGraphRowModel(graphModel, rowModel.getValues()); }
@Override public GraphRowModel adapt(Map<String, Object> data) { if (columns == null) { throw new ResultProcessingException("Column data cannot be null!"); } Set<Long> nodeIdentities = new HashSet<>(); Set<Long> edgeIdentities = new HashSet<>(); GraphModel graphModel = new DefaultGraphModel(); List<String> variables = new ArrayList<>(); List<Object> values = new ArrayList<>(); // there is no guarantee that the objects in the data are ordered the same way as required by the columns // so we use the columns information to extract them in the correct order for post-processing. Iterator<String> iterator = columns.iterator(); adapt(iterator, data, graphModel, variables, values, nodeIdentities, edgeIdentities); DefaultRowModel rowModel = new DefaultRowModel(values.toArray(new Object[] {}), variables.toArray(new String[] {})); return new DefaultGraphRowModel(graphModel, rowModel.getValues()); }
/** * Reads the next row from the result object and transforms it into a RowModel object * * @param data the data to transform, given as a map * @return the data transformed to an {@link RowModel} */ public GraphRowModel adapt(Map<String, Object> data) { if (columns == null) { throw new ResultProcessingException("Result columns should not be null"); } Set<Long> nodeIdentities = new HashSet<>(); Set<Long> edgeIdentities = new HashSet<>(); DefaultGraphModel graphModel = new DefaultGraphModel(); List<String> variables = new ArrayList<>(); List<Object> values = new ArrayList<>(); // there is no guarantee that the objects in the data are ordered the same way as required by the columns // so we use the columns information to extract them in the correct order for post-processing. Iterator<String> iterator = columns.iterator(); adapt(iterator, data, graphModel, variables, values, nodeIdentities, edgeIdentities); DefaultRowModel rowModel = new DefaultRowModel(values.toArray(new Object[] {}), variables.toArray(new String[] {})); return new DefaultGraphRowModel(graphModel, rowModel.getValues()); }
/** * Reads the next row from the result object and transforms it into a RowModel object * * @param data the data to transform, given as a map * @return the data transformed to an {@link RowModel} */ public GraphRowModel adapt(Map<String, Object> data) { if (columns == null) { throw new ResultProcessingException("Column data cannot be null!"); } Set<Long> nodeIdentities = new HashSet<>(); Set<Long> edgeIdentities = new HashSet<>(); GraphModel graphModel = new DefaultGraphModel(); List<String> variables = new ArrayList<>(); List<Object> values = new ArrayList<>(); // there is no guarantee that the objects in the data are ordered the same way as required by the columns // so we use the columns information to extract them in the correct order for post-processing. Iterator<String> iterator = columns.iterator(); adapt(iterator, data, graphModel, variables, values, nodeIdentities, edgeIdentities); DefaultRowModel rowModel = new DefaultRowModel(values.toArray(new Object[] {}), variables.toArray(new String[] {})); return new DefaultGraphRowModel(graphModel, rowModel.getValues()); }
final Set<Long> edgeIdentities = new HashSet<>(); GraphModel graphModel = new DefaultGraphModel();
GraphModel model = new DefaultGraphModel(); JGraph graph = new JGraph(model);