Source code for ska_db_oda.repository.proposal

"""Repository classes for the proposal schema (proposals, panels, reviews, decisions, access)."""

from psycopg import Connection
from ska_oso_pdm import Panel, PanelDecision, PanelReview, Proposal, ProposalAccess

from ska_db_oda.postgres.mapping import (
    PanelDecisionMapping,
    PanelMapping,
    PanelReviewMapping,
    ProposalAccessMapping,
    ProposalMapping,
)
from ska_db_oda.postgres.postgres_persistence import PostgresPersistence
from ska_db_oda.repository.base import AbstractRepository


[docs] class ProposalRepository(AbstractRepository[Proposal, str]): """Abstraction over persistent storage of Proposals.""" def __init__(self, conn: Connection): super().__init__(conn) self.postgres = PostgresPersistence(postgres_mapping=ProposalMapping(), connection=conn)
[docs] class PanelRepository(AbstractRepository[Panel, str]): """Abstraction over persistent storage of PM Panels.""" def __init__(self, conn: Connection): super().__init__(conn) self.postgres = PostgresPersistence(postgres_mapping=PanelMapping(), connection=conn)
[docs] class PanelDecisionRepository(AbstractRepository[PanelDecision, str]): """Abstraction over persistent storage of PanelDecisions.""" def __init__(self, conn: Connection): super().__init__(conn) self.postgres = PostgresPersistence( postgres_mapping=PanelDecisionMapping(), connection=conn )
[docs] class PanelReviewRepository(AbstractRepository[PanelReview, str]): """Abstraction over persistent storage of PanelReviews.""" def __init__(self, conn: Connection): super().__init__(conn) self.postgres = PostgresPersistence(postgres_mapping=PanelReviewMapping(), connection=conn)
[docs] class ProposalAccessRepository(AbstractRepository[ProposalAccess, str]): """Abstraction over persistent storage of Proposal Access.""" def __init__(self, conn: Connection): super().__init__(conn) self.postgres = PostgresPersistence( postgres_mapping=ProposalAccessMapping(), connection=conn )