diff --git a/osf/metadata/osf_gathering.py b/osf/metadata/osf_gathering.py index 3b21f079aaed..56b1c17a896f 100644 --- a/osf/metadata/osf_gathering.py +++ b/osf/metadata/osf_gathering.py @@ -688,6 +688,8 @@ def _gather_fileversion(fileversion, fileversion_iri): version_sha256 = (fileversion.metadata or {}).get('sha256') if version_sha256: yield (fileversion_iri, DCTERMS.requires, checksum_iri('sha-256', version_sha256)) + if fileversion.region is not None: + yield (fileversion_iri, OSF.storageRegion, rdflib.URIRef(fileversion.region.absolute_api_v2_url)) @gather.er(OSF.contains) @@ -1132,3 +1134,13 @@ def gather_addons(focus): yield (_addon_ref, RDF.type, OSF.AddonImplementation) yield (_addon_ref, DCTERMS.identifier, _addon_settings.short_name) yield (_addon_ref, SKOS.prefLabel, _addon_settings.config.full_name) + + +@gather.er(OSF.storageRegion) +def gather_storage_region(focus): + _region = getattr(focus.dbmodel, 'osfstorage_region', None) + if _region is not None: + _region_ref = rdflib.URIRef(_region.absolute_api_v2_url) + yield (OSF.storageRegion, _region_ref) + yield (_region_ref, RDF.type, OSF.Region) + yield (_region_ref, SKOS.prefLabel, rdflib.Literal(_region.name, lang='en')) diff --git a/osf_tests/metadata/expected_metadata_files/file_basic.turtle b/osf_tests/metadata/expected_metadata_files/file_basic.turtle index 14a78c46c888..1df106c47f96 100644 --- a/osf_tests/metadata/expected_metadata_files/file_basic.turtle +++ b/osf_tests/metadata/expected_metadata_files/file_basic.turtle @@ -34,6 +34,7 @@ dcterms:format "img/png" ; dcterms:modified "2123-05-04" ; dcterms:requires ; + osf:storageRegion ; osf:versionNumber "1" . a dcterms:Agent, diff --git a/osf_tests/metadata/expected_metadata_files/file_full.turtle b/osf_tests/metadata/expected_metadata_files/file_full.turtle index 37dd3c537f0d..3c31ffcbf4b3 100644 --- a/osf_tests/metadata/expected_metadata_files/file_full.turtle +++ b/osf_tests/metadata/expected_metadata_files/file_full.turtle @@ -40,6 +40,7 @@ dcterms:format "img/png" ; dcterms:modified "2123-05-04" ; dcterms:requires ; + osf:storageRegion ; osf:versionNumber "1" . a osf:FundingAward ; diff --git a/osf_tests/metadata/expected_metadata_files/preprint_supplement.turtle b/osf_tests/metadata/expected_metadata_files/preprint_supplement.turtle index 662c197699de..c30205f27c9d 100644 --- a/osf_tests/metadata/expected_metadata_files/preprint_supplement.turtle +++ b/osf_tests/metadata/expected_metadata_files/preprint_supplement.turtle @@ -1 +1,7 @@ -# correctly empty (for now) +@prefix osf: . +@prefix skos: . + + osf:storageRegion . + + a osf:Region ; + skos:prefLabel "United States"@en . diff --git a/osf_tests/metadata/expected_metadata_files/project_supplement.turtle b/osf_tests/metadata/expected_metadata_files/project_supplement.turtle index e01335e2f214..41341cca00f1 100644 --- a/osf_tests/metadata/expected_metadata_files/project_supplement.turtle +++ b/osf_tests/metadata/expected_metadata_files/project_supplement.turtle @@ -3,7 +3,11 @@ @prefix skos: . osf:hasOsfAddon ; + osf:storageRegion . a osf:AddonImplementation ; dcterms:identifier "gitlab" ; skos:prefLabel "GitLab" . + + a osf:Region ; + skos:prefLabel "United States"@en . diff --git a/osf_tests/metadata/expected_metadata_files/registration_supplement.turtle b/osf_tests/metadata/expected_metadata_files/registration_supplement.turtle index 662c197699de..ac9d0d08673c 100644 --- a/osf_tests/metadata/expected_metadata_files/registration_supplement.turtle +++ b/osf_tests/metadata/expected_metadata_files/registration_supplement.turtle @@ -1 +1,7 @@ -# correctly empty (for now) +@prefix osf: . +@prefix skos: . + + osf:storageRegion . + + a osf:Region ; + skos:prefLabel "United States"@en .