This commit is contained in:
2026-04-17 14:55:32 -04:00
commit bc3ac1d4c9
18017 changed files with 4371742 additions and 0 deletions

View File

@@ -0,0 +1,126 @@
---
source_files:
- DataPRO/Modules/SystemSettings/ISOSettings/Model/Enums.cs
- DataPRO/Modules/SystemSettings/ISOSettings/Model/ISOSettingsModel.cs
generated_at: "2026-04-16T04:42:28.425769+00:00"
model: "Qwen/Qwen3-Coder-Next-FP8"
schema_version: 1
sha256: "080376d61a35b88d"
---
# Model
## Documentation: ISOSettings Module
---
### 1. **Purpose**
This module manages system-wide configuration settings related to ISO code handling within the DataPRO test management system. It provides a centralized model (`ISOSettingsModel`) for reading, writing, and persisting user-configurable preferences that control how ISO codes, user codes, and related UI elements are displayed and enforced during test setup and execution. It also enforces business rules—such as requiring unique ISO codes or validating test object/position fields—and triggers re-evaluation of test completeness (`IsComplete`) when certain settings change, ensuring data integrity across test setups.
---
### 2. **Public Interface**
#### `class ISOSettingsModel : IISOSettingsModel`
> **Constructor**
> `public ISOSettingsModel(IEventAggregator eventAggregator)`
> Initializes the model with an `IEventAggregator` instance for publishing notifications (e.g., on save failure).
> *Note:* `IISOSettingsModel` interface is referenced but not defined in the provided source; assumed to be declared elsewhere.
> **`LoadData()`**
> `public IISOSettingsData LoadData()`
> Returns a new `ISOSettingsData` instance populated with the *current* values of the following properties:
> - `ISOViewMode`
> - `ShowISOStringBuilder`
> - `ShowChannelCodeLookupHelper`
> - `UseISOCodeFilterMapping`
> - `UniqueISOCodesRequired`
> - `ValidateTestObjectAndPosition`
> *Note:* Does *not* include `ShowISOCodes`, `ShowUserCodes`, or `ISOSupportLevel` in the returned data.
> **`SaveData(IISOSettingsData data)`**
> `public void SaveData(IISOSettingsData data)`
> Updates the models internal state from the provided `data` object (assumed to be of concrete type `ISOSettingsData`).
> - Updates `ShowISOCodes`, `ShowUserCodes`, `ISOViewMode`, `ShowISOStringBuilder`, `ShowChannelCodeLookupHelper`, `UseISOCodeFilterMapping`, `UniqueISOCodesRequired`, and `ValidateTestObjectAndPosition`.
> - If `UniqueISOCodesRequired` or `ValidateTestObjectAndPosition` changes value, calls `MarkAllTestsDirty()` to re-evaluate test completeness.
> - On exception, publishes a notification via `EventAggregator` with message and stack trace.
> - Sets `IsSaved = true` on success.
> **`OnPropertyChanged(string propertyName)`**
> `public void OnPropertyChanged(string propertyName)`
> Currently a no-op stub. Intended for `INotifyPropertyChanged` compliance but not implemented.
> **`IsSaved`**
> `public bool IsSaved { get; private set; }`
> Gets a flag indicating whether the last `SaveData` call succeeded.
> **`PropertyChanged`**
> `public event PropertyChangedEventHandler PropertyChanged;`
> Declared but unused (no raises observed in source).
#### **Public Properties (Read/Write via SettingsDB)**
All properties are backed by `SettingsDB.GetGlobalValue*` / `SetGlobalValue*` methods.
| Property | Type | Default | Description |
|---------|------|---------|-------------|
| `ISOSupportLevel` | `IsoSupportLevels` | `IsoSupportLevels.ISO_ONLY` | Controls overall ISO support behavior (e.g., ISO-only, transitional, non-ISO allowed). |
| `ShowISOCodes` | `bool` | `true` | Controls visibility of ISO codes in UI. |
| `ShowUserCodes` | `bool` | `false` | Controls visibility of user-defined codes in UI. |
| `ValidChannelCodes` | `bool` | — | Derived: `true` if *either* `ShowISOCodes` or `ShowUserCodes` is `true`. |
| `ISOViewMode` | `IsoViewMode` | — | Computed view mode based on `ShowISOCodes`/`ShowUserCodes`. Setter updates both flags accordingly. |
| `ShowISOStringBuilder` | `bool` | `true` | Controls visibility of the ISO string builder UI component. |
| `ShowChannelCodeLookupHelper` | `bool` | `true` | Controls visibility of the channel code lookup helper UI component. |
| `UseISOCodeFilterMapping` | `bool` | `true` | Enables/disables ISO code filter mapping logic. |
| `UniqueISOCodesRequired` | `bool` | `true` | Enforces uniqueness of ISO codes across test setups. |
| `AllowTransitional` | `bool` | `false` | Permits transitional (non-standard) ISO codes. |
| `AllowNonISO` | `bool` | `false` | Permits non-ISO codes. |
| `UseUserCodes` | `bool` | `false` | Enables use of user-defined codes (distinct from `ShowUserCodes`). |
| `ValidateTestObjectAndPosition` | `bool` | `false` | Enables validation of ISO test object/position fields against test setup rules. |
---
### 3. **Invariants**
- **Persistence**: All settings are persisted globally via `SettingsDB` using string keys derived from `Keys` enum values.
- **View Mode Consistency**: `ISOViewMode` is *derived* from `ShowISOCodes` and `ShowUserCodes`. Setting `ISOViewMode` *always* updates both underlying flags to match the requested view.
- **Dirty Test Re-evaluation**: Changing `UniqueISOCodesRequired` or `ValidateTestObjectAndPosition` triggers `MarkAllTestsDirty()`, which marks *all* test setups as incomplete/dirty to force re-validation of `IsComplete`.
- **Validation Scope**: `ValidateTestObjectAndPosition` only affects test setup validation logic (not runtime behavior), and its effect is conditional on being enabled at validation time.
- **Code Visibility**: `ValidChannelCodes` is a computed property and *must* equal `ShowISOCodes || ShowUserCodes` at all times.
---
### 4. **Dependencies**
#### **Internal Dependencies**
- **`DTS.Common.Settings.SettingsDB`**: Used for global setting persistence (`GetGlobalValue`, `SetGlobalValue`, `GetGlobalValueBool`, `SetGlobalValueBoolean`).
- **`DTS.Common.Events.IEventAggregator`**: Used to publish `RaiseNotification` events on save failure.
- **`DTS.Common.Enums.IsoSupportLevels`**, **`IsoViewMode`**: Enum types used for `ISOSupportLevel` and `ISOViewMode`.
- **`ISOSettingsData`**: Concrete implementation of `IISOSettingsData`, used in `LoadData()` and `SaveData()`.
- **`DbOperations.TestSetupsGet(...)` / `TestSetupsMarkIsCompleteIsDirty(...)`**: Used by `GetAllTests()` and `MarkTestDirty()` to enumerate and mark tests as dirty.
#### **External Dependencies**
- **Prism.Events**: For `IEventAggregator`.
- **System.ComponentModel**: For `INotifyPropertyChanged` interface (partially implemented).
- **System.Linq**: For `records.Any()`, `tests.Any()`.
#### **Depended Upon**
- `IISOSettingsModel` interface (not shown) is likely consumed by UI/view-layer components (e.g., settings view models or pages).
---
### 5. **Gotchas**
- **`LoadData()` omits key properties**: The returned `IISOSettingsData` does *not* include `ShowISOCodes`, `ShowUserCodes`, or `ISOSupportLevel`, despite these being core settings. This may cause data loss if `SaveData()` is called with such an incomplete object (though `SaveData()` explicitly casts to `ISOSettingsData`, implying the consumer is expected to populate all fields).
- **`ISOViewMode` setter is side-effectful**: Changing `ISOViewMode` *overwrites* `ShowISOCodes` and `ShowUserCodes` without preserving their prior values. This is non-intuitive if the caller expects `ISOViewMode` to be a derived-only property.
- **`MarkAllTestsDirty()` is expensive**: Iterates over *all* test setups in the database and marks each as dirty. This is triggered on *any* change to `UniqueISOCodesRequired` or `ValidateTestObjectAndPosition`, regardless of whether tests are currently complete or relevant.
- **No change notification**: `OnPropertyChanged` is a stub; UI bindings relying on `INotifyPropertyChanged` will not update automatically when settings change.
- **Hardcoded defaults**: Default values are defined as `const` fields (e.g., `ShowISOCodesDefault = true`) but are *not* used in `LoadData()`—only in property getters/setters. If `ISOSettingsData` is constructed externally, defaults may not be applied consistently.
- **Commented tech debt**: The `SaveData()` method includes comments referencing internal issue IDs (`#14215`, `#16235`, `#15457`) and notes about future optimization for selective test dirtying. This indicates known performance debt.
- **No validation in `SaveData()`**: The method casts `data` to `ISOSettingsData` without checking type safety (will throw `InvalidCastException` if misused). No validation of input values is performed.
---
*Documentation generated from provided source files. No external behavior or APIs inferred beyond what is explicitly present.*