Skip to content

Commit

Permalink
vge: add sources for OAI harvesting from RERO DOC
Browse files Browse the repository at this point in the history
* Adds four new sources for OAI records harvesting for VGE from RERO DOC.

Co-Authored-by: Sébastien Délèze <sebastien.deleze@rero.ch>
  • Loading branch information
Sébastien Délèze committed Jun 21, 2021
1 parent 9889cfc commit 0548ee1
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 20 deletions.
2 changes: 1 addition & 1 deletion data/oai_sources.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"url": "http://doc.rero.ch/oai2d",
"metadataprefix": "marcxml",
"comment": "",
"setspecs": "unisi unifr nl-epfl nl-ethz nl-fachhochschulen nl-lib4ri nl-unibas nl-unibe nl-unifr nl-unige nl-unil nl-unilu nl-unine nl-unisg nl-usi nl-uzh bge mhnge"
"setspecs": "unisi unifr nl-epfl nl-ethz nl-fachhochschulen nl-lib4ri nl-unibas nl-unibe nl-unifr nl-unige nl-unil nl-unilu nl-unine nl-unisg nl-usi nl-uzh bge mhnge baage bmuge imvge mhsge"
},
{
"key": "archive_ouverte_unige",
Expand Down
26 changes: 14 additions & 12 deletions sonar/modules/documents/dojson/rerodoc/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ def marc21_to_type_and_organisation(self, key, value):

# Specific transformation for `bpuge` and `mhnge`, because the real
# acronym is `vge`.
if organisation in ['bpuge', 'mhnge']:
if organisation in [
'bpuge', 'mhnge', 'baage', 'bmuge', 'imvge', 'mhsge'
]:
# Store section
self['sections'] = [organisation
] if organisation != 'bpuge' else ['bge']
Expand Down Expand Up @@ -615,17 +617,17 @@ def marc21_to_specific_collection(self, key, value):

# No collection found
if not collection_pid:
collection = CollectionRecord.create(
{
'name': [{
'language': 'eng',
'value': value.get('a')
}],
'organisation': {
'$ref': self['organisation'][0]['$ref']
},
'hashKey': hash_key
})
collection = CollectionRecord.create({
'name': [{
'language': 'eng',
'value': value.get('a')
}],
'organisation': {
'$ref': self['organisation'][0]['$ref']
},
'hashKey':
hash_key
})
collection.commit()
collection.reindex()
db.session.commit()
Expand Down
2 changes: 1 addition & 1 deletion sonar/modules/documents/dojson/rerodoc/overdo.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def create_organisation(organisation_key):
'name': organisation_key,
'isShared': False,
'isDedicated': False
})
}, dbcommit=True)
organisation.reindex()

@staticmethod
Expand Down
12 changes: 6 additions & 6 deletions tests/ui/documents/dojson/rerodoc/test_rerodoc_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def test_marc21_to_type_and_organisation(app, bucket_location,
<record>
<datafield tag="980" ind1=" " ind2=" ">
<subfield code="a">BOOK</subfield>
<subfield code="b">BAAGE</subfield>
<subfield code="b">TEST</subfield>
</datafield>
<datafield tag="269" ind1=" " ind2=" ">
<subfield code="c">1966</subfield>
Expand All @@ -59,15 +59,15 @@ def test_marc21_to_type_and_organisation(app, bucket_location,
assert data.get('documentType') == 'coar:c_2f33'
assert data.get('organisation') == [{
'$ref':
'https://sonar.ch/api/organisations/baage'
'https://sonar.ch/api/organisations/test'
}]

# Type, subtype and organisation
marc21xml = """
<record>
<datafield tag="980" ind1=" " ind2=" ">
<subfield code="a">POSTPRINT</subfield>
<subfield code="b">BAAGE</subfield>
<subfield code="b">TEST</subfield>
<subfield code="f">ART_JOURNAL</subfield>
</datafield>
<datafield tag="269" ind1=" " ind2=" ">
Expand All @@ -80,14 +80,14 @@ def test_marc21_to_type_and_organisation(app, bucket_location,
assert data.get('documentType') == 'coar:c_6501'
assert data.get('organisation') == [{
'$ref':
'https://sonar.ch/api/organisations/baage'
'https://sonar.ch/api/organisations/test'
}]

# Organisation only
marc21xml = """
<record>
<datafield tag="980" ind1=" " ind2=" ">
<subfield code="b">BAAGE</subfield>
<subfield code="b">TEST</subfield>
</datafield>
<datafield tag="269" ind1=" " ind2=" ">
<subfield code="c">1966</subfield>
Expand All @@ -99,7 +99,7 @@ def test_marc21_to_type_and_organisation(app, bucket_location,
assert not data.get('documentType')
assert data.get('organisation') == [{
'$ref':
'https://sonar.ch/api/organisations/baage'
'https://sonar.ch/api/organisations/test'
}]

# Specific conversion for unisi
Expand Down

0 comments on commit 0548ee1

Please sign in to comment.