|
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
Specifies a constraint that is able to perform the validation
of a table as a whole. Compared to the Constraint interface that
performs the validation per individual record, this allows to optimize
the validation algorithm as a set-level operation.
The following examples present how to define constraints for some complex validation requirements. For each example, we define:
setup method;checkTable.
We want to ensure, inside a table T1, that for any group of records
having the same code value,
the sum of the values of the portion field is less than a fixed threshold.
T1.
code and portion nodes,
hence dependencies to both nodes must be declared on insert, delete and modify events.
XPath predicate.
The XPath predicate defined within the validation message represents the set
of records violating the constraint.
We want to ensure, inside a table T2 defining a
beginDate and endDate, that
for any group of records that have the same code
their time periods do not overlap.
T2.
code, beginDate
and endDate nodes, then dependencies to these three nodes must be declared.
list of records.
We want to ensure that two tables T3 and T4
contain records with the same primary keys. More precisely, we will consider
here that the table T3 is the "master" table;
consequently, the table T4 holds an error if it does not
define a record existing in T3, or if it defines a record
that does not exist in T3.
T4 (the one holding the validation messages).
T3 and T4;
consequently, dependencies to insertion and deletion events in both tables must be declared
(see addDependencyToInsertAndDelete).
XPath predicate.
In this case, the subject of the message will be a ValidationReportItemSubjectForAdaptation.
The constraint must be declared in an element defining an osd:table,
under the element xs:annotation/xs:appinfo/osd:otherFacets:
where<osd:constraint class="com.foo.MyTableConstraint" />
com.foo.MyTableConstraint is
the fully qualified name of the class implementing this interface.
It is also possible to set additional JavaBean properties:
where<osd:constraint class="com.foo.MyTableConstraint"> <param1>...</param1> <param2>...</param2> </osd:constraint>
param1 and param2 are JavaBean properties of the specified class.
For more information, read JavaBeans specification.
When the schema is loaded:
setParam1(...) and
setParam2(...));setup(ConstraintContextOnTable) is called on the new instance.In operational phase, the method checkTable(ValueContextForValidationOnTable)
is called each time the validation report about the table is requested, and
the table's validation state is not up-to-date (the up-to-date state depends on
the dependencies that have been specified in setup(ConstraintContextOnTable);
Constraint| Method Summary | |
void |
checkTable(ValueContextForValidationOnTable aContext)
This method must perform a check of the whole table specified by the context, and adds error messages as long as errors are detected. |
void |
setup(ConstraintContextOnTable aContext)
This method is called when the schema is loaded, for checking and preparing this instance. |
String |
toUserDocumentation(Locale userLocale,
ValueContext aContext)
Returns a final user documentation about this constraint. |
| Method Detail |
public void checkTable(ValueContextForValidationOnTable aContext)
As the whole table is checked, this provides the opportunity to implement an adequate "set-level" algorithm, for example by handling the records in a given order. For tables with large volumes of records, this can even be a requirement for getting a reasonable validation time.
For a single instance of this interface, this method may be called concurrently by several threads.
InvalidSchemaException - if some schema's dynamic condition prevents the execution of this method.public void setup(ConstraintContextOnTable aContext)
This method must also declare the dependencies of the constraint, if any, so that validation is notified when a value is updated. If no dependencies are declared, they are considered as unknown.
ConstraintContext.addDependencyToInsertAndDelete(SchemaNode),
ConstraintContext.addDependencyToInsertDeleteAndModify(SchemaNode)
public String toUserDocumentation(Locale userLocale,
ValueContext aContext)
throws InvalidSchemaException
The method can return null if the specified locale is not handled by
the current implementation. Indeed, the container is able to try several locales
for handling a partial internationalization of this method's implementation and/or
a mismatch between the locales declared by the associated module and the locales supported
by EBX.Platform. In such cases, locales are tried in the following order:
Session.getLocaleForSchemaNode(SchemaNode));module.xml;For a single instance of this interface, this method may be called concurrently by several threads.
InvalidSchemaException - if some schema's dynamic condition prevents the execution of this method.
|
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
(report a bug)
EBX.Platform 4.8.4 [0722]
Copyright Orchestra Networks 2000-2010. All rights reserved.