final AtlasEntity.AtlasEntitiesWithExtInfo atlasEntities = new AtlasEntity.AtlasEntitiesWithExtInfo(createdEntities); final EntityMutationResponse mutationResponse = atlasClient.createEntities(atlasEntities); logger.debug("Created DataSet entities mutation response={}", mutationResponse); final AtlasEntity.AtlasEntitiesWithExtInfo atlasEntities = new AtlasEntity.AtlasEntitiesWithExtInfo(updatedEntities); final EntityMutationResponse mutationResponse = atlasClient.updateEntities(atlasEntities); logger.debug("Updated DataSet entities mutation response={}", mutationResponse);
entities.getEntities().get(0).setGuid(guid);
@Test(dependsOnMethods = "testCreate") public void testUpdateEntityWithMap() throws Exception { AtlasEntity tableEntity = new AtlasEntity(tblEntity.getEntity()); AtlasEntitiesWithExtInfo entitiesInfo = new AtlasEntitiesWithExtInfo(tableEntity); Map<String, AtlasStruct> partsMap = new HashMap<>(); partsMap.put("part0", new AtlasStruct(TestUtilsV2.PARTITION_STRUCT_TYPE, TestUtilsV2.NAME, "test")); entitiesInfo.addReferredEntity(col0); entitiesInfo.addReferredEntity(col1); init(); response = entityStore.createOrUpdate(new AtlasEntityStream(entitiesInfo), false);
@Test(dependsOnMethods = "testCreate") public void testUpdateEntityWithMap() throws Exception { AtlasEntity tableEntity = new AtlasEntity(tblEntity.getEntity()); AtlasEntitiesWithExtInfo entitiesInfo = new AtlasEntitiesWithExtInfo(tableEntity); Map<String, AtlasStruct> partsMap = new HashMap<>(); partsMap.put("part0", new AtlasStruct(TestUtilsV2.PARTITION_STRUCT_TYPE, TestUtilsV2.NAME, "test")); entitiesInfo.addReferredEntity(col0); entitiesInfo.addReferredEntity(col1); init(); response = entityStore.createOrUpdate(new AtlasEntityStream(entitiesInfo), false);
public static AtlasEntitiesWithExtInfo getDepartmentEmployeeInstances() { AtlasEntitiesWithExtInfo ret = new AtlasEntitiesWithExtInfo(); mike.setAttribute("approximationOfPi", new BigDecimal("3.14159")); ret.addEntity(hrDept); ret.addEntity(jane); ret.addEntity(julius); ret.addEntity(max); ret.addEntity(john); ret.addEntity(mike);
dbEntity.setAttribute("colo", "10001"); EntityStream dbStream = new AtlasEntityStream(new AtlasEntitiesWithExtInfo(dbEntity)); EntityMutationResponse response = entityStore.createOrUpdate(dbStream, false); AtlasEntityHeader dbHeader = response.getFirstEntityCreated(); dbEntity.setAttribute("isReplicated", true); // optional attr dbStream = new AtlasEntityStream(new AtlasEntitiesWithExtInfo(dbEntity)); AtlasEntitiesWithExtInfo tableEntityInfo = new AtlasEntitiesWithExtInfo(tblEntity); tableEntityInfo.addReferredEntity(col1.getGuid(), col1); tableEntityInfo.addReferredEntity(col2.getGuid(), col2); tblEntity.setAttribute(TestUtilsV2.COLUMNS_ATTR_NAME, columns); tableEntityInfo = new AtlasEntitiesWithExtInfo(tblEntity); tableEntityInfo.addReferredEntity(col3.getGuid(), col3); tableEntityInfo.addReferredEntity(col4.getGuid(), col4);
dbEntity.setAttribute("colo", "10001"); EntityStream dbStream = new AtlasEntityStream(new AtlasEntitiesWithExtInfo(dbEntity)); EntityMutationResponse response = entityStore.createOrUpdate(dbStream, false); AtlasEntityHeader dbHeader = response.getFirstEntityCreated(); dbEntity.setAttribute("isReplicated", true); // optional attr dbStream = new AtlasEntityStream(new AtlasEntitiesWithExtInfo(dbEntity)); AtlasEntitiesWithExtInfo tableEntityInfo = new AtlasEntitiesWithExtInfo(tblEntity); tableEntityInfo.addReferredEntity(col1.getGuid(), col1); tableEntityInfo.addReferredEntity(col2.getGuid(), col2); tblEntity.setAttribute(TestUtilsV2.COLUMNS_ATTR_NAME, columns); tableEntityInfo = new AtlasEntitiesWithExtInfo(tblEntity); tableEntityInfo.addReferredEntity(col3.getGuid(), col3); tableEntityInfo.addReferredEntity(col4.getGuid(), col4);
public static AtlasEntitiesWithExtInfo createDeptEg2() { AtlasEntitiesWithExtInfo entitiesWithExtInfo = new AtlasEntitiesWithExtInfo(); hrDept.setAttribute("employees", Arrays.asList(janeId, juliusId, maxId, johnId)); entitiesWithExtInfo.addEntity(hrDept); entitiesWithExtInfo.addEntity(jane); entitiesWithExtInfo.addEntity(julius); entitiesWithExtInfo.addEntity(max); entitiesWithExtInfo.addEntity(john);
init(); AtlasEntity complexEntity = getEntityFromStore(complexCollectionAttrEntity.getEntity().getGuid()); AtlasEntitiesWithExtInfo complexEntitiesInfo = new AtlasEntitiesWithExtInfo(complexEntity); put("key22", getAtlasObjectId(e2MapValue)); }}; complexEntity.setAttribute("mapOfEntities", entityMap); complexEntitiesInfo.addReferredEntity(e0MapValue); complexEntitiesInfo.addReferredEntity(e1MapValue); complexEntitiesInfo.addReferredEntity(e2MapValue); entityMap.put("key33", getAtlasObjectId(e3MapValue)); complexEntity.setAttribute("mapOfEntities", entityMap); complexEntitiesInfo.addReferredEntity(e3MapValue); entityMap.remove("key00"); complexEntity.setAttribute("mapOfEntities", entityMap); complexEntitiesInfo.addReferredEntity(e3MapValue); entityMap.put("key33", getAtlasObjectId(e3MapValue)); complexEntity.setAttribute("mapOfEntities", entityMap); complexEntitiesInfo.addReferredEntity(e1MapValueEdit); entityMap.put("key33", getAtlasObjectId(e3MapValue)); complexEntity.setAttribute("mapOfEntities", entityMap); complexEntitiesInfo.addReferredEntity(e3MapValue); entityMap.clear(); complexEntity.setAttribute("mapOfEntities", entityMap); complexEntitiesInfo.addReferredEntity(e3MapValue);
AtlasEntity maxEntity = updatedEntities.getEntity(maxId.getGuid()); verifyRelationshipAttributeValue(maxEntity, "manager", juliusId.getGuid()); AtlasEntity juliusEntity = updatedEntities.getEntity(juliusId.getGuid()); verifyRelationshipAttributeList(juliusEntity, "subordinates", ImmutableList.of(maxId, mikeId)); AtlasEntity janeEntity = updatedEntities.getEntity(janeId.getGuid()); maxEntity = updatedEntities.getEntity(maxId.getGuid()); juliusEntity = updatedEntities.getEntity(juliusId.getGuid()); AtlasEntity mikeEntity = updatedEntities.getEntity(mikeId.getGuid()); AtlasEntity johnEntity = updatedEntities.getEntity(johnId.getGuid()); juliusEntity = updatedEntities.getEntity(juliusId.getGuid()); janeEntity = updatedEntities.getEntity(janeId.getGuid()); mikeEntity = updatedEntities.getEntity(mikeId.getGuid());
init(); AtlasEntity complexEntity = getEntityFromStore(complexCollectionAttrEntity.getEntity().getGuid()); AtlasEntitiesWithExtInfo complexEntitiesInfo = new AtlasEntitiesWithExtInfo(complexEntity); AtlasEntityType entityType = typeRegistry.getEntityTypeByName(ENTITY_TYPE); complexEntitiesInfo.addReferredEntity(e0Array); complexEntitiesInfo.addReferredEntity(e1Array); complexEntitiesInfo.addReferredEntity(e2Array); complexEntitiesInfo.getReferredEntities().clear(); complexEntitiesInfo.addReferredEntity(e3Array); entityList = new ArrayList<>(Arrays.asList(getAtlasObjectId(e1Array), getAtlasObjectId(e2Array), getAtlasObjectId(e3Array))); complexEntity.setAttribute("listOfEntities", entityList); complexEntitiesInfo.getReferredEntities().clear(); entityList.add(getAtlasObjectId(e3Array_duplicate)); complexEntity.setAttribute("listOfEntities", entityList); complexEntitiesInfo.getReferredEntities().clear(); complexEntitiesInfo.addReferredEntity(e3Array_duplicate); entityList.clear(); complexEntity.setAttribute("listOfEntities", entityList); complexEntitiesInfo.getReferredEntities().clear();
init(); AtlasEntity complexEntity = getEntityFromStore(complexCollectionAttrEntity.getEntity().getGuid()); AtlasEntitiesWithExtInfo complexEntitiesInfo = new AtlasEntitiesWithExtInfo(complexEntity); put("key22", getAtlasObjectId(e2MapValue)); }}; complexEntity.setAttribute("mapOfEntities", entityMap); complexEntitiesInfo.addReferredEntity(e0MapValue); complexEntitiesInfo.addReferredEntity(e1MapValue); complexEntitiesInfo.addReferredEntity(e2MapValue); entityMap.put("key33", getAtlasObjectId(e3MapValue)); complexEntity.setAttribute("mapOfEntities", entityMap); complexEntitiesInfo.addReferredEntity(e3MapValue); entityMap.remove("key00"); complexEntity.setAttribute("mapOfEntities", entityMap); complexEntitiesInfo.addReferredEntity(e3MapValue); entityMap.put("key33", getAtlasObjectId(e3MapValue)); complexEntity.setAttribute("mapOfEntities", entityMap); complexEntitiesInfo.addReferredEntity(e1MapValueEdit); entityMap.put("key33", getAtlasObjectId(e3MapValue)); complexEntity.setAttribute("mapOfEntities", entityMap); complexEntitiesInfo.addReferredEntity(e3MapValue); entityMap.clear(); complexEntity.setAttribute("mapOfEntities", entityMap); complexEntitiesInfo.addReferredEntity(e3MapValue);
AtlasEntity maxEntity = updatedEntities.getEntity(maxId.getGuid()); verifyRelationshipAttributeValue(maxEntity, "manager", juliusId.getGuid()); AtlasEntity juliusEntity = updatedEntities.getEntity(juliusId.getGuid()); verifyRelationshipAttributeList(juliusEntity, "subordinates", ImmutableList.of(maxId, mikeId)); AtlasEntity janeEntity = updatedEntities.getEntity(janeId.getGuid()); maxEntity = updatedEntities.getEntity(maxId.getGuid()); juliusEntity = updatedEntities.getEntity(juliusId.getGuid()); AtlasEntity mikeEntity = updatedEntities.getEntity(mikeId.getGuid()); AtlasEntity johnEntity = updatedEntities.getEntity(johnId.getGuid()); juliusEntity = updatedEntities.getEntity(juliusId.getGuid()); janeEntity = updatedEntities.getEntity(janeId.getGuid()); mikeEntity = updatedEntities.getEntity(mikeId.getGuid());
init(); AtlasEntity complexEntity = getEntityFromStore(complexCollectionAttrEntity.getEntity().getGuid()); AtlasEntitiesWithExtInfo complexEntitiesInfo = new AtlasEntitiesWithExtInfo(complexEntity); complexEntitiesInfo.addReferredEntity(e0Array); complexEntitiesInfo.addReferredEntity(e1Array); complexEntitiesInfo.addReferredEntity(e2Array); entityList.add(getAtlasObjectId(e3Array)); complexEntity.setAttribute("listOfEntities", entityList); complexEntitiesInfo.addReferredEntity(e3Array); entityList.add(getAtlasObjectId(e3Array_duplicate)); complexEntity.setAttribute("listOfEntities", entityList); complexEntitiesInfo.addReferredEntity(e3Array_duplicate);
AtlasEntitiesWithExtInfo entitiesInfo = new AtlasEntitiesWithExtInfo(tableEntity); entitiesInfo.addReferredEntity(columnEntity1); entitiesInfo.addReferredEntity(columnEntity2); entitiesInfo.addReferredEntity(columnEntity3); AtlasTypeUtil.getAtlasObjectId(col2), AtlasTypeUtil.getAtlasObjectId(col3))); AtlasEntitiesWithExtInfo tableInfo = new AtlasEntitiesWithExtInfo(tableEntity1); tableInfo.addReferredEntity(col1.getGuid(), col1); tableInfo.addReferredEntity(col2.getGuid(), col2); tableInfo.addReferredEntity(col3.getGuid(), col3);
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); AtlasEntity storedEntity = storedEntities.getEntity(a1.getGuid()); Object value = storedEntity.getAttribute("mapToB"); assertTrue(value instanceof Map); 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()); 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);
AtlasEntitiesWithExtInfo entitiesInfo = new AtlasEntitiesWithExtInfo(tableEntity); entitiesInfo.addReferredEntity(columnEntity1); entitiesInfo.addReferredEntity(columnEntity2); entitiesInfo.addReferredEntity(columnEntity3); AtlasTypeUtil.getAtlasObjectId(col2), AtlasTypeUtil.getAtlasObjectId(col3))); AtlasEntitiesWithExtInfo tableInfo = new AtlasEntitiesWithExtInfo(tableEntity1); tableInfo.addReferredEntity(col1.getGuid(), col1); tableInfo.addReferredEntity(col2.getGuid(), col2); tableInfo.addReferredEntity(col3.getGuid(), col3);
entities.addEntity(columnLineage);
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); AtlasEntity storedEntity = storedEntities.getEntity(a1.getGuid()); Object value = storedEntity.getAttribute("mapToB"); assertTrue(value instanceof Map); 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()); 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);
b.setAttribute(NAME, "b_name"); AtlasEntitiesWithExtInfo entitiesWithExtInfo = new AtlasEntitiesWithExtInfo(); entitiesWithExtInfo.addEntity(a1); entitiesWithExtInfo.addEntity(a2); entitiesWithExtInfo.addEntity(a3); entitiesWithExtInfo.addEntity(b); entityStore.createOrUpdate(new AtlasEntityStream(entitiesWithExtInfo) , false); AtlasEntitiesWithExtInfo updatedEntities = entityStore.getByIds(ImmutableList.of(a1.getGuid(), a2.getGuid(), b.getGuid())); AtlasEntity a1Entity = updatedEntities.getEntity(a1.getGuid()); verifyRelationshipAttributeValue(a1Entity, "oneB", b.getGuid()); AtlasEntity a2Entity = updatedEntities.getEntity(a2.getGuid()); verifyRelationshipAttributeValue(a2Entity, "oneB", b.getGuid()); AtlasEntity bEntity = updatedEntities.getEntity(b.getGuid()); verifyRelationshipAttributeList(bEntity, "manyA", ImmutableList.of(getAtlasObjectId(a1), getAtlasObjectId(a2))); a1Entity = updatedEntities.getEntity(a1.getGuid()); a2Entity = updatedEntities.getEntity(a2.getGuid()); bEntity = updatedEntities.getEntity(b.getGuid()); AtlasEntity a3Entity = updatedEntities.getEntity(a3.getGuid()); verifyRelationshipAttributeValue(a3Entity, "oneB", b.getGuid());