---
title: SAIF.Business.Tasks architecture
summary: Architectural responsibilities, boundaries, and interaction patterns for SAIF.Business.Tasks.
status: draft
owner: SAIF
last_reviewed: 2026-07-24
library: SAIF.Business.Tasks
reference_type: package
---

# SAIF.Business.Tasks architecture

SAIF.Business.Tasks sits between consuming task implementations and the BOF/Oracle data-access infrastructure. It does not define a concrete workflow of its own; instead, it provides the abstract task contract, lookup-code model, and persistence/query machinery that downstream task libraries extend.

## Responsibilities
- Provide the abstract entity/collection contract for task-centric business objects.
- Separate core task behavior from reference-code lookups and from Oracle package operations.
- Preserve BOF lifecycle conventions for validation, retrieval, save, delete, and purge behavior.

## Component boundaries
- `clsTask`, `clsTaskCollection`, `clsTaskContext`, and `clsTaskBusinessRules` form the reusable task core.
- `clsTaskActionCode`, `clsTaskCategoryCode`, `clsTaskPriorityCode`, and `clsTaskSourceCode` form the read-only reference-data layer.
- `pk82036_task` supplies single-task persistence and purge behavior behind BOF lifecycle methods.
- Concrete task implementations live outside this library and fill in the abstract members such as `ActionCode`, `SourceCode`, `Load(...)`, `PostFill()`, `CopyTo(...)`, `MarkCompleted()`, and `NewTask()`.

## Interaction model
- A consuming library subclasses `clsTask` and `clsTaskCollection` to define a typed task implementation.
- `clsTask` validation runs BOF-required-field checks and task-specific rule helpers before persistence.
- Single-task retrieve/insert/update/delete operations route through `pk82036_task` package calls.
- Collection retrieval builds a dynamic `SELECT` against `TASK` and materializes each row through the collection factory method.
- Lookup collections issue direct read-only SQL against the task code tables.

## Architecture diagram
The following diagram shows the major library components and their runtime dependencies.

```mermaid
flowchart TD
    Consumer[Concrete task library<br>or application] --> TaskCore[clsTask / clsTaskCollection]
    TaskCore --> Context[clsTaskContext]
    TaskCore --> Rules[clsTaskBusinessRules]
    TaskCore --> OraclePkg[pk82036_task package]
    TaskCore --> QuerySql[Dynamic TASK SELECT]
    TaskCore --> LookupLayer[Action / Category / Priority / Source lookup types]
    OraclePkg --> TaskTable[(TASK)]
    QuerySql --> TaskTable
    LookupLayer --> CodeTables[(TASK_*_CODE)]
```

## Sequence diagram
The following diagram shows the primary save/update interaction path.

```mermaid
sequenceDiagram
    participant Consumer
    participant Task as clsTask
    participant Rules as clsTaskBusinessRules
    participant Proc as pk82036_task
    participant Oracle
    Consumer->>Task: Save()
    Task->>Rules: Evaluate BOF and task rules
    Rules-->>Task: Validation outcome
    Task->>Proc: task_insert / task_update / task_delete
    Proc->>Oracle: Apply TASK row change
    Oracle-->>Proc: SQL%ROWCOUNT
    Proc-->>Task: RowsAffected
    Task-->>Consumer: Success or contention/error state
```

## Design constraints
- The library publishes an abstract task model; concrete task behavior depends on consuming subclasses outside this documentation set.
- All dependencies are package-based; the project has no `<ProjectReference>` entries.
- Collection retrieval mixes bind-variable filters with runtime string concatenation for some text/context filters, so query shape depends on the caller-supplied criteria.*
- The delete lifecycle performs a soft delete first; physical deletion is intentionally isolated to `Task_Purge`.

> **Note:** Statements marked with `*` are inferred from code behavior rather than explicit documentation or comments.

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

## Sources
- `Business\SAIF.Business.Tasks\clsTask.vb`
- `Business\SAIF.Business.Tasks\clsTaskCollection.vb`
- `Business\SAIF.Business.Tasks\clsTaskContext.vb`
- `Business\SAIF.Business.Tasks\clsTaskBusinessRules.vb`
- `Business\SAIF.Business.Tasks\SAIF.BOF.Business.Tasks.vbproj`
