Skip to content

Commit

Permalink
ark: get rid of archetype
Browse files Browse the repository at this point in the history
* Adds a Ark NAAN configuration into organisation.
* Disallows Ark NAAN configuration modification for non super user.
* Mints an ark identifier if the document organisation contains a NAAN.
* Removes legacy code.
* Closes #652.
* Adds the cli to create an ARK in existing documents.
* Removes unused file.
* Adds document Dublin Core export format.
* Moves ark in identifiedBy.
* Uses dumpers to enrich indexed documents.
* Adds dublin core as export format.
* Closes #669.
* Adds the full URI version of the ARK on the search result API.
* Sets the application configurations for the test to allow the use of
  multiple docker-compose files.
* Uses angular 14.
* Solves safety, need to move to Flask 2.
* Fixes json-ld context value.
* Adds multiple identifiers for dublin core.
* Uses ARK URI for `@id` and `identifier` field in json-ld.
* Fixes some tests.
* Makes all fields searchable for documents index.

Co-Authored-by: Johnny Mariéthoz <Johnny.Mariethoz@rero.ch>
  • Loading branch information
jma committed Jun 29, 2023
1 parent d5c2981 commit 8bbb16d
Show file tree
Hide file tree
Showing 70 changed files with 3,180 additions and 3,159 deletions.
1 change: 1 addition & 0 deletions data/organisations/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"code": "rero",
"name": "RERO",
"isShared": true,
"arkNAAN": "99999",
"files": [
{
"key": "rero.jpg",
Expand Down
4,037 changes: 1,883 additions & 2,154 deletions poetry.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ theme = "sonar.theme.views:blueprint"
validation = "sonar.modules.validation.views:blueprint"
users = "sonar.modules.users.views:blueprint"
sitemap = "sonar.modules.sitemap.views:blueprint"
ark = "sonar.modules.ark.views:blueprint"

[tool.poetry.plugins."invenio_base.api_blueprints"]
deposits = "sonar.modules.deposits.rest:api_blueprint"
Expand Down
2 changes: 1 addition & 1 deletion scripts/setup
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ if $import; then
message "Size of import sets is set to \"$size\"" "info"
fi

# Try to create database and tables if does not exists
# Try to create database and tables if does not exist
invenio db init create || true

# Purge celery
Expand Down
2 changes: 1 addition & 1 deletion scripts/test
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ fi
# | celery | 5.1.2 | <5.2.0 | 42498 |
# | celery | 5.1.2 | <5.2.2 | 43738 |
# +==============================================================================+
safety check -i 45183 -i 44501 -i 51668 -i 42194 -i 42852 -i 53325 -i 53326 -i 54456 -i 42498 -i 43738 -i 47833 -i 51457 -i 51358 -i 53812 -i 52495 -i 50792
safety check -i 45183 -i 44501 -i 51668 -i 42194 -i 42852 -i 53325 -i 53326 -i 54456 -i 42498 -i 43738 -i 47833 -i 51457 -i 51358 -i 53812 -i 52495 -i 50792 -i 55261
pydocstyle sonar tests docs
isort --check-only --diff "${SCRIPT_PATH}/.."
autoflake -c -r --remove-all-unused-imports --ignore-init-module-imports . &> /dev/null || {
Expand Down
15 changes: 14 additions & 1 deletion sonar/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@ def _(x):
},
}
"""Records UI for sonar."""
REST_MIMETYPE_QUERY_ARG_NAME = 'format'

RECORDS_REST_ENDPOINTS = {
'doc':
Expand All @@ -382,10 +383,22 @@ def _(x):
record_serializers={
'application/json': ('sonar.modules.documents.serializers'
':json_v1_response'),
'text/xml': ('sonar.modules.documents.serializers'
':dc_v1_response'),
},
record_serializers_aliases={
'json': 'application/json',
'dc': 'text/xml',
},
search_serializers={
'application/json': ('sonar.modules.documents.serializers'
':json_v1_search'),
'text/xml': ('sonar.modules.documents.serializers'
':dc_v1_search'),
},
search_serializers_aliases={
'json': 'application/json',
'dc': 'text/xml',
},
record_loaders={
'application/json': ('sonar.modules.documents.loaders'
Expand Down Expand Up @@ -874,7 +887,7 @@ def _(x):
'oai_dc': {
'namespace': 'http://www.openarchives.org/OAI/2.0/oai_dc/',
'schema': 'http://www.openarchives.org/OAI/2.0/oai_dc.xsd',
'serializer': 'sonar.modules.documents.serializers.dc.sonar_dublin_core',
'serializer': 'sonar.modules.documents.serializers.oai_dc.sonar_dublin_core',
}
}
#: Number of records to return per page in OAI-PMH results.
Expand Down
14 changes: 3 additions & 11 deletions sonar/config_sonar.py
Original file line number Diff line number Diff line change
Expand Up @@ -565,19 +565,11 @@
# ARK
# ===

# SONAR_APP_ARK_USER = 'test'
"""Username for the NMA server."""
# SONAR_APP_ARK_PASSWORD = 'test'
"""Password for the NMA server."""
# SONAR_APP_ARK_RESOLVER = 'https://n2t.net'
SONAR_APP_ARK_RESOLVER = 'https://localhost:5000'
"""ARK resolver URL."""
# SONAR_APP_ARK_NMA = 'https://www.arketype.ch'
"""ARK Name Mapping Authority: a service provider server."""
# SONAR_APP_ARK_NAAN = '99999'
"""ARK prefix corresponding to an organisation."""
# SONAR_APP_ARK_SCHEME = 'ark:'
SONAR_APP_ARK_SCHEME = 'ark:'
"""ARK scheme."""
# SONAR_APP_ARK_SHOULDER = 'ffk3'
SONAR_APP_ARK_SHOULDER = 'ffk3'
"""ARK Shoulder, can be multiple for a given organisation."""

SONAR_APP_SWISSCOVERY_SEARCH_URL = 'https://swisscovery.slsp.ch/view/sru/41SLSP_NETWORK'
Expand Down
8 changes: 8 additions & 0 deletions sonar/ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,14 @@ def init_config(self, app):
'SONAR_APP_SITEMAP_FOLDER_PATH',
os.path.join(app.instance_path, 'sitemap'))

# add keep alive support for angular application
# NOTE: this will not work for werkzeug> 2.1.2
# https://werkzeug.palletsprojects.com/en/2.2.x/changes/#version-2-1-2
if app.config.get('DEBUG'): # pragma: no cover
# debug code do not need to be cover by the tests
from werkzeug.serving import WSGIRequestHandler
WSGIRequestHandler.protocol_version = "HTTP/1.1"

def init_views(self, app):
"""Initialize the main flask views."""
app.url_map.converters['org_code'] = OrganisationCodeConverter
Expand Down
2 changes: 1 addition & 1 deletion sonar/json_schemas/organisations_json_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def process(self):
# Remove modes fields if user does not have superuser role.
if not current_user_record.is_superuser:
propertiesOrder = schema.get('propertiesOrder', []);
for field in ['isDedicated', 'isShared']:
for field in ['isDedicated', 'isShared', 'arkNAAN']:
if field in propertiesOrder:
schema['propertiesOrder'].remove(field)

Expand Down
12 changes: 11 additions & 1 deletion sonar/modules/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import os.path
import re
from copy import deepcopy
from io import BytesIO
from uuid import uuid4

Expand Down Expand Up @@ -219,6 +220,15 @@ def get_record_by_bucket(bucket):
except Exception:
return None

def resolve(self):
"""Resolve references data.
Mainly used by the `resolve=1` URL parameter.
:returns: a fresh copy of the resolved data.
"""
return deepcopy(self.replace_refs())

def reindex(self):
"""Reindex record."""
indexer = self.get_indexer_class()
Expand Down Expand Up @@ -344,7 +354,7 @@ def has_subdivision(self, subdivision_pid):
if not self.subdivisions:
return False

for subdivision in self.subdivisions:
for subdivision in self.subdivisions:
if subdivision_pid == subdivision['pid']:
return True

Expand Down
Loading

0 comments on commit 8bbb16d

Please sign in to comment.