logger.debug("Created FlowPath entities mutation response={}", mutationResponse); final Map<String, String> guidAssignments = mutationResponse.getGuidAssignments(); createdEntities.forEach(entity -> { final String guid = entity.getGuid();
logger.debug("Created DataSet entities mutation response={}", mutationResponse); final Map<String, String> guidAssignments = mutationResponse.getGuidAssignments(); for (AtlasEntity entity : createdEntities) {
private AtlasEntity registerNiFiFlowEntity(final NiFiFlow nifiFlow) throws AtlasServiceException { final List<AtlasEntity> entities = new ArrayList<>(); final AtlasEntity.AtlasEntitiesWithExtInfo atlasEntities = new AtlasEntity.AtlasEntitiesWithExtInfo(entities); if (!nifiFlow.isMetadataUpdated()) { // Nothing has been changed, return existing entity. return nifiFlow.getExEntity(); } // Create parent flow entity using existing NiFiFlow entity if available, so that common properties are taken over. final AtlasEntity flowEntity = nifiFlow.getExEntity() != null ? new AtlasEntity(nifiFlow.getExEntity()) : new AtlasEntity(); flowEntity.setTypeName(TYPE_NIFI_FLOW); flowEntity.setVersion(1L); flowEntity.setAttribute(ATTR_NAME, nifiFlow.getFlowName()); flowEntity.setAttribute(ATTR_QUALIFIED_NAME, nifiFlow.toQualifiedName(nifiFlow.getRootProcessGroupId())); flowEntity.setAttribute(ATTR_URL, nifiFlow.getUrl()); flowEntity.setAttribute(ATTR_DESCRIPTION, nifiFlow.getDescription()); // If flowEntity is not persisted yet, then store nifi_flow entity to make nifiFlowId available for other entities. if (flowEntity.getGuid().startsWith("-")) { entities.add(flowEntity); final EntityMutationResponse mutationResponse = atlasClient.createEntities(atlasEntities); logger.debug("Registered a new nifi_flow entity, mutation response={}", mutationResponse); final String assignedNiFiFlowGuid = mutationResponse.getGuidAssignments().get(flowEntity.getGuid()); flowEntity.setGuid(assignedNiFiFlowGuid); nifiFlow.setAtlasGuid(assignedNiFiFlowGuid); } return flowEntity; }
logger.debug("Created DataSet entities mutation response={}", mutationResponse); final Map<String, String> guidAssignments = mutationResponse.getGuidAssignments(); for (AtlasEntity entity : createdEntities) {
logger.debug("Created FlowPath entities mutation response={}", mutationResponse); final Map<String, String> guidAssignments = mutationResponse.getGuidAssignments(); createdEntities.forEach(entity -> { final String guid = entity.getGuid();
Map<String, String> guidAssignments = reponse.getGuidAssignments();
EntityMutationResponse resp = entityStore.createOrUpdateForImport(oneEntityStream); if (resp.getGuidAssignments() != null) { ret.getGuidAssignments().putAll(resp.getGuidAssignments());
public <T extends AtlasBaseModelObject> void saveNoLoad(T obj) throws AtlasBaseException { Objects.requireNonNull(obj, "Can't save a null object"); AtlasPerfTracer perf = null; try { if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) { perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "DataAccess.save()"); } DataTransferObject<T> dto = (DataTransferObject<T>) dtoRegistry.get(obj.getClass()); AtlasEntityWithExtInfo entityWithExtInfo = dto.toEntityWithExtInfo(obj); EntityMutationResponse entityMutationResponse = entityStore.createOrUpdate(new AtlasEntityStream(entityWithExtInfo), false); if (noEntityMutation(entityMutationResponse)) { throw new AtlasBaseException(AtlasErrorCode.DATA_ACCESS_SAVE_FAILED, obj.toString()); } // Update GUID assignment for newly created entity if (CollectionUtils.isNotEmpty(entityMutationResponse.getCreatedEntities())) { String assignedGuid = entityMutationResponse.getGuidAssignments().get(obj.getGuid()); if (!obj.getGuid().equals(assignedGuid)) { obj.setGuid(assignedGuid); } } } finally { AtlasPerfTracer.log(perf); } }
EntityMutationResponse resp = entityStore.createOrUpdateForImport(oneEntityStream); if (resp.getGuidAssignments() != null) { ret.getGuidAssignments().putAll(resp.getGuidAssignments());
public <T extends AtlasBaseModelObject> T save(T obj) throws AtlasBaseException { Objects.requireNonNull(obj, "Can't save a null object"); AtlasPerfTracer perf = null; try { if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) { perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "DataAccess.save()"); } DataTransferObject<T> dto = (DataTransferObject<T>) dtoRegistry.get(obj.getClass()); AtlasEntityWithExtInfo entityWithExtInfo = dto.toEntityWithExtInfo(obj); EntityMutationResponse entityMutationResponse = entityStore.createOrUpdate(new AtlasEntityStream(entityWithExtInfo), false); if (noEntityMutation(entityMutationResponse)) { throw new AtlasBaseException(AtlasErrorCode.DATA_ACCESS_SAVE_FAILED, obj.toString()); } // Update GUID assignment for newly created entity if (CollectionUtils.isNotEmpty(entityMutationResponse.getCreatedEntities())) { String assignedGuid = entityMutationResponse.getGuidAssignments().get(obj.getGuid()); if (!obj.getGuid().equals(assignedGuid)) { obj.setGuid(assignedGuid); } } return this.load(obj); } finally { AtlasPerfTracer.log(perf); } }
response.setGuidAssignments(guidMapping.getGuidAssignments());
private AtlasEntity registerNiFiFlowEntity(final NiFiFlow nifiFlow) throws AtlasServiceException { final List<AtlasEntity> entities = new ArrayList<>(); final AtlasEntity.AtlasEntitiesWithExtInfo atlasEntities = new AtlasEntity.AtlasEntitiesWithExtInfo(entities); if (!nifiFlow.isMetadataUpdated()) { // Nothing has been changed, return existing entity. return nifiFlow.getExEntity(); } // Create parent flow entity using existing NiFiFlow entity if available, so that common properties are taken over. final AtlasEntity flowEntity = nifiFlow.getExEntity() != null ? new AtlasEntity(nifiFlow.getExEntity()) : new AtlasEntity(); flowEntity.setTypeName(TYPE_NIFI_FLOW); flowEntity.setVersion(1L); flowEntity.setAttribute(ATTR_NAME, nifiFlow.getFlowName()); flowEntity.setAttribute(ATTR_QUALIFIED_NAME, nifiFlow.toQualifiedName(nifiFlow.getRootProcessGroupId())); flowEntity.setAttribute(ATTR_URL, nifiFlow.getUrl()); flowEntity.setAttribute(ATTR_DESCRIPTION, nifiFlow.getDescription()); // If flowEntity is not persisted yet, then store nifi_flow entity to make nifiFlowId available for other entities. if (flowEntity.getGuid().startsWith("-")) { entities.add(flowEntity); final EntityMutationResponse mutationResponse = atlasClient.createEntities(atlasEntities); logger.debug("Registered a new nifi_flow entity, mutation response={}", mutationResponse); final String assignedNiFiFlowGuid = mutationResponse.getGuidAssignments().get(flowEntity.getGuid()); flowEntity.setGuid(assignedNiFiFlowGuid); nifiFlow.setAtlasGuid(assignedNiFiFlowGuid); } return flowEntity; }
Map<String, String> guidAssignments = reponse.getGuidAssignments();