Search in sources :

Example 11 with AtlasEntity

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

the class TestEntitiesREST method serDeserEntity.

AtlasEntity serDeserEntity(AtlasEntity entity) throws IOException {
    //Convert from json to object and back to trigger the case where it gets translated to a map for attributes instead of AtlasEntity
    String jsonString = AtlasType.toJson(entity);
    AtlasEntity newEntity = AtlasType.fromJson(jsonString, AtlasEntity.class);
    return newEntity;
}
Also used : AtlasEntity(org.apache.atlas.model.instance.AtlasEntity)

Example 12 with AtlasEntity

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

the class TestEntitiesREST method testGetEntities.

@Test(dependsOnMethods = "testCreateOrUpdateEntities")
public void testGetEntities() throws Exception {
    final AtlasEntitiesWithExtInfo response = entityREST.getByGuids(createdGuids);
    final List<AtlasEntity> entities = response.getEntities();
    Assert.assertNotNull(entities);
    Assert.assertEquals(entities.size(), 3);
    verifyAttributes(entities);
}
Also used : AtlasEntity(org.apache.atlas.model.instance.AtlasEntity) AtlasEntitiesWithExtInfo(org.apache.atlas.model.instance.AtlasEntity.AtlasEntitiesWithExtInfo) Test(org.testng.annotations.Test)

Example 13 with AtlasEntity

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

the class QuickStartV2 method getTableId.

private String getTableId(String tableName) throws AtlasServiceException {
    Map<String, String> attributes = new HashMap<>();
    attributes.put(AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, tableName);
    AtlasEntity tableEntity = atlasClientV2.getEntityByAttribute(TABLE_TYPE, attributes).getEntity();
    return tableEntity.getGuid();
}
Also used : HashMap(java.util.HashMap) AtlasEntity(org.apache.atlas.model.instance.AtlasEntity)

Example 14 with AtlasEntity

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

the class QuickStartV2 method createInstance.

private AtlasEntity createInstance(AtlasEntity entity, String[] traitNames) throws Exception {
    AtlasEntity ret = null;
    EntityMutationResponse response = atlasClientV2.createEntity(new AtlasEntityWithExtInfo(entity));
    List<AtlasEntityHeader> entities = response.getEntitiesByOperation(EntityOperation.CREATE);
    if (CollectionUtils.isNotEmpty(entities)) {
        AtlasEntityWithExtInfo getByGuidResponse = atlasClientV2.getEntityByGuid(entities.get(0).getGuid());
        ret = getByGuidResponse.getEntity();
        System.out.println("Created entity of type [" + ret.getTypeName() + "], guid: " + ret.getGuid());
    }
    return ret;
}
Also used : AtlasEntityWithExtInfo(org.apache.atlas.model.instance.AtlasEntity.AtlasEntityWithExtInfo) AtlasEntity(org.apache.atlas.model.instance.AtlasEntity) EntityMutationResponse(org.apache.atlas.model.instance.EntityMutationResponse) AtlasEntityHeader(org.apache.atlas.model.instance.AtlasEntityHeader)

Example 15 with AtlasEntity

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

the class QuickStartV2 method createView.

AtlasEntity createView(String name, AtlasEntity db, List<AtlasEntity> inputTables, String... traitNames) throws Exception {
    AtlasEntity entity = new AtlasEntity(VIEW_TYPE);
    entity.setClassifications(toAtlasClassifications(traitNames));
    entity.setAttribute("name", name);
    entity.setAttribute(AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, name);
    entity.setAttribute("db", db);
    entity.setAttribute("inputTables", inputTables);
    return createInstance(entity, traitNames);
}
Also used : AtlasEntity(org.apache.atlas.model.instance.AtlasEntity)

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