Sample Business Entity with before-image support
- Last Updated: March 30, 2020
- 3 minute read
- OpenEdge
- Version 12.2
- Documentation
Following is a sample ABL Business Entity class (Customer) defined for a Data Object resource that has before-image support
(with all annotations removed). This class inherits from OpenEdge-defined abstract
class, OpenEdge.BusinessLogic.BusinessEntity, and calls
several of its methods to implement the Data Object. It thus uses the following public
methods to implement the standard Data Object CRUD and Submit operations on a ProDataSet
named dsCustomer:
-
Create —
CreatedsCustomer( ), which callsCreateData( )in the super class -
Read —
ReaddsCustomer( ), which callsReadData( )in the super class -
Update —
UpdatedsCustomer( ), which callsUpdateData( )in the super class -
Delete —
DeletedsCustomer( ), which callsDeletedData( )in the super class -
Submit —
SubmitdsCustomer( ), which callsSubmitData( )in the super class
In this case, the ProDataSet contains a single temp-table, ttCustomer,
with a before-table, bttCustomer, that is defined for the
Customer table in the sports2000 database. The
listing of the data model follows the class.
The class constructor first invokes the super class constructor to pass the handle of the
instance ProDataSet to the abstract class, which sets the protected
ProDataSet property defined in the class, then passes the required
data source handles and skip lists (one each in this case) by setting the protected
ProDataSource and SkipList properties that are
defined in the abstract class.
INPUT-OUTPUT DATASET
parameter replaces the dsCustomer data left over from
any prior operation. Also note that while the client JSDO invokes the Submit operation
on all changed records in the JSDO, the JSDO invokes any Create, Update, or Delete
operation on only one changed record at a time, similar to when a Data Object resource
is defined without before-image support. However, in this case (with before-image
support), before-image data is passed by the JSDO and processed for these single-record
operations as well.
|
All the public methods call the corresponding super class methods to manage the
business logic, such as calling ReadData( ) to parse
the filter string passed to the ReaddsCustomer( )
method and then fill dsCustomer with data accordingly.
Note that the inherited BusinessEntity class
provides alternative overloadings of the ReadData( )
method that you can call with different options to implement ReaddsCustomer( ) in the Business Entity. For more information, you can
obtain a listing of the installed OpenEdge.BusinessLogic.BusinessEntity class from the following ABL source
library:
|
Note that the inherited behavior of the public SubmitData( ) method is to process all record changes in the transaction
according to the same order defined for a default call to the saveChanges( ) method on the client JSDO without
using the Submit operation:
- Apply all record deletes
- Apply all record creates
- Apply all record updates
Also, you can add additional processing for the respective record changes. For example
following the call to a super class method, you might replace or modify the value of the
ERROR-STRING attribute returned on each changed record buffer based
on custom criteria. This attribute value is then available in the client JSDO as the
value of the _errorString property in each record object returned with
a record change error.
Customer class listed above is based on
the Business Entity generated for an Express Data Object using the Customer table.Following is the customer.i include file that provides the data model
for the Customer class.
|