AdsValidationBase Class Methods

In this section, the AdsValidationBase class methods are presented in alphabetical order.

Syntax

AdsValidationBase(project_name)

Description

This is the base class constructor supplied by Oracle. If the ADS definition does not specify an application class, this constructor will be automatically invoked when ADS projects are copied or compared. If the ADS definition does specify an application class, the constructor of the specified class will be automatically invoked when ADS projects are copied or compared. In the latter case, the derived class constructor must invoke this constructor as a %Super.

Parameters

Field or Control

Definition

project_name

Specifies the data migration project name as a string.

Returns

None.

Example

Use this methodology to instantiate a subclass to perform extended validations:

import PTADSDEFN:AdsValidationBase;

class ADSValidations1 implements PTADSDEFN:AdsValidationBase;
   method ADSValidations1(&ProjectName As string);
end-class;

/* constructor */

method ADSValidations1
   /+ &ProjectName as String +/
   %Super = create PTADSDEFN:AdsValidationBase(&ProjectName);
end-method;

Syntax

DoADSValidations(&ADS_rowset, ADS_name)

Description

In the base class supplied by Oracle, this method provides basic validation of static prompts, translate values, Y/N values, and required fields.

The base class method will be automatically invoked for each ADS instance when ADS projects are copied or compared unless the method is overridden in the derived application class for the current ADS definition. If the method is overridden, then the overriding method from the derived class will be automatically invoked. During copy, this method is called for all objects in the project before any objects are copied so that a single validation error anywhere in the project will prevent any objects from being copied.

When this method encounters a validation error, it invokes the ReportErrorModified method to store the error in the database so that it can be reviewed later on the Validation page.

Parameters

Field or Control

Definition

&ADS_rowset

Specifies the current ADS rowset instance as a rowset object. The rowset contains the data from the source project file.

ADS_name

Specifies the name of the current ADS definition as a string.

Returns

A Boolean value: True if all basic validations succeeded, False if any errors were encountered.

Example

import PTADSDEFN:AdsValidationBase;

class AdsValidationSample extends PTADSDEFN:AdsValidationBase
   method AdsValidationSample(&ProjectName As string);
   method DoADSValidations(&ADSRowset As Rowset, &ADSName As string,) Returns boolean;
   
end-class;

method AdsValidationSample
   /+ &ProjectName as String +/
   
   %Super = create PTADSDEFN:AdsValidationBase(&ProjectName);
   
end-method;

method DoADSValidations
   /+ &ADSRowset as Rowset, +/
   /+ &ADSName as String +/
   /+ Returns Boolean +/
   
   /* delegate to the base class DoADSValidations method */
   Return %Super.DoADSValidations(&ADSRowset, &ADSName);
   
end-method;

Syntax

OnPreCopyCompare(&ADS_rowset, ADS_name)

Description

This method will be automatically invoked for each ADS instance when ADS projects are copied or compared unless the method is overridden in the derived application class for the current ADS definition. If the method is overridden, then the overriding method from the derived class will be automatically invoked. During copy, this method is called for all objects in the project before any objects are copied so that a single validation error anywhere in the project will prevent any objects from being copied.

The definition of this method in the base class is an “empty implementation.”

If this method encounters a validation error, it should invoke the ReportErrorModified method to store the error in the database so that it can be reviewed later on the Validation page.

Parameters

Field or Control

Definition

&ADS_rowset

Specifies the current ADS rowset instance as a rowset object. The rowset contains the data from the source project file.

ADS_name

Specifies the name of the current ADS definition as a string.

Returns

A Boolean value: True if pre-copy compare validations succeeded, False if any errors were encountered.

Example

import PTADSDEFN:AdsValidationBase;

class AdsValidationSample extends PTADSDEFN:AdsValidationBase
   method AdsValidationSample(&ProjectName As string);
   method OnPreCopyCompare(&ADSRowset As Rowset, &ADSName As string,) Returns boolean;
   
end-class;

method AdsValidationSample
   /+ &ProjectName as String +/
   
   %Super = create PTADSDEFN:AdsValidationBase(&ProjectName);
   
end-method;

method OnPreCopyCompare
   /+ &ADSRowset as Rowset, +/
   /+ &ADSName as String +/
   /+ Returns Boolean +/
   
   /* place code to validate the input rowset here */
   
end-method;

Syntax

OnPreUpdate(&ADS_rowset, ADS_name)

Description

This method will be automatically invoked after all data in each distinct ADS name in the project has been copied.

The definition of this method in the base class is an “empty implementation.”

If this method encounters a validation error, it should invoke the ReportErrorModified method to store the error in the database so that it can be reviewed later on the Validation page.

If errors are detected by this method, subsequent data will not be copied, but any data already copied to the database will not be rolled back.

Parameters

Field or Control

Definition

&ADS_rowset

Specifies the current ADS rowset instance as a rowset object. The rowset contains the data from the source project file.

ADS_name

Specifies the name of the current ADS definition as a string.

Returns

A Boolean value: True if pre-copy compare validations succeeded, False if any errors were encountered.

Example

import PTADSDEFN:AdsValidationBase;

class AdsValidationSample extends PTADSDEFN:AdsValidationBase
   method AdsValidationSample(&ProjectName As string);
   method OnPreUpdate(&ADSRowset As Rowset, &ADSName As string,) Returns boolean;
   
end-class;

method AdsValidationSample
   /+ &ProjectName as String +/
   
   %Super = create PTADSDEFN:AdsValidationBase(&ProjectName);
   
end-method;

method OnPreUpdate
   /+ &ADSRowset as Rowset, +/
   /+ &ADSName as String +/
   /+ Returns Boolean +/
   
   /* place code to validate the input rowset here */
   
end-method;

Syntax

OnPostCopy(ADS_name, &content_list)

Description

This method will be automatically invoked for each ADS instance when ADS projects are copied or compared unless the method is overridden in the derived application class for the current ADS definition. If the method is overridden, then the overriding method from the derived class will be automatically invoked. During copy, this method is called for each object in the project immediately prior to copying the object to the database. This occurs only after OnPreCopyCompare has been called for all objects with no validation errors.

The definition of this method in the base class is an “empty implementation.”

This method should be used for validations that require SQL access to all the data that was in the project and in the target database simultaneously. If any errors are encountered and cleanup is required, updates can be performed by this method.

If this method encounters a validation error, it should invoke the ReportErrorModified method to store the error in the database so that it can be reviewed later on the Validation page.

In addition, the OnPreUpdate method can perform database updates. If severe errors are detected by this method, the current data set will not be copied and subsequent data sets will not be copied; however, any data sets already copied to the database will not be rolled back.

Parameters

Field or Control

Definition

ADS_name

Specifies the name of the current ADS definition as a string.

&content_list

Specifies an array of integers that identify the keys of the objects in the current project for the current ADS name.

To translate this array into the keys of objects, one can query the project definition tables in the target database as follows:

SELECT PTADSCONTENTID, SEQNBR, PTBINDSYMBOL, PTADSBINDEXPR 
     FROM PSPROJBINDITEM 
     WHERE PROJECTNAME = :1 AND PTADSNAME = :2 AND PTADSCONTENTID IN (:3, :4, ...)
     ORDER BY SEQNBR, PTADSCONTENTID"); 

The fields and bind variables are defined as follows:

  • :1 – The project name (which is stored in the AdsValidationBase property called strProjectName).

  • :2 – TheADS definition name.

  • :3, :4, ... – The integers in the &content_list array.

  • PTBINDSYMBOL – The ADS key name.

  • PTADSBINDEXPR – The ADS key value.

  • SEQNBR – The key sequence number.

The keys thus retrieved are the unique keys of the top-level record in the ADS definition. They are also keys, but generally not unique keys, of the child records in the ADS definition.

Once the keys are retrieved, you can use the rowset API to validate the data. The records in the rowset can be determined from the ADS definition with the following query:

SELECT RECNAME, PTPARENTRECNAME 
     FROM PSADSDEFNITEM 
     WHERE PTADSNAME = :1 

The fields and bind variables are defined as follows:

  • :1 – The ADS definition name.

  • RECNAME – The child record name.

  • PTPARENTRECNAME – The parent record name or blank when RECNAME is the root record.

Returns

A Boolean value: True if post-copy compare validations succeeded, False if any errors were encountered.

Example

import PTADSDEFN:AdsValidationBase;

class AdsValidationSample extends PTADSDEFN:AdsValidationBase
   method AdsValidationSample(&ProjectName As string);
   method OnPostCopy(&AdsName As string, &ContentList As array of integer) Returns boolean;
   
end-class;

method AdsValidationSample
   /+ &ProjectName as String +/
   %Super = create PTADSDEFN:AdsValidationBase(&ProjectName);
end-method;

method OnPostCopy
   /+ &AdsName As string +/
   /+ &ContentList As array of integer +/
   
   /* place code to validate the data just copied here */
   
end-method;

Syntax

ReportErrorModified(&recReportKey, &recReportError)

Description

Invoke the ReportErrorModified method to write validation errors to the database to be reviewed later on the Validation page.

Invocation of the ReportErrorModified method is optional and can be skipped if error reporting in the validation report is not a requirement for your custom validation.

Important! ReportErrorModified is a protected method and must not be extended in your custom application class.

Parameters

Field or Control

Definition

&recReportKey

Specifies a record based on the PSCOMPOBJKEY record definition.

&recReportError

Specifies a record based on the PSCOMPOBJERR record definition.

Returns

None.

Example

Example 1

The following pseudo-code excerpt demonstrates how to invoke the ReportErrorModified method:

Local Record &recReportKey, &recReportError, &recParent;

&recReportKey = CreateRecord(Record.PSCOMPOBJKEY);
&recReportError = CreateRecord(Record.PSCOMPOBJERR);

*** error processing ***

If * error type 1 *
/* Set error record field values */
   &recReportError.PTADSVALIDTYPE.Value = "*";
   ***
   Else
   If * error type 2 *
   /* Set error record field values */
      &recReportError.PTADSVALIDTYPE.Value = "*";
      ***
   End-If;
End-If;

ReportErrorModified(&recReportKey, &recReportError);

Example 2

The PTADSDEFN:AdsValidationBase:ProcessValidationError method provides a complete example of how to invoke ReportErrorModified:

method ProcessValidationError
   /+ &RecError as Record +/
   
   Local number &i, &j, &k, &m, &n, &p, &q, &r, &s, &u, &nCtr, &x, &nBegin;
   Local Field &fldError;
   Local Record &recReportKey, &recReportError, &recParent;
   Local string &strPTRecName, &strPTRecValue, &strKeyColName, &strKeyColValue, &strFieldType, &strType;
   Local Rowset &rsParent;
   Local array of string &arrRecHierarchy;
   Local %metadata:RecordDefn:RecordDefn_Manager &mgr = create %metadata:RecordDefn:RecordDefn_Manager();
   Local %metadata:Key &key;
   Local %metadata:RecordDefn:RecordDefn &defn;
   Local string &strTableName;
   
   &arrRecHierarchy = CreateArrayRept("", 0);
   
   &recReportKey = CreateRecord(Record.PSCOMPOBJKEY);
   &recReportError = CreateRecord(Record.PSCOMPOBJERR);
   
   &i = 1;
   &r = Value(&arrRecName [&arrRecName.Find(&RecError.Name)][2]);
   &q = 1;
   /* Logic to Populate the PTRECNAMEs and PTNUMKEYS */
   For &s = &r To 1 Step - 1
      &strPTRecName = "PTRECNAME" | String(&s);
      If &s = &r Then
         &strPTRecValue = &RecError.Name;
         &recParent = &RecError;
      Else
         &rsParent = &recParent.ParentRow.ParentRowset.ParentRowset;
         &strPTRecValue = &rsParent.DBRecordName;
         &recParent = &rsParent.GetRow(1).GetRecord(@("Record." | &strPTRecValue));
      End-If;
      &recReportKey.GetField(@("Field." | &strPTRecName)).Value = &strPTRecValue;
      &m = &arrRecName.Find(&strPTRecValue);
      &key = create %metadata:Key(Key:Class_Record, &strPTRecValue);
      &defn = &mgr.GetDefn(&key);
      &strTableName = &defn.TableName;
      &recReportKey.GetField(@("Field." | "PTTABLENAME" | String(&s))).Value = &strTableName;
      &recReportKey.GetField(@("Field." | "PTNUMKEYS" | String(&s))).Value = &arrKeyFieldNameType [&m].Len;
      &arrRecHierarchy.Push(&strPTRecValue);
   End-For;
   
   /* Logic to Populate the PTKEYCOLs and PTKEYTYPEs */
   For &u = &arrRecHierarchy.Len To 1 Step - 1
      &strPTRecValue = &arrRecHierarchy [&u];
      &m = &arrRecName.Find(&strPTRecValue);
      For &p = 1 To &arrKeyFieldNameType [&m].Len
         &strKeyColName = "PTKEYCOL" | String(&q);
         
         &strKeyColValue = &arrKeyFieldNameType [&m][&p][1];
         &strType = &arrKeyFieldNameType [&m][&p][2];
         Evaluate &strType
         When "CHAR"
            &strFieldType = "0";
            Break;
         When "LONGCHAR"
            &strFieldType = "1";
            Break;
         When "NUMBER"
            &strFieldType = "2";
            Break;
         When "SIGNEDNUMBER"
            &strFieldType = "3";
            Break;
         When "DATE"
            &strFieldType = "4";
            Break;
         When "TIME"
            &strFieldType = "5";
            Break;
         When "DATETIME"
            &strFieldType = "6";
            Break;
         When "IMAGE"
            &strFieldType = "8";
            Break;
         When "IMAGEREFERENCE"
            &strFieldType = "9";
            Break;
         End-Evaluate;
         &recReportKey.GetField(@("Field." | &strKeyColName)).Value = &strKeyColValue;
         &recReportKey.GetField(@("Field.PTKEYTYPE" | String(&q))).Value = &strFieldType;
         &q = &q + 1;
      End-For;
   End-For;
   
   /* Logic to Populate the PTKEYVALUEs */
   &nCtr = 0;
   For &u = &r To 1 Step - 1
      &nCtr = &nCtr + &recReportKey.GetField(@("Field.PTNUMKEYS" | String(&u))).Value;
   End-For;
   For &x = &r To 1 Step - 1
      &nBegin = &nCtr - (&recReportKey.GetField(@("Field.PTNUMKEYS" | String(&x))).Value) + 1;
      If &x = &r Then
         &recParent = &RecError;
      Else
         &rsParent = &recParent.ParentRow.ParentRowset.ParentRowset;
         &recParent = &rsParent.GetRow(1).GetRecord(@("Record." | &rsParent.DBRecordName));
      End-If;
      For &j = 1 To &recReportKey.GetField(@("Field.PTNUMKEYS" | String(&x))).Value
         If &x = &r Then
            &recReportKey.GetField(@("Field.PTKEYVALUE" | String(&nBegin))).Value = &RecError.GetField(@("Field." | &recReportKey.GetField(@("Field.PTKEYCOL" | String(&nBegin))).Value)).Value;
         Else
            &recReportKey.GetField(@("Field.PTKEYVALUE" | String(&nBegin))).Value = &recParent.GetField(@("Field." | &recReportKey.GetField(@("Field.PTKEYCOL" | String(&nBegin))).Value)).Value;
         End-If;
         &nBegin = &nBegin + 1;
         &nCtr = &nCtr - 1;
      End-For;
   End-For;
   
   /* Logic to actually populate the PSPRJVALIDERR main fields and then insert into the table */
   For &k = 1 To &RecError.FieldCount
      &fldError = &RecError.GetField(&k);
      If &fldError.EditError And
            &arrFieldNamesOfDynamicPrompts.Find(&fldError.Name) = 0 Then
         &recReportError.PTADSVALIDTYPE.Value = " ";
         &recReportError.PTPARAMETERVAL1.Value = " ";
         &recReportError.PTPARAMETERVAL2.Value = " ";
         &recReportError.PTPARAMETERVAL3.Value = " ";
         &recReportError.PTPARAMETERVAL4.Value = " ";
         &recReportError.MESSAGE_SET_NBR.Value = 0;
         &recReportError.MESSAGE_NBR.Value = 0;
         &recReportError.MESSAGE_TEXT_254.Value = " ";
         &recReportError.MESSAGE_TEXT_LONG.Value = " ";
         &recReportError.MSG_SEVERITY.Value = " ";
         If &fldError.IsEditTable Then
            &recReportError.PTADSVALIDTYPE.Value = "S";
            &recReportError.PTPARAMETERVAL1.Value = &RecError.Name;
            &recReportError.PTPARAMETERVAL2.Value = &fldError.Name;
            &recReportError.PTPARAMETERVAL3.Value = &fldError.Value;
            &recReportError.PTPARAMETERVAL4.Value = &fldError.PromptTableName;
            &recReportError.MESSAGE_SET_NBR.Value = "257";
            &recReportError.MESSAGE_NBR.Value = "501";
            &recReportError.MESSAGE_TEXT_254.Value = MsgGet(257, 501, "Message Not Found", &fldError.Value, &fldError.Name, &RecError.Name, &fldError.PromptTableName);
            &recReportError.MESSAGE_TEXT_LONG.Value = MsgGetExplainText(257, 501, "Message Not Found");
            &recReportError.MSG_SEVERITY.Value = "E";
            &bValidationError = True;
         Else
            If &fldError.IsEditXlat Then
               &recReportError.PTADSVALIDTYPE.Value = "X";
               &recReportError.PTPARAMETERVAL1.Value = &RecError.Name;
               &recReportError.PTPARAMETERVAL2.Value = &fldError.Name;
               &recReportError.PTPARAMETERVAL3.Value = &fldError.Value;
               &recReportError.MESSAGE_SET_NBR.Value = "257";
               &recReportError.MESSAGE_NBR.Value = "503";
               &recReportError.MESSAGE_TEXT_254.Value = MsgGet(257, 503, "Message Not Found", &fldError.Value, &fldError.Name, &RecError.Name);
               &recReportError.MESSAGE_TEXT_LONG.Value = MsgGetExplainText(257, 503, "Message Not Found");
               &recReportError.MSG_SEVERITY.Value = "E";
               &bValidationError = True;
            Else
               If &fldError.IsYesNo Then
                  &recReportError.PTADSVALIDTYPE.Value = "Y";
                  &recReportError.PTPARAMETERVAL1.Value = &RecError.Name;
                  &recReportError.PTPARAMETERVAL2.Value = &fldError.Name;
                  &recReportError.PTPARAMETERVAL3.Value = &fldError.Value;
                  &recReportError.MESSAGE_SET_NBR.Value = "257";
                  &recReportError.MESSAGE_NBR.Value = "504";
                  &recReportError.MESSAGE_TEXT_254.Value = MsgGet(257, 504, "Message Not Found", &fldError.Value, &fldError.Name, &RecError.Name);
                  &recReportError.MESSAGE_TEXT_LONG.Value = MsgGetExplainText(257, 504, "Message Not Found");
                  &recReportError.MSG_SEVERITY.Value = "E";
                  &bValidationError = True;
               Else
                  If &fldError.IsRequired Then
                     &recReportError.PTADSVALIDTYPE.Value = "R";
                     &recReportError.PTPARAMETERVAL1.Value = &RecError.Name;
                     &recReportError.PTPARAMETERVAL2.Value = &fldError.Name;
                     &recReportError.MESSAGE_SET_NBR.Value = "257";
                     &recReportError.MESSAGE_NBR.Value = "502";
                     &recReportError.MESSAGE_TEXT_254.Value = MsgGet(257, 502, "Message Not Found", &fldError.Name, &RecError.Name);
                     &recReportError.MESSAGE_TEXT_LONG.Value = MsgGetExplainText(257, 502, "Message Not Found");
                     &recReportError.MSG_SEVERITY.Value = "E";
                     &bValidationError = True;
                  Else
                  End-If;
               End-If;
            End-If;
         End-If;
         %This.ReportErrorModified(&recReportKey, &recReportError);
      End-If;
   End-For;
end-method;