API Documentation - DADO.Persistency.BaseTypes.DataObject
This class provides the basics for every business object that supports persistence. Most business objects can extend this class.
ID (String):
Every entity must have an ID. Since this can differ from Data layer to Data Layer on the business object model it's of type string.
Usually this is defined by the data layer after a "Save()" operation, but can be defined by the upper layers too. Once defined and the object is saved it cannot be changed anymore (an Exception is thrown if the user tries to change it)
DateTimeStamp (DateTime):
The Date/Time stamp of the object when it was saved last. Should be in Zulu time. It is used to track the object history and by Export/Import and Synchronization algorithms (an object with the same ID and DateTimeStamp must not be synchronized!).
ToString () As String:
Every object can be also represented as string (in the GUI, in reports, in error messages, etc.). Every class has its own system to be represented as string and no generic rules can be defined, even for very small objects defined by only a code and text (ES: A currency is represented textually with its ISO code while a CivilStatus by its text). The string representation if the class is localizable must be in the correct language.
Refresh ():
Since objects inheriting from DataObject can be persistable the data content of the object can be also refreshed from the persistence layer. Refresh reloads the data from the data source keeping the object reference.
Reset ():
Since the data content of the object can be changed during automation, this method allows to reset the initial status when the object was first loaded (but not the status from the persistence layer).
Validate ():
Every Data object to be correctly saved need to accomplish some rules. These rules are defined here. If the object doesn't accomplish these rules a validation exception will be thrown with a description of the reason.
Save ():
Makes the object persistent or updates its data content on the persistence layer.
DeletableCheck ():
Checks if the DataObject can be deleted. If not an exception is thrown with the description of the reason.
Delete ():
Deletes the object from the persistent layer. Of course as object reference is always available, so a clone could be created just by calling "Save()" after "Delete()"
GetChanges () As DataChanges:
Get a "DataChangeList" collection with all differences between current data status, initial data status and data-layer data status. Used exclusively for optimistic locking.
When developing your own business objects you can extend this base class, overwrite the "Validate()", "DeletableCheck()" and "ToString()" methods and add the data and business properties and methods of the object. All the rest will work automatically the correct way.
|