private Tuple<EntityChangeType, AtlasEntity> toAtlasEntity(EntityChangeType changeType, final NiFiFlowPath path) { final AtlasEntity entity = EntityChangeType.CREATED.equals(changeType) ? new AtlasEntity() : new AtlasEntity(path.getExEntity()); entity.setTypeName(TYPE_NIFI_FLOW_PATH); entity.setVersion(1L); entity.setAttribute(ATTR_NIFI_FLOW, getAtlasObjectId()); final StringBuilder name = new StringBuilder(); final StringBuilder description = new StringBuilder(); path.getProcessComponentIds().forEach(pid -> { final String componentName = getProcessComponentName(pid); if (name.length() > 0) { name.append(", "); description.append(", "); } name.append(componentName); description.append(String.format("%s::%s", componentName, pid)); }); path.setName(name.toString()); entity.setAttribute(ATTR_NAME, name.toString()); entity.setAttribute(ATTR_DESCRIPTION, description.toString()); // Use first processor's id as qualifiedName. entity.setAttribute(ATTR_QUALIFIED_NAME, toQualifiedName(path.getId())); entity.setAttribute(ATTR_URL, path.createDeepLinkURL(getUrl())); final boolean inputsChanged = setChangedIOIds(path, entity, true); final boolean outputsChanged = setChangedIOIds(path, entity, false); // Even iff there's no flow path metadata changed, if any IO is changed then the pass should be updated. EntityChangeType finalChangeType = EntityChangeType.AS_IS.equals(changeType) ? (path.isMetadataUpdated() || inputsChanged || outputsChanged ? EntityChangeType.UPDATED : EntityChangeType.AS_IS) : changeType; return new Tuple<>(finalChangeType, entity); }
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; }
setVersion(((Number) version).longValue());
private Tuple<EntityChangeType, AtlasEntity> toAtlasEntity(EntityChangeType changeType, final NiFiFlowPath path) { final AtlasEntity entity = EntityChangeType.CREATED.equals(changeType) ? new AtlasEntity() : new AtlasEntity(path.getExEntity()); entity.setTypeName(TYPE_NIFI_FLOW_PATH); entity.setVersion(1L); entity.setAttribute(ATTR_NIFI_FLOW, getAtlasObjectId()); final StringBuilder name = new StringBuilder(); final StringBuilder description = new StringBuilder(); path.getProcessComponentIds().forEach(pid -> { final String componentName = getProcessComponentName(pid); if (name.length() > 0) { name.append(", "); description.append(", "); } name.append(componentName); description.append(String.format("%s::%s", componentName, pid)); }); path.setName(name.toString()); entity.setAttribute(ATTR_NAME, name.toString()); entity.setAttribute(ATTR_DESCRIPTION, description.toString()); // Use first processor's id as qualifiedName. entity.setAttribute(ATTR_QUALIFIED_NAME, toQualifiedName(path.getId())); entity.setAttribute(ATTR_URL, path.createDeepLinkURL(getUrl())); final boolean inputsChanged = setChangedIOIds(path, entity, true); final boolean outputsChanged = setChangedIOIds(path, entity, false); // Even iff there's no flow path metadata changed, if any IO is changed then the pass should be updated. EntityChangeType finalChangeType = EntityChangeType.AS_IS.equals(changeType) ? (path.isMetadataUpdated() || inputsChanged || outputsChanged ? EntityChangeType.UPDATED : EntityChangeType.AS_IS) : changeType; return new Tuple<>(finalChangeType, 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)); 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 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; }
entity.setUpdatedBy(entRef.getSystemAttributes().modifiedBy); entity.setUpdateTime(entRef.getSystemAttributes().modifiedTime); entity.setVersion((long) entRef.getId().version);
entity.setVersion((long) entRef.getId().getVersion());
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()); } }
shallowEntity.setUpdatedBy(entity.getUpdatedBy()); shallowEntity.setStatus(entity.getStatus()); shallowEntity.setVersion(entity.getVersion());
shallowEntity.setUpdatedBy(entity.getUpdatedBy()); shallowEntity.setStatus(entity.getStatus()); shallowEntity.setVersion(entity.getVersion());
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()); } }