protected Map<String, AtlasAttribute> getUniqueAttributes(Map<String, AtlasAttribute> attributes) { Map<String, AtlasAttribute> ret = new HashMap<>(); if (MapUtils.isNotEmpty(attributes)) { for (AtlasAttribute attribute : attributes.values()) { if (attribute.getAttributeDef().getIsUnique()) { ret.put(attribute.getName(), attribute); } } } return Collections.unmodifiableMap(ret); }
protected Map<String, AtlasAttribute> getUniqueAttributes(Map<String, AtlasAttribute> attributes) { Map<String, AtlasAttribute> ret = new HashMap<>(); if (MapUtils.isNotEmpty(attributes)) { for (AtlasAttribute attribute : attributes.values()) { if (attribute.getAttributeDef().getIsUnique()) { ret.put(attribute.getName(), attribute); } } } return Collections.unmodifiableMap(ret); }
attribInfo.put("isUnique", attributeDef.getIsUnique()); attribInfo.put("isIndexable", attributeDef.getIsIndexable()); attribInfo.put("includeInNotification", attributeDef.getIncludeInNotification());
private void createIndexForAttribute(AtlasGraphManagement management, String typeName, AtlasAttributeDef attributeDef) { final String propertyName = AtlasGraphUtilsV2.encodePropertyKey(typeName + "." + attributeDef.getName()); AtlasCardinality cardinality = toAtlasCardinality(attributeDef.getCardinality()); boolean isUnique = attributeDef.getIsUnique(); boolean isIndexable = attributeDef.getIsIndexable(); String attribTypeName = attributeDef.getTypeName();
private void createIndexForAttribute(AtlasGraphManagement management, String typeName, AttributeInfo field) { final String propertyName = GraphHelper.encodePropertyKey(typeName + "." + field.name); switch (field.dataType().getTypeCategory()) { case PRIMITIVE: AtlasCardinality cardinality = getCardinality(field.multiplicity); createIndexes(management, propertyName, getPrimitiveClass(field.dataType()), field.isUnique, cardinality, false, field.isIndexable); break; case ENUM: cardinality = getCardinality(field.multiplicity); createIndexes(management, propertyName, String.class, field.isUnique, cardinality, false, field.isIndexable); break; case ARRAY: case MAP: // todo - how do we overcome this limitation? // IGNORE: Can only index single-valued property keys on vertices in Mixed Index break; case STRUCT: StructType structType = (StructType) field.dataType(); createIndexForFields(management, structType, structType.fieldMapping().fields); break; case TRAIT: // do nothing since this is NOT contained in other types break; case CLASS:
if (attribute.getAttributeDef().getIsUnique() || attribute.getAttributeDef().getIncludeInNotification()) { Object attrValue = entity.getAttribute(attribute.getName());
attribInfo.put("isUnique", attributeDef.getIsUnique()); attribInfo.put("isIndexable", attributeDef.getIsIndexable()); attribInfo.put("includeInNotification", attributeDef.getIncludeInNotification());
ret.setIsUnique(attributeDef.getIsUnique()); ret.setIsIndexable(attributeDef.getIsIndexable()); ret.setIsComposite(attribute.isOwnedRef());
/** * Validate that each attribute given is an unique attribute * @param entityType the entity type * @param attributes attributes */ private void validateUniqueAttribute(AtlasEntityType entityType, Map<String, Object> attributes) throws AtlasBaseException { if (MapUtils.isEmpty(attributes)) { throw new AtlasBaseException(AtlasErrorCode.ATTRIBUTE_UNIQUE_INVALID, entityType.getTypeName(), ""); } for (String attributeName : attributes.keySet()) { AtlasAttributeDef attribute = entityType.getAttributeDef(attributeName); if (attribute == null || !attribute.getIsUnique()) { throw new AtlasBaseException(AtlasErrorCode.ATTRIBUTE_UNIQUE_INVALID, entityType.getTypeName(), attributeName); } } } }
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 static AttributeDefinition toAttributeDefinition(AtlasAttribute attribute) { final AtlasAttributeDef attrDef = attribute.getAttributeDef(); AttributeDefinition ret = new AttributeDefinition(); ret.setName(attrDef.getName()); ret.setDataTypeName(attrDef.getTypeName()); ret.setMultiplicity(getMultiplicity(attrDef)); ret.setIsComposite(attribute.isOwnedRef()); ret.setIsUnique(attrDef.getIsUnique()); ret.setIsIndexable(attrDef.getIsIndexable()); ret.setReverseAttributeName(attribute.getInverseRefAttributeName()); ret.setDescription(attrDef.getDescription()); ret.setDefaultValue(attrDef.getDefaultValue()); 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()); setDefaultValue(other.getDefaultValue()); setConstraints(other.getConstraints()); } }
public static AttributeDefinition toAttributeDefinition(AtlasAttribute attribute) { final AtlasAttributeDef attrDef = attribute.getAttributeDef(); AttributeDefinition ret = new AttributeDefinition(); ret.setName(attrDef.getName()); ret.setDataTypeName(attrDef.getTypeName()); ret.setMultiplicity(AtlasTypeUtil.getMultiplicity(attrDef)); ret.setIsComposite(attribute.isOwnedRef()); ret.setIsUnique(attrDef.getIsUnique()); ret.setIsIndexable(attrDef.getIsIndexable()); ret.setReverseAttributeName(attribute.getInverseRefAttributeName()); ret.setDescription(attrDef.getDescription()); ret.setDefaultValue(attrDef.getDefaultValue()); return ret; } }