Search in sources :

Example 31 with AtlasObjectId

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

the class ExportService method processItems.

private AtlasExportResult.OperationStatus[] processItems(AtlasExportRequest request, ExportContext context) throws AtlasServiceException, AtlasException, AtlasBaseException {
    AtlasExportResult.OperationStatus[] statuses = new AtlasExportResult.OperationStatus[request.getItemsToExport().size()];
    List<AtlasObjectId> itemsToExport = request.getItemsToExport();
    for (int i = 0; i < itemsToExport.size(); i++) {
        AtlasObjectId item = itemsToExport.get(i);
        statuses[i] = processObjectId(item, context);
    }
    return statuses;
}
Also used : AtlasObjectId(org.apache.atlas.model.instance.AtlasObjectId)

Example 32 with AtlasObjectId

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

the class InverseReferenceUpdateV1Test method verifyReferenceValue.

protected void verifyReferenceValue(AtlasEntity entity, String refName, String expectedGuid) {
    Object refValue = entity.getAttribute(refName);
    if (expectedGuid == null) {
        assertNull(refValue);
    } else {
        assertTrue(refValue instanceof AtlasObjectId);
        AtlasObjectId referencedObjectId = (AtlasObjectId) refValue;
        assertEquals(referencedObjectId.getGuid(), expectedGuid);
    }
}
Also used : AtlasObjectId(org.apache.atlas.model.instance.AtlasObjectId)

Example 33 with AtlasObjectId

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

the class SoftDeleteHandlerV1Test method assertJohnForTestDisconnectBidirectionalReferences.

@Override
protected void assertJohnForTestDisconnectBidirectionalReferences(final AtlasEntity.AtlasEntityWithExtInfo john, final String janeGuid) throws Exception {
    AtlasObjectId mgr = (AtlasObjectId) john.getEntity().getAttribute("manager");
    assertNotNull(mgr);
    assertEquals(mgr.getGuid(), janeGuid);
    final AtlasEntity.AtlasEntityWithExtInfo mgrEntity = entityStore.getById(mgr.getGuid());
    assertEquals(mgrEntity.getEntity().getStatus(), AtlasEntity.Status.DELETED);
}
Also used : AtlasEntity(org.apache.atlas.model.instance.AtlasEntity) AtlasObjectId(org.apache.atlas.model.instance.AtlasObjectId)

Example 34 with AtlasObjectId

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

the class InverseReferenceUpdateSoftDeleteV1Test method verify_testInverseReferenceAutoUpdate_Map.

@Override
protected void verify_testInverseReferenceAutoUpdate_Map(AtlasEntity a1, AtlasEntity b1, AtlasEntity b2, AtlasEntity b3) {
    Object value = a1.getAttribute("mapToB");
    assertTrue(value instanceof Map);
    Map<String, AtlasObjectId> refMap = (Map<String, AtlasObjectId>) value;
    assertEquals(refMap.size(), 3);
    AtlasObjectId referencedEntityId = refMap.get("b3");
    assertEquals(referencedEntityId, AtlasTypeUtil.getAtlasObjectId(b3));
    verifyReferenceValue(b1, "mappedFromA", a1.getGuid());
    verifyReferenceValue(b2, "mappedFromA", a1.getGuid());
}
Also used : AtlasObjectId(org.apache.atlas.model.instance.AtlasObjectId) Map(java.util.Map)

Example 35 with AtlasObjectId

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

the class FullTextMapperV2 method mapAttribute.

private void mapAttribute(Object value, AtlasEntityExtInfo entityExtInfo, StringBuilder sb, Set<String> processedGuids) throws AtlasBaseException {
    if (value instanceof AtlasObjectId) {
        if (followReferences) {
            AtlasObjectId objectId = (AtlasObjectId) value;
            AtlasEntity entity = entityExtInfo.getEntity(objectId.getGuid());
            if (entity != null) {
                map(entity, entityExtInfo, sb, processedGuids);
            }
        }
    } else if (value instanceof List) {
        List valueList = (List) value;
        for (Object listElement : valueList) {
            mapAttribute(listElement, entityExtInfo, sb, processedGuids);
        }
    } else if (value instanceof Map) {
        Map valueMap = (Map) value;
        for (Object key : valueMap.keySet()) {
            mapAttribute(key, entityExtInfo, sb, processedGuids);
            mapAttribute(valueMap.get(key), entityExtInfo, sb, processedGuids);
        }
    } else if (value instanceof Enum) {
        Enum enumValue = (Enum) value;
        sb.append(enumValue.name()).append(FULL_TEXT_DELIMITER);
    } else if (value instanceof AtlasStruct) {
        AtlasStruct atlasStruct = (AtlasStruct) value;
        for (Map.Entry<String, Object> entry : atlasStruct.getAttributes().entrySet()) {
            sb.append(entry.getKey()).append(FULL_TEXT_DELIMITER);
            mapAttribute(entry.getValue(), entityExtInfo, sb, processedGuids);
        }
    } else {
        sb.append(String.valueOf(value)).append(FULL_TEXT_DELIMITER);
    }
}
Also used : AtlasStruct(org.apache.atlas.model.instance.AtlasStruct) AtlasEntity(org.apache.atlas.model.instance.AtlasEntity) AtlasObjectId(org.apache.atlas.model.instance.AtlasObjectId) List(java.util.List) Map(java.util.Map)

Aggregations

AtlasObjectId (org.apache.atlas.model.instance.AtlasObjectId)46 AtlasEntity (org.apache.atlas.model.instance.AtlasEntity)27 Test (org.testng.annotations.Test)17 Map (java.util.Map)15 EntityMutationResponse (org.apache.atlas.model.instance.EntityMutationResponse)15 AtlasEntityHeader (org.apache.atlas.model.instance.AtlasEntityHeader)13 ArrayList (java.util.ArrayList)12 HashMap (java.util.HashMap)11 AtlasBaseException (org.apache.atlas.exception.AtlasBaseException)11 AtlasVertex (org.apache.atlas.repository.graphdb.AtlasVertex)11 BeforeTest (org.testng.annotations.BeforeTest)11 AtlasEntityType (org.apache.atlas.type.AtlasEntityType)10 AtlasEntitiesWithExtInfo (org.apache.atlas.model.instance.AtlasEntity.AtlasEntitiesWithExtInfo)7 List (java.util.List)6 AtlasEntityWithExtInfo (org.apache.atlas.model.instance.AtlasEntity.AtlasEntityWithExtInfo)5 AtlasStruct (org.apache.atlas.model.instance.AtlasStruct)5 RequestContextV1 (org.apache.atlas.RequestContextV1)4 AtlasExportRequest (org.apache.atlas.model.impexp.AtlasExportRequest)4 TestUtils.randomString (org.apache.atlas.TestUtils.randomString)3 AtlasEntityDef (org.apache.atlas.model.typedef.AtlasEntityDef)3