Search in sources :

Example 11 with AtlasRelationship

use of org.apache.atlas.model.instance.AtlasRelationship in project atlas by apache.

the class AtlasRelationshipStoreV1 method getById.

@Override
@GraphTransaction
public AtlasRelationship getById(String guid) throws AtlasBaseException {
    if (LOG.isDebugEnabled()) {
        LOG.debug("==> getById({})", guid);
    }
    AtlasRelationship ret;
    AtlasEdge edge = graphHelper.getEdgeForGUID(guid);
    ret = entityRetriever.mapEdgeToAtlasRelationship(edge);
    if (LOG.isDebugEnabled()) {
        LOG.debug("<== getById({}): {}", guid, ret);
    }
    return ret;
}
Also used : AtlasRelationship(org.apache.atlas.model.instance.AtlasRelationship) AtlasEdge(org.apache.atlas.repository.graphdb.AtlasEdge) GraphTransaction(org.apache.atlas.annotation.GraphTransaction)

Example 12 with AtlasRelationship

use of org.apache.atlas.model.instance.AtlasRelationship in project incubator-atlas by apache.

the class AtlasRelationshipStoreV1 method create.

@Override
@GraphTransaction
public AtlasRelationship create(AtlasRelationship relationship) throws AtlasBaseException {
    if (LOG.isDebugEnabled()) {
        LOG.debug("==> create({})", relationship);
    }
    validateRelationship(relationship);
    AtlasVertex end1Vertex = getVertexFromEndPoint(relationship.getEnd1());
    AtlasVertex end2Vertex = getVertexFromEndPoint(relationship.getEnd2());
    AtlasRelationship ret = createRelationship(relationship, end1Vertex, end2Vertex);
    if (LOG.isDebugEnabled()) {
        LOG.debug("<== create({}): {}", relationship, ret);
    }
    return ret;
}
Also used : AtlasVertex(org.apache.atlas.repository.graphdb.AtlasVertex) AtlasRelationship(org.apache.atlas.model.instance.AtlasRelationship) GraphTransaction(org.apache.atlas.annotation.GraphTransaction)

Example 13 with AtlasRelationship

use of org.apache.atlas.model.instance.AtlasRelationship in project incubator-atlas by apache.

the class AtlasRelationshipStoreV1 method getOrCreate.

public AtlasRelationship getOrCreate(AtlasRelationship relationship) throws AtlasBaseException {
    if (LOG.isDebugEnabled()) {
        LOG.debug("==> getOrCreate({})", relationship);
    }
    validateRelationship(relationship);
    AtlasVertex end1Vertex = getVertexFromEndPoint(relationship.getEnd1());
    AtlasVertex end2Vertex = getVertexFromEndPoint(relationship.getEnd2());
    AtlasRelationship ret;
    // check if relationship exists
    AtlasEdge relationshipEdge = getRelationshipEdge(end1Vertex, end2Vertex, relationship);
    if (relationshipEdge != null) {
        ret = mapEdgeToAtlasRelationship(relationshipEdge);
    } else {
        validateRelationship(relationship);
        ret = createRelationship(relationship, end1Vertex, end2Vertex);
    }
    if (LOG.isDebugEnabled()) {
        LOG.debug("<== getOrCreate({}): {}", relationship, ret);
    }
    return ret;
}
Also used : AtlasVertex(org.apache.atlas.repository.graphdb.AtlasVertex) AtlasRelationship(org.apache.atlas.model.instance.AtlasRelationship) AtlasEdge(org.apache.atlas.repository.graphdb.AtlasEdge)

Aggregations

AtlasRelationship (org.apache.atlas.model.instance.AtlasRelationship)13 AtlasEdge (org.apache.atlas.repository.graphdb.AtlasEdge)8 AtlasVertex (org.apache.atlas.repository.graphdb.AtlasVertex)6 GraphTransaction (org.apache.atlas.annotation.GraphTransaction)5 AtlasBaseException (org.apache.atlas.exception.AtlasBaseException)4 AtlasRelationshipType (org.apache.atlas.type.AtlasRelationshipType)2 ArrayList (java.util.ArrayList)1 AtlasObjectId (org.apache.atlas.model.instance.AtlasObjectId)1 AtlasRelatedObjectId (org.apache.atlas.model.instance.AtlasRelatedObjectId)1 AtlasStruct (org.apache.atlas.model.instance.AtlasStruct)1 RepositoryException (org.apache.atlas.repository.RepositoryException)1 AtlasAttribute (org.apache.atlas.type.AtlasStructType.AtlasAttribute)1 EntityNotFoundException (org.apache.atlas.typesystem.exception.EntityNotFoundException)1