Skip to content

Commit

Permalink
use get_semantic_iri for subjects
Browse files Browse the repository at this point in the history
  • Loading branch information
aaxelb committed Jan 18, 2024
1 parent 965302e commit fdd5ae3
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 30 deletions.
2 changes: 1 addition & 1 deletion osf/metadata/osf_gathering.py
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ def _subject_triples(dbsubject, *, child_ref=None, related_ref=None):
_is_bepress = (not dbsubject.bepress_subject)
_is_distinct_from_bepress = (dbsubject.text != dbsubject.bepress_text)
if _is_bepress or _is_distinct_from_bepress:
_subject_ref = rdflib.URIRef(dbsubject.absolute_api_v2_subject_url)
_subject_ref = rdflib.URIRef(dbsubject.get_semantic_iri())
yield (DCTERMS.subject, _subject_ref)
yield (_subject_ref, RDF.type, SKOS.Concept)
yield (_subject_ref, SKOS.prefLabel, dbsubject.text)
Expand Down
24 changes: 12 additions & 12 deletions osf_tests/metadata/expected_metadata_files/preprint_basic.turtle
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
"https://doi.org/11.pp/FK2osf.io/w4ibb" ;
dcterms:modified "2123-05-04" ;
dcterms:publisher <http://localhost:5000/preprints/preprovi> ;
dcterms:subject <http://localhost:8000/v2/subjects/subjwibb/>,
<http://localhost:8000/v2/subjects/subjwibbb/>,
<http://localhost:8000/v2/subjects/subjwobb/>,
<http://localhost:8000/v2/subjects/subjwobbb/> ;
dcterms:subject <http://localhost:8000/v2/subjects/subjwibb>,
<http://localhost:8000/v2/subjects/subjwibbb>,
<http://localhost:8000/v2/subjects/subjwobb>,
<http://localhost:8000/v2/subjects/subjwobbb> ;
dcterms:title "this is a preprint title!" ;
dcterms:type <https://schema.datacite.org/meta/kernel-4.4/#Preprint> ;
owl:sameAs <https://doi.org/11.pp/FK2osf.io/w4ibb> ;
Expand Down Expand Up @@ -50,11 +50,11 @@
dcterms:title "this is a project title!" ;
owl:sameAs <https://doi.org/10.70102/FK2osf.io/w2ibb> .

<http://localhost:8000/v2/subjects/subjwobb/> a skos:Concept ;
skos:broader <http://localhost:8000/v2/subjects/subjwibb/> ;
<http://localhost:8000/v2/subjects/subjwobb> a skos:Concept ;
skos:broader <http://localhost:8000/v2/subjects/subjwibb> ;
skos:inScheme <http://localhost:8000/v2/providers/preprints/preprovi/subjects/> ;
skos:prefLabel "wobble" ;
skos:related <http://localhost:8000/v2/subjects/subjwobbb/> .
skos:related <http://localhost:8000/v2/subjects/subjwobbb> .

<https://cos.io/> a dcterms:Agent,
foaf:Organization ;
Expand All @@ -75,20 +75,20 @@
<http://localhost:8000/v2/providers/preprints/preprovi/subjects/> a skos:ConceptScheme ;
dcterms:title "preprovi" .

<http://localhost:8000/v2/subjects/subjwibb/> a skos:Concept ;
<http://localhost:8000/v2/subjects/subjwibb> a skos:Concept ;
skos:inScheme <http://localhost:8000/v2/providers/preprints/preprovi/subjects/> ;
skos:prefLabel "wibble" ;
skos:related <http://localhost:8000/v2/subjects/subjwibbb/> .
skos:related <http://localhost:8000/v2/subjects/subjwibbb> .

<http://localhost:8000/v2/subjects/subjwobbb/> a skos:Concept ;
skos:broader <http://localhost:8000/v2/subjects/subjwibbb/> ;
<http://localhost:8000/v2/subjects/subjwobbb> a skos:Concept ;
skos:broader <http://localhost:8000/v2/subjects/subjwibbb> ;
skos:inScheme <https://bepress.com/reference_guide_dc/disciplines/> ;
skos:prefLabel "wobbble" .

<https://bepress.com/reference_guide_dc/disciplines/> a skos:ConceptScheme ;
dcterms:title "bepress Digital Commons Three-Tiered Taxonomy" .

<http://localhost:8000/v2/subjects/subjwibbb/> a skos:Concept ;
<http://localhost:8000/v2/subjects/subjwibbb> a skos:Concept ;
skos:inScheme <https://bepress.com/reference_guide_dc/disciplines/> ;
skos:prefLabel "wibbble" .

24 changes: 12 additions & 12 deletions osf_tests/metadata/expected_metadata_files/preprint_full.turtle
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
"https://doi.org/11.pp/FK2osf.io/w4ibb" ;
dcterms:modified "2123-05-04" ;
dcterms:publisher <http://localhost:5000/preprints/preprovi> ;
dcterms:subject <http://localhost:8000/v2/subjects/subjwibb/>,
<http://localhost:8000/v2/subjects/subjwibbb/>,
<http://localhost:8000/v2/subjects/subjwobb/>,
<http://localhost:8000/v2/subjects/subjwobbb/> ;
dcterms:subject <http://localhost:8000/v2/subjects/subjwibb>,
<http://localhost:8000/v2/subjects/subjwibbb>,
<http://localhost:8000/v2/subjects/subjwobb>,
<http://localhost:8000/v2/subjects/subjwobbb> ;
dcterms:title "this is a preprint title!" ;
dcterms:type <https://schema.datacite.org/meta/kernel-4.4/#Preprint> ;
owl:sameAs <https://doi.org/11.pp/FK2osf.io/w4ibb> ;
Expand Down Expand Up @@ -53,11 +53,11 @@
osf:funder <https://doi.org/10.$$$$> ;
osf:hasFunding <https://moneypockets.example/millions> .

<http://localhost:8000/v2/subjects/subjwobb/> a skos:Concept ;
skos:broader <http://localhost:8000/v2/subjects/subjwibb/> ;
<http://localhost:8000/v2/subjects/subjwobb> a skos:Concept ;
skos:broader <http://localhost:8000/v2/subjects/subjwibb> ;
skos:inScheme <http://localhost:8000/v2/providers/preprints/preprovi/subjects/> ;
skos:prefLabel "wobble" ;
skos:related <http://localhost:8000/v2/subjects/subjwobbb/> .
skos:related <http://localhost:8000/v2/subjects/subjwobbb> .

<https://cos.io/> a dcterms:Agent,
foaf:Organization ;
Expand Down Expand Up @@ -89,13 +89,13 @@
<http://localhost:8000/v2/providers/preprints/preprovi/subjects/> a skos:ConceptScheme ;
dcterms:title "preprovi" .

<http://localhost:8000/v2/subjects/subjwibb/> a skos:Concept ;
<http://localhost:8000/v2/subjects/subjwibb> a skos:Concept ;
skos:inScheme <http://localhost:8000/v2/providers/preprints/preprovi/subjects/> ;
skos:prefLabel "wibble" ;
skos:related <http://localhost:8000/v2/subjects/subjwibbb/> .
skos:related <http://localhost:8000/v2/subjects/subjwibbb> .

<http://localhost:8000/v2/subjects/subjwobbb/> a skos:Concept ;
skos:broader <http://localhost:8000/v2/subjects/subjwibbb/> ;
<http://localhost:8000/v2/subjects/subjwobbb> a skos:Concept ;
skos:broader <http://localhost:8000/v2/subjects/subjwibbb> ;
skos:inScheme <https://bepress.com/reference_guide_dc/disciplines/> ;
skos:prefLabel "wobbble" .

Expand All @@ -106,7 +106,7 @@
dcterms:identifier "https://doi.org/10.$$$$" ;
foaf:name "Mx. Moneypockets" .

<http://localhost:8000/v2/subjects/subjwibbb/> a skos:Concept ;
<http://localhost:8000/v2/subjects/subjwibbb> a skos:Concept ;
skos:inScheme <https://bepress.com/reference_guide_dc/disciplines/> ;
skos:prefLabel "wibbble" .

10 changes: 5 additions & 5 deletions osf_tests/metadata/test_osf_gathering.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ def test_gather_subjects(self):
assert_triples(osf_gathering.gather_subjects(self.projectfocus), set())
_bloo_subject = factories.SubjectFactory(text='Bloomy', provider=_osf_provider)
self.project.set_subjects([[_bloo_subject._id]], auth=Auth(self.user__admin))
_bloo_iri = URIRef(_bloo_subject.absolute_api_v2_subject_url)
_bloo_iri = URIRef(_bloo_subject.get_semantic_iri())
_bepress_iri = rdflib.URIRef('https://bepress.com/reference_guide_dc/disciplines/')
assert_triples(osf_gathering.gather_subjects(self.projectfocus), {
(self.projectfocus.iri, DCTERMS.subject, _bloo_iri),
Expand All @@ -368,10 +368,10 @@ def test_gather_subjects(self):
[_customchild_subj._id, _customparent_subj._id],
[_bloo_subject._id],
], auth=Auth(self.user__admin))
_parent_iri = URIRef(_parent_subj.absolute_api_v2_subject_url)
_child_iri = URIRef(_child_subj.absolute_api_v2_subject_url)
_customparent_iri = URIRef(_customparent_subj.absolute_api_v2_subject_url)
_customchild_iri = URIRef(_customchild_subj.absolute_api_v2_subject_url)
_parent_iri = URIRef(_parent_subj.get_semantic_iri())
_child_iri = URIRef(_child_subj.get_semantic_iri())
_customparent_iri = URIRef(_customparent_subj.get_semantic_iri())
_customchild_iri = URIRef(_customchild_subj.get_semantic_iri())
_customtax_iri = URIRef(f'{self.registration.provider.absolute_api_v2_url}subjects/')
assert_triples(osf_gathering.gather_subjects(self.registrationfocus), {
(self.registrationfocus.iri, DCTERMS.subject, _bloo_iri),
Expand Down

0 comments on commit fdd5ae3

Please sign in to comment.