Note: By now I already have an answer to most questions I pose here.
I'm still posting because
1. I'd like some sanity check of the way I'm approaching this
2. If valid, the answers I found might be useful for someone else.
We have some rules concerning Business entities
Examples
* some fields should be present in entity temp-tables
* some fields should not be present in entity temp-tables
* all uniquely indexed fields should be initial ?
* ...
We would like those checks done before saving a BE
We would like the ability to run the same checks in batch, possible through unit checks.
Similar to sonar lint rules we'd like a mechanism to mark rule violations as intentional.
e.g. field that should normally be present is left out intentionally
The rules would be mostly custom, although I can image there could be some rules that are generally accepted, e.g.temp-table should have a unique index.
Can we have some general provisions in the BED / BEDGM for this or should we write a custom plugin for that ? Currently, going for the custom plugin approach
If done by a custom plugin are there fields/tables in the bedgm data structure we can safely use to mark violations as intentional ? Can we use the *properties tables for that ?
Is there a save event that has a cancellable eventargs ? Currently, subscribing to BusinessEntityDatasetController:BeforeFileSave
Code fragments from our plugin.
method public void Startup (dataset for dsBusinessEntity bind,
poController as BusinessEntityDatasetController,
poForm as BusinessEntityDesignerForm,
poToolbar as UltraToolbarsManager):
this-object:Form = poForm .
this-object:Controller = poController .
if valid-object(this-object:Controller)
then this-object:Controller:BeforeFileSave:subscribe(this-object:BeforeFileSaveHandler).
/* trimmed */
end method .
method public void BeforeFileSaveHandler(caller as progress.lang.object, e AS CancelableFileEventArgs):
define variable hDs as handle no-undo.
hDs = dataset dsBusinessEntity:handle.
new be.cce.SmartTools.BusinessEntityDesigner.Validator.CceDesignValidation(DATASET-HANDLE hDs BIND):PerformChecks().
end method.
method public void Shutdown ():
if valid-object(this-object:Controller)
then this-object:Controller:BeforeFileSave:unsubscribe(this-object:BeforeFileSaveHandler).
this-object:Form = ?.
this-object:Controller = ?.
end method .