Skip to Main Content
Return to Navigation

Defining Validation

Use the Validation page (PSADSVALIDATION) to define the extension application class that will be used to validate the data in the data set definition.

Image: Data Set Validation page

This example illustrates the fields and controls on the Data Set Validation page. You can find definitions for the fields and controls later on this page.

Data Set Validation page

There are 2 types of validations that are supported for data sets:

This table describes when class methods are called.

Method

When Called

DoADSValidations

  • Compare from file

  • First pass of copy from file

OnPreCopyCompare

  • Compare from file

  • First pass of copy from file, prior to copy

OnPreUpdate

  • Compare from file

  • Second pass of copy from file, immediately prior to copying to the data base

OnPostCopy

After copy from file

Validation Flow for the Copy From File Process

The following steps are performed:

  1. DoADSValidations method is invoked.

  2. OnPreCopyCompare method is invoked.

  3. OnPreUpdate method is invoked.

Copy from file makes two passes through the data set instances in the file. The first pass calls the DoADSValidations and OnPreCopyCompare validation methods for each instance but does not copy any data to the database. If and only if the first pass has no errors, the second pass calls the OnPreUpdate validation method for each instance then copies the instance to the target database. If an error is detected in the second pass the copy is terminated but the transaction is not rolled back. As each object is copied, the Done flag for the project item is set to true, so the copy can be restarted without recopying the objects already copied

For additional details, see Submitting for Copy

Pass 1

  1. DoADSValidations method is invoked.

  2. OnPreCopyCompare method is invoked if there were no validation errors found in DoADSValidations.

Note: No data is copied in Pass 1.

Pass 2 (performed only if no validation errors were found in DoADSValidations or OnPreCopyCompare)

  1. OnPreUpdate method is called for each data set instance.

  2. If validation passes, the data set instance is copied to the target database. If the validation fails the current object is not copied and no additional objects are copied, however previously copied objects will still be copied.

  3. After all data set instances for each data set name have been copied, the OnPostCopy method is called passing the data set name and an array of item identifiers of the data set instances that were copied. The item identifiers are integers stored in the PSPROJBINDITEM project table for the current project and can be used to get the data keys set instances. The OnPostCopy method can be used to perform validations that require data from multiple tables that may not be present until the entire project has been copied. Any validation errors detected in this method would have already been copied to the data base, so it is best practice to use this method only in cases when necessary.

When OnPreCopyCompare and OnPreUpdate are invoked from the C++ layer they are passed the data set name and the current in-memory rowset representation of the data set instance currently being processed. The developer can use the PeopleCode rowset API to examine the content of the rowset.

These two methods are invoked once prior to compare and twice prior to copy. The OnPreCopyCompare method is intended to not change values of the rowset, but the OnPreUpdate can also transform data set values. It should not change the shape of the data: it should not add new fields or records or delete fields.