Search in sources :

Example 21 with TraitType

use of org.apache.atlas.typesystem.types.TraitType in project incubator-atlas by apache.

the class DataSetLineageJerseyResourceIT method setupInstances.

private void setupInstances() throws Exception {
    HierarchicalTypeDefinition<TraitType> factTrait = TypesUtil.createTraitTypeDef("Fact", ImmutableSet.<String>of());
    HierarchicalTypeDefinition<TraitType> etlTrait = TypesUtil.createTraitTypeDef("ETL", ImmutableSet.<String>of());
    HierarchicalTypeDefinition<TraitType> dimensionTrait = TypesUtil.createTraitTypeDef("Dimension", ImmutableSet.<String>of());
    HierarchicalTypeDefinition<TraitType> metricTrait = TypesUtil.createTraitTypeDef("Metric", ImmutableSet.<String>of());
    createType(getTypesDef(null, null, ImmutableList.of(factTrait, etlTrait, dimensionTrait, metricTrait), null));
    salesDBName = "Sales" + randomString();
    Id salesDB = database(salesDBName, "Sales Database", "John ETL", "hdfs://host:8000/apps/warehouse/sales");
    List<Referenceable> salesFactColumns = ImmutableList.of(column("time_id", "int", "time id"), column("product_id", "int", "product id"), column("customer_id", "int", "customer id", "pii"), column("sales", "double", "product id", "Metric"));
    salesFactTable = "sales_fact" + randomString();
    Id salesFact = table(salesFactTable, "sales fact table", salesDB, "Joe", "MANAGED", salesFactColumns, "Fact");
    List<Referenceable> timeDimColumns = ImmutableList.of(column("time_id", "int", "time id"), column("dayOfYear", "int", "day Of Year"), column("weekDay", "int", "week Day"));
    Id timeDim = table("time_dim" + randomString(), "time dimension table", salesDB, "John Doe", "EXTERNAL", timeDimColumns, "Dimension");
    Id reportingDB = database("Reporting" + randomString(), "reporting database", "Jane BI", "hdfs://host:8000/apps/warehouse/reporting");
    Id salesFactDaily = table("sales_fact_daily_mv" + randomString(), "sales fact daily materialized view", reportingDB, "Joe BI", "MANAGED", salesFactColumns, "Metric");
    loadProcess("loadSalesDaily" + randomString(), "John ETL", ImmutableList.of(salesFact, timeDim), ImmutableList.of(salesFactDaily), "create table as select ", "plan", "id", "graph", "ETL");
    salesMonthlyTable = "sales_fact_monthly_mv" + randomString();
    Id salesFactMonthly = table(salesMonthlyTable, "sales fact monthly materialized view", reportingDB, "Jane BI", "MANAGED", salesFactColumns, "Metric");
    loadProcess("loadSalesMonthly" + randomString(), "John ETL", ImmutableList.of(salesFactDaily), ImmutableList.of(salesFactMonthly), "create table as select ", "plan", "id", "graph", "ETL");
}
Also used : Referenceable(org.apache.atlas.typesystem.Referenceable) TraitType(org.apache.atlas.typesystem.types.TraitType) Id(org.apache.atlas.typesystem.persistence.Id)

Example 22 with TraitType

use of org.apache.atlas.typesystem.types.TraitType in project incubator-atlas by apache.

the class EntityJerseyResourceIT method testUTF8.

@Test
public void testUTF8() throws Exception {
    // Type names cannot be arbitrary UTF8 characters. See org.apache.atlas.type.AtlasTypeUtil#validateType()
    String classType = randomString();
    String attrName = random();
    String attrValue = random();
    HierarchicalTypeDefinition<ClassType> classTypeDefinition = TypesUtil.createClassTypeDef(classType, ImmutableSet.<String>of(), TypesUtil.createUniqueRequiredAttrDef(attrName, DataTypes.STRING_TYPE));
    TypesDef typesDef = TypesUtil.getTypesDef(ImmutableList.<EnumTypeDefinition>of(), ImmutableList.<StructTypeDefinition>of(), ImmutableList.<HierarchicalTypeDefinition<TraitType>>of(), ImmutableList.of(classTypeDefinition));
    createType(typesDef);
    Referenceable instance = new Referenceable(classType);
    instance.set(attrName, attrValue);
    Id guid = createInstance(instance);
    JSONObject response = atlasClientV1.callAPIWithBodyAndParams(AtlasClient.API.GET_ENTITY, null, guid._getId());
    Referenceable getReferenceable = InstanceSerialization.fromJsonReferenceable(response.getString(AtlasClient.DEFINITION), true);
    Assert.assertEquals(getReferenceable.get(attrName), attrValue);
}
Also used : TypesDef(org.apache.atlas.typesystem.TypesDef) Referenceable(org.apache.atlas.typesystem.Referenceable) JSONObject(org.codehaus.jettison.json.JSONObject) TraitType(org.apache.atlas.typesystem.types.TraitType) Id(org.apache.atlas.typesystem.persistence.Id) ClassType(org.apache.atlas.typesystem.types.ClassType) Test(org.testng.annotations.Test)

Example 23 with TraitType

use of org.apache.atlas.typesystem.types.TraitType in project incubator-atlas by apache.

the class TypesJerseyResourceIT method createHiveTypes.

private List<HierarchicalTypeDefinition> createHiveTypes() throws Exception {
    ArrayList<HierarchicalTypeDefinition> typeDefinitions = new ArrayList<>();
    HierarchicalTypeDefinition<ClassType> databaseTypeDefinition = TypesUtil.createClassTypeDef("database", ImmutableSet.<String>of(), TypesUtil.createUniqueRequiredAttrDef(NAME, DataTypes.STRING_TYPE), TypesUtil.createRequiredAttrDef(DESCRIPTION, DataTypes.STRING_TYPE), TypesUtil.createRequiredAttrDef(QUALIFIED_NAME, DataTypes.STRING_TYPE));
    typeDefinitions.add(databaseTypeDefinition);
    HierarchicalTypeDefinition<ClassType> tableTypeDefinition = TypesUtil.createClassTypeDef("table", ImmutableSet.<String>of(), TypesUtil.createUniqueRequiredAttrDef(NAME, DataTypes.STRING_TYPE), TypesUtil.createRequiredAttrDef(DESCRIPTION, DataTypes.STRING_TYPE), TypesUtil.createRequiredAttrDef(QUALIFIED_NAME, DataTypes.STRING_TYPE), createOptionalAttrDef("columnNames", DataTypes.arrayTypeName(DataTypes.STRING_TYPE)), createOptionalAttrDef("created", DataTypes.DATE_TYPE), createOptionalAttrDef("parameters", DataTypes.mapTypeName(DataTypes.STRING_TYPE, DataTypes.STRING_TYPE)), TypesUtil.createRequiredAttrDef("type", DataTypes.STRING_TYPE), new AttributeDefinition("database", "database", Multiplicity.REQUIRED, false, "database"));
    typeDefinitions.add(tableTypeDefinition);
    HierarchicalTypeDefinition<TraitType> fetlTypeDefinition = TypesUtil.createTraitTypeDef("fetl", ImmutableSet.<String>of(), TypesUtil.createRequiredAttrDef("level", DataTypes.INT_TYPE));
    typeDefinitions.add(fetlTypeDefinition);
    return typeDefinitions;
}
Also used : HierarchicalTypeDefinition(org.apache.atlas.typesystem.types.HierarchicalTypeDefinition) TraitType(org.apache.atlas.typesystem.types.TraitType) ArrayList(java.util.ArrayList) AttributeDefinition(org.apache.atlas.typesystem.types.AttributeDefinition) ClassType(org.apache.atlas.typesystem.types.ClassType)

Example 24 with TraitType

use of org.apache.atlas.typesystem.types.TraitType in project incubator-atlas by apache.

the class TypesJerseyResourceIT method testDuplicateSubmit.

@Test
public void testDuplicateSubmit() throws Exception {
    HierarchicalTypeDefinition<ClassType> type = TypesUtil.createClassTypeDef(randomString(), ImmutableSet.<String>of(), TypesUtil.createUniqueRequiredAttrDef(NAME, DataTypes.STRING_TYPE));
    TypesDef typesDef = TypesUtil.getTypesDef(ImmutableList.<EnumTypeDefinition>of(), ImmutableList.<StructTypeDefinition>of(), ImmutableList.<HierarchicalTypeDefinition<TraitType>>of(), ImmutableList.of(type));
    atlasClientV1.createType(typesDef);
    try {
        atlasClientV1.createType(typesDef);
        fail("Expected 409");
    } catch (AtlasServiceException e) {
        assertEquals(e.getStatus().getStatusCode(), Response.Status.CONFLICT.getStatusCode());
    }
}
Also used : TypesDef(org.apache.atlas.typesystem.TypesDef) AtlasServiceException(org.apache.atlas.AtlasServiceException) TraitType(org.apache.atlas.typesystem.types.TraitType) ClassType(org.apache.atlas.typesystem.types.ClassType) Test(org.testng.annotations.Test)

Example 25 with TraitType

use of org.apache.atlas.typesystem.types.TraitType in project incubator-atlas by apache.

the class MetadataDiscoveryJerseyResourceIT method createTypes.

private void createTypes() throws Exception {
    createTypeDefinitionsV1();
    HierarchicalTypeDefinition<ClassType> dslTestTypeDefinition = TypesUtil.createClassTypeDef("dsl_test_type", ImmutableSet.<String>of(), TypesUtil.createUniqueRequiredAttrDef("name", DataTypes.STRING_TYPE), TypesUtil.createRequiredAttrDef("description", DataTypes.STRING_TYPE));
    HierarchicalTypeDefinition<TraitType> classificationTraitDefinition = TypesUtil.createTraitTypeDef("Classification", ImmutableSet.<String>of(), TypesUtil.createRequiredAttrDef("tag", DataTypes.STRING_TYPE));
    TypesDef typesDef = TypesUtil.getTypesDef(ImmutableList.<EnumTypeDefinition>of(), ImmutableList.<StructTypeDefinition>of(), ImmutableList.of(classificationTraitDefinition), ImmutableList.of(dslTestTypeDefinition));
    createType(typesDef);
}
Also used : TypesDef(org.apache.atlas.typesystem.TypesDef) TraitType(org.apache.atlas.typesystem.types.TraitType) ClassType(org.apache.atlas.typesystem.types.ClassType)

Aggregations

TraitType (org.apache.atlas.typesystem.types.TraitType)40 Test (org.testng.annotations.Test)22 ClassType (org.apache.atlas.typesystem.types.ClassType)19 TypesDef (org.apache.atlas.typesystem.TypesDef)13 Referenceable (org.apache.atlas.typesystem.Referenceable)12 Struct (org.apache.atlas.typesystem.Struct)12 Id (org.apache.atlas.typesystem.persistence.Id)10 AttributeDefinition (org.apache.atlas.typesystem.types.AttributeDefinition)10 ITypedReferenceableInstance (org.apache.atlas.typesystem.ITypedReferenceableInstance)7 TypeSystem (org.apache.atlas.typesystem.types.TypeSystem)7 IStruct (org.apache.atlas.typesystem.IStruct)6 ITypedStruct (org.apache.atlas.typesystem.ITypedStruct)6 ArrayList (java.util.ArrayList)5 AtlasTypesDef (org.apache.atlas.model.typedef.AtlasTypesDef)5 AtlasServiceException (org.apache.atlas.AtlasServiceException)4 HierarchicalTypeDefinition (org.apache.atlas.typesystem.types.HierarchicalTypeDefinition)3 BeforeTest (org.testng.annotations.BeforeTest)3 ImmutableList (com.google.common.collect.ImmutableList)2 ImmutableSet (com.google.common.collect.ImmutableSet)2 HashMap (java.util.HashMap)2