---
title: SAIF.Framework.CodeGen architecture
summary: Architectural responsibilities, boundaries, and interaction patterns for the SAIF.Framework.CodeGen developer code-generation tool.
status: draft
owner: <owner>
last_reviewed: 2026-07-23
library: SAIF.Framework.CodeGen
reference_type: package
---

# SAIF.Framework.CodeGen architecture

`SAIF.Framework.CodeGen` is a narrow, single-purpose developer/code-generation tooling library. It reads Oracle "code table" reference data and emits VB.NET source-code text fragments (`Case` statements or `Enum` member lists) for a developer to paste into hand-written code. It does not participate in runtime business-object lifecycle, web request handling, or application-layer orchestration, and it bypasses the standard BOF business-object pattern by connecting directly to the Oracle data layer.

## Responsibilities
- Generate VB `Case` statement blocks from a code table's rows, for manual insertion into hand-written source code (`CreateCaseStatement`).
- Generate VB `Enum` member lists from a code table's rows (`CreateEnumStatement`).
- Establish and, when parameters change, re-establish a direct Oracle data-layer connection used solely to source code-table data for generation (`Connect`).
- Derive unique, legal VB identifier names from code-table row values (`GetEnumValue`).

## Component boundaries
- **`CodeTableMap` (public class)**: the sole public entry point of the library. Owns the connection lifecycle, SQL execution, and source-text generation. It is a standalone tooling class, not a `clsBusinessBase`/`clsBusinessCollectionBase` business object.
- **`CodeBlockType` (public enum)**: values `CaseStatement`, `EnumStatement`. Defined for external callers but not referenced by any live code in this library; its intended consumer is unknown*.
- **Oracle data layer boundary**: `CodeTableMap` directly instantiates `clsMSOracleDataLayer` (from `SAIF.Business`) and obtains an `IDataPortalInfo`, then issues a raw SQL query through `SqlHelper.ResultSetQuery` (from `saif.framework`). This is the library's only external system boundary.
- **No presentation, web, or WCF surface** exists in this library.

## Interaction model
- A caller constructs `CodeTableMap(dbUser, database)`, which invokes `Connect` to establish `m_dpi` (the Oracle data-portal handle).
- The caller then invokes `CreateCaseStatement` or `CreateEnumStatement`, supplying a table name, enum name, and generation options.
- Each of these public methods calls the private `GetResult(table)` helper, which builds `select code, code_descr from {table}` via `String.Format` and executes it through `SqlHelper.ResultSetQuery(m_dpi).Execute(sql)`, returning a `clsResultSet`.
- For each returned row, `GetEnumValue` derives a unique, legal VB identifier from the `code`/`code_descr` columns.
- The method accumulates and returns a generated source-text string; no output is written to disk or persisted — the caller is responsible for consuming the returned text.
- No callers of `CodeTableMap` were found anywhere in this repository. This library appears to be invoked interactively/manually (e.g., from a console or test harness) rather than as part of any runtime request pipeline**.

The following diagram shows the high-level component interactions between the caller, `CodeTableMap`, and the Oracle data layer.

```mermaid
flowchart TD
	A[Caller / developer tool] --> B[CodeTableMap]
	B --> C[clsMSOracleDataLayer<br>SAIF.Business]
	B --> D[SqlHelper.ResultSetQuery<br>saif.framework]
	D --> E[(Oracle code table)]
	B --> A
```

The following diagram shows the primary sequence for generating a source-code fragment from a code table.

```mermaid
sequenceDiagram
	participant Caller
	participant CodeTableMap
	participant DataLayer as clsMSOracleDataLayer / IDataPortalInfo
	participant Oracle as Oracle code table
	Caller->>CodeTableMap: New CodeTableMap(dbUser, database)
	CodeTableMap->>DataLayer: Connect (establish m_dpi)
	Caller->>CodeTableMap: CreateCaseStatement / CreateEnumStatement
	CodeTableMap->>DataLayer: GetResult(table)
	DataLayer->>Oracle: select code, code_descr from table
	Oracle-->>DataLayer: rows
	DataLayer-->>CodeTableMap: clsResultSet
	CodeTableMap-->>Caller: generated VB source text
```

## Design constraints
- Bypasses the standard BOF `clsBusinessBase`/`clsBusinessCollectionBase` + `IBusinessCriteria` pattern entirely; `CodeTableMap` has no nested `Criteria` class and exposes no `CreateSQL`/`RetrieveSQL`/`InsertSQL`/`UpdateSQL`/`DeleteSQL` properties.
- Table name is passed as a caller-supplied string and interpolated directly into SQL text via `String.Format`, not as a bound parameter; there is no fixed table literal anywhere in the source.
- Only a read (`SELECT`) operation is performed; the library has no write/insert/update/delete capability.
- Connection re-establishment is optimized: `Connect` only reconstructs `clsMSOracleDataLayer` when `dbUser` or `database` differ from the current connection.
- Targets `.NET Framework v3.5`, consistent with the surrounding legacy BOF codebase.
- No configuration-file-driven settings, security/authorization checks, or AD integration exist in this library; connection parameters are supplied entirely as constructor arguments.

## Related documentation
- [Index](index.md)
- [Overview](overview.md)
- [Dependencies](dependencies.md)
- [Operations and processes](operations-processes.md)
- [Business rules](business-rules.md)
- [Configuration](configuration.md)
- [Database tables](database-tables.md)
- [SQL catalog](sql/index.md)
- [API reference](api/index.md)

> **Note:** Statements marked with * were inferred from code structure, naming conventions, or
> contextual evidence where direct confirmation was not available in source artifacts. Statements
> marked with ** could not be confirmed; treat as unknown until verified.

## Sources
- SAIF.Framework.CodeGen\CodeTableMap.vb
- SAIF.Framework.CodeGen\SAIF.Framework.CodeGen.vbproj
