public void normalizeAttributeValues(Map<String, Object> obj) { if (obj != null) { for (AtlasAttributeDef attributeDef : structDef.getAttributeDefs()) { String attributeName = attributeDef.getName(); if (obj.containsKey(attributeName)) { Object attributeValue = getNormalizedValue(obj.get(attributeName), attributeDef); obj.put(attributeName, attributeValue); } else if (!attributeDef.getIsOptional()) { obj.put(attributeName, createDefaultValue(attributeDef)); } } } }
public void normalizeAttributeValues(Map<String, Object> obj) { if (obj != null) { for (AtlasAttributeDef attributeDef : structDef.getAttributeDefs()) { String attributeName = attributeDef.getName(); if (obj.containsKey(attributeName)) { Object attributeValue = getNormalizedValue(obj.get(attributeName), attributeDef); obj.put(attributeName, attributeValue); } else if (!attributeDef.getIsOptional()) { obj.put(attributeName, createDefaultValue(attributeDef)); } } } }
lower = attributeDef.getIsOptional() ? 0 : 1; upper = 1; } else { if(attributeDef.getIsOptional()) { lower = 0; } else {
if (CollectionUtils.isEmpty(currAttrNames) || !currAttrNames.contains(attributeDef.getName())) { if (!attributeDef.getIsOptional()) { throw new AtlasBaseException(AtlasErrorCode.CANNOT_ADD_MANDATORY_ATTRIBUTE, structDef.getName(), attributeDef.getName());
} else if (!attributeDef.getIsOptional()) { ret = false; messages.add(fieldName + ": mandatory attribute value missing in type " + getTypeName()); } else if (!attributeDef.getIsOptional()) { ret = false; messages.add(fieldName + ": mandatory attribute value missing in type " + getTypeName());
lower = attributeDef.getIsOptional() ? 0 : 1; upper = 1; } else { if(attributeDef.getIsOptional()) { lower = 0; } else {
lower = attributeDef.getIsOptional() ? 0 : 1; upper = 1; } else { if(attributeDef.getIsOptional()) { lower = 0; } else {
private void mapAttribute(AtlasAttribute attribute, Object attrValue, AtlasVertex vertex, EntityOperation op, EntityMutationContext context) throws AtlasBaseException { if (attrValue == null) { AtlasAttributeDef attributeDef = attribute.getAttributeDef(); AtlasType attrType = attribute.getAttributeType(); if (attrType.getTypeCategory() == TypeCategory.PRIMITIVE) { if (attributeDef.getDefaultValue() != null) { attrValue = attrType.createDefaultValue(attributeDef.getDefaultValue()); } else { if (attribute.getAttributeDef().getIsOptional()) { attrValue = attrType.createOptionalDefaultValue(); } else { attrValue = attrType.createDefaultValue(); } } } } AttributeMutationContext ctx = new AttributeMutationContext(op, vertex, attribute, attrValue); mapToVertexByTypeCategory(ctx, context); }
private void mapAttribute(AtlasAttribute attribute, Object attrValue, AtlasVertex vertex, EntityOperation op, EntityMutationContext context) throws AtlasBaseException { if (attrValue == null) { AtlasAttributeDef attributeDef = attribute.getAttributeDef(); AtlasType attrType = attribute.getAttributeType(); if (attrType.getTypeCategory() == TypeCategory.PRIMITIVE) { if (attributeDef.getDefaultValue() != null) { attrValue = attrType.createDefaultValue(attributeDef.getDefaultValue()); } else { if (attribute.getAttributeDef().getIsOptional()) { attrValue = attrType.createOptionalDefaultValue(); } else { attrValue = attrType.createDefaultValue(); } } } } AttributeMutationContext ctx = new AttributeMutationContext(op, vertex, attribute, attrValue); mapToVertexByTypeCategory(ctx, context); }
public static Multiplicity getMultiplicity(AtlasAttributeDef attributeDef) { final int lower; final int upper; final boolean isUnique = AtlasAttributeDef.Cardinality.SET.equals(attributeDef.getCardinality()); if (attributeDef.getCardinality() == AtlasAttributeDef.Cardinality.SINGLE) { lower = attributeDef.getIsOptional() ? 0 : 1; upper = 1; } else { if(attributeDef.getIsOptional()) { lower = 0; } else { lower = attributeDef.getValuesMinCount() < 1 ? 1 : attributeDef.getValuesMinCount(); } upper = attributeDef.getValuesMaxCount() < 2 ? Integer.MAX_VALUE : attributeDef.getValuesMaxCount(); } Multiplicity ret = new Multiplicity(lower, upper, isUnique); return ret; }
private boolean isAssignableValue(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.isValidValue(value)) { ret = false; // invalid value } } } else if (!attributeDef.getIsOptional()) { ret = false; // mandatory attribute not present } return ret; }
private boolean isAssignableValue(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.isValidValue(value)) { ret = false; // invalid value } } } else if (!attributeDef.getIsOptional()) { ret = false; // mandatory attribute not present } return ret; }
public AtlasAttributeDef(AtlasAttributeDef other) { if (other != null) { setName(other.getName()); setTypeName(other.getTypeName()); setIsOptional(other.getIsOptional()); setCardinality(other.getCardinality()); setValuesMinCount(other.getValuesMinCount()); setValuesMaxCount(other.getValuesMaxCount()); setIsUnique(other.getIsUnique()); setIsIndexable(other.getIsIndexable()); setIncludeInNotification(other.getIncludeInNotification()); setDefaultValue(other.getDefaultValue()); setConstraints(other.getConstraints()); setDescription((other.getDescription())); } }
public AtlasAttributeDef(AtlasAttributeDef other) { if (other != null) { setName(other.getName()); setTypeName(other.getTypeName()); setIsOptional(other.getIsOptional()); setCardinality(other.getCardinality()); setValuesMinCount(other.getValuesMinCount()); setValuesMaxCount(other.getValuesMaxCount()); setIsUnique(other.getIsUnique()); setIsIndexable(other.getIsIndexable()); setDefaultValue(other.getDefaultValue()); setConstraints(other.getConstraints()); } }
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; }
public void populateDefaultValues(AtlasStruct obj) { if (obj != null) { Map<String, Object> attributes = obj.getAttributes(); if (attributes == null) { attributes = new HashMap<>(); } for (AtlasAttributeDef attributeDef : structDef.getAttributeDefs()) { if (!attributeDef.getIsOptional()) { attributes.put(attributeDef.getName(), createDefaultValue(attributeDef)); } } obj.setAttributes(attributes); } }
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; }
public void populateDefaultValues(AtlasStruct obj) { if (obj != null) { Map<String, Object> attributes = obj.getAttributes(); if (attributes == null) { attributes = new HashMap<>(); } for (AtlasAttributeDef attributeDef : structDef.getAttributeDefs()) { if (!attributeDef.getIsOptional()) { attributes.put(attributeDef.getName(), createDefaultValue(attributeDef)); } } obj.setAttributes(attributes); } }
public void normalizeAttributeValues(AtlasStruct obj) { if (obj != null) { for (AtlasAttributeDef attributeDef : structDef.getAttributeDefs()) { String attributeName = attributeDef.getName(); if (obj.hasAttribute(attributeName)) { Object attributeValue = getNormalizedValue(obj.getAttribute(attributeName), attributeDef); obj.setAttribute(attributeName, attributeValue); } else if (!attributeDef.getIsOptional()) { obj.setAttribute(attributeName, createDefaultValue(attributeDef)); } } } }
public void normalizeAttributeValues(AtlasStruct obj) { if (obj != null) { for (AtlasAttributeDef attributeDef : structDef.getAttributeDefs()) { String attributeName = attributeDef.getName(); if (obj.hasAttribute(attributeName)) { Object attributeValue = getNormalizedValue(obj.getAttribute(attributeName), attributeDef); obj.setAttribute(attributeName, attributeValue); } else if (!attributeDef.getIsOptional()) { obj.setAttribute(attributeName, createDefaultValue(attributeDef)); } } } }