Skip to content

Commit

Permalink
metadata: adds corporate bodies to contributions
Browse files Browse the repository at this point in the history
* Renames person module into contribution module.
* Adds corporate bodies from MEF to contributions.
* Closes rero#1360

Co-Authored-by: Peter Weber <peter.weber@rero.ch>
  • Loading branch information
rerowep and rerowep committed Nov 17, 2020
1 parent ed12fd5 commit ed7331e
Show file tree
Hide file tree
Showing 85 changed files with 86,664 additions and 81,976 deletions.
66,207 changes: 66,207 additions & 0 deletions data/contributions_big.json

Large diffs are not rendered by default.

15,243 changes: 15,243 additions & 0 deletions data/contributions_small.json

Large diffs are not rendered by default.

5,085 changes: 3,020 additions & 2,065 deletions data/documents_big.json

Large diffs are not rendered by default.

1,096 changes: 638 additions & 458 deletions data/documents_small.json

Large diffs are not rendered by default.

62,245 changes: 0 additions & 62,245 deletions data/persons_big.json

This file was deleted.

15,915 changes: 0 additions & 15,915 deletions data/persons_small.json

This file was deleted.

85 changes: 48 additions & 37 deletions rero_ils/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@
from .modules.circ_policies.permissions import CirculationPolicyPermission
from .modules.collections.api import Collection
from .modules.collections.permissions import CollectionPermission
from .modules.contributions.api import Contribution
from .modules.contributions.permissions import ContributionPermission
from .modules.documents.api import Document
from .modules.documents.permissions import DocumentPermission
from .modules.holdings.api import Holding
Expand Down Expand Up @@ -91,8 +93,6 @@
from .modules.patrons.api import Patron
from .modules.patrons.permissions import PatronPermission
from .modules.permissions import record_permission_factory
from .modules.persons.api import Person
from .modules.persons.permissions import PersonPermission
from .modules.templates.api import Template
from .modules.templates.permissions import TemplatePermission
from .modules.vendors.api import Vendor
Expand Down Expand Up @@ -1042,13 +1042,13 @@ def _(x):
delete_permission_factory_imp=lambda record: record_permission_factory(
action='delete', record=record, cls=LocationPermission)
),
pers=dict(
pid_type='pers',
pid_minter='person_id',
pid_fetcher='person_id',
search_class='rero_ils.modules.persons.api:PersonsSearch',
search_index='persons',
indexer_class='rero_ils.modules.persons.api:PersonsIndexer',
cont=dict(
pid_type='cont',
pid_minter='contribution_id',
pid_fetcher='contribution_id',
search_class='rero_ils.modules.contributions.api:ContributionsSearch',
search_index='contributions',
indexer_class='rero_ils.modules.contributions.api:ContributionsIndexer',
search_type=None,
record_serializers={
'application/json': (
Expand All @@ -1063,26 +1063,26 @@ def _(x):
'rero_ils.modules.serializers:json_v1_search'
)
},
list_route='/persons/',
list_route='/contributions/',
record_loaders={
'application/json': lambda: Person(request.get_json()),
'application/json': lambda: Contribution(request.get_json()),
},
record_class='rero_ils.modules.persons.api:Person',
item_route=('/persons/<pid(pers, record_class='
'"rero_ils.modules.persons.api:Person"):pid_value>'),
record_class='rero_ils.modules.contributions.api:Contribution',
item_route=('/contributions/<pid(cont, record_class='
'"rero_ils.modules.contributions.api:Contribution"):pid_value>'),
default_media_type='application/json',
max_result_window=10000,
search_factory_imp='rero_ils.query:person_view_search_factory',
search_factory_imp='rero_ils.query:contribution_view_search_factory',
list_permission_factory_imp=lambda record: record_permission_factory(
action='list', record=record, cls=PersonPermission),
action='list', record=record, cls=ContributionPermission),
read_permission_factory_imp=lambda record: record_permission_factory(
action='read', record=record, cls=PersonPermission),
action='read', record=record, cls=ContributionPermission),
create_permission_factory_imp=lambda record: record_permission_factory(
action='create', record=record, cls=PersonPermission),
action='create', record=record, cls=ContributionPermission),
update_permission_factory_imp=lambda record: record_permission_factory(
action='update', record=record, cls=PersonPermission),
action='update', record=record, cls=ContributionPermission),
delete_permission_factory_imp=lambda record: record_permission_factory(
action='delete', record=record, cls=PersonPermission)
action='delete', record=record, cls=ContributionPermission)
),
cipo=dict(
pid_type='cipo',
Expand Down Expand Up @@ -1696,20 +1696,30 @@ def _(x):
_('status'): and_term_filter('order_status')
},
),
persons=dict(
contributions=dict(
aggs=dict(
sources=dict(
terms=dict(
field='sources',
# This does not take into account
# env variable or instance config file
size=RERO_ILS_AGGREGATION_SIZE.get(
'persons', RERO_ILS_DEFAULT_AGGREGATION_SIZE)
'contribution', RERO_ILS_DEFAULT_AGGREGATION_SIZE)
)
),
type=dict(
terms=dict(
field='type',
# This does not take into account
# env variable or instance config file
size=RERO_ILS_AGGREGATION_SIZE.get(
'contribution', RERO_ILS_DEFAULT_AGGREGATION_SIZE)
)
)
),
filters={
_('sources'): and_term_filter('sources')
_('sources'): and_term_filter('sources'),
_('type'): and_term_filter('type')
}
),
templates=dict(
Expand Down Expand Up @@ -1807,6 +1817,7 @@ def _(x):
'budgets',
'circ_policies',
'collections',
'contributions',
'documents',
'items',
'item_types',
Expand All @@ -1817,7 +1828,6 @@ def _(x):
'organisations',
'patrons',
'patron_types',
'persons',
'vendors',
'templates'
]
Expand Down Expand Up @@ -2004,12 +2014,13 @@ def _(x):
permission_factory_imp='rero_ils.permissions.'
'librarian_permission_factory',
),
'pers': dict(
pid_type='pers',
route='/<string:viewcode>/persons/<pid_value>',
template='rero_ils/detailed_view_persons.html',
record_class='rero_ils.modules.persons.api:Person',
view_imp='rero_ils.modules.persons.views.person_view_method'
'cont': dict(
pid_type='cont',
route='/<string:viewcode>/contributions/<pid_value>',
template='rero_ils/detailed_view_contribution.html',
record_class='rero_ils.modules.contributions.api:Contribution',
view_imp='rero_ils.modules.contributions.'
'views.contribution_view_method'
)
}

Expand All @@ -2031,6 +2042,7 @@ def _(x):
'budg': '/budgets/budget-v0.0.1.json',
'cipo': '/circ_policies/circ_policy-v0.0.1.json',
'coll': '/collections/collection-v0.0.1.json',
'cont': '/contributions/contribution-v0.0.1.json',
'doc': '/documents/document-v0.0.1.json',
'hold': '/holdings/holding-v0.0.1.json',
'illr': '/ill_requests/ill_request-v0.0.1.json',
Expand All @@ -2040,7 +2052,6 @@ def _(x):
'loc': '/locations/location-v0.0.1.json',
'notif': '/notifications/notification-v0.0.1.json',
'org': '/organisations/organisation-v0.0.1.json',
'pers': '/persons/person-v0.0.1.json',
'pttr': '/patron_transactions/patron_transaction-v0.0.1.json',
'ptty': '/patron_types/patron_type-v0.0.1.json',
'ptre': '/patron_transaction_events/patron_transaction_event-v0.0.1.json',
Expand Down Expand Up @@ -2100,14 +2111,14 @@ def _(x):
#: Cover service
RERO_ILS_THUMBNAIL_SERVICE_URL = 'https://services.test.rero.ch/cover'

#: Persons
RERO_ILS_PERSONS_MEF_SCHEMA = 'persons/person-v0.0.1.json'
RERO_ILS_PERSONS_SOURCES = ['rero', 'bnf', 'gnd', 'idref']
#: Contributions
RERO_ILS_CONTRIBUTIONS_MEF_SCHEMA = 'contributions/contribution-v0.0.1.json'
RERO_ILS_CONTRIBUTIONS_SOURCES = ['idref', 'gnd', 'rero']

RERO_ILS_PERSONS_LABEL_ORDER = {
RERO_ILS_CONTRIBUTIONS_LABEL_ORDER = {
'fallback': 'fr',
'fr': ['rero', 'idref', 'bnf', 'gnd'],
'de': ['gnd', 'rero', 'idref', 'bnf'],
'fr': ['idref', 'rero', 'gnd'],
'de': ['gnd', 'idref', 'rero'],
}

# JSONSchemas
Expand Down
45 changes: 44 additions & 1 deletion rero_ils/jsonschemas/common/languages-v0.0.1.json
Original file line number Diff line number Diff line change
Expand Up @@ -2443,54 +2443,97 @@
"type": "string",
"enum": [
"ara-arab",
"ara-latn",
"arm-armn",
"arm-latn",
"awa-deva",
"awa-latn",
"bel-cyrl",
"bel-latn",
"bho-deva",
"bho-latn",
"bra-deva",
"bra-latn",
"chi-hani",
"chi-latn",
"chi-zyyy",
"chu-cyrl",
"chu-latn",
"doi-deva",
"doi-latn",
"eng-latn",
"fre-latn",
"geo-geor",
"geo-latn",
"ger-latn",
"grc-grek",
"grc-latn",
"gre-grek",
"gre-latn",
"heb-hebr",
"heb-latn",
"hin-deva",
"hin-latn",
"ita-latn",
"jpn-hani",
"jpn-hrkt",
"jpn-jpan",
"jpn-latn",
"kas-deva",
"kas-latn",
"kok-deva",
"kok-latn",
"kor-kore",
"kor-latn",
"lad-hebr",
"lad-latn",
"mac-cyrl",
"mac-latn",
"mag-deva",
"mag-latn",
"mai-deva",
"mai-latn",
"mar-deva",
"mar-latn",
"mun-deva",
"mun-latn",
"nep-deva",
"nep-latn",
"per-arab",
"per-latn",
"pli-deva",
"pli-latn",
"pra-deva",
"pra-latn",
"raj-deva",
"raj-latn",
"rus-cyrl",
"rus-latn",
"san-deva",
"san-latn",
"sat-deva",
"sat-latn",
"snd-deva",
"snd-latn",
"srp-cyrl",
"srp-latn",
"tam-taml",
"tam-latn",
"tha-thai",
"tha-latn",
"ukr-cyrl",
"ukr-latn",
"und-arab",
"und-cyrl",
"und-grek",
"und-hani",
"und-hebr",
"und-jpan",
"und-kore",
"und-latn",
"und-zyyy",
"yid-hebr"
"yid-hebr",
"yid-latn"
],
"form": {
"templateOptions": {
Expand Down
1 change: 0 additions & 1 deletion rero_ils/manual_translations.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ _('video')
_('other')

_('gnd')
_('bnf')
_('rero')
_('idref')

Expand Down
2 changes: 1 addition & 1 deletion rero_ils/modules/apiharvester/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

"""Click command-line interface for mef person management."""
"""Click command-line interface for mef contribution management."""

from __future__ import absolute_import, print_function

Expand Down
29 changes: 14 additions & 15 deletions rero_ils/modules/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@

from .api import IlsRecordsIndexer
from .collections.cli import create_collections
from .contributions.tasks import create_mef_record_online
from .documents.dojson.contrib.marc21tojson import marc21
from .holdings.cli import create_patterns
from .ill_requests.cli import create_ill_requests
from .items.cli import create_items, reindex_items
from .loans.cli import create_loans
from .patrons.cli import import_users
from .persons.tasks import create_mef_record_online
from .tasks import process_bulk_queue
from .utils import get_record_class_from_schema_or_pid_type, read_json_record
from ..modules.providers import append_fixtures_new_identifiers
Expand Down Expand Up @@ -284,7 +284,7 @@ def init(force):
@click.option('-v', '--verbose', 'verbose', is_flag=True, default=True)
@click.option('-d', '--debug', 'debug', is_flag=True, default=False)
@click.option('-s', '--schema', 'schema', default=None)
@click.option('-p', '--pid_type', 'pid_type', default=None)
@click.option('-t', '--pid_type', 'pid_type', default=None)
@click.option('-l', '--lazy', 'lazy', is_flag=True, default=False)
@click.option('-o', '--dont-stop', 'dont_stop_on_error',
is_flag=True, default=False)
Expand Down Expand Up @@ -430,9 +430,9 @@ def count_cli(infile, lazy):
help="wait for enqueued tasks to finish")
@with_appcontext
def get_all_mef_records(infile, lazy, verbose, enqueue, wait):
"""Get all persons for given document file."""
"""Get all contributions for given document file."""
click.secho(
'Get all persons for {file_name}.'.format(file_name=infile.name),
'Get all contributions for {file_name}.'.format(file_name=infile.name),
fg='green'
)
if lazy:
Expand All @@ -453,7 +453,7 @@ def get_all_mef_records(infile, lazy, verbose, enqueue, wait):
msg = create_mef_record_online.delay(ref)
else:
pid, online = create_mef_record_online(ref)
msg = 'person pid: {pid} {online}'.format(
msg = 'contribution pid: {pid} {online}'.format(
pid=pid,
online=online
)
Expand Down Expand Up @@ -949,9 +949,8 @@ def marc21json(xml_file, json_file_ok, xml_file_error, parallel, chunk,
path = current_jsonschemas.url_to_path(get_schema_for_resource('doc'))
schema = current_jsonschemas.get_schema(path=path)
schema = _records_state.replace_refs(schema)
transform = Marc21toJson(xml_file, json_file_ok, xml_file_error,
parallel, chunk, verbose, debug, pid_required,
schema)
transform = Marc21toJson(xml_file, json_file_ok, xml_file_error, parallel,
chunk, verbose, debug, pid_required, schema)

count, count_ok, count_ko = transform.counts()

Expand All @@ -968,7 +967,7 @@ def marc21json(xml_file, json_file_ok, xml_file_error, parallel, chunk,


@utils.command('reserve_pid_range')
@click.option('-p', '--pid_type', 'pid_type', default=None,
@click.option('-t', '--pid_type', 'pid_type', default=None,
help='pid type of the resource')
@click.option('-n', '--records_number', 'records_number', default=None,
help='Number of records to load')
Expand Down Expand Up @@ -1497,7 +1496,7 @@ def dump_es_mappings(verbose, outfile):

@utils.command('export')
@click.option('-v', '--verbose', 'verbose', is_flag=True, default=False)
@click.option('-p', '--pid_type', 'pid_type', default='doc')
@click.option('-t', '--pid_type', 'pid_type', default='doc')
@click.option('-o', '--outfile', 'outfile', required=True,
type=click.File('w'))
@click.option('-i', '--pidfile', 'pidfile', type=click.File('r'),
Expand Down Expand Up @@ -1549,12 +1548,12 @@ def export(verbose, pid_type, outfile, pidfile, indent, schema):
if count > 1:
outfile.write(',')
if not schema:
del rec['$schema']
persons_sources = current_app.config.get(
'RERO_ILS_PERSONS_SOURCES', [])
for persons_source in persons_sources:
rec.pop('$schema', None)
contributions_sources = current_app.config.get(
'RERO_ILS_CONTRIBUTIONS_SOURCES', [])
for contributions_source in contributions_sources:
try:
del rec[persons_source]['$schema']
del rec[contributions_source]['$schema']
except:
pass
output = ''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

"""Mef Persons Records."""
"""Mef Contributions Records."""
Loading

0 comments on commit ed7331e

Please sign in to comment.