AbstractRepository module (ska_db_oda.persistence.domain.repository)
This module contains the AbstractRepository base class and the entity specific types.
- class ska_db_oda.persistence.domain.repository.AbstractRepository(bridge: RepositoryBridge[T, U])[source]
Generic repository that defines the interface for users to add and retrieve entities from the ODA.
It is expected to be extended as SBDefinitionRepository, SBInstanceRepository, etc.
- add(entity: T, user: str | None = None) T[source]
Stores the entity in the ODA.
The entity passed to this method will have its metadata validated and updated.
- Raises:
ValueError – if the validation of the sbd or its metadata fails
ODAError – if an error occurs while persisting the entity
- Returns:
the entity as it exists in the ODA, eg with updated metadata
- get(entity_id: U, version: U | None = None) T[source]
- Retrieves the latest version of the entity with the given id from the ODA.
- param entity_id:
entity_id of the entity
- param version:
version of the entity
- Raises:
NotFoundInODA – if the entity_id is not found in the repository
ODAError – if an error occurs while retrieving the entity
- get_relationship(entity_id: U, parent_entity: U, associated_entity: U) T[source]
Retrieves the entity data associated with the given parent entity ID from the ODA.
- Raises:
NotFoundInODA – if the sbd_id is not found in the repository
ODAError – if an error occurs while retrieving the SBD
- Parameters:
entity_id – entity id to be search.
parent_entity – primary entity name to be join.
associated_entity – secondary entity name to be join.
- query(qry_param: QueryParams) List[T][source]
Queries the latest version of the entity based on QueryParams class from the ODA and returns the corresponding entities
Returns an empty list if no entities in the repository match the parameters.
- Raises:
ValueError – if the qry_params are not supported
ODAError – if an error occurs while querying the entity
- class ska_db_oda.persistence.domain.repository.EntityRelationshipRepository(bridge: RepositoryBridge[T, U])[source]
Abstraction over persistent storage of Relational Entities
- class ska_db_oda.persistence.domain.repository.ExecutionBlockRepository(bridge: RepositoryBridge[T, U])[source]
Abstraction over persistent storage of OSOExecutionBlocks
- class ska_db_oda.persistence.domain.repository.ExecutionBlockStatusHistoryRepository(bridge: RepositoryBridge[T, U])[source]
Abstraction over persistent storage of ExecutionBlock
- class ska_db_oda.persistence.domain.repository.PanelDecisionRepository(bridge: RepositoryBridge[T, U])[source]
Abstraction over persistent storage of PanelDecisions
- class ska_db_oda.persistence.domain.repository.PanelRepository(bridge: RepositoryBridge[T, U])[source]
Abstraction over persistent storage of PM Panels
- class ska_db_oda.persistence.domain.repository.PanelReviewRepository(bridge: RepositoryBridge[T, U])[source]
Abstraction over persistent storage of PanelReviews
- class ska_db_oda.persistence.domain.repository.ProjectRepository(bridge: RepositoryBridge[T, U])[source]
Abstraction over persistent storage of Projects
- class ska_db_oda.persistence.domain.repository.ProjectStatusHistoryRepository(bridge: RepositoryBridge[T, U])[source]
Abstraction over persistent storage of Projects
- class ska_db_oda.persistence.domain.repository.ProposalAccessRepository(bridge: RepositoryBridge[T, U])[source]
Abstraction over persistent storage of Proposal Access
- class ska_db_oda.persistence.domain.repository.ProposalRepository(bridge: RepositoryBridge[T, U])[source]
Abstraction over persistent storage of Proposals
- class ska_db_oda.persistence.domain.repository.RepositoryBridge[source]
This class is the implementor of the Bridge pattern which decouples the persistence method from the Repository abstraction.
It is designed to be used as a composition within a repository and offers CRUD type methods.
- abstract create(entity: T) T[source]
Stores a new, versioned entity in the repository
- Raises:
ValueError – if the validation of the entity or its metadata fails
ODAError – if an error occurs while persisting the entity
- Returns:
the entity as it exists in the ODA
- abstract query(qry_params: QueryParams) List[U][source]
Queries the latest version of the entity based on QueryParams class from the ODA and returns the corresponding entity ID
Returns an empty list if no entities in the repository match the parameters.
- Raises:
QueryParameterError – if the qry_params are not supported
ODAError – if an error occurs while querying the entity
- abstract read(entity_id: U) T[source]
Retrieves the latest version of the entity with the given id from the ODA.
- Raises:
NotFoundInODA – if the sbd_id is not found in the repository
ODAError – if an error occurs while retrieving the SBD
- abstract read_relationship(entity_id: U, parent_entity: U, associated_entity: U) T[source]
Retrieves the entity data associated with the given parent entity ID from the ODA.
- Raises:
NotFoundInODA – if the sbd_id is not found in the repository
ODAError – if an error occurs while retrieving the SBD
- abstract update(entity: T) T[source]
Updates version 1 of the entity with the given entity ID in the repository, or creates version 1 if it doesn’t already exist.
- Raises:
ValueError – if the validation of the entity or its metadata fails
ODAError – if an error occurs while persisting the entity
- Returns:
the entity as it exists in the ODA
- class ska_db_oda.persistence.domain.repository.SBDefinitionRepository(bridge: RepositoryBridge[T, U])[source]
Abstraction over persistent storage of SBDefinitions
- class ska_db_oda.persistence.domain.repository.SBDefinitionStatusHistoryRepository(bridge: RepositoryBridge[T, U])[source]
Abstraction over persistent storage of SBDefinitions
- class ska_db_oda.persistence.domain.repository.SBInstanceRepository(bridge: RepositoryBridge[T, U])[source]
Abstraction over persistent storage of SBInstances
- class ska_db_oda.persistence.domain.repository.SBInstanceStatusHistoryRepository(bridge: RepositoryBridge[T, U])[source]
Abstraction over persistent storage of SBInstance