Search in sources :

Example 56 with AtlasTypesDef

use of org.apache.atlas.model.typedef.AtlasTypesDef in project incubator-atlas by apache.

the class RestUtilsTest method convertV1toV2.

private List<AtlasEntityDef> convertV1toV2(List<HierarchicalTypeDefinition<ClassType>> types) throws AtlasBaseException {
    ImmutableList<HierarchicalTypeDefinition<ClassType>> classTypeList = ImmutableList.<HierarchicalTypeDefinition<ClassType>>builder().addAll(types).build();
    TypesDef toConvert = TypesUtil.getTypesDef(ImmutableList.<EnumTypeDefinition>of(), ImmutableList.<StructTypeDefinition>of(), ImmutableList.<HierarchicalTypeDefinition<TraitType>>of(), classTypeList);
    String json = TypesSerialization.toJson(toConvert);
    AtlasTypeRegistry emptyRegistry = new AtlasTypeRegistry();
    AtlasTypesDef converted = TypeConverterUtil.toAtlasTypesDef(json, emptyRegistry);
    List<AtlasEntityDef> convertedEntityDefs = converted.getEntityDefs();
    return convertedEntityDefs;
}
Also used : HierarchicalTypeDefinition(org.apache.atlas.typesystem.types.HierarchicalTypeDefinition) AtlasEntityDef(org.apache.atlas.model.typedef.AtlasEntityDef) AtlasTypesDef(org.apache.atlas.model.typedef.AtlasTypesDef) TypesDef(org.apache.atlas.typesystem.TypesDef) TraitType(org.apache.atlas.typesystem.types.TraitType) AtlasTypeRegistry(org.apache.atlas.type.AtlasTypeRegistry) AtlasTypesDef(org.apache.atlas.model.typedef.AtlasTypesDef)

Example 57 with AtlasTypesDef

use of org.apache.atlas.model.typedef.AtlasTypesDef in project incubator-atlas by apache.

the class TestEntitiesREST method setUp.

@BeforeClass
public void setUp() throws Exception {
    AtlasTypesDef[] testTypesDefs = new AtlasTypesDef[] { TestUtilsV2.defineHiveTypes() };
    for (AtlasTypesDef typesDef : testTypesDefs) {
        AtlasTypesDef typesToCreate = AtlasTypeDefStoreInitializer.getTypesToCreate(typesDef, typeRegistry);
        if (!typesToCreate.isEmpty()) {
            typeStore.createTypesDef(typesToCreate);
        }
    }
    dbEntity = TestUtilsV2.createDBEntity();
    tableEntity = TestUtilsV2.createTableEntity(dbEntity);
    final AtlasEntity colEntity = TestUtilsV2.createColumnEntity(tableEntity);
    columns = new ArrayList<AtlasEntity>() {

        {
            add(colEntity);
        }
    };
    tableEntity.setAttribute("columns", getObjIdList(columns));
}
Also used : AtlasEntity(org.apache.atlas.model.instance.AtlasEntity) AtlasTypesDef(org.apache.atlas.model.typedef.AtlasTypesDef) BeforeClass(org.testng.annotations.BeforeClass)

Example 58 with AtlasTypesDef

use of org.apache.atlas.model.typedef.AtlasTypesDef in project incubator-atlas by apache.

the class TestEntityREST method setUp.

@BeforeClass
public void setUp() throws Exception {
    AtlasTypesDef typesDef = TestUtilsV2.defineHiveTypes();
    typeStore.createTypesDef(typesDef);
}
Also used : AtlasTypesDef(org.apache.atlas.model.typedef.AtlasTypesDef) BeforeClass(org.testng.annotations.BeforeClass)

Example 59 with AtlasTypesDef

use of org.apache.atlas.model.typedef.AtlasTypesDef in project incubator-atlas by apache.

the class AtlasTypeDefGraphStore method updateGraphStore.

private AtlasTypesDef updateGraphStore(AtlasTypesDef typesDef, AtlasTransientTypeRegistry ttr) throws AtlasBaseException {
    AtlasTypesDef ret = new AtlasTypesDef();
    AtlasEnumDefStore enumDefStore = getEnumDefStore(ttr);
    AtlasStructDefStore structDefStore = getStructDefStore(ttr);
    AtlasClassificationDefStore classifiDefStore = getClassificationDefStore(ttr);
    AtlasEntityDefStore entityDefStore = getEntityDefStore(ttr);
    if (CollectionUtils.isNotEmpty(typesDef.getEnumDefs())) {
        for (AtlasEnumDef enumDef : typesDef.getEnumDefs()) {
            ret.getEnumDefs().add(enumDefStore.update(enumDef));
        }
    }
    if (CollectionUtils.isNotEmpty(typesDef.getStructDefs())) {
        for (AtlasStructDef structDef : typesDef.getStructDefs()) {
            ret.getStructDefs().add(structDefStore.update(structDef));
        }
    }
    if (CollectionUtils.isNotEmpty(typesDef.getClassificationDefs())) {
        for (AtlasClassificationDef classifiDef : typesDef.getClassificationDefs()) {
            ret.getClassificationDefs().add(classifiDefStore.update(classifiDef));
        }
    }
    if (CollectionUtils.isNotEmpty(typesDef.getEntityDefs())) {
        for (AtlasEntityDef entityDef : typesDef.getEntityDefs()) {
            ret.getEntityDefs().add(entityDefStore.update(entityDef));
        }
    }
    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) AtlasEnumDef(org.apache.atlas.model.typedef.AtlasEnumDef) AtlasTypesDef(org.apache.atlas.model.typedef.AtlasTypesDef)

Example 60 with AtlasTypesDef

use of org.apache.atlas.model.typedef.AtlasTypesDef 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)

Aggregations

AtlasTypesDef (org.apache.atlas.model.typedef.AtlasTypesDef)64 AtlasEntityDef (org.apache.atlas.model.typedef.AtlasEntityDef)30 Test (org.testng.annotations.Test)25 AtlasClassificationDef (org.apache.atlas.model.typedef.AtlasClassificationDef)22 AtlasStructDef (org.apache.atlas.model.typedef.AtlasStructDef)20 AtlasBaseException (org.apache.atlas.exception.AtlasBaseException)16 AtlasEnumDef (org.apache.atlas.model.typedef.AtlasEnumDef)13 AtlasEntity (org.apache.atlas.model.instance.AtlasEntity)12 AtlasAttributeDef (org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef)9 SearchFilter (org.apache.atlas.model.SearchFilter)8 ArrayList (java.util.ArrayList)7 AtlasEntityHeader (org.apache.atlas.model.instance.AtlasEntityHeader)7 EntityMutationResponse (org.apache.atlas.model.instance.EntityMutationResponse)7 HashMap (java.util.HashMap)6 AtlasConstraintDef (org.apache.atlas.model.typedef.AtlasStructDef.AtlasConstraintDef)6 BeforeClass (org.testng.annotations.BeforeClass)6 BeforeTest (org.testng.annotations.BeforeTest)5 Produces (javax.ws.rs.Produces)4 AtlasClassification (org.apache.atlas.model.instance.AtlasClassification)4 AtlasObjectId (org.apache.atlas.model.instance.AtlasObjectId)4