11from pymongo import MongoClient
22from dags .pipelines .pipeline_protocols import NoticePipelineOutput
33from ted_sws .core .model .notice import Notice , NoticeStatus
4+ from ted_sws .event_manager .services .log import log_notice_error
45
56
67def notice_normalisation_pipeline (notice : Notice , mongodb_client : MongoClient ) -> NoticePipelineOutput :
@@ -9,7 +10,7 @@ def notice_normalisation_pipeline(notice: Notice, mongodb_client: MongoClient) -
910 """
1011 from ted_sws .data_sampler .services .notice_xml_indexer import index_notice
1112 from ted_sws .notice_metadata_processor .services .metadata_normalizer import normalise_notice
12-
13+ notice . update_status_to ( new_status = NoticeStatus . RAW )
1314 indexed_notice = index_notice (notice = notice )
1415 normalised_notice = normalise_notice (notice = indexed_notice )
1516
@@ -26,10 +27,16 @@ def notice_transformation_pipeline(notice: Notice, mongodb_client: MongoClient)
2627 from ted_sws .notice_transformer .services .notice_transformer import transform_notice
2728 from ted_sws .notice_transformer .adapters .rml_mapper import RMLMapper
2829 from ted_sws .data_manager .adapters .mapping_suite_repository import MappingSuiteRepositoryMongoDB
29-
30+ notice . update_status_to ( new_status = NoticeStatus . NORMALISED_METADATA )
3031 mapping_suite_repository = MappingSuiteRepositoryMongoDB (mongodb_client = mongodb_client )
3132 result = notice_eligibility_checker (notice = notice , mapping_suite_repository = mapping_suite_repository )
3233 if not result :
34+ log_notice_error (
35+ message = f"This notice { notice .ted_id } is not eligible for transformation. Notice info: "
36+ f"form_number=[{ notice .normalised_metadata .form_number } ],"
37+ f" eform_subtype=[{ notice .normalised_metadata .eforms_subtype } ], "
38+ f"xsd_version=[{ notice .normalised_metadata .xsd_version } ]. Check mapping suites!" ,
39+ notice_id = notice .ted_id , domain_action = notice_transformation_pipeline .__name__ )
3340 return NoticePipelineOutput (notice = notice , processed = False )
3441 notice_id , mapping_suite_id = result
3542 # TODO: Implement XML preprocessing
@@ -50,18 +57,18 @@ def notice_validation_pipeline(notice: Notice, mongodb_client: MongoClient) -> N
5057 from ted_sws .notice_validator .services .xpath_coverage_runner import validate_xpath_coverage_notice
5158 from ted_sws .data_manager .adapters .mapping_suite_repository import MappingSuiteRepositoryMongoDB
5259 from ted_sws .event_manager .services .log import log_notice_info
53-
60+ notice . update_status_to ( new_status = NoticeStatus . DISTILLED )
5461 mapping_suite_id = notice .distilled_rdf_manifestation .mapping_suite_id
5562 mapping_suite_repository = MappingSuiteRepositoryMongoDB (mongodb_client = mongodb_client )
5663 mapping_suite = mapping_suite_repository .get (reference = mapping_suite_id )
5764 log_notice_info (message = "Validation :: XPATH coverage :: START" , notice_id = notice .ted_id )
5865 validate_xpath_coverage_notice (notice = notice , mapping_suite = mapping_suite , mongodb_client = mongodb_client )
5966 log_notice_info (message = "Validation :: XPATH coverage :: END" , notice_id = notice .ted_id )
6067 log_notice_info (message = "Validation :: SPARQL :: START" , notice_id = notice .ted_id )
61- validate_notice_with_sparql_suite (notice = notice , mapping_suite_package = mapping_suite )
68+ validate_notice_with_sparql_suite (notice = notice , mapping_suite_package = mapping_suite , execute_full_validation = False )
6269 log_notice_info (message = "Validation :: SPARQL :: END" , notice_id = notice .ted_id )
6370 log_notice_info (message = "Validation :: SHACL :: START" , notice_id = notice .ted_id )
64- validate_notice_with_shacl_suite (notice = notice , mapping_suite_package = mapping_suite )
71+ validate_notice_with_shacl_suite (notice = notice , mapping_suite_package = mapping_suite , execute_full_validation = False )
6572 log_notice_info (message = "Validation :: SHACL :: END" , notice_id = notice .ted_id )
6673 log_notice_info (message = "Validation :: Summary :: START" , notice_id = notice .ted_id )
6774 validation_summary_report_notice (notice = notice )
@@ -75,6 +82,7 @@ def notice_package_pipeline(notice: Notice, mongodb_client: MongoClient) -> Noti
7582 """
7683 from ted_sws .notice_packager .services .notice_packager import package_notice
7784
85+ notice .update_status_to (new_status = NoticeStatus .VALIDATED )
7886 # TODO: Implement notice package eligiblity
7987 notice .set_is_eligible_for_packaging (eligibility = True )
8088 packaged_notice = package_notice (notice = notice )
@@ -88,7 +96,7 @@ def notice_publish_pipeline(notice: Notice, mongodb_client: MongoClient) -> Noti
8896 from ted_sws .notice_publisher .services .notice_publisher import publish_notice , publish_notice_rdf_into_s3
8997 from ted_sws .event_manager .services .log import log_notice_error
9098 from ted_sws import config
91-
99+ notice . update_status_to ( new_status = NoticeStatus . PACKAGED )
92100 if config .S3_PUBLISH_ENABLED :
93101 published_into_s3 = publish_notice_rdf_into_s3 (notice = notice )
94102 if not published_into_s3 :
@@ -99,4 +107,5 @@ def notice_publish_pipeline(notice: Notice, mongodb_client: MongoClient) -> Noti
99107 if result :
100108 return NoticePipelineOutput (notice = notice )
101109 else :
110+ notice .set_is_eligible_for_publishing (eligibility = False )
102111 return NoticePipelineOutput (notice = notice , processed = False )
0 commit comments