Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

metadata: import, export, create csv data files #1710

Merged
merged 1 commit into from
May 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
255 changes: 255 additions & 0 deletions data/pid_dependencies_small.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,255 @@
[
{
"name": "organisation",
"filename": "organisations.json"
},
{
"name": "library",
"filename": "libraries.json",
"dependencies": [
{
"name": "organisation"
}
]
},
{
"name": "location",
"filename": "locations.json",
"dependencies": [
{
"name": "library"
}
]
},
{
"name": "pickup_location",
"filename": "locations.json"
},
{
"name": "item_type",
"filename": "item_types.json",
"dependencies": [
{
"name": "organisation"
}
]
},
{
"name": "patron_type",
"filename": "patron_types.json",
"dependencies": [
{
"name": "organisation"
},
{
"name": "library_exceptions",
"optional": "True",
"sublist": [
{
"name": "library"
}
]
}
]
},
{
"name": "circulation_policie",
"filename": "circulation_policies.json",
"dependencies": [
{
"name": "organisation"
},
{
"name": "settings",
"optional": "True",
"sublist": [
{
"name": "patron_type"
},
{
"name": "item_type"
}
]
},
{
"name": "library",
"optional": "True"
}
]
},
{
"name": "vendor",
"filename": "vendors.json",
"dependencies": [
{
"name": "organisation"
}
]
},
{
"name": "patron",
"filename": "users.json",
"dependencies": [
{
"name": "library",
"optional": "True"
},
{
"name": "patron",
"optional": "True",
"sublist": [
{
"name": "patron_type",
"optional": "True"
}
]
}
]
},
{
"name": "document",
"filename": "documents_small.json"
},
{
"name": "holding",
"filename": "holdings_small.json",
"dependencies": [
{
"name": "location"
},
{
"name": "circulation_category",
"ref": "item_type"
},
{
"name": "document"
}
]
},
{
"name": "item",
"filename": "items_small.json",
"dependencies": [
{
"name": "location"
},
{
"name": "document"
},
{
"name": "item_type"
},
{
"name": "holding",
"optional": "True"
},
{
"name": "organisation",
"optional": "True"
}
]
},
{
"name": "patterns",
"filename": "patterns.json"
},
{
"name": "budget",
"filename": "budgets.json",
"dependencies": [
{
"name": "organisation",
"optional": "True"
}
]
},
{
"name": "collection",
"filename": "collections.json",
"dependencies": [
{
"name": "librarie",
"ref": "libraries",
"optional": "True"
},
{
"name": "item",
"ref": "items",
"optional": "True"
},
{
"name": "organisation"
}
]
},
{
"name": "acq_account",
"filename": "acq_accounts.json",
"dependencies": [
{
"name": "budget"
},
{
"name": "library"
},
{
"name": "organisation",
"optional": "True"
}
]
},
{
"name": "template",
"filename": "templates.json",
"dependencies": [
{
"name": "organisation"
},
{
"name": "creator",
"ref": "patron"
}
]
},
{
"name": "loan",
"filename": "loans.json",
"dependencies": [
{
"name": "item",
"optional": "True"
},
{
"name": "patron",
"optional": "True"
},
{
"name": "document",
"optional": "True"
},
{
"name": "organisation",
"optional": "True"
}
]
},
{
"name": "local_field",
"filename": "local_fields.json",
"dependencies": [
{
"name": "organisation",
"optional": "True"
},
{
"name": "parent",
"optional": "True",
"refs": {
"document": "documents",
"item": "items",
"holding": "holdings"
}
}
]
}
]
11 changes: 9 additions & 2 deletions rero_ils/modules/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@
from invenio_records_rest.utils import obj_or_import_string
from invenio_search import current_search
from invenio_search.api import RecordsSearch
from jsonschema.exceptions import ValidationError
from kombu.compat import Consumer
from sqlalchemy import text
from sqlalchemy.orm.exc import NoResultFound

from .errors import RecordValidationError
from .utils import extracted_data_from_ref


Expand Down Expand Up @@ -139,7 +139,7 @@ def _validate(self, **kwargs):
not_required=self.pids_exist_check.get('not_required', {})
) or True
if validation_message is not True:
raise RecordValidationError(validation_message)
raise ValidationError(validation_message)
return json

def extended_validation(self, **kwargs):
Expand Down Expand Up @@ -433,6 +433,13 @@ def organisation_pid(self):
"""Get organisation pid for circulation policy."""
return extracted_data_from_ref(self.get('organisation'))

@classmethod
def get_metadata_identifier_names(cls):
"""Get metadata and identifier table names."""
metadata = cls.model_cls.__tablename__
identifier = cls.provider.identifier
return metadata, identifier


class IlsRecordsIndexer(RecordIndexer):
"""Indexing class for ils."""
Expand Down
Loading