Application code scoping¶
Application code scoping maintains BUSONLINE_APPS_CODE, the lookup table that scopes MENU_PAGE records to a particular application via PAG.APPLICATION_CODE = APP.CODE. clsApplicationCode follows the standard BOF CRUD lifecycle; clsApplicationCodeCollection adds an active-only retrieval mode that treats a null ACTIVE_CODE as active by default.
| Field | Value |
|---|---|
| Operation ID | OP-MNU-05 |
| Trigger | Caller requests clsApplicationCode/clsApplicationCodeCollection by key, active-only, or in full, or calls Save() after Create()/retrieve |
| Inputs | Code (key lookup); Code, ApplicationPath (description), IsActive (insert/update) |
| Outputs | Populated clsApplicationCode/clsApplicationCodeCollection; on save, a persisted row or an error message on DML contention |
| Primary components | clsApplicationCode, clsApplicationCodeCollection |
| Entry point | Business\SAIF.Business.Menu\clsApplicationCode.vb |
Steps¶
- Retrieve a single application code.
clsApplicationCode.GetApplicationCodecreates aCriteriawith the requestedCodeand invokes the data portal;BeforeRetrievebinds:Codeand executesRetrieveSQL(SQL-012, BUSONLINE_APPS_CODE).AfterRetrievefills the object (Code,ApplicationPath, andIsActivederived fromNVL(ACTIVE_CODE,'Y')) and marks it old. - Retrieve active codes only.
clsApplicationCodeCollection.GetActiveApplicationCodessetsActiveOnly = Trueon the criteria;BeforeRetrievedetects this and executesRetrieveActiveSQL(SQL-013), which appendsWHERE NVL(ACTIVE_CODE, 'Y') = 'Y'— codes with a nullACTIVE_CODEare treated as active by default (BR-MNU-03). - Retrieve all codes.
clsApplicationCodeCollection.GetAllApplicationCodesleavesActiveOnlyfalse, soBeforeRetrieveexecutes the unfilteredRetrieveSQL(SQL-014) instead, returning both active and inactive codes. - Create a new application code.
clsApplicationCode.NewApplicationCodecallsCreate(), which setsm_Code = MyCriteria.Codedirectly — no sequence generation, sinceCodeis a caller-supplied natural key.* - Save (insert) the code.
BeforeInsertbindsCode(max length 5),ApplicationPath(max length 65), andIsActiveconverted to aY/Nstring, then executesInsertSQL(SQL-005, BUSONLINE_APPS_CODE). - On success (
RowsAffected = 1):AfterInsertcallsMarkOld(). - On failure:
AddErrorMessage("InsertError", "Insert Failed")(BR-MNU-02). - Update the code's path or active flag.
BeforeUpdatebindsApplicationPath,IsActive, and the keyCode, then executesUpdateSQL(SQL-031, BUSONLINE_APPS_CODE).AfterUpdateapplies the row-count check, callingMarkOld()on success or addingUpdateErrorwithBOC.Messages.DBContentionErrorotherwise (BR-MNU-02). - Delete the code.
BeforeDeletebindsCodeand executesDeleteSQL(SQL-038, BUSONLINE_APPS_CODE).AfterDeletecallsMarkNew()on a rows-affected value of1, or adds aDeleteErrorotherwise (BR-MNU-02). - In-memory lookup by application path.
clsApplicationCodeCollection.ItemByAppPathfilters the already-loaded collection in memory (trimmed, upper-cased comparison) to resolve aclsApplicationCodeby its display path without a further database round trip. - Consume the scoping in menu rendering. The menu authorization data lookup operation's UNION queries join
BUSONLINE_APPS_CODEtoMENU_PAGEonAPP.CODE = PAG.APPLICATION_CODEto resolveApplicationPathfor display alongside each returned menu item.
Process flow¶
The following diagram visualizes the retrieve/save control flow for application codes, including the active-only filter.
flowchart TD
Start([Caller requests application code<br>by key, active, all, or new]) --> Which{Operation?}
Which -->|Retrieve by key| RetKey[Execute RetrieveSQL<br>with Code parameter]
Which -->|Retrieve active only| ActiveCheck[Execute RetrieveActiveSQL:<br>NVL ACTIVE_CODE,'Y' = 'Y']
Which -->|Retrieve all| RetAll[Execute unfiltered RetrieveSQL]
Which -->|Create new| Assign[Set Code from criteria<br>no sequence lookup]
Assign --> SaveCall{Save called?}
SaveCall -->|Yes| Insert[Execute InsertSQL]
Insert --> Rows{RowsAffected = 1?}
Rows -->|Yes| Ok([MarkOld])
Rows -->|No| Err([AddErrorMessage: InsertError])
Failure and edge-case behavior¶
- Every insert, update, and delete enforces a strict rows-affected-equals-1 check; any other value raises
InsertError,UpdateError, orDeleteErrorand the object is not marked clean (BR-MNU-02). - A null
ACTIVE_CODEis treated as active by default viaNVL(ACTIVE_CODE, 'Y')in both the single-object retrieve and the active-only collection retrieve, so an application code is active unless explicitly marked otherwise (BR-MNU-03). Codeis a caller-supplied natural key (no sequence), so two concurrent callers creating the sameCodewill conflict at the database's primary-key constraint rather than through this library's own logic.*- The
UpdateSQLtext has a typo in itsSETclause parameter name (:ApplicaitonPathinstead of:ApplicationPath); because ADO.NET binds parameters positionally rather than by name for this call, the misspelling does not affect execution, but it is a latent maintainability defect.*
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.Menu\clsApplicationCode.vbBusiness\SAIF.Business.Menu\clsApplicationCodeCollection.vb