private void restoreEntityAttributes(AtlasEntity entity, Map<String, Object> prunedAttributes) { if (MapUtils.isEmpty(prunedAttributes)) { return; } AtlasEntityType entityType = typeRegistry.getEntityTypeByName(entity.getTypeName()); if (entityType != null && MapUtils.isNotEmpty(entityType.getAllAttributes())) { for (AtlasAttribute attribute : entityType.getAllAttributes().values()) { String attrName = attribute.getName(); if (prunedAttributes.containsKey(attrName)) { entity.setAttribute(attrName, prunedAttributes.get(attrName)); } } } }
private void restoreEntityAttributes(AtlasEntity entity, Map<String, Object> prunedAttributes) { if (MapUtils.isEmpty(prunedAttributes)) { return; } AtlasEntityType entityType = typeRegistry.getEntityTypeByName(entity.getTypeName()); if (entityType != null && MapUtils.isNotEmpty(entityType.getAllAttributes())) { for (AtlasAttribute attribute : entityType.getAllAttributes().values()) { String attrName = attribute.getName(); if (prunedAttributes.containsKey(attrName)) { entity.setAttribute(attrName, prunedAttributes.get(attrName)); } } } }
private Map<String, Object> pruneEntityAttributesForAudit(AtlasEntity entity) { Map<String, Object> ret = null; Map<String, Object> entityAttributes = entity.getAttributes(); List<String> excludeAttributes = auditRepository.getAuditExcludeAttributes(entity.getTypeName()); AtlasEntityType entityType = typeRegistry.getEntityTypeByName(entity.getTypeName()); if (CollectionUtils.isNotEmpty(excludeAttributes) && MapUtils.isNotEmpty(entityAttributes) && entityType != null) { for (AtlasAttribute attribute : entityType.getAllAttributes().values()) { String attrName = attribute.getName(); Object attrValue = entityAttributes.get(attrName); if (excludeAttributes.contains(attrName)) { if (ret == null) { ret = new HashMap<>(); } ret.put(attrName, attrValue); entityAttributes.remove(attrName); } } } return ret; }
private Map<String, Object> pruneEntityAttributesForAudit(AtlasEntity entity) { Map<String, Object> ret = null; Map<String, Object> entityAttributes = entity.getAttributes(); List<String> excludeAttributes = auditRepository.getAuditExcludeAttributes(entity.getTypeName()); AtlasEntityType entityType = typeRegistry.getEntityTypeByName(entity.getTypeName()); if (CollectionUtils.isNotEmpty(excludeAttributes) && MapUtils.isNotEmpty(entityAttributes) && entityType != null) { for (AtlasAttribute attribute : entityType.getAllAttributes().values()) { String attrName = attribute.getName(); Object attrValue = entityAttributes.get(attrName); if (excludeAttributes.contains(attrName)) { if (ret == null) { ret = new HashMap<>(); } ret.put(attrName, attrValue); entityAttributes.remove(attrName); } } } return ret; }
private Map<String, AtlasAttribute> getAttrsForType(String typeName) { return typeRegistry.getEntityTypeByName(typeName).getAllAttributes(); } }
private Map<String, AtlasAttribute> getAttrsForType(String typeName) { return typeRegistry.getEntityTypeByName(typeName).getAllAttributes(); } }
void visitEntity(AtlasEntityType entityType, AtlasEntity entity) throws AtlasBaseException { List<String> visitedAttributes = new ArrayList<>(); // visit relationship attributes visitRelationships(entityType, entity, visitedAttributes); // visit struct attributes for (AtlasAttribute attribute : entityType.getAllAttributes().values()) { AtlasType attrType = attribute.getAttributeType(); String attrName = attribute.getName(); Object attrVal = entity.getAttribute(attrName); if (entity.hasAttribute(attrName) && !visitedAttributes.contains(attrName)) { visitAttribute(attrType, attrVal); } } }
void visitEntity(AtlasEntityType entityType, AtlasEntity entity) throws AtlasBaseException { List<String> visitedAttributes = new ArrayList<>(); // visit relationship attributes visitRelationships(entityType, entity, visitedAttributes); // visit struct attributes for (AtlasAttribute attribute : entityType.getAllAttributes().values()) { AtlasType attrType = attribute.getAttributeType(); String attrName = attribute.getName(); Object attrVal = entity.getAttribute(attrName); if (entity.hasAttribute(attrName) && !visitedAttributes.contains(attrName)) { visitAttribute(attrType, attrVal); } } }
public static ClassTypeDefinition toClassTypeDefinition(final AtlasEntityType entityType) { ClassTypeDefinition ret = null; if (entityType != null) { AtlasEntityDef entityDef = entityType.getEntityDef(); ret = new ClassTypeDefinition(); ret.setTypeName(entityDef.getName()); ret.setTypeDescription(entityDef.getDescription()); ret.setTypeVersion(entityDef.getTypeVersion()); ret.setSuperTypes(entityDef.getSuperTypes()); if (MapUtils.isNotEmpty(entityType.getAllAttributes())) { List<AttributeDefinition> attributeDefinitions = entityType.getAllAttributes() .entrySet() .stream() .map(e -> toV1AttributeDefinition(e.getValue())) .collect(Collectors.toList()); ret.setAttributeDefinitions(attributeDefinitions); } } return ret; }
private void restoreEntityAttributes(Referenceable entity, Map<String, Object> prunedAttributes) throws AtlasException { if (MapUtils.isEmpty(prunedAttributes)) { return; } AtlasEntityType entityType = typeRegistry.getEntityTypeByName(entity.getTypeName()); if (entityType != null && MapUtils.isNotEmpty(entityType.getAllAttributes())) { Map<String, Object> entityAttributes = entity.getValuesMap(); for (AtlasStructType.AtlasAttribute attribute : entityType.getAllAttributes().values()) { String attrName = attribute.getName(); Object attrValue = entityAttributes.get(attrName); if (prunedAttributes.containsKey(attrName)) { entity.set(attrName, prunedAttributes.get(attrName)); } else if (attribute.isOwnedRef()) { if (attrValue instanceof Collection) { for (Object arrElem : (Collection) attrValue) { if (arrElem instanceof Referenceable) { restoreAttributes(prunedAttributes, (Referenceable) arrElem); } } } else if (attrValue instanceof Referenceable) { restoreAttributes(prunedAttributes, (Referenceable) attrValue); } } } } }
private void validateAttributeNames(AtlasTypeRegistry typeRegistry, String typeName, Set<String> attributeNames) { AtlasType type = null; try { type = typeRegistry.getType(typeName); } catch (AtlasBaseException excp) { } Map<String, AtlasStructType.AtlasAttribute> attributes = null; if (type != null) { if (type instanceof AtlasEntityType) { attributes = ((AtlasEntityType) type).getAllAttributes(); } else if (type instanceof AtlasClassificationType) { attributes = ((AtlasClassificationType) type).getAllAttributes(); } } assertNotNull(attributes); assertEquals(attributes.keySet(), attributeNames); } }
private Map<String, Object> pruneEntityAttributesForAudit(Referenceable entity) throws AtlasException { Map<String, Object> ret = null; Map<String, Object> entityAttributes = entity.getValuesMap(); List<String> excludeAttributes = auditRepository.getAuditExcludeAttributes(entity.getTypeName()); AtlasEntityType entityType = typeRegistry.getEntityTypeByName(entity.getTypeName()); if (CollectionUtils.isNotEmpty(excludeAttributes) && MapUtils.isNotEmpty(entityAttributes) && entityType != null) { for (AtlasStructType.AtlasAttribute attribute : entityType.getAllAttributes().values()) { String attrName = attribute.getName(); Object attrValue = entityAttributes.get(attrName); if (excludeAttributes.contains(attrName)) { if (ret == null) { ret = new HashMap<>(); } ret.put(attrName, attrValue); entityAttributes.remove(attrName); } else if (attribute.isOwnedRef()) { if (attrValue instanceof Collection) { for (Object arrElem : (Collection) attrValue) { if (arrElem instanceof Referenceable) { ret = pruneAttributes(ret, (Referenceable) arrElem); } } } else if (attrValue instanceof Referenceable) { ret = pruneAttributes(ret, (Referenceable) attrValue); } } } } return ret; }
for (AtlasAttribute attribute : entityType.getAllAttributes().values()) { String attrName = attribute.getName(); AtlasType attrType = attribute.getAttributeType();
for (AtlasStructType.AtlasAttribute attributeInfo : entityType.getAllAttributes().values()) { if (!attributeInfo.isOwnedRef()) { continue;
for (AtlasAttribute attribute : entityType.getAllAttributes().values()) { if (attribute.getAttributeDef().getIsUnique() || attribute.getAttributeDef().getIncludeInNotification()) { Object attrValue = entity.getAttribute(attribute.getName());
for (AtlasAttribute attribute : entityType.getAllAttributes().values()) { if (!entity.getAttributes().containsKey(attribute.getName())) { // if value is not provided, current value will not be updated continue;