Skip to content
This repository has been archived by the owner on Sep 16, 2022. It is now read-only.

Commit

Permalink
Merge pull request #316 from CSCfi/CSCMETAX-413-add-event-outcome
Browse files Browse the repository at this point in the history
CSCMETAX-413: [ADD] event_outcome to dataset schemas, full test datas…
  • Loading branch information
hannu40k authored Aug 13, 2018
2 parents 0d0ac82 + 2fb378c commit 192ca09
Show file tree
Hide file tree
Showing 8 changed files with 90 additions and 4 deletions.
8 changes: 8 additions & 0 deletions src/metax_api/api/rest/base/schemas/att_dataset_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
8 changes: 8 additions & 0 deletions src/metax_api/api/rest/base/schemas/ida_dataset_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
7 changes: 7 additions & 0 deletions src/metax_api/services/catalog_record_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 9 additions & 2 deletions src/metax_api/tests/api/rest/base/views/datasets/write.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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']
Expand Down Expand Up @@ -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'])
Expand All @@ -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))
Expand All @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,10 @@
},
"representation": "http://uri.of.filetype.concept/scheme"
}
]
],
"event_outcome": {
"identifier": "Success"
}
},
{
"title": {
Expand All @@ -295,6 +298,9 @@
},
"preservation_event": {
"identifier": "http://purl.org/att/reference_data/preservation_event/preservation_event_upd"
},
"event_outcome": {
"identifier": "Failure"
}
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,10 @@
},
"representation": "http://uri.of.filetype.concept/scheme"
}
]
],
"event_outcome": {
"identifier": "Success"
}
},
{
"title": {
Expand All @@ -305,6 +308,9 @@
},
"preservation_event": {
"identifier": "http://purl.org/att/reference_data/preservation_event/preservation_event_upd"
},
"event_outcome": {
"identifier": "Failure"
}
}
],
Expand Down
36 changes: 36 additions & 0 deletions src/metax_api/tests/testdata/test_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down Expand Up @@ -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"
},
Expand Down Expand Up @@ -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."
Expand Down Expand Up @@ -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"
},
Expand Down Expand Up @@ -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."
Expand Down Expand Up @@ -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"
},
Expand Down Expand Up @@ -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."
Expand Down Expand Up @@ -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"
},
Expand Down Expand Up @@ -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."
Expand Down Expand Up @@ -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"
},
Expand Down Expand Up @@ -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."
Expand Down Expand Up @@ -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"
},
Expand Down

0 comments on commit 192ca09

Please sign in to comment.