AbstractRepository module (ska_db_oda.domain.repository)

This module contains the AbstractRepository base class and the entity specific types.

class ska_db_oda.domain.repository.AbstractRepository(bridge: RepositoryBridge[T, U])[source]

Generic repository that defines the interface for users to add and retrieve entities from the ODA. The implementation is passed at runtime (eg postgres, filesystem) and metadata updates are handled via the mixin class.

It is expected to be typed to SBDefinitionRepository, SBInstanceRepository, etc.

add(entity: T) 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

  • OSError – 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) T[source]

Retrieves the latest version of the entity with the given id from the ODA.

Raises:
  • KeyError – if the sbd_id is not found in the repository

  • OSError – if an error occurs while retrieving the SBD

query(qry_param: 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:
  • ValueError – if the qry_params are not supported

  • OSError – if an error occurs while querying the entity

class ska_db_oda.domain.repository.ExecutionBlockRepository(bridge: RepositoryBridge[T, U])[source]

Abstraction over persistent storage of ExecutionBlocks

class ska_db_oda.domain.repository.ProjectRepository(bridge: RepositoryBridge[T, U])[source]

Abstraction over persistent storage of Projects

class ska_db_oda.domain.repository.ProposalRepository(bridge: RepositoryBridge[T, U])[source]

Abstraction over persistent storage of Proposals

class ska_db_oda.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

  • OSError – 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:
  • ValueError – if the qry_params are not supported

  • OSError – 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:
  • KeyError – if the sbd_id is not found in the repository

  • OSError – 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

  • OSError – if an error occurs while persisting the entity

Returns:

the entity as it exists in the ODA

class ska_db_oda.domain.repository.SBDefinitionRepository(bridge: RepositoryBridge[T, U])[source]

Abstraction over persistent storage of SBDefinitions

class ska_db_oda.domain.repository.SBInstanceRepository(bridge: RepositoryBridge[T, U])[source]

Abstraction over persistent storage of SBInstances