use of org.apache.atlas.model.instance.AtlasStruct in project incubator-atlas by apache.
the class AtlasStructType method validateValueForUpdate.
@Override
public boolean validateValueForUpdate(Object obj, String objName, List<String> messages) {
boolean ret = true;
Map<String, Object> attributes = null;
if (obj != null) {
if (obj instanceof AtlasStruct) {
AtlasStruct structObj = (AtlasStruct) obj;
attributes = structObj.getAttributes();
} else if (obj instanceof Map) {
attributes = AtlasTypeUtil.toStructAttributes((Map) obj);
} else {
ret = false;
messages.add(objName + "=" + obj + ": invalid value for type " + getTypeName());
}
if (MapUtils.isNotEmpty(attributes)) {
for (Map.Entry<String, Object> e : attributes.entrySet()) {
String attrName = e.getKey();
Object attrValue = e.getValue();
AtlasAttribute attribute = allAttributes.get(attrName);
if (attrValue == null) {
continue;
}
if (attribute != null) {
AtlasType dataType = attribute.getAttributeType();
String fieldName = objName + "." + attrName;
ret = dataType.validateValueForUpdate(attrValue, fieldName, messages) && ret;
}
}
}
}
return ret;
}
Aggregations