private List<Referenceable> toReferenceables(List<AtlasRelatedObjectId> entityIds) throws AtlasBaseException { List<Referenceable> ret = new ArrayList<>(); if (CollectionUtils.isNotEmpty(entityIds)) { for (AtlasRelatedObjectId relatedObjectId : entityIds) { String entityGuid = relatedObjectId.getGuid(); ret.add(toReferenceable(entityGuid)); } } return ret; }
private List<Referenceable> toReferenceables(List<AtlasRelatedObjectId> entityIds) throws AtlasBaseException { List<Referenceable> ret = new ArrayList<>(); if (CollectionUtils.isNotEmpty(entityIds)) { for (AtlasRelatedObjectId relatedObjectId : entityIds) { String entityGuid = relatedObjectId.getGuid(); ret.add(toReferenceable(entityGuid)); } } return ret; }
public void processTermAssignments(AtlasGlossaryTerm glossaryTerm, Collection<AtlasRelatedObjectId> relatedObjectIds) throws AtlasBaseException { if (DEBUG_ENABLED) { LOG.debug("==> GlossaryTermUtils.processTermAssignments({}, {})", glossaryTerm, relatedObjectIds); } Objects.requireNonNull(glossaryTerm); Set<AtlasRelatedObjectId> assignedEntities = glossaryTerm.getAssignedEntities(); for (AtlasRelatedObjectId objectId : relatedObjectIds) { if (CollectionUtils.isNotEmpty(assignedEntities) && assignedEntities.contains(objectId)) { if (DEBUG_ENABLED) { LOG.debug("Skipping already assigned entity {}", objectId); continue; } } if (DEBUG_ENABLED) { LOG.debug("Assigning term guid={}, to entity guid = {}", glossaryTerm.getGuid(), objectId.getGuid()); } createRelationship(defineTermAssignment(glossaryTerm.getGuid(), objectId)); } if (DEBUG_ENABLED) { LOG.debug("<== GlossaryTermUtils.processTermAssignments()"); } }
public void processTermAssignments(AtlasGlossaryTerm glossaryTerm, Collection<AtlasRelatedObjectId> relatedObjectIds) throws AtlasBaseException { if (DEBUG_ENABLED) { LOG.debug("==> GlossaryTermUtils.processTermAssignments({}, {})", glossaryTerm, relatedObjectIds); } Objects.requireNonNull(glossaryTerm); Set<AtlasRelatedObjectId> assignedEntities = glossaryTerm.getAssignedEntities(); for (AtlasRelatedObjectId objectId : relatedObjectIds) { if (CollectionUtils.isNotEmpty(assignedEntities) && assignedEntities.contains(objectId)) { if (DEBUG_ENABLED) { LOG.debug("Skipping already assigned entity {}", objectId); continue; } } if (DEBUG_ENABLED) { LOG.debug("Assigning term guid={}, to entity guid = {}", glossaryTerm.getGuid(), objectId.getGuid()); } createRelationship(defineTermAssignment(glossaryTerm.getGuid(), objectId)); } if (DEBUG_ENABLED) { LOG.debug("<== GlossaryTermUtils.processTermAssignments()"); } }
@Override public void onTermDeleted(AtlasGlossaryTerm term, List<AtlasRelatedObjectId> entities) throws AtlasBaseException { if (term != null && CollectionUtils.isNotEmpty(entities)) { List<EntityAuditEventV2> events = new ArrayList<>(); for (AtlasRelatedObjectId relatedObjectId : entities) { AtlasEntityWithExtInfo entityWithExtInfo = instanceConverter.getAndCacheEntity(relatedObjectId.getGuid()); AtlasEntity entity = (entityWithExtInfo != null) ? entityWithExtInfo.getEntity() : null; if (entity != null) { events.add(createEvent(entity, TERM_DELETE, "Deleted term: " + term.toAuditString())); } } auditRepository.putEventsV2(events); } }
@Override public void onTermAdded(AtlasGlossaryTerm term, List<AtlasRelatedObjectId> entities) throws AtlasBaseException { if (term != null && CollectionUtils.isNotEmpty(entities)) { List<EntityAuditEventV2> events = new ArrayList<>(); for (AtlasRelatedObjectId relatedObjectId : entities) { AtlasEntityWithExtInfo entityWithExtInfo = instanceConverter.getAndCacheEntity(relatedObjectId.getGuid()); AtlasEntity entity = (entityWithExtInfo != null) ? entityWithExtInfo.getEntity() : null; if (entity != null) { events.add(createEvent(entity, TERM_ADD, "Added term: " + term.toAuditString())); } } auditRepository.putEventsV2(events); } }
protected AtlasGlossaryHeader constructGlossaryId(AtlasRelatedObjectId relatedObjectId) { AtlasGlossaryHeader ret = new AtlasGlossaryHeader(); ret.setGlossaryGuid(relatedObjectId.getGuid()); ret.setRelationGuid(relatedObjectId.getRelationshipGuid()); return ret; }
protected AtlasGlossaryHeader constructGlossaryId(AtlasRelatedObjectId relatedObjectId) { AtlasGlossaryHeader ret = new AtlasGlossaryHeader(); ret.setGlossaryGuid(relatedObjectId.getGuid()); ret.setRelationGuid(relatedObjectId.getRelationshipGuid()); return ret; }
@Override public void onTermDeleted(AtlasGlossaryTerm term, List<AtlasRelatedObjectId> entities) throws AtlasBaseException { if (term != null && CollectionUtils.isNotEmpty(entities)) { MetricRecorder metric = RequestContext.get().startMetricRecord("entityAudit"); List<EntityAuditEventV2> events = new ArrayList<>(); for (AtlasRelatedObjectId relatedObjectId : entities) { AtlasEntity entity = instanceConverter.getAndCacheEntity(relatedObjectId.getGuid()); if (entity != null) { events.add(createEvent(entity, TERM_DELETE, "Deleted term: " + term.toAuditString())); } } auditRepository.putEventsV2(events); RequestContext.get().endMetricRecord(metric); } }
@Override public void onTermAdded(AtlasGlossaryTerm term, List<AtlasRelatedObjectId> entities) throws AtlasBaseException { if (term != null && CollectionUtils.isNotEmpty(entities)) { MetricRecorder metric = RequestContext.get().startMetricRecord("entityAudit"); List<EntityAuditEventV2> events = new ArrayList<>(); for (AtlasRelatedObjectId relatedObjectId : entities) { AtlasEntity entity = instanceConverter.getAndCacheEntity(relatedObjectId.getGuid()); if (entity != null) { events.add(createEvent(entity, TERM_ADD, "Added term: " + term.toAuditString())); } } auditRepository.putEventsV2(events); RequestContext.get().endMetricRecord(metric); } }
protected static List<AtlasObjectId> toAtlasObjectIds(Object object) { List<AtlasObjectId> ret = new ArrayList<>(); if (object instanceof List) { List<?> objectIds = (List) object; if (CollectionUtils.isNotEmpty(objectIds)) { for (Object obj : objectIds) { if (obj instanceof AtlasRelatedObjectId) { AtlasRelatedObjectId relatedObjectId = (AtlasRelatedObjectId) obj; ret.add(new AtlasObjectId(relatedObjectId.getGuid(), relatedObjectId.getTypeName(), relatedObjectId.getUniqueAttributes())); } } } } return ret; }
protected static List<AtlasObjectId> toAtlasObjectIds(Object object) { List<AtlasObjectId> ret = new ArrayList<>(); if (object instanceof List) { List<?> objectIds = (List) object; if (CollectionUtils.isNotEmpty(objectIds)) { for (Object obj : objectIds) { if (obj instanceof AtlasRelatedObjectId) { AtlasRelatedObjectId relatedObjectId = (AtlasRelatedObjectId) obj; ret.add(new AtlasObjectId(relatedObjectId.getGuid(), relatedObjectId.getTypeName(), relatedObjectId.getUniqueAttributes())); } } } } return ret; }
protected AtlasRelatedCategoryHeader constructRelatedCategoryId(AtlasRelatedObjectId relatedObjectId) { AtlasRelatedCategoryHeader ret = new AtlasRelatedCategoryHeader(); ret.setCategoryGuid(relatedObjectId.getGuid()); ret.setRelationGuid(relatedObjectId.getRelationshipGuid()); AtlasStruct relationshipAttributes = relatedObjectId.getRelationshipAttributes(); if (relationshipAttributes != null) { ret.setDescription((String) relationshipAttributes.getAttribute("description")); } return ret; }
protected static AtlasObjectId toAtlasObjectId(Object object) { if (object instanceof AtlasRelatedObjectId) { AtlasRelatedObjectId relatedObjectId = (AtlasRelatedObjectId) object; return new AtlasObjectId(relatedObjectId.getGuid(), relatedObjectId.getTypeName(), relatedObjectId.getUniqueAttributes()); } return null; }
protected AtlasRelatedCategoryHeader constructRelatedCategoryId(AtlasRelatedObjectId relatedObjectId) { AtlasRelatedCategoryHeader ret = new AtlasRelatedCategoryHeader(); ret.setCategoryGuid(relatedObjectId.getGuid()); ret.setRelationGuid(relatedObjectId.getRelationshipGuid()); AtlasStruct relationshipAttributes = relatedObjectId.getRelationshipAttributes(); if (relationshipAttributes != null) { ret.setDescription((String) relationshipAttributes.getAttribute("description")); } return ret; }
protected static AtlasObjectId toAtlasObjectId(Object object) { if (object instanceof AtlasRelatedObjectId) { AtlasRelatedObjectId relatedObjectId = (AtlasRelatedObjectId) object; return new AtlasObjectId(relatedObjectId.getGuid(), relatedObjectId.getTypeName(), relatedObjectId.getUniqueAttributes()); } return null; }
protected AtlasTermCategorizationHeader constructTermCategorizationId(final AtlasRelatedObjectId category) { AtlasTermCategorizationHeader ret = new AtlasTermCategorizationHeader(); ret.setCategoryGuid(category.getGuid()); ret.setRelationGuid(category.getRelationshipGuid()); AtlasStruct relationshipAttributes = category.getRelationshipAttributes(); if (relationshipAttributes != null) { ret.setDescription((String) relationshipAttributes.getAttribute("description")); Object status = relationshipAttributes.getAttribute("status"); if (status instanceof AtlasTermRelationshipStatus) { ret.setStatus((AtlasTermRelationshipStatus) status); } else if (status instanceof String) { ret.setStatus(AtlasTermRelationshipStatus.valueOf((String) status)); } } return ret; }
protected AtlasTermCategorizationHeader constructTermCategorizationId(final AtlasRelatedObjectId category) { AtlasTermCategorizationHeader ret = new AtlasTermCategorizationHeader(); ret.setCategoryGuid(category.getGuid()); ret.setRelationGuid(category.getRelationshipGuid()); AtlasStruct relationshipAttributes = category.getRelationshipAttributes(); if (relationshipAttributes != null) { ret.setDescription((String) relationshipAttributes.getAttribute("description")); Object status = relationshipAttributes.getAttribute("status"); if (status instanceof AtlasTermRelationshipStatus) { ret.setStatus((AtlasTermRelationshipStatus) status); } else if (status instanceof String) { ret.setStatus(AtlasTermRelationshipStatus.valueOf((String) status)); } } return ret; }
protected AtlasRelatedTermHeader constructRelatedTermId(AtlasRelatedObjectId relatedObjectId) { AtlasRelatedTermHeader ret = new AtlasRelatedTermHeader(); ret.setTermGuid(relatedObjectId.getGuid()); ret.setRelationGuid(relatedObjectId.getRelationshipGuid()); AtlasStruct relationshipAttributes = relatedObjectId.getRelationshipAttributes(); if (relationshipAttributes != null) { ret.setDescription((String) relationshipAttributes.getAttribute("description")); ret.setExpression((String) relationshipAttributes.getAttribute("expression")); ret.setSource((String) relationshipAttributes.getAttribute("source")); ret.setSteward((String) relationshipAttributes.getAttribute("steward")); Object status = relationshipAttributes.getAttribute("status"); if (status instanceof String) { ret.setStatus(AtlasTermRelationshipStatus.valueOf((String) status)); } else if (status instanceof AtlasTermRelationshipStatus) { ret.setStatus((AtlasTermRelationshipStatus) status); } } return ret; }
protected AtlasRelatedTermHeader constructRelatedTermId(AtlasRelatedObjectId relatedObjectId) { AtlasRelatedTermHeader ret = new AtlasRelatedTermHeader(); ret.setTermGuid(relatedObjectId.getGuid()); ret.setRelationGuid(relatedObjectId.getRelationshipGuid()); AtlasStruct relationshipAttributes = relatedObjectId.getRelationshipAttributes(); if (relationshipAttributes != null) { ret.setDescription((String) relationshipAttributes.getAttribute("description")); ret.setExpression((String) relationshipAttributes.getAttribute("expression")); ret.setSource((String) relationshipAttributes.getAttribute("source")); ret.setSteward((String) relationshipAttributes.getAttribute("steward")); Object status = relationshipAttributes.getAttribute("status"); if (status instanceof String) { ret.setStatus(AtlasTermRelationshipStatus.valueOf((String) status)); } else if (status instanceof AtlasTermRelationshipStatus) { ret.setStatus((AtlasTermRelationshipStatus) status); } } return ret; }