Search in sources :

Example 6 with EdgeElement

use of ai.grakn.kb.internal.structure.EdgeElement 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

EdgeElement (ai.grakn.kb.internal.structure.EdgeElement)6 AttributeType (ai.grakn.concept.AttributeType)2 EntityType (ai.grakn.concept.EntityType)2 Label (ai.grakn.concept.Label)2 RelationshipType (ai.grakn.concept.RelationshipType)2 Casting (ai.grakn.kb.internal.structure.Casting)2 Vertex (org.apache.tinkerpop.gremlin.structure.Vertex)2 Test (org.junit.Test)2 Attribute (ai.grakn.concept.Attribute)1 Concept (ai.grakn.concept.Concept)1 ConceptId (ai.grakn.concept.ConceptId)1 LabelId (ai.grakn.concept.LabelId)1 Relationship (ai.grakn.concept.Relationship)1 Role (ai.grakn.concept.Role)1 Thing (ai.grakn.concept.Thing)1 Type (ai.grakn.concept.Type)1 GraknTxOperationException (ai.grakn.exception.GraknTxOperationException)1 Cache (ai.grakn.kb.internal.cache.Cache)1 Cacheable (ai.grakn.kb.internal.cache.Cacheable)1 ConceptVertex (ai.grakn.kb.internal.concept.ConceptVertex)1