Skip to content

Commit

Permalink
Merge daaa18e into 5d017de
Browse files Browse the repository at this point in the history
  • Loading branch information
jma committed Sep 3, 2019
2 parents 5d017de + daaa18e commit ecfb99f
Show file tree
Hide file tree
Showing 34 changed files with 2,650 additions and 1,319 deletions.
31 changes: 22 additions & 9 deletions rero_ils/modules/documents/dojson/contrib/unimarctojson/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,20 @@ def unimarctype(self, key, value):
return type


@unimarctojson.over('identifiers', '^003')
@unimarctojson.over('identifiedBy', '^003')
@utils.ignore_value
def unimarcbnfid(self, key, value):
"""Get ID.
identifier bnfID 003
"""
values = value.split('/')
identifiers = self.get('identifiers', {})
identifiers['bnfID'] = values[-1]
identifiers = self.get('identifiedBy', [])
if value.startswith('http://catalogue.bnf.fr/'):
identifiers.append({
"type": "bf:Local",
"source": "BNF",
"value": value.replace('http://catalogue.bnf.fr/', '')
})
return identifiers


Expand Down Expand Up @@ -116,7 +120,7 @@ def unimarctitlesProper(self, key, value):
return value.get('a')


@unimarctojson.over('languages', '^101')
@unimarctojson.over('language', '^101')
@utils.ignore_value
def unimarclanguages(self, key, value):
"""Get languages.
Expand All @@ -134,7 +138,7 @@ def unimarclanguages(self, key, value):
'properties']['language']['items']['properties']['value']['enum']
for language in languages:
if language in langs:
to_return.append({'language': language})
to_return.append({'value': language, 'type': 'bf:Language'})

translatedsfrom = utils.force_list(value.get('c'))
if translatedsfrom:
Expand Down Expand Up @@ -285,16 +289,25 @@ def unimarcabstracts(self, key, value):
return ', '.join(utils.force_list(value.get('a')))


@unimarctojson.over('identifiers', '^073..')
@unimarctojson.over('identifiedBy', '^073..')
@utils.ignore_value
def unimarcidentifier_isbn(self, key, value):
"""Get identifier isbn.
identifiers:isbn: 010$a
"""
identifiers = self.get('identifiers', {})
from isbnlib import EAN13
identifiers = self.get('identifiedBy', [])
if value.get('a'):
identifiers['isbn'] = value.get('a')
ean = {
"type": "bf:Ean",
"value": value.get('a')
}
check_ean = EAN13(value.get('a'))
# Do we have to check also cancelled status?
if not check_ean:
ean['status'] = 'invalid'
identifiers.append(ean)
return identifiers


Expand Down
203 changes: 108 additions & 95 deletions rero_ils/modules/documents/jsonschemas/documents/document-v0.0.1.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"title": "Type",
"description": "Document type.",
"type": "string",
"default": "book",
"validationMessage": "Required. Type of the document. Should be selected in the list below.",
"enum": [
"article",
Expand Down Expand Up @@ -55,14 +56,70 @@
"minLength": 1
}
},
"is_part_of": {
"title": "Is part of",
"description": "Title of the host document.",
"type": "string",
"minLength": 3
"authors": {
"title": "Authors",
"description": "Author(s) of the resource. Can be either persons or organisations.",
"type": "array",
"minItems": 1,
"items": {
"type": "object",
"required": [
"type"
],
"additionalProperties": false,
"properties": {
"$ref": {
"title": "MEF person ref",
"type": "string",
"pattern": "^https://mef.rero.ch/api/mef/.*?$"
},
"pid": {
"title": "pid",
"description": "Corresponding pid of the MEF record.",
"type": "string",
"minLength": 1
},
"name": {
"title": "Name",
"description": "Person's or organisation's name.",
"type": "string"
},
"type": {
"title": "Type",
"description": "Identify if the author is a person or an organisation.",
"type": "string",
"default": "person",
"enum": [
"person",
"organisation"
]
},
"date": {
"title": "Date",
"description": "Information about the birth and the death of a person. Helpful to disambiguate people.",
"type": "string"
},
"qualifier": {
"title": "Qualifier",
"description": "Information about the person, ie her profession. Helpful to disambiguate people.",
"type": "string"
}
}
}
},
"subjects": {
"type": "array",
"title": "Subjects",
"minItems": 1,
"items": {
"type": "string",
"title": "Subject",
"description": "Subject of the resource.",
"minLength": 1
}
},
"language": {
"title": "Language",
"title": "Languages",
"description": "List of languages for the resource.",
"type": "array",
"minItems": 1,
Expand All @@ -87,6 +144,7 @@
"title": "Language value",
"description": "Language value.",
"type": "string",
"default": "fre",
"enum": [
"fre",
"ger",
Expand Down Expand Up @@ -117,55 +175,15 @@
"validationMessage": "Should be in the ISO 639 format, with 3 characters, ie <code>eng</code> for English."
}
},
"authors": {
"title": "Authors",
"description": "Author(s) of the resource. Can be either persons or organisations.",
"abstracts": {
"type": "array",
"title": "Abstracts",
"minItems": 1,
"items": {
"type": "object",
"required": [
"type"
],
"additionalProperties": false,
"properties": {
"$ref": {
"title": "MEF person ref",
"type": "string",
"pattern": "^https://mef.rero.ch/api/mef/.*?$"
},
"pid": {
"title": "pid",
"description": "Corresponding pid of the MEF record.",
"type": "string",
"minLength": 1
},
"name": {
"title": "Name",
"description": "Person's or organisation's name.",
"type": "string"
},
"type": {
"title": "Type",
"description": "Identify if the author is a person or an organisation.",
"type": "string",
"enum": [
"person",
"organisation"
],
"default": "person"
},
"date": {
"title": "Date",
"description": "Information about the birth and the death of a person. Helpful to disambiguate people.",
"type": "string"
},
"qualifier": {
"title": "Qualifier",
"description": "Information about the person, ie her profession. Helpful to disambiguate people.",
"type": "string"
}
}
"title": "Abstract",
"description": "Abstract of the resource.",
"type": "string",
"minLength": 3
}
},
"publishers": {
Expand All @@ -176,23 +194,26 @@
"items": {
"type": "object",
"additionalProperties": false,
"required": [
"name"
],
"properties": {
"name": {
"title": "Name",
"description": "Publisher's name.",
"type": "array",
"minItems": 1,
"items": {
"title": "Name",
"description": "Publisher's name.",
"type": "string",
"minLength": 2
}
},
"place": {
"title": "Place of publication",
"description": "Publisher's place of publication.",
"type": "array",
"minItems": 1,
"items": {
"title": "Place of publication",
"description": "Publisher's place of publication.",
"type": "string",
"minLength": 2
}
Expand Down Expand Up @@ -227,7 +248,7 @@
"minLength": 1
},
"formats": {
"title": "Format",
"title": "Formats",
"description": "Format of the resource, ie dimensions in cm.",
"type": "array",
"minItems": 1,
Expand Down Expand Up @@ -267,25 +288,11 @@
}
}
},
"notes": {
"title": "Note",
"description": "Note on the resource.",
"type": "array",
"minItems": 1,
"items": {
"type": "string",
"minLength": 1
}
},
"abstracts": {
"title": "Abstract",
"description": "Abstract of the resource.",
"type": "array",
"minItems": 1,
"items": {
"type": "string",
"minLength": 3
}
"is_part_of": {
"title": "Is part of",
"description": "Title of the host document.",
"type": "string",
"minLength": 3
},
"identifiedBy": {
"title": "Identifiers",
Expand All @@ -304,6 +311,7 @@
"title": "Type",
"description": "Type of the value.",
"type": "string",
"default": "bf:Isbn",
"enum": [
"bf:AudioIssueNumber",
"bf:Doi",
Expand All @@ -330,13 +338,13 @@
},
"value": {
"title": "Identifier value",
"description": "Identifier value.",
"description": "Value of the identifier.",
"type": "string",
"minLength": 1
},
"note": {
"title": "Qualifier",
"description": "Qualifier of the identifier.",
"title": "Note",
"description": "Note about the identifier.",
"type": "string",
"minLength": 1
},
Expand All @@ -362,8 +370,10 @@
"title": "Status",
"description": "Status of the ISBN/ISSN identifier.",
"type": "string",
"default": "valid",
"validationMessage": "ISBN/ISSN status should be selected in the list below.",
"enum": [
"valid",
"invalid",
"cancelled",
"invalid or cancelled"
Expand All @@ -372,25 +382,19 @@
}
}
},
"subjects": {
"title": "Subject",
"description": "Subject of the resource.",
"notes": {
"type": "array",
"title": "Notes",
"minItems": 1,
"items": {
"title": "Note",
"description": "Note on the resource.",
"type": "string",
"description": "Subject of the resource.",
"minLength": 1
}
},
"cover_art": {
"title": "Cover art",
"description": "Vendor cover art URL.",
"type": "string",
"format": "uri"
},
"electronic_location": {
"title": "Electronic Location",
"title": "Electronic Locations",
"description": "Information needed to locate and access an electronic resource.",
"type": "array",
"minItems": 1,
Expand All @@ -399,14 +403,23 @@
"required": [
"uri"
],
"uri": {
"title": "Uniform Resource Identifier",
"description": "Uniform Resource Identifier (URI), which provides standard syntax for locating an object using existing Internet protocols.",
"type": "string",
"format": "uri"
"additionalProperties": false,
"properties": {
"uri": {
"title": "Uniform Resource Identifier",
"description": "Uniform Resource Identifier (URI), which provides standard syntax for locating an object using existing Internet protocols.",
"type": "string",
"format": "uri"
}
}
}
},
"cover_art": {
"title": "Cover art",
"description": "Vendor cover art URL.",
"type": "string",
"format": "uri"
},
"harvested": {
"title": "Harvested",
"description": "Document is harvested or not, will disable record edition or similar.",
Expand Down

0 comments on commit ecfb99f

Please sign in to comment.