diff --git a/osf/metadata/osf_gathering.py b/osf/metadata/osf_gathering.py index 0234e98931e..23fe6ca1178 100644 --- a/osf/metadata/osf_gathering.py +++ b/osf/metadata/osf_gathering.py @@ -523,21 +523,24 @@ def gather_subjects(focus): def _subject_triples(dbsubject, *, child_ref=None, related_ref=None): - _subject_ref = rdflib.URIRef(dbsubject.absolute_api_v2_subject_url) - yield (DCTERMS.subject, _subject_ref) - yield (_subject_ref, RDF.type, SKOS.Concept) - yield (_subject_ref, SKOS.prefLabel, dbsubject.text) - yield from _subject_scheme_triples(dbsubject, _subject_ref) - if dbsubject.text != dbsubject.bepress_text: - yield (_subject_ref, SKOS.altLabel, dbsubject.bepress_text) - if child_ref is not None: - yield (child_ref, SKOS.broader, _subject_ref) - if related_ref is not None: - yield (related_ref, SKOS.related, _subject_ref) - if dbsubject.bepress_subject and (dbsubject != dbsubject.bepress_subject): - yield from _subject_triples(dbsubject.bepress_subject, related_ref=_subject_ref) - if dbsubject.parent and (dbsubject != dbsubject.parent): - yield from _subject_triples(dbsubject.parent, child_ref=_subject_ref) + _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) + yield (DCTERMS.subject, _subject_ref) + yield (_subject_ref, RDF.type, SKOS.Concept) + yield (_subject_ref, SKOS.prefLabel, dbsubject.text) + yield from _subject_scheme_triples(dbsubject, _subject_ref) + if _is_distinct_from_bepress: + yield from _subject_triples(dbsubject.bepress_subject, related_ref=_subject_ref) + if child_ref is not None: + yield (child_ref, SKOS.broader, _subject_ref) + if related_ref is not None: + yield (related_ref, SKOS.related, _subject_ref) + if dbsubject.parent and (dbsubject != dbsubject.parent): + yield from _subject_triples(dbsubject.parent, child_ref=_subject_ref) + else: # if the custom subject adds nothing of value, just include the bepress subject + yield from _subject_triples(dbsubject.bepress_subject, child_ref=child_ref, related_ref=related_ref) def _subject_scheme_triples(dbsubject, subject_ref): diff --git a/osf_tests/metadata/expected_metadata_files/preprint_basic.turtle b/osf_tests/metadata/expected_metadata_files/preprint_basic.turtle index 9d99fc43217..aa96cd911d2 100644 --- a/osf_tests/metadata/expected_metadata_files/preprint_basic.turtle +++ b/osf_tests/metadata/expected_metadata_files/preprint_basic.turtle @@ -51,7 +51,6 @@ owl:sameAs . a skos:Concept ; - skos:altLabel "wobbble" ; skos:broader ; skos:inScheme ; skos:prefLabel "wobble" ; @@ -77,7 +76,6 @@ dcterms:title "preprovi" . a skos:Concept ; - skos:altLabel "wibbble" ; skos:inScheme ; skos:prefLabel "wibble" ; skos:related . diff --git a/osf_tests/metadata/expected_metadata_files/preprint_full.turtle b/osf_tests/metadata/expected_metadata_files/preprint_full.turtle index 5cc372df4e2..37544e116bd 100644 --- a/osf_tests/metadata/expected_metadata_files/preprint_full.turtle +++ b/osf_tests/metadata/expected_metadata_files/preprint_full.turtle @@ -54,7 +54,6 @@ osf:hasFunding . a skos:Concept ; - skos:altLabel "wobbble" ; skos:broader ; skos:inScheme ; skos:prefLabel "wobble" ; @@ -91,7 +90,6 @@ dcterms:title "preprovi" . a skos:Concept ; - skos:altLabel "wibbble" ; skos:inScheme ; skos:prefLabel "wibble" ; skos:related . diff --git a/osf_tests/metadata/test_osf_gathering.py b/osf_tests/metadata/test_osf_gathering.py index 84d3084b243..4d328502204 100644 --- a/osf_tests/metadata/test_osf_gathering.py +++ b/osf_tests/metadata/test_osf_gathering.py @@ -394,8 +394,6 @@ def test_gather_subjects(self): (_child_iri, SKOS.prefLabel, Literal('Child')), (_customparent_iri, SKOS.prefLabel, Literal('Custom-parent')), (_customchild_iri, SKOS.prefLabel, Literal('Custom-child')), - (_customparent_iri, SKOS.altLabel, Literal('Parent')), - (_customchild_iri, SKOS.altLabel, Literal('Child')), (_child_iri, SKOS.broader, _parent_iri), (_customchild_iri, SKOS.broader, _customparent_iri), (_customchild_iri, SKOS.related, _child_iri),