INVALID_RELATIONSHIP_ATTRIBUTE(400,"ATLAS-400-00-048","Expected attribute {0} to be a relationship but found type {1}"),
INVALID_RELATIONSHIP_TYPE(400,"ATLAS-400-00-049","Invalid entity type '{0}', guid '{1}' in relationship search"),
INVALID_IMPORT_ATTRIBUTE_TYPE_CHANGED(400,"ATLAS-400-00-050","Attribute {0}.{1} is of type {2}. Import has this attribute type as {3}"),
ENTITYTYPE_REMOVAL_NOT_SUPPORTED(400,"ATLAS-400-00-051","EntityTypes cannot be removed from ClassificationDef ‘{0}‘"),
CLASSIFICATIONDEF_INVALID_ENTITYTYPES(400,"ATLAS-400-00-052","ClassificationDef ‘{0}‘ has invalid ‘{1}‘ in entityTypes"),
CLASSIFICATIONDEF_PARENTS_ENTITYTYPES_DISJOINT(400,"ATLAS-400-00-053","ClassificationDef ‘{0}‘ has supertypes whose entityTypes are disjoint; e.g. 2 supertypes that are not related by inheritance specify different non empty entityType lists. This means the child cannot honour the restrictions specified in both parents."),
CLASSIFICATIONDEF_ENTITYTYPES_NOT_PARENTS_SUBSET(400,"ATLAS-400-00-054","ClassificationDef ‘{0}‘ has entityTypes ‘{1}‘ which are not subsets of it's supertypes entityTypes"),
INVALID_ENTITY_FOR_CLASSIFICATION(400,"ATLAS-400-00-055","Entity (guid=‘{0}‘,typename=‘{1}‘) cannot be classified by Classification ‘{2}‘, because ‘{1}‘ is not in the ClassificationDef's restrictions."),
// All Not found enums go here
TYPE_NAME_NOT_FOUND(404,"ATLAS-404-00-001","Given typename {0} was invalid"),
* Specifying a list of entityType names in the classificationDef, ensures that classifications can
* only be applied to those entityTypes.
* <ul>
* <li>Any subtypes of the entity types inherit the restriction</li>
* <li>Any classificationDef subtypes inherit the parents entityTypes restrictions</li>
* <li>Any classificationDef subtypes can further restrict the parents entityTypes restrictions by specifying a subset of the entityTypes</li>
* <li>An empty entityTypes list when there are no parent restrictions means there are no restrictions</li>
* <li>An empty entityTypes list when there are parent restrictions means that the subtype picks up the parents restrictions</li>
* <li>If a list of entityTypes are supplied, where one inherits from another, this will be rejected. This should encourage cleaner classificationsDefs</li>
this.allSubTypes=newHashSet<>();// this will be populated in resolveReferencesPhase2()
this.typeAndAllSubTypes=newHashSet<>();// this will be populated in resolveReferencesPhase2()
this.entityTypes=newHashSet<>();// this will be populated in resolveReferencesPhase3()
this.typeAndAllSubTypes.add(this.getTypeName());
}
...
...
@@ -109,11 +120,92 @@ public class AtlasClassificationType extends AtlasStructType {
}
}
/**
* This method processes the entityTypes to ensure they are valid, using the following principles:
* - entityTypes are supplied on the classificationDef to restrict the types of entities that this classification can be applied to
* - Any subtypes of the specified entity type can also have this classification applied
* - Any subtypes of the classificationDef inherit the parents entityTypes restrictions
* - Any subtypes of the classificationDef can further restrict the parents entityTypes restrictions
* - An empty entityTypes list when there are no parent restrictions means there are no restrictions
* - An empty entityTypes list when there are parent restrictions means that the subtype picks up the parents restrictions
*
* This method validates that these priniciples are adhered to.
*
* Note that if duplicate Strings in the entityTypes are specified on an add / update, the duplicates are ignored - as Java Sets cannot have duplicates.
* Note if an entityType is supplied in the list that is a subtype of one of the other supplied entityTypes, we are not policing this case as invalid.
// Compatible parents and entityTypes, now check whether the specified entityTypes are the same as the effective entityTypes due to our parents or a subset.