Package com.apgar.common.lib.constraint
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcheckRecord(com.orchestranetworks.instance.ValueContextForValidationOnRecord valueContextForValidation) Checks uniqueness of record and raise error in case of violationvoidcheckTable(com.orchestranetworks.instance.ValueContextForValidationOnTable valueContextForValidation) Checks uniqueness across all records of the table based on the fields and predicate parametersGets the endKeyPropertyGets fields which should be uniquegetFks()Gets the foreign keys as a semi-colon separated StringgetPks()Gets the primary keys as a semi-colon separated StringGets the uniqueness predicatecom.onwbp.base.text.SeverityGets the error severityvoidsetEndKeysProperty(String endKeysProperty) Sets the endKeysPropertyvoidSets fields to be checkedvoidSets the foreign keysvoidSets the primary keysvoidsetPredicate(String predicate) Sets the uniqueness predicatevoidsetSeverity(String severity) Sets the error severityvoidsetup(com.orchestranetworks.schema.ConstraintContextOnTable context) Preliminary processing of fields from XSD so that they can be appended and included in the uniqueness check querytoUserDocumentation(Locale locale, com.orchestranetworks.instance.ValueContext arg1) Methods inherited from class com.apgar.common.lib.constraint.BundledConstraint
createErrorUserMessage, createErrorUserMessage, createErrorUserMessage, createErrorUserMessage, createUserDocumentation, createUserDocumentation, createUserDocumentation, createUserDocumentation, getDocumentationBundleBaseName, getErrorBundleBaseName, getPropertiesBaseKeyMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.orchestranetworks.schema.JavaBeanVersion
getBeanVersion
-
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:
checkTablein interfacecom.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:
setupin interfacecom.orchestranetworks.schema.ConstraintOnTable
-
toUserDocumentation
- Specified by:
toUserDocumentationin interfacecom.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:
checkRecordin interfacecom.orchestranetworks.schema.ConstraintOnTableWithRecordLevelCheck
-
getFields
Gets fields which should be unique- Returns:
- fields which should be unique
-
setFields
Sets fields to be checked- Parameters:
fields- fields to be checked
-
getPredicate
Gets the uniqueness predicate- Returns:
- predicate as a String
-
setPredicate
Sets the uniqueness predicate- Parameters:
predicate- uniqueness predicate
-
getSeverity
public com.onwbp.base.text.Severity getSeverity()Gets the error severity- Returns:
- error severity
-
setSeverity
Sets the error severity- Parameters:
severity- severity of the error to be raised
-
getEndKeysProperty
Gets the endKeyProperty- Returns:
- endKeyProperty endKeyProperty
-
setEndKeysProperty
Sets the endKeysProperty- Parameters:
endKeysProperty- endKeyProperty
-
getPks
Gets the primary keys as a semi-colon separated String- Returns:
- pks primary keys as a String
-
setPks
Sets the primary keys- Parameters:
pks- primary keys
-
getFks
Gets the foreign keys as a semi-colon separated String- Returns:
- foreign keys as a String
-
setFks
Sets the foreign keys- Parameters:
fks- foreign keys
-