/** * Deletes the concept as an Thing */ @Override public void delete() { //Remove links to relationships and return them Set<Relationship> relationships = castingsInstance().map(casting -> { Relationship relationship = casting.getRelationship(); Role role = casting.getRole(); relationship.unassign(role, this); return relationship; }).collect(toSet()); vertex().tx().txCache().removedInstance(type().id()); deleteNode(); relationships.forEach(relation -> { if(relation.type().isImplicit()){//For now implicit relationships die relation.delete(); } else { RelationshipImpl rel = (RelationshipImpl) relation; rel.cleanUp(); } }); }
private Stream<Relationship> relationEdges(){ //Unfortunately this is a slow process return roles(). flatMap(Role::players). flatMap(type ->{ //Traversal is used here to take advantage of vertex centric index return vertex().tx().getTinkerTraversal().V(). has(Schema.VertexProperty.ID.name(), type.id().getValue()). in(Schema.EdgeLabel.SHARD.getLabel()). in(Schema.EdgeLabel.ISA.getLabel()). outE(Schema.EdgeLabel.ATTRIBUTE.getLabel()). has(Schema.EdgeProperty.RELATIONSHIP_TYPE_LABEL_ID.name(), labelId().getValue()). toStream(). map(edge -> vertex().tx().factory().<Relationship>buildConcept(edge)); }); }