Skip to content

Commit

Permalink
api: search swisscovery records
Browse files Browse the repository at this point in the history
* Adds an endpoint to search for swisscovery records.
* Adds a loader to transform swisscovery record to document record.
* Adds a serializer to transform document record to deposit record.
* Closes #610.

Co-Authored-by: Sébastien Délèze <sebastien.deleze@rero.ch>
  • Loading branch information
Sébastien Délèze committed Aug 30, 2021
1 parent 33bce7e commit f94f94c
Show file tree
Hide file tree
Showing 20 changed files with 3,444 additions and 44 deletions.
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@
'monitoring = sonar.monitoring.views:blueprint',
'translations = sonar.translations.rest:blueprint',
'suggestions = sonar.suggestions.rest:blueprint',
'validation = sonar.modules.validation.views:blueprint'
'validation = sonar.modules.validation.views:blueprint',
'swisscovery = sonar.modules.swisscovery.rest:blueprint'
],
'invenio_assets.webpack': [
'sonar_theme = sonar.theme.webpack:theme'
Expand Down
3 changes: 3 additions & 0 deletions sonar/config_sonar.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,6 @@
"""ARK scheme."""
# SONAR_APP_ARK_SHOULDER = 'ffk3'
"""ARK Shoulder, can be multiple for a given organisation."""

SONAR_APP_SWISSCOVERY_SEARCH_URL = 'https://swisscovery.slsp.ch/view/sru/41SLSP_NETWORK'
SONAR_APP_SWISSCOVERY_SEARCH_VERSION = '1.1'
48 changes: 46 additions & 2 deletions sonar/modules/deposits/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,16 +180,22 @@ def create_document(self):
# Add a statement for date
metadata['provisionActivity'][0]['statement'].append({
'label': [{
'value': self['metadata']['documentDate']
'value':
self['metadata']['statementDate']
if self['metadata'].get('statementDate') else
self['metadata']['documentDate']
}],
'type':
'Date'
})

# Published in
if self['metadata'].get('publication'):
year = self['metadata']['publication']['year'] if self['metadata'][
'publication'].get(
'year') else self['metadata']['documentDate']
part_of = {
'numberingYear': self['metadata']['documentDate'],
'numberingYear': year,
'document': {
'title': self['metadata']['publication']['publishedIn']
}
Expand All @@ -216,6 +222,10 @@ def create_document(self):
'statement': self['metadata']['publication']['publisher']
}

if self['metadata']['publication'].get('identifiedBy'):
part_of['document']['identifiedBy'] = self['metadata'][
'publication']['identifiedBy']

metadata['partOf'] = [part_of]

# Other electronic versions
Expand Down Expand Up @@ -302,6 +312,40 @@ def create_document(self):
if identifiers:
metadata['identifiedBy'] = identifiers

# Content note
if self['metadata'].get('contentNote'):
metadata['contentNote'] = self['metadata']['contentNote']

# Extent
if self['metadata'].get('extent'):
metadata['extent'] = self['metadata']['extent']

# Additional materials
if self['metadata'].get('additionalMaterials'):
metadata['additionalMaterials'] = self['metadata'][
'additionalMaterials']

# Formats
if self['metadata'].get('formats'):
metadata['formats'] = self['metadata']['formats']

# Other material characteristics
if self['metadata'].get('otherMaterialCharacteristics'):
metadata['otherMaterialCharacteristics'] = self['metadata'][
'otherMaterialCharacteristics']

# Edition statement
if self['metadata'].get('editionStatement'):
metadata['editionStatement'] = self['metadata']['editionStatement']

# Notes
if self['metadata'].get('notes'):
metadata['notes'] = self['metadata']['notes']

# Series
if self['metadata'].get('series'):
metadata['series'] = self['metadata']['series']

# Contributors
contributors = []
for contributor in self.get('contributors', []):
Expand Down
179 changes: 179 additions & 0 deletions sonar/modules/deposits/jsonschemas/deposits/deposit-v1.0.0_src.json
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,12 @@
}
}
},
"statementDate": {
"title": "Statement date",
"type": "string",
"minLength": 1
},

"identifiedBy": {
"title": "Identifiers",
"type": "array",
Expand Down Expand Up @@ -608,6 +614,14 @@
}
}
},
"year": {
"title": "Year",
"type": "string",
"minLength": 1,
"form": {
"hide": true
}
},
"editors": {
"title": "Authors / Editors",
"type": "array",
Expand All @@ -623,6 +637,59 @@
"title": "Publisher",
"type": "string",
"minLength": 1
},
"identifiedBy": {
"title": "Identifiers",
"type": "array",
"minItems": 1,
"items": {
"title": "Identifier",
"type": "object",
"additionalProperties": false,
"properties": {
"type": {
"title": "Type",
"type": "string",
"enum": [
"bf:AudioIssueNumber",
"bf:Doi",
"bf:Ean",
"bf:Gtin14Number",
"bf:Identifier",
"bf:Isan",
"bf:Isbn",
"bf:Ismn",
"bf:Isrc",
"bf:Issn",
"bf:Local",
"bf:IssnL",
"bf:MatrixNumber",
"bf:MusicDistributorNumber",
"bf:MusicPlate",
"bf:MusicPublisherNumber",
"bf:PublisherNumber",
"bf:Upc",
"bf:Urn",
"bf:VideoRecordingNumber",
"uri",
"bf:ReportNumber",
"bf:Strn"
]
},
"value": {
"title": "Value",
"type": "string",
"minLength": 1
}
},
"required": [
"type",
"value"
]
},
"form": {
"hide": true
}
}
},
"form": {
Expand Down Expand Up @@ -915,6 +982,118 @@
]
}
}
},
"contentNote": {
"title": "Content notes",
"type": "array",
"minItems": 1,
"items": {
"title": "Content note",
"type": "string",
"minLength": 1
}
},
"extent": {
"title": "Extent",
"description": "Extent of the resource, i.e. the number of pages or volumes.",
"type": "string",
"minLength": 1
},
"additionalMaterials": {
"title": "Additional materials",
"description": "Accompanying material of the resource, i.e. maps.",
"type": "string",
"minLength": 1
},
"formats": {
"title": "Formats",
"description": "Format of the resource, i.e. dimensions in cm.",
"type": "array",
"minItems": 1,
"items": {
"title": "Format",
"type": "string",
"minLength": 1
}
},
"otherMaterialCharacteristics": {
"title": "Other Material Characteristics",
"description": "Other Material Characteristics, i.e. illustrations, black and white, or coloured.",
"type": "string",
"minLength": 1
},
"editionStatement": {
"title": "Edition",
"type": "object",
"additionalProperties": false,
"properties": {
"editionDesignation": {
"title": "Designation",
"type": "object",
"properties": {
"value": {
"title": "Value",
"type": "string",
"minLength": 1
}
},
"required": [
"value"
]
},
"responsibility": {
"title": "Responsibility",
"type": "object",
"properties": {
"value": {
"title": "Value",
"type": "string",
"minLength": 1
}
},
"required": [
"value"
]
}
},
"required": [
"editionDesignation"
]
},
"notes": {
"title": "Notes",
"type": "array",
"minItems": 1,
"items": {
"title": "Note",
"type": "string",
"minLength": 1
}
},
"series": {
"title": "Series",
"description": "Series the resource belongs to.",
"type": "array",
"minItems": 1,
"items": {
"type": "object",
"additionalProperties": false,
"properties": {
"name": {
"title": "Title",
"type": "string",
"minLength": 1
},
"number": {
"title": "Numbering",
"type": "string",
"minLength": 1
}
},
"required": [
"name"
]
}
}
}
},
Expand Down
64 changes: 64 additions & 0 deletions sonar/modules/deposits/mappings/v7/deposits/deposit-v1.0.0.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@
"type": "date",
"format": "yyyy-MM-dd||yyyy"
},
"statementDate": {
"type": "text"
},
"publication": {
"type": "object",
"properties": {
Expand All @@ -151,6 +154,17 @@
},
"publisher": {
"type": "text"
},
"identifiedBy": {
"type": "object",
"properties": {
"type": {
"type": "keyword"
},
"value": {
"type": "keyword"
}
}
}
}
},
Expand Down Expand Up @@ -234,6 +248,56 @@
"format": "yyyy-MM-dd||yyyy"
}
}
},
"contentNote": {
"type": "text"
},
"extent": {
"type": "text"
},
"additionalMaterials": {
"type": "text"
},
"formats": {
"type": "text"
},
"otherMaterialCharacteristics": {
"type": "text"
},
"editionStatement": {
"type": "object",
"properties": {
"editionDesignation": {
"type": "object",
"properties": {
"value": {
"type": "text"
}
}
},
"responsibility": {
"type": "object",
"properties": {
"value": {
"type": "text"
}
}
}
}
},
"notes": {
"type": "text"
},
"series": {
"type": "object",
"properties": {
"name": {
"type": "text"
},
"number": {
"type": "text"
}
}
}
}
},
Expand Down

0 comments on commit f94f94c

Please sign in to comment.