Search in sources :

Example 1 with ConceptVertex

use of ai.grakn.kb.internal.concept.ConceptVertex in project grakn by graknlabs.

the class EmbeddedGraknTx method copyRelationshipEdge.

/**
 * Copy a relation which is an edge - {@link RelationshipEdge}
 */
private void copyRelationshipEdge(Attribute main, Attribute other, RelationshipEdge relationEdge) {
    ConceptVertex newOwner;
    ConceptVertex newValue;
    if (relationEdge.owner().equals(other)) {
        // The resource owns another resource which it needs to replace
        newOwner = ConceptVertex.from(main);
        newValue = ConceptVertex.from(relationEdge.value());
    } else {
        // The resource is owned by another Entity
        newOwner = ConceptVertex.from(relationEdge.owner());
        newValue = ConceptVertex.from(main);
    }
    EdgeElement edge = newOwner.vertex().putEdge(newValue.vertex(), Schema.EdgeLabel.ATTRIBUTE);
    factory().buildRelation(edge, relationEdge.type(), relationEdge.ownerRole(), relationEdge.valueRole());
}
Also used : EdgeElement(ai.grakn.kb.internal.structure.EdgeElement) ConceptVertex(ai.grakn.kb.internal.concept.ConceptVertex)

Aggregations

ConceptVertex (ai.grakn.kb.internal.concept.ConceptVertex)1 EdgeElement (ai.grakn.kb.internal.structure.EdgeElement)1