Skip to content

Commit

Permalink
rules: updated ignored keys
Browse files Browse the repository at this point in the history
* schemas structures fix
  • Loading branch information
kpsherva committed Jun 21, 2019
1 parent 61480be commit 9bed388
Show file tree
Hide file tree
Showing 10 changed files with 258 additions and 194 deletions.
27 changes: 6 additions & 21 deletions cds_dojson/marc21/fields/books/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ def publication_info(self, key, value):
clean_val('o', v, str) or '',
clean_val('x', v, str) or '').strip()
if text:
temp_info.update({'pubinfo_freetext': text})
temp_info.update({'note': text})
if temp_info:
_publication_info.append(temp_info)
return _publication_info
Expand Down Expand Up @@ -563,7 +563,7 @@ def conference_info(self, key, value):
'opening_date': opening_date.date().isoformat(),
'closing_date': closing_date.date().isoformat(),
'cern_conference_code': clean_val('g', v, str),
'series_number': clean_val('n', v, int),
'series': {'number': clean_val('n', v, int)},
'country_code': country_code,
})
elif key == '270__':
Expand All @@ -574,7 +574,7 @@ def conference_info(self, key, value):
raise MissingRequiredField(subfield='m')
else:
_conference_info.update({
'conference_acronym': clean_val('a', v, str)})
'acronym': clean_val('a', v, str)})
return _conference_info


Expand Down Expand Up @@ -603,11 +603,11 @@ def title(self, key, value):
}


@model.over('editions', '^250__')
@model.over('edition', '^250__')
@out_strip
@for_each_value
def editions(self, key, value):
"""Translates editions fields."""
def edition(self, key, value):
"""Translates edition indicator field."""
return clean_val('a', value, str)


Expand All @@ -628,21 +628,6 @@ def imprints(self, key, value):
}


@model.over('preprint_date', '^269__') # item, RDM?!
@out_strip
def preprint_date(self, key, value):
"""Translates preprint_date fields."""
date = clean_val('c', value, str)
if date:
try:
date = parser.parse(date)
return date.date().isoformat()
except (ValueError, AttributeError):
raise ManualMigrationRequired(subfield='c')
else:
raise IgnoreKey('preprint_date')


@model.over('number_of_pages', '^300__') # item
def number_of_pages(self, key, value):
"""Translates number_of_pages fields."""
Expand Down
19 changes: 19 additions & 0 deletions cds_dojson/marc21/fields/rdm/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
#
# This file is part of CERN Document Server.
# Copyright (C) 2017 CERN.
#
# Invenio is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of the
# License, or (at your option) any later version.
#
# Invenio is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Invenio; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
"""CDS RDM fields."""
41 changes: 41 additions & 0 deletions cds_dojson/marc21/fields/rdm/base.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# -*- coding: utf-8 -*-
#
# This file is part of CERN Document Server.
# Copyright (C) 2017 CERN.
#
# Invenio is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of the
# License, or (at your option) any later version.
#
# Invenio is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Invenio; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
"""Common RDM fields."""

from dateutil import parser
from dojson.errors import IgnoreKey

from cds_dojson.marc21.fields.books.errors import ManualMigrationRequired
from cds_dojson.marc21.fields.utils import clean_val, out_strip
from cds_dojson.marc21.models.base import model


@model.over('preprint_date', '^269__') # item, RDM?!
@out_strip
def preprint_date(self, key, value):
"""Translates preprint_date fields."""
date = clean_val('c', value, str)
if date:
try:
date = parser.parse(date)
return date.date().isoformat()
except (ValueError, AttributeError):
raise ManualMigrationRequired(subfield='c')
else:
raise IgnoreKey('preprint_date')
13 changes: 13 additions & 0 deletions cds_dojson/marc21/models/books/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,25 @@
'082042',
'0820_2',
'082__2',
'111__d',
'111__f',
'269__a', # preprint info
'269__b', # preprint info
'269__c', # preprint date
'340__a',
'541__9',
'502__a', # thesis_info/defense_date
'502__b', # thesis_info/degree_type
'502__c', # thesis_info/institutions
'502__d', # thesis_info/date (publication)
'650172',
'65017a',
'650272',
'65027a',
'694__9',
'694__a',
'773__r', # publication_info/parent_report_number
'773__z', # publication_info/parent_isbn
'852__c',
'852__h',
'901__a', # record affiliation
Expand All @@ -58,6 +69,8 @@
'961__h',
'961__l',
'961__x',
'962__b',
'962__n',
'963__a',
'964__a',
'981__a',
Expand Down
114 changes: 58 additions & 56 deletions cds_dojson/schemas/records/books/book/document-v0.0.1.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
"title": "Email address associated to the submitter's account",
"type": "string"
},
"id": {
"user_id": {
"description": "This field is used when `method` is `submitter`.",
"title": "User ID of the submitter",
"type": "integer"
Expand Down Expand Up @@ -1967,64 +1967,66 @@
"uniqueItems": true
},
"conference_info": {
"cern_conference_code": {
"description": ":MARC: ``111__g``",
"minLength": 1,
"type": "string"
},
"closing_date": {
"description": ":MARC: ``111__z``\nclosing date of the conference",
"format": "date",
"minLength": 1,
"type": "string"
},
"acronym": {
"description": ":MARC: ``711__a``",
"minLength": 1,
"type": "string"
},
"contact": {
"description": ":MARC: ``270__m`` Do we still need?",
"minLength": 1,
"type": "string"
},
"country": {
"description": ":MARC: ``111__w`` Do we still need?",
"minLength": 1,
"type": "string"
},
"place": {
"description": ":MARC: ``111__c``",
"minLength": 1,
"type": "string"
},
"series": {
"description": ":MARC: Does not exist in CDS",
"minLength": 1,
"type": "string",
"number": {
"description": ":MARC: ``111/711``\n.. Notes:: In Inspire there is a separate entity for conferences.",
"properties": {
"acronym": {
"description": ":MARC: ``711__a``",
"minLength": 1,
"type": "string"
},
"cern_conference_code": {
"description": ":MARC: ``111__g``",
"minLength": 1,
"type": "string"
},
"closing_date": {
"description": ":MARC: ``111__z``\nclosing date of the conference",
"format": "date",
"minLength": 1,
"type": "string"
},
"contact": {
"description": ":MARC: ``270__m`` Do we still need?",
"minLength": 1,
"type": "string"
},
"country": {
"description": ":MARC: ``111__w`` Do we still need?",
"minLength": 1,
"type": "string"
},
"inspire_cnum": {
"description": ":MARC: ``035__a`` when 9:INSPIRE-CNUM",
"minLength": 1,
"type": "string"
},
"opening_date": {
"description": ":MARC: ``111__9``\nstarting date of the conference",
"format": "date",
"minLength": 1,
"type": "string"
},
"place": {
"description": ":MARC: ``111__c``",
"minLength": 1,
"type": "string"
},
"series": {
"description": ":MARC: Does not exist in CDS",
"minLength": 1,
"type": "integer"
"type": "string",
"number": {
"description": ":MARC: Does not exist in CDS",
"minLength": 1,
"type": "integer"
}
},
"title": {
"description": ":MARC: ``111__a``\n.. Note: There can be different values there.",
"minLength": 1,
"type": "string"
}
},
"title": {
"description": ":MARC: ``111__a``\n.. Note: There can be different values there.",
"minLength": 1,
"type": "string"
},
"description": ":MARC: ``111/711``\n.. Notes:: In Inspire there is a separate entity for conferences.",
"inspire_cnum": {
"description": ":MARC: ``035__a`` when 9:INSPIRE-CNUM",
"minLength": 1,
"type": "string"
},
"opening_date": {
"description": ":MARC: ``111__9``\nstarting date of the conference",
"format": "date",
"minLength": 1,
"type": "string"
},
"required": [
"place",
"title"
Expand Down Expand Up @@ -2053,7 +2055,7 @@
"type": "string"
},
"minItems": 1,
"title": "List of book editions",
"title": "Book edition indicator",
"type": "array",
"uniqueItems": true
},
Expand Down
Loading

0 comments on commit 9bed388

Please sign in to comment.