4141
4242METADATA_PUBLICATION_DATE = "publication_date"
4343METADATA_DOCUMENT_SENT_DATE = "document_sent_date"
44- FILE_STORAGE_COLLECTION_NAME = "fs.files"
4544
4645
4746class NoticeRepositoryInFileSystem (NoticeRepositoryABC ):
@@ -200,20 +199,20 @@ def _write_lazy_fields(self, notice: Notice):
200199 if notice_field is not None :
201200 repository .add (notice .ted_id , notice_field )
202201
203- @staticmethod
204- def _create_notice_from_repository_result (notice_dict : dict ) -> Union [Notice , None ]:
202+ def _create_notice_from_repository_result (self , notice_dict : dict ) -> Union [Notice , None ]:
205203 """
206204 This method allows you to create a Notice from the dictionary extracted from the repository.
207205 :param notice_dict:
208206 :return:
209207 """
210208 if notice_dict :
211209 del notice_dict [MONGODB_COLLECTION_ID ]
212- notice_dict .pop (NOTICE_NORMALISED_METADATA )
210+ notice_dict .pop (NOTICE_NORMALISED_METADATA , None )
213211 remove_date_string_fields (data = notice_dict , date_field_name = NOTICE_CREATED_AT )
214212 notice_dict [NOTICE_CREATED_AT ] = notice_dict [NOTICE_CREATED_AT ].isoformat ()
215213 notice = Notice (** notice_dict )
216214 notice ._status = NoticeStatus [notice_dict [NOTICE_STATUS ]]
215+ notice .set_lazy_object_fields_loader (lazy_object_fields_loader = self )
217216 return notice
218217 return None
219218
@@ -225,7 +224,7 @@ def _create_dict_from_notice(notice: Notice) -> dict:
225224 :return:
226225 """
227226
228- notice_dict = notice .dict (include = [ NOTICE_TED_ID , NOTICE_STATUS , NOTICE_CREATED_AT ] )
227+ notice_dict = notice .dict (include = { NOTICE_TED_ID : True , NOTICE_STATUS : True , NOTICE_CREATED_AT : True } )
229228 notice_dict [MONGODB_COLLECTION_ID ] = notice_dict [NOTICE_TED_ID ]
230229 notice_dict [NOTICE_STATUS ] = str (notice_dict [NOTICE_STATUS ])
231230 notice_dict [NOTICE_CREATED_AT ] = datetime .fromisoformat (notice_dict [NOTICE_CREATED_AT ])
@@ -278,7 +277,7 @@ def get(self, reference) -> Optional[Notice]:
278277 """
279278 result_dict = self .collection .find_one ({MONGODB_COLLECTION_ID : reference })
280279 if result_dict is not None :
281- notice = NoticeRepository ._create_notice_from_repository_result (result_dict )
280+ notice = self ._create_notice_from_repository_result (result_dict )
282281 return notice
283282 return None
284283
@@ -289,7 +288,7 @@ def get_notices_by_status(self, notice_status: NoticeStatus) -> Iterator[Notice]
289288 :return:
290289 """
291290 for result_dict in self .collection .find ({NOTICE_STATUS : str (notice_status )}):
292- notice = NoticeRepository ._create_notice_from_repository_result (result_dict )
291+ notice = self ._create_notice_from_repository_result (result_dict )
293292 yield notice
294293
295294 def get_notice_ids_by_status (self , notice_status : NoticeStatus ) -> Iterator [str ]:
@@ -307,5 +306,5 @@ def list(self) -> Iterator[Notice]:
307306 :return: list of notices
308307 """
309308 for result_dict in self .collection .find ():
310- notice = NoticeRepository ._create_notice_from_repository_result (result_dict )
309+ notice = self ._create_notice_from_repository_result (result_dict )
311310 yield notice
0 commit comments