/** * Create an instance of {@link EdgeType } * */ public EdgeType createEdgeType() { return new EdgeType(); }
@Override protected void transformEdge(final IEdge edge) { final EdgeType edgeType = new EdgeType(); edgeType.setId(edge.getId().toString()); edgeType.setSource(edge.getVertex(Direction.OUT).getId().toString()); edgeType.setTarget(edge.getVertex(Direction.IN).getId().toString()); final List<DataType> data = edgeType.getData(); for (final String propertyKey : edge.getPropertyKeys()) { final DataType dataType = new DataType(); dataType.setKey(propertyKey); dataType.setContent(edge.getProperty(propertyKey).toString()); data.add(dataType); this.edgeKeys.add(propertyKey); } this.graphType.getDataOrNodeOrEdge().add(edgeType); }
GraphMLEdge convertedEdge = new GraphMLEdge(); GraphMLGraph sourceGraph = nodeIdToGraphMapping.get(eachEdge.getSource()); GraphMLGraph targetGraph = nodeIdToGraphMapping.get(eachEdge.getTarget()); throw new InvalidGraphException("No graph found for edge with id " + eachEdge.getSource()); throw new InvalidGraphException("No graph found for edge with id " + eachEdge.getTarget()); GraphMLNode sourceNode = sourceGraph.getNodeById(eachEdge.getSource()); GraphMLNode targetNode = targetGraph.getNodeById(eachEdge.getTarget()); addProperties(convertedEdge, eachEdge.getId(), keyIdToTypeMapping, filter(eachEdge.getData(), DataType.class)); sourceGraph.addEdge(convertedEdge);
public static GraphmlType convert(GraphML graphML) throws InvalidGraphException { GraphmlType graphmlType = new GraphmlType(); addProperties(graphmlType, KeyForType.GRAPHML, graphML, dataType -> graphmlType.getGraphOrData().add(dataType)); for (GraphMLGraph eachGraph : graphML.getGraphs()) { GraphType graphType = new GraphType(); graphType.setId(eachGraph.getId()); addProperties(graphmlType, KeyForType.GRAPH, eachGraph, dataType -> graphType.getDataOrNodeOrEdge().add(dataType)); for (GraphMLNode eachNode : eachGraph.getNodes()) { NodeType nodeType = new NodeType(); nodeType.setId(eachNode.getId()); graphType.getDataOrNodeOrEdge().add(nodeType); addProperties(graphmlType, KeyForType.NODE, eachNode, dataType -> nodeType.getDataOrPort().add(dataType)); } for (GraphMLEdge eachEdge : eachGraph.getEdges()) { EdgeType edgeType = new EdgeType(); edgeType.setId(eachEdge.getId()); edgeType.setSource(eachEdge.getSource().getId()); edgeType.setTarget(eachEdge.getTarget().getId()); graphType.getDataOrNodeOrEdge().add(edgeType); addProperties(graphmlType, KeyForType.EDGE, eachEdge, dataType -> edgeType.getData().add(dataType)); } graphmlType.getGraphOrData().add(graphType); } return graphmlType; }
/** * Create an instance of {@link EdgeType } * */ public EdgeType createEdgeType() { return new EdgeType(); }