Class UniquenessCheckWithConditionConstraintOnTable

java.lang.Object
com.apgar.common.lib.constraint.BundledConstraint
com.apgar.common.lib.constraint.UniquenessCheckWithConditionConstraintOnTable
All Implemented Interfaces:
com.orchestranetworks.schema.ConstraintOnTable, com.orchestranetworks.schema.ConstraintOnTableWithRecordLevelCheck, com.orchestranetworks.schema.JavaBeanVersion

public class UniquenessCheckWithConditionConstraintOnTable extends BundledConstraint implements com.orchestranetworks.schema.ConstraintOnTableWithRecordLevelCheck
Constraint that checks for record uniqueness across the table it is defined on and based on the fields passed as input parameters in the data model.

The inputed fields should be separated by a ";" ex: field1;field2.

If the field is a primary key, it needs to be inserted in the "pks" element

The error message and/or information message created in the error.properties and text.properties files respectively will be displayed if the constraint is not verified.

  • error.properties to be: constraint.com.apgar.common.lib.constraint.UniquenessCheckWithConditionConstraintOnTable The combination of {pk1}, {field}, ..., and {field} has to be unique
  • text.properties: constraint.com.apgar.common.lib.constraint.constraint.UniquenessCheckWithConditionConstraintOnTable The combination of {pk1}, {field}, ..., and {field} has to be unique

The constraint is defined as follows under the table it will be applied to in the XSD.

 <xs:complexType name="SampleTable_Type">
     <xs:annotation>
         <xs:documentation xml:lang="en-US">
             <osd:label>Sample Table</osd:label>
         </xs:documentation>
         <xs:appinfo>
             <osd:otherFacets>
             <osd:constraint class="com.apgar.common.lib.constraint.UniquenessCheckWithConditionConstraintOnTable">
                 <pks>pk1;pk2</pks>
                 <fields>field1;field2</fields>
                 <predicate>activeIndicator = 'AC'; ...2</predicate>
                 <severity>severity</severity>
                 <endKeysProperty>tableName</endKeysProperty>
             </osd:constraint>
             </osd:otherFacets>
         </xs:appinfo>
     </xs:annotation>
 </xs:complexType>
 
Author:
APGAR Consulting
  • Constructor Details

    • UniquenessCheckWithConditionConstraintOnTable

      public UniquenessCheckWithConditionConstraintOnTable()
  • Method Details

    • checkTable

      public void checkTable(com.orchestranetworks.instance.ValueContextForValidationOnTable valueContextForValidation)
      Checks uniqueness across all records of the table based on the fields and predicate parameters
      Specified by:
      checkTable in interface com.orchestranetworks.schema.ConstraintOnTable
    • setup

      public void setup(com.orchestranetworks.schema.ConstraintContextOnTable context)
      Preliminary processing of fields from XSD so that they can be appended and included in the uniqueness check query
      Specified by:
      setup in interface com.orchestranetworks.schema.ConstraintOnTable
    • toUserDocumentation

      public String toUserDocumentation(Locale locale, com.orchestranetworks.instance.ValueContext arg1)
      Specified by:
      toUserDocumentation in interface com.orchestranetworks.schema.ConstraintOnTable
    • checkRecord

      public void checkRecord(com.orchestranetworks.instance.ValueContextForValidationOnRecord valueContextForValidation)
      Checks uniqueness of record and raise error in case of violation
      Specified by:
      checkRecord in interface com.orchestranetworks.schema.ConstraintOnTableWithRecordLevelCheck
    • getFields

      public String getFields()
      Gets fields which should be unique
      Returns:
      fields which should be unique
    • setFields

      public void setFields(String fields)
      Sets fields to be checked
      Parameters:
      fields - fields to be checked
    • getPredicate

      public String getPredicate()
      Gets the uniqueness predicate
      Returns:
      predicate as a String
    • setPredicate

      public void setPredicate(String predicate)
      Sets the uniqueness predicate
      Parameters:
      predicate - uniqueness predicate
    • getSeverity

      public com.onwbp.base.text.Severity getSeverity()
      Gets the error severity
      Returns:
      error severity
    • setSeverity

      public void setSeverity(String severity)
      Sets the error severity
      Parameters:
      severity - severity of the error to be raised
    • getEndKeysProperty

      public String getEndKeysProperty()
      Gets the endKeyProperty
      Returns:
      endKeyProperty endKeyProperty
    • setEndKeysProperty

      public void setEndKeysProperty(String endKeysProperty)
      Sets the endKeysProperty
      Parameters:
      endKeysProperty - endKeyProperty
    • getPks

      public String getPks()
      Gets the primary keys as a semi-colon separated String
      Returns:
      pks primary keys as a String
    • setPks

      public void setPks(String pks)
      Sets the primary keys
      Parameters:
      pks - primary keys
    • getFks

      public String getFks()
      Gets the foreign keys as a semi-colon separated String
      Returns:
      foreign keys as a String
    • setFks

      public void setFks(String fks)
      Sets the foreign keys
      Parameters:
      fks - foreign keys