private void rectifyOwnedReferenceError(AtlasStructDef structDef, AtlasAttributeDef attributeDef) { List<AtlasConstraintDef> constraints = attributeDef.getConstraints(); if (CollectionUtils.isNotEmpty(constraints)) { for (int i = 0; i < constraints.size(); i++) { AtlasConstraintDef constraint = constraints.get(i); if (constraint.isConstraintType(AtlasConstraintDef.CONSTRAINT_TYPE_OWNED_REF)) { LOG.warn("Invalid constraint ownedRef for attribute {}.{}", structDef.getName(), attributeDef.getName()); constraints.remove(i); i--; } } } }
private void rectifyAttributesIfNeeded(final Set<String> entityNames, AtlasStructDef structDef) { List<AtlasAttributeDef> attributeDefs = structDef.getAttributeDefs(); if (CollectionUtils.isNotEmpty(attributeDefs)) { for (AtlasAttributeDef attributeDef : attributeDefs) { if (!hasOwnedReferenceConstraint(attributeDef.getConstraints())) { continue; } Set<String> referencedTypeNames = AtlasTypeUtil.getReferencedTypeNames(attributeDef.getTypeName()); boolean valid = false; for (String referencedTypeName : referencedTypeNames) { if (entityNames.contains(referencedTypeName)) { valid = true; break; } } if (!valid) { rectifyOwnedReferenceError(structDef, attributeDef); } } } }
public AtlasAttribute(AtlasStructType definedInType, AtlasAttributeDef attrDef, AtlasType attributeType, String relationshipLabel) { this.definedInType = definedInType; this.attributeDef = attrDef; this.attributeType = attributeType.getTypeForAttribute(); this.qualifiedName = getQualifiedAttributeName(definedInType.getStructDef(), attributeDef.getName()); this.vertexPropertyName = encodePropertyKey(this.qualifiedName); this.relationshipEdgeLabel = getRelationshipEdgeLabel(relationshipLabel); boolean isOwnedRef = false; String inverseRefAttribute = null; if (CollectionUtils.isNotEmpty(attributeDef.getConstraints())) { for (AtlasConstraintDef constraint : attributeDef.getConstraints()) { if (constraint.isConstraintType(CONSTRAINT_TYPE_OWNED_REF)) { isOwnedRef = true; } if (constraint.isConstraintType(CONSTRAINT_TYPE_INVERSE_REF)) { Object val = constraint.getParam(CONSTRAINT_PARAM_ATTRIBUTE); if (val != null) { inverseRefAttribute = val.toString(); } } } } this.isOwnedRef = isOwnedRef; this.inverseRefAttributeName = inverseRefAttribute; this.relationshipEdgeDirection = AtlasRelationshipEdgeDirection.OUT; }
private void resolveConstraints(AtlasTypeRegistry typeRegistry) throws AtlasBaseException { for (AtlasAttributeDef attributeDef : getStructDef().getAttributeDefs()) { if (CollectionUtils.isEmpty(attributeDef.getConstraints())) { continue; for (AtlasConstraintDef constraint : attributeDef.getConstraints()) { if (constraint.isConstraintType(CONSTRAINT_TYPE_OWNED_REF)) { AtlasEntityType attrType = getReferencedEntityType(typeRegistry.getType(attributeDef.getTypeName()));
private void resolveConstraints(AtlasTypeRegistry typeRegistry) throws AtlasBaseException { for (AtlasAttributeDef attributeDef : getStructDef().getAttributeDefs()) { if (CollectionUtils.isEmpty(attributeDef.getConstraints())) { continue; for (AtlasConstraintDef constraint : attributeDef.getConstraints()) { if (constraint.isConstraintType(CONSTRAINT_TYPE_OWNED_REF)) { AtlasEntityType attrType = getReferencedEntityType(typeRegistry.getType(attributeDef.getTypeName()));
public AtlasAttribute(AtlasStructType definedInType, AtlasAttributeDef attrDef, AtlasType attributeType, String relationshipLabel) { this.definedInType = definedInType; this.attributeDef = attrDef; this.attributeType = attributeType.getTypeForAttribute(); this.qualifiedName = getQualifiedAttributeName(definedInType.getStructDef(), attributeDef.getName()); this.vertexPropertyName = encodePropertyKey(this.qualifiedName); this.relationshipEdgeLabel = getRelationshipEdgeLabel(relationshipLabel); boolean isOwnedRef = false; String inverseRefAttribute = null; if (CollectionUtils.isNotEmpty(attributeDef.getConstraints())) { for (AtlasConstraintDef constraint : attributeDef.getConstraints()) { if (constraint.isConstraintType(CONSTRAINT_TYPE_OWNED_REF)) { isOwnedRef = true; } if (constraint.isConstraintType(CONSTRAINT_TYPE_INVERSE_REF)) { Object val = constraint.getParam(CONSTRAINT_PARAM_ATTRIBUTE); if (val != null) { inverseRefAttribute = val.toString(); } } } } this.isOwnedRef = isOwnedRef; this.inverseRefAttributeName = inverseRefAttribute; this.relationshipEdgeDirection = AtlasRelationshipEdgeDirection.OUT; }
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()); } }