diff --git a/src/metax_api/api/rest/base/schemas/att_dataset_schema.json b/src/metax_api/api/rest/base/schemas/att_dataset_schema.json index 605b2db3..68af0689 100644 --- a/src/metax_api/api/rest/base/schemas/att_dataset_schema.json +++ b/src/metax_api/api/rest/base/schemas/att_dataset_schema.json @@ -57,6 +57,14 @@ "type":"object", "$ref":"#/definitions/Concept" }, + "event_outcome":{ + "@id":"http://uri.suomi.fi/datamodel/ns/mrd#eventOutcome", + "title":"Event outcome", + "description":"Outcome of the event", + "@type":"@id", + "type":"object", + "$ref":"#/definitions/Concept" + }, "used_entity":{ "@id":"http://www.w3.org/ns/prov#used", "title":"Used entity", diff --git a/src/metax_api/api/rest/base/schemas/harvester_dataset_schema.json b/src/metax_api/api/rest/base/schemas/harvester_dataset_schema.json index 2609db44..13a761d7 100644 --- a/src/metax_api/api/rest/base/schemas/harvester_dataset_schema.json +++ b/src/metax_api/api/rest/base/schemas/harvester_dataset_schema.json @@ -57,6 +57,14 @@ "type":"object", "$ref":"#/definitions/Concept" }, + "event_outcome":{ + "@id":"http://uri.suomi.fi/datamodel/ns/mrd#eventOutcome", + "title":"Event outcome", + "description":"Outcome of the event", + "@type":"@id", + "type":"object", + "$ref":"#/definitions/Concept" + }, "used_entity":{ "@id":"http://www.w3.org/ns/prov#used", "title":"Used entity", diff --git a/src/metax_api/api/rest/base/schemas/ida_dataset_schema.json b/src/metax_api/api/rest/base/schemas/ida_dataset_schema.json index f849cb6e..5bf46817 100644 --- a/src/metax_api/api/rest/base/schemas/ida_dataset_schema.json +++ b/src/metax_api/api/rest/base/schemas/ida_dataset_schema.json @@ -57,6 +57,14 @@ "type":"object", "$ref":"#/definitions/Concept" }, + "event_outcome":{ + "@id":"http://uri.suomi.fi/datamodel/ns/mrd#eventOutcome", + "title":"Event outcome", + "description":"Outcome of the event", + "@type":"@id", + "type":"object", + "$ref":"#/definitions/Concept" + }, "used_entity":{ "@id":"http://www.w3.org/ns/prov#used", "title":"Used entity", diff --git a/src/metax_api/services/catalog_record_service.py b/src/metax_api/services/catalog_record_service.py index 3cafc819..c10f3968 100644 --- a/src/metax_api/services/catalog_record_service.py +++ b/src/metax_api/services/catalog_record_service.py @@ -557,6 +557,13 @@ def validate_reference_data(cls, research_dataset, cache): if ref_entry: cls.populate_from_ref_data(ref_entry, activity['preservation_event'], label_field='pref_label') + if activity.get('event_outcome', False): + ref_entry = cls.check_ref_data(refdata['event_outcome'], + activity['event_outcome']['identifier'], + 'research_dataset.provenance.event_outcome.identifier', errors) + + if ref_entry: + cls.populate_from_ref_data(ref_entry, activity['event_outcome'], label_field='pref_label') for infra in research_dataset.get('infrastructure', []): ref_entry = cls.check_ref_data(refdata['research_infra'], infra['identifier'], 'research_dataset.infrastructure.identifier', errors) diff --git a/src/metax_api/tests/api/rest/base/views/datasets/write.py b/src/metax_api/tests/api/rest/base/views/datasets/write.py index b054063d..554722f8 100644 --- a/src/metax_api/tests/api/rest/base/views/datasets/write.py +++ b/src/metax_api/tests/api/rest/base/views/datasets/write.py @@ -903,10 +903,11 @@ def test_create_catalog_record_with_invalid_reference_data(self): rd_ida['relation'][0]['entity']['type']['identifier'] = 'nonexisting' rd_ida['provenance'][0]['lifecycle_event']['identifier'] = 'nonexisting' rd_ida['provenance'][1]['preservation_event']['identifier'] = 'nonexisting' + rd_ida['provenance'][0]['event_outcome']['identifier'] = 'nonexisting' response = self.client.post('/rest/datasets', self.cr_full_ida_test_data, format="json") self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) self.assertEqual('research_dataset' in response.data.keys(), True) - self.assertEqual(len(response.data['research_dataset']), 17) + self.assertEqual(len(response.data['research_dataset']), 18) rd_att = self.cr_full_att_test_data['research_dataset'] rd_att['remote_resources'][0]['checksum']['algorithm'] = 'nonexisting' @@ -988,7 +989,8 @@ def test_create_catalog_record_populate_fields_from_reference_data(self): 'funder_type', 'relation_type', 'lifecycle_event', - 'preservation_event' + 'preservation_event', + 'event_outcome' ] # the values in these selected entries will be used throghout the rest of the test case @@ -1034,6 +1036,7 @@ def test_create_catalog_record_populate_fields_from_reference_data(self): rd_ida['relation'][0]['entity']['type'] = {'identifier': refs['resource_type']['code']} rd_ida['provenance'][0]['lifecycle_event'] = {'identifier': refs['lifecycle_event']['code']} rd_ida['provenance'][1]['preservation_event'] = {'identifier': refs['preservation_event']['code']} + rd_ida['provenance'][0]['event_outcome'] = {'identifier': refs['event_outcome']['code']} # these have other required fields, so only update the identifier with code rd_ida['is_output_of'][0]['source_organization'][0]['identifier'] = refs['organization']['code'] @@ -1120,6 +1123,7 @@ def _assert_uri_copied_to_identifier(self, refs, new_rd): self.assertEqual(refs['resource_type']['uri'], new_rd['relation'][0]['entity']['type']['identifier']) self.assertEqual(refs['lifecycle_event']['uri'], new_rd['provenance'][0]['lifecycle_event']['identifier']) self.assertEqual(refs['preservation_event']['uri'], new_rd['provenance'][1]['preservation_event']['identifier']) + self.assertEqual(refs['event_outcome']['uri'], new_rd['provenance'][0]['event_outcome']['identifier']) def _assert_scheme_copied_to_in_scheme(self, refs, new_rd): self.assertEqual(refs['keyword']['scheme'], new_rd['theme'][0]['in_scheme']) @@ -1143,6 +1147,7 @@ def _assert_scheme_copied_to_in_scheme(self, refs, new_rd): self.assertEqual(refs['lifecycle_event']['scheme'], new_rd['provenance'][0]['lifecycle_event']['in_scheme']) self.assertEqual(refs['preservation_event']['scheme'], new_rd['provenance'][1]['preservation_event']['in_scheme']) + self.assertEqual(refs['event_outcome']['scheme'], new_rd['provenance'][0]['event_outcome']['in_scheme']) def _assert_label_copied_to_pref_label(self, refs, new_rd): self.assertEqual(refs['keyword']['label'], new_rd['theme'][0].get('pref_label', None)) @@ -1169,6 +1174,8 @@ def _assert_label_copied_to_pref_label(self, refs, new_rd): new_rd['provenance'][0]['lifecycle_event'].get('pref_label', None)) self.assertEqual(refs['preservation_event']['label'], new_rd['provenance'][1]['preservation_event'].get('pref_label', None)) + self.assertEqual(refs['event_outcome']['label'], + new_rd['provenance'][0]['event_outcome'].get('pref_label', None)) def _assert_label_copied_to_title(self, refs, new_rd): required_langs = dict((lang, val) for lang, val in refs['language']['label'].items() diff --git a/src/metax_api/tests/testdata/catalog_record_test_data_template_full_att.json b/src/metax_api/tests/testdata/catalog_record_test_data_template_full_att.json index 3ee87d53..5b381d0b 100644 --- a/src/metax_api/tests/testdata/catalog_record_test_data_template_full_att.json +++ b/src/metax_api/tests/testdata/catalog_record_test_data_template_full_att.json @@ -272,7 +272,10 @@ }, "representation": "http://uri.of.filetype.concept/scheme" } - ] + ], + "event_outcome": { + "identifier": "Success" + } }, { "title": { @@ -295,6 +298,9 @@ }, "preservation_event": { "identifier": "http://purl.org/att/reference_data/preservation_event/preservation_event_upd" + }, + "event_outcome": { + "identifier": "Failure" } } ], diff --git a/src/metax_api/tests/testdata/catalog_record_test_data_template_full_ida.json b/src/metax_api/tests/testdata/catalog_record_test_data_template_full_ida.json index 45041df6..3c6060cd 100644 --- a/src/metax_api/tests/testdata/catalog_record_test_data_template_full_ida.json +++ b/src/metax_api/tests/testdata/catalog_record_test_data_template_full_ida.json @@ -282,7 +282,10 @@ }, "representation": "http://uri.of.filetype.concept/scheme" } - ] + ], + "event_outcome": { + "identifier": "Success" + } }, { "title": { @@ -305,6 +308,9 @@ }, "preservation_event": { "identifier": "http://purl.org/att/reference_data/preservation_event/preservation_event_upd" + }, + "event_outcome": { + "identifier": "Failure" } } ], diff --git a/src/metax_api/tests/testdata/test_data.json b/src/metax_api/tests/testdata/test_data.json index f5effc2c..0b64dcc3 100644 --- a/src/metax_api/tests/testdata/test_data.json +++ b/src/metax_api/tests/testdata/test_data.json @@ -7100,6 +7100,9 @@ "description": { "en": "Description of provenance activity" }, + "event_outcome": { + "identifier": "Success" + }, "lifecycle_event": { "definition": { "en": "A statement or formal explanation of the meaning of a concept." @@ -7193,6 +7196,9 @@ "description": { "en": "Description of other provenance activity" }, + "event_outcome": { + "identifier": "Failure" + }, "preservation_event": { "identifier": "http://purl.org/att/reference_data/preservation_event/preservation_event_upd" }, @@ -7759,6 +7765,9 @@ "description": { "en": "Description of provenance activity" }, + "event_outcome": { + "identifier": "Success" + }, "lifecycle_event": { "definition": { "en": "A statement or formal explanation of the meaning of a concept." @@ -7852,6 +7861,9 @@ "description": { "en": "Description of other provenance activity" }, + "event_outcome": { + "identifier": "Failure" + }, "preservation_event": { "identifier": "http://purl.org/att/reference_data/preservation_event/preservation_event_upd" }, @@ -8510,6 +8522,9 @@ "description": { "en": "Description of provenance activity" }, + "event_outcome": { + "identifier": "Success" + }, "lifecycle_event": { "definition": { "en": "A statement or formal explanation of the meaning of a concept." @@ -8603,6 +8618,9 @@ "description": { "en": "Description of other provenance activity" }, + "event_outcome": { + "identifier": "Failure" + }, "preservation_event": { "identifier": "http://purl.org/att/reference_data/preservation_event/preservation_event_upd" }, @@ -10056,6 +10074,9 @@ "description": { "en": "Description of provenance activity" }, + "event_outcome": { + "identifier": "Success" + }, "lifecycle_event": { "definition": { "en": "A statement or formal explanation of the meaning of a concept." @@ -10149,6 +10170,9 @@ "description": { "en": "Description of other provenance activity" }, + "event_outcome": { + "identifier": "Failure" + }, "preservation_event": { "identifier": "http://purl.org/att/reference_data/preservation_event/preservation_event_upd" }, @@ -10724,6 +10748,9 @@ "description": { "en": "Description of provenance activity" }, + "event_outcome": { + "identifier": "Success" + }, "lifecycle_event": { "definition": { "en": "A statement or formal explanation of the meaning of a concept." @@ -10817,6 +10844,9 @@ "description": { "en": "Description of other provenance activity" }, + "event_outcome": { + "identifier": "Failure" + }, "preservation_event": { "identifier": "http://purl.org/att/reference_data/preservation_event/preservation_event_upd" }, @@ -11392,6 +11422,9 @@ "description": { "en": "Description of provenance activity" }, + "event_outcome": { + "identifier": "Success" + }, "lifecycle_event": { "definition": { "en": "A statement or formal explanation of the meaning of a concept." @@ -11485,6 +11518,9 @@ "description": { "en": "Description of other provenance activity" }, + "event_outcome": { + "identifier": "Failure" + }, "preservation_event": { "identifier": "http://purl.org/att/reference_data/preservation_event/preservation_event_upd" },