Java Code Examples for com.tinkerpop.blueprints.Edge#getLabel()

The following examples show how to use com.tinkerpop.blueprints.Edge#getLabel() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GenericRelation.java    From incubator-atlas with Apache License 2.0 5 votes vote down vote up
@Override
public Collection<RelationSet> traverse(VertexWrapper vWrapper) {
    Collection<RelationSet> relations = new ArrayList<>();
    Vertex v = vWrapper.getVertex();
    String vertexType = v.getProperty(Constants.ENTITY_TYPE_PROPERTY_KEY);
    Map<String, Collection<VertexWrapper>> vertexMap = new HashMap<>();
    for (Edge e : v.getEdges(Direction.OUT)) {
        String edgeLabel = e.getLabel();
        String edgePrefix = String.format("%s%s.", Constants.INTERNAL_PROPERTY_KEY_PREFIX, vertexType);
        if (edgeLabel.startsWith(edgePrefix)) {
            Vertex adjacentVertex = e.getVertex(Direction.IN);
            if (! isDeleted(adjacentVertex)) {
                VertexWrapper relationVertex = new VertexWrapper(adjacentVertex, resourceDefinition);
                String relationName = edgeLabel.substring(edgePrefix.length());
                Collection<VertexWrapper> vertices = vertexMap.get(relationName);
                if (vertices == null) {
                    vertices = new ArrayList<>();
                    vertexMap.put(relationName, vertices);
                }
                vertices.add(relationVertex);
            }
        }
    }
    for (Map.Entry<String, Collection<VertexWrapper>> entry : vertexMap.entrySet()) {
        relations.add(new RelationSet(entry.getKey(), entry.getValue()));
    }
    return relations;
}
 
Example 2
Source File: TinkerGraphUtil.java    From SciGraph with Apache License 2.0 5 votes vote down vote up
Edge addEdge(Edge edge) {
  Edge newEdge = graph.getEdge(edge.getId());
  if (null == newEdge) {
    Vertex outVertex = addNode(edge.getVertex(Direction.OUT));
    Vertex inVertex = addNode(edge.getVertex(Direction.IN));
    String label = edge.getLabel();
    newEdge = graph.addEdge(edge.getId(), outVertex, inVertex, label);
    copyProperties(edge, edge);
  }
  return newEdge;
}
 
Example 3
Source File: DVertex.java    From org.openntf.domino with Apache License 2.0 5 votes vote down vote up
@Override
public void addInEdge(final Edge edge) {
	String label = edge.getLabel();
	getParent().startTransaction(this);
	getInDirtyKeySet().add(label);
	List<Edge> inLabelObjs = getInEdgeObjects(label);
	inLabelObjs.add(edge);
}
 
Example 4
Source File: DVertex.java    From org.openntf.domino with Apache License 2.0 5 votes vote down vote up
@Override
public void addOutEdge(final Edge edge) {
	String label = edge.getLabel();
	getParent().startTransaction(this);
	getOutDirtyKeySet().add(label);
	List<Edge> outLabelObjs = getOutEdgeObjects(label);
	outLabelObjs.add(edge);
}
 
Example 5
Source File: DominoVertex.java    From org.openntf.domino with Apache License 2.0 5 votes vote down vote up
@Override
public void addInEdge(final Edge edge) {
	String label = edge.getLabel();

	Set<String> ins = getInEdgesSet(label);
	if (!ins.contains(edge.getId())) {
		getParent().startTransaction(this);
		Map<String, Boolean> map = getInDirtyMap();
		map.put(label, true);
		Set<Edge> inLabelObjs = getInEdgeCache(label);
		inLabelObjs.add(edge);
		ins.add((String) edge.getId());
	}
}
 
Example 6
Source File: DominoVertex.java    From org.openntf.domino with Apache License 2.0 5 votes vote down vote up
@Override
public void addOutEdge(final Edge edge) {
	String label = edge.getLabel();

	Set<String> outs = getOutEdgesSet(label);
	if (!outs.contains(edge.getId())) {
		getParent().startTransaction(this);
		Map<String, Boolean> map = getOutDirtyMap();
		map.put(label, true);
		Set<Edge> outLabelObjs = getOutEdgeCache(label);
		outLabelObjs.add(edge);
		outs.add((String) edge.getId());
	}
}
 
Example 7
Source File: ImageWriter.java    From SciGraph with Apache License 2.0 4 votes vote down vote up
@Override
public String transform(Edge edge) {
  return edge.getLabel();
}
 
Example 8
Source File: BaseEdgeMutator.java    From AccumuloGraph with Apache License 2.0 4 votes vote down vote up
public BaseEdgeMutator(Edge edge) {
  this(edge.getId().toString(),
      edge.getVertex(Direction.OUT).getId().toString(),
      edge.getVertex(Direction.IN).getId().toString(),
      edge.getLabel());
}
 
Example 9
Source File: StringFactory.java    From org.openntf.domino with Apache License 2.0 4 votes vote down vote up
public static String edgeString(final Edge edge) {
    return E + L_BRACKET + edge.getId() + R_BRACKET + L_BRACKET + edge.getVertex(Direction.OUT).getId() + DASH + edge.getLabel() + ARROW + edge.getVertex(Direction.IN).getId() + R_BRACKET;
}
 
Example 10
Source File: DominoVertex.java    From org.openntf.domino with Apache License 2.0 4 votes vote down vote up
public void removeEdge(final Edge edge) {
	getParent().startTransaction(this);
	String label = edge.getLabel();

	boolean inChanged = false;
	Set<String> ins = getInEdgesSet(label);
	if (ins != null) {
		//			System.out.println("Removing an in edge from " + label + " with id " + edge.getId() + " from a vertex of type "
		//					+ getProperty("Form"));
		//			synchronized (ins) {
		inChanged = ins.remove(edge.getId());
		//			}
	} else {
		//			System.out.println("in edges were null from a vertex of type " + getProperty("Form") + ": " + getId());
	}
	// Set<Edge> inObjs = getInEdgeObjects();
	// synchronized (inObjs) {
	// inObjs.remove(edge);
	// }
	if (inChanged) {
		//			System.out.println("Ins were changed so recording cache invalidation...");
		Set<Edge> inObjsLabel = getInEdgeCache(label);
		//			synchronized (inObjsLabel) {
		inObjsLabel.remove(edge);
		//			}
		Map<String, Boolean> inDirtyMap = getInDirtyMap();
		//			synchronized (inDirtyMap) {
		inDirtyMap.put(label, true);
		//			}
	}

	boolean outChanged = false;
	Set<String> outs = getOutEdgesSet(label);
	if (outs != null) {
		//			System.out.println("Removing an out edge from " + label + " with id " + edge.getId() + " from a vertex of type "
		//					+ getProperty("Form"));
		//			synchronized (outs) {
		outChanged = outs.remove(edge.getId());
		//			}
	} else {
		//			System.out.println("out edges were null from a vertex of type " + getProperty("Form") + ": " + getId());
	}
	if (outChanged) {
		//			System.out.println("Out were changed so recording cache invalidation...");
		Set<Edge> outObjsLabel = getOutEdgeCache(label);
		//			synchronized (outObjsLabel) {
		outObjsLabel.remove(edge);
		//			}
		Map<String, Boolean> outDirtyMap = getOutDirtyMap();
		//			synchronized (outDirtyMap) {
		outDirtyMap.put(label, true);
		//			}
	}
}