Claim authority save¶
Claim authority save persists whichever parts of the authority aggregate the caller changed: the employee's own grant authority level, the business function limit rows, and the category change limit rows. Before persisting, every dirty limit row is stamped with the acting (authorizing) employee's ID, and the object's aggregate IsValid — which rolls up the grant authority and both limit collections — governs whether callers should invoke Save() at all, mirroring the caller-checks-IsValid-first pattern used across the BOF business layer.
| Field | Value |
|---|---|
| Operation ID | OP-002 |
| Trigger | clsClaimAuthority.Save() (also invoked as SaveChild() when this object is saved as another object's child) |
| Inputs | Dirty state of GrantAuthority, BusinessFunctionLimits, CategoryChangeLimits; AuthorizingEmployee.ID from initialization; IsSecurityOverride flag |
| Outputs | Boolean success (ErrorCount = 0); persisted CL_CLAIM_EMP_AUTH_TYPE row; persisted business function and category change limit rows |
| Primary components | clsClaimAuthority.Save, clsClaimAuthority.SaveMe, clsClaimAuthority.IsValid, clsClaimAuthority.IsSecurityOverride |
| Entry point | Business\SAIF.Business.Claim.Authority\clsClaimAuthority.vb |
Steps¶
- Check whether anything changed.
SaveMe()returnsTrueimmediately ifIsDirtyis false —IsDirtyis true when the base object, the grant authority, the business function limits, or the category change limits report dirty. - Evaluate aggregate validity (caller responsibility).
IsValidrolls upMyBase.IsValid(which runs BR-001 — the subject employee record must be valid — and BR-002 — the requested grant authority level must not exceed the acting employee's own level) together withGrantAuthority.IsValid,BusinessFunctionLimits.IsValid, andCategoryChangeLimits.IsValid.Save()itself does not callIsValid; callers are expected to check it first.* IsSecurityOverridecan suppress the authority-level ceiling in BR-002 and the amount/approval-type checks used by the child limit rules (see Authorization amount and approval-type checks). The property setter itself enforces a rule: setting it toTruewhileAppGlobal.EnvironmentService.IsProductionis true is silently forced back toFalseinstead of taking effect (BR-012).- Stamp the authorizing employee on dirty limit rows. If
BusinessFunctionLimits.IsDirty, every dirty item in the collection hasAuthorizedByEmplidset to the acting employee's ID; the same stamping happens for every dirty item inCategoryChangeLimits. This runs unconditionally before any child save, even if the grant authority itself is unchanged. - Save the grant authority, if dirty.
SaveChildObject(GrantAuthority)dispatches toclsClaimEmpAuthType's CRUD lifecycle: - New row:
BeforeInsertbindsClaimAuthTypeCode,ClaimBusProcessCode,EmployeeEmplid, and the update user, then executes the insert (SQL-003, CL_CLAIM_EMP_AUTH_TYPE).- On a rows-affected value other than
1: add anInsertErrorwith message "Insert Failed".
- On a rows-affected value other than
- Existing row:
BeforeUpdatebinds the same fields plusUpdateNumand executes the update (SQL-018, CL_CLAIM_EMP_AUTH_TYPE).- On a rows-affected value other than
1: add anUpdateErrorwith the DB contention message.
- On a rows-affected value other than
- Deleted row (structurally supported but not exercised by any caller found in this library*):
BeforeDeletebinds the key and update number and executes the delete (SQL-021, CL_CLAIM_EMP_AUTH_TYPE).- On a rows-affected value other than
1: add aDeleteErrorwith the DB contention message.
- On a rows-affected value other than
- Save the business function limits, if dirty.
SaveChildObject(BusinessFunctionLimits)cascades through the collection's ownSave()(which callsApplyEdit()first) and each dirty item's insert/update/delete lifecycle. See Business function limit maintenance for the full per-row detail and rule citations. - Save the category change limits, if dirty.
SaveChildObject(CategoryChangeLimits)cascades the same way. See Category change limit maintenance for the full per-row detail and rule citations. - Return the outcome.
SaveMe()returnsErrorCount = 0as the overall success indicator; bothSave()andSaveChild()return this same result.
Process flow¶
The following diagram visualizes the save cascade.
flowchart TD
Start([Caller calls Save]) --> Dirty{IsDirty?}
Dirty -->|No| NoOp([Return True; nothing to do])
Dirty -->|Yes| Stamp[Stamp AuthorizedByEmplid<br>on dirty limit rows]
Stamp --> GrantDirty{GrantAuthority dirty?}
GrantDirty -->|Yes| SaveGrant[Insert / update / delete<br>CL_CLAIM_EMP_AUTH_TYPE]
GrantDirty -->|No| BizDirty
SaveGrant --> BizDirty{BusinessFunctionLimits dirty?}
BizDirty -->|Yes| SaveBiz[Cascade save to<br>business function limit rows]
BizDirty -->|No| CatDirty
SaveBiz --> CatDirty{CategoryChangeLimits dirty?}
CatDirty -->|Yes| SaveCat[Cascade save to<br>category change limit rows]
CatDirty -->|No| Done
SaveCat --> Done([Return ErrorCount = 0])
Failure and edge-case behavior¶
Save()never callsIsValiditself, so an invalid aggregate (for example, a grant authority that exceeds the acting employee's own level) can still reach the database if the caller skips theIsValidcheck.*- Optimistic concurrency failures on any child (grant authority, business function limit, or category change limit) surface as an added error message rather than a thrown exception;
SaveMe()still returns based on the aggregateErrorCount. - Production environments force
IsSecurityOverridetoFalseregardless of what the caller requests, so override behavior can only be exercised in non-production environments. - Because
AuthorizedByEmplidis stamped from the in-memoryAuthorizingEmployeeresolved during initialization, a save performed long after initialization (in a long-lived object) reflects the identity captured at load time, not necessarily the current caller.*
Related documentation¶
Note: Statements marked with
*were inferred from code structure, naming conventions, or contextual evidence where direct confirmation was not available in source artifacts.
Sources¶
Business\SAIF.Business.Claim.Authority\clsClaimAuthority.vbBusiness\SAIF.Business.Claim.Authority\clsClaimEmpAuthType.vb