Skip to content

Commit

Permalink
osf:storageRegion supplementary metadata [ENG-6186]
Browse files Browse the repository at this point in the history
  • Loading branch information
aaxelb committed Oct 18, 2024
1 parent 86a23e0 commit 6b97c40
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 2 deletions.
12 changes: 12 additions & 0 deletions osf/metadata/osf_gathering.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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'))
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
dcterms:format "img/png" ;
dcterms:modified "2123-05-04" ;
dcterms:requires <urn:checksum:sha-256::6ac3c336e4094835293a3fed8a4b5fedde1b5e2626d9838fed50693bba00af0e> ;
osf:storageRegion <http://localhost:8000/v2/regions/us/> ;
osf:versionNumber "1" .

<http://localhost:5000/w1ibb> a dcterms:Agent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
dcterms:format "img/png" ;
dcterms:modified "2123-05-04" ;
dcterms:requires <urn:checksum:sha-256::6ac3c336e4094835293a3fed8a4b5fedde1b5e2626d9838fed50693bba00af0e> ;
osf:storageRegion <http://localhost:8000/v2/regions/us/> ;
osf:versionNumber "1" .

<https://moneypockets.example/millions> a osf:FundingAward ;
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
# correctly empty (for now)
@prefix osf: <https://osf.io/vocab/2022/> .
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .

<http://localhost:5000/w4ibb> osf:storageRegion <http://localhost:8000/v2/regions/us/> .

<http://localhost:8000/v2/regions/us/> a osf:Region ;
skos:prefLabel "United States"@en .
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .

<http://localhost:5000/w2ibb> osf:hasOsfAddon <urn:osf.io:addons:gitlab> ;
osf:storageRegion <http://localhost:8000/v2/regions/us/> .

<urn:osf.io:addons:gitlab> a osf:AddonImplementation ;
dcterms:identifier "gitlab" ;
skos:prefLabel "GitLab" .

<http://localhost:8000/v2/regions/us/> a osf:Region ;
skos:prefLabel "United States"@en .
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
# correctly empty (for now)
@prefix osf: <https://osf.io/vocab/2022/> .
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .

<http://localhost:5000/w5ibb> osf:storageRegion <http://localhost:8000/v2/regions/us/> .

<http://localhost:8000/v2/regions/us/> a osf:Region ;
skos:prefLabel "United States"@en .

0 comments on commit 6b97c40

Please sign in to comment.