Menu categorization¶
Menu categorization maintains MENU_CATEGORY_CODE, the simple two-column lookup table (Code, Description) that clsMenuItem.MenuCategoryCode references to group menu items for display. clsMenuCategoryCode follows the standard BOF CRUD lifecycle with no child objects and no computed fields.
| Field | Value |
|---|---|
| Operation ID | OP-MNU-02 |
| Trigger | Caller requests clsMenuCategoryCode/clsMenuCategoryCodeCollection by key or in full, or calls Save() after Create()/retrieve |
| Inputs | Code (key lookup); Code, Description (insert/update) |
| Outputs | Populated clsMenuCategoryCode/clsMenuCategoryCodeCollection; on save, a persisted row or an error message on DML contention |
| Primary components | clsMenuCategoryCode, clsMenuCategoryCodeCollection |
| Entry point | Business\SAIF.Business.Menu\clsMenuCategoryCode.vb |
Steps¶
- Retrieve a single category code.
clsMenuCategoryCode.GetMenuCategoryCodecreates aCriteriawith the requestedCodeand invokes the data portal;BeforeRetrievebinds:Codeand executesRetrieveSQL(SQL-017, MENU_CATEGORY_CODE).AfterRetrievefills the object and marks it old. - Retrieve the full collection.
clsMenuCategoryCodeCollection.GetMenuCategoryCodesexecutes the unfilteredRetrieveSQL(SQL-018, MENU_CATEGORY_CODE) and loads oneclsMenuCategoryCodeper row. - Create a new category code.
clsMenuCategoryCode.NewMenuCategoryCodecallsCreate(), which simply setsm_Code = MyCriteria.Code— no sequence generation is involved becauseCodeis a caller-supplied natural key rather than a generated surrogate key.* - Save (insert) the code.
BeforeInsertbindsCode(max length 5) andDescription(max length 100) and executesInsertSQL(SQL-006, MENU_CATEGORY_CODE). - On success (
RowsAffected = 1):AfterInsertcallsMarkOld(). - On failure:
AddErrorMessage("InsertError", "Insert Failed")(BR-MNU-02). - Update the code's description.
BeforeUpdatebindsDescriptionand the keyCode, then executesUpdateSQL(SQL-032, MENU_CATEGORY_CODE).AfterUpdateapplies the row-count check, callingMarkOld()on success or addingUpdateErrorwithBOC.Messages.DBContentionErrorotherwise (BR-MNU-02). - Delete the code.
BeforeDeletebindsCodeand executesDeleteSQL(SQL-039, MENU_CATEGORY_CODE).AfterDeletecallsMarkNew()on a rows-affected value of1, or adds aDeleteErrorotherwise (BR-MNU-02). - Consume the classification.
clsMenuItem.MenuCategoryand the menu authorization data lookup UNION queries both join toMENU_CATEGORY_CODEonCodeto resolve a human-readable category description for display; this library does not enforce that everyclsMenuItem.MenuCategoryCodevalue has a matching row inMENU_CATEGORY_CODE— no foreign-key validation is performed in code.*
Process flow¶
The following diagram visualizes the retrieve/save control flow for category codes.
flowchart TD
Start([Caller requests category code<br>by key, all, or new]) --> Which{Operation?}
Which -->|Retrieve by key| RetKey[Execute RetrieveSQL<br>with Code parameter]
RetKey --> Fill[Fill object from reader;<br>MarkOld]
Which -->|Retrieve all| RetAll[Execute unfiltered RetrieveSQL]
RetAll --> FillEach[Load one object per row]
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). 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.*- No validation confirms a
clsMenuItem.MenuCategoryCodevalue has a matchingMENU_CATEGORY_CODE.CODErow before an item is saved; an orphaned category reference would surface only as a missing join result at query time, not as a save-time error.*
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\clsMenuCategoryCode.vbBusiness\SAIF.Business.Menu\clsMenuCategoryCodeCollection.vb