Java Code Examples for org.apache.atlas.model.instance.AtlasObjectId#setGuid()
The following examples show how to use
org.apache.atlas.model.instance.AtlasObjectId#setGuid() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NotificationHookConsumer.java From atlas with Apache License 2.0 | 5 votes |
private void updateProcessedEntityReferences(AtlasObjectId objId, Map<String, String> guidAssignments) { String guid = objId.getGuid(); if (guid != null && guidAssignments.containsKey(guid)) { String assignedGuid = guidAssignments.get(guid); if (LOG.isDebugEnabled()) { LOG.debug("{}(guid={}) is already processed; updating its reference to use assigned-guid={}", objId.getTypeName(), guid, assignedGuid); } objId.setGuid(assignedGuid); objId.setTypeName(null); objId.setUniqueAttributes(null); } }
Example 2
Source File: StartEntityFetchByExportRequest.java From atlas with Apache License 2.0 | 5 votes |
public List<AtlasObjectId> get(AtlasExportRequest exportRequest) { List<AtlasObjectId> list = new ArrayList<>(); for(AtlasObjectId objectId : exportRequest.getItemsToExport()) { List<String> guids = get(exportRequest, objectId); if (guids.isEmpty()) { continue; } objectId.setGuid(guids.get(0)); list.add(objectId); } return list; }
Example 3
Source File: AtlasEntityStoreV2.java From atlas with Apache License 2.0 | 5 votes |
private AtlasObjectId getAtlasObjectId(AtlasEntity entity) { AtlasObjectId ret = entityRetriever.toAtlasObjectId(entity); if (ret != null && !RequestContext.get().isImportInProgress() && MapUtils.isNotEmpty(ret.getUniqueAttributes())) { // if uniqueAttributes is not empty, reset guid to null. ret.setGuid(null); } return ret; }
Example 4
Source File: EntityGraphRetriever.java From atlas with Apache License 2.0 | 4 votes |
public AtlasObjectId toAtlasObjectIdWithoutGuid(AtlasEntity entity) { AtlasObjectId objectId = toAtlasObjectId(entity); objectId.setGuid(null); return objectId; }
Example 5
Source File: AtlasEntityStoreV2Test.java From atlas with Apache License 2.0 | 4 votes |
@Test(priority = -1) public void testCreate() throws Exception { init(); EntityMutationResponse response = entityStore.createOrUpdate(new AtlasEntityStream(deptEntity), false); validateMutationResponse(response, EntityOperation.CREATE, 5); AtlasEntityHeader dept1 = response.getFirstCreatedEntityByTypeName(TestUtilsV2.DEPARTMENT_TYPE); validateEntity(deptEntity, getEntityFromStore(dept1), deptEntity.getEntities().get(0)); final Map<EntityOperation, List<AtlasEntityHeader>> entitiesMutated = response.getMutatedEntities(); List<AtlasEntityHeader> entitiesCreated = entitiesMutated.get(EntityOperation.CREATE); assertTrue(entitiesCreated.size() >= deptEntity.getEntities().size()); for (int i = 0; i < deptEntity.getEntities().size(); i++) { AtlasEntity expected = deptEntity.getEntities().get(i); AtlasEntity actual = getEntityFromStore(entitiesCreated.get(i)); validateEntity(deptEntity, actual, expected); } //Create DB init(); EntityMutationResponse dbCreationResponse = entityStore.createOrUpdate(new AtlasEntityStream(dbEntity), false); validateMutationResponse(dbCreationResponse, EntityOperation.CREATE, 1); dbEntityGuid = dbCreationResponse.getCreatedEntities().get(0).getGuid(); AtlasEntityHeader db1 = dbCreationResponse.getFirstCreatedEntityByTypeName(TestUtilsV2.DATABASE_TYPE); validateEntity(dbEntity, getEntityFromStore(db1)); //Create Table //Update DB guid AtlasObjectId dbObjectId = (AtlasObjectId) tblEntity.getEntity().getAttribute("database"); dbObjectId.setGuid(db1.getGuid()); tblEntity.addReferredEntity(dbEntity.getEntity()); init(); EntityMutationResponse tableCreationResponse = entityStore.createOrUpdate(new AtlasEntityStream(tblEntity), false); validateMutationResponse(tableCreationResponse, EntityOperation.CREATE, 1); tblEntityGuid = tableCreationResponse.getCreatedEntities().get(0).getGuid(); AtlasEntityHeader tableEntity = tableCreationResponse.getFirstCreatedEntityByTypeName(TABLE_TYPE); validateEntity(tblEntity, getEntityFromStore(tableEntity)); //Create nested-collection attribute entity init(); EntityMutationResponse entityMutationResponse = entityStore.createOrUpdate(new AtlasEntityStream(nestedCollectionAttrEntity), false); validateMutationResponse(entityMutationResponse, EntityOperation.CREATE, 1); AtlasEntityHeader createdEntity = entityMutationResponse.getFirstCreatedEntityByTypeName(TestUtilsV2.ENTITY_TYPE_WITH_NESTED_COLLECTION_ATTR); validateEntity(nestedCollectionAttrEntity, getEntityFromStore(createdEntity)); }
Example 6
Source File: AtlasEntityStoreV1Test.java From incubator-atlas with Apache License 2.0 | 4 votes |
@Test public void testCreate() throws Exception { init(); EntityMutationResponse response = entityStore.createOrUpdate(new AtlasEntityStream(deptEntity), false); validateMutationResponse(response, EntityOperation.CREATE, 5); AtlasEntityHeader dept1 = response.getFirstCreatedEntityByTypeName(TestUtilsV2.DEPARTMENT_TYPE); validateEntity(deptEntity, getEntityFromStore(dept1), deptEntity.getEntities().get(0)); final Map<EntityOperation, List<AtlasEntityHeader>> entitiesMutated = response.getMutatedEntities(); List<AtlasEntityHeader> entitiesCreated = entitiesMutated.get(EntityOperation.CREATE); Assert.assertTrue(entitiesCreated.size() >= deptEntity.getEntities().size()); for (int i = 0; i < deptEntity.getEntities().size(); i++) { AtlasEntity expected = deptEntity.getEntities().get(i); AtlasEntity actual = getEntityFromStore(entitiesCreated.get(i)); validateEntity(deptEntity, actual, expected); } //Create DB init(); EntityMutationResponse dbCreationResponse = entityStore.createOrUpdate(new AtlasEntityStream(dbEntity), false); validateMutationResponse(dbCreationResponse, EntityOperation.CREATE, 1); AtlasEntityHeader db1 = dbCreationResponse.getFirstCreatedEntityByTypeName(TestUtilsV2.DATABASE_TYPE); validateEntity(dbEntity, getEntityFromStore(db1)); //Create Table //Update DB guid AtlasObjectId dbObjectId = (AtlasObjectId) tblEntity.getEntity().getAttribute("database"); dbObjectId.setGuid(db1.getGuid()); tblEntity.addReferredEntity(dbEntity.getEntity()); init(); EntityMutationResponse tableCreationResponse = entityStore.createOrUpdate(new AtlasEntityStream(tblEntity), false); validateMutationResponse(tableCreationResponse, EntityOperation.CREATE, 1); AtlasEntityHeader tableEntity = tableCreationResponse.getFirstCreatedEntityByTypeName(TABLE_TYPE); validateEntity(tblEntity, getEntityFromStore(tableEntity)); }