Search in sources :

Example 91 with AtlasType

use of org.apache.atlas.type.AtlasType in project incubator-atlas by apache.

the class AtlasEntityDefStoreV1 method updateByGuid.

@Override
public AtlasEntityDef updateByGuid(String guid, AtlasEntityDef entityDef) throws AtlasBaseException {
    if (LOG.isDebugEnabled()) {
        LOG.debug("==> AtlasEntityDefStoreV1.updateByGuid({})", guid);
    }
    validateType(entityDef);
    AtlasType type = typeRegistry.getTypeByGuid(guid);
    if (type.getTypeCategory() != org.apache.atlas.model.TypeCategory.ENTITY) {
        throw new AtlasBaseException(AtlasErrorCode.TYPE_MATCH_FAILED, entityDef.getName(), TypeCategory.CLASS.name());
    }
    AtlasVertex vertex = typeDefStore.findTypeVertexByGuidAndCategory(guid, TypeCategory.CLASS);
    if (vertex == null) {
        throw new AtlasBaseException(AtlasErrorCode.TYPE_GUID_NOT_FOUND, guid);
    }
    updateVertexPreUpdate(entityDef, (AtlasEntityType) type, vertex);
    updateVertexAddReferences(entityDef, vertex);
    AtlasEntityDef ret = toEntityDef(vertex);
    if (LOG.isDebugEnabled()) {
        LOG.debug("<== AtlasEntityDefStoreV1.updateByGuid({}): {}", guid, ret);
    }
    return ret;
}
Also used : AtlasBaseException(org.apache.atlas.exception.AtlasBaseException) AtlasEntityDef(org.apache.atlas.model.typedef.AtlasEntityDef) AtlasVertex(org.apache.atlas.repository.graphdb.AtlasVertex) AtlasType(org.apache.atlas.type.AtlasType)

Example 92 with AtlasType

use of org.apache.atlas.type.AtlasType in project incubator-atlas by apache.

the class AtlasEntityDefStoreV1 method updateByName.

@Override
public AtlasEntityDef updateByName(String name, AtlasEntityDef entityDef) throws AtlasBaseException {
    if (LOG.isDebugEnabled()) {
        LOG.debug("==> AtlasEntityDefStoreV1.updateByName({}, {})", name, entityDef);
    }
    validateType(entityDef);
    AtlasType type = typeRegistry.getType(entityDef.getName());
    if (type.getTypeCategory() != org.apache.atlas.model.TypeCategory.ENTITY) {
        throw new AtlasBaseException(AtlasErrorCode.TYPE_MATCH_FAILED, entityDef.getName(), TypeCategory.CLASS.name());
    }
    AtlasVertex vertex = typeDefStore.findTypeVertexByNameAndCategory(name, TypeCategory.CLASS);
    if (vertex == null) {
        throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_NOT_FOUND, name);
    }
    updateVertexPreUpdate(entityDef, (AtlasEntityType) type, vertex);
    updateVertexAddReferences(entityDef, vertex);
    AtlasEntityDef ret = toEntityDef(vertex);
    if (LOG.isDebugEnabled()) {
        LOG.debug("<== AtlasEntityDefStoreV1.updateByName({}, {}): {}", name, entityDef, ret);
    }
    return ret;
}
Also used : AtlasBaseException(org.apache.atlas.exception.AtlasBaseException) AtlasEntityDef(org.apache.atlas.model.typedef.AtlasEntityDef) AtlasVertex(org.apache.atlas.repository.graphdb.AtlasVertex) AtlasType(org.apache.atlas.type.AtlasType)

Example 93 with AtlasType

use of org.apache.atlas.type.AtlasType in project incubator-atlas by apache.

the class AtlasEntityGraphDiscoveryV1 method visitStruct.

void visitStruct(AtlasStructType structType, AtlasStruct struct) throws AtlasBaseException {
    for (AtlasAttribute attribute : structType.getAllAttributes().values()) {
        AtlasType attrType = attribute.getAttributeType();
        Object attrVal = struct.getAttribute(attribute.getName());
        visitAttribute(attrType, attrVal);
    }
}
Also used : AtlasAttribute(org.apache.atlas.type.AtlasStructType.AtlasAttribute) AtlasType(org.apache.atlas.type.AtlasType)

Example 94 with AtlasType

use of org.apache.atlas.type.AtlasType in project incubator-atlas by apache.

the class AtlasEntityGraphDiscoveryV1 method visitEntity.

void visitEntity(AtlasEntityType entityType, AtlasEntity entity) throws AtlasBaseException {
    visitStruct(entityType, entity);
    for (AtlasAttribute attribute : entityType.getRelationshipAttributes().values()) {
        AtlasType attrType = attribute.getAttributeType();
        Object attrVal = entity.getRelationshipAttribute(attribute.getName());
        visitAttribute(attrType, attrVal);
    }
}
Also used : AtlasAttribute(org.apache.atlas.type.AtlasStructType.AtlasAttribute) AtlasType(org.apache.atlas.type.AtlasType)

Example 95 with AtlasType

use of org.apache.atlas.type.AtlasType in project incubator-atlas by apache.

the class AtlasClassificationDefStoreV1 method updateByGuid.

@Override
public AtlasClassificationDef updateByGuid(String guid, AtlasClassificationDef classificationDef) throws AtlasBaseException {
    if (LOG.isDebugEnabled()) {
        LOG.debug("==> AtlasClassificationDefStoreV1.updateByGuid({})", guid);
    }
    validateType(classificationDef);
    AtlasType type = typeRegistry.getTypeByGuid(guid);
    if (type.getTypeCategory() != org.apache.atlas.model.TypeCategory.CLASSIFICATION) {
        throw new AtlasBaseException(AtlasErrorCode.TYPE_MATCH_FAILED, classificationDef.getName(), TypeCategory.TRAIT.name());
    }
    AtlasVertex vertex = typeDefStore.findTypeVertexByGuidAndCategory(guid, TypeCategory.TRAIT);
    if (vertex == null) {
        throw new AtlasBaseException(AtlasErrorCode.TYPE_GUID_NOT_FOUND, guid);
    }
    updateVertexPreUpdate(classificationDef, (AtlasClassificationType) type, vertex);
    updateVertexAddReferences(classificationDef, vertex);
    AtlasClassificationDef ret = toClassificationDef(vertex);
    if (LOG.isDebugEnabled()) {
        LOG.debug("<== AtlasClassificationDefStoreV1.updateByGuid({}): {}", guid, ret);
    }
    return ret;
}
Also used : AtlasClassificationDef(org.apache.atlas.model.typedef.AtlasClassificationDef) AtlasBaseException(org.apache.atlas.exception.AtlasBaseException) AtlasVertex(org.apache.atlas.repository.graphdb.AtlasVertex) AtlasType(org.apache.atlas.type.AtlasType)

Aggregations

AtlasType (org.apache.atlas.type.AtlasType)95 AtlasBaseException (org.apache.atlas.exception.AtlasBaseException)51 AtlasVertex (org.apache.atlas.repository.graphdb.AtlasVertex)33 AtlasAttribute (org.apache.atlas.type.AtlasStructType.AtlasAttribute)23 AtlasArrayType (org.apache.atlas.type.AtlasArrayType)17 AtlasEntityType (org.apache.atlas.type.AtlasEntityType)17 AtlasStructType (org.apache.atlas.type.AtlasStructType)16 AtlasEdge (org.apache.atlas.repository.graphdb.AtlasEdge)15 AtlasMapType (org.apache.atlas.type.AtlasMapType)13 ArrayList (java.util.ArrayList)11 AtlasEntity (org.apache.atlas.model.instance.AtlasEntity)9 HashMap (java.util.HashMap)8 AtlasTypeAccessRequest (org.apache.atlas.authorize.AtlasTypeAccessRequest)8 AtlasObjectId (org.apache.atlas.model.instance.AtlasObjectId)8 AtlasStructDef (org.apache.atlas.model.typedef.AtlasStructDef)8 Map (java.util.Map)7 List (java.util.List)6 Collection (java.util.Collection)5 LinkedHashSet (java.util.LinkedHashSet)5 Set (java.util.Set)4