aeat.adapters.persistence.profile.modelos_work_units module

Encrypted SQL repository for the modelo work-unit catalogue.

WorkUnitCatalogueRepository persists WorkUnit records in a WorkUnitCatalogue at FINANCIAL SensitivityClass through SecureObjectRepository. The catalogue is serialised as a single Envelope-wrapped JSON payload keyed by a stable namespace and object key; the underlying column is encrypted so no plaintext work-unit metadata lands on disk.

This concrete repository is the persistence adapter behind the read-side WorkUnitCatalogueRepositoryProtocol. It lives in the persistence adapter (not in modelos) because its secure-object coupling is SQL/crypto-bound; the domain package owns only the typed WorkUnitCatalogue model and its pure catalogue mutators.

See also

_modelo_runtime

Bucket-id resolution and runtime secure-object factory shared by modelo persistence adapters.

WorkUnitCatalogue

Domain catalogue payload encrypted by this repository.

WorkUnitCatalogueRepositoryProtocol

Domain port this concrete persistence adapter implements.

MODELO_WORK_UNIT_CATALOGUE_NAMESPACE

Central namespace, sensitivity, schema-version, and singleton-key contract for these secure objects.

modelos_calculation

Sibling calculation-revision repository referenced by work-unit current and verification lifecycle state.

modelo

Application facade that creates, calculates, verifies, files, and exports work units from this catalogue.

class WorkUnitCatalogueRepository(*, bucket_id=None, objects=None)[source]

Bases: object

Repository over encrypted SQL-backed work-unit catalogue storage.

A single envelope-wrapped catalogue object holds every work unit. Loads return an empty catalogue when no object has been persisted yet (no separate “fresh install” path is needed). The WorkUnitCatalogue payload is wrapped in Envelope before the SecureObjectRepository persists it; this class is the concrete implementation behind WorkUnitCatalogueRepositoryProtocol.

Parameters:
property bucket_id: str | None

Return the profile bucket id when this repository resolved one.

exists()[source]

Return whether a work-unit catalogue object has been persisted.

Return type:

bool

load()[source]

Return the persisted catalogue or an empty catalogue if absent.

Return type:

WorkUnitCatalogue

Returns:

The deserialised WorkUnitCatalogue, or an empty instance when no object has been persisted yet.

Raises:

WorkUnitPersistenceError – When the persisted envelope’s classification or schema version disagrees with the consumer’s contract.

save(catalogue)[source]

Persist catalogue as the encrypted singleton object.

The on-disk database value is an encrypted Envelope BLOB at the SensitivityClass FINANCIAL classification.

Parameters:

catalogue (WorkUnitCatalogue) – The WorkUnitCatalogue to persist.

Return type:

None