private static void sortCollectionElements(AtlasAttribute attribute, List<AtlasEdge> edges) { // sort array elements based on edge index if (attribute.getAttributeType() instanceof AtlasArrayType && CollectionUtils.isNotEmpty(edges)) { Collections.sort(edges, (e1, e2) -> { Integer e1Index = getIndexValue(e1); Integer e2Index = getIndexValue(e2); return e1Index.compareTo(e2Index); }); } }
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); } } }
private void visitRelationships(AtlasEntityType entityType, AtlasEntity entity, List<String> visitedAttributes) throws AtlasBaseException { for (AtlasAttribute attribute : entityType.getRelationshipAttributes().values()) { AtlasType attrType = attribute.getAttributeType(); String attrName = attribute.getName(); Object attrVal = entity.getRelationshipAttribute(attrName); if (entity.hasRelationshipAttribute(attrName)) { visitAttribute(attrType, attrVal); visitedAttributes.add(attrName); } } }
public AtlasType getAttrType() { return currentElementType == null ? attribute.getAttributeType() : currentElementType; }
private Object getNormalizedValue(Object value, AtlasAttributeDef attributeDef) { AtlasAttribute attribute = allAttributes.get(attributeDef.getName()); if (attribute != null) { AtlasType attrType = attribute.getAttributeType(); if (value == null) { if (!attributeDef.getIsOptional()) { return attrType.createDefaultValue(); } } else { return attrType.getNormalizedValue(value); } } return null; }
private Object getNormalizedValue(Object value, AtlasAttributeDef attributeDef) { AtlasAttribute attribute = allAttributes.get(attributeDef.getName()); if (attribute != null) { AtlasType attrType = attribute.getAttributeType(); if (value == null) { if (!attributeDef.getIsOptional()) { return attrType.createDefaultValue(); } } else { return attrType.getNormalizedValue(value); } } return null; }
private boolean isAssignableValueForUpdate(Object value, AtlasAttributeDef attributeDef) { boolean ret = true; if (value != null) { AtlasAttribute attribute = allAttributes.get(attributeDef.getName()); if (attribute != null) { AtlasType attrType = attribute.getAttributeType(); if (!attrType.isValidValueForUpdate(value)) { ret = false; // invalid value } } } return ret; }
private boolean isAssignableValue(Object value, AtlasAttributeDef attributeDef) { boolean ret = true; if (value != null) { AtlasAttribute attribute = relationshipAttributes.get(attributeDef.getName()); if (attribute != null) { AtlasType attrType = attribute.getAttributeType(); if (!isValidRelationshipType(attrType) && !attrType.isValidValue(value)) { ret = false; } } } return ret; }
private boolean isAssignableValueForUpdate(Object value, AtlasAttributeDef attributeDef) { boolean ret = true; if (value != null) { AtlasAttribute attribute = allAttributes.get(attributeDef.getName()); if (attribute != null) { AtlasType attrType = attribute.getAttributeType(); if (!attrType.isValidValueForUpdate(value)) { ret = false; // invalid value } } } return ret; }
public AtlasType getAttributeType(String attributeName) { AtlasAttribute attribute = getAttribute(attributeName); return attribute != null ? attribute.getAttributeType() : null; }
private boolean isRelationshipAttribute(AtlasAttribute attribute) throws AtlasBaseException { boolean ret = true; AtlasType attrType = attribute.getAttributeType(); if (attrType.getTypeCategory() == ARRAY) { attrType = ((AtlasArrayType) attrType).getElementType(); } else if (attrType.getTypeCategory() == MAP) { attrType = ((AtlasMapType) attrType).getValueType(); } if (attrType.getTypeCategory() != OBJECT_ID_TYPE) { ret = false; } return ret; }
void visitStruct(AtlasStructType structType, AtlasStruct struct) throws AtlasBaseException { for (AtlasAttribute attribute : structType.getAllAttributes().values()) { AtlasType attrType = attribute.getAttributeType(); Object attrVal = struct.getAttribute(attribute.getName()); visitAttribute(attrType, attrVal); } }
private void visitRelationships(AtlasEntityType entityType, AtlasEntity entity, List<String> visitedAttributes) throws AtlasBaseException { for (AtlasAttribute attribute : entityType.getRelationshipAttributes().values()) { AtlasType attrType = attribute.getAttributeType(); String attrName = attribute.getName(); Object attrVal = entity.getRelationshipAttribute(attrName); if (entity.hasRelationshipAttribute(attrName)) { visitAttribute(attrType, attrVal); visitedAttributes.add(attrName); } } }
private Object createDefaultValue(AtlasAttributeDef attributeDef) { Object ret = null; if (attributeDef != null) { AtlasAttribute attribute = allAttributes.get(attributeDef.getName()); if (attribute != null) { AtlasType dataType = attribute.getAttributeType(); ret = dataType.createDefaultValue(attributeDef.getDefaultValue()); } } return ret; }
private Object getNormalizedValue(Object value, AtlasAttributeDef attributeDef) { AtlasAttribute attribute = relationshipAttributes.get(attributeDef.getName()); if (attribute != null) { AtlasType attrType = attribute.getAttributeType(); if (isValidRelationshipType(attrType) && value != null) { return attrType.getNormalizedValue(value); } } return null; }
public AtlasType getAttributeType(String attributeName) { AtlasAttribute attribute = getAttribute(attributeName); return attribute != null ? attribute.getAttributeType() : null; }
private Object createDefaultValue(AtlasAttributeDef attributeDef) { Object ret = null; if (attributeDef != null) { AtlasAttribute attribute = allAttributes.get(attributeDef.getName()); if (attribute != null) { AtlasType dataType = attribute.getAttributeType(); ret = dataType.createDefaultValue(attributeDef.getDefaultValue()); } } return ret; }
private Object getNormalizedValueForUpdate(Object value, AtlasAttributeDef attributeDef) { AtlasAttribute attribute = allAttributes.get(attributeDef.getName()); if (attribute != null) { AtlasType attrType = attribute.getAttributeType(); if (value != null) { return attrType.getNormalizedValueForUpdate(value); } } return null; }
private Object getNormalizedValueForUpdate(Object value, AtlasAttributeDef attributeDef) { AtlasAttribute attribute = allAttributes.get(attributeDef.getName()); if (attribute != null) { AtlasType attrType = attribute.getAttributeType(); if (value != null) { return attrType.getNormalizedValueForUpdate(value); } } return null; }
void visitStruct(AtlasStructType structType, AtlasStruct struct) throws AtlasBaseException { for (AtlasAttribute attribute : structType.getAllAttributes().values()) { AtlasType attrType = attribute.getAttributeType(); Object attrVal = struct.getAttribute(attribute.getName()); visitAttribute(attrType, attrVal); } }