Search in sources :

Example 66 with AtlasEntity

use of org.apache.atlas.model.instance.AtlasEntity in project incubator-atlas by apache.

the class QuickStartV2 method createStorageDescriptor.

AtlasEntity createStorageDescriptor(String location, String inputFormat, String outputFormat, boolean compressed) throws Exception {
    AtlasEntity entity = new AtlasEntity(STORAGE_DESC_TYPE);
    entity.setAttribute("location", location);
    entity.setAttribute("inputFormat", inputFormat);
    entity.setAttribute("outputFormat", outputFormat);
    entity.setAttribute("compressed", compressed);
    return createInstance(entity, null);
}
Also used : AtlasEntity(org.apache.atlas.model.instance.AtlasEntity)

Example 67 with AtlasEntity

use of org.apache.atlas.model.instance.AtlasEntity in project incubator-atlas by apache.

the class QuickStartV2 method createColumn.

AtlasEntity createColumn(String name, String dataType, String comment, String... traitNames) throws Exception {
    AtlasEntity entity = new AtlasEntity(COLUMN_TYPE);
    entity.setClassifications(toAtlasClassifications(traitNames));
    entity.setAttribute("name", name);
    entity.setAttribute("dataType", dataType);
    entity.setAttribute("comment", comment);
    return createInstance(entity, traitNames);
}
Also used : AtlasEntity(org.apache.atlas.model.instance.AtlasEntity)

Example 68 with AtlasEntity

use of org.apache.atlas.model.instance.AtlasEntity in project incubator-atlas by apache.

the class QuickStartV2 method createProcess.

AtlasEntity createProcess(String name, String description, String user, List<AtlasEntity> inputs, List<AtlasEntity> outputs, String queryText, String queryPlan, String queryId, String queryGraph, String... traitNames) throws Exception {
    AtlasEntity entity = new AtlasEntity(LOAD_PROCESS_TYPE);
    entity.setClassifications(toAtlasClassifications(traitNames));
    entity.setAttribute(AtlasClient.NAME, name);
    entity.setAttribute(AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, name);
    entity.setAttribute("description", description);
    entity.setAttribute("inputs", inputs);
    entity.setAttribute("outputs", outputs);
    entity.setAttribute("user", user);
    entity.setAttribute("startTime", System.currentTimeMillis());
    entity.setAttribute("endTime", System.currentTimeMillis() + 10000);
    entity.setAttribute("queryText", queryText);
    entity.setAttribute("queryPlan", queryPlan);
    entity.setAttribute("queryId", queryId);
    entity.setAttribute("queryGraph", queryGraph);
    return createInstance(entity, traitNames);
}
Also used : AtlasEntity(org.apache.atlas.model.instance.AtlasEntity)

Example 69 with AtlasEntity

use of org.apache.atlas.model.instance.AtlasEntity in project incubator-atlas by apache.

the class QuickStartV2 method createTable.

AtlasEntity createTable(String name, String description, AtlasEntity db, AtlasEntity sd, String owner, String tableType, List<AtlasEntity> columns, String... traitNames) throws Exception {
    AtlasEntity entity = new AtlasEntity(TABLE_TYPE);
    entity.setClassifications(toAtlasClassifications(traitNames));
    entity.setAttribute("name", name);
    entity.setAttribute(AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, name);
    entity.setAttribute("description", description);
    entity.setAttribute("owner", owner);
    entity.setAttribute("tableType", tableType);
    entity.setAttribute("createTime", System.currentTimeMillis());
    entity.setAttribute("lastAccessTime", System.currentTimeMillis());
    entity.setAttribute("retention", System.currentTimeMillis());
    entity.setAttribute("db", AtlasTypeUtil.getAtlasObjectId(db));
    entity.setAttribute("sd", AtlasTypeUtil.getAtlasObjectId(sd));
    entity.setAttribute("columns", AtlasTypeUtil.toObjectIds(columns));
    return createInstance(entity, traitNames);
}
Also used : AtlasEntity(org.apache.atlas.model.instance.AtlasEntity)

Example 70 with AtlasEntity

use of org.apache.atlas.model.instance.AtlasEntity in project incubator-atlas by apache.

the class BaseResourceIT method createHiveTableInstanceV2.

protected AtlasEntity createHiveTableInstanceV2(AtlasEntity databaseInstance, String tableName) throws Exception {
    AtlasEntity tableInstance = new AtlasEntity(HIVE_TABLE_TYPE_V2);
    tableInstance.setClassifications(Arrays.asList(new AtlasClassification("classification"), new AtlasClassification("pii"), new AtlasClassification("phi"), new AtlasClassification("pci"), new AtlasClassification("sox"), new AtlasClassification("sec"), new AtlasClassification("finance")));
    tableInstance.setAttribute(NAME, tableName);
    tableInstance.setAttribute(AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, tableName);
    tableInstance.setAttribute("db", AtlasTypeUtil.getAtlasObjectId(databaseInstance));
    tableInstance.setAttribute(DESCRIPTION, "bar table");
    tableInstance.setAttribute("lastAccessTime", "2014-07-11T08:00:00.000Z");
    tableInstance.setAttribute("type", "managed");
    tableInstance.setAttribute("level", 2);
    // enum
    tableInstance.setAttribute("tableType", "MANAGED");
    tableInstance.setAttribute("compressed", false);
    AtlasClassification classification = tableInstance.getClassifications().get(0);
    classification.setAttribute("tag", "foundation_etl");
    AtlasStruct serde1Instance = new AtlasStruct("serdeType");
    serde1Instance.setAttribute(NAME, "serde1");
    serde1Instance.setAttribute("serde", "serde1");
    tableInstance.setAttribute("serde1", serde1Instance);
    AtlasStruct serde2Instance = new AtlasStruct("serdeType");
    serde2Instance.setAttribute(NAME, "serde2");
    serde2Instance.setAttribute("serde", "serde2");
    tableInstance.setAttribute("serde2", serde2Instance);
    List<AtlasClassification> traits = tableInstance.getClassifications();
    Assert.assertEquals(traits.size(), 7);
    return tableInstance;
}
Also used : AtlasStruct(org.apache.atlas.model.instance.AtlasStruct) AtlasEntity(org.apache.atlas.model.instance.AtlasEntity) AtlasClassification(org.apache.atlas.model.instance.AtlasClassification)

Aggregations

AtlasEntity (org.apache.atlas.model.instance.AtlasEntity)124 Test (org.testng.annotations.Test)58 EntityMutationResponse (org.apache.atlas.model.instance.EntityMutationResponse)43 AtlasEntityHeader (org.apache.atlas.model.instance.AtlasEntityHeader)36 HashMap (java.util.HashMap)25 BeforeTest (org.testng.annotations.BeforeTest)25 AtlasEntityWithExtInfo (org.apache.atlas.model.instance.AtlasEntity.AtlasEntityWithExtInfo)24 AtlasObjectId (org.apache.atlas.model.instance.AtlasObjectId)24 AtlasEntitiesWithExtInfo (org.apache.atlas.model.instance.AtlasEntity.AtlasEntitiesWithExtInfo)21 AtlasEntityType (org.apache.atlas.type.AtlasEntityType)17 ArrayList (java.util.ArrayList)16 AtlasBaseException (org.apache.atlas.exception.AtlasBaseException)14 Map (java.util.Map)12 List (java.util.List)11 AtlasTypesDef (org.apache.atlas.model.typedef.AtlasTypesDef)11 AtlasStruct (org.apache.atlas.model.instance.AtlasStruct)9 ITypedReferenceableInstance (org.apache.atlas.typesystem.ITypedReferenceableInstance)9 TestUtils.randomString (org.apache.atlas.TestUtils.randomString)7 AtlasEntityDef (org.apache.atlas.model.typedef.AtlasEntityDef)7 AtlasVertex (org.apache.atlas.repository.graphdb.AtlasVertex)7