entity.setGuid(guid); final AtlasObjectId idWithGuid = new AtlasObjectId(guid, entity.getTypeName(), Collections.singletonMap(ATTR_QUALIFIED_NAME, qualifiedName)); entityMap.put(idWithGuid, entity);
createdEntities.forEach(entity -> { final String guid = entity.getGuid(); entity.setGuid(guidAssignments.get(guid)); final String pathId = getComponentIdFromQualifiedName(toStr(entity.getAttribute(ATTR_QUALIFIED_NAME))); final NiFiFlowPath path = nifiFlow.getFlowPaths().get(pathId);
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; }
protected AtlasEntity getDefaultAtlasEntity(T obj) throws AtlasBaseException { AtlasEntity ret = getEntityType().createDefaultValue(); if (obj != null) { if (StringUtils.isNotEmpty(obj.getGuid())) { ret.setGuid(obj.getGuid()); } } return ret; }
protected AtlasEntity getDefaultAtlasEntity(T obj) { AtlasEntity ret = getEntityType().createDefaultValue(); if (obj != null) { if (StringUtils.isNotEmpty(obj.getGuid())) { ret.setGuid(obj.getGuid()); } } return ret; }
public void updateEntityGuid(String oldGuid, String newGuid) { AtlasEntity entity = getEntity(oldGuid); if (entity != null) { entity.setGuid(newGuid); if(removeEntity(oldGuid) != null) { addReferredEntity(newGuid, entity); } } }
public void updateEntityGuid(String oldGuid, String newGuid) { AtlasEntity entity = getEntity(oldGuid); if (entity != null) { entity.setGuid(newGuid); if(removeEntity(oldGuid) != null) { addReferredEntity(newGuid, entity); } } }
private void addReferredEntities(AtlasEntity.AtlasEntityWithExtInfo entityWithExtInfo, int maxEntries) { for (int i = 1; i <= maxEntries; i++) { AtlasEntity entity1 = new AtlasEntity(); entity1.setGuid(String.format(knownEntityGuidFormat, i)); entityWithExtInfo.addReferredEntity(entity1); } }
private void addReferredEntities(AtlasEntity.AtlasEntityWithExtInfo entityWithExtInfo, int maxEntries) { for (int i = 1; i <= maxEntries; i++) { AtlasEntity entity1 = new AtlasEntity(); entity1.setGuid(String.format(knownEntityGuidFormat, i)); entityWithExtInfo.addReferredEntity(entity1); } }
@Override @GraphTransaction public EntityMutationResponse updateByUniqueAttributes(AtlasEntityType entityType, Map<String, Object> uniqAttributes, AtlasEntityWithExtInfo updatedEntityInfo) throws AtlasBaseException { if (LOG.isDebugEnabled()) { LOG.debug("==> updateByUniqueAttributes({}, {})", entityType.getTypeName(), uniqAttributes); } if (updatedEntityInfo == null || updatedEntityInfo.getEntity() == null) { throw new AtlasBaseException(AtlasErrorCode.INVALID_PARAMETERS, "no entity to update."); } String guid = AtlasGraphUtilsV2.getGuidByUniqueAttributes(entityType, uniqAttributes); AtlasEntity entity = updatedEntityInfo.getEntity(); entity.setGuid(guid); return createOrUpdate(new AtlasEntityStream(updatedEntityInfo), true, false); }
@Override @GraphTransaction public EntityMutationResponse updateByUniqueAttributes(AtlasEntityType entityType, Map<String, Object> uniqAttributes, AtlasEntityWithExtInfo updatedEntityInfo) throws AtlasBaseException { if (LOG.isDebugEnabled()) { LOG.debug("==> updateByUniqueAttributes({}, {})", entityType.getTypeName(), uniqAttributes); } if (updatedEntityInfo == null || updatedEntityInfo.getEntity() == null) { throw new AtlasBaseException(AtlasErrorCode.INVALID_PARAMETERS, "no entity to update."); } String guid = AtlasGraphUtilsV2.getGuidByUniqueAttributes(entityType, uniqAttributes); AtlasEntity entity = updatedEntityInfo.getEntity(); entity.setGuid(guid); return createOrUpdate(new AtlasEntityStream(updatedEntityInfo), true, false); }
@Test public void recordsEntityEntries() throws AtlasBaseException { ByteArrayOutputStream byteOutputStream = new ByteArrayOutputStream(); ZipSink zs = new ZipSink(byteOutputStream); AtlasEntity entity = new AtlasEntity(); entity.setGuid(String.format(knownEntityGuidFormat, 0)); zs.add(entity); assertTrue(zs.hasEntity(String.format(knownEntityGuidFormat, 0))); zs.close(); }
private void init() { setGuid(nextInternalId()); setStatus(null); setCreatedBy(null); setUpdatedBy(null); setCreateTime(null); setUpdateTime(null); setClassifications(null); }
@Test public void recordsEntityWithExtInfoEntries() throws AtlasBaseException { final int max_entries = 3; ByteArrayOutputStream byteOutputStream = new ByteArrayOutputStream(); ZipSink zs = new ZipSink(byteOutputStream); AtlasEntity entity = new AtlasEntity(); entity.setGuid(String.format(knownEntityGuidFormat, 0)); AtlasEntity.AtlasEntityWithExtInfo entityWithExtInfo = new AtlasEntity.AtlasEntityWithExtInfo(entity); addReferredEntities(entityWithExtInfo, max_entries); zs.add(entityWithExtInfo); for (int i = 0; i <= max_entries; i++) { String g = String.format(knownEntityGuidFormat, i); assertTrue(zs.hasEntity(g)); } zs.close(); }
@Test public void recordsEntityWithExtInfoEntries() throws AtlasBaseException { final int max_entries = 3; ByteArrayOutputStream byteOutputStream = new ByteArrayOutputStream(); ZipSink zs = new ZipSink(byteOutputStream); AtlasEntity entity = new AtlasEntity(); entity.setGuid(String.format(knownEntityGuidFormat, 0)); AtlasEntity.AtlasEntityWithExtInfo entityWithExtInfo = new AtlasEntity.AtlasEntityWithExtInfo(entity); addReferredEntities(entityWithExtInfo, max_entries); zs.add(entityWithExtInfo); for (int i = 0; i <= max_entries; i++) { String g = String.format(knownEntityGuidFormat, i); assertTrue(zs.hasEntity(g)); } zs.close(); }
private AtlasEntity mapSystemAttributes(AtlasVertex entityVertex, AtlasEntity entity) { if (LOG.isDebugEnabled()) { LOG.debug("Mapping system attributes for type {}", entity.getTypeName()); } entity.setGuid(getGuid(entityVertex)); entity.setTypeName(getTypeName(entityVertex)); entity.setStatus(GraphHelper.getStatus(entityVertex)); entity.setVersion(GraphHelper.getVersion(entityVertex)); entity.setCreatedBy(GraphHelper.getCreatedByAsString(entityVertex)); entity.setUpdatedBy(GraphHelper.getModifiedByAsString(entityVertex)); entity.setCreateTime(new Date(GraphHelper.getCreatedTime(entityVertex))); entity.setUpdateTime(new Date(GraphHelper.getModifiedTime(entityVertex))); entity.setHomeId(GraphHelper.getHomeId(entityVertex)); entity.setIsProxy(GraphHelper.isProxy(entityVertex)); return entity; }
private AtlasEntity mapSystemAttributes(AtlasVertex entityVertex, AtlasEntity entity) { if (LOG.isDebugEnabled()) { LOG.debug("Mapping system attributes for type {}", entity.getTypeName()); } entity.setGuid(getGuid(entityVertex)); entity.setTypeName(getTypeName(entityVertex)); entity.setStatus(GraphHelper.getStatus(entityVertex)); entity.setVersion(GraphHelper.getVersion(entityVertex)); entity.setCreatedBy(GraphHelper.getCreatedByAsString(entityVertex)); entity.setUpdatedBy(GraphHelper.getModifiedByAsString(entityVertex)); entity.setCreateTime(new Date(GraphHelper.getCreatedTime(entityVertex))); entity.setUpdateTime(new Date(GraphHelper.getModifiedTime(entityVertex))); entity.setHomeId(GraphHelper.getHomeId(entityVertex)); entity.setIsProxy(GraphHelper.isProxy(entityVertex)); entity.setProvenanceType(GraphHelper.getProvenanceType(entityVertex)); return entity; }
private void init() { setGuid(nextInternalId()); setHomeId(null); setIsProxy(Boolean.FALSE); setStatus(null); setCreatedBy(null); setUpdatedBy(null); setCreateTime(null); setUpdateTime(null); setClassifications(null); setMeanings(null); }
public AtlasEntity(AtlasEntity other) { super(other); if (other != null) { setGuid(other.getGuid()); setStatus(other.getStatus()); setCreatedBy(other.getCreatedBy()); setUpdatedBy(other.getUpdatedBy()); setCreateTime(other.getCreateTime()); setUpdateTime(other.getUpdateTime()); setVersion(other.getVersion()); setClassifications(other.getClassifications()); } }
public AtlasEntity(AtlasEntity other) { super(other); if (other != null) { setGuid(other.getGuid()); setHomeId(other.getHomeId()); setIsProxy(other.isProxy()); setStatus(other.getStatus()); setCreatedBy(other.getCreatedBy()); setUpdatedBy(other.getUpdatedBy()); setCreateTime(other.getCreateTime()); setUpdateTime(other.getUpdateTime()); setVersion(other.getVersion()); setClassifications(other.getClassifications()); } }