Search in sources :

Example 11 with AtlasTransientTypeRegistry

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

the class AtlasTypeDefGraphStore method updateClassificationDefByGuid.

@Override
@GraphTransaction
public AtlasClassificationDef updateClassificationDefByGuid(String guid, AtlasClassificationDef classificationDef) throws AtlasBaseException {
    AtlasTransientTypeRegistry ttr = lockTypeRegistryAndReleasePostCommit();
    tryUpdateByGUID(guid, classificationDef, ttr);
    return getClassificationDefStore(ttr).updateByGuid(guid, classificationDef);
}
Also used : AtlasTransientTypeRegistry(org.apache.atlas.type.AtlasTypeRegistry.AtlasTransientTypeRegistry) GraphTransaction(org.apache.atlas.annotation.GraphTransaction)

Example 12 with AtlasTransientTypeRegistry

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

the class AtlasTypeDefGraphStore method createTypesDef.

@Override
@GraphTransaction
public AtlasTypesDef createTypesDef(AtlasTypesDef typesDef) throws AtlasBaseException {
    if (LOG.isDebugEnabled()) {
        LOG.debug("==> AtlasTypeDefGraphStore.createTypesDef(enums={}, structs={}, classifications={}, entities={})", CollectionUtils.size(typesDef.getEnumDefs()), CollectionUtils.size(typesDef.getStructDefs()), CollectionUtils.size(typesDef.getClassificationDefs()), CollectionUtils.size(typesDef.getEntityDefs()));
    }
    AtlasTransientTypeRegistry ttr = lockTypeRegistryAndReleasePostCommit();
    tryTypeCreation(typesDef, ttr);
    AtlasTypesDef ret = addToGraphStore(typesDef, ttr);
    if (LOG.isDebugEnabled()) {
        LOG.debug("<== AtlasTypeDefGraphStore.createTypesDef(enums={}, structs={}, classfications={}, entities={})", CollectionUtils.size(typesDef.getEnumDefs()), CollectionUtils.size(typesDef.getStructDefs()), CollectionUtils.size(typesDef.getClassificationDefs()), CollectionUtils.size(typesDef.getEntityDefs()));
    }
    return ret;
}
Also used : AtlasTransientTypeRegistry(org.apache.atlas.type.AtlasTypeRegistry.AtlasTransientTypeRegistry) AtlasTypesDef(org.apache.atlas.model.typedef.AtlasTypesDef) GraphTransaction(org.apache.atlas.annotation.GraphTransaction)

Example 13 with AtlasTransientTypeRegistry

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

the class ModelTestUtil method newEntityDef.

public static AtlasEntityDef newEntityDef(AtlasTypeRegistry typesRegistry, AtlasEntityDef[] superTypes) {
    int entDefIdx = IDX_ENTITY_DEF.getAndIncrement();
    AtlasEntityDef ret = new AtlasEntityDef();
    ret.setName(PREFIX_ENTITY_DEF + entDefIdx);
    ret.setDescription(ret.getName());
    ret.setAttributeDefs(newAttributeDefsWithAllBuiltInTypes(PREFIX_ATTRIBUTE_NAME));
    if (superTypes != null) {
        for (AtlasEntityDef superType : superTypes) {
            ret.addSuperType(superType.getName());
        }
    }
    AtlasTransientTypeRegistry ttr = null;
    boolean commit = false;
    try {
        ttr = typesRegistry.lockTypeRegistryForUpdate();
        ttr.addType(ret);
        commit = true;
    } catch (AtlasBaseException excp) {
        LOG.error("failed to create entity-def", excp);
        ret = null;
    } finally {
        typesRegistry.releaseTypeRegistryForUpdate(ttr, commit);
    }
    return ret;
}
Also used : AtlasEntityDef(org.apache.atlas.model.typedef.AtlasEntityDef) AtlasBaseException(org.apache.atlas.exception.AtlasBaseException) AtlasTransientTypeRegistry(org.apache.atlas.type.AtlasTypeRegistry.AtlasTransientTypeRegistry)

Example 14 with AtlasTransientTypeRegistry

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

the class ModelTestUtil method newClassificationDef.

public static AtlasClassificationDef newClassificationDef(AtlasTypeRegistry typesRegistry, AtlasClassificationDef[] superTypes) {
    int classificationDefIdx = IDX_CLASSIFICATION_DEF.getAndIncrement();
    AtlasClassificationDef ret = new AtlasClassificationDef();
    ret.setName(PREFIX_CLASSIFICATION_DEF + classificationDefIdx);
    ret.setDescription(ret.getName());
    ret.setAttributeDefs(newAttributeDefsWithAllBuiltInTypes(PREFIX_ATTRIBUTE_NAME));
    if (superTypes != null) {
        for (AtlasClassificationDef superType : superTypes) {
            ret.addSuperType(superType.getName());
        }
    }
    AtlasTransientTypeRegistry ttr = null;
    boolean commit = false;
    try {
        ttr = typesRegistry.lockTypeRegistryForUpdate();
        ttr.addType(ret);
        commit = true;
    } catch (AtlasBaseException excp) {
        LOG.error("failed to create classification-def", excp);
        ret = null;
    } finally {
        typesRegistry.releaseTypeRegistryForUpdate(ttr, commit);
    }
    return ret;
}
Also used : AtlasClassificationDef(org.apache.atlas.model.typedef.AtlasClassificationDef) AtlasBaseException(org.apache.atlas.exception.AtlasBaseException) AtlasTransientTypeRegistry(org.apache.atlas.type.AtlasTypeRegistry.AtlasTransientTypeRegistry)

Example 15 with AtlasTransientTypeRegistry

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

the class ModelTestUtil method newStructDef.

public static AtlasStructDef newStructDef(AtlasTypeRegistry typesRegistry) {
    int structDefIdx = IDX_STRUCT_DEF.getAndIncrement();
    AtlasStructDef ret = new AtlasStructDef();
    ret.setName(PREFIX_STRUCT_DEF + structDefIdx);
    ret.setDescription(ret.getName());
    ret.setAttributeDefs(newAttributeDefsWithAllBuiltInTypes(PREFIX_ATTRIBUTE_NAME));
    AtlasTransientTypeRegistry ttr = null;
    boolean commit = false;
    try {
        ttr = typesRegistry.lockTypeRegistryForUpdate();
        ttr.addType(ret);
        commit = true;
    } catch (AtlasBaseException excp) {
        LOG.error("failed to create struct-def", excp);
        ret = null;
    } finally {
        typesRegistry.releaseTypeRegistryForUpdate(ttr, commit);
    }
    return ret;
}
Also used : AtlasStructDef(org.apache.atlas.model.typedef.AtlasStructDef) AtlasBaseException(org.apache.atlas.exception.AtlasBaseException) AtlasTransientTypeRegistry(org.apache.atlas.type.AtlasTypeRegistry.AtlasTransientTypeRegistry)

Aggregations

AtlasTransientTypeRegistry (org.apache.atlas.type.AtlasTypeRegistry.AtlasTransientTypeRegistry)34 AtlasBaseException (org.apache.atlas.exception.AtlasBaseException)20 Test (org.testng.annotations.Test)14 GraphTransaction (org.apache.atlas.annotation.GraphTransaction)12 AtlasEntityDef (org.apache.atlas.model.typedef.AtlasEntityDef)9 ArrayList (java.util.ArrayList)7 AtlasErrorCode (org.apache.atlas.AtlasErrorCode)5 AtlasTypesDef (org.apache.atlas.model.typedef.AtlasTypesDef)4 AtlasClassificationDef (org.apache.atlas.model.typedef.AtlasClassificationDef)3 AtlasEnumDef (org.apache.atlas.model.typedef.AtlasEnumDef)3 AtlasStructDef (org.apache.atlas.model.typedef.AtlasStructDef)3 AtlasAttributeDef (org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef)3 AtlasEnumElementDef (org.apache.atlas.model.typedef.AtlasEnumDef.AtlasEnumElementDef)1 AtlasTypeRegistry (org.apache.atlas.type.AtlasTypeRegistry)1