use of com.tinkerpop.blueprints.Edge in project orientdb by orientechnologies.
the class BlueprintsConcurrentGraphChangesTestNoTx method assertEdgesDeletedGraph.
private void assertEdgesDeletedGraph() {
OrientBaseGraph graph = getGraph();
graph.setUseLightweightEdges(false);
Assert.assertEquals(VERTEXES_COUNT, graph.countVertices("TestVertex"));
Assert.assertEquals(0, graph.countEdges("TestEdge"));
for (TestVertex vertex : vertexes) {
Iterable<Vertex> vertexes = graph.command(new OSQLSynchQuery<Vertex>("select from TestVertex where uuid = '" + vertex.uuid + "'")).execute();
Assert.assertTrue(vertexes.iterator().hasNext());
Vertex gVertex = vertexes.iterator().next();
OMultiCollectionIterator<Edge> outEdges = (OMultiCollectionIterator<Edge>) gVertex.getEdges(Direction.OUT);
Assert.assertEquals(outEdges.size(), 0);
OMultiCollectionIterator<Edge> inEdges = (OMultiCollectionIterator<Edge>) gVertex.getEdges(Direction.IN);
Assert.assertEquals(inEdges.size(), 0);
}
assertGraphIsConsistent(graph);
graph.shutdown();
}
use of com.tinkerpop.blueprints.Edge in project orientdb by orientechnologies.
the class BlueprintsTest method testSubEdge.
@Test
public void testSubEdge() {
if (graph.getEdgeType("SubEdge") == null)
graph.createEdgeType("SubEdge");
if (graph.getVertexType("SubVertex") == null)
graph.createVertexType("SubVertex");
Vertex v1 = graph.addVertex("class:SubVertex");
v1.setProperty("key", "subtype+subedge");
Assert.assertEquals(((OrientVertex) v1).getRecord().getSchemaClass().getName(), "SubVertex");
Vertex v2 = graph.addVertex("class:SubVertex");
v2.setProperty("key", "subtype+subedge");
Assert.assertEquals(((OrientVertex) v2).getRecord().getSchemaClass().getName(), "SubVertex");
Edge e = graph.addEdge("class:SubEdge", v1, v2, null);
e.setProperty("key", "subedge");
Assert.assertEquals(((OrientEdge) e).getRecord().getSchemaClass().getName(), "SubEdge");
graph.commit();
}
use of com.tinkerpop.blueprints.Edge in project orientdb by orientechnologies.
the class BlueprintsTest method testEdgePhysicalRemoval.
@Test
public void testEdgePhysicalRemoval() {
graph.command(new OCommandSQL("delete from e where name = 'forceCreationOfDocument'")).execute();
Vertex v1 = graph.addVertex(null);
Vertex v2 = graph.addVertex(null);
OrientEdge e = graph.addEdge(null, v1, v2, "anyLabel");
e.setProperty("key", "forceCreationOfDocument");
Iterable<Edge> result = graph.command(new OSQLSynchQuery<Edge>("select from e where key = 'forceCreationOfDocument'")).execute();
Assert.assertTrue(result.iterator().hasNext());
Assert.assertTrue(result.iterator().next() instanceof Edge);
e.remove();
graph.commit();
result = graph.command(new OSQLSynchQuery<Edge>("select from e where key = 'forceCreationOfDocument'")).execute();
Assert.assertFalse(result.iterator().hasNext());
}
use of com.tinkerpop.blueprints.Edge in project orientdb by orientechnologies.
the class EdgeBug method reparent.
private void reparent(Vertex child, Vertex parent) {
OrientGraph db = new OrientGraph("memory:temp", "admin", "admin");
OrientVertex childVertex = db.getVertex(child.getId());
Iterable<Edge> parentEdges = childVertex.getEdges(Direction.OUT, "hasParent");
// remove original parent edge
for (Edge parentEdge : parentEdges) parentEdge.remove();
// get vertex again
childVertex = db.getVertex(childVertex.getId());
Vertex parentVertex = db.getVertex(parent.getId());
// add new edge to b
childVertex.addEdge("hasParent", parentVertex);
db.commit();
}
use of com.tinkerpop.blueprints.Edge in project orientdb by orientechnologies.
the class OrientIndex method create.
private void create(final String indexName, final Class<? extends Element> indexClass, OType iKeyType) {
this.indexClass = indexClass;
if (iKeyType == null)
iKeyType = OType.STRING;
final OIndexFactory factory = OIndexes.getFactory(OClass.INDEX_TYPE.DICTIONARY.toString(), null);
this.recordKeyValueIndex = new OIndexTxAwareOneValue(graph.getRawGraph(), (OIndex<OIdentifiable>) graph.getRawGraph().getMetadata().getIndexManager().createIndex("__@recordmap@___" + indexName, OClass.INDEX_TYPE.DICTIONARY.toString(), new OSimpleKeyIndexDefinition(factory.getLastVersion(), OType.LINK, OType.STRING), null, null, null));
final String className;
if (Vertex.class.isAssignableFrom(indexClass))
className = VERTEX;
else if (Edge.class.isAssignableFrom(indexClass))
className = EDGE;
else
className = indexClass.getName();
final ODocument metadata = new ODocument();
metadata.field(CONFIG_CLASSNAME, className);
metadata.field(CONFIG_RECORD_MAP_NAME, recordKeyValueIndex.getName());
final OIndexFactory nuFactory = OIndexes.getFactory(OClass.INDEX_TYPE.NOTUNIQUE.toString(), null);
// CREATE THE MAP
this.underlying = new OIndexTxAwareMultiValue(graph.getRawGraph(), (OIndex<Set<OIdentifiable>>) graph.getRawGraph().getMetadata().getIndexManager().createIndex(indexName, OClass.INDEX_TYPE.NOTUNIQUE.toString(), new OSimpleKeyIndexDefinition(nuFactory.getLastVersion(), iKeyType), null, null, metadata));
}
Aggregations