Class TxnValidations
java.lang.Object
org.odpi.openmetadata.adapters.repositoryservices.xtdb.repositoryconnector.txnfn.TxnValidations
Common validations to use within transaction functions.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
classification
(String classificationName, String entityTypeName, String className, String methodName) Validate that a classification is valid for the entity.static void
classificationList
(clojure.lang.IPersistentMap instance, String entityTypeName, String className, String methodName) Validate that a classification is valid for the entity.static void
classificationProperties
(String classificationName, InstanceProperties classificationProperties, String className, String methodName) Validate that a classification is valid for the entity.static void
entityFromStore
(String guid, clojure.lang.IPersistentMap entity, String className, String methodName) Verify that an entity has been successfully retrieved from the repository and has valid contents.static void
instanceCanBeUpdated
(clojure.lang.IPersistentMap instance, String guid, String metadataCollectionId, String className, String methodName) Verify that a metadata instance can be updated by the metadataCollection.static void
instanceCanBeUpdated
(clojure.lang.IPersistentMap instance, String guid, String metadataCollectionId, String classificationName, String className, String methodName) Verify that a metadata instance can be updated by the metadataCollection.static void
instanceIsDeleted
(clojure.lang.IPersistentMap existing, String instanceGUID, String className, String methodName) Validates that the provided metadata instance is in a soft-deleted state.static void
instanceIsNotDeleted
(clojure.lang.IPersistentMap existing, String instanceGUID, String className, String methodName) Validates that the provided metadata instance is not in a deleted state.static void
instanceStatus
(Integer instanceStatus, TypeDef typeDef, String className, String methodName) Validates an instance status where null is permissible.static void
instanceType
(clojure.lang.IPersistentMap instance, String className, String methodName) Verify that the instance retrieved from the repository has a valid instance type.static void
nonProxyEntity
(clojure.lang.IPersistentMap existing, String entityGUID, String className, String methodName) Validates that the provided entity is not only an EntityProxy.static void
propertiesForType
(TypeDef typeDef, InstanceProperties properties, String className, String methodName) Validate that the properties for a metadata instance match its TypeDef.static void
relationshipEnds
(String entityOneGUID, String entityTwoGUID, clojure.lang.IPersistentMap entityOneProxy, clojure.lang.IPersistentMap entityTwoProxy, String typeDefGUID, String className, String methodName) Validate that the types of the two ends of a relationship match the relationship's TypeDef.static void
relationshipFromStore
(String guid, clojure.lang.IPersistentMap relationship, String className, String methodName) Verify that a relationship has been successfully retrieved from the repository and has valid contents.static void
requiredProperty
(String guid, String propertyName, Object propertyValue, String className, String methodName) Validates an instance status where null is not allowed.
-
Constructor Details
-
TxnValidations
public TxnValidations()
-
-
Method Details
-
entityFromStore
public static void entityFromStore(String guid, clojure.lang.IPersistentMap entity, String className, String methodName) throws RepositoryErrorException, EntityNotKnownException Verify that an entity has been successfully retrieved from the repository and has valid contents.- Parameters:
guid
- unique identifier used to retrieve the entityentity
- the retrieved entity (or null)className
- doing the validationmethodName
- method receiving the call- Throws:
EntityNotKnownException
- No entity foundRepositoryErrorException
- logic error in the repository corrupted instance
-
relationshipFromStore
public static void relationshipFromStore(String guid, clojure.lang.IPersistentMap relationship, String className, String methodName) throws RepositoryErrorException, RelationshipNotKnownException Verify that a relationship has been successfully retrieved from the repository and has valid contents.- Parameters:
guid
- unique identifier used to retrieve the entityrelationship
- the retrieved relationship (or null)className
- doing the validationmethodName
- method receiving the call- Throws:
RelationshipNotKnownException
- No relationship foundRepositoryErrorException
- logic error in the repository corrupted instance
-
classification
public static void classification(String classificationName, String entityTypeName, String className, String methodName) throws InvalidParameterException, ClassificationErrorException Validate that a classification is valid for the entity.- Parameters:
classificationName
- unique name for a classification typeentityTypeName
- name of entity typeclassName
- doing the validationmethodName
- method receiving the call- Throws:
InvalidParameterException
- classification name is nullClassificationErrorException
- the classification is invalid for this entity
-
instanceIsNotDeleted
public static void instanceIsNotDeleted(clojure.lang.IPersistentMap existing, String instanceGUID, String className, String methodName) throws InvalidParameterException Validates that the provided metadata instance is not in a deleted state.- Parameters:
existing
- metadata instanceinstanceGUID
- of the instanceclassName
- doing the validationmethodName
- doing the validation- Throws:
InvalidParameterException
- if the provided metadata instance is already in a deleted state
-
instanceIsDeleted
public static void instanceIsDeleted(clojure.lang.IPersistentMap existing, String instanceGUID, String className, String methodName) throws InvalidParameterException Validates that the provided metadata instance is in a soft-deleted state.- Parameters:
existing
- metadata instanceinstanceGUID
- of the instanceclassName
- doing the validationmethodName
- doing the validation- Throws:
InvalidParameterException
- if the provided metadata instance is not in a deleted state
-
nonProxyEntity
public static void nonProxyEntity(clojure.lang.IPersistentMap existing, String entityGUID, String className, String methodName) throws EntityNotKnownException Validates that the provided entity is not only an EntityProxy.- Parameters:
existing
- entity to checkentityGUID
- of the entityclassName
- doing the validationmethodName
- doing the validation- Throws:
EntityNotKnownException
- if the provided entity is only an EntityProxy
-
instanceCanBeUpdated
public static void instanceCanBeUpdated(clojure.lang.IPersistentMap instance, String guid, String metadataCollectionId, String className, String methodName) throws InvalidParameterException Verify that a metadata instance can be updated by the metadataCollection. The caller can update a metadata instance provided: the instance is locally homed (matching metadataCollectionId) OR the instance has instanceProvenanceType set to external and replicatedBy is set to the local metadataCollectionId. Any other combination suggests that this is either a reference copy of an instance from the local cohort or a reference copy of an external entity (and something else is responsible for its replication): in these cases we are not permitted to update the metadata instance and will instead throw an InvalidParameterException.- Parameters:
instance
- instance to validateguid
- unique identifier for the metadata instance being updatedmetadataCollectionId
- unique identifier for the metadata collectionclassName
- name of the calling classmethodName
- name of calling method- Throws:
InvalidParameterException
- the instance cannot be updated due to its status or metadataCollectionId
-
instanceCanBeUpdated
public static void instanceCanBeUpdated(clojure.lang.IPersistentMap instance, String guid, String metadataCollectionId, String classificationName, String className, String methodName) throws InvalidParameterException Verify that a metadata instance can be updated by the metadataCollection. The caller can update a metadata instance provided: the instance is locally homed (matching metadataCollectionId) OR the instance has instanceProvenanceType set to external and replicatedBy is set to the local metadataCollectionId. Any other combination suggests that this is either a reference copy of an instance from the local cohort or a reference copy of an external entity (and something else is responsible for its replication): in these cases we are not permitted to update the metadata instance and will instead throw an InvalidParameterException.- Parameters:
instance
- instance to validateguid
- unique identifier for the metadata instance being updatedmetadataCollectionId
- unique identifier for the metadata collectionclassificationName
- of the classification to be updated (or null if only the base instance)className
- name of the calling classmethodName
- name of calling method- Throws:
InvalidParameterException
- the instance cannot be updated due to its status or metadataCollectionId
-
requiredProperty
public static void requiredProperty(String guid, String propertyName, Object propertyValue, String className, String methodName) throws InvalidParameterException Validates an instance status where null is not allowed.- Parameters:
guid
- unique identifier for the metadata instance being updatedpropertyName
- name of the required propertypropertyValue
- value of the required propertyclassName
- class calledmethodName
- method called- Throws:
InvalidParameterException
- invalid parameter
-
instanceType
public static void instanceType(clojure.lang.IPersistentMap instance, String className, String methodName) throws RepositoryErrorException, IOException Verify that the instance retrieved from the repository has a valid instance type.- Parameters:
instance
- the retrieved instanceclassName
- calling classmethodName
- calling method- Throws:
RepositoryErrorException
- logic error in the repository corrupted instanceIOException
- on any error deserializing the type information
-
instanceStatus
public static void instanceStatus(Integer instanceStatus, TypeDef typeDef, String className, String methodName) throws StatusNotSupportedException Validates an instance status where null is permissible.- Parameters:
instanceStatus
- initial status valuetypeDef
- type of the instanceclassName
- calling classmethodName
- method called- Throws:
StatusNotSupportedException
- the initial status is invalid for this type
-
classificationProperties
public static void classificationProperties(String classificationName, InstanceProperties classificationProperties, String className, String methodName) throws PropertyErrorException, RepositoryErrorException Validate that a classification is valid for the entity.- Parameters:
classificationName
- unique name for a classification typeclassificationProperties
- properties to testclassName
- calling classmethodName
- method receiving the call- Throws:
PropertyErrorException
- classification name is nullRepositoryErrorException
- on any other error
-
classificationList
public static void classificationList(clojure.lang.IPersistentMap instance, String entityTypeName, String className, String methodName) throws InvalidParameterException, ClassificationErrorException, PropertyErrorException, RepositoryErrorException, IOException Validate that a classification is valid for the entity.- Parameters:
instance
- metadata instance with classificationsentityTypeName
- name of entity typeclassName
- calling classmethodName
- method receiving the call- Throws:
InvalidParameterException
- classification name is nullClassificationErrorException
- the classification is invalid for this entityPropertyErrorException
- the classification's properties are invalid for its typeIOException
- on any error deserializing valuesRepositoryErrorException
- on any other error
-
propertiesForType
public static void propertiesForType(TypeDef typeDef, InstanceProperties properties, String className, String methodName) throws RepositoryErrorException, PropertyErrorException Validate that the properties for a metadata instance match its TypeDef.- Parameters:
typeDef
- type information to validate againstproperties
- proposed properties for instanceclassName
- calling classmethodName
- method receiving the call- Throws:
PropertyErrorException
- invalid propertyRepositoryErrorException
- on any other error
-
relationshipEnds
public static void relationshipEnds(String entityOneGUID, String entityTwoGUID, clojure.lang.IPersistentMap entityOneProxy, clojure.lang.IPersistentMap entityTwoProxy, String typeDefGUID, String className, String methodName) throws InvalidParameterException, RepositoryErrorException Validate that the types of the two ends of a relationship match the relationship's TypeDef.- Parameters:
entityOneGUID
- unique identifier of end oneentityTwoGUID
- unique identifier of end twoentityOneProxy
- content of end oneentityTwoProxy
- content of end twotypeDefGUID
- typeDefGUID for the relationshipclassName
- of the calling classmethodName
- of the calling method- Throws:
InvalidParameterException
- types do not alignRepositoryErrorException
- on any other error
-