java.lang.Object
org.odpi.openmetadata.adapters.repositoryservices.xtdb.repositoryconnector.txnfn.TxnValidations

public class TxnValidations extends Object
Common validations to use within transaction functions.
  • 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 entity
      entity - the retrieved entity (or null)
      className - doing the validation
      methodName - method receiving the call
      Throws:
      EntityNotKnownException - No entity found
      RepositoryErrorException - 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 entity
      relationship - the retrieved relationship (or null)
      className - doing the validation
      methodName - method receiving the call
      Throws:
      RelationshipNotKnownException - No relationship found
      RepositoryErrorException - 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 type
      entityTypeName - name of entity type
      className - doing the validation
      methodName - method receiving the call
      Throws:
      InvalidParameterException - classification name is null
      ClassificationErrorException - 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 instance
      instanceGUID - of the instance
      className - doing the validation
      methodName - 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 instance
      instanceGUID - of the instance
      className - doing the validation
      methodName - 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 check
      entityGUID - of the entity
      className - doing the validation
      methodName - 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 validate
      guid - unique identifier for the metadata instance being updated
      metadataCollectionId - unique identifier for the metadata collection
      className - name of the calling class
      methodName - 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 validate
      guid - unique identifier for the metadata instance being updated
      metadataCollectionId - unique identifier for the metadata collection
      classificationName - of the classification to be updated (or null if only the base instance)
      className - name of the calling class
      methodName - 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 updated
      propertyName - name of the required property
      propertyValue - value of the required property
      className - class called
      methodName - 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 instance
      className - calling class
      methodName - calling method
      Throws:
      RepositoryErrorException - logic error in the repository corrupted instance
      IOException - 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 value
      typeDef - type of the instance
      className - calling class
      methodName - 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 type
      classificationProperties - properties to test
      className - calling class
      methodName - method receiving the call
      Throws:
      PropertyErrorException - classification name is null
      RepositoryErrorException - 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 classifications
      entityTypeName - name of entity type
      className - calling class
      methodName - method receiving the call
      Throws:
      InvalidParameterException - classification name is null
      ClassificationErrorException - the classification is invalid for this entity
      PropertyErrorException - the classification's properties are invalid for its type
      IOException - on any error deserializing values
      RepositoryErrorException - 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 against
      properties - proposed properties for instance
      className - calling class
      methodName - method receiving the call
      Throws:
      PropertyErrorException - invalid property
      RepositoryErrorException - 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 one
      entityTwoGUID - unique identifier of end two
      entityOneProxy - content of end one
      entityTwoProxy - content of end two
      typeDefGUID - typeDefGUID for the relationship
      className - of the calling class
      methodName - of the calling method
      Throws:
      InvalidParameterException - types do not align
      RepositoryErrorException - on any other error