Search in sources :

Example 26 with AtlasObjectId

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

the class EntityGraphMapper method mapAttributesAndClassifications.

public EntityMutationResponse mapAttributesAndClassifications(EntityMutationContext context, final boolean isPartialUpdate, final boolean replaceClassifications) throws AtlasBaseException {
    EntityMutationResponse resp = new EntityMutationResponse();
    Collection<AtlasEntity> createdEntities = context.getCreatedEntities();
    Collection<AtlasEntity> updatedEntities = context.getUpdatedEntities();
    if (CollectionUtils.isNotEmpty(createdEntities)) {
        for (AtlasEntity createdEntity : createdEntities) {
            String guid = createdEntity.getGuid();
            AtlasVertex vertex = context.getVertex(guid);
            AtlasEntityType entityType = context.getType(guid);
            mapAttributes(createdEntity, vertex, CREATE, context);
            resp.addEntity(CREATE, constructHeader(createdEntity, entityType, vertex));
            addClassifications(context, guid, createdEntity.getClassifications());
        }
    }
    if (CollectionUtils.isNotEmpty(updatedEntities)) {
        for (AtlasEntity updatedEntity : updatedEntities) {
            String guid = updatedEntity.getGuid();
            AtlasVertex vertex = context.getVertex(guid);
            AtlasEntityType entityType = context.getType(guid);
            mapAttributes(updatedEntity, vertex, UPDATE, context);
            if (isPartialUpdate) {
                resp.addEntity(PARTIAL_UPDATE, constructHeader(updatedEntity, entityType, vertex));
            } else {
                resp.addEntity(UPDATE, constructHeader(updatedEntity, entityType, vertex));
            }
            if (replaceClassifications) {
                deleteClassifications(guid);
                addClassifications(context, guid, updatedEntity.getClassifications());
            }
        }
    }
    RequestContextV1 req = RequestContextV1.get();
    for (AtlasObjectId id : req.getDeletedEntityIds()) {
        resp.addEntity(DELETE, constructHeader(id));
    }
    for (AtlasObjectId id : req.getUpdatedEntityIds()) {
        if (isPartialUpdate) {
            resp.addEntity(PARTIAL_UPDATE, constructHeader(id));
        } else {
            resp.addEntity(UPDATE, constructHeader(id));
        }
    }
    return resp;
}
Also used : AtlasVertex(org.apache.atlas.repository.graphdb.AtlasVertex) RequestContextV1(org.apache.atlas.RequestContextV1) AtlasEntity(org.apache.atlas.model.instance.AtlasEntity) EntityMutationResponse(org.apache.atlas.model.instance.EntityMutationResponse) AtlasObjectId(org.apache.atlas.model.instance.AtlasObjectId) AtlasEntityType(org.apache.atlas.type.AtlasEntityType)

Example 27 with AtlasObjectId

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

the class ExportServiceTest method tamperEmployeeRequest.

private void tamperEmployeeRequest(AtlasExportRequest request) {
    AtlasObjectId objectId = request.getItemsToExport().get(0);
    objectId.getUniqueAttributes().remove("name");
    objectId.getUniqueAttributes().put("qualifiedName", "XXX@121");
}
Also used : AtlasObjectId(org.apache.atlas.model.instance.AtlasObjectId)

Example 28 with AtlasObjectId

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

the class ExportServiceTest method getRequestForFullFetch.

private AtlasExportRequest getRequestForFullFetch() {
    AtlasExportRequest request = new AtlasExportRequest();
    List<AtlasObjectId> itemsToExport = new ArrayList<>();
    itemsToExport.add(new AtlasObjectId("hive_db", "qualifiedName", "default@cl1"));
    request.setItemsToExport(itemsToExport);
    return request;
}
Also used : AtlasExportRequest(org.apache.atlas.model.impexp.AtlasExportRequest) ArrayList(java.util.ArrayList) AtlasObjectId(org.apache.atlas.model.instance.AtlasObjectId)

Example 29 with AtlasObjectId

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

the class ExportServiceTest method getRequestForEmployee.

private AtlasExportRequest getRequestForEmployee() {
    AtlasExportRequest request = new AtlasExportRequest();
    List<AtlasObjectId> itemsToExport = new ArrayList<>();
    itemsToExport.add(new AtlasObjectId("Employee", "name", "Max"));
    request.setItemsToExport(itemsToExport);
    setOptionsMap(request, true, "CONNECTED", false, "");
    return request;
}
Also used : AtlasExportRequest(org.apache.atlas.model.impexp.AtlasExportRequest) ArrayList(java.util.ArrayList) AtlasObjectId(org.apache.atlas.model.instance.AtlasObjectId)

Example 30 with AtlasObjectId

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

the class ZipSinkTest method getDefaultExportResult.

private AtlasExportResult getDefaultExportResult() {
    AtlasExportRequest request = new AtlasExportRequest();
    List<AtlasObjectId> itemsToExport = new ArrayList<>();
    itemsToExport.add(new AtlasObjectId("hive_db", "qualifiedName", "default"));
    request.setItemsToExport(itemsToExport);
    defaultExportResult = new AtlasExportResult(request, "admin", "1.0.0.0", "root", 100);
    return defaultExportResult;
}
Also used : AtlasExportResult(org.apache.atlas.model.impexp.AtlasExportResult) AtlasExportRequest(org.apache.atlas.model.impexp.AtlasExportRequest) ArrayList(java.util.ArrayList) AtlasObjectId(org.apache.atlas.model.instance.AtlasObjectId)

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