Search in sources :

Example 76 with AtlasObjectId

use of org.apache.atlas.model.instance.AtlasObjectId in project atlas by apache.

the class HiveDDLEntityFilter method apply.

private HookNotification.EntityPartialUpdateRequestV2 apply(HookNotification.EntityPartialUpdateRequestV2 notification) {
    AtlasObjectId objectId = filterObjectId(notification.getEntityId());
    if (objectId == null) {
        return null;
    }
    AtlasEntity.AtlasEntityWithExtInfo entityWithExtInfo = apply(notification.getEntity());
    if (entityWithExtInfo == null) {
        return null;
    }
    return new HookNotification.EntityPartialUpdateRequestV2(notification.getUser(), objectId, entityWithExtInfo);
}
Also used : AtlasEntity(org.apache.atlas.model.instance.AtlasEntity) AtlasObjectId(org.apache.atlas.model.instance.AtlasObjectId)

Example 77 with AtlasObjectId

use of org.apache.atlas.model.instance.AtlasObjectId in project atlas by apache.

the class DropTable method getHiveEntities.

public List<AtlasObjectId> getHiveEntities() {
    List<AtlasObjectId> ret = new ArrayList<>();
    for (Entity entity : getOutputs()) {
        if (entity.getType() == Entity.Type.TABLE) {
            String tblQName = getQualifiedName(entity.getTable());
            AtlasObjectId tblId = new AtlasObjectId(HIVE_TYPE_TABLE, ATTRIBUTE_QUALIFIED_NAME, tblQName);
            context.removeFromKnownTable(tblQName);
            ret.add(tblId);
        }
    }
    return ret;
}
Also used : Entity(org.apache.hadoop.hive.ql.hooks.Entity) ArrayList(java.util.ArrayList) AtlasObjectId(org.apache.atlas.model.instance.AtlasObjectId)

Example 78 with AtlasObjectId

use of org.apache.atlas.model.instance.AtlasObjectId in project atlas by apache.

the class HiveITBase method validateHDFSPaths.

protected void validateHDFSPaths(AtlasEntity processEntity, String attributeName, String... testPaths) throws Exception {
    List<AtlasObjectId> hdfsPathIds = toAtlasObjectIdList(processEntity.getAttribute(attributeName));
    for (String testPath : testPaths) {
        Path path = new Path(testPath);
        String testPathNormed = lower(path.toString());
        String hdfsPathId = assertHDFSPathIsRegistered(testPathNormed);
        assertHDFSPathIdsContain(hdfsPathIds, hdfsPathId);
    }
}
Also used : Path(org.apache.hadoop.fs.Path) AtlasObjectId(org.apache.atlas.model.instance.AtlasObjectId)

Example 79 with AtlasObjectId

use of org.apache.atlas.model.instance.AtlasObjectId in project atlas by apache.

the class HiveITBase method toAtlasObjectIdList.

protected List<AtlasObjectId> toAtlasObjectIdList(Object obj) {
    final List<AtlasObjectId> ret;
    if (obj instanceof Collection) {
        Collection coll = (Collection) obj;
        ret = new ArrayList<>(coll.size());
        for (Object item : coll) {
            AtlasObjectId objId = toAtlasObjectId(item);
            if (objId != null) {
                ret.add(objId);
            }
        }
    } else {
        AtlasObjectId objId = toAtlasObjectId(obj);
        if (objId != null) {
            ret = new ArrayList<>(1);
            ret.add(objId);
        } else {
            ret = null;
        }
    }
    return ret;
}
Also used : Collection(java.util.Collection) AtlasObjectId(org.apache.atlas.model.instance.AtlasObjectId) JSONObject(org.json.JSONObject)

Example 80 with AtlasObjectId

use of org.apache.atlas.model.instance.AtlasObjectId in project atlas by apache.

the class TestAtlasObjectIdType method testObjectIdTypeGetNormalizedValue.

@Test
public void testObjectIdTypeGetNormalizedValue() {
    assertNull(objectIdType.getNormalizedValue(null), "value=" + null);
    for (Object value : validValues) {
        if (value == null) {
            continue;
        }
        AtlasObjectId normalizedValue = objectIdType.getNormalizedValue(value);
        assertNotNull(normalizedValue, "value=" + value);
        if (value instanceof AtlasObjectId) {
            assertEquals(normalizedValue, value, "value=" + value);
        } else if (value instanceof Map) {
            assertEquals(normalizedValue.getTypeName(), ((Map) value).get(AtlasObjectId.KEY_TYPENAME), "value=" + value);
            if (((Map) value).get(AtlasObjectId.KEY_GUID) == null) {
                assertEquals(normalizedValue.getGuid(), ((Map) value).get(AtlasObjectId.KEY_GUID), "value=" + value);
            } else {
                assertEquals(normalizedValue.getGuid(), ((Map) value).get(AtlasObjectId.KEY_GUID), "value=" + value);
            }
            assertEquals(normalizedValue.getUniqueAttributes(), ((Map) value).get(AtlasObjectId.KEY_UNIQUE_ATTRIBUTES), "value=" + value);
        }
    }
}
Also used : AtlasObjectId(org.apache.atlas.model.instance.AtlasObjectId) Map(java.util.Map) HashMap(java.util.HashMap) Test(org.testng.annotations.Test)

Aggregations

AtlasObjectId (org.apache.atlas.model.instance.AtlasObjectId)255 AtlasEntity (org.apache.atlas.model.instance.AtlasEntity)124 Test (org.testng.annotations.Test)70 ArrayList (java.util.ArrayList)69 Map (java.util.Map)47 EntityMutationResponse (org.apache.atlas.model.instance.EntityMutationResponse)44 AtlasEntityHeader (org.apache.atlas.model.instance.AtlasEntityHeader)41 AtlasEntityType (org.apache.atlas.type.AtlasEntityType)41 HashMap (java.util.HashMap)40 AtlasVertex (org.apache.atlas.repository.graphdb.AtlasVertex)38 List (java.util.List)36 AtlasEntityWithExtInfo (org.apache.atlas.model.instance.AtlasEntity.AtlasEntityWithExtInfo)33 AtlasBaseException (org.apache.atlas.exception.AtlasBaseException)32 BeforeTest (org.testng.annotations.BeforeTest)32 AtlasEntitiesWithExtInfo (org.apache.atlas.model.instance.AtlasEntity.AtlasEntitiesWithExtInfo)29 AtlasTypeUtil.getAtlasObjectId (org.apache.atlas.type.AtlasTypeUtil.getAtlasObjectId)24 AtlasStruct (org.apache.atlas.model.instance.AtlasStruct)22 AtlasExportRequest (org.apache.atlas.model.impexp.AtlasExportRequest)14 AtlasEdge (org.apache.atlas.repository.graphdb.AtlasEdge)13 AtlasType (org.apache.atlas.type.AtlasType)11