repositories
oxytcmri.domain.ports.repositories
¶
This module defines repositories for the application, storing and retrieving entities.
Classes:
Name | Description |
---|---|
EntityNotFoundException |
Exception raised when an entity is not found in the repository. |
Repository |
Abstract base class for repositories. |
SubjectRepository |
|
MRIExamRepository |
Abstract base class for MRI repository. |
AtlasRepository |
Abstract base class for Atlas repository. |
CenterRepository |
Abstract base class for Center repository. |
RepositoriesRegistry |
Abstract base class for a registry responsible for managing the repositories in the application. |
Attributes:
Name | Type | Description |
---|---|---|
Entity |
|
|
EntityIdentifier |
|
Entity = TypeVar('Entity')
module-attribute
¶
EntityIdentifier = TypeVar('EntityIdentifier')
module-attribute
¶
EntityNotFoundException(entity_id, repository)
¶
Bases: Exception
Exception raised when an entity is not found in the repository.
Source code in oxytcmri/domain/ports/repositories.py
22 23 |
|
Repository
¶
Bases: ABC
, Generic[Entity, EntityIdentifier]
Abstract base class for repositories. Defines the interface for all repositories in the application.
Methods:
Name | Description |
---|---|
find_by_id |
Retrieve an entity by its ID. |
get_by_id |
Retrieve an entity by its ID. |
list_all |
List all entities in the repository. |
save |
Save an entity to the repository. |
save_list |
Save a list of entities to the repository. |
delete |
Delete an entity from the repository. |
find_by_id(entity_id)
abstractmethod
¶
Retrieve an entity by its ID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
entity_id
|
EntityIdentifier
|
The ID of the entity |
required |
Returns:
Type | Description |
---|---|
Entity
|
The entity object if found, otherwise None |
Source code in oxytcmri/domain/ports/repositories.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
|
get_by_id(entity_id)
¶
Retrieve an entity by its ID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
entity_id
|
EntityIdentifier
|
The ID of the entity |
required |
Returns:
Type | Description |
---|---|
Entity
|
The entity object |
Raises:
Type | Description |
---|---|
EntityNotFoundException
|
If the entity with the given ID does not exist |
Source code in oxytcmri/domain/ports/repositories.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
|
list_all()
abstractmethod
¶
List all entities in the repository.
Returns:
Type | Description |
---|---|
List[Entity]
|
List of all entities |
Source code in oxytcmri/domain/ports/repositories.py
72 73 74 75 76 77 78 79 80 81 |
|
save(entity)
abstractmethod
¶
Save an entity to the repository.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
entity
|
Entity
|
The entity to save |
required |
Source code in oxytcmri/domain/ports/repositories.py
83 84 85 86 87 88 89 90 91 92 |
|
save_list(entity_list)
¶
Save a list of entities to the repository.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
entity_list
|
List[Entity]
|
The list of entities to save |
required |
Source code in oxytcmri/domain/ports/repositories.py
94 95 96 97 98 99 100 101 102 103 104 |
|
delete(entity)
abstractmethod
¶
Delete an entity from the repository.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
entity
|
Entity
|
The entity to delete |
required |
Source code in oxytcmri/domain/ports/repositories.py
106 107 108 109 110 111 112 113 114 115 |
|
SubjectRepository
¶
Bases: Repository[Subject, SubjectId]
Methods:
Name | Description |
---|---|
find_subjects_by_center |
Find subjects for a given center, optionally filtered by type. |
find_subjects_by_center(center, subject_type=None)
abstractmethod
¶
Find subjects for a given center, optionally filtered by type.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
center
|
Center
|
The center to find subjects for |
required |
subject_type
|
Optional[SubjectType]
|
If provided, only return subjects of this type |
None
|
Returns:
Type | Description |
---|---|
List[Subject]
|
List of matching subjects |
Source code in oxytcmri/domain/ports/repositories.py
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
|
MRIExamRepository
¶
Bases: Repository[MRIExam, MRIExamId]
Abstract base class for MRI repository. Defines the interface for retrieving MRI exam data.
Methods:
Name | Description |
---|---|
get_exam_for_subject |
Retrieve the MRI exam for a specific subject. |
get_exam_for_subject(subject_id)
abstractmethod
¶
Retrieve the MRI exam for a specific subject.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
subject_id
|
SubjectId
|
The identifier of the subject |
required |
Returns:
Type | Description |
---|---|
MRIExam
|
The MRI exam for the subject |
Source code in oxytcmri/domain/ports/repositories.py
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
|
AtlasRepository
¶
Bases: Repository[Atlas, int]
, ABC
Abstract base class for Atlas repository. Defines the interface for retrieving atlas data.
CenterRepository
¶
RepositoriesRegistry
¶
Bases: ABC
Abstract base class for a registry responsible for managing the repositories in the application.
Methods:
Name | Description |
---|---|
get_repository |
Return the repository corresponding to the given entity type. |
list_all_repositories |
Return a list of all repositories in the registry. |
get_repository(entity_type)
abstractmethod
¶
Return the repository corresponding to the given entity type.
Source code in oxytcmri/domain/ports/repositories.py
178 179 180 |
|
list_all_repositories()
abstractmethod
¶
Return a list of all repositories in the registry.
Source code in oxytcmri/domain/ports/repositories.py
182 183 184 |
|