Java Code Examples for com.tinkerpop.blueprints.Direction#BOTH

The following examples show how to use com.tinkerpop.blueprints.Direction#BOTH . 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: TitanObjectFactory.java    From incubator-atlas with Apache License 2.0 5 votes vote down vote up
/**
 * Retrieves the titan direction corresponding to the given
 * AtlasEdgeDirection.
 *
 * @param dir
 * @return
 */
public static Direction createDirection(AtlasEdgeDirection dir) {

    switch(dir) {
    case IN:
        return Direction.IN;
    case OUT:
        return Direction.OUT;
    case BOTH:
        return Direction.BOTH;
    default:
        throw new RuntimeException("Unrecognized direction: " + dir);
    }
}
 
Example 2
Source File: DVertex.java    From org.openntf.domino with Apache License 2.0 5 votes vote down vote up
@Override
public Iterable<Vertex> getVertices(final Direction direction, final String... labels) {
	if (direction == Direction.BOTH) {
		List<Iterable<Vertex>> list = new ArrayList<Iterable<Vertex>>();
		list.add(new VerticesFromEdgesIterable(this, Direction.IN, labels));
		list.add(new VerticesFromEdgesIterable(this, Direction.OUT, labels));
		return new MultiIterable<Vertex>(list);
	} else {
		return new VerticesFromEdgesIterable(this, direction, labels);
	}
}
 
Example 3
Source File: AbstractIncidenceHandler.java    From org.openntf.domino with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("rawtypes")
private Edge findEdge(final Annotation annotation, final FramedGraph framedGraph, final Vertex vertex, final Vertex newVertex) {
	Edge result = null;
	Direction dir = Direction.BOTH;
	String label = "";
	boolean unique = false;
	if (annotation instanceof Adjacency) {
		dir = ((Adjacency) annotation).direction();
		label = ((Adjacency) annotation).label();
	} else if (annotation instanceof AdjacencyUnique) {
		dir = ((AdjacencyUnique) annotation).direction();
		label = ((AdjacencyUnique) annotation).label();
		unique = true;
	} else if (annotation instanceof Incidence) {
		dir = ((Incidence) annotation).direction();
		label = ((Incidence) annotation).label();
	} else if (annotation instanceof IncidenceUnique) {
		dir = ((IncidenceUnique) annotation).direction();
		label = ((IncidenceUnique) annotation).label();
		unique = true;
	}

	switch (dir) {
	case OUT:
		result = ((DVertex) vertex).findOutEdge(newVertex, label, unique);
		break;
	case IN:
		result = ((DVertex) vertex).findInEdge(newVertex, label, unique);
		break;
	default:
		break;
	}
	return result;
}
 
Example 4
Source File: DominoVertex.java    From org.openntf.domino with Apache License 2.0 5 votes vote down vote up
@Override
public Iterable<Vertex> getVertices(final Direction direction, final String... labels) {
	if (direction == Direction.BOTH) {
		List<Iterable<Vertex>> list = new ArrayList<Iterable<Vertex>>();
		list.add(new VerticesFromEdgesIterable(this, Direction.IN, labels));
		list.add(new VerticesFromEdgesIterable(this, Direction.OUT, labels));
		return new MultiIterable<Vertex>(list);
	} else {
		return new VerticesFromEdgesIterable(this, direction, labels);
	}
}
 
Example 5
Source File: BigdataEdge.java    From database with GNU General Public License v2.0 4 votes vote down vote up
@Override
public Vertex getVertex(final Direction dir) throws IllegalArgumentException {
	
       if (log.isInfoEnabled())
           log.info("("+dir+")");
       
	if (dir == Direction.BOTH) {
		throw new IllegalArgumentException();
	}
	
	final URI uri = (URI)  
			(dir == Direction.OUT ? stmt.getSubject() : stmt.getObject());
	
	final String id = graph.factory.fromURI(uri);
	
	return graph.getVertex(id);
	
}
 
Example 6
Source File: BothPipe.java    From org.openntf.domino with Apache License 2.0 4 votes vote down vote up
public BothPipe(final String... labels) {
    super(Direction.BOTH, labels);
}
 
Example 7
Source File: BothPipe.java    From org.openntf.domino with Apache License 2.0 4 votes vote down vote up
public BothPipe(final int branchFactor, final String... labels) {
    super(Direction.BOTH, branchFactor, labels);
}
 
Example 8
Source File: BothVerticesPipe.java    From org.openntf.domino with Apache License 2.0 4 votes vote down vote up
public BothVerticesPipe() {
    super(Direction.BOTH);
}
 
Example 9
Source File: BothEdgesPipe.java    From org.openntf.domino with Apache License 2.0 4 votes vote down vote up
public BothEdgesPipe(final String... labels) {
    super(Direction.BOTH, labels);
}
 
Example 10
Source File: BothEdgesPipe.java    From org.openntf.domino with Apache License 2.0 4 votes vote down vote up
public BothEdgesPipe(final int branchFactor, final String... labels) {
    super(Direction.BOTH, branchFactor, labels);
}
 
Example 11
Source File: AbstractIncidenceHandler.java    From org.openntf.domino with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("rawtypes")
private Edge addEdge(final Annotation annotation, final FramedGraph framedGraph, final Vertex vertex, final Vertex newVertex,
		final String replicaid) {
	Edge result = null;
	Direction dir = Direction.BOTH;
	String label = "";
	boolean unique = false;
	if (annotation instanceof Adjacency) {
		dir = ((Adjacency) annotation).direction();
		label = ((Adjacency) annotation).label();
	} else if (annotation instanceof AdjacencyUnique) {
		dir = ((AdjacencyUnique) annotation).direction();
		label = ((AdjacencyUnique) annotation).label();
		unique = true;
	} else if (annotation instanceof Incidence) {
		dir = ((Incidence) annotation).direction();
		label = ((Incidence) annotation).label();
	} else if (annotation instanceof IncidenceUnique) {
		dir = ((IncidenceUnique) annotation).direction();
		label = ((IncidenceUnique) annotation).label();
		unique = true;
	}
	NoteCoordinate id = null;
	switch (dir) {
	case OUT:
		if (unique) {
			id = getForcedId(vertex, newVertex, label, replicaid);
		}
		result = framedGraph.addEdge(id, vertex, newVertex, label);
		break;
	case IN:
		if (unique) {
			id = getForcedId(newVertex, vertex, label, replicaid);
		}
		result = framedGraph.addEdge(id, newVertex, vertex, label);
		break;
	case BOTH:
		throw new UnsupportedOperationException("Direction.BOTH it not supported on 'add' or 'set' methods");
	}
	return result;
}