Search in sources :

Example 31 with GraphTransaction

use of org.apache.atlas.annotation.GraphTransaction in project incubator-atlas by apache.

the class AtlasTypeDefGraphStore method updateEntityDefByName.

@Override
@GraphTransaction
public AtlasEntityDef updateEntityDefByName(String name, AtlasEntityDef entityDef) throws AtlasBaseException {
    AtlasTransientTypeRegistry ttr = lockTypeRegistryAndReleasePostCommit();
    tryUpdateByName(name, entityDef, ttr);
    return getEntityDefStore(ttr).updateByName(name, entityDef);
}
Also used : AtlasTransientTypeRegistry(org.apache.atlas.type.AtlasTypeRegistry.AtlasTransientTypeRegistry) GraphTransaction(org.apache.atlas.annotation.GraphTransaction)

Example 32 with GraphTransaction

use of org.apache.atlas.annotation.GraphTransaction in project incubator-atlas by apache.

the class AtlasTypeDefGraphStore method updateEnumDefByName.

@Override
@GraphTransaction
public AtlasEnumDef updateEnumDefByName(String name, AtlasEnumDef enumDef) throws AtlasBaseException {
    AtlasTransientTypeRegistry ttr = lockTypeRegistryAndReleasePostCommit();
    tryUpdateByName(name, enumDef, ttr);
    return getEnumDefStore(ttr).updateByName(name, enumDef);
}
Also used : AtlasTransientTypeRegistry(org.apache.atlas.type.AtlasTypeRegistry.AtlasTransientTypeRegistry) GraphTransaction(org.apache.atlas.annotation.GraphTransaction)

Example 33 with GraphTransaction

use of org.apache.atlas.annotation.GraphTransaction in project incubator-atlas by apache.

the class AtlasTypeDefGraphStore method updateTypesDef.

@Override
@GraphTransaction
public AtlasTypesDef updateTypesDef(AtlasTypesDef typesDef) throws AtlasBaseException {
    if (LOG.isDebugEnabled()) {
        LOG.debug("==> AtlasTypeDefGraphStore.updateTypesDef(enums={}, structs={}, classfications={}, entities={})", CollectionUtils.size(typesDef.getEnumDefs()), CollectionUtils.size(typesDef.getStructDefs()), CollectionUtils.size(typesDef.getClassificationDefs()), CollectionUtils.size(typesDef.getEntityDefs()));
    }
    AtlasTransientTypeRegistry ttr = lockTypeRegistryAndReleasePostCommit();
    // Translate any NOT FOUND errors to BAD REQUEST
    try {
        ttr.updateTypes(typesDef);
    } catch (AtlasBaseException e) {
        if (AtlasErrorCode.TYPE_NAME_NOT_FOUND == e.getAtlasErrorCode()) {
            throw new AtlasBaseException(AtlasErrorCode.BAD_REQUEST, e.getMessage());
        } else {
            throw e;
        }
    }
    AtlasTypesDef ret = updateGraphStore(typesDef, ttr);
    if (LOG.isDebugEnabled()) {
        LOG.debug("<== AtlasTypeDefGraphStore.updateTypesDef(enums={}, structs={}, classfications={}, entities={})", CollectionUtils.size(typesDef.getEnumDefs()), CollectionUtils.size(typesDef.getStructDefs()), CollectionUtils.size(typesDef.getClassificationDefs()), CollectionUtils.size(typesDef.getEntityDefs()));
    }
    return ret;
}
Also used : AtlasBaseException(org.apache.atlas.exception.AtlasBaseException) AtlasTransientTypeRegistry(org.apache.atlas.type.AtlasTypeRegistry.AtlasTransientTypeRegistry) AtlasTypesDef(org.apache.atlas.model.typedef.AtlasTypesDef) GraphTransaction(org.apache.atlas.annotation.GraphTransaction)

Example 34 with GraphTransaction

use of org.apache.atlas.annotation.GraphTransaction in project incubator-atlas by apache.

the class AtlasTypeDefGraphStore method createUpdateTypesDef.

@Override
@GraphTransaction
public AtlasTypesDef createUpdateTypesDef(AtlasTypesDef typesToCreate, AtlasTypesDef typesToUpdate) throws AtlasBaseException {
    if (LOG.isDebugEnabled()) {
        LOG.debug("==> AtlasTypeDefGraphStore.createUpdateTypesDef({}, {})", typesToCreate, typesToUpdate);
    }
    AtlasTransientTypeRegistry ttr = lockTypeRegistryAndReleasePostCommit();
    if (!typesToUpdate.isEmpty()) {
        ttr.updateTypesWithNoRefResolve(typesToUpdate);
    }
    // Translate any NOT FOUND errors to BAD REQUEST
    tryTypeCreation(typesToCreate, ttr);
    AtlasTypesDef ret = addToGraphStore(typesToCreate, ttr);
    if (!typesToUpdate.isEmpty()) {
        AtlasTypesDef updatedTypes = updateGraphStore(typesToUpdate, ttr);
        if (CollectionUtils.isNotEmpty(updatedTypes.getEnumDefs())) {
            for (AtlasEnumDef enumDef : updatedTypes.getEnumDefs()) {
                ret.getEnumDefs().add(enumDef);
            }
        }
        if (CollectionUtils.isNotEmpty(updatedTypes.getStructDefs())) {
            for (AtlasStructDef structDef : updatedTypes.getStructDefs()) {
                ret.getStructDefs().add(structDef);
            }
        }
        if (CollectionUtils.isNotEmpty(updatedTypes.getClassificationDefs())) {
            for (AtlasClassificationDef classificationDef : updatedTypes.getClassificationDefs()) {
                ret.getClassificationDefs().add(classificationDef);
            }
        }
        if (CollectionUtils.isNotEmpty(updatedTypes.getEntityDefs())) {
            for (AtlasEntityDef entityDef : updatedTypes.getEntityDefs()) {
                ret.getEntityDefs().add(entityDef);
            }
        }
    }
    if (LOG.isDebugEnabled()) {
        LOG.debug("<== AtlasTypeDefGraphStore.createUpdateTypesDef({}, {}): {}", typesToCreate, typesToUpdate, ret);
    }
    return ret;
}
Also used : AtlasStructDef(org.apache.atlas.model.typedef.AtlasStructDef) AtlasClassificationDef(org.apache.atlas.model.typedef.AtlasClassificationDef) AtlasEntityDef(org.apache.atlas.model.typedef.AtlasEntityDef) AtlasTransientTypeRegistry(org.apache.atlas.type.AtlasTypeRegistry.AtlasTransientTypeRegistry) AtlasEnumDef(org.apache.atlas.model.typedef.AtlasEnumDef) AtlasTypesDef(org.apache.atlas.model.typedef.AtlasTypesDef) GraphTransaction(org.apache.atlas.annotation.GraphTransaction)

Aggregations

GraphTransaction (org.apache.atlas.annotation.GraphTransaction)34 AtlasTransientTypeRegistry (org.apache.atlas.type.AtlasTypeRegistry.AtlasTransientTypeRegistry)12 AtlasBaseException (org.apache.atlas.exception.AtlasBaseException)11 AtlasVertex (org.apache.atlas.repository.graphdb.AtlasVertex)11 AtlasException (org.apache.atlas.AtlasException)6 RepositoryException (org.apache.atlas.repository.RepositoryException)6 ArrayList (java.util.ArrayList)5 RequestContext (org.apache.atlas.RequestContext)4 AtlasEntityWithExtInfo (org.apache.atlas.model.instance.AtlasEntity.AtlasEntityWithExtInfo)4 EntityMutationResponse (org.apache.atlas.model.instance.EntityMutationResponse)4 CreateUpdateEntitiesResult (org.apache.atlas.CreateUpdateEntitiesResult)3 AtlasEntity (org.apache.atlas.model.instance.AtlasEntity)3 GuidMapping (org.apache.atlas.model.instance.GuidMapping)3 AtlasTypesDef (org.apache.atlas.model.typedef.AtlasTypesDef)3 AtlasClassification (org.apache.atlas.model.instance.AtlasClassification)2 EntityResult (org.apache.atlas.model.legacy.EntityResult)2 AtlasClassificationDef (org.apache.atlas.model.typedef.AtlasClassificationDef)2 AtlasEntityDef (org.apache.atlas.model.typedef.AtlasEntityDef)2 AtlasEnumDef (org.apache.atlas.model.typedef.AtlasEnumDef)2 AtlasStructDef (org.apache.atlas.model.typedef.AtlasStructDef)2