Search in sources :

Example 66 with AtlasObjectId

use of org.apache.atlas.model.instance.AtlasObjectId in project 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 67 with AtlasObjectId

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

the class ExportIncrementalTest method getExportRequestForHiveTable.

private AtlasExportRequest getExportRequestForHiveTable(String name, String fetchType, long changeMarker, boolean skipLineage) {
    AtlasExportRequest request = new AtlasExportRequest();
    List<AtlasObjectId> itemsToExport = new ArrayList<>();
    itemsToExport.add(new AtlasObjectId("hive_table", "qualifiedName", name));
    request.setItemsToExport(itemsToExport);
    request.setOptions(getOptionsMap(fetchType, changeMarker, skipLineage));
    return request;
}
Also used : AtlasExportRequest(org.apache.atlas.model.impexp.AtlasExportRequest) ArrayList(java.util.ArrayList) AtlasObjectId(org.apache.atlas.model.instance.AtlasObjectId)

Example 68 with AtlasObjectId

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

the class RelationshipAttributesExtractorTest method getExportRequestForHiveTable.

private AtlasExportRequest getExportRequestForHiveTable(String hiveTableName, String fetchType, boolean skipLineage) {
    AtlasExportRequest request = new AtlasExportRequest();
    List<AtlasObjectId> itemsToExport = new ArrayList<>();
    itemsToExport.add(new AtlasObjectId("hive_table", "qualifiedName", hiveTableName));
    request.setItemsToExport(itemsToExport);
    request.setOptions(getOptionsMap(fetchType, skipLineage));
    return request;
}
Also used : AtlasExportRequest(org.apache.atlas.model.impexp.AtlasExportRequest) ArrayList(java.util.ArrayList) AtlasObjectId(org.apache.atlas.model.instance.AtlasObjectId)

Example 69 with AtlasObjectId

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

the class StartEntityFetchByExportRequestTest method fetchTypeGuid.

@Test
public void fetchTypeGuid() {
    String exportRequestJson = "{ \"itemsToExport\": [ { \"typeName\": \"hive_db\", \"guid\": \"111-222-333\" } ]}";
    AtlasExportRequest exportRequest = AtlasType.fromJson(exportRequestJson, AtlasExportRequest.class);
    List<AtlasObjectId> objectGuidMap = startEntityFetchByExportRequestSpy.get(exportRequest);
    assertEquals(objectGuidMap.get(0).getGuid(), "111-222-333");
}
Also used : AtlasExportRequest(org.apache.atlas.model.impexp.AtlasExportRequest) AtlasObjectId(org.apache.atlas.model.instance.AtlasObjectId) Test(org.testng.annotations.Test)

Example 70 with AtlasObjectId

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

the class InverseReferenceUpdateV2Test method testInverseReferenceAutoUpdate_Map.

@Test
public void testInverseReferenceAutoUpdate_Map() throws Exception {
    AtlasEntity a1 = new AtlasEntity("A");
    a1.setAttribute(NAME, TestUtilsV2.randomString());
    AtlasEntity b1 = new AtlasEntity("B");
    b1.setAttribute(NAME, TestUtilsV2.randomString());
    AtlasEntity b2 = new AtlasEntity("B");
    b2.setAttribute(NAME, TestUtilsV2.randomString());
    AtlasEntity b3 = new AtlasEntity("B");
    b3.setAttribute(NAME, TestUtilsV2.randomString());
    AtlasEntitiesWithExtInfo atlasEntitiesWithExtInfo = new AtlasEntitiesWithExtInfo();
    atlasEntitiesWithExtInfo.addEntity(a1);
    atlasEntitiesWithExtInfo.addEntity(b1);
    atlasEntitiesWithExtInfo.addEntity(b2);
    atlasEntitiesWithExtInfo.addEntity(b3);
    AtlasEntityStream entityStream = new AtlasEntityStream(atlasEntitiesWithExtInfo);
    EntityMutationResponse response = entityStore.createOrUpdate(entityStream, false);
    AtlasEntityType aType = typeRegistry.getEntityTypeByName("A");
    AtlasEntity aForPartialUpdate = new AtlasEntity("A");
    aForPartialUpdate.setAttribute("mapToB", ImmutableMap.<String, AtlasObjectId>of("b1", AtlasTypeUtil.getAtlasObjectId(b1), "b2", AtlasTypeUtil.getAtlasObjectId(b2)));
    init();
    response = entityStore.updateByUniqueAttributes(aType, Collections.<String, Object>singletonMap(NAME, a1.getAttribute(NAME)), new AtlasEntityWithExtInfo(aForPartialUpdate));
    List<AtlasEntityHeader> partialUpdatedEntities = response.getPartialUpdatedEntities();
    // Verify 3 entities were updated:
    // * set a1.mapToB to "b1"->b1, "b2"->b2
    // * set b1.mappedFromA to a1
    // * set b2.mappedFromA to a1
    assertEquals(partialUpdatedEntities.size(), 3);
    AtlasEntitiesWithExtInfo storedEntities = entityStore.getByIds(ImmutableList.of(a1.getGuid(), b2.getGuid(), b1.getGuid()));
    AtlasEntity storedEntity = storedEntities.getEntity(a1.getGuid());
    Object value = storedEntity.getAttribute("mapToB");
    assertTrue(value instanceof Map);
    Map<String, AtlasObjectId> refMap = (Map<String, AtlasObjectId>) value;
    assertEquals(refMap.size(), 2);
    AtlasObjectId referencedEntityId = refMap.get("b1");
    assertEquals(referencedEntityId, AtlasTypeUtil.getAtlasObjectId(b1));
    referencedEntityId = refMap.get("b2");
    assertEquals(referencedEntityId, AtlasTypeUtil.getAtlasObjectId(b2));
    storedEntity = storedEntities.getEntity(b1.getGuid());
    verifyReferenceValue(storedEntity, "mappedFromA", a1.getGuid());
    storedEntity = storedEntities.getEntity(b2.getGuid());
    verifyReferenceValue(storedEntity, "mappedFromA", a1.getGuid());
    aForPartialUpdate.setAttribute("mapToB", ImmutableMap.<String, AtlasObjectId>of("b3", AtlasTypeUtil.getAtlasObjectId(b3)));
    init();
    response = entityStore.updateByUniqueAttributes(aType, Collections.<String, Object>singletonMap(NAME, a1.getAttribute(NAME)), new AtlasEntityWithExtInfo(aForPartialUpdate));
    partialUpdatedEntities = response.getPartialUpdatedEntities();
    // Verify 4 entities were updated:
    // * set a1.mapToB to "b3"->b3
    // * set b3.mappedFromA to a1
    // * disconnect b1.mappedFromA
    // * disconnect b2.mappedFromA
    assertEquals(partialUpdatedEntities.size(), 4);
    storedEntities = entityStore.getByIds(ImmutableList.of(a1.getGuid(), b2.getGuid(), b1.getGuid(), b3.getGuid()));
    AtlasEntity storedB3 = storedEntities.getEntity(b3.getGuid());
    verifyReferenceValue(storedB3, "mappedFromA", a1.getGuid());
    verify_testInverseReferenceAutoUpdate_Map(storedEntities.getEntity(a1.getGuid()), storedEntities.getEntity(b1.getGuid()), storedEntities.getEntity(b2.getGuid()), storedB3);
}
Also used : AtlasEntityWithExtInfo(org.apache.atlas.model.instance.AtlasEntity.AtlasEntityWithExtInfo) EntityMutationResponse(org.apache.atlas.model.instance.EntityMutationResponse) AtlasObjectId(org.apache.atlas.model.instance.AtlasObjectId) AtlasEntity(org.apache.atlas.model.instance.AtlasEntity) AtlasEntitiesWithExtInfo(org.apache.atlas.model.instance.AtlasEntity.AtlasEntitiesWithExtInfo) AtlasEntityHeader(org.apache.atlas.model.instance.AtlasEntityHeader) AtlasEntityType(org.apache.atlas.type.AtlasEntityType) HashMap(java.util.HashMap) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) 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