Skip to content

Commit

Permalink
Merge dbdc4ec into 875b8cc
Browse files Browse the repository at this point in the history
  • Loading branch information
rerowep committed May 16, 2020
2 parents 875b8cc + dbdc4ec commit 6a07c8f
Show file tree
Hide file tree
Showing 39 changed files with 29,149 additions and 21,267 deletions.
7,396 changes: 5,647 additions & 1,749 deletions data/documents_big.json

Large diffs are not rendered by default.

1,813 changes: 1,383 additions & 430 deletions data/documents_small.json

Large diffs are not rendered by default.

384 changes: 363 additions & 21 deletions rero_ils/dojson/utils.py

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions rero_ils/manual_translations.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,8 @@ _('bf:Place')
# Harvested source
_('ebibliomedia')
_('mv-cantook')

# Notes types
_('accompanyingMaterial')
_('general')
_('otherPhysicalDetails')
3 changes: 2 additions & 1 deletion rero_ils/modules/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,8 @@ def _index_action(self, payload):
:param payload: Decoded message body.
:returns: Dictionary defining an Elasticsearch bulk 'index' action.
"""
record = self.record_cls.get_record(payload['id'])
with db.session.begin_nested():
record = self.record_cls.get_record(payload['id'])
index, doc_type = self.record_to_index(record)

arguments = {}
Expand Down
7 changes: 5 additions & 2 deletions rero_ils/modules/documents/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
from invenio_search.api import RecordsSearch

from .models import DocumentIdentifier, DocumentMetadata
from .utils import edition_format_text, publication_statement_text, \
series_format_text, title_format_text_head
from .utils import edition_format_text, note_format_text, \
publication_statement_text, series_format_text, title_format_text_head
from ..acq_order_lines.api import AcqOrderLinesSearch
from ..api import IlsRecord, IlsRecordsIndexer
from ..fetchers import id_fetcher
Expand Down Expand Up @@ -166,6 +166,9 @@ def dumps(self, **kwargs):
editions = dump.get('editionStatement', [])
for edition in editions:
edition['_text'] = edition_format_text(edition)
notes = dump.get('note', [])
if notes:
dump["notes_text"] = note_format_text(notes)
titles = dump.get('title', [])
bf_titles = list(filter(lambda t: t['type'] == 'bf:Title', titles))
for title in bf_titles:
Expand Down
58 changes: 30 additions & 28 deletions rero_ils/modules/documents/dojson/contrib/marc21tojson/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
import requests
from dojson import utils

from rero_ils.dojson.utils import ReroIlsMarc21Overdo, TitlePartList, \
build_responsibility_data, error_print, \
from rero_ils.dojson.utils import BookFormatExtraction, ReroIlsMarc21Overdo, \
TitlePartList, add_note, build_responsibility_data, error_print, \
extract_subtitle_and_parallel_titles_from_field_245_b, get_field_items, \
get_field_link_data, make_year, not_repetitive, \
remove_trailing_punctuation
Expand Down Expand Up @@ -464,33 +464,28 @@ def build_place():
return publication or None


@marc21.over('formats', '^300..')
@marc21.over('extent', '^300..')
@utils.ignore_value
def marc21_to_description(self, key, value):
"""Get extent, otherMaterialCharacteristics, formats.
extent: 300$a (the first one if many)
otherMaterialCharacteristics: 300$b (the first one if many)
formats: 300 [$c repetitive]
"""Get physical description.
Extract:
- extent
- duration
- colorContent
- productionMethod
- illustrativeContent
- note of type otherPhysicalDetails and accompanyingMaterial
- book_formats
- dimensions
300 [$a repetitive]: extent, duration:
300 [$a non repetitive]: colorContent, productionMethod,
illustrativeContent, note of type otherPhysicalDetails
300 [$c repetitive]: dimensions, book_formats
"""
if value.get('a'):
if not self.get('extent', None):
self['extent'] = remove_trailing_punctuation(
not_repetitive(marc21.bib_id, key, value, 'a')
)
if value.get('b'):
if self.get('otherMaterialCharacteristics', []) == []:
self['otherMaterialCharacteristics'] = remove_trailing_punctuation(
not_repetitive(marc21.bib_id, key, value, 'b')
)
if value.get('c'):
formats = self.get('formats', None)
if not formats:
data = value.get('c')
formats = list(utils.force_list(data))
return formats
else:
return None
marc21.extract_description_from_marc_field(key, value, self)
return None


@marc21.over('series', '^490..')
Expand Down Expand Up @@ -855,15 +850,22 @@ def marc21_to_identifiedBy_from_field_930(self, key, value):
return identifiedBy or None


@marc21.over('notes', '^500..')
@marc21.over('note', '^500..')
@utils.for_each_value
@utils.ignore_value
def marc21_to_notes(self, key, value):
"""Get notes.
note: [500$a repetitive]
"""
return not_repetitive(marc21.bib_id, key, value, 'a')
add_note(
dict(
noteType='general',
label=not_repetitive(marc21.bib_id, key, value, 'a')
),
self)

return None


@marc21.over('is_part_of', '^773..')
Expand Down
57 changes: 30 additions & 27 deletions rero_ils/modules/documents/dojson/contrib/unimarctojson/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from pkg_resources import resource_string

from rero_ils.dojson.utils import ReroIlsUnimarcOverdo, TitlePartList, \
get_field_items, make_year, remove_trailing_punctuation
add_note, get_field_items, make_year, remove_trailing_punctuation

unimarc = ReroIlsUnimarcOverdo()

Expand Down Expand Up @@ -367,33 +367,29 @@ def build_place():
return publication or None


@unimarc.over('formats', '^215..')
@unimarc.over('extent', '^215..')
@utils.ignore_value
def unimarc_description(self, key, value):
"""Get extent, otherMaterialCharacteristics, formats.
extent: 215$a (the first one if many)
otherMaterialCharacteristics: 215$b (the first one if many)
formats: 215 [$c repetitive]
"""Get physical description.
Extract:
- extent
- duration
- colorContent
- productionMethod
- illustrativeContent
- note of type otherPhysicalDetails and accompanyingMaterial
- book_formats
- dimensions
215 [$a repetitive (the first one if many)]: extent, duration:
215 [$c non repetitive]: colorContent, productionMethod,
illustrativeContent, note of type otherPhysicalDetails
215 [$d repetitive]: dimensions, book_formats
215 [$e repetitive]: accompanying material note
"""
if value.get('a'):
if not self.get('extent', None):
self['extent'] = (
utils.force_list(value.get('a'))[0]
)
if value.get('c'):
if self.get('otherMaterialCharacteristics', []) == []:
self['otherMaterialCharacteristics'] = (
utils.force_list(value.get('c'))[0]
)
if value.get('d'):
formats = self.get('formats', None)
if not formats:
data = value.get('d')
formats = list(utils.force_list(data))
return formats
else:
return None
unimarc.extract_description_from_marc_field(key, value, self)
return None


@unimarc.over('series', '^225..')
Expand Down Expand Up @@ -448,15 +444,22 @@ def unimarc_identifier_isbn(self, key, value):
return identifiers


@unimarc.over('notes', '^300..')
@unimarc.over('note', '^300..')
@utils.for_each_value
@utils.ignore_value
def unimarc_notes(self, key, value):
"""Get notes.
note: [300$a repetitive]
"""
return value.get('a', '')
add_note(
dict(
noteType='general',
label=value.get('a', '')
),
self)

return None


@unimarc.over('subjects', '^6((0[0-9])|(1[0-7]))..')
Expand Down

0 comments on commit 6a07c8f

Please sign in to comment.