public boolean hasAttribute(String attrName) { return getAttribute(attrName) != null; }
List<AtlasStructDef.AtlasAttributeDef> difference = new ArrayList<>(); for (AtlasStructDef.AtlasAttributeDef attr : incoming.getAttributeDefs()) { if(existing.getAttribute(attr.getName()) == null) { difference.add(attr);
AtlasAttributeDef existingAttribute = currentStructDef.getAttribute(attributeDef.getName()); if (null != existingAttribute && !attributeDef.getTypeName().equals(existingAttribute.getTypeName())) { throw new AtlasBaseException(AtlasErrorCode.BAD_REQUEST, "Data type update for attribute is not supported");
public boolean hasAttribute(String attrName) { return getAttribute(attrName) != null; }
AtlasAttributeDef existingAttribute = currentStructDef.getAttribute(attributeDef.getName()); if (null != existingAttribute && !attributeDef.getTypeName().equals(existingAttribute.getTypeName())) { throw new AtlasBaseException(AtlasErrorCode.BAD_REQUEST, "Data type update for attribute is not supported");
@Override public boolean isValidValueForUpdate(Object obj) { if (obj != null) { Map<String, Object> attributes; if (obj instanceof AtlasStruct) { AtlasStruct structObj = (AtlasStruct) obj; attributes = structObj.getAttributes(); } else if (obj instanceof Map) { attributes = AtlasTypeUtil.toStructAttributes((Map) obj); } else { return false; } if (MapUtils.isNotEmpty(attributes)) { for (Map.Entry<String, Object> e : attributes.entrySet()) { String attrName = e.getKey(); Object attrValue = e.getValue(); AtlasAttributeDef attrDef = structDef.getAttribute(attrName); if (attrValue == null || attrDef == null) { continue; } if (!isAssignableValueForUpdate(attrValue, attrDef)) { return false; } } } } return true; }
AtlasAttributeDef inverseRefAttrDef = attrType.getStructDef().getAttribute(inverseRefAttrName);
@Override public boolean isValidValueForUpdate(Object obj) { if (obj != null) { Map<String, Object> attributes; if (obj instanceof AtlasStruct) { AtlasStruct structObj = (AtlasStruct) obj; attributes = structObj.getAttributes(); } else if (obj instanceof Map) { attributes = AtlasTypeUtil.toStructAttributes((Map) obj); } else { return false; } if (MapUtils.isNotEmpty(attributes)) { for (Map.Entry<String, Object> e : attributes.entrySet()) { String attrName = e.getKey(); Object attrValue = e.getValue(); AtlasAttributeDef attrDef = structDef.getAttribute(attrName); if (attrValue == null || attrDef == null) { continue; } if (!isAssignableValueForUpdate(attrValue, attrDef)) { return false; } } } } return true; }
AtlasAttributeDef inverseRefAttrDef = attrType.getStructDef().getAttribute(inverseRefAttrName);
private void updateCollectionWithDifferingAttributes(List<AtlasStructDef.AtlasAttributeDef> difference, AtlasStructDef existing, AtlasStructDef.AtlasAttributeDef incoming) throws AtlasBaseException { AtlasStructDef.AtlasAttributeDef existingAttribute = existing.getAttribute(incoming.getName()); if (existingAttribute == null) { difference.add(incoming); } else { if (!existingAttribute.getTypeName().equals(incoming.getTypeName())) { LOG.error("Attribute definition difference found: {}, {}", existingAttribute, incoming); throw new AtlasBaseException(AtlasErrorCode.INVALID_IMPORT_ATTRIBUTE_TYPE_CHANGED, existing.getName(), existingAttribute.getName(), existingAttribute.getTypeName(), incoming.getTypeName()); } } }