+
+ Terms of Agreement:
+ To ensure the security of your transaction, this service implements 3D
+ Secure 2.0 identity verification.
+ For the purpose of fraud prevention and authentication, certain personal
+ information (such as your name, email address, phone number, and device
+ information) will be provided to the card issuer and our payment processor.
+ By clicking the "Charge" button, you agree to the processing of your
+ personal information as described above.
+
+
-
\ No newline at end of file
+
diff --git a/modules/weko-records-ui/weko_records_ui/utils.py b/modules/weko-records-ui/weko_records_ui/utils.py
index 8666a6cc2a..7b01def741 100644
--- a/modules/weko-records-ui/weko_records_ui/utils.py
+++ b/modules/weko-records-ui/weko_records_ui/utils.py
@@ -22,6 +22,7 @@
import base64
import orjson
+import pickle
from datetime import datetime as dt
from datetime import timedelta
from decimal import Decimal
@@ -29,11 +30,12 @@
from urllib.parse import quote
from elasticsearch_dsl import Q
-from flask import abort, current_app, request
+from flask import abort, current_app, request, session
from flask_babelex import gettext as _
from flask_babelex import to_utc
+from flask_login import login_user
from flask_security import current_user
-from invenio_accounts.models import Role
+from invenio_accounts.models import Role, User
from invenio_cache import current_cache
from invenio_db import db
from invenio_i18n.ext import current_i18n
@@ -52,6 +54,7 @@
from weko_records.serializers.utils import get_mapping
from weko_records.utils import replace_fqdn
from weko_records_ui.models import InstitutionName
+from weko_redis.redis import RedisConnection
from weko_schema_ui.models import PublishStatus
from weko_workflow.api import WorkActivity, WorkFlow
@@ -92,9 +95,9 @@ def check_items_settings(settings=None):
if isinstance(settings,dict):
if 'items_display_email' in settings:
current_app.config['EMAIL_DISPLAY_FLG'] = settings['items_display_email']
- if 'items_search_author' in settings:
+ if 'items_search_author' in settings:
current_app.config['ITEM_SEARCH_FLG'] = settings['items_search_author']
- if 'item_display_open_date' in settings:
+ if 'item_display_open_date' in settings:
current_app.config['OPEN_DATE_DISPLAY_FLG'] = \
settings['item_display_open_date']
else:
@@ -232,10 +235,10 @@ def is_open_access(record: Dict, file_name: str) -> bool:
Args:
record (dict): item's meta data
file_name (str): target file name
-
+
Returns:
bool: open access item or not
-
+
"""
from weko_records_ui.permissions import check_publish_status
target_index_list = record['path']
@@ -256,7 +259,7 @@ def is_open_access(record: Dict, file_name: str) -> bool:
return True
if access_role == 'open_date':
if file.get('date') and file.get('date')[0] and file.get('date')[0].get('dateValue'):
- if dt.strptime(file.get('date')[0].get('dateValue'),
+ if dt.strptime(file.get('date')[0].get('dateValue'),
'%Y-%m-%d').date() <= dt.now().date():
return True
return False
@@ -433,7 +436,7 @@ def get_license_pdf(license, item_metadata_json, pdf, file_item_id, footer_w,
# current_app.logger.debug("footer_h:{}".format(footer_h))
# current_app.logger.debug("cc_logo_xposition:{}".format(cc_logo_xposition))
# current_app.logger.debug("item:{}".format(item))
-
+
from .views import blueprint
license_icon_pdf_location = \
current_app.config['WEKO_RECORDS_UI_LICENSE_ICON_PDF_LOCATION']
@@ -469,7 +472,7 @@ def get_pair_value(name_keys, lang_keys, datas):
current_app.logger.debug("name_keys:{}".format(name_keys))
current_app.logger.debug("lang_keys:{}".format(lang_keys))
current_app.logger.debug("datas:{}".format(datas))
-
+
if len(name_keys) == 1 and len(lang_keys) == 1:
if isinstance(datas, list):
for data in datas:
@@ -509,7 +512,7 @@ def hide_item_metadata(record, settings=None, item_type_mapping=None,
record['item_type_id'], item_type_mapping, item_type_data
)
record = hide_by_itemtype(record, list_hidden)
-
+
hide_email = hide_meta_data_for_role(record)
if hide_email:
# Hidden owners_ext.email
@@ -518,7 +521,7 @@ def hide_item_metadata(record, settings=None, item_type_mapping=None,
del record['_deposit']['owners_ext']['email']
if hide_email and not current_app.config['EMAIL_DISPLAY_FLG']:
- record = hide_by_email(record)
+ record = hide_by_email(record, True)
record = hide_by_file(record)
@@ -539,7 +542,7 @@ def hide_item_metadata_email_only(record):
check_items_settings()
record['weko_creator_id'] = record.get('owner')
-
+
hide_email = hide_meta_data_for_role(record)
if hide_email:
# Hidden owners_ext.email
@@ -548,7 +551,7 @@ def hide_item_metadata_email_only(record):
del record['_deposit']['owners_ext']['email']
if hide_email and not current_app.config['EMAIL_DISPLAY_FLG']:
- record = hide_by_email(record)
+ record = hide_by_email(record, True)
return True
record.pop('weko_creator_id')
@@ -579,6 +582,7 @@ def hide_by_email(item_metadata, force_flag=False):
"""Hiding emails.
:param item_metadata:
+ :param force_flag: force to hide
:return:
"""
from weko_items_ui.utils import get_options_and_order_list, get_hide_list_by_schema_form
@@ -586,15 +590,13 @@ def hide_by_email(item_metadata, force_flag=False):
subitem_keys = current_app.config['WEKO_RECORDS_UI_EMAIL_ITEM_KEYS']
item_type_id = item_metadata.get('item_type_id')
-
if item_type_id:
meta_options, type_mapping = get_options_and_order_list(item_type_id)
hide_list = get_hide_list_by_schema_form(item_type_id)
-
# Hidden owners_ext info
if item_metadata.get('_deposit') and item_metadata['_deposit'].get('owners_ext'):
- del item_metadata['_deposit']['owners_ext']
-
+ if force_flag or not show_email_flag:
+ del item_metadata['_deposit']['owners_ext']
for item in item_metadata:
_item = item_metadata[item]
prop_hidden = meta_options.get(item, {}).get('option', {}).get('hidden', False)
@@ -656,44 +658,6 @@ def item_setting_show_email():
is_display = False
return is_display
-def is_show_email_of_creator(item_type_id):
- """Check setting show/hide email for 'Detail' and 'PDF Cover Page' screen.
-
- :param item_type_id: item type id of current record.
- :return: True/False, True: show, False: hide.
- """
- def get_creator_id(item_type_id):
- type_mapping = Mapping.get_record(item_type_id)
- item_map = get_mapping(type_mapping, "jpcoar_mapping")
- creator = 'creator.creatorName.@value'
- creator_id = None
- if creator in item_map:
- creator_id = item_map[creator].split('.')[0]
- return creator_id
-
- def item_type_show_email(item_type_id):
- # Get flag of creator's email hide from item type.
- creator_id = get_creator_id(item_type_id)
- if not creator_id:
- return None
- item_type = ItemTypes.get_by_id(item_type_id)
- schema_editor = item_type.render.get('schemaeditor', {})
- schema = schema_editor.get('schema', {})
- creator = schema.get(creator_id)
- if not creator:
- return None
- properties = creator.get('properties', {})
- creator_mails = properties.get('creatorMails', {})
- items = creator_mails.get('items', {})
- properties = items.get('properties', {})
- creator_mail = properties.get('creatorMail', {})
- is_hide = creator_mail.get('isHide', None)
- return is_hide
-
- is_hide = item_type_show_email(item_type_id)
- is_display = item_setting_show_email()
-
- return not is_hide and is_display
def replace_license_free(record_metadata, is_change_label=True):
"""Change the item name 'licensefree' to 'license_note'.
@@ -813,16 +777,16 @@ def get_data_by_key_array_json(key, array_json, get_key):
for item in array_json:
if str(item.get('id')) == str(key):
return item.get(get_key)
-
+
def is_price_highlight(p_file):
""""Rerturn True if price is highlighted
-
+
Args:
p_file (dict): all metadata of a record.
Returns:
bool: rerturn True if price is highlighted.
-
+
"""
min_price = p_file['min_price']
user_flag = True
@@ -851,7 +815,7 @@ def is_price_highlight(p_file):
priceinfo['has_role'] and min_price == priceinfo['price']:
is_highlight = True
priceinfo['is_highlight'] = is_highlight
-
+
def is_display_purchased(p_file):
""""Remove purchased from roles that do not have min_price
Args:
@@ -1138,7 +1102,7 @@ def generate_one_time_download_url(
:param record_id: File Version ID
:param guest_mail: guest email
:return:
- """
+ """
secret_key = current_app.config['WEKO_RECORDS_UI_SECRET_KEY']
download_pattern = current_app.config[
'WEKO_RECORDS_UI_ONETIME_DOWNLOAD_PATTERN']
@@ -1539,7 +1503,7 @@ def get_google_detaset_meta(record,record_tree=None):
# Required property check
min_length = current_app.config.get('WEKO_RECORDS_UI_GOOGLE_DATASET_DESCRIPTION_MIN',WEKO_RECORDS_UI_GOOGLE_DATASET_DESCRIPTION_MIN)
max_length = current_app.config.get('WEKO_RECORDS_UI_GOOGLE_DATASET_DESCRIPTION_MAX',WEKO_RECORDS_UI_GOOGLE_DATASET_DESCRIPTION_MAX)
-
+
for title in mtdata.findall('dc:title', namespaces=mtdata.nsmap):
res_data['name'] = title.text
for description in mtdata.findall('datacite:description', namespaces=mtdata.nsmap):
@@ -1746,3 +1710,21 @@ def get_billing_role(record: Dict) -> Tuple[str, str]:
min_role = Role.query.get(int(min_price_info.get(billing_role_key)))
return min_role.name, min_price_info.get(billing_price_key, '')
+
+def restore_session_info(session_id: str, redis_connection: RedisConnection) -> None:
+ """Restore session info.
+
+ Args:
+ session_id (str): Session ID
+ redis_connection (RedisConnection): Redis connection
+ """
+ # Get session data
+ session_store = redis_connection.connection(
+ db=current_app.config['ACCOUNTS_SESSION_REDIS_DB_NO'], kv=True)
+ session_data = pickle.loads(session_store.redis.get(session_id))
+ for k, v in session_data.items():
+ session[k] = v
+
+ # Login user
+ user = User.query.filter_by(id=session['user_id']).first()
+ login_user(user)
diff --git a/modules/weko-records-ui/weko_records_ui/views.py b/modules/weko-records-ui/weko_records_ui/views.py
index 07dc0055b4..a5a7043db7 100644
--- a/modules/weko-records-ui/weko_records_ui/views.py
+++ b/modules/weko-records-ui/weko_records_ui/views.py
@@ -45,6 +45,7 @@
from invenio_files_rest.signals import file_downloaded
from invenio_records_ui.utils import obj_or_import_string
from lxml import etree
+from urllib.parse import urljoin
from weko_accounts.views import _redirect_method
from weko_admin.models import AdminSettings
from weko_admin.utils import get_search_setting
@@ -58,6 +59,7 @@
from weko_records.serializers.utils import get_mapping
from weko_records.utils import custom_record_medata_for_export, \
remove_weko2_special_character, selected_value_by_language
+from weko_redis.redis import RedisConnection
from weko_schema_ui.models import PublishStatus
from weko_workflow.api import WorkFlow
@@ -69,11 +71,11 @@
from .permissions import check_content_clickable, check_created_id, \
check_file_download_permission, check_original_pdf_download_permission, \
check_permission_period, file_permission_factory, get_permission, \
- check_charge, create_charge, close_charge
+ check_charge, create_charge, close_charge, secure_charge
from .utils import get_billing_file_download_permission, \
get_google_detaset_meta, get_google_scholar_meta, get_groups_price, \
get_min_price_billing_file_download, get_record_permalink, hide_by_email, \
- is_show_email_of_creator,hide_by_itemtype
+ hide_by_itemtype, restore_session_info
from .utils import restore as restore_imp
from .utils import soft_delete as soft_delete_imp
@@ -283,8 +285,8 @@ def check_file_permission(record, fjson):
Args:
record (weko_deposit.api.WekoRecord): _description_
fjson (dict): _description_
-
- """
+
+ """
return check_file_download_permission(record, fjson)
@@ -368,21 +370,22 @@ def default_view_method(pid, record, filename=None, template=None, **kwargs):
:param kwargs: Additional view arguments based on URL rule.
:returns: The rendered template.
"""
- def _get_rights_title(result, rights_key, rights_values, current_lang, meta_options):
+ def _get_rights_title(result, rights_key_str, rights_values, current_lang, meta_options):
"""Get multi-lang rights title."""
- item_key = rights_key.split('.')[0]
- if item_key in meta_options:
- if meta_options[item_key].get('title'):
- item_title = meta_options[item_key]['title']
- if meta_options[item_key]['title_i18n'].get(current_lang, None):
- item_title = meta_options[item_key]['title_i18n'][current_lang]
- elif meta_options[item_key]['title_i18n'].get('en', None):
- item_title = meta_options[item_key]['title_i18n']['en']
- if rights_values:
- result[item_key] = {
- 'item_title': item_title,
- 'item_values': rights_values
- }
+ for rights_key in rights_key_str.split(','):
+ item_key = rights_key.split('.')[0]
+ if item_key in meta_options:
+ if meta_options[item_key].get('title'):
+ item_title = meta_options[item_key]['title']
+ if meta_options[item_key]['title_i18n'].get(current_lang, None):
+ item_title = meta_options[item_key]['title_i18n'][current_lang]
+ elif meta_options[item_key]['title_i18n'].get('en', None):
+ item_title = meta_options[item_key]['title_i18n']['en']
+ if rights_values:
+ result[item_key] = {
+ 'item_title': item_title,
+ 'item_values': rights_values
+ }
# Check file permision if request is File Information page.
file_order = int(request.args.get("file_order", -1))
@@ -449,7 +452,7 @@ def _get_rights_title(result, rights_key, rights_values, current_lang, meta_opti
if hasattr(current_user, 'site_license_flag') else False
send_info['site_license_name'] = current_user.site_license_name \
if hasattr(current_user, 'site_license_name') else ''
-
+
record_viewed.send(
current_app._get_current_object(),
pid=pid,
@@ -478,7 +481,7 @@ def _get_rights_title(result, rights_key, rights_values, current_lang, meta_opti
record["relation"] = res
else:
record["relation"] = {}
-
+
recstr = etree.tostring(
getrecord(
identifier=record['_oai'].get('id'),
@@ -489,48 +492,81 @@ def _get_rights_title(result, rights_key, rights_values, current_lang, meta_opti
et=etree.fromstring(recstr)
google_scholar_meta = get_google_scholar_meta(record,record_tree=et)
google_dataset_meta = get_google_detaset_meta(record,record_tree=et)
-
+
current_lang = current_i18n.language \
if hasattr(current_i18n, 'language') else None
# get title name
- from weko_records.utils import get_options_and_order_list
from weko_search_ui.utils import get_data_by_property
- from weko_records.utils import get_options_and_order_list
+ from weko_items_ui.utils import get_options_and_order_list, get_hide_list_by_schema_form
+ from weko_workflow.utils import get_sub_item_value
+
title_name = ''
rights_values = {}
accessRight = ''
- solst, meta_options = get_options_and_order_list(
+ meta_options, item_type_mapping = get_options_and_order_list(
record.get('item_type_id'))
- item_type_mapping = Mapping.get_record(record.get('item_type_id'))
- item_map = get_mapping(item_type_mapping, 'jpcoar_mapping')
- suffixes = '.@attributes.xml:lang'
- for key in item_map:
- prefix = key.replace(suffixes, '')
- if prefix == 'title' and key.find(suffixes) != -1:
+ hide_list = get_hide_list_by_schema_form(record.get('item_type_id'))
+ item_map = get_mapping(record.get('item_type_id'), 'jpcoar_mapping')
+
+ # get title info
+ title_value_key = 'title.@value'
+ title_lang_key = 'title.@attributes.xml:lang'
+ if title_value_key in item_map:
+ title_languages = []
+ _title_key_str = ''
+ if title_lang_key in item_map:
# get language
- title_languages, _title_key = get_data_by_property(
- record, item_map, key)
- # get value
- title_values, _title_key1 = get_data_by_property(
- record, item_map, prefix + '.@value')
- title_name = selected_value_by_language(
- title_languages,
- title_values,
- _title_key,
- _title_key1,
- current_lang,
- record)
- elif key == 'rights.@value':
- _rights_values, _rights_key = get_data_by_property(
- record, item_map, key)
- if _rights_key:
- _get_rights_title(rights_values, _rights_key,
- _rights_values, current_lang, meta_options)
- elif key == 'accessRights.@value':
- accessRights, _access_rights_key = get_data_by_property(
- record, item_map, key)
- if accessRights and len(accessRights) > 0:
- accessRight = accessRights[0]
+ title_languages, _title_key_str = get_data_by_property(
+ record, item_map, title_lang_key)
+ # get value
+ title_values, _title_key1_str = get_data_by_property(
+ record, item_map, title_value_key)
+ title_name = selected_value_by_language(
+ title_languages,
+ title_values,
+ _title_key_str,
+ _title_key1_str,
+ current_lang,
+ record,
+ meta_options,
+ hide_list)
+ # get rights info
+ rights_value_key = 'rights.@value'
+ if rights_value_key in item_map:
+ key_list = item_map.get(rights_value_key)
+ for k in key_list.split(","):
+ subkey_list = k.split('.')
+ _rights_values = []
+ attribute = record.get(subkey_list[0])
+ if attribute:
+ data_result = get_sub_item_value(attribute, subkey_list[-1])
+ if data_result:
+ if isinstance(data_result, list):
+ for value in data_result:
+ _rights_values.append(value)
+ elif isinstance(data_result, str):
+ _rights_values.append(data_result)
+ prop_hidden = meta_options.get(subkey_list[0], {}).get('option', {}).get('hidden', False)
+ if not prop_hidden and (subkey_list[0] not in hide_list or subkey_list[-1] not in hide_list):
+ _get_rights_title(rights_values, k, _rights_values,
+ current_lang, meta_options)
+ # get accessRights info
+ accessRights_value_key = 'accessRights.@value'
+ if accessRights_value_key in item_map:
+ key_list = item_map.get(accessRights_value_key)
+ for k in key_list.split(","):
+ subkey_list = k.split('.')
+ prop_hidden = meta_options.get(subkey_list[0], {}).get('option', {}).get('hidden', False)
+ attribute = record.get(subkey_list[0])
+ if attribute and not prop_hidden and (subkey_list[0] not in hide_list or subkey_list[-1] not in hide_list):
+ data_result = get_sub_item_value(attribute, subkey_list[-1])
+ if data_result:
+ if isinstance(data_result, list) and len(data_result) > 0:
+ accessRight = data_result[0]
+ break
+ elif isinstance(data_result, str):
+ accessRight = data_result
+ break
pdfcoverpage_set_rec = PDFCoverPageSettings.find(1)
# Check if user has the permission to download original pdf file
@@ -563,7 +599,7 @@ def _get_rights_title(result, rights_key, rights_values, current_lang, meta_opti
display_stats = display_setting.get('display_stats')
else:
display_stats = True
-
+
items_display_settings = AdminSettings.get(name='items_display_settings',
dict_to_object=False)
if items_display_settings:
@@ -605,12 +641,9 @@ def _get_rights_title(result, rights_key, rights_values, current_lang, meta_opti
# Hide email of creator in pdf cover page
if record.get('item_type_id'):
item_type_id = record['item_type_id']
- is_show_email = is_show_email_of_creator(item_type_id)
- if not is_show_email:
- # list_hidden = get_ignore_item(record['item_type_id'])
- # record = hide_by_itemtype(record, list_hidden)
- record = hide_by_email(record)
-
+
+ record = hide_by_email(record, False)
+
# Remove hide item
from weko_items_ui.utils import get_ignore_item
list_hidden = get_ignore_item(record['item_type_id'])
@@ -687,7 +720,7 @@ def _get_rights_title(result, rights_key, rights_values, current_lang, meta_opti
flg_display_resourcetype = current_app.config.get('WEKO_RECORDS_UI_DISPLAY_RESOURCE_TYPE') ,
search_author_flg=search_author_flg,
billing_settings=billing_settings,
-
+
**ctx,
**kwargs
)
@@ -786,7 +819,7 @@ def handle_over_max_file_size(error):
flash(_('PDF cover page settings have been updated.'),
category='success')
return redirect('/admin/pdfcoverpage')
-
+
return redirect('/admin/pdfcoverpage')
@@ -960,14 +993,14 @@ def get_uri():
"""_summary_
---
post:
- description:
+ description:
requestBody:
required: true
content:
application/json: {"uri":"https://localhost/record/1/files/001.jpg","pid_value":"1","accessrole":"1"}
responses:
200:
- """
+ """
data = request.get_json()
uri = data.get('uri')
pid_value = data.get('pid_value')
@@ -1011,18 +1044,35 @@ def charge():
title : タイトル
price : 支払い金額
- Response parameter(json):
- status :
- success : 課金成功
- already : 課金済み
- error : 課金失敗
- credit_error : 課金失敗(クレジットカード情報の不備)
+ Response parameter
+ json:
+ status:
+ already : 課金済み
+ error : 課金失敗
+ credit_error : 課金失敗(クレジットカード情報の不備)
+ redirect:
+ カード会社の3DS2.0画面へのリダイレクトURL
'''
+ # Get session_id
+ session_id = request.cookies.get('session')
+
item_id = request.values.get('item_id')
file_name = request.values.get('file_name')
title = request.values.get('title')
price = request.values.get('price')
file_url = current_app.config['THEME_SITEURL'] + f'/record/{item_id}/files/{file_name}'
+ ret_url = urljoin(
+ current_app.config['THEME_SITEURL'],
+ url_for('weko_records_ui.charge_secure', session_id=session_id.split('.')[0]),
+ )
+
+ # 課金中のアイテムIDをキャッシュから取得
+ redis_connection = RedisConnection()
+ datastore = redis_connection.connection(db=current_app.config['CACHE_REDIS_DB'], kv=True)
+ cache_key = f'charge_{current_user.id}'
+ if datastore.redis.exists(cache_key):
+ # 課金中だったら課金しない
+ return jsonify({'status': 'error'})
# 課金チェック
try:
@@ -1037,14 +1087,14 @@ def charge():
# 課金予約
try:
- trade_id = create_charge(current_user.id, int(item_id), price, title, file_url)
- if trade_id in ['connection_error', 'api_error']:
+ redirect_url = create_charge(current_user.id, int(item_id), price, title, file_url, ret_url)
+ if redirect_url in ['connection_error', 'api_error']:
# 課金失敗
return jsonify({'status': 'error'})
- if trade_id == 'credit_error':
+ if redirect_url == 'credit_error':
# 課金失敗(クレジットカード情報の不備)
return jsonify({'status': 'credit_error'})
- if trade_id == 'already':
+ if redirect_url == 'already':
# 課金済みだったら課金しない
return jsonify({'status': 'already'})
except Exception as e:
@@ -1052,14 +1102,88 @@ def charge():
current_app.logger.error(e)
return abort(500)
+ if not redirect_url:
+ # 課金失敗
+ return jsonify({'status': 'error'})
+
+ # 課金中のアイテムIDをキャッシュに保存
+ datastore.put(cache_key, str(item_id).encode('utf-8'), ttl_secs=300)
+
+ return jsonify({'redirect_url': redirect_url})
+
+@blueprint.route('/charge/secure/', methods=['POST'])
+def charge_secure(session_id):
+ """3DS2.0認証後の課金処理を行う。
+
+ Request parameter:
+ session_id : セッションID(URLパラメータ)
+ AccessID : 課金予約時に取得したaccess_id(POSTパラメータ)
+
+ Response parameter
+ json:
+ status:
+ success : 課金成功
+ error : 課金失敗
+ """
+ access_id = request.values.get('AccessID')
+ redis_connection = RedisConnection()
+
+ if not current_user.is_authenticated:
+ restore_session_info(session_id, redis_connection)
+
+ # 課金中のアイテムIDをキャッシュから取得
+ datastore = redis_connection.connection(db=current_app.config['CACHE_REDIS_DB'], kv=True)
+ cache_key = f'charge_{current_user.id}'
+ if not datastore.redis.exists(cache_key):
+ return redirect('/')
+
+ item_id = datastore.redis.get(cache_key).decode('utf-8')
+ redirect_url = '/records/{}'.format(item_id)
+ datastore.delete(cache_key)
+
+ # 3DS2.0認証後決済
+ try:
+ trade_id = secure_charge(current_user.id, access_id)
+ if trade_id in ['connection_error', 'api_error']:
+ # 課金失敗
+ return redirect(redirect_url)
+ except Exception as e:
+ current_app.logger.error(f'Error in secure_charge: user: {current_user.id}, access_id: {access_id}')
+ current_app.logger.error(e)
+ return abort(500)
+
# 課金確定
- try:
- charge_result = close_charge(current_user.id, trade_id)
- if charge_result:
+ try:
+ close_charge(current_user.id, trade_id)
+ return redirect(redirect_url)
+ except Exception as e:
+ current_app.logger.error(f'Error in close_charge: user: {current_user.id}, trade_id: {trade_id}')
+ current_app.logger.error(e)
+ return abort(500)
+
+@blueprint.route('/charge/show', methods=['GET'])
+def charge_show():
+ """課金済みかどうかを確認する。
+
+ Request parameter:
+ item_id : アイテムID
+
+ Response parameter
+ json:
+ status:
+ success : 課金済み
+ error : 課金失敗
+ """
+ item_id = request.values.get('item_id')
+ # 課金チェック
+ try:
+ charge_result = check_charge(current_user.id, int(item_id))
+ if charge_result == 'already':
+ # 課金済みの場合、課金成功
return jsonify({'status': 'success'})
else:
return jsonify({'status': 'error'})
except Exception as e:
- current_app.logger.error(f'Error in close_charge: user: {current_user.id}, trade_id: {trade_id}')
+ current_app.logger.error(f'Error in check_charge: user: {current_user.id}, item_id: {item_id}')
current_app.logger.error(e)
return abort(500)
diff --git a/modules/weko-records/tests/data/get_mapping.json b/modules/weko-records/tests/data/get_mapping.json
index 98130aca07..526ae7c3f7 100644
--- a/modules/weko-records/tests/data/get_mapping.json
+++ b/modules/weko-records/tests/data/get_mapping.json
@@ -8,8 +8,8 @@
"system_file.extent.@value": "system_file.subitem_systemfile_size",
"system_file.version.@value": "system_file.subitem_systemfile_version",
"system_file.mimeType.@value": "system_file.subitem_systemfile_mimetype",
- "title.@value": "item_15512643084872.subitem_15512556472252",
- "title.@attributes.xml:lang": "item_15512643084872.subitem_1551255648112",
+ "title.@value": "item_1551264308487.subitem_1551255647225,item_15512643084872.subitem_15512556472252",
+ "title.@attributes.xml:lang": "item_1551264308487.subitem_1551255648112,item_15512643084872.subitem_1551255648112",
"alternative.@value": "item_1551264326373.subitem_1551255720400",
"alternative.@attributes.xml:lang": "item_1551264326373.subitem_1551255721061",
"creator.givenName.@value": "item_1551264340087.subitem_1551255991424.subitem_1551256006332",
diff --git a/modules/weko-records/tests/data/item_map.json b/modules/weko-records/tests/data/item_map.json
new file mode 100644
index 0000000000..667dc7619e
--- /dev/null
+++ b/modules/weko-records/tests/data/item_map.json
@@ -0,0 +1,35 @@
+{
+ "test1.@value": "item_test1_5.test_value1",
+ "test1.@attributes.xml:lang": "item_test1_5.test_item_lang1",
+ "test1_2.@value": "item_test1_2",
+ "test1_2.@attributes.xml:lang": "item_test1_2.test_item_lang1",
+ "test1_3.@value": "item_test1_3.test_value1",
+ "test1_3.@attributes.test": "item_test1_3",
+ "test1_4.@value": "item_test1_4.test_value1",
+ "test1_4.@attributes.test": "item_test1_4",
+ "title.@value": "item_test2_title.test_title",
+ "title.@attributes.xml:lang": "item_test2_title.test_title_lang",
+ "file.URI.@value": "item_test3_file.url.url",
+ "file.URI.@attributes.label": "item_test3_file.url.label",
+ "file.URI.@attributes.objectType": "item_test3_file.url.objectType",
+ "file.mimeType.@value": "item_test3_file.format",
+ "type.@value": "item_resource_type.resourcetype",
+ "type.@attributes.rdf:resource": "item_resource_type.resourceuri",
+ "description.@value": "item_description.subitem_description_value",
+ "description.@attributes.xml:lang": "item_description.subitem_description_lang",
+ "date.@value": "item_date.subitem_date_value",
+ "date.@attributes.dateType": "item_date.subitem_date_type",
+ "publisher.@value": "item_publisher.subitem_publisher",
+ "publisher.@attributes.xml:lang": "item_publisher.subitem_publisherLang",
+ "creator.creatorName.@value": "item_test5_creator.creatorNames.creatorName",
+ "creator.creatorName.@attributes.xml:lang": "item_test5_creator.creatorName.creatorNameLang",
+ "issue": "item_test6_bibliographic.bibliographic_issue",
+ "volume": "item_test6_bibliographic.bibliographic_volume",
+ "pageStart": "item_test6_bibliographic.bibliographic_pageStart",
+ "pageEnd": "item_test6_bibliographic.bibliographic_pageEnd",
+ "sourceTitle.@value": "item_test6_bibliographic.bibliographic_titles.bibliographic_title",
+ "sourceTitle.@attributes.xml:lang": "item_test6_bibliographic.bibliographic_titles.bibliographic_titleLang",
+ "system_file.URI.@value": "system_file.subitem_systemfile_filename_uri",
+ "system_file.URI.@attributes.label": "system_file.subitem_systemfile_filename_label",
+ "system_file.URI.@attributes.objectType": "system_file.subitem_systemfile_filename_type"
+}
diff --git a/modules/weko-records/tests/data/meta00.json b/modules/weko-records/tests/data/meta00.json
index 83a1b2db24..dce1a98b51 100644
--- a/modules/weko-records/tests/data/meta00.json
+++ b/modules/weko-records/tests/data/meta00.json
@@ -25,7 +25,11 @@
{
"subitem_1551255905565": "\u4f5c\u8005",
"subitem_1551255907416": "ja"
- }
+ },
+ {
+ "subitem_1551255905565": "Creator",
+ "subitem_1551255907416": "en"
+ }
]
}
]
@@ -183,4 +187,4 @@
"item_type_id": "12",
"control_number": "870"
}
-]
\ No newline at end of file
+]
diff --git a/modules/weko-records/tests/test_api.py b/modules/weko-records/tests/test_api.py
index 25805ef46d..16fff0afa7 100644
--- a/modules/weko-records/tests/test_api.py
+++ b/modules/weko-records/tests/test_api.py
@@ -76,14 +76,14 @@ def __init__(self, id, version_id, created, updated):
assert result["created"] == "yesterday"
assert result["updated"] == "now"
assert record.validate(validator=Draft4Validator)==None
-
+
schema = {
'type': 'object',
'properties': {
'id': { 'type': 'integer' },
'version_id': { 'type': 'integer' },
'created': {'type': 'string' },
- 'updated': { 'type': 'string' },
+ 'updated': { 'type': 'string' },
},
'required': ['id']
}
@@ -98,7 +98,7 @@ def __init__(self, id, version_id, created, updated):
test_model.__getitem__.side_effect = data.__getitem__
record = RecordBase(data)
record.model = test_model
- assert record.validate(validator=Draft4Validator) == None
+ assert record.validate(validator=Draft4Validator) == None
assert record.replace_refs()=={'id': 1, 'version_id': 10, 'created': 'yesterday', 'updated': 'now', '$schema': {'type': 'object', 'properties': {'id': {'type': 'integer'}, 'version_id': {'type': 'integer'}, 'created': {'type': 'string'}, 'updated': {'type': 'string'}}, 'required': ['id']}}
# class ItemTypeNames(RecordBase):
@@ -362,7 +362,7 @@ def all():
filter_magicmock.all = all
return filter_magicmock
-
+
def myfilter_2(item):
def all_2():
all2_magicmock = MagicMock()
@@ -401,7 +401,7 @@ def all_2():
result=item_type,
schema=_schema
) != None
-
+
with patch("weko_records.api.db.session.query", return_value=data1):
assert test.update_item_type(
form=_form,
@@ -851,7 +851,7 @@ def test_itemtypes_restore(app, db):
# def revisions(self):
def test_revision_ItemTypes(app):
test = ItemTypes(data={})
-
+
# Exception coverage
try:
test.revisions()
@@ -859,7 +859,7 @@ def test_revision_ItemTypes(app):
pass
test.model = True
-
+
with patch('weko_records.api.RevisionsIterator', return_value=MagicMock()):
assert test.revisions() != None
@@ -1275,7 +1275,7 @@ def all_func():
all_magicmock = MagicMock()
all_magicmock.id = 1
return [all_magicmock]
-
+
data1.query = MagicMock()
data1.query.filter_by = MagicMock()
data1.query.filter_by.all = all_func
@@ -1391,7 +1391,7 @@ def test_item_metadata_revert(app, db):
# def revisions(self):
def test_revision_ItemsMetadata(app):
test = ItemsMetadata(data={})
-
+
# Exception coverage
try:
test.revisions()
@@ -1427,7 +1427,7 @@ def test_files_metadata_create(app, db):
def test_files_metadata_get_record(app, db):
FilesMetadata.create(data={'data': 'test'}, pid=1, con=bytes('test content', 'utf-8'))
FilesMetadata.create(data={})
-
+
record = FilesMetadata.get_record(1)
assert record.id==1
assert record.model.pid==1
@@ -1469,7 +1469,7 @@ def test_files_metadata_get_records(app, db):
# def patch(self, patch):
def test_patch_FilesMetadata(app):
test = FilesMetadata(data={})
-
+
with patch("weko_records.api.apply_patch", return_value=""):
test.patch(patch="test")
@@ -1555,7 +1555,7 @@ def test_files_metadata_revert(app, db):
# def revisions(self):
def test_revision_FilesMetadata(app):
test = FilesMetadata(data={})
-
+
# Exception coverage
try:
test.revisions()
@@ -1563,7 +1563,7 @@ def test_revision_FilesMetadata(app):
pass
test.model = True
-
+
with patch('weko_records.api.RevisionsIterator', return_value=MagicMock()):
assert test.revisions() != None
@@ -1668,7 +1668,7 @@ def get_func(item1, item2):
# def depid(self):
def test_depid_WekoRecord(app):
test = WekoRecord(data={})
-
+
with patch('weko_records.api.PersistentIdentifier', return_value=True):
assert test.depid() != None
diff --git a/modules/weko-records/tests/test_serializers_dc.py b/modules/weko-records/tests/test_serializers_dc.py
index 70fd8a517b..da6285a221 100644
--- a/modules/weko-records/tests/test_serializers_dc.py
+++ b/modules/weko-records/tests/test_serializers_dc.py
@@ -1,10 +1,42 @@
import pytest
+from lxml import etree
from mock import patch, MagicMock
-from weko_records.serializers.dc import DcWekoEntryExtension
+from weko_records.serializers.dc import DcWekoBaseExtension, DcWekoEntryExtension
+# .tox/c1/bin/pytest --cov=weko_records tests/test_serializers_dc.py::test_dc_creator -v -s -vv --cov-branch --cov-report=term --cov-report=html --cov-config=tox.ini --basetemp=/code/modules/weko-records/.tox/c1/tmp
+# class DcWekoBaseExtension(JSONSerializer):
+# def dc_creator
+def test_dc_creator(app):
+ test = DcWekoBaseExtension()
+ # creator: None, lang: None
+ assert test.dc_creator() is None
-# class DcWekoEntryExtension(JSONSerializer):
+ # creator: str, lang: None
+ result = test.dc_creator(creator="creator1")
+ assert result == ["creator1"]
+
+ # creator: list, lang: None
+ result = test.dc_creator(creator=["creator2", "creator3"], replace=True)
+ assert result == ["creator2", "creator3"]
+
+ # creator: str, lang: str
+ result = test.dc_creator(creator="creator4", lang="ja", replace=True)
+ assert result == ["creator4"]
+ assert test._dcelem_creator_lang == ["ja"]
+
+ # creator: str, lang: list
+ result = test.dc_creator(creator="creator5", lang=["en"], replace=True)
+ assert result == ["creator5"]
+ assert test._dcelem_creator_lang == ["en"]
+
+ # creator: list, lang: list, replace=False(既存値に追加されることを確認)
+ result = test.dc_creator(creator=["creator6", "creator7"], lang=["de", "it"], replace=False)
+ assert result == ["creator5", "creator6", "creator7"]
+ assert test._dcelem_creator_lang == ["en", "de", "it"]
+
+
+# class DcWekoEntryExtension(JSONSerializer):
# def extend_atom
def test_extend_atom(app):
test = DcWekoEntryExtension()
@@ -30,4 +62,35 @@ def _extend_xml(item):
assert test.extend_jpcoar(
item=item
- ) != None
\ No newline at end of file
+ ) != None
+
+# .tox/c1/bin/pytest --cov=weko_records tests/test_serializers_dc.py::test__extend_xml -v -s -vv --cov-branch --cov-report=term --cov-report=html --cov-config=tox.ini --basetemp=/code/modules/weko-records/.tox/c1/tmp
+# class DcWekoEntryExtension(JSONSerializer):
+# def _extend_xml
+def test__extend_xml(app):
+ ext = DcWekoBaseExtension()
+ ext._dcelem_title = ["title1"]
+ ext._dcelem_creator_lang = ["ja"]
+ ext._dcelem_creator = ["creator1", "creator2"]
+ ext._dcelem_publisher = ["publisher1"]
+ del ext._dcelem_rights
+ del ext._dcelem_publisher_lang
+
+ item = etree.Element('item')
+ ext._extend_xml(item)
+
+ titles = item.findall("{http://purl.org/dc/elements/1.1/}title")
+ assert len(titles) == 1
+ assert titles[0].text == "title1"
+
+ creators = item.findall("{http://purl.org/dc/elements/1.1/}creator")
+ assert len(creators) == 2
+ assert creators[0].text == "creator1"
+ assert creators[0].get("{http://www.w3.org/XML/1998/namespace}lang") == "ja"
+ assert creators[1].text == "creator2"
+ assert creators[1].get("{http://www.w3.org/XML/1998/namespace}lang") is None
+
+ publishers = item.findall("{http://purl.org/dc/elements/1.1/}publisher")
+ assert len(publishers) == 1
+ assert publishers[0].text == "publisher1"
+ assert publishers[0].get("{http://www.w3.org/XML/1998/namespace}lang") is None
diff --git a/modules/weko-records/tests/test_serializers_utils.py b/modules/weko-records/tests/test_serializers_utils.py
index 1d3a7ee655..1e4c11ab53 100644
--- a/modules/weko-records/tests/test_serializers_utils.py
+++ b/modules/weko-records/tests/test_serializers_utils.py
@@ -1,8 +1,7 @@
import pytest
-import uuid
-import json
-import base64
import copy
+from flask import request
+from urllib.parse import urlencode
from lxml import etree
from tests.helpers import json_data
from mock import patch, MagicMock
@@ -25,11 +24,17 @@
# def get_mapping(item_type_mapping, mapping_type):
# .tox/c1/bin/pytest --cov=weko_records tests/test_serializers_utils.py::test_get_mapping -v -s -vv --cov-branch --cov-report=term --cov-config=tox.ini --basetemp=/code/modules/weko-records/.tox/c1/tmp
-def test_get_mapping():
+def test_get_mapping(app):
mapping = json_data("data/item_type_mapping.json")
- result = get_mapping(mapping, 'jpcoar_mapping')
- data = json_data("data/get_mapping.json")
- assert result == data
+ item_type_list = list(mapping.keys())
+ item_type_list.append("dummy")
+ mock_return = MagicMock()
+ mock_return.render.get.return_value = item_type_list
+ with patch("weko_records.api.Mapping.get_record", return_value=mapping), \
+ patch("weko_records.api.ItemTypes.get_by_id", return_value=mock_return):
+ result = get_mapping("item_type_id", "jpcoar_mapping")
+ data = json_data("data/get_mapping.json")
+ assert result == data
# def get_full_mapping(item_type_mapping, mapping_type):
# .tox/c1/bin/pytest --cov=weko_records tests/test_serializers_utils.py::test_get_full_mapping -v -s -vv --cov-branch --cov-report=term --cov-config=tox.ini --basetemp=/code/modules/weko-records/.tox/c1/tmp
@@ -160,121 +165,123 @@ def test_get_wekolog_2(db, record2):
True)]
@pytest.mark.parametrize("render, form, mapping, hit, licence", params)
def test_open_search_detail_data(app, db, db_index, record1, render, form, mapping, hit, licence):
- def fetcher(obj_uuid, data):
- assert obj_uuid=="1"
- return PersistentIdentifier(pid_type='recid', pid_value=data['pid'])
- _item_type_name=ItemTypeName(name="test")
- _item_type = ItemTypes.create(
- name="test",
- item_type_name=_item_type_name,
- schema=json_data("data/item_type/item_type_schema.json"),
- render=json_data(render),
- form=json_data(form),
- tag=1
- )
- Mapping.create(
- item_type_id=_item_type.id,
- mapping=json_data(mapping)
- )
- _data = {
- 'lang': 'en',
- 'log_term': '2021-01'
- }
- hit_data = json_data(hit)
- hit_data['_id'] = record1[0].object_uuid
- _search_result = {'hits': {'total': 1, 'hits': [hit_data]}}
- detail = OpenSearchDetailData(fetcher, _search_result, 'rss')
- with app.test_request_context(headers=[('Accept-Language','en')], query_string=_data):
- res = detail.output_open_search_detail_data()
- res = res.decode('utf-8')
- cnt = 1 if res.find('wekolog:terms') else 0
- cnt += 1 if res.find('wekolog:view') else 0
- cnt += 1 if res.find('wekolog:download') else 0
- assert True if cnt == 3 else False
-
- _data = {
- 'lang': 'en',
- 'index_id': "1"
- }
- hit_data1 = copy.deepcopy(hit_data)
- hit_data1['_source']['_item_metadata']['pubdate']['attribute_value'] = ""
- _search_result = {'hits': {'total': 1, 'hits': [hit_data1]}}
- detail = OpenSearchDetailData(fetcher, _search_result, 'rss')
- with app.test_request_context(headers=[('Accept-Language','en')], query_string=_data):
- res = detail.output_open_search_detail_data()
- res = res.decode('utf-8')
- cnt = 1 if res.find('wekolog:terms') == -1 else 0
- cnt += 1 if res.find('wekolog:view') == -1 else 0
- cnt += 1 if res.find('wekolog:download') == -1 else 0
- assert True if cnt == 3 else False
-
- _search_result = {'hits': {'total': 0, 'hits': []}}
- data = OpenSearchDetailData(fetcher, _search_result, 'rss')
- with app.test_request_context():
- assert data.output_open_search_detail_data()
-
- # test for atom
- _data = {
- 'lang': 'en',
- 'index_id': 1,
- }
- _search_result = {'hits': {'total': 2, 'hits': [hit_data, hit_data]}}
- data = OpenSearchDetailData(fetcher, _search_result, 'atom')
- with app.test_request_context(headers=[('Accept-Language','en')], query_string=_data):
- assert data.output_open_search_detail_data()
- with patch("weko_records.api.Mapping.get_record", return_value=dict()):
- assert data.output_open_search_detail_data()
- with patch("weko_records.serializers.utils.get_metadata_from_map", return_value=None):
- assert data.output_open_search_detail_data()
+ with patch("weko_records.serializers.utils.get_mapping", return_value=json_data("data/item_map.json")):
+ def fetcher(obj_uuid, data):
+ assert obj_uuid=="1"
+ return PersistentIdentifier(pid_type='recid', pid_value=data['pid'])
+ _item_type_name=ItemTypeName(name="test")
+ _item_type = ItemTypes.create(
+ name="test",
+ item_type_name=_item_type_name,
+ schema=json_data("data/item_type/item_type_schema.json"),
+ render=json_data(render),
+ form=json_data(form),
+ tag=1
+ )
+ Mapping.create(
+ item_type_id=_item_type.id,
+ mapping=json_data(mapping)
+ )
+ _data = {
+ 'lang': 'en',
+ 'log_term': '2021-01'
+ }
- hit_data2 = json_data("data/record_hit/record_hit1_2.json")
- _search_result = {'hits': {'total': 1, 'hits': [hit_data2]}}
- data = OpenSearchDetailData(fetcher, _search_result, 'atom')
- with app.test_request_context(headers=[('Accept-Language','en')], query_string=_data):
- assert data.output_open_search_detail_data()
-
- hit_data3 = copy.deepcopy(hit_data)
- hit_data3['_source']['_item_metadata'] = {
- "item_type_id":"1",
- "control_number": "1",
- "item_title":"Test title",
- }
- _search_result = {'hits': {'total': 1, 'hits': [hit_data3]}}
- data = OpenSearchDetailData(fetcher, _search_result, 'atom')
- with app.test_request_context(headers=[('Accept-Language','en')], query_string=_data):
- assert data.output_open_search_detail_data()
-
- _data = {
- 'lang': 'ja',
- 'index_id': "aaa",
- 'idx': "bbb",
- }
- hit_data4 = copy.deepcopy(hit_data)
- hit_data4['_source']['_item_metadata']['path'] = ["9999"]
- _search_result = {'hits': {'total': 1, 'hits': [hit_data4]}}
- data = OpenSearchDetailData(fetcher, _search_result, 'atom')
- with app.test_request_context(headers=[('Accept-Language','ja')], query_string=_data):
- assert data.output_open_search_detail_data()
-
- # test for atom with Yhandle
- _data = {
- 'lang': 'ja',
- 'index_id': "1",
- 'idx': "bbb",
- }
- _search_result = {'hits': {'total': 1, 'hits': [hit_data]}}
- data = OpenSearchDetailData(fetcher, _search_result, 'atom')
- with app.test_request_context(headers=[('Accept-Language','ja')], query_string=_data):
- with patch("invenio_pidstore.models.PersistentIdentifier.get_by_object", return_value=PersistentIdentifier(pid_type='yhdl', pid_value="http://test.com/1000/00000001/")):
- res = data.output_open_search_detail_data()
+ hit_data = json_data(hit)
+ hit_data['_id'] = record1[0].object_uuid
+ _search_result = {'hits': {'total': 1, 'hits': [hit_data]}}
+ detail = OpenSearchDetailData(fetcher, _search_result, 'rss')
+ with app.test_request_context(headers=[('Accept-Language','en')], query_string=_data):
+ res = detail.output_open_search_detail_data()
res = res.decode('utf-8')
- assert res.find('') > 0
- _data['index_id'] = "aaa"
- with app.test_request_context(headers=[('Accept-Language','ja')], query_string=_data):
- with patch("invenio_pidstore.models.PersistentIdentifier.get_by_object", return_value=PersistentIdentifier(pid_type='yhdl', pid_value="http://test.com/1000/00000001")):
- res = data.output_open_search_detail_data()
+ cnt = 1 if res.find('wekolog:terms') else 0
+ cnt += 1 if res.find('wekolog:view') else 0
+ cnt += 1 if res.find('wekolog:download') else 0
+ assert True if cnt == 3 else False
+
+ _data = {
+ 'lang': 'en',
+ 'index_id': "1"
+ }
+ hit_data1 = copy.deepcopy(hit_data)
+ hit_data1['_source']['_item_metadata']['pubdate']['attribute_value'] = ""
+ _search_result = {'hits': {'total': 1, 'hits': [hit_data1]}}
+ detail = OpenSearchDetailData(fetcher, _search_result, 'rss')
+ with app.test_request_context(headers=[('Accept-Language','en')], query_string=_data):
+ res = detail.output_open_search_detail_data()
res = res.decode('utf-8')
- assert res.find('') > 0
+ cnt = 1 if res.find('wekolog:terms') == -1 else 0
+ cnt += 1 if res.find('wekolog:view') == -1 else 0
+ cnt += 1 if res.find('wekolog:download') == -1 else 0
+ assert True if cnt == 3 else False
+
+ _search_result = {'hits': {'total': 0, 'hits': []}}
+ data = OpenSearchDetailData(fetcher, _search_result, 'rss')
+ with app.test_request_context():
+ assert data.output_open_search_detail_data()
+
+ # test for atom
+ _data = {
+ 'lang': 'en',
+ 'index_id': 1,
+ }
+ _search_result = {'hits': {'total': 2, 'hits': [hit_data, hit_data]}}
+ data = OpenSearchDetailData(fetcher, _search_result, 'atom')
+ with app.test_request_context(headers=[('Accept-Language','en')], query_string=_data):
+ assert data.output_open_search_detail_data()
+ with patch("weko_records.api.Mapping.get_record", return_value=dict()):
+ assert data.output_open_search_detail_data()
+ with patch("weko_records.serializers.utils.get_metadata_from_map", return_value=None):
+ assert data.output_open_search_detail_data()
+
+ hit_data2 = json_data("data/record_hit/record_hit1_2.json")
+ _search_result = {'hits': {'total': 1, 'hits': [hit_data2]}}
+ data = OpenSearchDetailData(fetcher, _search_result, 'atom')
+ with app.test_request_context(headers=[('Accept-Language','en')], query_string=_data):
+ assert data.output_open_search_detail_data()
+
+ hit_data3 = copy.deepcopy(hit_data)
+ hit_data3['_source']['_item_metadata'] = {
+ "item_type_id":"1",
+ "control_number": "1",
+ "item_title":"Test title",
+ }
+ _search_result = {'hits': {'total': 1, 'hits': [hit_data3]}}
+ data = OpenSearchDetailData(fetcher, _search_result, 'atom')
+ with app.test_request_context(headers=[('Accept-Language','en')], query_string=_data):
+ assert data.output_open_search_detail_data()
+
+ _data = {
+ 'lang': 'ja',
+ 'index_id': "aaa",
+ 'idx': "bbb",
+ }
+ hit_data4 = copy.deepcopy(hit_data)
+ hit_data4['_source']['_item_metadata']['path'] = ["9999"]
+ _search_result = {'hits': {'total': 1, 'hits': [hit_data4]}}
+ data = OpenSearchDetailData(fetcher, _search_result, 'atom')
+ with app.test_request_context(headers=[('Accept-Language','ja')], query_string=_data):
+ assert data.output_open_search_detail_data()
+
+ # test for atom with Yhandle
+ _data = {
+ 'lang': 'ja',
+ 'index_id': "1",
+ 'idx': "bbb",
+ }
+ _search_result = {'hits': {'total': 1, 'hits': [hit_data]}}
+ data = OpenSearchDetailData(fetcher, _search_result, 'atom')
+ with app.test_request_context(headers=[('Accept-Language','ja')], query_string=_data):
+ with patch("invenio_pidstore.models.PersistentIdentifier.get_by_object", return_value=PersistentIdentifier(pid_type='yhdl', pid_value="http://test.com/1000/00000001/")):
+ res = data.output_open_search_detail_data()
+ res = res.decode('utf-8')
+ assert res.find('') > 0
+ _data['index_id'] = "aaa"
+ with app.test_request_context(headers=[('Accept-Language','ja')], query_string=_data):
+ with patch("invenio_pidstore.models.PersistentIdentifier.get_by_object", return_value=PersistentIdentifier(pid_type='yhdl', pid_value="http://test.com/1000/00000001")):
+ res = data.output_open_search_detail_data()
+ res = res.decode('utf-8')
+ assert res.find('') > 0
sample = OpenSearchDetailData(
@@ -287,7 +294,7 @@ def fetcher(obj_uuid, data):
)
# class OpenSearchDetailData:
-# def output_open_search_detail_data(self):
+# def output_open_search_detail_data(self):
# .tox/c1/bin/pytest --cov=weko_records tests/test_serializers_utils.py::test_output_open_search_detail_data -v -s -vv --cov-branch --cov-report=term --cov-config=tox.ini --basetemp=/code/modules/weko-records/.tox/c1/tmp
def test_output_open_search_detail_data(app):
item_map = {
@@ -421,10 +428,10 @@ def test__set_publication_date(app):
with patch("weko_records.serializers.utils.get_metadata_from_map", return_value=["date"]):
sample_copy._set_publication_date(fe=fe, item_map=item_map, item_metadata=item_metadata)
-
+
with patch("weko_records.serializers.utils.get_metadata_from_map", return_value={"date.@value": "date.@value"}):
sample_copy._set_publication_date(fe=fe, item_map=item_map, item_metadata=item_metadata)
-
+
with patch("weko_records.serializers.utils.get_metadata_from_map", return_value={"date.@value": ["date.@value"]}):
sample_copy._set_publication_date(fe=fe, item_map=item_map, item_metadata=item_metadata)
@@ -446,7 +453,7 @@ def test__set_publication_date(app):
with patch("weko_records.serializers.utils.get_metadata_from_map", return_value=data2):
sample_copy._set_publication_date(fe=fe, item_map=item_map, item_metadata=item_metadata)
-
+
# def _set_source_identifier(self, fe, item_map, item_metadata):
def test__set_source_identifier(app):
@@ -456,7 +463,7 @@ def test__set_source_identifier(app):
def issn(item):
return item
-
+
fe.prism.issn = issn
item_map = {
@@ -485,14 +492,14 @@ def issn(item):
with patch("weko_records.serializers.utils.get_metadata_from_map", return_value=item_metadata):
assert sample_copy._set_source_identifier(fe=fe, item_map=item_map, item_metadata=item_metadata) == None
-
+
item_metadata["sourceIdentifier"] = [
"sourceIdentifier"
]
with patch("weko_records.serializers.utils.get_metadata_from_map", return_value=item_metadata):
assert sample_copy._set_source_identifier(fe=fe, item_map=item_map, item_metadata=item_metadata) == None
-
+
sample_copy.output_type = "not_atom"
item_metadata["sourceIdentifier"] = "ISSN"
@@ -503,8 +510,8 @@ def issn(item):
item_metadata["sourceIdentifier"] = ["ISSN"]
assert sample_copy._set_source_identifier(fe=fe, item_map=item_map, item_metadata=item_metadata) == None
-
+# .tox/c1/bin/pytest --cov=weko_records tests/test_serializers_utils.py::test__set_author_info -v -s -vv --cov-branch --cov-report=term --cov-report=html --cov-config=tox.ini --basetemp=/code/modules/weko-records/.tox/c1/tmp
# def _set_author_info(self, fe, item_map, item_metadata, request_lang):
def test__set_author_info(app):
sample_copy = copy.deepcopy(sample)
@@ -540,8 +547,156 @@ def test__set_author_info(app):
assert sample_copy._set_author_info(fe=fe, item_map=item_map, item_metadata=item_metadata, request_lang=request_lang) == None
+ # output_typeがRSSでget_pair_valueが複数値を返し、request_langが一致する場合
+ sample_copy = copy.deepcopy(sample)
+ sample_copy.output_type = sample_copy.OUTPUT_RSS
+ fe = MagicMock()
+ fe.dc = MagicMock()
+ item_map = {"creator.creatorName.@value": "creator.creatorName"}
+ item_metadata = {"creator": {"attribute_value_mlt": []}}
+ # get_pair_valueが2件返し、request_langが'en'の場合
+ with patch("weko_records_ui.utils.get_pair_value", return_value=[("Taro", "en"), ("Jiro", "ja")]):
+ sample_copy._set_author_info(fe=fe, item_map=item_map, item_metadata=item_metadata, request_lang="en")
+ fe.dc.dc_creator.assert_called_once_with("Taro", "en")
+ # 'ja'は呼ばれない
+ calls = [call[0] for call in fe.dc.dc_creator.call_args_list]
+ assert ("Jiro", "ja") not in calls
+
+ # 異常系テスト
+
+ # 1. item_mapに'creator.creatorName.@value'がない場合
+ fe = MagicMock()
+ fe.dc = MagicMock()
+ fe.author = MagicMock()
+ item_map = {}
+ item_metadata = {}
+ assert sample_copy._set_author_info(fe=fe, item_map=item_map, item_metadata=item_metadata, request_lang="en") is None
+ fe.dc.dc_creator.assert_not_called()
+ fe.author.assert_not_called()
+
+ # 2. item_idがitem_metadataにない場合
+ fe = MagicMock()
+ fe.dc = MagicMock()
+ fe.author = MagicMock()
+ item_map = {"creator.creatorName.@value": "notfound.creatorName"}
+ item_metadata = {}
+ assert sample_copy._set_author_info(fe=fe, item_map=item_map, item_metadata=item_metadata, request_lang="en") is None
+ fe.dc.dc_creator.assert_not_called()
+ fe.author.assert_not_called()
+
+ # 3. RSS分岐: get_pair_valueが空リスト
+ fe = MagicMock()
+ fe.dc = MagicMock()
+ sample_copy.output_type = sample_copy.OUTPUT_RSS
+ item_map = {"creator.creatorName.@value": "creator.creatorName"}
+ item_metadata = {"creator": {"attribute_value_mlt": []}}
+ with patch("weko_records_ui.utils.get_pair_value", return_value=[]):
+ assert sample_copy._set_author_info(fe=fe, item_map=item_map, item_metadata=item_metadata, request_lang="en") is None
+ fe.dc.dc_creator.assert_not_called()
+
+ # 4. RSS形式でdc_creator_dataに言語情報が無い場合
+ fe = MagicMock()
+ fe.dc = MagicMock()
+ sample_copy.output_type = sample_copy.OUTPUT_RSS
+ item_map = {"creator.creatorName.@value": "creator.creatorName"}
+ item_metadata = {"creator": {"attribute_value_mlt": []}}
+ # get_pair_valueが言語情報なし(None, 空文字)を返す場合
+ with patch("weko_records_ui.utils.get_pair_value", return_value=[("Taro", None), ("Jiro", "")]):
+ sample_copy._set_author_info(fe=fe, item_map=item_map, item_metadata=item_metadata, request_lang="en")
+ fe.dc.dc_creator.assert_not_called()
+
+ # 5. RSS分岐: get_pair_valueが値あり、request_langなし
+ fe = MagicMock()
+ fe.dc = MagicMock()
+ with patch("weko_records_ui.utils.get_pair_value", return_value=[("Taro", "ja")]):
+ assert sample_copy._set_author_info(fe=fe, item_map=item_map, item_metadata=item_metadata, request_lang=None) is None
+ fe.dc.dc_creator.assert_called_with("Taro", "ja")
+
+ # 6. ATOM分岐: get_metadata_from_mapがNone
+ fe = MagicMock()
+ fe.dc = MagicMock()
+ fe.author = MagicMock()
+ sample_copy.output_type = sample_copy.OUTPUT_ATOM
+ item_map = {"creator.creatorName.@value": "creator.creatorName"}
+ item_metadata = {"creator": {}}
+ with patch("weko_records.serializers.utils.get_metadata_from_map", return_value=None):
+ assert sample_copy._set_author_info(fe=fe, item_map=item_map, item_metadata=item_metadata, request_lang="en") is None
+ fe.author.assert_not_called()
+
+ # 7. ATOM分岐: creator_metadata.get(create_name_key)がNone
+ fe = MagicMock()
+ fe.dc = MagicMock()
+ fe.author = MagicMock()
+ with patch("weko_records.serializers.utils.get_metadata_from_map", return_value={}):
+ assert sample_copy._set_author_info(fe=fe, item_map=item_map, item_metadata=item_metadata, request_lang="en") is None
+ fe.author.assert_not_called()
+
+ # 8. ATOM分岐: creator_name_langsがリストでrequest_lang一致
+ fe = MagicMock()
+ fe.dc = MagicMock()
+ fe.author = MagicMock()
+ creator_metadata = {
+ "creator.creatorName": ["Taro", "Jiro"],
+ "creator.creatorNames.creatorNameLang": ["en", "ja"]
+ }
+ with patch("weko_records.serializers.utils.get_metadata_from_map", return_value=creator_metadata):
+ assert sample_copy._set_author_info(fe=fe, item_map=item_map, item_metadata={"creator": {}}, request_lang="en") is None
+ fe.author.assert_any_call({'name': "Taro", 'lang': "en"})
+
+ # 9. ATOM分岐: creator_name_langsが単一値
+ fe = MagicMock()
+ fe.dc = MagicMock()
+ fe.author = MagicMock()
+ creator_metadata = {
+ "creator.creatorName": "Taro",
+ "creator.creatorNames.creatorNameLang": "en"
+ }
+ with patch("weko_records.serializers.utils.get_metadata_from_map", return_value=creator_metadata):
+ assert sample_copy._set_author_info(fe=fe, item_map=item_map, item_metadata={"creator": {}}, request_lang="en") is None
+ fe.author.assert_any_call({'name': "Taro", 'lang': "en"})
+
+ # 10. ATOM分岐: creator_name_langsが単一値でrequest_lang一致しない場合
+ fe = MagicMock()
+ fe.dc = MagicMock()
+ fe.author = MagicMock()
+ creator_metadata = {
+ "creator.creatorName": "Taro",
+ "creator.creatorNames.creatorNameLang": "en"
+ }
+ with patch("weko_records.serializers.utils.get_metadata_from_map", return_value=creator_metadata):
+ assert sample_copy._set_author_info(fe=fe, item_map=item_map, item_metadata={"creator": {}}, request_lang="ja") is None
+ fe.author.assert_not_called()
+
+ # 11. ATOM分岐: creator_name_langsがリストでrequest_langが無い場合
+ fe = MagicMock()
+ fe.dc = MagicMock()
+ fe.author = MagicMock()
+ creator_metadata = {
+ "creator.creatorName": ["Taro", "Jiro"],
+ "creator.creatorNames.creatorNameLang": ["en", "ja"]
+ }
+ with patch("weko_records.serializers.utils.get_metadata_from_map", return_value=creator_metadata):
+ assert sample_copy._set_author_info(fe=fe, item_map=item_map, item_metadata={"creator": {}}, request_lang=None) is None
+ fe.author.assert_any_call({'name': "Taro", 'lang': "en"})
+ fe.author.assert_any_call({'name': "Jiro", 'lang': "ja"})
+ assert fe.author.call_count == 2
+
+ # 12. ATOM分岐: creator_name_langsが単一値でrequest_langが無い場合
+ fe = MagicMock()
+ fe.dc = MagicMock()
+ fe.author = MagicMock()
+ creator_metadata = {
+ "creator.creatorName": "Taro",
+ "creator.creatorNames.creatorNameLang": "en"
+ }
+ with patch("weko_records.serializers.utils.get_metadata_from_map", return_value=creator_metadata):
+ assert sample_copy._set_author_info(fe=fe, item_map=item_map, item_metadata={"creator": {}}, request_lang=None) is None
+ fe.author.assert_any_call({'name': "Taro", 'lang': "en"})
+ assert fe.author.call_count == 1
+
+
-# def _set_publisher(self, fe, item_map, item_metadata, request_lang):
+# def _set_publisher(self, fe, item_map, item_metadata, request_lang):
def test__set_publisher(app):
sample_copy = copy.deepcopy(sample)
fe = MagicMock()
diff --git a/modules/weko-records/tests/test_utils.py b/modules/weko-records/tests/test_utils.py
index 3244c6eac1..8c014f0866 100644
--- a/modules/weko-records/tests/test_utils.py
+++ b/modules/weko-records/tests/test_utils.py
@@ -443,8 +443,8 @@ def test_get_all_items(admin_settings,roles):
# 55
role_name = 'role_name'
_nlst2 = [
- {'billing': ['billing_file'],
- 'priceinfo': [{'tax': 'include_tax', 'price': '110', 'billingrole': role_name, 'has_role': True}],
+ {'billing': ['billing_file'],
+ 'priceinfo': [{'tax': 'include_tax', 'price': '110', 'billingrole': role_name, 'has_role': True}],
}
]
_klst2 = [
@@ -458,8 +458,8 @@ def test_get_all_items(admin_settings,roles):
role_name = '6'
_nlst2 = [
- {'billing': ['billing_file'],
- 'priceinfo': [{'tax': 'include_tax', 'price': '110', 'billingrole': role_name, 'has_role': True}],
+ {'billing': ['billing_file'],
+ 'priceinfo': [{'tax': 'include_tax', 'price': '110', 'billingrole': role_name, 'has_role': True}],
}
]
res2 = get_all_items(_nlst2, _klst2)
@@ -684,7 +684,7 @@ async def test_sort_meta_data_by_options_sample_1(i18n_app, db, admin_settings):
mapping={}
)
settings = AdminSettings.get("items_display_settings")
-
+
data1 = {
"key1.@attributes.xml:lang": "test",
}
@@ -710,7 +710,7 @@ async def test_sort_meta_data_by_options_sample_1(i18n_app, db, admin_settings):
"meta_list_9999": "meta_list_9999",
}
}
-
+
with patch("weko_records.serializers.utils.get_mapping", return_value=data1):
with patch("weko_search_ui.utils.get_data_by_property", return_value=("1", "2")):
await sort_meta_data_by_options(record_hit,settings,item_type_mapping,item_type)
@@ -832,7 +832,7 @@ async def test_sort_meta_data_by_options_sample_1(i18n_app, db, admin_settings):
"meta_list": {
"meta_list_9999": "meta_list_9999",
}
- }
+ }
await sort_meta_data_by_options(
record_hit=record_hit_2,
@@ -1147,17 +1147,45 @@ def test_selected_value_by_language(app, meta):
_val_id = 'item_1551264308487.subitem_1551255647225'
res = selected_value_by_language(['ja', 'en'], ['タイトル日本語', 'Title'], _lang_id, _val_id, 'en', meta[0])
assert res=='Title'
+
app.config['WEKO_RECORDS_UI_LANG_DISP_FLG'] = False
_lang_id = 'item_1551264340087.subitem_1551255898956.subitem_1551255907416'
_val_id = 'item_1551264340087.subitem_1551255898956.subitem_1551255905565'
res = selected_value_by_language(['ja'], ['作者'], _lang_id, _val_id, 'en', meta[0])
assert res=='作者'
+
app.config['WEKO_RECORDS_UI_LANG_DISP_FLG'] = True
res = selected_value_by_language(['en'], ['Creator'], _lang_id, _val_id, 'en', meta[0])
assert res=='Creator'
+ res = selected_value_by_language(['en'], ['Creator'], _lang_id, _val_id, 'en', meta[0],{},['item_1551264340087.subitem_1551255898956.subitem_1551255905565','dummy'])
+ assert res == None
+ res = selected_value_by_language([], ['Creator'], _lang_id, _val_id, 'ja', meta[0])
+ assert res == '作者'
+
with patch("weko_records.utils.check_info_in_metadata", return_value="en"):
res = selected_value_by_language(["ja-Latn"], ['ja-Latn'], _lang_id, _val_id, 'en', meta[0])
assert res=='en'
+ with patch("weko_records.utils.check_info_in_metadata", side_effect=[None, "expected"]):
+ res = selected_value_by_language(['en'], ['Creator'], _lang_id, _val_id, 'en', meta[0])
+ assert res=="expected"
+ with patch("weko_records.utils.check_info_in_metadata", side_effect=[None, "expected"]):
+ res = selected_value_by_language(['ja-Latn'], ['Creator'], _lang_id, _val_id, 'en', meta[0])
+ assert res=="expected"
+ with patch("weko_records.utils.check_info_in_metadata", side_effect=[None, None, None, None, None]):
+ res = selected_value_by_language(['en'], ['Creator'], _lang_id, _val_id, 'en', meta[0])
+ assert res==None
+ with patch("weko_records.utils.check_info_in_metadata", side_effect=[None, None]):
+ res = selected_value_by_language(['ja'], ['Creator'], _lang_id, _val_id, 'en', meta[0])
+ assert res==None
+ with patch("weko_records.utils.check_info_in_metadata", side_effect=[None, None]):
+ res = selected_value_by_language([''], ['Creator'], _lang_id, _val_id, 'en', meta[0])
+ assert res==None
+
+ _lang_id = 'item_1551264308487.subitem_1551255648112'
+ _val_id = 'item_1551264340087.subitem_1551255898956.subitem_1551255905565'
+ res = selected_value_by_language(['en'], ['Creator'], _lang_id, _val_id, 'en', meta[0])
+ assert res == '作者'
+
# .tox/c1/bin/pytest --cov=weko_records tests/test_utils.py::test_selected_value_by_language_2 -v -s -vv --cov-branch --cov-report=term --cov-config=tox.ini --basetemp=/code/modules/weko-records/.tox/c1/tmp
def test_selected_value_by_language_2(app, meta):
@@ -1176,20 +1204,11 @@ def test_selected_value_by_language_3(app):
res = selected_value_by_language(["en"], ['title_with_nolang','title_en'], _lang_id, _val_id, 'ja', meta)
assert res!='title_en'
assert res=='title_with_nolang'
-
with patch("weko_records.utils.check_info_in_metadata", return_value="en"):
res = selected_value_by_language(["ja-Latn"], ['ja-Latn'], _lang_id, _val_id, 'en', meta)
assert res=='en'
-def test_selected_value_by_language_2(app, meta):
- _lang_id = 'item_1551264308487.subitem_15512556481122'
- _val_id = 'item_1551264308487.subitem_15512556472252'
-
- with patch("weko_records.utils.check_info_in_metadata", return_value="en"):
- res = selected_value_by_language(["en"], ['ja'], _lang_id, _val_id, 'ja', meta[0])
- assert res=='en'
-
# def check_info_in_metadata(str_key_lang, str_key_val, str_lang, metadata):
# .tox/c1/bin/pytest --cov=weko_records tests/test_utils.py::test_check_info_in_metadata -v -s -vv --cov-branch --cov-report=term --cov-config=tox.ini --basetemp=/code/modules/weko-records/.tox/c1/tmp
def test_check_info_in_metadata(app, meta):
@@ -1206,6 +1225,23 @@ def test_check_info_in_metadata(app, meta):
_str_key_val = 'item_1551264418667.subitem_1551257245638.subitem_1551257276108'
res = check_info_in_metadata(_str_key_lang, _str_key_val, 'en', meta[0])
assert res=='Contributor'
+ _str_key_lang = 'item_30002_title0.subitem_title_language'
+ _str_key_val = 'item_30002_title0.subitem_title'
+ _lang = 'ja'
+ _meta = {'path': ['1623632832836'], 'pubdate': '2024-12-26', 'item_30002_title0': {'subitem_title': 'title', 'subitem_title_language': 'ja'}, 'item_30002_resource_type13': {'resourcetype': 'conference paper', 'resourceuri': 'http://purl.org/coar/resource_type/c_5794'}, 'item_30002_file35': [{'filename': '日本語.png'}], 'item_1735223788720': {'subitem_thumbnail': [{'thumbnail_label': 'jdcat.jsps.go.jp_about.png', 'thumbnail_url': '/api/files/d88a107f-c3a7-4ad6-81ca-4c34691682d1/jdcat.jsps.go.jp_about.png?versionId=37ad1676-9099-4f82-ba7a-35ef4f325b39'}]}}
+ res = check_info_in_metadata(_str_key_lang, _str_key_val, _lang, _meta)
+ assert res is not None
+ assert res=='title'
+ _str_key_lang = 'item_30002_title0.subitem_title_language'
+ _str_key_val = 'item_30002_title0.subitem_title'
+ _lang = 'ja'
+ _meta = {'path': ['1623632832836'], 'pubdate': '2024-12-26', 'item_30002_title0': [{'subitem_title': 'title', 'subitem_title_language': 'ja'}], 'item_30002_resource_type13': {'resourcetype': 'conference paper', 'resourceuri': 'http://purl.org/coar/resource_type/c_5794'}, 'item_30002_file35': [{'filename': '日本語.png'}], 'item_1735223788720': {'subitem_thumbnail': [{'thumbnail_label': 'jdcat.jsps.go.jp_about.png', 'thumbnail_url': '/api/files/d88a107f-c3a7-4ad6-81ca-4c34691682d1/jdcat.jsps.go.jp_about.png?versionId=37ad1676-9099-4f82-ba7a-35ef4f325b39'}]}}
+ res = check_info_in_metadata(_str_key_lang, _str_key_val, _lang, _meta)
+ assert res=='title'
+
+
+
+
# def get_value_and_lang_by_key(key, data_json, data_result, stt_key):
# .tox/c1/bin/pytest --cov=weko_records tests/test_utils.py::test_get_value_and_lang_by_key -v -s -vv --cov-branch --cov-report=term --cov-config=tox.ini --basetemp=/code/modules/weko-records/.tox/c1/tmp
@@ -1299,7 +1335,7 @@ def test_get_value_by_selected_lang(app):
res = get_value_by_selected_lang(_source_title3, 'en')
assert res=='no_lang_test'
-
+
# def get_show_list_author(solst_dict_array, hide_email_flag, author_key, creates):
# .tox/c1/bin/pytest --cov=weko_records tests/test_utils.py::test_get_show_list_author -v -s -vv --cov-branch --cov-report=term --cov-config=tox.ini --basetemp=/code/modules/weko-records/.tox/c1/tmp
@@ -1443,7 +1479,7 @@ def test_format_creates(i18n_app):
}]
}]
_hide_creator_keys = ['familyNames']
-
+
res = format_creates(_creates, _hide_creator_keys)
assert res==[{'creatorName': ['en_name'], 'affiliationName': ['en_af'], 'creatorAlternative': ['en_al']}]
@@ -1566,13 +1602,13 @@ def test_get_author_has_language(app):
]
res = get_author_has_language(_create, {}, 'en', ['affiliationName', 'af_lang'])
assert res=={'affiliationName': ['en_af']}
-
+
res = get_author_has_language(_create, {}, 'fr', ['affiliationName', 'af_lang'])
assert res=={'affiliationName': ['en_af']}
-
+
res = get_author_has_language(_create, {}, 'en', ['affiliationName', 'af_lang2'])
assert res=={'affiliationName': ['en_af']}
-
+
res = get_author_has_language(_create, {}, 'en', ['affiliationName2', 'af_lang2'])
assert res=={}
@@ -1586,7 +1622,7 @@ def test_add_author(app):
_data = {'creatorName': 'test1'}
_s1 = {'key': 'item_1.names[].creatorName'}
_s2 = {'key': 'item_1.ids[].nameIdentifier'}
-
+
stt_key, data_result, newline_array = add_author(_data, [], [], _s1, 'value1', {}, False, False, True)
assert stt_key==['creatorName']
assert data_result=={'creatorName': {'creatorName': {'value': 'test1'}}}
@@ -1635,7 +1671,7 @@ def test_convert_bibliographic():
assert res2=='key name1, key name2, key name3'
-# def add_biographic(sys_bibliographic, bibliographic_key, s, stt_key, data_result,
+# def add_biographic(sys_bibliographic, bibliographic_key, s, stt_key, data_result,
def test_add_biographic(app):
def get_bibliographic_list(x):
return x
@@ -1704,7 +1740,7 @@ def test_replace_fqdn_of_file_metadata(app):
'version_id': '1'
}
]
-
+
_file_url = []
replace_fqdn_of_file_metadata(_file_metadata_list1)
assert _file_metadata_list1==[{'url': {'url': 'http://test/a'}}, {'url': {'url': 'http://test/b'}}]
@@ -1712,4 +1748,3 @@ def test_replace_fqdn_of_file_metadata(app):
assert _file_url==['http://test/a', 'http://test/b']
replace_fqdn_of_file_metadata(_file_metadata_list2)
assert _file_metadata_list2==[{'url': {'url': 'https://localhost/a'}, 'version_id': '1'}, {'url': {'url': 'https://localhost/b'}, 'version_id': '1'}]
-
\ No newline at end of file
diff --git a/modules/weko-records/weko_records/api.py b/modules/weko-records/weko_records/api.py
index 8e696ec46e..eba50da64a 100644
--- a/modules/weko-records/weko_records/api.py
+++ b/modules/weko-records/weko_records/api.py
@@ -465,7 +465,7 @@ def __get_delete_mapping_key(item_type_mapping, _delete_list):
result = []
for key in _delete_list:
prop_mapping = item_type_mapping.get(key, {}).get("jpcoar_mapping", {})
- if prop_mapping:
+ if prop_mapping and isinstance(prop_mapping, dict):
result.extend(list(prop_mapping.keys()))
return result
diff --git a/modules/weko-records/weko_records/serializers/dc.py b/modules/weko-records/weko_records/serializers/dc.py
index dc4f8b5699..1eba5e2346 100644
--- a/modules/weko-records/weko_records/serializers/dc.py
+++ b/modules/weko-records/weko_records/serializers/dc.py
@@ -35,6 +35,8 @@ def __init__(self):
"""__init__."""
self._dcelem_publisher = None
self._dcelem_publisher_lang = None
+ self._dcelem_creator = None
+ self._dcelem_creator_lang = None
super().__init__()
def _extend_xml(self, xml_elem):
@@ -56,7 +58,7 @@ def _extend_xml(self, xml_elem):
node = etree.SubElement(xml_elem,
'{%s}%s' % (DCELEMENTS_NS, elem))
node.text = val
- if elem == 'publisher':
+ if elem == 'publisher' or elem == 'creator':
if hasattr(self, '_dcelem_%s_lang' % elem):
langs = getattr(
self, '_dcelem_%s_lang' %
@@ -90,7 +92,34 @@ def dc_publisher(self, publisher=None, lang=None, replace=False):
self._dcelem_publisher_lang += lang
return self._dcelem_publisher
+
+ def dc_creator(self, creator=None, lang=None, replace=False):
+ """Get or set the dc:creator.
+ Which is an entity responsible for
+ making the resource available.
+ For more information see:
+ http://dublincore.org/documents/dcmi-terms
+ :param creator: Creator or list of creators.
+ :param replace: Replace alredy set creators (deault: False).
+ :returns: List of creators.
+ """
+ if creator is not None:
+ if not isinstance(creator, list):
+ creator = [creator]
+ if replace or not self._dcelem_creator:
+ self._dcelem_creator = []
+ self._dcelem_creator += creator
+
+ if lang is not None:
+ if not isinstance(lang, list):
+ lang = [lang]
+ if replace or not self._dcelem_creator_lang:
+ self._dcelem_creator_lang = []
+ self._dcelem_creator_lang += lang
+
+ return self._dcelem_creator
+
def extend_jpcoar(self, jpcoar_feed):
"""Extend a JPCOAR feed with the set DC fields.
diff --git a/modules/weko-records/weko_records/serializers/utils.py b/modules/weko-records/weko_records/serializers/utils.py
index 4fe1d81504..cc3a459061 100644
--- a/modules/weko-records/weko_records/serializers/utils.py
+++ b/modules/weko-records/weko_records/serializers/utils.py
@@ -24,7 +24,7 @@
from datetime import datetime
import pytz
-from flask import request
+from flask import request, current_app
from invenio_db import db
from invenio_pidstore.models import PersistentIdentifier
from invenio_records.models import RecordMetadata
@@ -32,7 +32,7 @@
from invenio_stats.views import QueryRecordViewCount, QueryFileStatsCount
from weko_index_tree.api import Index
-from weko_records.api import Mapping
+from weko_records.api import Mapping, ItemTypes
from weko_records.models import ItemType, ItemTypeName, ItemTypeProperty
from .dc import DcWekoBaseExtension, DcWekoEntryExtension
@@ -42,11 +42,11 @@
from .wekolog import WekologEntryExtension, WekologExtension
-def get_mapping(item_type_mapping, mapping_type):
+def get_mapping(item_type_id, mapping_type):
"""Format itemtype mapping data.
[Key:Schema, Value:ItemId]
- :param item_type_mapping:
+ :param item_type_id:
:param mapping_type:
:return:
"""
@@ -63,12 +63,18 @@ def get_schema_key_info(schema, parent_key, schema_json={}):
return schema_json
schema = {}
- for item_id, maps in item_type_mapping.items():
- if mapping_type in maps.keys() and isinstance(maps[mapping_type], dict):
- item_schema = get_schema_key_info(maps[mapping_type], '', {})
- for k, v in item_schema.items():
- item_schema[k] = item_id + '.' + v if v else item_id
- schema.update(item_schema)
+ item_type_mapping = Mapping.get_record(item_type_id)
+ item_type_list = ItemTypes.get_by_id(item_type_id).render.get('table_row')
+ for item_id in item_type_list:
+ if item_id in item_type_mapping:
+ maps = item_type_mapping.get(item_id)
+ if isinstance(maps,dict) and mapping_type in maps.keys() and isinstance(maps[mapping_type], dict):
+ item_schema = get_schema_key_info(maps[mapping_type], '', {})
+ for k, v in item_schema.items():
+ if k in schema:
+ schema[k] += ',' + item_id + '.' + v if v else ',' + item_id
+ else:
+ schema[k] = item_id + '.' + v if v else item_id
return schema
@@ -94,6 +100,7 @@ def get_schema_key_info(schema, parent_key, schema_json={}):
return schema_json
schema = {}
+
for item_id, maps in item_type_mapping.items():
if mapping_type in maps.keys() \
and isinstance(maps[mapping_type], dict):
@@ -396,12 +403,11 @@ def output_open_search_detail_data(self):
item_metadata = hit['_source']['_item_metadata']
item_type_id = item_metadata['item_type_id']
- type_mapping = Mapping.get_record(item_type_id)
if item_type_id in jpcoar_map:
item_map = jpcoar_map[item_type_id]
else:
- item_map = get_mapping(type_mapping, 'jpcoar_mapping')
+ item_map = get_mapping(item_type_id, 'jpcoar_mapping')
jpcoar_map[item_type_id] = item_map
fe = fg.add_entry()
@@ -790,99 +796,130 @@ def _set_publisher(self, fe, item_map, item_metadata, request_lang):
publisher_lang)
def _set_source_identifier(self, fe, item_map, item_metadata):
- if self.output_type == self.OUTPUT_ATOM:
- _source_identifier_value = 'sourceIdentifier.@value'
- if _source_identifier_value in item_map:
- source_identifier_key = item_map[_source_identifier_value]
- item_id = source_identifier_key.split('.')[0]
+ """Retrieve the source identifier from
+ the item's metadata and set it in the feedentry.
- # Get item data
- if item_id in item_metadata:
- source_identifier_metadata = get_metadata_from_map(
- item_metadata[item_id], item_id)
-
- if not isinstance(source_identifier_metadata, dict) \
- or source_identifier_metadata.get(
- source_identifier_key) is None:
- return
- source_identifiers = source_identifier_metadata.get(
- source_identifier_key)
-
- if source_identifiers:
- if isinstance(source_identifiers, list):
- for source_identifier in source_identifiers:
- fe.prism.issn(source_identifier)
+ Args:
+ fe(WekoFeedGenerator): feed entry
+ item_map(dict): itemtype mapping
+ item_metadata(dict): item metadata
+ """
+ _source_identifier_value = 'sourceIdentifier.@value'
+ _source_identifier_attr_type = \
+ 'sourceIdentifier.@attributes.identifierType'
+ try:
+ if _source_identifier_value in item_map \
+ and _source_identifier_attr_type in item_map:
+ source_identifier_value_keys = \
+ item_map[_source_identifier_value].split(',')
+ source_identifier_attr_type_keys = \
+ item_map[_source_identifier_attr_type].split(',')
+ for source_identifier_value_key, source_identifier_attr_type_key in zip(
+ source_identifier_value_keys,
+ source_identifier_attr_type_keys
+ ):
+ item_id = source_identifier_value_key.split('.')[0]
+ # Get item data
+ if item_id in item_metadata:
+ source_identifier_metadata = get_metadata_from_map(
+ item_metadata[item_id], item_id)
+ if self.output_type == self.OUTPUT_ATOM:
+ source_identifiers = source_identifier_metadata.get(
+ source_identifier_value_key)
+
+ if source_identifiers:
+ if isinstance(source_identifiers, list):
+ for source_identifier in source_identifiers:
+ fe.prism.issn(source_identifier)
+ else:
+ fe.prism.issn(source_identifiers)
else:
- fe.prism.issn(source_identifiers)
- else:
- _source_identifier_attr_type = \
- 'sourceIdentifier.@attributes.identifierType'
- _source_identifier_value = 'sourceIdentifier.@value'
- if _source_identifier_value in item_map:
- item_id = item_map[_source_identifier_value].split('.')[0]
-
- # Get item data
- if item_id in item_metadata:
- source_identifier_metadata = get_metadata_from_map(
- item_metadata[item_id], item_id)
-
- source_identifiers = source_identifier_metadata[
- item_map[_source_identifier_attr_type]]
-
- source_identifier_types = source_identifier_metadata[
- item_map[_source_identifier_value]]
-
- if source_identifiers:
- if isinstance(source_identifiers, list):
- for i in range(len(source_identifiers)):
- source_identifier_type = \
- source_identifier_types[i]
- if source_identifier_type \
- and source_identifier_type == 'ISSN':
- fe.prism.issn(source_identifiers[i])
-
- elif source_identifier_types \
- and source_identifier_types == 'ISSN':
- fe.prism.issn(source_identifiers)
+ source_identifiers = source_identifier_metadata.get(
+ source_identifier_value_key)
+ source_identifier_types = source_identifier_metadata.get(
+ source_identifier_attr_type_key)
+ if source_identifiers and source_identifier_types:
+ if isinstance(source_identifiers, str):
+ source_identifiers = [source_identifiers]
+ if isinstance(source_identifier_types, str):
+ source_identifier_types = [source_identifier_types]
+ if len(source_identifiers) != len(source_identifier_types):
+ attr = item_metadata.get(item_id).get("attribute_value_mlt")
+ if not attr:
+ continue
+ for a in attr:
+ if a.get(source_identifier_attr_type_key.split('.')[1]) \
+ and a.get(source_identifier_value_key.split('.')[1]):
+ continue
+ value = next(iter(a.values()))
+ if value in source_identifiers:
+ source_identifiers.remove(value)
+ if value in source_identifier_types:
+ source_identifier_types.remove(value)
+ for source_identifier_type, source_identifier in zip(
+ source_identifier_types, source_identifiers
+ ):
+ if source_identifier_type == 'ISSN':
+ fe.prism.issn(source_identifier)
+ except Exception as ex:
+ current_app.logger.error(ex)
def _set_author_info(self, fe, item_map, item_metadata, request_lang):
+ from weko_records_ui.utils import get_pair_value
_creator_name_value = 'creator.creatorName.@value'
if _creator_name_value in item_map:
- item_id = item_map[_creator_name_value].split('.')[0]
-
- # Get item data
- if item_id in item_metadata:
- creator_metadata = get_metadata_from_map(
- item_metadata[item_id], item_id)
-
- create_name_key = item_map[_creator_name_value]
- if not isinstance(creator_metadata, dict) \
- or creator_metadata.get(create_name_key) is None:
- return
-
- creator_names = creator_metadata[create_name_key]
-
- _creator_name_attr_lang = item_id + '.' + 'creatorNameLang'
- creator_name_langs = creator_metadata[
- _creator_name_attr_lang] \
- if _creator_name_attr_lang in creator_metadata else None
-
- if creator_name_langs:
- if isinstance(creator_name_langs, list):
- for i in range(len(creator_name_langs)):
- creator_name_lang = creator_name_langs[i]
+ create_name_keys = item_map[_creator_name_value].split(',')
+ for create_name_key in create_name_keys:
+ item_id = create_name_key.split('.')[0]
+ if item_id not in item_metadata:
+ continue
+
+ _creator_name_attr_lang = item_id + '.creatorNames.creatorNameLang'
+
+ # RSS dc:creator
+ if self.output_type == self.OUTPUT_RSS:
+ dc_creator_data = get_pair_value(
+ create_name_key.split('.')[1:],
+ _creator_name_attr_lang.split('.')[1:],
+ item_metadata[item_id]['attribute_value_mlt']
+ )
+
+ for dc_creator_name, dc_creator_name_lang in dc_creator_data:
+ if dc_creator_name and dc_creator_name_lang:
if request_lang:
- if creator_name_lang == request_lang:
+ if dc_creator_name_lang == request_lang:
+ fe.dc.dc_creator(dc_creator_name, dc_creator_name_lang)
+ else:
+ fe.dc.dc_creator(dc_creator_name, dc_creator_name_lang)
+ else:
+ # Atom author
+ creator_metadata = get_metadata_from_map(
+ item_metadata[item_id], item_id)
+ if not isinstance(creator_metadata, dict) \
+ or creator_metadata.get(create_name_key) is None:
+ continue
+
+ creator_names = creator_metadata[create_name_key]
+ creator_name_langs = creator_metadata[
+ _creator_name_attr_lang] \
+ if _creator_name_attr_lang in creator_metadata else None
+
+ if creator_name_langs:
+ if isinstance(creator_name_langs, list):
+ for i in range(len(creator_name_langs)):
+ creator_name_lang = creator_name_langs[i]
+ if request_lang:
+ if creator_name_lang == request_lang:
+ fe.author({'name': creator_names[i],
+ 'lang': creator_name_lang})
+ else:
fe.author({'name': creator_names[i],
- 'lang': creator_name_lang})
+ 'lang': creator_name_lang})
+ else:
+ if request_lang:
+ if creator_name_langs == request_lang:
+ fe.author({'name': creator_names,
+ 'lang': creator_name_langs})
else:
- fe.author({'name': creator_names[i],
- 'lang': creator_name_lang})
- else:
- if request_lang:
- if creator_name_langs == request_lang:
fe.author({'name': creator_names,
- 'lang': creator_name_langs})
- else:
- fe.author({'name': creator_names,
- 'lang': creator_name_langs})
+ 'lang': creator_name_langs})
diff --git a/modules/weko-records/weko_records/utils.py b/modules/weko-records/weko_records/utils.py
index 156c4d912f..7b1a3e060b 100644
--- a/modules/weko-records/weko_records/utils.py
+++ b/modules/weko-records/weko_records/utils.py
@@ -1059,7 +1059,7 @@ def get_option_value(option_type, parent_option, child_option):
)
return result
-
+
def get_value_by_selected_language(values,lang_key,current_lang):
dict = convert_array_to_dict(values,lang_key)
if dict.get(current_lang):
@@ -1068,7 +1068,7 @@ def get_value_by_selected_language(values,lang_key,current_lang):
return dict.get("None")
elif dict.get("en"):
return dict.get("en")
-
+
def get_creator_comments(key,meta_options,creators,is_hide_email):
"""
TODO: affiliationは未実装
@@ -1081,108 +1081,108 @@ def get_creator_comments(key,meta_options,creators,is_hide_email):
if creator.get("creatorMails"):
opt = dict["{}.{}".format(key,"creatorMails")]
if opt.get('option'):
- _opt = opt.get('option')
+ _opt = opt.get('option')
if (_opt.get('hide') | _opt.get('non_display')|is_hide_email):
creator.pop("creatorMails")
opt = dict["{}.{}.{}".format(key,"creatorMails","creatorMail")]
if opt.get('option'):
- _opt = opt.get('option')
+ _opt = opt.get('option')
if (_opt.get('hide') | _opt.get('non_display')|is_hide_email):
if creator.get("creatorMails"):
creator.pop("creatorMails")
-
+
if creator.get("familyNames"):
opt = dict["{}.{}".format(key,"familyNames")]
if opt.get('option'):
- _opt = opt.get('option')
+ _opt = opt.get('option')
if (_opt.get('hide') | _opt.get('non_display')):
creator.pop("familyNames")
else:
creator["familyNames"] = get_value_by_selected_language(creator["familyNames"],"familyNameLang",current_lang)
opt = dict["{}.{}.{}".format(key,"familyNames","familyName")]
if opt.get('option'):
- _opt = opt.get('option')
+ _opt = opt.get('option')
if (_opt.get('hide') | _opt.get('non_display')):
if creator.get("familyNames"):
creator.pop("familyNames")
-
+
if creator.get("creatorNames"):
opt = dict["{}.{}".format(key,"creatorNames")]
if opt.get('option'):
- _opt = opt.get('option')
+ _opt = opt.get('option')
if (_opt.get('hide') | _opt.get('non_display')):
creator.pop("creatorNames")
else:
creator["creatorNames"] = get_value_by_selected_language(creator["creatorNames"],"creatorNameLang",current_lang)
opt = dict["{}.{}.{}".format(key,"creatorNames","creatorName")]
if opt.get('option'):
- _opt = opt.get('option')
+ _opt = opt.get('option')
if (_opt.get('hide') | _opt.get('non_display')):
if creator.get("creatorNames"):
creator.pop("creatorNames")
-
+
if creator.get("givenNames"):
opt = dict["{}.{}".format(key,"givenNames")]
if opt.get('option'):
- _opt = opt.get('option')
+ _opt = opt.get('option')
if (_opt.get('hide') | _opt.get('non_display')):
creator.pop("givenNames")
else:
creator["givenNames"] = get_value_by_selected_language(creator["givenNames"],"givenNameLang",current_lang)
opt = dict["{}.{}.{}".format(key,"givenNames","givenName")]
if opt.get('option'):
- _opt = opt.get('option')
+ _opt = opt.get('option')
if (_opt.get('hide') | _opt.get('non_display')):
if creator.get("givenNames"):
creator.pop("givenNames")
-
+
if creator.get("nameIdentifiers"):
opt = dict["{}.{}".format(key,"nameIdentifiers")]
if opt.get('option'):
- _opt = opt.get('option')
+ _opt = opt.get('option')
if (_opt.get('hide') | _opt.get('non_display')):
creator.pop("nameIdentifiers")
opt = dict["{}.{}.{}".format(key,"nameIdentifiers","nameIdentifierScheme")]
if opt.get('option'):
- _opt = opt.get('option')
+ _opt = opt.get('option')
if (_opt.get('hide') | _opt.get('non_display')):
if creator.get("nameIdentifiers"):
creator.pop("nameIdentifiers")
-
+
opt = dict["{}.{}.{}".format(key,"nameIdentifiers","nameIdentifierURI")]
if opt.get('option'):
- _opt = opt.get('option')
+ _opt = opt.get('option')
if (_opt.get('hide') | _opt.get('non_display')):
if creator.get("nameIdentifiers"):
creator.pop("nameIdentifiers")
-
+
opt = dict["{}.{}.{}".format(key,"nameIdentifiers","nameIdentifier")]
if opt.get('option'):
- _opt = opt.get('option')
+ _opt = opt.get('option')
if (_opt.get('hide') | _opt.get('non_display')):
if creator.get("nameIdentifiers"):
- creator.pop("nameIdentifiers")
+ creator.pop("nameIdentifiers")
if creator.get("creatorAffiliations"):
opt = dict["{}.{}".format(key,"creatorAffiliations")]
if opt.get('option'):
- _opt = opt.get('option')
+ _opt = opt.get('option')
if (_opt.get('hide') | _opt.get('non_display')):
creator.pop("creatorAffiliations")
-
+
if creator.get("affiliationNameIdentifiers"):
opt = dict["{}.{}".format(key,"affiliationNameIdentifiers")]
if opt.get('option'):
- _opt = opt.get('option')
+ _opt = opt.get('option')
if (_opt.get('hide') | _opt.get('non_display')):
creator.pop("affiliationNameIdentifiers")
-
+
if creator.get("creatorNames") or creator.get("familyNames") or creator.get("givenNames"):
ret.append(creator)
-
+
return ret
-
-
+
+
def get_file_comments(record, files):
"""Check and get file info."""
@@ -1325,56 +1325,45 @@ def get_title_option(solst_dict_array):
item_type_id = record_hit["_source"].get("item_type_id") or src.get(
"item_type_id"
)
- item_map = get_mapping(item_type_mapping, "jpcoar_mapping")
- language_dict = {}
- suffixes = ".@attributes.xml:lang"
- for key in item_map:
- if key.find(suffixes) != -1:
- # get language
- title_languages, _title_key = get_data_by_property(src, item_map, key)
- # get value
- prefix = key.replace(suffixes, "")
- title_values, _title_key1 = get_data_by_property(
- src, item_map, prefix + ".@value"
- )
- language_dict.update(
- {
- prefix: {
- "lang": title_languages,
- "lang-id": _title_key,
- "val": title_values,
- "val-id": _title_key1,
- }
- }
- )
+ item_map = get_mapping(item_type_id, "jpcoar_mapping")
+
# selected title
- title_obj = language_dict.get("title")
- if title_obj is not None:
- lang_arr = title_obj.get("lang")
- val_arr = title_obj.get("val")
- lang_id = title_obj.get("lang-id")
- val_id = title_obj.get("val-id")
- if lang_arr and len(lang_arr) > 0 and lang_arr != "null":
- result = selected_value_by_language(
- lang_arr, val_arr, lang_id, val_id, web_screen_lang, _item_metadata
- )
- if result is not None:
- for idx, val in enumerate(record_hit["_source"]["title"]):
- if val == result:
- arr = []
- record_hit["_source"]["title"][idx] = record_hit["_source"][
- "title"
- ][0]
- record_hit["_source"]["title"][0] = result
- arr.append(result)
- record_hit["_source"]["_comment"] = arr
- break
- elif val_arr and len(val_arr) > 0:
- record_hit["_source"]["_comment"] = [val_arr[0]]
+ from weko_items_ui.utils import get_hide_list_by_schema_form
+ solst, meta_options = get_options_and_order_list(item_type_id, item_type_data)
+ hide_list = get_hide_list_by_schema_form(item_type_id)
+ title_value_key = 'title.@value'
+ title_lang_key = 'title.@attributes.xml:lang'
+ title_languages = []
+ title_values = []
+ _title_key_str = ''
+ _title_key1_str = ''
+ if title_value_key in item_map:
+ if title_lang_key in item_map:
+ # get language
+ title_languages, _title_key_str = get_data_by_property(
+ src, item_map, title_lang_key)
+ # get value
+ title_values, _title_key1_str = get_data_by_property(
+ src, item_map, title_value_key)
+ if title_languages and len(title_languages) > 0:
+ result = selected_value_by_language(
+ title_languages, title_values, _title_key_str, _title_key1_str, web_screen_lang, _item_metadata, meta_options, hide_list
+ )
+ if result is not None:
+ for idx, val in enumerate(record_hit["_source"]["title"]):
+ if val == result:
+ arr = []
+ record_hit["_source"]["title"][idx] = record_hit["_source"]["title"][0]
+ record_hit["_source"]["title"][0] = result
+ arr.append(result)
+ record_hit["_source"]["_comment"] = arr
+ break
+ elif title_values and len(title_values) > 0:
+ record_hit["_source"]["_comment"] = [title_values[0]]
+ record_hit["_source"]["title"][0] = title_values[0]
if not item_type_id:
return
- solst, meta_options = get_options_and_order_list(item_type_id, item_type_data)
solst_dict_array = convert_data_to_dict(solst)
files_info = []
creator_info = {}
@@ -1493,7 +1482,7 @@ def convert_array_to_dict(solst_dict_array,key):
dict['None']['creatorName'] = creator_names
idx=idx+1
return dict
-
+
def get_keywords_data_load(str):
"""Get a json of item type info.
@@ -1966,7 +1955,7 @@ def __remove_special_character(_s_str: str):
def selected_value_by_language(
- lang_array, value_array, lang_id, val_id, lang_selected, _item_metadata
+ lang_array, value_array, lang_key_str, val_key_str, lang_selected, _item_metadata, meta_option={}, hide_list=[]
):
"""Select value by language.
@@ -1976,76 +1965,89 @@ def selected_value_by_language(
@param val_id:
@param lang_selected:
@param _item_metadata:
+ @param meta_option:
+ @param hide_list:
@return:
"""
- if (
- (lang_array is not None)
- and (value_array is not None)
- and isinstance(lang_selected, str)
- ):
- if len(value_array) < 1:
- return None
- else:
- if len(lang_array) > 0:
- for idx, lang in enumerate(lang_array):
- lang_array[idx] = lang.strip()
- if lang_selected in lang_array: # Web screen display language
- value = check_info_in_metadata(
- lang_id, val_id, lang_selected, _item_metadata
- )
- if value is not None:
- return value
-
- if len(value_array)>len(lang_array): # First title without language code
- value0 = value_array[0]
- tmp = copy.copy(value_array)
- for lang in lang_array:
- value = check_info_in_metadata(
- lang_id, val_id, lang, _item_metadata
- )
- if value and value in tmp:
- tmp.remove(value)
- if len(tmp)>0 and tmp[0]==value0:
- return tmp[0]
-
- if "ja-Latn" in lang_array: # ja_Latn
- value = check_info_in_metadata(
- lang_id, val_id, "ja-Latn", _item_metadata
- )
- if value is not None:
- return value
- if "en" in lang_array and (
- lang_selected != "ja"
- or not current_app.config.get("WEKO_RECORDS_UI_LANG_DISP_FLG", False)
- ): # English
- value = check_info_in_metadata(lang_id, val_id, "en", _item_metadata)
- if value is not None:
- return value
- # 1st language when registering items
- if len(lang_array) > 0:
- noreturn = False
- for idx, lg in enumerate(lang_array):
- if current_app.config.get(
- "WEKO_RECORDS_UI_LANG_DISP_FLG", False
- ) and (
- (lg == "ja" and lang_selected == "en")
- or (lg == "en" and lang_selected == "ja")
- ):
- noreturn = True
- break
- if len(lg) > 0:
+ result = None
+ lang_key_list = lang_key_str.split(",")
+ val_key_list = val_key_str.split(",")
+ for val_key in val_key_list:
+ val_parent_key = val_key.split(".")[0]
+ val_sub_key = val_key.split(".")[-1]
+ prop_hidden = meta_option.get(val_parent_key, {}).get('option', {}).get('hidden', False)
+ for h in hide_list:
+ if h.startswith(val_parent_key) and h.endswith(val_sub_key):
+ prop_hidden = True
+ for lang_key in lang_key_list:
+ if val_parent_key == lang_key.split(".")[0]:
+ if (
+ lang_array is not None
+ and (value_array is not None and len(value_array) > 0)
+ and isinstance(lang_selected, str)
+ and not prop_hidden
+ ):
+ if len(lang_array) > 0:
+ for idx, lang in enumerate(lang_array):
+ lang_array[idx] = lang.strip()
+ if lang_selected in lang_array: # Web screen display language
value = check_info_in_metadata(
- lang_id, val_id, lg, _item_metadata
+ lang_key, val_key, lang_selected, _item_metadata
)
if value is not None:
- return value
- if noreturn:
- return None
- # 1st value when registering without language
- if len(value_array) > 0:
- return value_array[0]
- else:
- return None
+ result = value
+
+ if len(value_array)>len(lang_array): # First title without language code
+ result = check_info_in_metadata(lang_key, val_key, None, _item_metadata)
+
+ if not result and "ja-Latn" in lang_array: # ja_Latn
+ value = check_info_in_metadata(
+ lang_key, val_key, "ja-Latn", _item_metadata
+ )
+ if value is not None:
+ result = value
+ if not result and "en" in lang_array and (
+ lang_selected != "ja"
+ or not current_app.config.get("WEKO_RECORDS_UI_LANG_DISP_FLG", False)
+ ): # English
+ value = check_info_in_metadata(lang_key, val_key, "en", _item_metadata)
+ if value is not None:
+ result = value
+ # 1st language when registering items
+ if not result and len(lang_array) > 0:
+ noreturn = False
+ for idx, lg in enumerate(lang_array):
+ if current_app.config.get(
+ "WEKO_RECORDS_UI_LANG_DISP_FLG", False
+ ) and (
+ (lg == "ja" and lang_selected == "en")
+ or (lg == "en" and lang_selected == "ja")
+ ):
+ noreturn = True
+ break
+ if len(lg) > 0:
+ value = check_info_in_metadata(
+ lang_key, val_key, lg, _item_metadata
+ )
+ if value is not None:
+ result = value
+ if noreturn:
+ result = None
+ # 1st value when registering without language
+ if not result and len(value_array) > 0:
+ result = check_info_in_metadata(lang_key, val_key, None, _item_metadata)
+ if not result:
+ break
+ if not result:
+ if (
+ (value_array is not None and len(value_array) > 0)
+ and isinstance(lang_selected, str)
+ and not prop_hidden
+ ):
+ result = check_info_in_metadata('', val_key, None, _item_metadata)
+ if result:
+ break
+ return result
def check_info_in_metadata(str_key_lang, str_key_val, str_lang, metadata):
@@ -2058,8 +2060,7 @@ def check_info_in_metadata(str_key_lang, str_key_val, str_lang, metadata):
@return
"""
if (
- len(str_key_lang) > 0
- and (len(str_lang) > 0 or str_lang is None)
+ (str_lang is None or len(str_lang) > 0)
and len(metadata) > 0
and str_key_val is not None
and len(str_key_val) > 0
@@ -2071,34 +2072,49 @@ def check_info_in_metadata(str_key_lang, str_key_val, str_lang, metadata):
metadata = (
metadata.get("_item_metadata") if "_item_metadata" in metadata else metadata
)
- if str_key_lang[0] in metadata:
- obj = metadata.get(str_key_lang[0]).get("attribute_value_mlt")
+ if str_key_val[0] in metadata:
+ obj = metadata.get(str_key_val[0])
+ if not isinstance(obj,list):
+ obj = obj.get("attribute_value_mlt",obj)
save = obj
- for ob in str_key_lang:
+ for ob in str_key_val:
if (
- ob not in str_key_lang[0]
- and ob not in str_key_lang[len(str_key_lang) - 1]
+ ob not in str_key_val[0]
+ and ob not in str_key_val[len(str_key_val) - 1]
):
for x in save:
if x.get(ob):
save = x.get(ob)
- for s in save:
- if str_lang is None:
- value = s.get(str_key_val[len(str_key_val) - 1]).strip()
- if len(value) > 0:
- return value
- if (
- s
- and isinstance(s, dict)
- and s.get(str_key_lang[-1])
- and s.get(str_key_val[-1])
- ):
+
+ if isinstance(save, list):
+ for s in save:
+ if s is not None and str_lang is None:
+ value = s
+ if isinstance(s,dict):
+ value = s.get(str_key_val[len(str_key_val) - 1]).strip()
+ if len(value) > 0:
+ return value
+
if (
- s.get(str_key_lang[-1]).strip() == str_lang.strip()
- and str_key_val[-1] in s
- and len(s.get(str_key_val[-1]).strip()) > 0
+ s
+ and isinstance(s, dict)
+ and s.get(str_key_lang[-1])
+ and s.get(str_key_val[-1])
):
- return s.get(str_key_val[-1])
+ if (
+ s.get(str_key_lang[-1]).strip() == str_lang.strip()
+ and str_key_val[-1] in s
+ and len(s.get(str_key_val[-1]).strip()) > 0
+ ):
+ return s.get(str_key_val[-1])
+ elif isinstance(save, dict):
+ if (
+ save.get(str_key_lang[-1])
+ and save.get(str_key_val[-1])
+ and save.get(str_key_lang[-1]).strip() == str_lang.strip()
+ ):
+ return save.get(str_key_val[-1])
+
return None
@@ -2187,10 +2203,10 @@ def get_value_by_selected_lang(source_title, current_lang):
if len(title_data_langs_none)>0:
source = list(source_title.values())[0]
- target = list(title_data_langs_none[0].values())[0]
+ target = list(title_data_langs_none[0].values())[0]
if source==target:
return target
-
+
if value_latn:
return value_latn
diff --git a/modules/weko-search-ui/tests/test_utils.py b/modules/weko-search-ui/tests/test_utils.py
index 2854a89508..eae8e1294d 100644
--- a/modules/weko-search-ui/tests/test_utils.py
+++ b/modules/weko-search-ui/tests/test_utils.py
@@ -180,7 +180,7 @@ def test_DefaultOrderDict_deepcopy():
class MockSearchPerm:
def __init__(self):
pass
-
+
def can(self):
return True
# def get_tree_items(index_tree_id): ERROR ~ AttributeError: '_AppCtxGlobals' object has no attribute 'identity'
@@ -1442,232 +1442,51 @@ def test_handle_fill_system_item(app, test_list_records, mocker):
assert items == items_result
-# .tox/c1/bin/pytest --cov=weko_search_ui tests/test_utils.py::test_handle_fill_system_item3 -vv -s --cov-branch --cov-report=term --basetemp=/code/modules/weko-search-ui/.tox/c1/tmp
+# .tox/c1/bin/pytest --cov=weko_search_ui tests/test_utils.py::test_handle_fill_system_item3_id1 -vv -s --cov-branch --cov-report=term --basetemp=/code/modules/weko-search-ui/.tox/c1/tmp
# doi2, doi_ra2 は自動補完が原則
@pytest.mark.parametrize(
- "item_id, before_doi,after_doi,warnings,errors,is_change_identifier,is_register_cnri",
+ "before_doi,after_doi,warnings,errors,is_change_identifier",
[
- (1,{"doi": "xyz.jalc/0000000001","doi_ra":"JaLC","doi2": "xyz.jalc/0000000001","doi_ra2":"JaLC"},{"doi": "xyz.jalc/0000000001","doi_ra":"JaLC","doi2": "xyz.jalc/0000000001","doi_ra2":"JaLC"},[],[],False,False),
- (1,{"doi": "","doi_ra":"", "doi2": "","doi_ra2":""},{"doi": "xyz.jalc/0000000001","doi_ra":"JaLC","doi2": "xyz.jalc/0000000001","doi_ra2":"JaLC"},['The specified DOI is wrong and fixed with the registered DOI.', 'The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],[],False,False),
- (1,{"doi": "xyz.jalc/0000000001","doi_ra":"", "doi2": "","doi_ra2":""},{"doi": "xyz.jalc/0000000001","doi_ra":"JaLC","doi2": None,"doi_ra2":None},['The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],['DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],False,False),
- (1,{"doi": "xyz.jalc/0000000001","doi_ra":"JaLC", "doi2": "","doi_ra2":""},{"doi": "xyz.jalc/0000000001","doi_ra":"JaLC","doi2": "xyz.jalc/0000000001","doi_ra2":"JaLC"},[],[],False,False),
- (1,{"doi": "xyz.jalc/0000000001","doi_ra":"JaLC", "doi2": "xyz.jalc/0000000001","doi_ra2":""},{"doi": "xyz.jalc/0000000001","doi_ra":"JaLC","doi2": "xyz.jalc/0000000001","doi_ra2":"JaLC"},[],[],False,False),
- (1,{"doi": "xyz.jalc/0000000001","doi_ra":"JaLC", "doi2": "","doi_ra2":"JaLC"},{"doi": "xyz.jalc/0000000001","doi_ra":"JaLC","doi2": "xyz.jalc/0000000001","doi_ra2":"JaLC"},[],[],False,False),
- (1,{"doi": "xyz.jalc/0000000001","doi_ra":"JaLC", "doi2": "","doi_ra2":"DataCite"},{"doi": "xyz.jalc/0000000001","doi_ra":"JaLC","doi2": "xyz.jalc/0000000001","doi_ra2":"JaLC"},['The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],[],False,False),
- (1,{"doi": "xyz.jalc/0000000001","doi_ra":"JaLC", "doi2": "xyz.jalc/0000000001","doi_ra2":"DataCite"},{"doi": "xyz.jalc/0000000001","doi_ra":"JaLC","doi2": "xyz.jalc/0000000001","doi_ra2":"JaLC"},['The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],[],False,False),
- (1,{"doi": "xyz.jalc/0000000001","doi_ra":"JaLC", "doi2": "xyz.jalc/0000000002","doi_ra2":"DataCite"},{"doi": "xyz.jalc/0000000001","doi_ra":"JaLC","doi2": "xyz.jalc/0000000001","doi_ra2":"JaLC"},['The specified DOI is wrong and fixed with the registered DOI.', 'The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],[],False,False),
- (1,{"doi": "xyz.jalc/0000000001","doi_ra":"JaLC", "doi2": "","doi_ra2":"JaLC2"},{"doi": "xyz.jalc/0000000001","doi_ra":"JaLC","doi2": "xyz.jalc/0000000001","doi_ra2":"JaLC"},['The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],[],False,False),
- (1,{"doi": "xyz.jalc/0000000002","doi_ra":"JaLC","doi2": "","doi_ra2":""},{"doi": "xyz.jalc/0000000001","doi_ra":"JaLC","doi2": "xyz.jalc/0000000001","doi_ra2":"JaLC"},['The specified DOI is wrong and fixed with the registered DOI.'],[],False,False),
- (1,{"doi": "xyz.jalc/0000000002","doi_ra":"JaLC","doi2": "xyz.jalc/0000000001","doi_ra2":"JaLC"},{"doi": "xyz.jalc/0000000001","doi_ra":"JaLC","doi2": "xyz.jalc/0000000001","doi_ra2":"JaLC"},['The specified DOI is wrong and fixed with the registered DOI.'],[],False,False),
- (1,{"doi": "xyz.jalc/0000000002","doi_ra":"JaLC2","doi2": "xyz.jalc/0000000001","doi_ra2":"JaLC"},{"doi": "xyz.jalc/0000000001","doi_ra":"JaLC","doi2": None,"doi_ra2":None},['The specified DOI is wrong and fixed with the registered DOI.', 'The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],['DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],False,False),
- (1,{"doi": "xyz.jalc/0000000002","doi_ra":"JaLC","doi2": "xyz.jalc/0000000002","doi_ra2":"JaLC"},{"doi": "xyz.jalc/0000000001","doi_ra":"JaLC","doi2": "xyz.jalc/0000000001","doi_ra2":"JaLC"},['The specified DOI is wrong and fixed with the registered DOI.'],[],False,False),
- (1,{"doi": None,"doi_ra":None,"doi2": None,"doi_ra2":None},{"doi": "xyz.jalc/0000000001","doi_ra":"JaLC","doi2": "xyz.jalc/0000000001","doi_ra2":"JaLC"},['The specified DOI is wrong and fixed with the registered DOI.','The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],[],False,False),
- (1,{"doi": "xyz.jalc/0000000001","doi_ra":None,"doi2": None,"doi_ra2":None},{"doi": "xyz.jalc/0000000001","doi_ra":"JaLC","doi2": "xyz.jalc/0000000001","doi_ra2":"JaLC"},['The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],['DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],False,False),
- (1,{"doi": None,"doi_ra":"JaLC","doi2": None,"doi_ra2":None},{"doi": "xyz.jalc/0000000001","doi_ra":"JaLC","doi2": "xyz.jalc/0000000001","doi_ra2":"JaLC"},['The specified DOI is wrong and fixed with the registered DOI.'],[],False,False),
- (1,{"doi": "xyz.jalc/0000000001","doi_ra":"JaLC","doi2": "xyz.jalc/0000000001","doi_ra2":"JaLC"},{"doi": "xyz.jalc/0000000001","doi_ra":"JaLC","doi2": "xyz.jalc/0000000001","doi_ra2":"JaLC"},[],[],True,False),
- (1,{"doi": "","doi_ra":"", "doi2": "","doi_ra2":""},{"doi": "","doi_ra":"","doi2": "","doi_ra2":""},[],['Please specify DOI prefix/suffix.'],True,False),
- (1,{"doi": "xyz.jalc/0000000001","doi_ra":"", "doi2": "","doi_ra2":""},{"doi": "xyz.jalc/0000000001","doi_ra":"","doi2": None,"doi_ra2":None},[],['DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],True,False),
-
- (1,{"doi": "xyz.jalc/0000000001","doi_ra":"JaLC", "doi2": "","doi_ra2":""},{"doi": "xyz.jalc/0000000001","doi_ra":"JaLC","doi2": "xyz.jalc/0000000001","doi_ra2":"JaLC"},[],[],True,False),
- (1,{"doi": "xyz.jalc/0000000001","doi_ra":"JaLC", "doi2": "xyz.jalc/0000000001","doi_ra2":""},{"doi": "xyz.jalc/0000000001","doi_ra":"JaLC","doi2": "xyz.jalc/0000000001","doi_ra2":"JaLC"},[],[],True,False),
- (1,{"doi": "xyz.jalc/0000000001","doi_ra":"JaLC", "doi2": "","doi_ra2":"JaLC"},{"doi": "xyz.jalc/0000000001","doi_ra":"JaLC","doi2": "xyz.jalc/0000000001","doi_ra2":"JaLC"},[],[],True,False),
- (1,{"doi": "xyz.jalc/0000000001","doi_ra":"JaLC", "doi2": "","doi_ra2":"DataCite"},{"doi": "xyz.jalc/0000000001","doi_ra":"JaLC","doi2": "xyz.jalc/0000000001","doi_ra2":"JaLC"},['The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],[],True,False),
- (1,{"doi": "xyz.jalc/0000000001","doi_ra":"JaLC", "doi2": "xyz.jalc/0000000001","doi_ra2":"DataCite"},{"doi": "xyz.jalc/0000000001","doi_ra":"JaLC","doi2": "xyz.jalc/0000000001","doi_ra2":"JaLC"},['The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],[],True,False),
- (1,{"doi": "xyz.jalc/0000000001","doi_ra":"JaLC", "doi2": "xyz.jalc/0000000002","doi_ra2":"DataCite"},{"doi": "xyz.jalc/0000000001","doi_ra":"JaLC","doi2": "xyz.jalc/0000000001","doi_ra2":"JaLC"},['The specified DOI is wrong and fixed with the registered DOI.', 'The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],[],True,False),
- (1,{"doi": "xyz.jalc/0000000001","doi_ra":"JaLC", "doi2": "","doi_ra2":"JaLC2"},{"doi": "xyz.jalc/0000000001","doi_ra":"JaLC","doi2": "xyz.jalc/0000000001","doi_ra2":"JaLC"},['The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],[],True,False),
- (1,{"doi": "xyz.jalc/0000000002","doi_ra":"JaLC","doi2": "","doi_ra2":""},{"doi": "xyz.jalc/0000000002","doi_ra":"JaLC","doi2": "xyz.jalc/0000000002","doi_ra2":"JaLC"},[],[],True,False),
- (1,{"doi": "xyz.jalc/0000000002","doi_ra":"JaLC","doi2": "xyz.jalc/0000000001","doi_ra2":"JaLC"},{"doi": "xyz.jalc/0000000002","doi_ra":"JaLC","doi2": "xyz.jalc/0000000002","doi_ra2":"JaLC"},['The specified DOI is wrong and fixed with the registered DOI.'],[],True,False),
- (1,{"doi": "xyz.jalc/0000000002","doi_ra":"JaLC2","doi2": "xyz.jalc/0000000001","doi_ra2":"JaLC"},{"doi": "xyz.jalc/0000000002","doi_ra":"JaLC2","doi2": None,"doi_ra2":None},[],['DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],True,False),
- (1,{"doi": "xyz.jalc/0000000002","doi_ra":"JaLC","doi2": "xyz.jalc/0000000002","doi_ra2":"JaLC"},{"doi": "xyz.jalc/0000000002","doi_ra":"JaLC","doi2": "xyz.jalc/0000000002","doi_ra2":"JaLC"},[],[],True,False),
- (1,{"doi": None,"doi_ra":None,"doi2": None,"doi_ra2":None},{"doi": "","doi_ra":"","doi2": None,"doi_ra2":None},[],['Please specify DOI prefix/suffix.'],True,False),
- (1,{"doi": "xyz.jalc/0000000001","doi_ra":None,"doi2": None,"doi_ra2":None},{"doi": "xyz.jalc/0000000001","doi_ra":"","doi2": None,"doi_ra2":None},[],['DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],True,False),
- (1,{"doi": None,"doi_ra":"JaLC","doi2": None,"doi_ra2":None},{"doi": "","doi_ra":"JaLC","doi2": "","doi_ra2":"JaLC"},[],['Please specify DOI prefix/suffix.'],True,False),
-
- (2,{"doi": "xyz.crossref/0000000002","doi_ra":"Crossref","doi2": "xyz.crossref/0000000002","doi_ra2":"Crossref"},{"doi": "xyz.crossref/0000000002","doi_ra":"Crossref","doi2": "xyz.crossref/0000000002","doi_ra2":"Crossref"},[],[],False,False),
- (2,{"doi": "","doi_ra":"", "doi2": "","doi_ra2":""},{"doi": "xyz.crossref/0000000002","doi_ra":"Crossref","doi2": "xyz.crossref/0000000002","doi_ra2":"Crossref"},['The specified DOI is wrong and fixed with the registered DOI.', 'The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],[],False,False),
- (2,{"doi": "xyz.crossref/0000000002","doi_ra":"", "doi2": "","doi_ra2":""},{"doi": "xyz.crossref/0000000002","doi_ra":"Crossref","doi2": None,"doi_ra2":None},['The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],['DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],False,False),
- (2,{"doi": "xyz.crossref/0000000002","doi_ra":"Crossref", "doi2": "","doi_ra2":""},{"doi": "xyz.crossref/0000000002","doi_ra":"Crossref","doi2": "xyz.crossref/0000000002","doi_ra2":"Crossref"},[],[],False,False),
- (2,{"doi": "xyz.crossref/0000000002","doi_ra":"Crossref", "doi2": "xyz.crossref/0000000002","doi_ra2":""},{"doi": "xyz.crossref/0000000002","doi_ra":"Crossref","doi2": "xyz.crossref/0000000002","doi_ra2":"Crossref"},[],[],False,False),
- (2,{"doi": "xyz.crossref/0000000002","doi_ra":"Crossref", "doi2": "","doi_ra2":"Crossref"},{"doi": "xyz.crossref/0000000002","doi_ra":"Crossref","doi2": "xyz.crossref/0000000002","doi_ra2":"Crossref"},[],[],False,False),
- (2,{"doi": "xyz.crossref/0000000002","doi_ra":"Crossref", "doi2": "","doi_ra2":"DataCite"},{"doi": "xyz.crossref/0000000002","doi_ra":"Crossref","doi2": "xyz.crossref/0000000002","doi_ra2":"Crossref"},['The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],[],False,False),
- (2,{"doi": "xyz.crossref/0000000002","doi_ra":"Crossref", "doi2": "xyz.crossref/0000000002","doi_ra2":"DataCite"},{"doi": "xyz.crossref/0000000002","doi_ra":"Crossref","doi2": "xyz.crossref/0000000002","doi_ra2":"Crossref"},['The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],[],False,False),
- (2,{"doi": "xyz.crossref/0000000002","doi_ra":"Crossref", "doi2": "xyz.crossref/0000000003","doi_ra2":"DataCite"},{"doi": "xyz.crossref/0000000002","doi_ra":"Crossref","doi2": "xyz.crossref/0000000002","doi_ra2":"Crossref"},['The specified DOI is wrong and fixed with the registered DOI.', 'The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],[],False,False),
- (2,{"doi": "xyz.crossref/0000000002","doi_ra":"Crossref", "doi2": "","doi_ra2":"JaLC2"},{"doi": "xyz.crossref/0000000002","doi_ra":"Crossref","doi2": "xyz.crossref/0000000002","doi_ra2":"Crossref"},['The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],[],False,False),
- (2,{"doi": "xyz.crossref/0000000003","doi_ra":"Crossref","doi2": "","doi_ra2":""},{"doi": "xyz.crossref/0000000002","doi_ra":"Crossref","doi2": "xyz.crossref/0000000002","doi_ra2":"Crossref"},['The specified DOI is wrong and fixed with the registered DOI.'],[],False,False),
- (2,{"doi": "xyz.crossref/0000000003","doi_ra":"Crossref","doi2": "xyz.crossref/0000000002","doi_ra2":"Crossref"},{"doi": "xyz.crossref/0000000002","doi_ra":"Crossref","doi2": "xyz.crossref/0000000002","doi_ra2":"Crossref"},['The specified DOI is wrong and fixed with the registered DOI.'],[],False,False),
- (2,{"doi": "xyz.crossref/0000000003","doi_ra":"JaLC2","doi2": "xyz.crossref/0000000002","doi_ra2":"Crossref"},{"doi": "xyz.crossref/0000000002","doi_ra":"Crossref","doi2": None,"doi_ra2":None},['The specified DOI is wrong and fixed with the registered DOI.', 'The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],['DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],False,False),
- (2,{"doi": "xyz.crossref/0000000003","doi_ra":"Crossref","doi2": "xyz.crossref/0000000003","doi_ra2":"Crossref"},{"doi": "xyz.crossref/0000000002","doi_ra":"Crossref","doi2": "xyz.crossref/0000000002","doi_ra2":"Crossref"},['The specified DOI is wrong and fixed with the registered DOI.'],[],False,False),
- (2,{"doi": None,"doi_ra":None,"doi2": None,"doi_ra2":None},{"doi": "xyz.crossref/0000000002","doi_ra":"Crossref","doi2": "xyz.crossref/0000000002","doi_ra2":"Crossref"},['The specified DOI is wrong and fixed with the registered DOI.','The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],[],False,False),
- (2,{"doi": "xyz.crossref/0000000002","doi_ra":None,"doi2": None,"doi_ra2":None},{"doi": "xyz.crossref/0000000002","doi_ra":"Crossref","doi2": "xyz.crossref/0000000002","doi_ra2":"Crossref"},['The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],['DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],False,False),
- (2,{"doi": None,"doi_ra":"Crossref","doi2": None,"doi_ra2":None},{"doi": "xyz.crossref/0000000002","doi_ra":"Crossref","doi2": "xyz.crossref/0000000002","doi_ra2":"Crossref"},['The specified DOI is wrong and fixed with the registered DOI.'],[],False,False),
-
- (2,{"doi": "xyz.crossref/0000000002","doi_ra":"Crossref","doi2": "xyz.crossref/0000000002","doi_ra2":"Crossref"},{"doi": "xyz.crossref/0000000002","doi_ra":"Crossref","doi2": "xyz.crossref/0000000002","doi_ra2":"Crossref"},[],[],True,False),
- (2,{"doi": "","doi_ra":"", "doi2": "","doi_ra2":""},{"doi": "","doi_ra":"","doi2": "","doi_ra2":""},[],['Please specify DOI prefix/suffix.'],True,False),
- (2,{"doi": "xyz.crossref/0000000002","doi_ra":"", "doi2": "","doi_ra2":""},{"doi": "xyz.crossref/0000000002","doi_ra":"","doi2": None,"doi_ra2":None},[],['DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],True,False),
-
- (2,{"doi": "xyz.crossref/0000000002","doi_ra":"Crossref", "doi2": "","doi_ra2":""},{"doi": "xyz.crossref/0000000002","doi_ra":"Crossref","doi2": "xyz.crossref/0000000002","doi_ra2":"Crossref"},[],[],True,False),
- (2,{"doi": "xyz.crossref/0000000002","doi_ra":"Crossref", "doi2": "xyz.crossref/0000000002","doi_ra2":""},{"doi": "xyz.crossref/0000000002","doi_ra":"Crossref","doi2": "xyz.crossref/0000000002","doi_ra2":"Crossref"},[],[],True,False),
- (2,{"doi": "xyz.crossref/0000000002","doi_ra":"Crossref", "doi2": "","doi_ra2":"Crossref"},{"doi": "xyz.crossref/0000000002","doi_ra":"Crossref","doi2": "xyz.crossref/0000000002","doi_ra2":"Crossref"},[],[],True,False),
- (2,{"doi": "xyz.crossref/0000000002","doi_ra":"Crossref", "doi2": "","doi_ra2":"DataCite"},{"doi": "xyz.crossref/0000000002","doi_ra":"Crossref","doi2": "xyz.crossref/0000000002","doi_ra2":"Crossref"},['The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],[],True,False),
- (2,{"doi": "xyz.crossref/0000000002","doi_ra":"Crossref", "doi2": "xyz.crossref/0000000002","doi_ra2":"DataCite"},{"doi": "xyz.crossref/0000000002","doi_ra":"Crossref","doi2": "xyz.crossref/0000000002","doi_ra2":"Crossref"},['The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],[],True,False),
- (2,{"doi": "xyz.crossref/0000000002","doi_ra":"Crossref", "doi2": "xyz.crossref/0000000003","doi_ra2":"DataCite"},{"doi": "xyz.crossref/0000000002","doi_ra":"Crossref","doi2": "xyz.crossref/0000000002","doi_ra2":"Crossref"},['The specified DOI is wrong and fixed with the registered DOI.', 'The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],[],True,False),
- (2,{"doi": "xyz.crossref/0000000002","doi_ra":"Crossref", "doi2": "","doi_ra2":"JaLC2"},{"doi": "xyz.crossref/0000000002","doi_ra":"Crossref","doi2": "xyz.crossref/0000000002","doi_ra2":"Crossref"},['The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],[],True,False),
- (2,{"doi": "xyz.crossref/0000000003","doi_ra":"Crossref","doi2": "","doi_ra2":""},{"doi": "xyz.crossref/0000000003","doi_ra":"Crossref","doi2": "xyz.crossref/0000000003","doi_ra2":"Crossref"},[],[],True,False),
- (2,{"doi": "xyz.crossref/0000000003","doi_ra":"Crossref","doi2": "xyz.crossref/0000000002","doi_ra2":"Crossref"},{"doi": "xyz.crossref/0000000003","doi_ra":"Crossref","doi2": "xyz.crossref/0000000003","doi_ra2":"Crossref"},['The specified DOI is wrong and fixed with the registered DOI.'],[],True,False),
- (2,{"doi": "xyz.crossref/0000000003","doi_ra":"JaLC2","doi2": "xyz.crossref/0000000002","doi_ra2":"Crossref"},{"doi": "xyz.crossref/0000000003","doi_ra":"JaLC2","doi2": None,"doi_ra2":None},[],['DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],True,False),
- (2,{"doi": "xyz.crossref/0000000003","doi_ra":"Crossref","doi2": "xyz.crossref/0000000003","doi_ra2":"Crossref"},{"doi": "xyz.crossref/0000000003","doi_ra":"Crossref","doi2": "xyz.crossref/0000000003","doi_ra2":"Crossref"},[],[],True,False),
- (2,{"doi": None,"doi_ra":None,"doi2": None,"doi_ra2":None},{"doi": "","doi_ra":"","doi2": None,"doi_ra2":None},[],['Please specify DOI prefix/suffix.'],True,False),
- (2,{"doi": "xyz.crossref/0000000002","doi_ra":None,"doi2": None,"doi_ra2":None},{"doi": "xyz.crossref/0000000002","doi_ra":"","doi2": None,"doi_ra2":None},[],['DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],True,False),
- (2,{"doi": None,"doi_ra":"Crossref","doi2": None,"doi_ra2":None},{"doi": "","doi_ra":"Crossref","doi2": "","doi_ra2":"Crossref"},[],['Please specify DOI prefix/suffix.'],True,False),
-
- (3,{"doi": "xyz.datacite/0000000003","doi_ra":"DataCite","doi2": "xyz.datacite/0000000003","doi_ra2":"DataCite"},{"doi": "xyz.datacite/0000000003","doi_ra":"DataCite","doi2": "xyz.datacite/0000000003","doi_ra2":"DataCite"},[],[],False,False),
- (3,{"doi": "","doi_ra":"", "doi2": "","doi_ra2":""},{"doi": "xyz.datacite/0000000003","doi_ra":"DataCite","doi2": "xyz.datacite/0000000003","doi_ra2":"DataCite"},['The specified DOI is wrong and fixed with the registered DOI.', 'The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],[],False,False),
- (3,{"doi": "xyz.datacite/0000000003","doi_ra":"", "doi2": "","doi_ra2":""},{"doi": "xyz.datacite/0000000003","doi_ra":"DataCite","doi2": None,"doi_ra2":None},['The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],['DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],False,False),
- (3,{"doi": "xyz.datacite/0000000003","doi_ra":"DataCite", "doi2": "","doi_ra2":""},{"doi": "xyz.datacite/0000000003","doi_ra":"DataCite","doi2": "xyz.datacite/0000000003","doi_ra2":"DataCite"},[],[],False,False),
- (3,{"doi": "xyz.datacite/0000000003","doi_ra":"DataCite", "doi2": "xyz.datacite/0000000003","doi_ra2":""},{"doi": "xyz.datacite/0000000003","doi_ra":"DataCite","doi2": "xyz.datacite/0000000003","doi_ra2":"DataCite"},[],[],False,False),
- (3,{"doi": "xyz.datacite/0000000003","doi_ra":"DataCite", "doi2": "","doi_ra2":"DataCite"},{"doi": "xyz.datacite/0000000003","doi_ra":"DataCite","doi2": "xyz.datacite/0000000003","doi_ra2":"DataCite"},[],[],False,False),
- (3,{"doi": "xyz.datacite/0000000003","doi_ra":"DataCite", "doi2": "","doi_ra2":"JaLC"},{"doi": "xyz.datacite/0000000003","doi_ra":"DataCite","doi2": "xyz.datacite/0000000003","doi_ra2":"DataCite"},['The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],[],False,False),
- (3,{"doi": "xyz.datacite/0000000003","doi_ra":"DataCite", "doi2": "xyz.datacite/0000000003","doi_ra2":"JaLC"},{"doi": "xyz.datacite/0000000003","doi_ra":"DataCite","doi2": "xyz.datacite/0000000003","doi_ra2":"DataCite"},['The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],[],False,False),
- (3,{"doi": "xyz.datacite/0000000003","doi_ra":"DataCite", "doi2": "xyz.datacite/0000000004","doi_ra2":"JaLC"},{"doi": "xyz.datacite/0000000003","doi_ra":"DataCite","doi2": "xyz.datacite/0000000003","doi_ra2":"DataCite"},['The specified DOI is wrong and fixed with the registered DOI.', 'The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],[],False,False),
- (3,{"doi": "xyz.datacite/0000000003","doi_ra":"DataCite", "doi2": "","doi_ra2":"JaLC2"},{"doi": "xyz.datacite/0000000003","doi_ra":"DataCite","doi2": "xyz.datacite/0000000003","doi_ra2":"DataCite"},['The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],[],False,False),
- (3,{"doi": "xyz.datacite/0000000004","doi_ra":"DataCite","doi2": "","doi_ra2":""},{"doi": "xyz.datacite/0000000003","doi_ra":"DataCite","doi2": "xyz.datacite/0000000003","doi_ra2":"DataCite"},['The specified DOI is wrong and fixed with the registered DOI.'],[],False,False),
- (3,{"doi": "xyz.datacite/0000000004","doi_ra":"DataCite","doi2": "xyz.datacite/0000000003","doi_ra2":"DataCite"},{"doi": "xyz.datacite/0000000003","doi_ra":"DataCite","doi2": "xyz.datacite/0000000003","doi_ra2":"DataCite"},['The specified DOI is wrong and fixed with the registered DOI.'],[],False,False),
- (3,{"doi": "xyz.datacite/0000000004","doi_ra":"JaLC2","doi2": "xyz.datacite/0000000003","doi_ra2":"DataCite"},{"doi": "xyz.datacite/0000000003","doi_ra":"DataCite","doi2": None,"doi_ra2":None},['The specified DOI is wrong and fixed with the registered DOI.', 'The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],['DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],False,False),
- (3,{"doi": "xyz.datacite/0000000004","doi_ra":"DataCite","doi2": "xyz.datacite/0000000004","doi_ra2":"DataCite"},{"doi": "xyz.datacite/0000000003","doi_ra":"DataCite","doi2": "xyz.datacite/0000000003","doi_ra2":"DataCite"},['The specified DOI is wrong and fixed with the registered DOI.'],[],False,False),
- (3,{"doi": None,"doi_ra":None,"doi2": None,"doi_ra2":None},{"doi": "xyz.datacite/0000000003","doi_ra":"DataCite","doi2": "xyz.datacite/0000000003","doi_ra2":"DataCite"},['The specified DOI is wrong and fixed with the registered DOI.','The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],[],False,False),
- (3,{"doi": "xyz.datacite/0000000003","doi_ra":None,"doi2": None,"doi_ra2":None},{"doi": "xyz.datacite/0000000003","doi_ra":"DataCite","doi2": "xyz.datacite/0000000003","doi_ra2":"DataCite"},['The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],['DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],False,False),
- (3,{"doi": None,"doi_ra":"DataCite","doi2": None,"doi_ra2":None},{"doi": "xyz.datacite/0000000003","doi_ra":"DataCite","doi2": "xyz.datacite/0000000003","doi_ra2":"DataCite"},['The specified DOI is wrong and fixed with the registered DOI.'],[],False,False),
-
- (3,{"doi": "xyz.datacite/0000000003","doi_ra":"DataCite","doi2": "xyz.datacite/0000000003","doi_ra2":"DataCite"},{"doi": "xyz.datacite/0000000003","doi_ra":"DataCite","doi2": "xyz.datacite/0000000003","doi_ra2":"DataCite"},[],[],True,False),
- (3,{"doi": "","doi_ra":"", "doi2": "","doi_ra2":""},{"doi": "","doi_ra":"","doi2": "","doi_ra2":""},[],['Please specify DOI prefix/suffix.'],True,False),
- (3,{"doi": "xyz.datacite/0000000003","doi_ra":"", "doi2": "","doi_ra2":""},{"doi": "xyz.datacite/0000000003","doi_ra":"","doi2": None,"doi_ra2":None},[],['DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],True,False),
- (3,{"doi": "xyz.datacite/0000000003","doi_ra":"DataCite", "doi2": "","doi_ra2":""},{"doi": "xyz.datacite/0000000003","doi_ra":"DataCite","doi2": "xyz.datacite/0000000003","doi_ra2":"DataCite"},[],[],True,False),
- (3,{"doi": "xyz.datacite/0000000003","doi_ra":"DataCite", "doi2": "xyz.datacite/0000000003","doi_ra2":""},{"doi": "xyz.datacite/0000000003","doi_ra":"DataCite","doi2": "xyz.datacite/0000000003","doi_ra2":"DataCite"},[],[],True,False),
- (3,{"doi": "xyz.datacite/0000000003","doi_ra":"DataCite", "doi2": "","doi_ra2":"DataCite"},{"doi": "xyz.datacite/0000000003","doi_ra":"DataCite","doi2": "xyz.datacite/0000000003","doi_ra2":"DataCite"},[],[],True,False),
- (3,{"doi": "xyz.datacite/0000000003","doi_ra":"DataCite", "doi2": "","doi_ra2":"JaLC"},{"doi": "xyz.datacite/0000000003","doi_ra":"DataCite","doi2": "xyz.datacite/0000000003","doi_ra2":"DataCite"},['The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],[],True,False),
- (3,{"doi": "xyz.datacite/0000000003","doi_ra":"DataCite", "doi2": "xyz.datacite/0000000003","doi_ra2":"JaLC"},{"doi": "xyz.datacite/0000000003","doi_ra":"DataCite","doi2": "xyz.datacite/0000000003","doi_ra2":"DataCite"},['The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],[],True,False),
- (3,{"doi": "xyz.datacite/0000000003","doi_ra":"DataCite", "doi2": "xyz.datacite/0000000004","doi_ra2":"JaLC"},{"doi": "xyz.datacite/0000000003","doi_ra":"DataCite","doi2": "xyz.datacite/0000000003","doi_ra2":"DataCite"},['The specified DOI is wrong and fixed with the registered DOI.', 'The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],[],True,False),
- (3,{"doi": "xyz.datacite/0000000003","doi_ra":"DataCite", "doi2": "","doi_ra2":"JaLC2"},{"doi": "xyz.datacite/0000000003","doi_ra":"DataCite","doi2": "xyz.datacite/0000000003","doi_ra2":"DataCite"},['The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],[],True,False),
- (3,{"doi": "xyz.datacite/0000000004","doi_ra":"DataCite","doi2": "","doi_ra2":""},{"doi": "xyz.datacite/0000000004","doi_ra":"DataCite","doi2": "xyz.datacite/0000000004","doi_ra2":"DataCite"},[],[],True,False),
- (3,{"doi": "xyz.datacite/0000000004","doi_ra":"DataCite","doi2": "xyz.datacite/0000000003","doi_ra2":"DataCite"},{"doi": "xyz.datacite/0000000004","doi_ra":"DataCite","doi2": "xyz.datacite/0000000004","doi_ra2":"DataCite"},['The specified DOI is wrong and fixed with the registered DOI.'],[],True,False),
- (3,{"doi": "xyz.datacite/0000000004","doi_ra":"JaLC2","doi2": "xyz.datacite/0000000003","doi_ra2":"DataCite"},{"doi": "xyz.datacite/0000000004","doi_ra":"JaLC2","doi2": None,"doi_ra2":None},[],['DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],True,False),
- (3,{"doi": "xyz.datacite/0000000004","doi_ra":"DataCite","doi2": "xyz.datacite/0000000004","doi_ra2":"DataCite"},{"doi": "xyz.datacite/0000000004","doi_ra":"DataCite","doi2": "xyz.datacite/0000000004","doi_ra2":"DataCite"},[],[],True,False),
- (3,{"doi": None,"doi_ra":None,"doi2": None,"doi_ra2":None},{"doi": "","doi_ra":"","doi2": None,"doi_ra2":None},[],['Please specify DOI prefix/suffix.'],True,False),
- (3,{"doi": "xyz.datacite/0000000003","doi_ra":None,"doi2": None,"doi_ra2":None},{"doi": "xyz.datacite/0000000003","doi_ra":"","doi2": None,"doi_ra2":None},[],['DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],True,False),
- (3,{"doi": None,"doi_ra":"DataCite","doi2": None,"doi_ra2":None},{"doi": "","doi_ra":"DataCite","doi2": "","doi_ra2":"DataCite"},[],['Please specify DOI prefix/suffix.'],True,False),
-
-
- (4,{"doi": "xyz.ndl/0000000004","doi_ra":"NDL JaLC","doi2": "xyz.ndl/0000000004","doi_ra2":"NDL JaLC"},{"doi": "xyz.ndl/0000000004","doi_ra":"NDL JaLC","doi2": "xyz.ndl/0000000004","doi_ra2":"NDL JaLC"},[],[],False,False),
- (4,{"doi": "","doi_ra":"", "doi2": "","doi_ra2":""},{"doi": "xyz.ndl/0000000004","doi_ra":"NDL JaLC","doi2": "xyz.ndl/0000000004","doi_ra2":"NDL JaLC"},['The specified DOI is wrong and fixed with the registered DOI.', 'The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],[],False,False),
- (4,{"doi": "xyz.ndl/0000000004","doi_ra":"", "doi2": "","doi_ra2":""},{"doi": "xyz.ndl/0000000004","doi_ra":"NDL JaLC","doi2": None,"doi_ra2":None},['The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],['DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],False,False),
- (4,{"doi": "xyz.ndl/0000000004","doi_ra":"NDL JaLC", "doi2": "","doi_ra2":""},{"doi": "xyz.ndl/0000000004","doi_ra":"NDL JaLC","doi2": "xyz.ndl/0000000004","doi_ra2":"NDL JaLC"},[],[],False,False),
- (4,{"doi": "xyz.ndl/0000000004","doi_ra":"NDL JaLC", "doi2": "xyz.ndl/0000000004","doi_ra2":""},{"doi": "xyz.ndl/0000000004","doi_ra":"NDL JaLC","doi2": "xyz.ndl/0000000004","doi_ra2":"NDL JaLC"},[],[],False,False),
- (4,{"doi": "xyz.ndl/0000000004","doi_ra":"NDL JaLC", "doi2": "","doi_ra2":"NDL JaLC"},{"doi": "xyz.ndl/0000000004","doi_ra":"NDL JaLC","doi2": "xyz.ndl/0000000004","doi_ra2":"NDL JaLC"},[],[],False,False),
- (4,{"doi": "xyz.ndl/0000000004","doi_ra":"NDL JaLC", "doi2": "","doi_ra2":"DataCite"},{"doi": "xyz.ndl/0000000004","doi_ra":"NDL JaLC","doi2": "xyz.ndl/0000000004","doi_ra2":"NDL JaLC"},['The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],[],False,False),
- (4,{"doi": "xyz.ndl/0000000004","doi_ra":"NDL JaLC", "doi2": "xyz.ndl/0000000004","doi_ra2":"DataCite"},{"doi": "xyz.ndl/0000000004","doi_ra":"NDL JaLC","doi2": "xyz.ndl/0000000004","doi_ra2":"NDL JaLC"},['The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],[],False,False),
- (4,{"doi": "xyz.ndl/0000000004","doi_ra":"NDL JaLC", "doi2": "xyz.ndl/0000000005","doi_ra2":"DataCite"},{"doi": "xyz.ndl/0000000004","doi_ra":"NDL JaLC","doi2": "xyz.ndl/0000000004","doi_ra2":"NDL JaLC"},['The specified DOI is wrong and fixed with the registered DOI.', 'The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],[],False,False),
- (4,{"doi": "xyz.ndl/0000000004","doi_ra":"NDL JaLC", "doi2": "","doi_ra2":"JaLC2"},{"doi": "xyz.ndl/0000000004","doi_ra":"NDL JaLC","doi2": "xyz.ndl/0000000004","doi_ra2":"NDL JaLC"},['The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],[],False,False),
- (4,{"doi": "xyz.ndl/0000000005","doi_ra":"NDL JaLC","doi2": "","doi_ra2":""},{"doi": "xyz.ndl/0000000004","doi_ra":"NDL JaLC","doi2": "xyz.ndl/0000000004","doi_ra2":"NDL JaLC"},['The specified DOI is wrong and fixed with the registered DOI.'],[],False,False),
- (4,{"doi": "xyz.ndl/0000000005","doi_ra":"NDL JaLC","doi2": "xyz.ndl/0000000004","doi_ra2":"NDL JaLC"},{"doi": "xyz.ndl/0000000004","doi_ra":"NDL JaLC","doi2": "xyz.ndl/0000000004","doi_ra2":"NDL JaLC"},['The specified DOI is wrong and fixed with the registered DOI.'],[],False,False),
- (4,{"doi": "xyz.ndl/0000000005","doi_ra":"JaLC2","doi2": "xyz.ndl/0000000004","doi_ra2":"NDL JaLC"},{"doi": "xyz.ndl/0000000004","doi_ra":"NDL JaLC","doi2": None,"doi_ra2":None},['The specified DOI is wrong and fixed with the registered DOI.', 'The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],['DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],False,False),
- (4,{"doi": "xyz.ndl/0000000005","doi_ra":"NDL JaLC","doi2": "xyz.ndl/0000000005","doi_ra2":"NDL JaLC"},{"doi": "xyz.ndl/0000000004","doi_ra":"NDL JaLC","doi2": "xyz.ndl/0000000004","doi_ra2":"NDL JaLC"},['The specified DOI is wrong and fixed with the registered DOI.'],[],False,False),
- (4,{"doi": None,"doi_ra":None,"doi2": None,"doi_ra2":None},{"doi": "xyz.ndl/0000000004","doi_ra":"NDL JaLC","doi2": "xyz.ndl/0000000004","doi_ra2":"NDL JaLC"},['The specified DOI is wrong and fixed with the registered DOI.','The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],[],False,False),
- (4,{"doi": "xyz.ndl/0000000004","doi_ra":None,"doi2": None,"doi_ra2":None},{"doi": "xyz.ndl/0000000004","doi_ra":"NDL JaLC","doi2": "xyz.ndl/0000000004","doi_ra2":"NDL JaLC"},['The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],['DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],False,False),
- (4,{"doi": None,"doi_ra":"NDL JaLC","doi2": None,"doi_ra2":None},{"doi": "xyz.ndl/0000000004","doi_ra":"NDL JaLC","doi2": "xyz.ndl/0000000004","doi_ra2":"NDL JaLC"},['The specified DOI is wrong and fixed with the registered DOI.'],[],False,False),
-
- (4,{"doi": "xyz.ndl/0000000004","doi_ra":"NDL JaLC","doi2": "xyz.ndl/0000000004","doi_ra2":"NDL JaLC"},{"doi": "xyz.ndl/0000000004","doi_ra":"NDL JaLC","doi2": "xyz.ndl/0000000004","doi_ra2":"NDL JaLC"},[],[],True,False),
- (4,{"doi": "","doi_ra":"", "doi2": "","doi_ra2":""},{"doi": "","doi_ra":"","doi2": "","doi_ra2":""},[],['Please specify DOI prefix/suffix.'],True,False),
- (4,{"doi": "xyz.ndl/0000000004","doi_ra":"", "doi2": "","doi_ra2":""},{"doi": "xyz.ndl/0000000004","doi_ra":"","doi2": None,"doi_ra2":None},[],['DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],True,False),
- (4,{"doi": "xyz.ndl/0000000004","doi_ra":"NDL JaLC", "doi2": "","doi_ra2":""},{"doi": "xyz.ndl/0000000004","doi_ra":"NDL JaLC","doi2": "xyz.ndl/0000000004","doi_ra2":"NDL JaLC"},[],[],True,False),
- (4,{"doi": "xyz.ndl/0000000004","doi_ra":"NDL JaLC", "doi2": "xyz.ndl/0000000004","doi_ra2":""},{"doi": "xyz.ndl/0000000004","doi_ra":"NDL JaLC","doi2": "xyz.ndl/0000000004","doi_ra2":"NDL JaLC"},[],[],True,False),
- (4,{"doi": "xyz.ndl/0000000004","doi_ra":"NDL JaLC", "doi2": "","doi_ra2":"NDL JaLC"},{"doi": "xyz.ndl/0000000004","doi_ra":"NDL JaLC","doi2": "xyz.ndl/0000000004","doi_ra2":"NDL JaLC"},[],[],True,False),
- (4,{"doi": "xyz.ndl/0000000004","doi_ra":"NDL JaLC", "doi2": "","doi_ra2":"DataCite"},{"doi": "xyz.ndl/0000000004","doi_ra":"NDL JaLC","doi2": "xyz.ndl/0000000004","doi_ra2":"NDL JaLC"},['The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],[],True,False),
- (4,{"doi": "xyz.ndl/0000000004","doi_ra":"NDL JaLC", "doi2": "xyz.ndl/0000000004","doi_ra2":"DataCite"},{"doi": "xyz.ndl/0000000004","doi_ra":"NDL JaLC","doi2": "xyz.ndl/0000000004","doi_ra2":"NDL JaLC"},['The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],[],True,False),
- (4,{"doi": "xyz.ndl/0000000004","doi_ra":"NDL JaLC", "doi2": "xyz.ndl/0000000005","doi_ra2":"DataCite"},{"doi": "xyz.ndl/0000000004","doi_ra":"NDL JaLC","doi2": "xyz.ndl/0000000004","doi_ra2":"NDL JaLC"},['The specified DOI is wrong and fixed with the registered DOI.', 'The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],[],True,False),
- (4,{"doi": "xyz.ndl/0000000004","doi_ra":"NDL JaLC", "doi2": "","doi_ra2":"JaLC2"},{"doi": "xyz.ndl/0000000004","doi_ra":"NDL JaLC","doi2": "xyz.ndl/0000000004","doi_ra2":"NDL JaLC"},['The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],[],True,False),
- (4,{"doi": "xyz.ndl/0000000005","doi_ra":"NDL JaLC","doi2": "","doi_ra2":""},{"doi": "xyz.ndl/0000000005","doi_ra":"NDL JaLC","doi2": "xyz.ndl/0000000005","doi_ra2":"NDL JaLC"},[],[],True,False),
- (4,{"doi": "xyz.ndl/0000000005","doi_ra":"NDL JaLC","doi2": "xyz.ndl/0000000004","doi_ra2":"NDL JaLC"},{"doi": "xyz.ndl/0000000005","doi_ra":"NDL JaLC","doi2": "xyz.ndl/0000000005","doi_ra2":"NDL JaLC"},['The specified DOI is wrong and fixed with the registered DOI.'],[],True,False),
- (4,{"doi": "xyz.ndl/0000000005","doi_ra":"JaLC2","doi2": "xyz.ndl/0000000004","doi_ra2":"NDL JaLC"},{"doi": "xyz.ndl/0000000005","doi_ra":"JaLC2","doi2": None,"doi_ra2":None},[],['DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],True,False),
- (4,{"doi": "xyz.ndl/0000000005","doi_ra":"NDL JaLC","doi2": "xyz.ndl/0000000005","doi_ra2":"NDL JaLC"},{"doi": "xyz.ndl/0000000005","doi_ra":"NDL JaLC","doi2": "xyz.ndl/0000000005","doi_ra2":"NDL JaLC"},[],[],True,False),
- (4,{"doi": None,"doi_ra":None,"doi2": None,"doi_ra2":None},{"doi": "","doi_ra":"","doi2": None,"doi_ra2":None},[],['Please specify DOI prefix/suffix.'],True,False),
- (4,{"doi": "xyz.ndl/0000000004","doi_ra":None,"doi2": None,"doi_ra2":None},{"doi": "xyz.ndl/0000000004","doi_ra":"","doi2":None,"doi_ra2":None},[],['DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],True,False),
- (4,{"doi": None,"doi_ra":"NDL JaLC","doi2": None,"doi_ra2":None},{"doi": "","doi_ra":"NDL JaLC","doi2": "","doi_ra2":"NDL JaLC"},[],['Please specify DOI prefix/suffix.'],True,False),
-
- (5,{"doi":"","doi_ra":"","doi2":None,"doi_ra2":None},{"doi":"","doi_ra":"","doi2":None,"doi_ra2":None},[],[],False,False),
- (5,{"doi":"","doi_ra":"JaLC","doi2":None,"doi_ra2":None},{"doi":"","doi_ra":"JaLC","doi2":None,"doi_ra2":None},[],[],False,False),
- (5,{"doi":"xyz.jalc","doi_ra":"JaLC","doi2":None,"doi_ra2":None},{"doi":"xyz.jalc","doi_ra":"JaLC","doi2":None,"doi_ra2":None},[],[],False,False),
- (5,{"doi":"xyz.jalc/","doi_ra":"JaLC","doi2":None,"doi_ra2":None},{"doi":"xyz.jalc/","doi_ra":"JaLC","doi2":None,"doi_ra2":None},[],[],False,False),
- (5,{"doi":"xyz.jalc","doi_ra":"","doi2":None,"doi_ra2":None},{"doi":"xyz.jalc","doi_ra":"","doi2":None,"doi_ra2":None},[],['DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],False,False),
- (5,{"doi":"xyz.jalc/","doi_ra":"","doi2":None,"doi_ra2":None},{"doi":"xyz.jalc/","doi_ra":"","doi2":None,"doi_ra2":None},[],['DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],False,False),
- (5,{"doi":"","doi_ra":"Crossref","doi2":None,"doi_ra2":None},{"doi":"","doi_ra":"Crossref","doi2":None,"doi_ra2":None},[],[],False,False),
- (5,{"doi":"xyz.crossref","doi_ra":"Crossref","doi2":None,"doi_ra2":None},{"doi":"xyz.crossref","doi_ra":"Crossref","doi2":None,"doi_ra2":None},[],[],False,False),
- (5,{"doi":"xyz.crossref/","doi_ra":"Crossref","doi2":None,"doi_ra2":None},{"doi":"xyz.crossref/","doi_ra":"Crossref","doi2":None,"doi_ra2":None},[],[],False,False),
- (5,{"doi":"xyz.crossref","doi_ra":"","doi2":None,"doi_ra2":None},{"doi":"xyz.crossref","doi_ra":"","doi2":None,"doi_ra2":None},[],['DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],False,False),
- (5,{"doi":"xyz.crossref/","doi_ra":"","doi2":None,"doi_ra2":None},{"doi":"xyz.crossref/","doi_ra":"","doi2":None,"doi_ra2":None},[],['DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],False,False),
- (5,{"doi":"","doi_ra":"DataCite","doi2":None,"doi_ra2":None},{"doi":"","doi_ra":"DataCite","doi2":None,"doi_ra2":None},[],[],False,False),
- (5,{"doi":"xyz.datacite","doi_ra":"DataCite","doi2":None,"doi_ra2":None},{"doi":"xyz.datacite","doi_ra":"DataCite","doi2":None,"doi_ra2":None},[],[],False,False),
- (5,{"doi":"xyz.datacite/","doi_ra":"DataCite","doi2":None,"doi_ra2":None},{"doi":"xyz.datacite/","doi_ra":"DataCite","doi2":None,"doi_ra2":None},[],[],False,False),
- (5,{"doi":"xyz.datacite","doi_ra":"","doi2":None,"doi_ra2":None},{"doi":"xyz.datacite","doi_ra":"","doi2":None,"doi_ra2":None},[],['DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],False,False),
- (5,{"doi":"xyz.datacite/","doi_ra":"","doi2":None,"doi_ra2":None},{"doi":"xyz.datacite/","doi_ra":"","doi2":None,"doi_ra2":None},[],['DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],False,False),
- (5,{"doi":"","doi_ra":"NDL JaLC","doi2":None,"doi_ra2":None},{"doi":"","doi_ra":"NDL JaLC","doi2":None,"doi_ra2":None},[],[],False,False),
- (5,{"doi":"xyz.ndl","doi_ra":"NDL JaLC","doi2":None,"doi_ra2":None},{"doi":"xyz.ndl","doi_ra":"NDL JaLC","doi2":None,"doi_ra2":None},[],[],False,False),
- (5,{"doi":"xyz.ndl/","doi_ra":"NDL JaLC","doi2":None,"doi_ra2":None},{"doi":"xyz.ndl/","doi_ra":"NDL JaLC","doi2":None,"doi_ra2":None},[],[],False,False),
- (5,{"doi":"xyz.ndl","doi_ra":"","doi2":None,"doi_ra2":None},{"doi":"xyz.ndl","doi_ra":"","doi2":None,"doi_ra2":None},[],['DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],False,False),
- (5,{"doi":"xyz.ndl/","doi_ra":"","doi2":None,"doi_ra2":None},{"doi":"xyz.ndl/","doi_ra":"","doi2":None,"doi_ra2":None},[],['DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],False,False),
- (5,{"doi":"xyz.ndl","doi_ra":"JaLC","doi2":None,"doi_ra2":None},{"doi":"xyz.ndl","doi_ra":"JaLC","doi2":None,"doi_ra2":None},[],['Specified Prefix of DOI is incorrect.'],False,False),
- (5,{"doi":"xyz.ndl/","doi_ra":"JaLC","doi2":None,"doi_ra2":None},{"doi":"xyz.ndl/","doi_ra":"JaLC","doi2":None,"doi_ra2":None},[],['Specified Prefix of DOI is incorrect.'],False,False),
- # 更新によるDOI付与
- (5,{"doi":"","doi_ra":"","doi2":None,"doi_ra2":None},{"doi":"","doi_ra":"","doi2":None,"doi_ra2":None},[],['Please specify DOI prefix/suffix.'],True,False),
- (5,{"doi":"","doi_ra":"JaLC","doi2":None,"doi_ra2":None},{"doi":"","doi_ra":"JaLC","doi2":"","doi_ra2":"JaLC"},[],['Please specify DOI prefix/suffix.'],True,False),
- (5,{"doi":"xyz.jalc","doi_ra":"JaLC","doi2":None,"doi_ra2":None},{"doi":"xyz.jalc","doi_ra":"JaLC","doi2":"xyz.jalc","doi_ra2":"JaLC"},[],['Please specify DOI suffix.'],True,False),
- (5,{"doi":"xyz.jalc/","doi_ra":"JaLC","doi2":None,"doi_ra2":None},{"doi":"xyz.jalc/","doi_ra":"JaLC","doi2":"xyz.jalc/","doi_ra2":"JaLC"},[],['Please specify DOI suffix.'],True,False),
- (5,{"doi":"xyz.jalc/xyz","doi_ra":"JaLC","doi2":None,"doi_ra2":None},{"doi":"xyz.jalc/xyz","doi_ra":"JaLC","doi2":"xyz.jalc/xyz","doi_ra2":"JaLC"},[],[],True,False),
- (5,{"doi":"xyz.jalc","doi_ra":"","doi2":None,"doi_ra2":None},{"doi":"xyz.jalc","doi_ra":"","doi2":None,"doi_ra2":None},[],['Please specify DOI suffix.', 'DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],True,False),
- (5,{"doi":"xyz.jalc/","doi_ra":"","doi2":None,"doi_ra2":None},{"doi":"xyz.jalc/","doi_ra":"","doi2":None,"doi_ra2":None},[],['Please specify DOI suffix.', 'DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],True,False),
- (5,{"doi":"","doi_ra":"Crossref","doi2":None,"doi_ra2":None},{"doi":"","doi_ra":"Crossref","doi2":"","doi_ra2":"Crossref"},[],['Please specify DOI prefix/suffix.'],True,False),
- (5,{"doi":"xyz.crossref","doi_ra":"Crossref","doi2":None,"doi_ra2":None},{"doi":"xyz.crossref","doi_ra":"Crossref","doi2":"xyz.crossref","doi_ra2":"Crossref"},[],['Please specify DOI suffix.'],True,False),
- (5,{"doi":"xyz.crossref/","doi_ra":"Crossref","doi2":None,"doi_ra2":None},{"doi":"xyz.crossref/","doi_ra":"Crossref","doi2":"xyz.crossref/","doi_ra2":"Crossref"},[],['Please specify DOI suffix.'],True,False),
- (5,{"doi":"xyz.crossref","doi_ra":"","doi2":None,"doi_ra2":None},{"doi":"xyz.crossref","doi_ra":"","doi2":None,"doi_ra2":None},[],['Please specify DOI suffix.', 'DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],True,False),
- (5,{"doi":"xyz.crossref/","doi_ra":"","doi2":None,"doi_ra2":None},{"doi":"xyz.crossref/","doi_ra":"","doi2":None,"doi_ra2":None},[],['Please specify DOI suffix.', 'DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],True,False),
- (5,{"doi":"","doi_ra":"DataCite","doi2":None,"doi_ra2":None},{"doi":"","doi_ra":"DataCite","doi2":"","doi_ra2":"DataCite"},[],['Please specify DOI prefix/suffix.'],True,False),
- (5,{"doi":"xyz.datacite","doi_ra":"DataCite","doi2":None,"doi_ra2":None},{"doi":"xyz.datacite","doi_ra":"DataCite","doi2":"xyz.datacite","doi_ra2":"DataCite"},[],['Please specify DOI suffix.'],True,False),
- (5,{"doi":"xyz.datacite/","doi_ra":"DataCite","doi2":None,"doi_ra2":None},{"doi":"xyz.datacite/","doi_ra":"DataCite","doi2":"xyz.datacite/","doi_ra2":"DataCite"},[],['Please specify DOI suffix.'],True,False),
- (5,{"doi":"xyz.datacite","doi_ra":"","doi2":None,"doi_ra2":None},{"doi":"xyz.datacite","doi_ra":"","doi2":None,"doi_ra2":None},[],['Please specify DOI suffix.', 'DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],True,False),
- (5,{"doi":"xyz.datacite/","doi_ra":"","doi2":None,"doi_ra2":None},{"doi":"xyz.datacite/","doi_ra":"","doi2":None,"doi_ra2":None},[],['Please specify DOI suffix.', 'DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],True,False),
- (5,{"doi":"","doi_ra":"NDL JaLC","doi2":None,"doi_ra2":None},{"doi":"","doi_ra":"NDL JaLC","doi2":"","doi_ra2":"NDL JaLC"},[],['Please specify DOI prefix/suffix.'],True,False),
- (5,{"doi":"xyz.ndl","doi_ra":"NDL JaLC","doi2":None,"doi_ra2":None},{"doi":"xyz.ndl","doi_ra":"NDL JaLC","doi2":"xyz.ndl","doi_ra2":"NDL JaLC"},[],['Please specify DOI suffix.'],True,False),
- (5,{"doi":"xyz.ndl/","doi_ra":"NDL JaLC","doi2":None,"doi_ra2":None},{"doi":"xyz.ndl/","doi_ra":"NDL JaLC","doi2":"xyz.ndl/","doi_ra2":"NDL JaLC"},[],['Please specify DOI suffix.'],True,False),
- (5,{"doi":"xyz.ndl","doi_ra":"","doi2":None,"doi_ra2":None},{"doi":"xyz.ndl","doi_ra":"","doi2":None,"doi_ra2":None},[],['Please specify DOI suffix.', 'DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],True,False),
- (5,{"doi":"xyz.ndl/","doi_ra":"","doi2":None,"doi_ra2":None},{"doi":"xyz.ndl/","doi_ra":"","doi2":None,"doi_ra2":None},[],['Please specify DOI suffix.', 'DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],True,False),
- (5,{"doi":"xyz.ndl","doi_ra":"JaLC","doi2":None,"doi_ra2":None},{"doi":"xyz.ndl","doi_ra":"JaLC","doi2":"xyz.ndl","doi_ra2":"JaLC"},[],['Please specify DOI suffix.', 'Specified Prefix of DOI is incorrect.'],True,False),
- (5,{"doi":"xyz.ndl/","doi_ra":"JaLC","doi2":None,"doi_ra2":None},{"doi":"xyz.ndl/","doi_ra":"JaLC","doi2":"xyz.ndl/","doi_ra2":"JaLC"},[],['Please specify DOI suffix.', 'Specified Prefix of DOI is incorrect.'],True,False),
- # 新規登録時DOI付与
- (None,{"doi": "","doi_ra":"","doi2": None,"doi_ra2":None},{"doi": "","doi_ra":"","doi2": None,"doi_ra2":None},[],[],False,False),
- (None,{"doi": "","doi_ra":"JaLC","doi2": None,"doi_ra2":None},{"doi": "","doi_ra":"JaLC","doi2": None,"doi_ra2":None},[],[],False,False),
- (None,{"doi": "xyz.jalc","doi_ra":"JaLC","doi2": None,"doi_ra2":None},{"doi": "xyz.jalc","doi_ra":"JaLC","doi2": None,"doi_ra2":None},[],[],False,False),
- (None,{"doi": "xyz.jalc/","doi_ra":"JaLC","doi2": None,"doi_ra2":None},{"doi": "xyz.jalc/","doi_ra":"JaLC","doi2": None,"doi_ra2":None},[],[],False,False),
- (None,{"doi": "xyz.jalc","doi_ra":"","doi2": None,"doi_ra2":None},{"doi": "xyz.jalc","doi_ra":"","doi2": None,"doi_ra2":None},[],['DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],False,False),
- (None,{"doi": "xyz.jalc/","doi_ra":"","doi2": None,"doi_ra2":None},{"doi": "xyz.jalc/","doi_ra":"","doi2": None,"doi_ra2":None},[],['DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],False,False),
- (None,{"doi": "","doi_ra":"JaLC2","doi2": None,"doi_ra2":None},{"doi": "","doi_ra":"JaLC2","doi2": None,"doi_ra2":None},[],['DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],False,False),
- (None,{"doi": "xyz.jalc/abc","doi_ra":"JaLC","doi2": None,"doi_ra2":None},{"doi": "xyz.jalc/abc","doi_ra":"JaLC","doi2": None,"doi_ra2":None},[],['Do not specify DOI suffix.'],False,False),
- # 新規登録時DOI付与
- (None,{"doi": "","doi_ra":"","doi2": None,"doi_ra2":None},{"doi": "","doi_ra":"","doi2": None,"doi_ra2":None},[],['Please specify DOI prefix/suffix.'],True,False),
- (None,{"doi": "","doi_ra":"JaLC","doi2": None,"doi_ra2":None},{"doi": "","doi_ra":"JaLC","doi2": "","doi_ra2":"JaLC"},[],['Please specify DOI prefix/suffix.'],True,False),
- (None,{"doi": "xyz.jalc","doi_ra":"JaLC","doi2": None,"doi_ra2":None},{"doi": "xyz.jalc","doi_ra":"JaLC","doi2": "xyz.jalc","doi_ra2":"JaLC"},[],['Please specify DOI suffix.'],True,False),
- (None,{"doi": "xyz.jalc/","doi_ra":"JaLC","doi2": None,"doi_ra2":None},{"doi": "xyz.jalc/","doi_ra":"JaLC","doi2": "xyz.jalc/","doi_ra2":"JaLC"},[],['Please specify DOI suffix.'],True,False),
- (None,{"doi": "xyz.jalc","doi_ra":"","doi2": None,"doi_ra2":None},{"doi": "xyz.jalc","doi_ra":"","doi2": None,"doi_ra2":None},[],['Please specify DOI suffix.', 'DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],True,False),
- (None,{"doi": "xyz.jalc/","doi_ra":"","doi2": None,"doi_ra2":None},{"doi": "xyz.jalc/","doi_ra":"","doi2": None,"doi_ra2":None},[],['Please specify DOI suffix.', 'DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],True,False),
- (None,{"doi": "","doi_ra":"JaLC2","doi2": None,"doi_ra2":None},{"doi": "","doi_ra":"JaLC2","doi2": None,"doi_ra2":None},[],['Please specify DOI prefix/suffix.', 'DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],True,False),
- (None,{"doi": "xyz.jalc/abc","doi_ra":"JaLC","doi2": None,"doi_ra2":None},{"doi": "xyz.jalc/abc","doi_ra":"JaLC","doi2": "xyz.jalc/abc","doi_ra2":"JaLC"},[],[],True,False),
- # cnri登録可能
- (None,{"cnri":"","doi": "xyz.jalc/abc","doi_ra":"JaLC","doi2": None,"doi_ra2":None},{"cnri":"", "doi": "xyz.jalc/abc","doi_ra":"JaLC","doi2": "xyz.jalc/abc","doi_ra2":"JaLC"},[],[],True,True),
- (None,{"cnri":"","doi": "","doi_ra":"","doi2": None,"doi_ra2":None},{"cnri":"","doi": "","doi_ra":"","doi2": None,"doi_ra2":None},[],['Please specify DOI prefix/suffix.'],True,True),
- (None,{"cnri":"test_cnri","doi": "xyz.jalc/abc","doi_ra":"JaLC","doi2": None,"doi_ra2":None},{"cnri":"test_cnri","doi": "xyz.jalc/abc","doi_ra":"JaLC","doi2": "xyz.jalc/abc","doi_ra2":"JaLC"},[],[],True,True),
- (None,{"cnri":"test_cnri","doi": "","doi_ra":"","doi2": None,"doi_ra2":None},{"cnri":"test_cnri","doi": "","doi_ra":"","doi2": None,"doi_ra2":None},[],[],True,True),
+ ({"doi": "xyz.jalc/0000000001","doi_ra":"JaLC","doi2": "xyz.jalc/0000000001","doi_ra2":"JaLC"},{"doi": "xyz.jalc/0000000001","doi_ra":"JaLC","doi2": "xyz.jalc/0000000001","doi_ra2":"JaLC"},[],[],False),
+ ({"doi": "","doi_ra":"", "doi2": "","doi_ra2":""},{"doi": "xyz.jalc/0000000001","doi_ra":"JaLC","doi2": "xyz.jalc/0000000001","doi_ra2":"JaLC"},['The specified DOI is wrong and fixed with the registered DOI.', 'The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],[],False),
+ ({"doi": "xyz.jalc/0000000001","doi_ra":"", "doi2": "","doi_ra2":""},{"doi": "xyz.jalc/0000000001","doi_ra":"JaLC","doi2": None,"doi_ra2":None},['The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],['DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],False),
+ ({"doi": "xyz.jalc/0000000001","doi_ra":"JaLC", "doi2": "","doi_ra2":""},{"doi": "xyz.jalc/0000000001","doi_ra":"JaLC","doi2": "xyz.jalc/0000000001","doi_ra2":"JaLC"},[],[],False),
+ ({"doi": "xyz.jalc/0000000001","doi_ra":"JaLC", "doi2": "xyz.jalc/0000000001","doi_ra2":""},{"doi": "xyz.jalc/0000000001","doi_ra":"JaLC","doi2": "xyz.jalc/0000000001","doi_ra2":"JaLC"},[],[],False),
+ ({"doi": "xyz.jalc/0000000001","doi_ra":"JaLC", "doi2": "","doi_ra2":"JaLC"},{"doi": "xyz.jalc/0000000001","doi_ra":"JaLC","doi2": "xyz.jalc/0000000001","doi_ra2":"JaLC"},[],[],False),
+ ({"doi": "xyz.jalc/0000000001","doi_ra":"JaLC", "doi2": "","doi_ra2":"DataCite"},{"doi": "xyz.jalc/0000000001","doi_ra":"JaLC","doi2": "xyz.jalc/0000000001","doi_ra2":"JaLC"},['The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],[],False),
+ ({"doi": "xyz.jalc/0000000001","doi_ra":"JaLC", "doi2": "xyz.jalc/0000000001","doi_ra2":"DataCite"},{"doi": "xyz.jalc/0000000001","doi_ra":"JaLC","doi2": "xyz.jalc/0000000001","doi_ra2":"JaLC"},['The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],[],False),
+ ({"doi": "xyz.jalc/0000000001","doi_ra":"JaLC", "doi2": "xyz.jalc/0000000002","doi_ra2":"DataCite"},{"doi": "xyz.jalc/0000000001","doi_ra":"JaLC","doi2": "xyz.jalc/0000000001","doi_ra2":"JaLC"},['The specified DOI is wrong and fixed with the registered DOI.', 'The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],[],False),
+ ({"doi": "xyz.jalc/0000000001","doi_ra":"JaLC", "doi2": "","doi_ra2":"JaLC2"},{"doi": "xyz.jalc/0000000001","doi_ra":"JaLC","doi2": "xyz.jalc/0000000001","doi_ra2":"JaLC"},['The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],[],False),
+ ({"doi": "xyz.jalc/0000000002","doi_ra":"JaLC","doi2": "","doi_ra2":""},{"doi": "xyz.jalc/0000000001","doi_ra":"JaLC","doi2": "xyz.jalc/0000000001","doi_ra2":"JaLC"},['The specified DOI is wrong and fixed with the registered DOI.'],[],False),
+ ({"doi": "xyz.jalc/0000000002","doi_ra":"JaLC","doi2": "xyz.jalc/0000000001","doi_ra2":"JaLC"},{"doi": "xyz.jalc/0000000001","doi_ra":"JaLC","doi2": "xyz.jalc/0000000001","doi_ra2":"JaLC"},['The specified DOI is wrong and fixed with the registered DOI.'],[],False),
+ ({"doi": "xyz.jalc/0000000002","doi_ra":"JaLC2","doi2": "xyz.jalc/0000000001","doi_ra2":"JaLC"},{"doi": "xyz.jalc/0000000001","doi_ra":"JaLC","doi2": None,"doi_ra2":None},['The specified DOI is wrong and fixed with the registered DOI.', 'The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],['DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],False),
+ ({"doi": "xyz.jalc/0000000002","doi_ra":"JaLC","doi2": "xyz.jalc/0000000002","doi_ra2":"JaLC"},{"doi": "xyz.jalc/0000000001","doi_ra":"JaLC","doi2": "xyz.jalc/0000000001","doi_ra2":"JaLC"},['The specified DOI is wrong and fixed with the registered DOI.'],[],False),
+ ({"doi": None,"doi_ra":None,"doi2": None,"doi_ra2":None},{"doi": "xyz.jalc/0000000001","doi_ra":"JaLC","doi2": "xyz.jalc/0000000001","doi_ra2":"JaLC"},['The specified DOI is wrong and fixed with the registered DOI.','The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],[],False),
+ ({"doi": "xyz.jalc/0000000001","doi_ra":None,"doi2": None,"doi_ra2":None},{"doi": "xyz.jalc/0000000001","doi_ra":"JaLC","doi2": "xyz.jalc/0000000001","doi_ra2":"JaLC"},['The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],['DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],False),
+ ({"doi": None,"doi_ra":"JaLC","doi2": None,"doi_ra2":None},{"doi": "xyz.jalc/0000000001","doi_ra":"JaLC","doi2": "xyz.jalc/0000000001","doi_ra2":"JaLC"},['The specified DOI is wrong and fixed with the registered DOI.'],[],False),
+ ({"doi": "xyz.jalc/0000000001","doi_ra":"JaLC","doi2": "xyz.jalc/0000000001","doi_ra2":"JaLC"},{"doi": "xyz.jalc/0000000001","doi_ra":"JaLC","doi2": "xyz.jalc/0000000001","doi_ra2":"JaLC"},[],[],True),
+ ({"doi": "","doi_ra":"", "doi2": "","doi_ra2":""},{"doi": "","doi_ra":"","doi2": "","doi_ra2":""},[],['Please specify DOI prefix/suffix.'],True),
+ ({"doi": "xyz.jalc/0000000001","doi_ra":"", "doi2": "","doi_ra2":""},{"doi": "xyz.jalc/0000000001","doi_ra":"","doi2": None,"doi_ra2":None},[],['DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],True),
+
+ ({"doi": "xyz.jalc/0000000001","doi_ra":"JaLC", "doi2": "","doi_ra2":""},{"doi": "xyz.jalc/0000000001","doi_ra":"JaLC","doi2": "xyz.jalc/0000000001","doi_ra2":"JaLC"},[],[],True),
+ ({"doi": "xyz.jalc/0000000001","doi_ra":"JaLC", "doi2": "xyz.jalc/0000000001","doi_ra2":""},{"doi": "xyz.jalc/0000000001","doi_ra":"JaLC","doi2": "xyz.jalc/0000000001","doi_ra2":"JaLC"},[],[],True),
+ ({"doi": "xyz.jalc/0000000001","doi_ra":"JaLC", "doi2": "","doi_ra2":"JaLC"},{"doi": "xyz.jalc/0000000001","doi_ra":"JaLC","doi2": "xyz.jalc/0000000001","doi_ra2":"JaLC"},[],[],True),
+ ({"doi": "xyz.jalc/0000000001","doi_ra":"JaLC", "doi2": "","doi_ra2":"DataCite"},{"doi": "xyz.jalc/0000000001","doi_ra":"JaLC","doi2": "xyz.jalc/0000000001","doi_ra2":"JaLC"},['The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],[],True),
+ ({"doi": "xyz.jalc/0000000001","doi_ra":"JaLC", "doi2": "xyz.jalc/0000000001","doi_ra2":"DataCite"},{"doi": "xyz.jalc/0000000001","doi_ra":"JaLC","doi2": "xyz.jalc/0000000001","doi_ra2":"JaLC"},['The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],[],True),
+ ({"doi": "xyz.jalc/0000000001","doi_ra":"JaLC", "doi2": "xyz.jalc/0000000002","doi_ra2":"DataCite"},{"doi": "xyz.jalc/0000000001","doi_ra":"JaLC","doi2": "xyz.jalc/0000000001","doi_ra2":"JaLC"},['The specified DOI is wrong and fixed with the registered DOI.', 'The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],[],True),
+ ({"doi": "xyz.jalc/0000000001","doi_ra":"JaLC", "doi2": "","doi_ra2":"JaLC2"},{"doi": "xyz.jalc/0000000001","doi_ra":"JaLC","doi2": "xyz.jalc/0000000001","doi_ra2":"JaLC"},['The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],[],True),
+ ({"doi": "xyz.jalc/0000000002","doi_ra":"JaLC","doi2": "","doi_ra2":""},{"doi": "xyz.jalc/0000000002","doi_ra":"JaLC","doi2": "xyz.jalc/0000000002","doi_ra2":"JaLC"},[],[],True),
+ ({"doi": "xyz.jalc/0000000002","doi_ra":"JaLC","doi2": "xyz.jalc/0000000001","doi_ra2":"JaLC"},{"doi": "xyz.jalc/0000000002","doi_ra":"JaLC","doi2": "xyz.jalc/0000000002","doi_ra2":"JaLC"},['The specified DOI is wrong and fixed with the registered DOI.'],[],True),
+ ({"doi": "xyz.jalc/0000000002","doi_ra":"JaLC2","doi2": "xyz.jalc/0000000001","doi_ra2":"JaLC"},{"doi": "xyz.jalc/0000000002","doi_ra":"JaLC2","doi2": None,"doi_ra2":None},[],['DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],True),
+ ({"doi": "xyz.jalc/0000000002","doi_ra":"JaLC","doi2": "xyz.jalc/0000000002","doi_ra2":"JaLC"},{"doi": "xyz.jalc/0000000002","doi_ra":"JaLC","doi2": "xyz.jalc/0000000002","doi_ra2":"JaLC"},[],[],True),
+ ({"doi": None,"doi_ra":None,"doi2": None,"doi_ra2":None},{"doi": "","doi_ra":"","doi2": None,"doi_ra2":None},[],['Please specify DOI prefix/suffix.'],True),
+ ({"doi": "xyz.jalc/0000000001","doi_ra":None,"doi2": None,"doi_ra2":None},{"doi": "xyz.jalc/0000000001","doi_ra":"","doi2": None,"doi_ra2":None},[],['DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],True),
+ ({"doi": None,"doi_ra":"JaLC","doi2": None,"doi_ra2":None},{"doi": "","doi_ra":"JaLC","doi2": "","doi_ra2":"JaLC"},[],['Please specify DOI prefix/suffix.'],True),
])
-def test_handle_fill_system_item3(app,doi_records,item_id,before_doi,after_doi,warnings,errors,is_change_identifier,is_register_cnri):
+def test_handle_fill_system_item3_id1(app,doi_records,before_doi,after_doi,warnings,errors,is_change_identifier):
+ item_id = 1
app.config.update(
- WEKO_HANDLE_ALLOW_REGISTER_CRNI=is_register_cnri
+ WEKO_HANDLE_ALLOW_REGISTER_CRNI=False
)
before = {
"metadata": {
@@ -1698,29 +1517,28 @@ def test_handle_fill_system_item3(app,doi_records,item_id,before_doi,after_doi,w
"item_type_id": 1,
"$schema": "https://localhost:8443/items/jsonschema/1",
}
-
- if item_id:
- before["id"] = "{}".format(item_id)
- before["uri"] = "https://localhost:8443/records/{}".format(item_id)
- before["metadata"]["item_1617605131499"][0]["url"] = {"url": "https://weko3.example.org/record/{}/files/a.zip".format(item_id)}
+
+ before["id"] = "{}".format(item_id)
+ before["uri"] = "https://localhost:8443/records/{}".format(item_id)
+ before["metadata"]["item_1617605131499"][0]["url"] = {"url": "https://weko3.example.org/record/{}/files/a.zip".format(item_id)}
if before_doi["doi_ra2"] is not None:
before["metadata"]["item_1617186819068"]=before["metadata"].get("item_1617186819068",{})
before["metadata"]["item_1617186819068"]["subitem_identifier_reg_type"]= "{}".format(before_doi['doi_ra2'])
-
+
if before_doi["doi2"] is not None:
before["metadata"]["item_1617186819068"]=before["metadata"].get("item_1617186819068",{})
before["metadata"]["item_1617186819068"]["subitem_identifier_reg_text"]= "{}".format(before_doi['doi2'])
if before_doi['doi_ra'] is not None:
before["doi_ra"]="{}".format(before_doi['doi_ra'])
-
+
if before_doi['doi'] is not None:
before["doi"]="{}".format(before_doi['doi'])
-
+
if "cnri" in before_doi and before_doi["cnri"] is not None:
before["cnri"] = "{}".format(before_doi["cnri"])
-
+
before_list = [before]
after = {
"metadata": {
@@ -1755,30 +1573,29 @@ def test_handle_fill_system_item3(app,doi_records,item_id,before_doi,after_doi,w
"warnings": warnings,
}
- if item_id:
- after["id"] = "{}".format(item_id)
- after["uri"] = "https://localhost:8443/records/{}".format(item_id)
- after["metadata"]["item_1617605131499"][0]["url"] = {"url": "https://weko3.example.org/record/{}/files/a.zip".format(item_id)}
-
+ after["id"] = "{}".format(item_id)
+ after["uri"] = "https://localhost:8443/records/{}".format(item_id)
+ after["metadata"]["item_1617605131499"][0]["url"] = {"url": "https://weko3.example.org/record/{}/files/a.zip".format(item_id)}
+
if after_doi["doi_ra"] is not None:
after["doi_ra"]="{}".format(after_doi['doi_ra'])
-
+
if after_doi["doi"] is not None:
- after["doi"]="{}".format(after_doi["doi"])
-
+ after["doi"]="{}".format(after_doi["doi"])
+
if after_doi["doi_ra2"] is not None:
after["metadata"]["item_1617186819068"]=after["metadata"].get("item_1617186819068",{})
after["metadata"]["item_1617186819068"]["subitem_identifier_reg_type"]= "{}".format(after_doi['doi_ra2'])
-
+
if after_doi["doi2"] is not None:
after["metadata"]["item_1617186819068"]= after["metadata"].get("item_1617186819068",{})
after["metadata"]["item_1617186819068"]["subitem_identifier_reg_text"]= "{}".format(after_doi['doi2'])
if "cnri" in after_doi and after_doi["cnri"] is not None:
after["cnri"] = after_doi["cnri"]
-
+
after_list = [after]
-
+
if is_change_identifier:
before_list[0]['is_change_identifier']=True
after_list[0]['is_change_identifier']=True
@@ -1788,116 +1605,925 @@ def test_handle_fill_system_item3(app,doi_records,item_id,before_doi,after_doi,w
handle_fill_system_item(before_list)
assert after_list == before_list
+# .tox/c1/bin/pytest --cov=weko_search_ui tests/test_utils.py::test_handle_fill_system_item3_id2 -vv -s --cov-branch --cov-report=term --basetemp=/code/modules/weko-search-ui/.tox/c1/tmp
+# doi2, doi_ra2 は自動補完が原則
+@pytest.mark.parametrize(
+ "before_doi,after_doi,warnings,errors,is_change_identifier",
+ [
+ ({"doi": "xyz.crossref/0000000002","doi_ra":"Crossref","doi2": "xyz.crossref/0000000002","doi_ra2":"Crossref"},{"doi": "xyz.crossref/0000000002","doi_ra":"Crossref","doi2": "xyz.crossref/0000000002","doi_ra2":"Crossref"},[],[],False),
+ ({"doi": "","doi_ra":"", "doi2": "","doi_ra2":""},{"doi": "xyz.crossref/0000000002","doi_ra":"Crossref","doi2": "xyz.crossref/0000000002","doi_ra2":"Crossref"},['The specified DOI is wrong and fixed with the registered DOI.', 'The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],[],False),
+ ({"doi": "xyz.crossref/0000000002","doi_ra":"", "doi2": "","doi_ra2":""},{"doi": "xyz.crossref/0000000002","doi_ra":"Crossref","doi2": None,"doi_ra2":None},['The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],['DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],False),
+ ({"doi": "xyz.crossref/0000000002","doi_ra":"Crossref", "doi2": "","doi_ra2":""},{"doi": "xyz.crossref/0000000002","doi_ra":"Crossref","doi2": "xyz.crossref/0000000002","doi_ra2":"Crossref"},[],[],False),
+ ({"doi": "xyz.crossref/0000000002","doi_ra":"Crossref", "doi2": "xyz.crossref/0000000002","doi_ra2":""},{"doi": "xyz.crossref/0000000002","doi_ra":"Crossref","doi2": "xyz.crossref/0000000002","doi_ra2":"Crossref"},[],[],False),
+ ({"doi": "xyz.crossref/0000000002","doi_ra":"Crossref", "doi2": "","doi_ra2":"Crossref"},{"doi": "xyz.crossref/0000000002","doi_ra":"Crossref","doi2": "xyz.crossref/0000000002","doi_ra2":"Crossref"},[],[],False),
+ ({"doi": "xyz.crossref/0000000002","doi_ra":"Crossref", "doi2": "","doi_ra2":"DataCite"},{"doi": "xyz.crossref/0000000002","doi_ra":"Crossref","doi2": "xyz.crossref/0000000002","doi_ra2":"Crossref"},['The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],[],False),
+ ({"doi": "xyz.crossref/0000000002","doi_ra":"Crossref", "doi2": "xyz.crossref/0000000002","doi_ra2":"DataCite"},{"doi": "xyz.crossref/0000000002","doi_ra":"Crossref","doi2": "xyz.crossref/0000000002","doi_ra2":"Crossref"},['The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],[],False),
+ ({"doi": "xyz.crossref/0000000002","doi_ra":"Crossref", "doi2": "xyz.crossref/0000000003","doi_ra2":"DataCite"},{"doi": "xyz.crossref/0000000002","doi_ra":"Crossref","doi2": "xyz.crossref/0000000002","doi_ra2":"Crossref"},['The specified DOI is wrong and fixed with the registered DOI.', 'The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],[],False),
+ ({"doi": "xyz.crossref/0000000002","doi_ra":"Crossref", "doi2": "","doi_ra2":"JaLC2"},{"doi": "xyz.crossref/0000000002","doi_ra":"Crossref","doi2": "xyz.crossref/0000000002","doi_ra2":"Crossref"},['The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],[],False),
+ ({"doi": "xyz.crossref/0000000003","doi_ra":"Crossref","doi2": "","doi_ra2":""},{"doi": "xyz.crossref/0000000002","doi_ra":"Crossref","doi2": "xyz.crossref/0000000002","doi_ra2":"Crossref"},['The specified DOI is wrong and fixed with the registered DOI.'],[],False),
+ ({"doi": "xyz.crossref/0000000003","doi_ra":"Crossref","doi2": "xyz.crossref/0000000002","doi_ra2":"Crossref"},{"doi": "xyz.crossref/0000000002","doi_ra":"Crossref","doi2": "xyz.crossref/0000000002","doi_ra2":"Crossref"},['The specified DOI is wrong and fixed with the registered DOI.'],[],False),
+ ({"doi": "xyz.crossref/0000000003","doi_ra":"JaLC2","doi2": "xyz.crossref/0000000002","doi_ra2":"Crossref"},{"doi": "xyz.crossref/0000000002","doi_ra":"Crossref","doi2": None,"doi_ra2":None},['The specified DOI is wrong and fixed with the registered DOI.', 'The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],['DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],False),
+ ({"doi": "xyz.crossref/0000000003","doi_ra":"Crossref","doi2": "xyz.crossref/0000000003","doi_ra2":"Crossref"},{"doi": "xyz.crossref/0000000002","doi_ra":"Crossref","doi2": "xyz.crossref/0000000002","doi_ra2":"Crossref"},['The specified DOI is wrong and fixed with the registered DOI.'],[],False),
+ ({"doi": None,"doi_ra":None,"doi2": None,"doi_ra2":None},{"doi": "xyz.crossref/0000000002","doi_ra":"Crossref","doi2": "xyz.crossref/0000000002","doi_ra2":"Crossref"},['The specified DOI is wrong and fixed with the registered DOI.','The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],[],False),
+ ({"doi": "xyz.crossref/0000000002","doi_ra":None,"doi2": None,"doi_ra2":None},{"doi": "xyz.crossref/0000000002","doi_ra":"Crossref","doi2": "xyz.crossref/0000000002","doi_ra2":"Crossref"},['The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],['DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],False),
+ ({"doi": None,"doi_ra":"Crossref","doi2": None,"doi_ra2":None},{"doi": "xyz.crossref/0000000002","doi_ra":"Crossref","doi2": "xyz.crossref/0000000002","doi_ra2":"Crossref"},['The specified DOI is wrong and fixed with the registered DOI.'],[],False),
+
+ ({"doi": "xyz.crossref/0000000002","doi_ra":"Crossref","doi2": "xyz.crossref/0000000002","doi_ra2":"Crossref"},{"doi": "xyz.crossref/0000000002","doi_ra":"Crossref","doi2": "xyz.crossref/0000000002","doi_ra2":"Crossref"},[],[],True),
+ ({"doi": "","doi_ra":"", "doi2": "","doi_ra2":""},{"doi": "","doi_ra":"","doi2": "","doi_ra2":""},[],['Please specify DOI prefix/suffix.'],True),
+ ({"doi": "xyz.crossref/0000000002","doi_ra":"", "doi2": "","doi_ra2":""},{"doi": "xyz.crossref/0000000002","doi_ra":"","doi2": None,"doi_ra2":None},[],['DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],True),
+
+ ({"doi": "xyz.crossref/0000000002","doi_ra":"Crossref", "doi2": "","doi_ra2":""},{"doi": "xyz.crossref/0000000002","doi_ra":"Crossref","doi2": "xyz.crossref/0000000002","doi_ra2":"Crossref"},[],[],True),
+ ({"doi": "xyz.crossref/0000000002","doi_ra":"Crossref", "doi2": "xyz.crossref/0000000002","doi_ra2":""},{"doi": "xyz.crossref/0000000002","doi_ra":"Crossref","doi2": "xyz.crossref/0000000002","doi_ra2":"Crossref"},[],[],True),
+ ({"doi": "xyz.crossref/0000000002","doi_ra":"Crossref", "doi2": "","doi_ra2":"Crossref"},{"doi": "xyz.crossref/0000000002","doi_ra":"Crossref","doi2": "xyz.crossref/0000000002","doi_ra2":"Crossref"},[],[],True),
+ ({"doi": "xyz.crossref/0000000002","doi_ra":"Crossref", "doi2": "","doi_ra2":"DataCite"},{"doi": "xyz.crossref/0000000002","doi_ra":"Crossref","doi2": "xyz.crossref/0000000002","doi_ra2":"Crossref"},['The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],[],True),
+ ({"doi": "xyz.crossref/0000000002","doi_ra":"Crossref", "doi2": "xyz.crossref/0000000002","doi_ra2":"DataCite"},{"doi": "xyz.crossref/0000000002","doi_ra":"Crossref","doi2": "xyz.crossref/0000000002","doi_ra2":"Crossref"},['The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],[],True),
+ ({"doi": "xyz.crossref/0000000002","doi_ra":"Crossref", "doi2": "xyz.crossref/0000000003","doi_ra2":"DataCite"},{"doi": "xyz.crossref/0000000002","doi_ra":"Crossref","doi2": "xyz.crossref/0000000002","doi_ra2":"Crossref"},['The specified DOI is wrong and fixed with the registered DOI.', 'The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],[],True),
+ ({"doi": "xyz.crossref/0000000002","doi_ra":"Crossref", "doi2": "","doi_ra2":"JaLC2"},{"doi": "xyz.crossref/0000000002","doi_ra":"Crossref","doi2": "xyz.crossref/0000000002","doi_ra2":"Crossref"},['The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],[],True),
+ ({"doi": "xyz.crossref/0000000003","doi_ra":"Crossref","doi2": "","doi_ra2":""},{"doi": "xyz.crossref/0000000003","doi_ra":"Crossref","doi2": "xyz.crossref/0000000003","doi_ra2":"Crossref"},[],[],True),
+ ({"doi": "xyz.crossref/0000000003","doi_ra":"Crossref","doi2": "xyz.crossref/0000000002","doi_ra2":"Crossref"},{"doi": "xyz.crossref/0000000003","doi_ra":"Crossref","doi2": "xyz.crossref/0000000003","doi_ra2":"Crossref"},['The specified DOI is wrong and fixed with the registered DOI.'],[],True),
+ ({"doi": "xyz.crossref/0000000003","doi_ra":"JaLC2","doi2": "xyz.crossref/0000000002","doi_ra2":"Crossref"},{"doi": "xyz.crossref/0000000003","doi_ra":"JaLC2","doi2": None,"doi_ra2":None},[],['DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],True),
+ ({"doi": "xyz.crossref/0000000003","doi_ra":"Crossref","doi2": "xyz.crossref/0000000003","doi_ra2":"Crossref"},{"doi": "xyz.crossref/0000000003","doi_ra":"Crossref","doi2": "xyz.crossref/0000000003","doi_ra2":"Crossref"},[],[],True),
+ ({"doi": None,"doi_ra":None,"doi2": None,"doi_ra2":None},{"doi": "","doi_ra":"","doi2": None,"doi_ra2":None},[],['Please specify DOI prefix/suffix.'],True),
+ ({"doi": "xyz.crossref/0000000002","doi_ra":None,"doi2": None,"doi_ra2":None},{"doi": "xyz.crossref/0000000002","doi_ra":"","doi2": None,"doi_ra2":None},[],['DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],True),
+ ({"doi": None,"doi_ra":"Crossref","doi2": None,"doi_ra2":None},{"doi": "","doi_ra":"Crossref","doi2": "","doi_ra2":"Crossref"},[],['Please specify DOI prefix/suffix.'],True),
+ ])
+def test_handle_fill_system_item3_id2(app,doi_records,before_doi,after_doi,warnings,errors,is_change_identifier):
+ item_id = 2
+ app.config.update(
+ WEKO_HANDLE_ALLOW_REGISTER_CRNI=False
+ )
+ before = {
+ "metadata": {
+ "path": ["1667004052852"],
+ "pubdate": "2022-10-29",
+ "item_1617186331708": [
+ {"subitem_1551255647225": "title", "subitem_1551255648112": "en"}
+ ],
+ "item_1617258105262": {
+ "resourcetype": "conference paper",
+ "resourceuri": "http://purl.org/coar/resource_type/c_5794",
+ },
+ "item_1617605131499": [
+ {
+ "accessrole": "open_access",
+ "date": [{"dateType": "Available", "dateValue": "2022-10-29"}],
+ "filename": "a.zip",
+ "filesize": [{"value": "82 KB"}],
+ "format": "application/zip",
+ }
+ ],
+ },
+ "pos_index": ["IndexA"],
+ "publish_status": "public",
+ "edit_mode": "Keep",
+ "file_path": [""],
+ "item_type_name": "デフォルトアイテムタイプ(フル)",
+ "item_type_id": 1,
+ "$schema": "https://localhost:8443/items/jsonschema/1",
+ }
+
+ before["id"] = "{}".format(item_id)
+ before["uri"] = "https://localhost:8443/records/{}".format(item_id)
+ before["metadata"]["item_1617605131499"][0]["url"] = {"url": "https://weko3.example.org/record/{}/files/a.zip".format(item_id)}
-# def get_thumbnail_key(item_type_id=0):
-def test_get_thumbnail_key(i18n_app, db_itemtype, db_workflow):
- assert get_thumbnail_key(item_type_id=1)
+ if before_doi["doi_ra2"] is not None:
+ before["metadata"]["item_1617186819068"]=before["metadata"].get("item_1617186819068",{})
+ before["metadata"]["item_1617186819068"]["subitem_identifier_reg_type"]= "{}".format(before_doi['doi_ra2'])
+ if before_doi["doi2"] is not None:
+ before["metadata"]["item_1617186819068"]=before["metadata"].get("item_1617186819068",{})
+ before["metadata"]["item_1617186819068"]["subitem_identifier_reg_text"]= "{}".format(before_doi['doi2'])
-# def handle_check_thumbnail_file_type(thumbnail_paths):
-def test_handle_check_thumbnail_file_type(i18n_app):
- assert handle_check_thumbnail_file_type(["/"])
+ if before_doi['doi_ra'] is not None:
+ before["doi_ra"]="{}".format(before_doi['doi_ra'])
+ if before_doi['doi'] is not None:
+ before["doi"]="{}".format(before_doi['doi'])
-# def handle_check_metadata_not_existed(str_keys, item_type_id=0): *** not yet done
-def test_handle_check_metadata_not_existed(i18n_app, db_itemtype):
- # Test 1
- assert not handle_check_metadata_not_existed(
- ".metadata", db_itemtype["item_type"].id
- )
+ if "cnri" in before_doi and before_doi["cnri"] is not None:
+ before["cnri"] = "{}".format(before_doi["cnri"])
+
+ before_list = [before]
+ after = {
+ "metadata": {
+ "path": ["1667004052852"],
+ "pubdate": "2022-10-29",
+ "item_1617186331708": [
+ {"subitem_1551255647225": "title", "subitem_1551255648112": "en"}
+ ],
+ "item_1617258105262": {
+ "resourcetype": "conference paper",
+ "resourceuri": "http://purl.org/coar/resource_type/c_5794",
+ },
+ "item_1617605131499": [
+ {
+ "accessrole": "open_access",
+ "date": [{"dateType": "Available", "dateValue": "2022-10-29"}],
+ "filename": "a.zip",
+ "filesize": [{"value": "82 KB"}],
+ "format": "application/zip",
+ }
+ ],
+ },
+ "pos_index": ["IndexA"],
+ "publish_status": "public",
+ "edit_mode": "Keep",
+ "file_path": [""],
+ "item_type_name": "デフォルトアイテムタイプ(フル)",
+ "item_type_id": 1,
+ "$schema": "https://localhost:8443/items/jsonschema/1",
+ "identifier_key": "item_1617186819068",
+ "errors": errors,
+ "warnings": warnings,
+ }
+ after["id"] = "{}".format(item_id)
+ after["uri"] = "https://localhost:8443/records/{}".format(item_id)
+ after["metadata"]["item_1617605131499"][0]["url"] = {"url": "https://weko3.example.org/record/{}/files/a.zip".format(item_id)}
-# def handle_get_all_sub_id_and_name(items, root_id=None, root_name=None, form=[]):
+ if after_doi["doi_ra"] is not None:
+ after["doi_ra"]="{}".format(after_doi['doi_ra'])
+
+ if after_doi["doi"] is not None:
+ after["doi"]="{}".format(after_doi["doi"])
+
+ if after_doi["doi_ra2"] is not None:
+ after["metadata"]["item_1617186819068"]=after["metadata"].get("item_1617186819068",{})
+ after["metadata"]["item_1617186819068"]["subitem_identifier_reg_type"]= "{}".format(after_doi['doi_ra2'])
+
+ if after_doi["doi2"] is not None:
+ after["metadata"]["item_1617186819068"]= after["metadata"].get("item_1617186819068",{})
+ after["metadata"]["item_1617186819068"]["subitem_identifier_reg_text"]= "{}".format(after_doi['doi2'])
+
+ if "cnri" in after_doi and after_doi["cnri"] is not None:
+ after["cnri"] = after_doi["cnri"]
+
+ after_list = [after]
+
+ if is_change_identifier:
+ before_list[0]['is_change_identifier']=True
+ after_list[0]['is_change_identifier']=True
+
+ with app.test_request_context():
+ assert before_list != after_list
+ handle_fill_system_item(before_list)
+ assert after_list == before_list
+
+# .tox/c1/bin/pytest --cov=weko_search_ui tests/test_utils.py::test_handle_fill_system_item3_id3 -vv -s --cov-branch --cov-report=term --basetemp=/code/modules/weko-search-ui/.tox/c1/tmp
+# doi2, doi_ra2 は自動補完が原則
@pytest.mark.parametrize(
- "items,root_id,root_name,form,ids,names",
+ "before_doi,after_doi,warnings,errors,is_change_identifier",
[
- pytest.param(
- {"interim": {"type": "string"}},
- ".metadata.item_1657196790737[0]",
- "text[0]",
- [{"key": "item_1657196790737[].interim", "type": "text", "notitle": True}],
- [".metadata.item_1657196790737[0].interim"],
- ["text[0].None"],
- ),
- pytest.param(
- {
- "interim": {
- "enum": [None, "op1", "op2", "op3", "op4"],
- "type": ["null", "string"],
- "title": "list",
- "title_i18n": {"en": "", "ja": ""},
- }
- },
- ".metadata.item_1657204077414[0]",
- "list[0]",
- [
- {
- "key": "item_1657204077414[].interim",
- "type": "select",
- "title": "list",
- "notitle": True,
- "titleMap": [
- {"name": "op1", "value": "op1"},
- {"name": "op2", "value": "op2"},
- {"name": "op3", "value": "op3"},
- {"name": "op4", "value": "op4"},
- ],
- "title_i18n": {"en": "", "ja": ""},
- }
- ],
- [".metadata.item_1657204026946.interim[0]"],
- ["check.check[0]"],
- ),
- pytest.param(
- {
- "interim": {
- "enum": [None, "op1", "op2", "op3", "op4"],
- "type": ["null", "string"],
- "title": "list",
- "format": "select",
- }
- },
- ".metadata.item_1657204070640",
- "list",
- [
- {
- "key": "item_1657204070640.interim",
- "type": "select",
- "title": "list",
- "titleMap": [
- {"name": "op1", "value": "op1"},
- {"name": "op2", "value": "op2"},
- {"name": "op3", "value": "op3"},
- {"name": "op4", "value": "op4"},
- ],
- "title_i18n": {"en": "", "ja": ""},
- }
- ],
- [".metadata.item_1657204036771[0].interim[0]"],
- ["checjk[0].checjk[0]"],
- ),
- pytest.param(
- {
- "interim": {
- "type": "array",
- "items": {"enum": ["op1", "op2", "op3", "op4"], "type": "string"},
- "title": "check",
- "format": "checkboxes",
- "title_i18n": {"en": "", "ja": ""},
- }
+ ({"doi": "xyz.datacite/0000000003","doi_ra":"DataCite","doi2": "xyz.datacite/0000000003","doi_ra2":"DataCite"},{"doi": "xyz.datacite/0000000003","doi_ra":"DataCite","doi2": "xyz.datacite/0000000003","doi_ra2":"DataCite"},[],[],False),
+ ({"doi": "","doi_ra":"", "doi2": "","doi_ra2":""},{"doi": "xyz.datacite/0000000003","doi_ra":"DataCite","doi2": "xyz.datacite/0000000003","doi_ra2":"DataCite"},['The specified DOI is wrong and fixed with the registered DOI.', 'The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],[],False),
+ ({"doi": "xyz.datacite/0000000003","doi_ra":"", "doi2": "","doi_ra2":""},{"doi": "xyz.datacite/0000000003","doi_ra":"DataCite","doi2": None,"doi_ra2":None},['The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],['DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],False),
+ ({"doi": "xyz.datacite/0000000003","doi_ra":"DataCite", "doi2": "","doi_ra2":""},{"doi": "xyz.datacite/0000000003","doi_ra":"DataCite","doi2": "xyz.datacite/0000000003","doi_ra2":"DataCite"},[],[],False),
+ ({"doi": "xyz.datacite/0000000003","doi_ra":"DataCite", "doi2": "xyz.datacite/0000000003","doi_ra2":""},{"doi": "xyz.datacite/0000000003","doi_ra":"DataCite","doi2": "xyz.datacite/0000000003","doi_ra2":"DataCite"},[],[],False),
+ ({"doi": "xyz.datacite/0000000003","doi_ra":"DataCite", "doi2": "","doi_ra2":"DataCite"},{"doi": "xyz.datacite/0000000003","doi_ra":"DataCite","doi2": "xyz.datacite/0000000003","doi_ra2":"DataCite"},[],[],False),
+ ({"doi": "xyz.datacite/0000000003","doi_ra":"DataCite", "doi2": "","doi_ra2":"JaLC"},{"doi": "xyz.datacite/0000000003","doi_ra":"DataCite","doi2": "xyz.datacite/0000000003","doi_ra2":"DataCite"},['The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],[],False),
+ ({"doi": "xyz.datacite/0000000003","doi_ra":"DataCite", "doi2": "xyz.datacite/0000000003","doi_ra2":"JaLC"},{"doi": "xyz.datacite/0000000003","doi_ra":"DataCite","doi2": "xyz.datacite/0000000003","doi_ra2":"DataCite"},['The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],[],False),
+ ({"doi": "xyz.datacite/0000000003","doi_ra":"DataCite", "doi2": "xyz.datacite/0000000004","doi_ra2":"JaLC"},{"doi": "xyz.datacite/0000000003","doi_ra":"DataCite","doi2": "xyz.datacite/0000000003","doi_ra2":"DataCite"},['The specified DOI is wrong and fixed with the registered DOI.', 'The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],[],False),
+ ({"doi": "xyz.datacite/0000000003","doi_ra":"DataCite", "doi2": "","doi_ra2":"JaLC2"},{"doi": "xyz.datacite/0000000003","doi_ra":"DataCite","doi2": "xyz.datacite/0000000003","doi_ra2":"DataCite"},['The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],[],False),
+ ({"doi": "xyz.datacite/0000000004","doi_ra":"DataCite","doi2": "","doi_ra2":""},{"doi": "xyz.datacite/0000000003","doi_ra":"DataCite","doi2": "xyz.datacite/0000000003","doi_ra2":"DataCite"},['The specified DOI is wrong and fixed with the registered DOI.'],[],False),
+ ({"doi": "xyz.datacite/0000000004","doi_ra":"DataCite","doi2": "xyz.datacite/0000000003","doi_ra2":"DataCite"},{"doi": "xyz.datacite/0000000003","doi_ra":"DataCite","doi2": "xyz.datacite/0000000003","doi_ra2":"DataCite"},['The specified DOI is wrong and fixed with the registered DOI.'],[],False),
+ ({"doi": "xyz.datacite/0000000004","doi_ra":"JaLC2","doi2": "xyz.datacite/0000000003","doi_ra2":"DataCite"},{"doi": "xyz.datacite/0000000003","doi_ra":"DataCite","doi2": None,"doi_ra2":None},['The specified DOI is wrong and fixed with the registered DOI.', 'The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],['DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],False),
+ ({"doi": "xyz.datacite/0000000004","doi_ra":"DataCite","doi2": "xyz.datacite/0000000004","doi_ra2":"DataCite"},{"doi": "xyz.datacite/0000000003","doi_ra":"DataCite","doi2": "xyz.datacite/0000000003","doi_ra2":"DataCite"},['The specified DOI is wrong and fixed with the registered DOI.'],[],False),
+ ({"doi": None,"doi_ra":None,"doi2": None,"doi_ra2":None},{"doi": "xyz.datacite/0000000003","doi_ra":"DataCite","doi2": "xyz.datacite/0000000003","doi_ra2":"DataCite"},['The specified DOI is wrong and fixed with the registered DOI.','The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],[],False),
+ ({"doi": "xyz.datacite/0000000003","doi_ra":None,"doi2": None,"doi_ra2":None},{"doi": "xyz.datacite/0000000003","doi_ra":"DataCite","doi2": "xyz.datacite/0000000003","doi_ra2":"DataCite"},['The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],['DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],False),
+ ({"doi": None,"doi_ra":"DataCite","doi2": None,"doi_ra2":None},{"doi": "xyz.datacite/0000000003","doi_ra":"DataCite","doi2": "xyz.datacite/0000000003","doi_ra2":"DataCite"},['The specified DOI is wrong and fixed with the registered DOI.'],[],False),
+
+ ({"doi": "xyz.datacite/0000000003","doi_ra":"DataCite","doi2": "xyz.datacite/0000000003","doi_ra2":"DataCite"},{"doi": "xyz.datacite/0000000003","doi_ra":"DataCite","doi2": "xyz.datacite/0000000003","doi_ra2":"DataCite"},[],[],True),
+ ({"doi": "","doi_ra":"", "doi2": "","doi_ra2":""},{"doi": "","doi_ra":"","doi2": "","doi_ra2":""},[],['Please specify DOI prefix/suffix.'],True),
+ ({"doi": "xyz.datacite/0000000003","doi_ra":"", "doi2": "","doi_ra2":""},{"doi": "xyz.datacite/0000000003","doi_ra":"","doi2": None,"doi_ra2":None},[],['DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],True),
+ ({"doi": "xyz.datacite/0000000003","doi_ra":"DataCite", "doi2": "","doi_ra2":""},{"doi": "xyz.datacite/0000000003","doi_ra":"DataCite","doi2": "xyz.datacite/0000000003","doi_ra2":"DataCite"},[],[],True),
+ ({"doi": "xyz.datacite/0000000003","doi_ra":"DataCite", "doi2": "xyz.datacite/0000000003","doi_ra2":""},{"doi": "xyz.datacite/0000000003","doi_ra":"DataCite","doi2": "xyz.datacite/0000000003","doi_ra2":"DataCite"},[],[],True),
+ ({"doi": "xyz.datacite/0000000003","doi_ra":"DataCite", "doi2": "","doi_ra2":"DataCite"},{"doi": "xyz.datacite/0000000003","doi_ra":"DataCite","doi2": "xyz.datacite/0000000003","doi_ra2":"DataCite"},[],[],True),
+ ({"doi": "xyz.datacite/0000000003","doi_ra":"DataCite", "doi2": "","doi_ra2":"JaLC"},{"doi": "xyz.datacite/0000000003","doi_ra":"DataCite","doi2": "xyz.datacite/0000000003","doi_ra2":"DataCite"},['The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],[],True),
+ ({"doi": "xyz.datacite/0000000003","doi_ra":"DataCite", "doi2": "xyz.datacite/0000000003","doi_ra2":"JaLC"},{"doi": "xyz.datacite/0000000003","doi_ra":"DataCite","doi2": "xyz.datacite/0000000003","doi_ra2":"DataCite"},['The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],[],True),
+ ({"doi": "xyz.datacite/0000000003","doi_ra":"DataCite", "doi2": "xyz.datacite/0000000004","doi_ra2":"JaLC"},{"doi": "xyz.datacite/0000000003","doi_ra":"DataCite","doi2": "xyz.datacite/0000000003","doi_ra2":"DataCite"},['The specified DOI is wrong and fixed with the registered DOI.', 'The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],[],True),
+ ({"doi": "xyz.datacite/0000000003","doi_ra":"DataCite", "doi2": "","doi_ra2":"JaLC2"},{"doi": "xyz.datacite/0000000003","doi_ra":"DataCite","doi2": "xyz.datacite/0000000003","doi_ra2":"DataCite"},['The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],[],True),
+ ({"doi": "xyz.datacite/0000000004","doi_ra":"DataCite","doi2": "","doi_ra2":""},{"doi": "xyz.datacite/0000000004","doi_ra":"DataCite","doi2": "xyz.datacite/0000000004","doi_ra2":"DataCite"},[],[],True),
+ ({"doi": "xyz.datacite/0000000004","doi_ra":"DataCite","doi2": "xyz.datacite/0000000003","doi_ra2":"DataCite"},{"doi": "xyz.datacite/0000000004","doi_ra":"DataCite","doi2": "xyz.datacite/0000000004","doi_ra2":"DataCite"},['The specified DOI is wrong and fixed with the registered DOI.'],[],True),
+ ({"doi": "xyz.datacite/0000000004","doi_ra":"JaLC2","doi2": "xyz.datacite/0000000003","doi_ra2":"DataCite"},{"doi": "xyz.datacite/0000000004","doi_ra":"JaLC2","doi2": None,"doi_ra2":None},[],['DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],True),
+ ({"doi": "xyz.datacite/0000000004","doi_ra":"DataCite","doi2": "xyz.datacite/0000000004","doi_ra2":"DataCite"},{"doi": "xyz.datacite/0000000004","doi_ra":"DataCite","doi2": "xyz.datacite/0000000004","doi_ra2":"DataCite"},[],[],True),
+ ({"doi": None,"doi_ra":None,"doi2": None,"doi_ra2":None},{"doi": "","doi_ra":"","doi2": None,"doi_ra2":None},[],['Please specify DOI prefix/suffix.'],True),
+ ({"doi": "xyz.datacite/0000000003","doi_ra":None,"doi2": None,"doi_ra2":None},{"doi": "xyz.datacite/0000000003","doi_ra":"","doi2": None,"doi_ra2":None},[],['DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],True),
+ ({"doi": None,"doi_ra":"DataCite","doi2": None,"doi_ra2":None},{"doi": "","doi_ra":"DataCite","doi2": "","doi_ra2":"DataCite"},[],['Please specify DOI prefix/suffix.'],True),
+ ])
+def test_handle_fill_system_item3_id3(app,doi_records,before_doi,after_doi,warnings,errors,is_change_identifier):
+ item_id = 3
+ app.config.update(
+ WEKO_HANDLE_ALLOW_REGISTER_CRNI=False
+ )
+ before = {
+ "metadata": {
+ "path": ["1667004052852"],
+ "pubdate": "2022-10-29",
+ "item_1617186331708": [
+ {"subitem_1551255647225": "title", "subitem_1551255648112": "en"}
+ ],
+ "item_1617258105262": {
+ "resourcetype": "conference paper",
+ "resourceuri": "http://purl.org/coar/resource_type/c_5794",
+ },
+ "item_1617605131499": [
+ {
+ "accessrole": "open_access",
+ "date": [{"dateType": "Available", "dateValue": "2022-10-29"}],
+ "filename": "a.zip",
+ "filesize": [{"value": "82 KB"}],
+ "format": "application/zip",
+ }
+ ],
},
- ".metadata.item_1657204026946",
- "check",
- [
- {
- "key": "item_1657204026946.interim",
- "type": "template",
- "title": "check",
- "titleMap": [
- {"name": "op1", "value": "op1"},
- {"name": "op2", "value": "op2"},
- {"name": "op3", "value": "op3"},
- {"name": "op4", "value": "op4"},
+ "pos_index": ["IndexA"],
+ "publish_status": "public",
+ "edit_mode": "Keep",
+ "file_path": [""],
+ "item_type_name": "デフォルトアイテムタイプ(フル)",
+ "item_type_id": 1,
+ "$schema": "https://localhost:8443/items/jsonschema/1",
+ }
+
+ before["id"] = "{}".format(item_id)
+ before["uri"] = "https://localhost:8443/records/{}".format(item_id)
+ before["metadata"]["item_1617605131499"][0]["url"] = {"url": "https://weko3.example.org/record/{}/files/a.zip".format(item_id)}
+
+ if before_doi["doi_ra2"] is not None:
+ before["metadata"]["item_1617186819068"]=before["metadata"].get("item_1617186819068",{})
+ before["metadata"]["item_1617186819068"]["subitem_identifier_reg_type"]= "{}".format(before_doi['doi_ra2'])
+
+ if before_doi["doi2"] is not None:
+ before["metadata"]["item_1617186819068"]=before["metadata"].get("item_1617186819068",{})
+ before["metadata"]["item_1617186819068"]["subitem_identifier_reg_text"]= "{}".format(before_doi['doi2'])
+
+ if before_doi['doi_ra'] is not None:
+ before["doi_ra"]="{}".format(before_doi['doi_ra'])
+
+ if before_doi['doi'] is not None:
+ before["doi"]="{}".format(before_doi['doi'])
+
+ if "cnri" in before_doi and before_doi["cnri"] is not None:
+ before["cnri"] = "{}".format(before_doi["cnri"])
+
+ before_list = [before]
+ after = {
+ "metadata": {
+ "path": ["1667004052852"],
+ "pubdate": "2022-10-29",
+ "item_1617186331708": [
+ {"subitem_1551255647225": "title", "subitem_1551255648112": "en"}
+ ],
+ "item_1617258105262": {
+ "resourcetype": "conference paper",
+ "resourceuri": "http://purl.org/coar/resource_type/c_5794",
+ },
+ "item_1617605131499": [
+ {
+ "accessrole": "open_access",
+ "date": [{"dateType": "Available", "dateValue": "2022-10-29"}],
+ "filename": "a.zip",
+ "filesize": [{"value": "82 KB"}],
+ "format": "application/zip",
+ }
+ ],
+ },
+ "pos_index": ["IndexA"],
+ "publish_status": "public",
+ "edit_mode": "Keep",
+ "file_path": [""],
+ "item_type_name": "デフォルトアイテムタイプ(フル)",
+ "item_type_id": 1,
+ "$schema": "https://localhost:8443/items/jsonschema/1",
+ "identifier_key": "item_1617186819068",
+ "errors": errors,
+ "warnings": warnings,
+ }
+
+ after["id"] = "{}".format(item_id)
+ after["uri"] = "https://localhost:8443/records/{}".format(item_id)
+ after["metadata"]["item_1617605131499"][0]["url"] = {"url": "https://weko3.example.org/record/{}/files/a.zip".format(item_id)}
+
+ if after_doi["doi_ra"] is not None:
+ after["doi_ra"]="{}".format(after_doi['doi_ra'])
+
+ if after_doi["doi"] is not None:
+ after["doi"]="{}".format(after_doi["doi"])
+
+ if after_doi["doi_ra2"] is not None:
+ after["metadata"]["item_1617186819068"]=after["metadata"].get("item_1617186819068",{})
+ after["metadata"]["item_1617186819068"]["subitem_identifier_reg_type"]= "{}".format(after_doi['doi_ra2'])
+
+ if after_doi["doi2"] is not None:
+ after["metadata"]["item_1617186819068"]= after["metadata"].get("item_1617186819068",{})
+ after["metadata"]["item_1617186819068"]["subitem_identifier_reg_text"]= "{}".format(after_doi['doi2'])
+
+ if "cnri" in after_doi and after_doi["cnri"] is not None:
+ after["cnri"] = after_doi["cnri"]
+
+ after_list = [after]
+
+ if is_change_identifier:
+ before_list[0]['is_change_identifier']=True
+ after_list[0]['is_change_identifier']=True
+
+ with app.test_request_context():
+ assert before_list != after_list
+ handle_fill_system_item(before_list)
+ assert after_list == before_list
+
+# .tox/c1/bin/pytest --cov=weko_search_ui tests/test_utils.py::test_handle_fill_system_item3_id4 -vv -s --cov-branch --cov-report=term --basetemp=/code/modules/weko-search-ui/.tox/c1/tmp
+# doi2, doi_ra2 は自動補完が原則
+@pytest.mark.parametrize(
+ "before_doi,after_doi,warnings,errors,is_change_identifier",
+ [
+ ({"doi": "xyz.ndl/0000000004","doi_ra":"NDL JaLC","doi2": "xyz.ndl/0000000004","doi_ra2":"NDL JaLC"},{"doi": "xyz.ndl/0000000004","doi_ra":"NDL JaLC","doi2": "xyz.ndl/0000000004","doi_ra2":"NDL JaLC"},[],[],False),
+ ({"doi": "","doi_ra":"", "doi2": "","doi_ra2":""},{"doi": "xyz.ndl/0000000004","doi_ra":"NDL JaLC","doi2": "xyz.ndl/0000000004","doi_ra2":"NDL JaLC"},['The specified DOI is wrong and fixed with the registered DOI.', 'The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],[],False),
+ ({"doi": "xyz.ndl/0000000004","doi_ra":"", "doi2": "","doi_ra2":""},{"doi": "xyz.ndl/0000000004","doi_ra":"NDL JaLC","doi2": None,"doi_ra2":None},['The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],['DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],False),
+ ({"doi": "xyz.ndl/0000000004","doi_ra":"NDL JaLC", "doi2": "","doi_ra2":""},{"doi": "xyz.ndl/0000000004","doi_ra":"NDL JaLC","doi2": "xyz.ndl/0000000004","doi_ra2":"NDL JaLC"},[],[],False),
+ ({"doi": "xyz.ndl/0000000004","doi_ra":"NDL JaLC", "doi2": "xyz.ndl/0000000004","doi_ra2":""},{"doi": "xyz.ndl/0000000004","doi_ra":"NDL JaLC","doi2": "xyz.ndl/0000000004","doi_ra2":"NDL JaLC"},[],[],False),
+ ({"doi": "xyz.ndl/0000000004","doi_ra":"NDL JaLC", "doi2": "","doi_ra2":"NDL JaLC"},{"doi": "xyz.ndl/0000000004","doi_ra":"NDL JaLC","doi2": "xyz.ndl/0000000004","doi_ra2":"NDL JaLC"},[],[],False),
+ ({"doi": "xyz.ndl/0000000004","doi_ra":"NDL JaLC", "doi2": "","doi_ra2":"DataCite"},{"doi": "xyz.ndl/0000000004","doi_ra":"NDL JaLC","doi2": "xyz.ndl/0000000004","doi_ra2":"NDL JaLC"},['The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],[],False),
+ ({"doi": "xyz.ndl/0000000004","doi_ra":"NDL JaLC", "doi2": "xyz.ndl/0000000004","doi_ra2":"DataCite"},{"doi": "xyz.ndl/0000000004","doi_ra":"NDL JaLC","doi2": "xyz.ndl/0000000004","doi_ra2":"NDL JaLC"},['The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],[],False),
+ ({"doi": "xyz.ndl/0000000004","doi_ra":"NDL JaLC", "doi2": "xyz.ndl/0000000005","doi_ra2":"DataCite"},{"doi": "xyz.ndl/0000000004","doi_ra":"NDL JaLC","doi2": "xyz.ndl/0000000004","doi_ra2":"NDL JaLC"},['The specified DOI is wrong and fixed with the registered DOI.', 'The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],[],False),
+ ({"doi": "xyz.ndl/0000000004","doi_ra":"NDL JaLC", "doi2": "","doi_ra2":"JaLC2"},{"doi": "xyz.ndl/0000000004","doi_ra":"NDL JaLC","doi2": "xyz.ndl/0000000004","doi_ra2":"NDL JaLC"},['The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],[],False),
+ ({"doi": "xyz.ndl/0000000005","doi_ra":"NDL JaLC","doi2": "","doi_ra2":""},{"doi": "xyz.ndl/0000000004","doi_ra":"NDL JaLC","doi2": "xyz.ndl/0000000004","doi_ra2":"NDL JaLC"},['The specified DOI is wrong and fixed with the registered DOI.'],[],False),
+ ({"doi": "xyz.ndl/0000000005","doi_ra":"NDL JaLC","doi2": "xyz.ndl/0000000004","doi_ra2":"NDL JaLC"},{"doi": "xyz.ndl/0000000004","doi_ra":"NDL JaLC","doi2": "xyz.ndl/0000000004","doi_ra2":"NDL JaLC"},['The specified DOI is wrong and fixed with the registered DOI.'],[],False),
+ ({"doi": "xyz.ndl/0000000005","doi_ra":"JaLC2","doi2": "xyz.ndl/0000000004","doi_ra2":"NDL JaLC"},{"doi": "xyz.ndl/0000000004","doi_ra":"NDL JaLC","doi2": None,"doi_ra2":None},['The specified DOI is wrong and fixed with the registered DOI.', 'The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],['DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],False),
+ ({"doi": "xyz.ndl/0000000005","doi_ra":"NDL JaLC","doi2": "xyz.ndl/0000000005","doi_ra2":"NDL JaLC"},{"doi": "xyz.ndl/0000000004","doi_ra":"NDL JaLC","doi2": "xyz.ndl/0000000004","doi_ra2":"NDL JaLC"},['The specified DOI is wrong and fixed with the registered DOI.'],[],False),
+ ({"doi": None,"doi_ra":None,"doi2": None,"doi_ra2":None},{"doi": "xyz.ndl/0000000004","doi_ra":"NDL JaLC","doi2": "xyz.ndl/0000000004","doi_ra2":"NDL JaLC"},['The specified DOI is wrong and fixed with the registered DOI.','The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],[],False),
+ ({"doi": "xyz.ndl/0000000004","doi_ra":None,"doi2": None,"doi_ra2":None},{"doi": "xyz.ndl/0000000004","doi_ra":"NDL JaLC","doi2": "xyz.ndl/0000000004","doi_ra2":"NDL JaLC"},['The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],['DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],False),
+ ({"doi": None,"doi_ra":"NDL JaLC","doi2": None,"doi_ra2":None},{"doi": "xyz.ndl/0000000004","doi_ra":"NDL JaLC","doi2": "xyz.ndl/0000000004","doi_ra2":"NDL JaLC"},['The specified DOI is wrong and fixed with the registered DOI.'],[],False),
+
+ ({"doi": "xyz.ndl/0000000004","doi_ra":"NDL JaLC","doi2": "xyz.ndl/0000000004","doi_ra2":"NDL JaLC"},{"doi": "xyz.ndl/0000000004","doi_ra":"NDL JaLC","doi2": "xyz.ndl/0000000004","doi_ra2":"NDL JaLC"},[],[],True),
+ ({"doi": "","doi_ra":"", "doi2": "","doi_ra2":""},{"doi": "","doi_ra":"","doi2": "","doi_ra2":""},[],['Please specify DOI prefix/suffix.'],True),
+ ({"doi": "xyz.ndl/0000000004","doi_ra":"", "doi2": "","doi_ra2":""},{"doi": "xyz.ndl/0000000004","doi_ra":"","doi2": None,"doi_ra2":None},[],['DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],True),
+ ({"doi": "xyz.ndl/0000000004","doi_ra":"NDL JaLC", "doi2": "","doi_ra2":""},{"doi": "xyz.ndl/0000000004","doi_ra":"NDL JaLC","doi2": "xyz.ndl/0000000004","doi_ra2":"NDL JaLC"},[],[],True),
+ ({"doi": "xyz.ndl/0000000004","doi_ra":"NDL JaLC", "doi2": "xyz.ndl/0000000004","doi_ra2":""},{"doi": "xyz.ndl/0000000004","doi_ra":"NDL JaLC","doi2": "xyz.ndl/0000000004","doi_ra2":"NDL JaLC"},[],[],True),
+ ({"doi": "xyz.ndl/0000000004","doi_ra":"NDL JaLC", "doi2": "","doi_ra2":"NDL JaLC"},{"doi": "xyz.ndl/0000000004","doi_ra":"NDL JaLC","doi2": "xyz.ndl/0000000004","doi_ra2":"NDL JaLC"},[],[],True),
+ ({"doi": "xyz.ndl/0000000004","doi_ra":"NDL JaLC", "doi2": "","doi_ra2":"DataCite"},{"doi": "xyz.ndl/0000000004","doi_ra":"NDL JaLC","doi2": "xyz.ndl/0000000004","doi_ra2":"NDL JaLC"},['The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],[],True),
+ ({"doi": "xyz.ndl/0000000004","doi_ra":"NDL JaLC", "doi2": "xyz.ndl/0000000004","doi_ra2":"DataCite"},{"doi": "xyz.ndl/0000000004","doi_ra":"NDL JaLC","doi2": "xyz.ndl/0000000004","doi_ra2":"NDL JaLC"},['The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],[],True),
+ ({"doi": "xyz.ndl/0000000004","doi_ra":"NDL JaLC", "doi2": "xyz.ndl/0000000005","doi_ra2":"DataCite"},{"doi": "xyz.ndl/0000000004","doi_ra":"NDL JaLC","doi2": "xyz.ndl/0000000004","doi_ra2":"NDL JaLC"},['The specified DOI is wrong and fixed with the registered DOI.', 'The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],[],True),
+ ({"doi": "xyz.ndl/0000000004","doi_ra":"NDL JaLC", "doi2": "","doi_ra2":"JaLC2"},{"doi": "xyz.ndl/0000000004","doi_ra":"NDL JaLC","doi2": "xyz.ndl/0000000004","doi_ra2":"NDL JaLC"},['The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'],[],True),
+ ({"doi": "xyz.ndl/0000000005","doi_ra":"NDL JaLC","doi2": "","doi_ra2":""},{"doi": "xyz.ndl/0000000005","doi_ra":"NDL JaLC","doi2": "xyz.ndl/0000000005","doi_ra2":"NDL JaLC"},[],[],True),
+ ({"doi": "xyz.ndl/0000000005","doi_ra":"NDL JaLC","doi2": "xyz.ndl/0000000004","doi_ra2":"NDL JaLC"},{"doi": "xyz.ndl/0000000005","doi_ra":"NDL JaLC","doi2": "xyz.ndl/0000000005","doi_ra2":"NDL JaLC"},['The specified DOI is wrong and fixed with the registered DOI.'],[],True),
+ ({"doi": "xyz.ndl/0000000005","doi_ra":"JaLC2","doi2": "xyz.ndl/0000000004","doi_ra2":"NDL JaLC"},{"doi": "xyz.ndl/0000000005","doi_ra":"JaLC2","doi2": None,"doi_ra2":None},[],['DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],True),
+ ({"doi": "xyz.ndl/0000000005","doi_ra":"NDL JaLC","doi2": "xyz.ndl/0000000005","doi_ra2":"NDL JaLC"},{"doi": "xyz.ndl/0000000005","doi_ra":"NDL JaLC","doi2": "xyz.ndl/0000000005","doi_ra2":"NDL JaLC"},[],[],True),
+ ({"doi": None,"doi_ra":None,"doi2": None,"doi_ra2":None},{"doi": "","doi_ra":"","doi2": None,"doi_ra2":None},[],['Please specify DOI prefix/suffix.'],True),
+ ({"doi": "xyz.ndl/0000000004","doi_ra":None,"doi2": None,"doi_ra2":None},{"doi": "xyz.ndl/0000000004","doi_ra":"","doi2":None,"doi_ra2":None},[],['DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],True),
+ ({"doi": None,"doi_ra":"NDL JaLC","doi2": None,"doi_ra2":None},{"doi": "","doi_ra":"NDL JaLC","doi2": "","doi_ra2":"NDL JaLC"},[],['Please specify DOI prefix/suffix.'],True),
+ ])
+def test_handle_fill_system_item3_id4(app,doi_records,before_doi,after_doi,warnings,errors,is_change_identifier):
+ item_id = 4
+ app.config.update(
+ WEKO_HANDLE_ALLOW_REGISTER_CRNI=False
+ )
+ before = {
+ "metadata": {
+ "path": ["1667004052852"],
+ "pubdate": "2022-10-29",
+ "item_1617186331708": [
+ {"subitem_1551255647225": "title", "subitem_1551255648112": "en"}
+ ],
+ "item_1617258105262": {
+ "resourcetype": "conference paper",
+ "resourceuri": "http://purl.org/coar/resource_type/c_5794",
+ },
+ "item_1617605131499": [
+ {
+ "accessrole": "open_access",
+ "date": [{"dateType": "Available", "dateValue": "2022-10-29"}],
+ "filename": "a.zip",
+ "filesize": [{"value": "82 KB"}],
+ "format": "application/zip",
+ }
+ ],
+ },
+ "pos_index": ["IndexA"],
+ "publish_status": "public",
+ "edit_mode": "Keep",
+ "file_path": [""],
+ "item_type_name": "デフォルトアイテムタイプ(フル)",
+ "item_type_id": 1,
+ "$schema": "https://localhost:8443/items/jsonschema/1",
+ }
+
+ before["id"] = "{}".format(item_id)
+ before["uri"] = "https://localhost:8443/records/{}".format(item_id)
+ before["metadata"]["item_1617605131499"][0]["url"] = {"url": "https://weko3.example.org/record/{}/files/a.zip".format(item_id)}
+
+ if before_doi["doi_ra2"] is not None:
+ before["metadata"]["item_1617186819068"]=before["metadata"].get("item_1617186819068",{})
+ before["metadata"]["item_1617186819068"]["subitem_identifier_reg_type"]= "{}".format(before_doi['doi_ra2'])
+
+ if before_doi["doi2"] is not None:
+ before["metadata"]["item_1617186819068"]=before["metadata"].get("item_1617186819068",{})
+ before["metadata"]["item_1617186819068"]["subitem_identifier_reg_text"]= "{}".format(before_doi['doi2'])
+
+ if before_doi['doi_ra'] is not None:
+ before["doi_ra"]="{}".format(before_doi['doi_ra'])
+
+ if before_doi['doi'] is not None:
+ before["doi"]="{}".format(before_doi['doi'])
+
+ if "cnri" in before_doi and before_doi["cnri"] is not None:
+ before["cnri"] = "{}".format(before_doi["cnri"])
+
+ before_list = [before]
+ after = {
+ "metadata": {
+ "path": ["1667004052852"],
+ "pubdate": "2022-10-29",
+ "item_1617186331708": [
+ {"subitem_1551255647225": "title", "subitem_1551255648112": "en"}
+ ],
+ "item_1617258105262": {
+ "resourcetype": "conference paper",
+ "resourceuri": "http://purl.org/coar/resource_type/c_5794",
+ },
+ "item_1617605131499": [
+ {
+ "accessrole": "open_access",
+ "date": [{"dateType": "Available", "dateValue": "2022-10-29"}],
+ "filename": "a.zip",
+ "filesize": [{"value": "82 KB"}],
+ "format": "application/zip",
+ }
+ ],
+ },
+ "pos_index": ["IndexA"],
+ "publish_status": "public",
+ "edit_mode": "Keep",
+ "file_path": [""],
+ "item_type_name": "デフォルトアイテムタイプ(フル)",
+ "item_type_id": 1,
+ "$schema": "https://localhost:8443/items/jsonschema/1",
+ "identifier_key": "item_1617186819068",
+ "errors": errors,
+ "warnings": warnings,
+ }
+
+ after["id"] = "{}".format(item_id)
+ after["uri"] = "https://localhost:8443/records/{}".format(item_id)
+ after["metadata"]["item_1617605131499"][0]["url"] = {"url": "https://weko3.example.org/record/{}/files/a.zip".format(item_id)}
+
+ if after_doi["doi_ra"] is not None:
+ after["doi_ra"]="{}".format(after_doi['doi_ra'])
+
+ if after_doi["doi"] is not None:
+ after["doi"]="{}".format(after_doi["doi"])
+
+ if after_doi["doi_ra2"] is not None:
+ after["metadata"]["item_1617186819068"]=after["metadata"].get("item_1617186819068",{})
+ after["metadata"]["item_1617186819068"]["subitem_identifier_reg_type"]= "{}".format(after_doi['doi_ra2'])
+
+ if after_doi["doi2"] is not None:
+ after["metadata"]["item_1617186819068"]= after["metadata"].get("item_1617186819068",{})
+ after["metadata"]["item_1617186819068"]["subitem_identifier_reg_text"]= "{}".format(after_doi['doi2'])
+
+ if "cnri" in after_doi and after_doi["cnri"] is not None:
+ after["cnri"] = after_doi["cnri"]
+
+ after_list = [after]
+
+ if is_change_identifier:
+ before_list[0]['is_change_identifier']=True
+ after_list[0]['is_change_identifier']=True
+
+ with app.test_request_context():
+ assert before_list != after_list
+ handle_fill_system_item(before_list)
+ assert after_list == before_list
+
+# .tox/c1/bin/pytest --cov=weko_search_ui tests/test_utils.py::test_handle_fill_system_item3_id5 -vv -s --cov-branch --cov-report=term --basetemp=/code/modules/weko-search-ui/.tox/c1/tmp
+# doi2, doi_ra2 は自動補完が原則
+@pytest.mark.parametrize(
+ "before_doi,after_doi,warnings,errors,is_change_identifier",
+ [
+ ({"doi":"","doi_ra":"","doi2":None,"doi_ra2":None},{"doi":"","doi_ra":"","doi2":None,"doi_ra2":None},[],[],False),
+ ({"doi":"","doi_ra":"JaLC","doi2":None,"doi_ra2":None},{"doi":"","doi_ra":"JaLC","doi2":None,"doi_ra2":None},[],[],False),
+ ({"doi":"xyz.jalc","doi_ra":"JaLC","doi2":None,"doi_ra2":None},{"doi":"xyz.jalc","doi_ra":"JaLC","doi2":None,"doi_ra2":None},[],[],False),
+ ({"doi":"xyz.jalc/","doi_ra":"JaLC","doi2":None,"doi_ra2":None},{"doi":"xyz.jalc/","doi_ra":"JaLC","doi2":None,"doi_ra2":None},[],[],False),
+ ({"doi":"xyz.jalc","doi_ra":"","doi2":None,"doi_ra2":None},{"doi":"xyz.jalc","doi_ra":"","doi2":None,"doi_ra2":None},[],['DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],False),
+ ({"doi":"xyz.jalc/","doi_ra":"","doi2":None,"doi_ra2":None},{"doi":"xyz.jalc/","doi_ra":"","doi2":None,"doi_ra2":None},[],['DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],False),
+ ({"doi":"","doi_ra":"Crossref","doi2":None,"doi_ra2":None},{"doi":"","doi_ra":"Crossref","doi2":None,"doi_ra2":None},[],[],False),
+ ({"doi":"xyz.crossref","doi_ra":"Crossref","doi2":None,"doi_ra2":None},{"doi":"xyz.crossref","doi_ra":"Crossref","doi2":None,"doi_ra2":None},[],[],False),
+ ({"doi":"xyz.crossref/","doi_ra":"Crossref","doi2":None,"doi_ra2":None},{"doi":"xyz.crossref/","doi_ra":"Crossref","doi2":None,"doi_ra2":None},[],[],False),
+ ({"doi":"xyz.crossref","doi_ra":"","doi2":None,"doi_ra2":None},{"doi":"xyz.crossref","doi_ra":"","doi2":None,"doi_ra2":None},[],['DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],False),
+ ({"doi":"xyz.crossref/","doi_ra":"","doi2":None,"doi_ra2":None},{"doi":"xyz.crossref/","doi_ra":"","doi2":None,"doi_ra2":None},[],['DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],False),
+ ({"doi":"","doi_ra":"DataCite","doi2":None,"doi_ra2":None},{"doi":"","doi_ra":"DataCite","doi2":None,"doi_ra2":None},[],[],False),
+ ({"doi":"xyz.datacite","doi_ra":"DataCite","doi2":None,"doi_ra2":None},{"doi":"xyz.datacite","doi_ra":"DataCite","doi2":None,"doi_ra2":None},[],[],False),
+ ({"doi":"xyz.datacite/","doi_ra":"DataCite","doi2":None,"doi_ra2":None},{"doi":"xyz.datacite/","doi_ra":"DataCite","doi2":None,"doi_ra2":None},[],[],False),
+ ({"doi":"xyz.datacite","doi_ra":"","doi2":None,"doi_ra2":None},{"doi":"xyz.datacite","doi_ra":"","doi2":None,"doi_ra2":None},[],['DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],False),
+ ({"doi":"xyz.datacite/","doi_ra":"","doi2":None,"doi_ra2":None},{"doi":"xyz.datacite/","doi_ra":"","doi2":None,"doi_ra2":None},[],['DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],False),
+ ({"doi":"","doi_ra":"NDL JaLC","doi2":None,"doi_ra2":None},{"doi":"","doi_ra":"NDL JaLC","doi2":None,"doi_ra2":None},[],[],False),
+ ({"doi":"xyz.ndl","doi_ra":"NDL JaLC","doi2":None,"doi_ra2":None},{"doi":"xyz.ndl","doi_ra":"NDL JaLC","doi2":None,"doi_ra2":None},[],[],False),
+ ({"doi":"xyz.ndl/","doi_ra":"NDL JaLC","doi2":None,"doi_ra2":None},{"doi":"xyz.ndl/","doi_ra":"NDL JaLC","doi2":None,"doi_ra2":None},[],[],False),
+ ({"doi":"xyz.ndl","doi_ra":"","doi2":None,"doi_ra2":None},{"doi":"xyz.ndl","doi_ra":"","doi2":None,"doi_ra2":None},[],['DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],False),
+ ({"doi":"xyz.ndl/","doi_ra":"","doi2":None,"doi_ra2":None},{"doi":"xyz.ndl/","doi_ra":"","doi2":None,"doi_ra2":None},[],['DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],False),
+ ({"doi":"xyz.ndl","doi_ra":"JaLC","doi2":None,"doi_ra2":None},{"doi":"xyz.ndl","doi_ra":"JaLC","doi2":None,"doi_ra2":None},[],['Specified Prefix of DOI is incorrect.'],False),
+ ({"doi":"xyz.ndl/","doi_ra":"JaLC","doi2":None,"doi_ra2":None},{"doi":"xyz.ndl/","doi_ra":"JaLC","doi2":None,"doi_ra2":None},[],['Specified Prefix of DOI is incorrect.'],False),
+ #更新によるDOI付与
+ ({"doi":"","doi_ra":"","doi2":None,"doi_ra2":None},{"doi":"","doi_ra":"","doi2":None,"doi_ra2":None},[],['Please specify DOI prefix/suffix.'],True),
+ ({"doi":"","doi_ra":"JaLC","doi2":None,"doi_ra2":None},{"doi":"","doi_ra":"JaLC","doi2":"","doi_ra2":"JaLC"},[],['Please specify DOI prefix/suffix.'],True),
+ ({"doi":"xyz.jalc","doi_ra":"JaLC","doi2":None,"doi_ra2":None},{"doi":"xyz.jalc","doi_ra":"JaLC","doi2":"xyz.jalc","doi_ra2":"JaLC"},[],['Please specify DOI suffix.'],True),
+ ({"doi":"xyz.jalc/","doi_ra":"JaLC","doi2":None,"doi_ra2":None},{"doi":"xyz.jalc/","doi_ra":"JaLC","doi2":"xyz.jalc/","doi_ra2":"JaLC"},[],['Please specify DOI suffix.'],True),
+ ({"doi":"xyz.jalc/xyz","doi_ra":"JaLC","doi2":None,"doi_ra2":None},{"doi":"xyz.jalc/xyz","doi_ra":"JaLC","doi2":"xyz.jalc/xyz","doi_ra2":"JaLC"},[],[],True),
+ ({"doi":"xyz.jalc","doi_ra":"","doi2":None,"doi_ra2":None},{"doi":"xyz.jalc","doi_ra":"","doi2":None,"doi_ra2":None},[],['Please specify DOI suffix.', 'DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],True),
+ ({"doi":"xyz.jalc/","doi_ra":"","doi2":None,"doi_ra2":None},{"doi":"xyz.jalc/","doi_ra":"","doi2":None,"doi_ra2":None},[],['Please specify DOI suffix.', 'DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],True),
+ ({"doi":"","doi_ra":"Crossref","doi2":None,"doi_ra2":None},{"doi":"","doi_ra":"Crossref","doi2":"","doi_ra2":"Crossref"},[],['Please specify DOI prefix/suffix.'],True),
+ ({"doi":"xyz.crossref","doi_ra":"Crossref","doi2":None,"doi_ra2":None},{"doi":"xyz.crossref","doi_ra":"Crossref","doi2":"xyz.crossref","doi_ra2":"Crossref"},[],['Please specify DOI suffix.'],True),
+ ({"doi":"xyz.crossref/","doi_ra":"Crossref","doi2":None,"doi_ra2":None},{"doi":"xyz.crossref/","doi_ra":"Crossref","doi2":"xyz.crossref/","doi_ra2":"Crossref"},[],['Please specify DOI suffix.'],True),
+ ({"doi":"xyz.crossref","doi_ra":"","doi2":None,"doi_ra2":None},{"doi":"xyz.crossref","doi_ra":"","doi2":None,"doi_ra2":None},[],['Please specify DOI suffix.', 'DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],True),
+ ({"doi":"xyz.crossref/","doi_ra":"","doi2":None,"doi_ra2":None},{"doi":"xyz.crossref/","doi_ra":"","doi2":None,"doi_ra2":None},[],['Please specify DOI suffix.', 'DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],True),
+ ({"doi":"","doi_ra":"DataCite","doi2":None,"doi_ra2":None},{"doi":"","doi_ra":"DataCite","doi2":"","doi_ra2":"DataCite"},[],['Please specify DOI prefix/suffix.'],True),
+ ({"doi":"xyz.datacite","doi_ra":"DataCite","doi2":None,"doi_ra2":None},{"doi":"xyz.datacite","doi_ra":"DataCite","doi2":"xyz.datacite","doi_ra2":"DataCite"},[],['Please specify DOI suffix.'],True),
+ ({"doi":"xyz.datacite/","doi_ra":"DataCite","doi2":None,"doi_ra2":None},{"doi":"xyz.datacite/","doi_ra":"DataCite","doi2":"xyz.datacite/","doi_ra2":"DataCite"},[],['Please specify DOI suffix.'],True),
+ ({"doi":"xyz.datacite","doi_ra":"","doi2":None,"doi_ra2":None},{"doi":"xyz.datacite","doi_ra":"","doi2":None,"doi_ra2":None},[],['Please specify DOI suffix.', 'DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],True),
+ ({"doi":"xyz.datacite/","doi_ra":"","doi2":None,"doi_ra2":None},{"doi":"xyz.datacite/","doi_ra":"","doi2":None,"doi_ra2":None},[],['Please specify DOI suffix.', 'DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],True),
+ ({"doi":"","doi_ra":"NDL JaLC","doi2":None,"doi_ra2":None},{"doi":"","doi_ra":"NDL JaLC","doi2":"","doi_ra2":"NDL JaLC"},[],['Please specify DOI prefix/suffix.'],True),
+ ({"doi":"xyz.ndl","doi_ra":"NDL JaLC","doi2":None,"doi_ra2":None},{"doi":"xyz.ndl","doi_ra":"NDL JaLC","doi2":"xyz.ndl","doi_ra2":"NDL JaLC"},[],['Please specify DOI suffix.'],True),
+ ({"doi":"xyz.ndl/","doi_ra":"NDL JaLC","doi2":None,"doi_ra2":None},{"doi":"xyz.ndl/","doi_ra":"NDL JaLC","doi2":"xyz.ndl/","doi_ra2":"NDL JaLC"},[],['Please specify DOI suffix.'],True),
+ ({"doi":"xyz.ndl","doi_ra":"","doi2":None,"doi_ra2":None},{"doi":"xyz.ndl","doi_ra":"","doi2":None,"doi_ra2":None},[],['Please specify DOI suffix.', 'DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],True),
+ ({"doi":"xyz.ndl/","doi_ra":"","doi2":None,"doi_ra2":None},{"doi":"xyz.ndl/","doi_ra":"","doi2":None,"doi_ra2":None},[],['Please specify DOI suffix.', 'DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],True),
+ ({"doi":"xyz.ndl","doi_ra":"JaLC","doi2":None,"doi_ra2":None},{"doi":"xyz.ndl","doi_ra":"JaLC","doi2":"xyz.ndl","doi_ra2":"JaLC"},[],['Please specify DOI suffix.', 'Specified Prefix of DOI is incorrect.'],True),
+ ({"doi":"xyz.ndl/","doi_ra":"JaLC","doi2":None,"doi_ra2":None},{"doi":"xyz.ndl/","doi_ra":"JaLC","doi2":"xyz.ndl/","doi_ra2":"JaLC"},[],['Please specify DOI suffix.', 'Specified Prefix of DOI is incorrect.'],True),
+ ])
+def test_handle_fill_system_item3_id5(app,doi_records,before_doi,after_doi,warnings,errors,is_change_identifier):
+ item_id = 5
+ app.config.update(
+ WEKO_HANDLE_ALLOW_REGISTER_CRNI=False
+ )
+ before = {
+ "metadata": {
+ "path": ["1667004052852"],
+ "pubdate": "2022-10-29",
+ "item_1617186331708": [
+ {"subitem_1551255647225": "title", "subitem_1551255648112": "en"}
+ ],
+ "item_1617258105262": {
+ "resourcetype": "conference paper",
+ "resourceuri": "http://purl.org/coar/resource_type/c_5794",
+ },
+ "item_1617605131499": [
+ {
+ "accessrole": "open_access",
+ "date": [{"dateType": "Available", "dateValue": "2022-10-29"}],
+ "filename": "a.zip",
+ "filesize": [{"value": "82 KB"}],
+ "format": "application/zip",
+ }
+ ],
+ },
+ "pos_index": ["IndexA"],
+ "publish_status": "public",
+ "edit_mode": "Keep",
+ "file_path": [""],
+ "item_type_name": "デフォルトアイテムタイプ(フル)",
+ "item_type_id": 1,
+ "$schema": "https://localhost:8443/items/jsonschema/1",
+ }
+
+ before["id"] = "{}".format(item_id)
+ before["uri"] = "https://localhost:8443/records/{}".format(item_id)
+ before["metadata"]["item_1617605131499"][0]["url"] = {"url": "https://weko3.example.org/record/{}/files/a.zip".format(item_id)}
+
+ if before_doi["doi_ra2"] is not None:
+ before["metadata"]["item_1617186819068"]=before["metadata"].get("item_1617186819068",{})
+ before["metadata"]["item_1617186819068"]["subitem_identifier_reg_type"]= "{}".format(before_doi['doi_ra2'])
+
+ if before_doi["doi2"] is not None:
+ before["metadata"]["item_1617186819068"]=before["metadata"].get("item_1617186819068",{})
+ before["metadata"]["item_1617186819068"]["subitem_identifier_reg_text"]= "{}".format(before_doi['doi2'])
+
+ if before_doi['doi_ra'] is not None:
+ before["doi_ra"]="{}".format(before_doi['doi_ra'])
+
+ if before_doi['doi'] is not None:
+ before["doi"]="{}".format(before_doi['doi'])
+
+ if "cnri" in before_doi and before_doi["cnri"] is not None:
+ before["cnri"] = "{}".format(before_doi["cnri"])
+
+ before_list = [before]
+ after = {
+ "metadata": {
+ "path": ["1667004052852"],
+ "pubdate": "2022-10-29",
+ "item_1617186331708": [
+ {"subitem_1551255647225": "title", "subitem_1551255648112": "en"}
+ ],
+ "item_1617258105262": {
+ "resourcetype": "conference paper",
+ "resourceuri": "http://purl.org/coar/resource_type/c_5794",
+ },
+ "item_1617605131499": [
+ {
+ "accessrole": "open_access",
+ "date": [{"dateType": "Available", "dateValue": "2022-10-29"}],
+ "filename": "a.zip",
+ "filesize": [{"value": "82 KB"}],
+ "format": "application/zip",
+ }
+ ],
+ },
+ "pos_index": ["IndexA"],
+ "publish_status": "public",
+ "edit_mode": "Keep",
+ "file_path": [""],
+ "item_type_name": "デフォルトアイテムタイプ(フル)",
+ "item_type_id": 1,
+ "$schema": "https://localhost:8443/items/jsonschema/1",
+ "identifier_key": "item_1617186819068",
+ "errors": errors,
+ "warnings": warnings,
+ }
+
+ after["id"] = "{}".format(item_id)
+ after["uri"] = "https://localhost:8443/records/{}".format(item_id)
+ after["metadata"]["item_1617605131499"][0]["url"] = {"url": "https://weko3.example.org/record/{}/files/a.zip".format(item_id)}
+
+ if after_doi["doi_ra"] is not None:
+ after["doi_ra"]="{}".format(after_doi['doi_ra'])
+
+ if after_doi["doi"] is not None:
+ after["doi"]="{}".format(after_doi["doi"])
+
+ if after_doi["doi_ra2"] is not None:
+ after["metadata"]["item_1617186819068"]=after["metadata"].get("item_1617186819068",{})
+ after["metadata"]["item_1617186819068"]["subitem_identifier_reg_type"]= "{}".format(after_doi['doi_ra2'])
+
+ if after_doi["doi2"] is not None:
+ after["metadata"]["item_1617186819068"]= after["metadata"].get("item_1617186819068",{})
+ after["metadata"]["item_1617186819068"]["subitem_identifier_reg_text"]= "{}".format(after_doi['doi2'])
+
+ if "cnri" in after_doi and after_doi["cnri"] is not None:
+ after["cnri"] = after_doi["cnri"]
+
+ after_list = [after]
+
+ if is_change_identifier:
+ before_list[0]['is_change_identifier']=True
+ after_list[0]['is_change_identifier']=True
+
+ with app.test_request_context():
+ assert before_list != after_list
+ handle_fill_system_item(before_list)
+ assert after_list == before_list
+
+# .tox/c1/bin/pytest --cov=weko_search_ui tests/test_utils.py::test_handle_fill_system_item3_id_none -vv -s --cov-branch --cov-report=term --basetemp=/code/modules/weko-search-ui/.tox/c1/tmp
+# doi2, doi_ra2 は自動補完が原則
+@pytest.mark.parametrize(
+ "before_doi,after_doi,warnings,errors,is_change_identifier,is_register_cnri",
+ [
+ # 新規登録時DOI付与
+ ({"doi": "","doi_ra":"","doi2": None,"doi_ra2":None},{"doi": "","doi_ra":"","doi2": None,"doi_ra2":None},[],[],False,False),
+ ({"doi": "","doi_ra":"JaLC","doi2": None,"doi_ra2":None},{"doi": "","doi_ra":"JaLC","doi2": None,"doi_ra2":None},[],[],False,False),
+ ({"doi": "xyz.jalc","doi_ra":"JaLC","doi2": None,"doi_ra2":None},{"doi": "xyz.jalc","doi_ra":"JaLC","doi2": None,"doi_ra2":None},[],[],False,False),
+ ({"doi": "xyz.jalc/","doi_ra":"JaLC","doi2": None,"doi_ra2":None},{"doi": "xyz.jalc/","doi_ra":"JaLC","doi2": None,"doi_ra2":None},[],[],False,False),
+ ({"doi": "xyz.jalc","doi_ra":"","doi2": None,"doi_ra2":None},{"doi": "xyz.jalc","doi_ra":"","doi2": None,"doi_ra2":None},[],['DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],False,False),
+ ({"doi": "xyz.jalc/","doi_ra":"","doi2": None,"doi_ra2":None},{"doi": "xyz.jalc/","doi_ra":"","doi2": None,"doi_ra2":None},[],['DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],False,False),
+ ({"doi": "","doi_ra":"JaLC2","doi2": None,"doi_ra2":None},{"doi": "","doi_ra":"JaLC2","doi2": None,"doi_ra2":None},[],['DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],False,False),
+ ({"doi": "xyz.jalc/abc","doi_ra":"JaLC","doi2": None,"doi_ra2":None},{"doi": "xyz.jalc/abc","doi_ra":"JaLC","doi2": None,"doi_ra2":None},[],['Do not specify DOI suffix.'],False,False),
+ # 新規登録時DOI付与
+ ({"doi": "","doi_ra":"","doi2": None,"doi_ra2":None},{"doi": "","doi_ra":"","doi2": None,"doi_ra2":None},[],['Please specify DOI prefix/suffix.'],True,False),
+ ({"doi": "","doi_ra":"JaLC","doi2": None,"doi_ra2":None},{"doi": "","doi_ra":"JaLC","doi2": "","doi_ra2":"JaLC"},[],['Please specify DOI prefix/suffix.'],True,False),
+ ({"doi": "xyz.jalc","doi_ra":"JaLC","doi2": None,"doi_ra2":None},{"doi": "xyz.jalc","doi_ra":"JaLC","doi2": "xyz.jalc","doi_ra2":"JaLC"},[],['Please specify DOI suffix.'],True,False),
+ ({"doi": "xyz.jalc/","doi_ra":"JaLC","doi2": None,"doi_ra2":None},{"doi": "xyz.jalc/","doi_ra":"JaLC","doi2": "xyz.jalc/","doi_ra2":"JaLC"},[],['Please specify DOI suffix.'],True,False),
+ ({"doi": "xyz.jalc","doi_ra":"","doi2": None,"doi_ra2":None},{"doi": "xyz.jalc","doi_ra":"","doi2": None,"doi_ra2":None},[],['Please specify DOI suffix.', 'DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],True,False),
+ ({"doi": "xyz.jalc/","doi_ra":"","doi2": None,"doi_ra2":None},{"doi": "xyz.jalc/","doi_ra":"","doi2": None,"doi_ra2":None},[],['Please specify DOI suffix.', 'DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],True,False),
+ ({"doi": "","doi_ra":"JaLC2","doi2": None,"doi_ra2":None},{"doi": "","doi_ra":"JaLC2","doi2": None,"doi_ra2":None},[],['Please specify DOI prefix/suffix.', 'DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'],True,False),
+ ({"doi": "xyz.jalc/abc","doi_ra":"JaLC","doi2": None,"doi_ra2":None},{"doi": "xyz.jalc/abc","doi_ra":"JaLC","doi2": "xyz.jalc/abc","doi_ra2":"JaLC"},[],[],True,False),
+ # cnri登録可能
+ ({"cnri":"","doi": "xyz.jalc/abc","doi_ra":"JaLC","doi2": None,"doi_ra2":None},{"cnri":"", "doi": "xyz.jalc/abc","doi_ra":"JaLC","doi2": "xyz.jalc/abc","doi_ra2":"JaLC"},[],[],True,True),
+ ({"cnri":"","doi": "","doi_ra":"","doi2": None,"doi_ra2":None},{"cnri":"","doi": "","doi_ra":"","doi2": None,"doi_ra2":None},[],['Please specify DOI prefix/suffix.'],True,True),
+ ({"cnri":"test_cnri","doi": "xyz.jalc/abc","doi_ra":"JaLC","doi2": None,"doi_ra2":None},{"cnri":"test_cnri","doi": "xyz.jalc/abc","doi_ra":"JaLC","doi2": "xyz.jalc/abc","doi_ra2":"JaLC"},[],[],True,True),
+ ({"cnri":"test_cnri","doi": "","doi_ra":"","doi2": None,"doi_ra2":None},{"cnri":"test_cnri","doi": "","doi_ra":"","doi2": None,"doi_ra2":None},[],[],True,True),
+ ])
+def test_handle_fill_system_item3_id_none(app,doi_records,before_doi,after_doi,warnings,errors,is_change_identifier,is_register_cnri):
+ item_id = None
+ app.config.update(
+ WEKO_HANDLE_ALLOW_REGISTER_CRNI=is_register_cnri
+ )
+ before = {
+ "metadata": {
+ "path": ["1667004052852"],
+ "pubdate": "2022-10-29",
+ "item_1617186331708": [
+ {"subitem_1551255647225": "title", "subitem_1551255648112": "en"}
+ ],
+ "item_1617258105262": {
+ "resourcetype": "conference paper",
+ "resourceuri": "http://purl.org/coar/resource_type/c_5794",
+ },
+ "item_1617605131499": [
+ {
+ "accessrole": "open_access",
+ "date": [{"dateType": "Available", "dateValue": "2022-10-29"}],
+ "filename": "a.zip",
+ "filesize": [{"value": "82 KB"}],
+ "format": "application/zip",
+ }
+ ],
+ },
+ "pos_index": ["IndexA"],
+ "publish_status": "public",
+ "edit_mode": "Keep",
+ "file_path": [""],
+ "item_type_name": "デフォルトアイテムタイプ(フル)",
+ "item_type_id": 1,
+ "$schema": "https://localhost:8443/items/jsonschema/1",
+ }
+
+ if before_doi["doi_ra2"] is not None:
+ before["metadata"]["item_1617186819068"]=before["metadata"].get("item_1617186819068",{})
+ before["metadata"]["item_1617186819068"]["subitem_identifier_reg_type"]= "{}".format(before_doi['doi_ra2'])
+
+ if before_doi["doi2"] is not None:
+ before["metadata"]["item_1617186819068"]=before["metadata"].get("item_1617186819068",{})
+ before["metadata"]["item_1617186819068"]["subitem_identifier_reg_text"]= "{}".format(before_doi['doi2'])
+
+ if before_doi['doi_ra'] is not None:
+ before["doi_ra"]="{}".format(before_doi['doi_ra'])
+
+ if before_doi['doi'] is not None:
+ before["doi"]="{}".format(before_doi['doi'])
+
+ if "cnri" in before_doi and before_doi["cnri"] is not None:
+ before["cnri"] = "{}".format(before_doi["cnri"])
+
+ before_list = [before]
+ after = {
+ "metadata": {
+ "path": ["1667004052852"],
+ "pubdate": "2022-10-29",
+ "item_1617186331708": [
+ {"subitem_1551255647225": "title", "subitem_1551255648112": "en"}
+ ],
+ "item_1617258105262": {
+ "resourcetype": "conference paper",
+ "resourceuri": "http://purl.org/coar/resource_type/c_5794",
+ },
+ "item_1617605131499": [
+ {
+ "accessrole": "open_access",
+ "date": [{"dateType": "Available", "dateValue": "2022-10-29"}],
+ "filename": "a.zip",
+ "filesize": [{"value": "82 KB"}],
+ "format": "application/zip",
+ }
+ ],
+ },
+ "pos_index": ["IndexA"],
+ "publish_status": "public",
+ "edit_mode": "Keep",
+ "file_path": [""],
+ "item_type_name": "デフォルトアイテムタイプ(フル)",
+ "item_type_id": 1,
+ "$schema": "https://localhost:8443/items/jsonschema/1",
+ "identifier_key": "item_1617186819068",
+ "errors": errors,
+ "warnings": warnings,
+ }
+
+ if after_doi["doi_ra"] is not None:
+ after["doi_ra"]="{}".format(after_doi['doi_ra'])
+
+ if after_doi["doi"] is not None:
+ after["doi"]="{}".format(after_doi["doi"])
+
+ if after_doi["doi_ra2"] is not None:
+ after["metadata"]["item_1617186819068"]=after["metadata"].get("item_1617186819068",{})
+ after["metadata"]["item_1617186819068"]["subitem_identifier_reg_type"]= "{}".format(after_doi['doi_ra2'])
+
+ if after_doi["doi2"] is not None:
+ after["metadata"]["item_1617186819068"]= after["metadata"].get("item_1617186819068",{})
+ after["metadata"]["item_1617186819068"]["subitem_identifier_reg_text"]= "{}".format(after_doi['doi2'])
+
+ if "cnri" in after_doi and after_doi["cnri"] is not None:
+ after["cnri"] = after_doi["cnri"]
+
+ after_list = [after]
+
+ if is_change_identifier:
+ before_list[0]['is_change_identifier']=True
+ after_list[0]['is_change_identifier']=True
+
+ with app.test_request_context():
+ assert before_list != after_list
+ handle_fill_system_item(before_list)
+ assert after_list == before_list
+
+
+# def get_thumbnail_key(item_type_id=0):
+def test_get_thumbnail_key(i18n_app, db_itemtype, db_workflow):
+ assert get_thumbnail_key(item_type_id=1)
+
+
+# def handle_check_thumbnail_file_type(thumbnail_paths):
+def test_handle_check_thumbnail_file_type(i18n_app):
+ assert handle_check_thumbnail_file_type(["/"])
+
+
+# def handle_check_metadata_not_existed(str_keys, item_type_id=0): *** not yet done
+def test_handle_check_metadata_not_existed(i18n_app, db_itemtype):
+ # Test 1
+ assert not handle_check_metadata_not_existed(
+ ".metadata", db_itemtype["item_type"].id
+ )
+
+
+# def handle_get_all_sub_id_and_name(items, root_id=None, root_name=None, form=[]):
+@pytest.mark.parametrize(
+ "items,root_id,root_name,form,ids,names",
+ [
+ pytest.param(
+ {"interim": {"type": "string"}},
+ ".metadata.item_1657196790737[0]",
+ "text[0]",
+ [{"key": "item_1657196790737[].interim", "type": "text", "notitle": True}],
+ [".metadata.item_1657196790737[0].interim"],
+ ["text[0].None"],
+ ),
+ pytest.param(
+ {
+ "interim": {
+ "enum": [None, "op1", "op2", "op3", "op4"],
+ "type": ["null", "string"],
+ "title": "list",
+ "title_i18n": {"en": "", "ja": ""},
+ }
+ },
+ ".metadata.item_1657204077414[0]",
+ "list[0]",
+ [
+ {
+ "key": "item_1657204077414[].interim",
+ "type": "select",
+ "title": "list",
+ "notitle": True,
+ "titleMap": [
+ {"name": "op1", "value": "op1"},
+ {"name": "op2", "value": "op2"},
+ {"name": "op3", "value": "op3"},
+ {"name": "op4", "value": "op4"},
+ ],
+ "title_i18n": {"en": "", "ja": ""},
+ }
+ ],
+ [".metadata.item_1657204026946.interim[0]"],
+ ["check.check[0]"],
+ ),
+ pytest.param(
+ {
+ "interim": {
+ "enum": [None, "op1", "op2", "op3", "op4"],
+ "type": ["null", "string"],
+ "title": "list",
+ "format": "select",
+ }
+ },
+ ".metadata.item_1657204070640",
+ "list",
+ [
+ {
+ "key": "item_1657204070640.interim",
+ "type": "select",
+ "title": "list",
+ "titleMap": [
+ {"name": "op1", "value": "op1"},
+ {"name": "op2", "value": "op2"},
+ {"name": "op3", "value": "op3"},
+ {"name": "op4", "value": "op4"},
+ ],
+ "title_i18n": {"en": "", "ja": ""},
+ }
+ ],
+ [".metadata.item_1657204036771[0].interim[0]"],
+ ["checjk[0].checjk[0]"],
+ ),
+ pytest.param(
+ {
+ "interim": {
+ "type": "array",
+ "items": {"enum": ["op1", "op2", "op3", "op4"], "type": "string"},
+ "title": "check",
+ "format": "checkboxes",
+ "title_i18n": {"en": "", "ja": ""},
+ }
+ },
+ ".metadata.item_1657204026946",
+ "check",
+ [
+ {
+ "key": "item_1657204026946.interim",
+ "type": "template",
+ "title": "check",
+ "titleMap": [
+ {"name": "op1", "value": "op1"},
+ {"name": "op2", "value": "op2"},
+ {"name": "op3", "value": "op3"},
+ {"name": "op4", "value": "op4"},
],
"title_i18n": {"en": "", "ja": ""},
"templateUrl": "/static/templates/weko_deposit/checkboxes.html",
@@ -2100,7 +2726,7 @@ def get_record_by_uuid(uuid):
assert msg.decode() == "Export failed. Please check item id range."
# raise Exception
- with patch("weko_search_ui.utils.os.makedirs", side_effect=Exception("test_error")):
+ with patch("weko_search_ui.utils.os.makedirs", side_effect=[None, Exception("test_error")]):
export_all(root_url, user_id, data, start_time_str)
msg = datastore.get(msg_key)
assert msg.decode() == "Export failed."
@@ -2139,7 +2765,7 @@ def test_write_files(db_activity, i18n_app, users, redis_connect, mocker, item_t
mocker.patch("weko_search_ui.utils.os.makedirs")
mocker.patch('builtins.open', side_effect=unittest.mock.mock_open())
assert write_files(item_datas, "tests/data/write_files", current_user.get_id(), 0)
-
+
# result is False
with patch("weko_items_ui.utils.make_stats_file_with_permission", side_effect=SQLAlchemyError("test_error")):
assert not write_files(item_datas, "tests/data/write_files", current_user.get_id(), 0)
@@ -2187,7 +2813,7 @@ def test_cancel_export_all(i18n_app, users, redis_connect, mocker):
assert json.loads(ds_file_json) == file_result_json
mock_revoke.assert_called_with("test_task_key",terminate=True)
mock_delete_id.assert_called_with(args=("test_task_key","admin_cache_KEY_EXPORT_ALL_5"),countdown=60)
-
+
# export_status is False
with patch("weko_search_ui.utils.get_export_status", return_value=(False,None,None,None,None,None,None)):
datastore.put(file_cache_key, json.dumps(file_json).encode('utf-8'), ttl_secs=30)
@@ -2199,7 +2825,7 @@ def test_cancel_export_all(i18n_app, users, redis_connect, mocker):
assert json.loads(ds_file_json) == file_json
mock_revoke.assert_not_called()
mock_delete_id.assert_not_called()
-
+
# raise Exception
with patch("weko_search_ui.utils.get_export_status",side_effect=Exception("test_error")):
result = cancel_export_all()
@@ -2219,7 +2845,7 @@ def successful(self):
return self.state == "SUCCESS"
def failed(self):
return self.state == "FAILED"
-
+
start_time_str = '2024/05/21 14:23:46'
def create_file_json(status):
return {
@@ -2249,7 +2875,7 @@ def create_file_json(status):
name='RUN_MSG_EXPORT_ALL_FILE_CREATE', user_id=current_user.get_id()
)
datastore = redis_connect
-
+
datastore.put(cache_uri, "test_uri".encode("utf-8"), ttl_secs=30)
datastore.put(cache_msg, "test_msg".encode("utf-8"), ttl_secs=30)
datastore.put(run_msg, "test_run_msg".encode("utf-8"), ttl_secs=30)
@@ -2293,7 +2919,7 @@ def create_file_json(status):
datastore.put(run_msg, "test_run_msg".encode("utf-8"), ttl_secs=30)
result=get_export_status()
assert result == (False, uri.decode(), "test_msg", "test_run_msg", "SUCCESS", start_time_str, "")
-
+
# raise Exception
with patch("weko_search_ui.utils.AsyncResult",side_effect=Exception("test_error")):
datastore.delete(cache_uri)
@@ -2304,7 +2930,7 @@ def create_file_json(status):
datastore.put(run_msg, "test_run_msg".encode("utf-8"), ttl_secs=30)
result=get_export_status()
assert result == (False, "test_uri", "test_msg", "test_run_msg", "", "", "")
-
+
# write_file_status is canceled
datastore.delete(file_msg)
datastore.put(file_msg, json.dumps(create_file_json('canceled')).encode('utf-8'), ttl_secs=30)
@@ -2437,11 +3063,17 @@ def test_get_data_by_property(i18n_app):
assert get_data_by_property(item_metadata, item_map, mapping_key)
assert get_data_by_property(item_metadata, {}, mapping_key)
+ item_metadata = {"test": "test"}
with patch(
- "weko_workflow.utils.get_sub_item_value", return_value=[True, ["value"]]
+ "weko_search_ui.utils.get_sub_item_value", return_value=[True, ["value"]]
):
assert get_data_by_property(item_metadata, item_map, mapping_key)
+ with patch(
+ "weko_search_ui.utils.get_sub_item_value", return_value=None
+ ):
+
+ assert get_data_by_property(item_metadata, item_map, mapping_key)
# def get_filenames_from_metadata(metadata):
def test_get_filenames_from_metadata(i18n_app, record_with_metadata):
@@ -2466,8 +3098,8 @@ def test_get_billinginfo_from_metadata(i18n_app, record_with_metadata,record_wit
metadata = {
"item_1712310680597": [{
- "accessrole": "open_login",
- "billing": ["billing_file"],
+ "accessrole": "open_login",
+ "billing": ["billing_file"],
"displaytype": "detail",
"priceinfo": [{"billingrole": "10005", "price": "100", "tax": ["include_tax"]}]
}]
@@ -2500,6 +3132,7 @@ def test_handle_check_filename_consistence(i18n_app):
assert handle_check_filename_consistence(file_paths, meta_filenames)
+# .tox/c1/bin/pytest --cov=weko_search_ui tests/test_utils.py::test_function_issue34520 -v -vv -s --cov-branch --cov-report=term --basetemp=/code/modules/weko-search-ui/.tox/c1/tmp
@pytest.mark.parametrize(
"item_id, before_doi,after_doi,warnings,errors,is_change_identifier",
[
@@ -2543,7 +3176,7 @@ def test_function_issue34520(app, doi_records, item_id, before_doi, after_doi, w
"item_type_id": 1,
"$schema": "https://localhost/items/jsonschema/1",
}
-
+
if item_id:
before["id"] = "{}".format(item_id)
before["uri"] = "https://localhost/records/{}".format(item_id)
@@ -2552,17 +3185,17 @@ def test_function_issue34520(app, doi_records, item_id, before_doi, after_doi, w
if before_doi["doi_ra2"] is not None:
before["metadata"]["item_1617186819068"]=before["metadata"].get("item_1617186819068",{})
before["metadata"]["item_1617186819068"]["subitem_identifier_reg_type"]= "{}".format(before_doi['doi_ra2'])
-
+
if before_doi["doi2"] is not None:
before["metadata"]["item_1617186819068"]=before["metadata"].get("item_1617186819068",{})
before["metadata"]["item_1617186819068"]["subitem_identifier_reg_text"]= "{}".format(before_doi['doi2'])
if before_doi['doi_ra'] is not None:
before["doi_ra"]="{}".format(before_doi['doi_ra'])
-
+
if before_doi['doi'] is not None:
- before["doi"]="{}".format(before_doi['doi'])
-
+ before["doi"]="{}".format(before_doi['doi'])
+
before_list = [before]
after = {
"metadata": {
@@ -2601,23 +3234,23 @@ def test_function_issue34520(app, doi_records, item_id, before_doi, after_doi, w
after["id"] = "{}".format(item_id)
after["uri"] = "https://localhost/records/{}".format(item_id)
after["metadata"]["item_1617605131499"][0]["url"] = {"url": "https://weko3.example.org/record/{}/files/a.zip".format(item_id)}
-
+
if after_doi["doi_ra"] is not None:
after["doi_ra"]="{}".format(after_doi['doi_ra'])
-
+
if after_doi["doi"] is not None:
- after["doi"]="{}".format(after_doi["doi"])
-
+ after["doi"]="{}".format(after_doi["doi"])
+
if after_doi["doi_ra2"] is not None:
after["metadata"]["item_1617186819068"]=after["metadata"].get("item_1617186819068",{})
after["metadata"]["item_1617186819068"]["subitem_identifier_reg_type"]= "{}".format(after_doi['doi_ra2'])
-
+
if after_doi["doi2"] is not None:
after["metadata"]["item_1617186819068"]= after["metadata"].get("item_1617186819068",{})
after["metadata"]["item_1617186819068"]["subitem_identifier_reg_text"]= "{}".format(after_doi['doi2'])
after_list = [after]
-
+
if is_change_identifier:
before_list[0]['is_change_identifier']=True
after_list[0]['is_change_identifier']=True
@@ -2626,7 +3259,7 @@ def test_function_issue34520(app, doi_records, item_id, before_doi, after_doi, w
assert before_list != after_list
handle_fill_system_item(before_list)
assert after_list == before_list
-
+
# .tox/c1/bin/pytest --cov=weko_search_ui tests/test_utils.py::test_function_issue34535 -vv -s --cov-branch --cov-report=term --basetemp=/code/modules/weko-search_ui/.tox/c1/tmp
def test_function_issue34535(db,db_index,db_itemtype,location,db_oaischema,mocker):
mocker.patch("weko_search_ui.utils.find_and_update_location_size")
@@ -2661,7 +3294,7 @@ def test_function_issue34535(db,db_index,db_itemtype,location,db_oaischema,mocke
# new item
root_path = os.path.dirname(os.path.abspath(__file__))
new_item = {'$schema': 'https://192.168.56.103/items/jsonschema/1', 'edit_mode': 'Keep', 'errors': None, 'file_path': [''], 'filenames': [{'filename': '', 'id': '.metadata.item_1617605131499[0].filename'}], 'id': '4', 'identifier_key': 'item_1617186819068', 'is_change_identifier': False, 'item_title': 'test item in br', 'item_type_id': 1, 'item_type_name': 'デフォルトアイテムタイプ(フル)', 'metadata': {'item_1617186331708': [{'subitem_1551255647225': 'test item in br', 'subitem_1551255648112': 'ja'}], 'item_1617186626617': [{'subitem_description': 'this is line1. this is line2.', 'subitem_description_language': 'en', 'subitem_description_type': 'Abstract'}], 'item_1617258105262': {'resourcetype': 'conference paper', 'resourceuri': 'http://purl.org/coar/resource_type/c_5794'}, 'path': [1], 'pubdate': '2022-11-21'}, 'pos_index': ['Faculty of Humanities and Social Sciences'], 'publish_status': 'public', 'status': 'keep', 'uri': 'https://192.168.56.103/records/4', 'warnings': [], 'root_path': root_path}
-
+
register_item_metadata(new_item,root_path,True)
record = WekoDeposit.get_record(recid.object_uuid)
assert record == {'_oai': {'id': 'oai:weko3.example.org:00000004', 'sets': ['1']}, 'path': ['1'], 'owner': '1', 'recid': '4', 'title': ['test item in br'], 'pubdate': {'attribute_name': 'PubDate', 'attribute_value': '2022-11-21'}, '_buckets': {'deposit': '0796e490-6dcf-4e7d-b241-d7201c3de83a'}, '_deposit': {'id': '4', 'pid': {'type': 'depid', 'value': '4', 'revision_id': 0}, 'owner': '1', 'owners': [1], 'status': 'draft', 'created_by': 1}, 'item_title': 'test item in br', 'author_link': [], 'item_type_id': '1', 'publish_date': '2022-11-21', 'publish_status': '0', 'weko_shared_id': -1, 'item_1617186331708': {'attribute_name': 'Title', 'attribute_value_mlt': [{'subitem_1551255647225': 'test item in br', 'subitem_1551255648112': 'ja'}]}, 'item_1617186626617': {'attribute_name': 'Description', 'attribute_value_mlt': [{'subitem_description': 'this is line1.\nthis is line2.', 'subitem_description_language': 'en', 'subitem_description_type': 'Abstract'}]}, 'item_1617258105262': {'attribute_name': 'Resource Type', 'attribute_value_mlt': [{'resourcetype': 'conference paper', 'resourceuri': 'http://purl.org/coar/resource_type/c_5794'}]}, 'relation_version_is_last': True, 'control_number': '4'}
@@ -2682,14 +3315,14 @@ def test_function_issue34958(app, make_itemtype):
os.path.dirname(os.path.realpath(__file__)), "data/import_file/34958"
)
csv_path = "issue34958_import.csv"
-
-
+
+
test = [{"publish_status": "public", "pos_index": ["Index A"], "metadata": {"pubdate": "2022-11-11", "item_1671508244520": {"subitem_1551255647225": "Extra items test", "subitem_1551255648112": "en"}, "item_1671508260839": {"resourcetype": "conference paper", "resourceuri": "http://purl.org/coar/resource_type/c_5794"}, "item_1671508308460": [{"interim": "test_text_value0"}, {"interim": "test_text_value1"}], "item_1671606815997": "test_text", "item_1617186626617": {"subitem_description": "test_description"}}, "edit_mode": "keep", "item_type_name": "test_import", "item_type_id": 34958, "$schema": "http://TEST_SERVER/items/jsonschema/34958", "warnings": ["The following items are not registered because they do not exist in the specified item type. item_1617186626617.subitem_description"], "is_change_identifier": False, "errors": None}]
result = unpackage_import_file(data_path,csv_path,"csv",False,False)
-
+
assert result == test
-# .tox/c1/bin/pytest --cov=weko_search_ui tests/test_utils.py::test_function_issue34520 -v -vv -s --cov-branch --cov-report=term --basetemp=/code/modules/weko-search-ui/.tox/c1/tmp
+# .tox/c1/bin/pytest --cov=weko_search_ui tests/test_utils.py::test_handle_fill_system_item_issue34520 -v -vv -s --cov-branch --cov-report=term --basetemp=/code/modules/weko-search-ui/.tox/c1/tmp
@pytest.mark.parametrize(
"item_id, before_doi,after_doi,warnings,errors,is_change_identifier",
[
@@ -2742,7 +3375,7 @@ def test_handle_fill_system_item_issue34520(app, doi_records, item_id, before_do
"item_type_id": 1,
"$schema": "https://localhost/items/jsonschema/1",
}
-
+
if item_id:
before["id"] = "{}".format(item_id)
before["uri"] = "https://localhost/records/{}".format(item_id)
@@ -2751,17 +3384,17 @@ def test_handle_fill_system_item_issue34520(app, doi_records, item_id, before_do
if before_doi.get("doi_ra2") is not None:
before["metadata"]["item_1617186819068"]=before["metadata"].get("item_1617186819068",{})
before["metadata"]["item_1617186819068"]["subitem_identifier_reg_type"]= "{}".format(before_doi['doi_ra2'])
-
+
if before_doi.get("doi2") is not None:
before["metadata"]["item_1617186819068"]=before["metadata"].get("item_1617186819068",{})
before["metadata"]["item_1617186819068"]["subitem_identifier_reg_text"]= "{}".format(before_doi['doi2'])
if before_doi.get('doi_ra') is not None:
before["doi_ra"]="{}".format(before_doi['doi_ra'])
-
+
if before_doi.get('doi') is not None:
- before["doi"]="{}".format(before_doi['doi'])
-
+ before["doi"]="{}".format(before_doi['doi'])
+
before_list = [before]
after = {
"metadata": {
@@ -2800,17 +3433,17 @@ def test_handle_fill_system_item_issue34520(app, doi_records, item_id, before_do
after["id"] = "{}".format(item_id)
after["uri"] = "https://localhost/records/{}".format(item_id)
after["metadata"]["item_1617605131499"][0]["url"] = {"url": "https://weko3.example.org/record/{}/files/a.zip".format(item_id)}
-
+
if after_doi.get("doi_ra") is not None:
after["doi_ra"]="{}".format(after_doi['doi_ra'])
-
+
if after_doi.get("doi") is not None:
- after["doi"]="{}".format(after_doi["doi"])
-
+ after["doi"]="{}".format(after_doi["doi"])
+
if after_doi.get("doi_ra2") is not None:
after["metadata"]["item_1617186819068"]=after["metadata"].get("item_1617186819068",{})
after["metadata"]["item_1617186819068"]["subitem_identifier_reg_type"]= "{}".format(after_doi['doi_ra2'])
-
+
if after_doi.get("doi2") is not None:
after["metadata"]["item_1617186819068"]= after["metadata"].get("item_1617186819068",{})
after["metadata"]["item_1617186819068"]["subitem_identifier_reg_text"]= "{}".format(after_doi['doi2'])
@@ -2863,7 +3496,7 @@ def test_handle_check_exist_record_issue35315(app, doi_records, id, uri, warning
if uri is not None:
before["uri"] = uri
before_list = [before]
-
+
after = {
"metadata": {
"path": ["1667004052852"],
@@ -2890,9 +3523,9 @@ def test_handle_check_exist_record_issue35315(app, doi_records, id, uri, warning
if uri is not None:
after["uri"] = uri
after["status"] = status
-
+
after_list = [after]
-
+
with app.test_request_context():
assert before_list != after_list
result = handle_check_exist_record(before_list)
diff --git a/modules/weko-search-ui/weko_search_ui/utils.py b/modules/weko-search-ui/weko_search_ui/utils.py
index 5b57fb4c37..c01c62b783 100644
--- a/modules/weko-search-ui/weko_search_ui/utils.py
+++ b/modules/weko-search-ui/weko_search_ui/utils.py
@@ -33,6 +33,7 @@
import traceback
import uuid
import zipfile
+import chardet
import gc
from collections import Callable, OrderedDict
from datetime import datetime
@@ -249,7 +250,7 @@ def delete_records(index_tree_id, ignore_items):
paths.remove(index_id)
break
-
+
indexer = WekoIndexer()
if not del_flag:
@@ -547,13 +548,15 @@ def check_import_items(file, is_change_identifier: bool, is_gakuninrdm=False,
try:
# Create temp dir for import data
os.mkdir(data_path)
-
with zipfile.ZipFile(file) as z:
for info in z.infolist():
try:
- info.filename = info.orig_filename.encode("cp437").decode("cp932")
- if os.sep != "/" and os.sep in info.filename:
- info.filename = info.filename.replace(os.sep, "/")
+ info.filename = info.orig_filename
+ inf = chardet.detect(info.orig_filename)
+ if inf['encoding'] is not None and inf['encoding'] == 'cp437':
+ info.filename = info.orig_filename.encode("cp437").decode("cp932")
+ if os.sep != "/" and os.sep in info.filename:
+ info.filename = info.filename.replace(os.sep, "/")
except Exception:
current_app.logger.warning("-" * 60)
traceback.print_exc(file=sys.stdout)
@@ -666,7 +669,7 @@ def unpackage_import_file(data_path: str, file_name: str, file_format: str, forc
for record in list_record:
record["id"] = None
record["uri"] = None
-
+
current_app.logger.debug('list_record2: {}'.format(list_record))
# [{'pos_index': ['Index A'], 'publish_status': 'public', 'feedback_mail': ['wekosoftware@nii.ac.jp'], 'edit_mode': 'Keep', 'metadata': {'pubdate': '2021-03-19', 'item_1617186331708': [{'subitem_1551255647225': 'ja_conference paperITEM00000001(public_open_access_open_access_simple)', 'subitem_1551255648112': 'ja'}, {'subitem_1551255647225': 'en_conference paperITEM00000001(public_open_access_simple)', 'subitem_1551255648112': 'en'}], 'item_1617186385884': [{'subitem_1551255720400': 'Alternative Title', 'subitem_1551255721061': 'en'}, {'subitem_1551255720400': 'Alternative Title', 'subitem_1551255721061': 'ja'}], 'item_1617186419668': [{'creatorAffiliations': [{'affiliationNameIdentifiers': [{'affiliationNameIdentifier': '0000000121691048', 'affiliationNameIdentifierScheme': 'ISNI', 'affiliationNameIdentifierURI': 'http://isni.org/isni/0000000121691048'}], 'affiliationNames': [{'affiliationName': 'University', 'affiliationNameLang': 'en'}]}], 'creatorMails': [{'creatorMail': 'wekosoftware@nii.ac.jp'}], 'creatorNames': [{'creatorName': '情報, 太郎', 'creatorNameLang': 'ja'}, {'creatorName': 'ジョウホウ, タロウ', 'creatorNameLang': 'ja-Kana'}, {'creatorName': 'Joho, Taro', 'creatorNameLang': 'en'}], 'familyNames': [{'familyName': '情報', 'familyNameLang': 'ja'}, {'familyName': 'ジョウホウ', 'familyNameLang': 'ja-Kana'}, {'familyName': 'Joho', 'familyNameLang': 'en'}], 'givenNames': [{'givenName': '太郎', 'givenNameLang': 'ja'}, {'givenName': 'タロウ', 'givenNameLang': 'ja-Kana'}, {'givenName': 'Taro', 'givenNameLang': 'en'}], 'nameIdentifiers': [{'nameIdentifier': '4', 'nameIdentifierScheme': 'WEKO'}, {'nameIdentifier': 'xxxxxxx', 'nameIdentifierScheme': 'ORCID', 'nameIdentifierURI': 'https://orcid.org/'}, {'nameIdentifier': 'xxxxxxx', 'nameIdentifierScheme': 'CiNii', 'nameIdentifierURI': 'https://ci.nii.ac.jp/'}, {'nameIdentifier': 'zzzzzzz', 'nameIdentifierScheme': 'KAKEN2', 'nameIdentifierURI': 'https://kaken.nii.ac.jp/'}]}, {'creatorMails': [{'creatorMail': 'wekosoftware@nii.ac.jp'}], 'creatorNames': [{'creatorName': '情報, 太郎', 'creatorNameLang': 'ja'}, {'creatorName': 'ジョウホウ, タロウ', 'creatorNameLang': 'ja-Kana'}, {'creatorName': 'Joho, Taro', 'creatorNameLang': 'en'}], 'familyNames': [{'familyName': '情報', 'familyNameLang': 'ja'}, {'familyName': 'ジョウホウ', 'familyNameLang': 'ja-Kana'}, {'familyName': 'Joho', 'familyNameLang': 'en'}], 'givenNames': [{'givenName': '太郎', 'givenNameLang': 'ja'}, {'givenName': 'タロウ', 'givenNameLang': 'ja-Kana'}, {'givenName': 'Taro', 'givenNameLang': 'en'}], 'nameIdentifiers': [{'nameIdentifier': 'xxxxxxx', 'nameIdentifierScheme': 'ORCID', 'nameIdentifierURI': 'https://orcid.org/'}, {'nameIdentifier': 'xxxxxxx', 'nameIdentifierScheme': 'CiNii', 'nameIdentifierURI': 'https://ci.nii.ac.jp/'}, {'nameIdentifier': 'zzzzzzz', 'nameIdentifierScheme': 'KAKEN2', 'nameIdentifierURI': 'https://kaken.nii.ac.jp/'}]}, {'creatorMails': [{'creatorMail': 'wekosoftware@nii.ac.jp'}], 'creatorNames': [{'creatorName': '情報, 太郎', 'creatorNameLang': 'ja'}, {'creatorName': 'ジョウホウ, タロウ', 'creatorNameLang': 'ja-Kana'}, {'creatorName': 'Joho, Taro', 'creatorNameLang': 'en'}], 'familyNames': [{'familyName': '情報', 'familyNameLang': 'ja'}, {'familyName': 'ジョウホウ', 'familyNameLang': 'ja-Kana'}, {'familyName': 'Joho', 'familyNameLang': 'en'}], 'givenNames': [{'givenName': '太郎', 'givenNameLang': 'ja'}, {'givenName': 'タロウ', 'givenNameLang': 'ja-Kana'}, {'givenName': 'Taro', 'givenNameLang': 'en'}], 'nameIdentifiers': [{'nameIdentifier': 'xxxxxxx', 'nameIdentifierScheme': 'ORCID', 'nameIdentifierURI': 'https://orcid.org/'}, {'nameIdentifier': 'xxxxxxx', 'nameIdentifierScheme': 'CiNii', 'nameIdentifierURI': 'https://ci.nii.ac.jp/'}, {'nameIdentifier': 'zzzzzzz', 'nameIdentifierScheme': 'KAKEN2', 'nameIdentifierURI': 'https://kaken.nii.ac.jp/'}]}], 'item_1617349709064': [{'contributorMails': [{'contributorMail': 'wekosoftware@nii.ac.jp'}], 'contributorNames': [{'contributorName': '情報, 太郎', 'lang': 'ja'}, {'contributorName': 'ジョウホウ, タロウ', 'lang': 'ja-Kana'}, {'contributorName': 'Joho, Taro', 'lang': 'en'}], 'contributorType': 'ContactPerson', 'familyNames': [{'familyName': '情報', 'familyNameLang': 'ja'}, {'familyName': 'ジョウホウ', 'familyNameLang': 'ja-Kana'}, {'familyName': 'Joho', 'familyNameLang': 'en'}], 'givenNames': [{'givenName': '太郎', 'givenNameLang': 'ja'}, {'givenName': 'タロウ', 'givenNameLang': 'ja-Kana'}, {'givenName': 'Taro', 'givenNameLang': 'en'}], 'nameIdentifiers': [{'nameIdentifier': 'xxxxxxx', 'nameIdentifierScheme': 'ORCID', 'nameIdentifierURI': 'https://orcid.org/'}, {'nameIdentifier': 'xxxxxxx', 'nameIdentifierScheme': 'CiNii', 'nameIdentifierURI': 'https://ci.nii.ac.jp/'}, {'nameIdentifier': 'xxxxxxx', 'nameIdentifierScheme': 'KAKEN2', 'nameIdentifierURI': 'https://kaken.nii.ac.jp/'}]}], 'item_1617186476635': {'subitem_1522299639480': 'open access', 'subitem_1600958577026': 'http://purl.org/coar/access_right/c_abf2'}, 'item_1617351524846': {'subitem_1523260933860': 'Unknown'}, 'item_1617186499011': [{'subitem_1522650717957': 'ja', 'subitem_1522650727486': 'http://localhost', 'subitem_1522651041219': 'Rights Information'}], 'item_1617610673286': [{'nameIdentifiers': [{'nameIdentifier': 'xxxxxx', 'nameIdentifierScheme': 'ORCID', 'nameIdentifierURI': 'https://orcid.org/'}], 'rightHolderNames': [{'rightHolderLanguage': 'ja', 'rightHolderName': 'Right Holder Name'}]}], 'item_1617186609386': [{'subitem_1522299896455': 'ja', 'subitem_1522300014469': 'Other', 'subitem_1522300048512': 'http://localhost/', 'subitem_1523261968819': 'Sibject1'}], 'item_1617186626617': [{'subitem_description': 'Description\nDescription Description', 'subitem_description_language': 'en', 'subitem_description_type': 'Abstract'}, {'subitem_description': '概要\n概要\n概要\n概要', 'subitem_description_language': 'ja', 'subitem_description_type': 'Abstract'}], 'item_1617186643794': [{'subitem_1522300295150': 'en', 'subitem_1522300316516': 'Publisher'}], 'item_1617186660861': [{'subitem_1522300695726': 'Available', 'subitem_1522300722591': '2021-06-30'}], 'item_1617186702042': [{'subitem_1551255818386': 'jpn'}], 'item_1617258105262': {'resourcetype': 'conference paper', 'resourceuri': 'http://purl.org/coar/resource_type/c_5794'}, 'item_1617349808926': {'subitem_1523263171732': 'Version'}, 'item_1617265215918': {'subitem_1522305645492': 'AO', 'subitem_1600292170262': 'http://purl.org/coar/version/c_b1a7d7d4d402bcce'}, 'item_1617186783814': [{'subitem_identifier_type': 'URI', 'subitem_identifier_uri': 'http://localhost'}], 'item_1617353299429': [{'subitem_1522306207484': 'isVersionOf', 'subitem_1522306287251': {'subitem_1522306382014': 'arXiv', 'subitem_1522306436033': 'xxxxx'}, 'subitem_1523320863692': [{'subitem_1523320867455': 'en', 'subitem_1523320909613': 'Related Title'}]}], 'item_1617186859717': [{'subitem_1522658018441': 'en', 'subitem_1522658031721': 'Temporal'}], 'item_1617186882738': [{'subitem_geolocation_place': [{'subitem_geolocation_place_text': 'Japan'}]}], 'item_1617186901218': [{'subitem_1522399143519': {'subitem_1522399281603': 'ISNI', 'subitem_1522399333375': 'http://xxx'}, 'subitem_1522399412622': [{'subitem_1522399416691': 'en', 'subitem_1522737543681': 'Funder Name'}], 'subitem_1522399571623': {'subitem_1522399585738': 'Award URI', 'subitem_1522399628911': 'Award Number'}, 'subitem_1522399651758': [{'subitem_1522721910626': 'en', 'subitem_1522721929892': 'Award Title'}]}], 'item_1617186920753': [{'subitem_1522646500366': 'ISSN', 'subitem_1522646572813': 'xxxx-xxxx-xxxx'}], 'item_1617186941041': [{'subitem_1522650068558': 'en', 'subitem_1522650091861': 'Source Title'}], 'item_1617186959569': {'subitem_1551256328147': '1'}, 'item_1617186981471': {'subitem_1551256294723': '111'}, 'item_1617186994930': {'subitem_1551256248092': '12'}, 'item_1617187024783': {'subitem_1551256198917': '1'}, 'item_1617187045071': {'subitem_1551256185532': '3'}, 'item_1617187112279': [{'subitem_1551256126428': 'Degree Name', 'subitem_1551256129013': 'en'}], 'item_1617187136212': {'subitem_1551256096004': '2021-06-30'}, 'item_1617944105607': [{'subitem_1551256015892': [{'subitem_1551256027296': 'xxxxxx', 'subitem_1551256029891': 'kakenhi'}], 'subitem_1551256037922': [{'subitem_1551256042287': 'Degree Grantor Name', 'subitem_1551256047619': 'en'}]}], 'item_1617187187528': [{'subitem_1599711633003': [{'subitem_1599711636923': 'Conference Name', 'subitem_1599711645590': 'ja'}], 'subitem_1599711655652': '1', 'subitem_1599711660052': [{'subitem_1599711680082': 'Sponsor', 'subitem_1599711686511': 'ja'}], 'subitem_1599711699392': {'subitem_1599711704251': '2020/12/11', 'subitem_1599711712451': '1', 'subitem_1599711727603': '12', 'subitem_1599711731891': '2000', 'subitem_1599711735410': '1', 'subitem_1599711739022': '12', 'subitem_1599711743722': '2020', 'subitem_1599711745532': 'ja'}, 'subitem_1599711758470': [{'subitem_1599711769260': 'Conference Venue', 'subitem_1599711775943': 'ja'}], 'subitem_1599711788485': [{'subitem_1599711798761': 'Conference Place', 'subitem_1599711803382': 'ja'}], 'subitem_1599711813532': 'JPN'}], 'item_1617605131499': [{'accessrole': 'open_access', 'date': [{'dateType': 'Available', 'dateValue': '2021-07-12'}], 'displaytype': 'simple', 'filename': '1KB.pdf', 'filesize': [{'value': '1 KB'}], 'format': 'text/plain'}, {'filename': ''}], 'item_1617620223087': [{'subitem_1565671149650': 'ja', 'subitem_1565671169640': 'Banner Headline', 'subitem_1565671178623': 'Subheading'}, {'subitem_1565671149650': 'en', 'subitem_1565671169640': 'Banner Headline', 'subitem_1565671178623': 'Subheding'}]}, 'file_path': ['file00000001/1KB.pdf', ''], 'item_type_name': 'デフォルトアイテムタイプ(フル)', 'item_type_id': 15, '$schema': 'https://localhost:8443/items/jsonschema/15'}]
@@ -681,7 +684,7 @@ def unpackage_import_file(data_path: str, file_name: str, file_format: str, forc
# current_app.logger.debug('list_record4: {}'.format(list_record))
# [{'pos_index': ['Index A'], 'publish_status': 'public', 'feedback_mail': ['wekosoftware@nii.ac.jp'], 'edit_mode': 'Keep', 'metadata': {'pubdate': '2021-03-19', 'item_1617186331708': [{'subitem_1551255647225': 'ja_conference paperITEM00000001(public_open_access_open_access_simple)', 'subitem_1551255648112': 'ja'}, {'subitem_1551255647225': 'en_conference paperITEM00000001(public_open_access_simple)', 'subitem_1551255648112': 'en'}], 'item_1617186385884': [{'subitem_1551255720400': 'Alternative Title', 'subitem_1551255721061': 'en'}, {'subitem_1551255720400': 'Alternative Title', 'subitem_1551255721061': 'ja'}], 'item_1617186419668': [{'creatorAffiliations': [{'affiliationNameIdentifiers': [{'affiliationNameIdentifier': '0000000121691048', 'affiliationNameIdentifierScheme': 'ISNI', 'affiliationNameIdentifierURI': 'http://isni.org/isni/0000000121691048'}], 'affiliationNames': [{'affiliationName': 'University', 'affiliationNameLang': 'en'}]}], 'creatorMails': [{'creatorMail': 'wekosoftware@nii.ac.jp'}], 'creatorNames': [{'creatorName': '情報, 太郎', 'creatorNameLang': 'ja'}, {'creatorName': 'ジョウホウ, タロウ', 'creatorNameLang': 'ja-Kana'}, {'creatorName': 'Joho, Taro', 'creatorNameLang': 'en'}], 'familyNames': [{'familyName': '情報', 'familyNameLang': 'ja'}, {'familyName': 'ジョウホウ', 'familyNameLang': 'ja-Kana'}, {'familyName': 'Joho', 'familyNameLang': 'en'}], 'givenNames': [{'givenName': '太郎', 'givenNameLang': 'ja'}, {'givenName': 'タロウ', 'givenNameLang': 'ja-Kana'}, {'givenName': 'Taro', 'givenNameLang': 'en'}], 'nameIdentifiers': [{'nameIdentifier': '4', 'nameIdentifierScheme': 'WEKO'}, {'nameIdentifier': 'xxxxxxx', 'nameIdentifierScheme': 'ORCID', 'nameIdentifierURI': 'https://orcid.org/'}, {'nameIdentifier': 'xxxxxxx', 'nameIdentifierScheme': 'CiNii', 'nameIdentifierURI': 'https://ci.nii.ac.jp/'}, {'nameIdentifier': 'zzzzzzz', 'nameIdentifierScheme': 'KAKEN2', 'nameIdentifierURI': 'https://kaken.nii.ac.jp/'}]}, {'creatorMails': [{'creatorMail': 'wekosoftware@nii.ac.jp'}], 'creatorNames': [{'creatorName': '情報, 太郎', 'creatorNameLang': 'ja'}, {'creatorName': 'ジョウホウ, タロウ', 'creatorNameLang': 'ja-Kana'}, {'creatorName': 'Joho, Taro', 'creatorNameLang': 'en'}], 'familyNames': [{'familyName': '情報', 'familyNameLang': 'ja'}, {'familyName': 'ジョウホウ', 'familyNameLang': 'ja-Kana'}, {'familyName': 'Joho', 'familyNameLang': 'en'}], 'givenNames': [{'givenName': '太郎', 'givenNameLang': 'ja'}, {'givenName': 'タロウ', 'givenNameLang': 'ja-Kana'}, {'givenName': 'Taro', 'givenNameLang': 'en'}], 'nameIdentifiers': [{'nameIdentifier': 'xxxxxxx', 'nameIdentifierScheme': 'ORCID', 'nameIdentifierURI': 'https://orcid.org/'}, {'nameIdentifier': 'xxxxxxx', 'nameIdentifierScheme': 'CiNii', 'nameIdentifierURI': 'https://ci.nii.ac.jp/'}, {'nameIdentifier': 'zzzzzzz', 'nameIdentifierScheme': 'KAKEN2', 'nameIdentifierURI': 'https://kaken.nii.ac.jp/'}]}, {'creatorMails': [{'creatorMail': 'wekosoftware@nii.ac.jp'}], 'creatorNames': [{'creatorName': '情報, 太郎', 'creatorNameLang': 'ja'}, {'creatorName': 'ジョウホウ, タロウ', 'creatorNameLang': 'ja-Kana'}, {'creatorName': 'Joho, Taro', 'creatorNameLang': 'en'}], 'familyNames': [{'familyName': '情報', 'familyNameLang': 'ja'}, {'familyName': 'ジョウホウ', 'familyNameLang': 'ja-Kana'}, {'familyName': 'Joho', 'familyNameLang': 'en'}], 'givenNames': [{'givenName': '太郎', 'givenNameLang': 'ja'}, {'givenName': 'タロウ', 'givenNameLang': 'ja-Kana'}, {'givenName': 'Taro', 'givenNameLang': 'en'}], 'nameIdentifiers': [{'nameIdentifier': 'xxxxxxx', 'nameIdentifierScheme': 'ORCID', 'nameIdentifierURI': 'https://orcid.org/'}, {'nameIdentifier': 'xxxxxxx', 'nameIdentifierScheme': 'CiNii', 'nameIdentifierURI': 'https://ci.nii.ac.jp/'}, {'nameIdentifier': 'zzzzzzz', 'nameIdentifierScheme': 'KAKEN2', 'nameIdentifierURI': 'https://kaken.nii.ac.jp/'}]}], 'item_1617349709064': [{'contributorMails': [{'contributorMail': 'wekosoftware@nii.ac.jp'}], 'contributorNames': [{'contributorName': '情報, 太郎', 'lang': 'ja'}, {'contributorName': 'ジョウホウ, タロウ', 'lang': 'ja-Kana'}, {'contributorName': 'Joho, Taro', 'lang': 'en'}], 'contributorType': 'ContactPerson', 'familyNames': [{'familyName': '情報', 'familyNameLang': 'ja'}, {'familyName': 'ジョウホウ', 'familyNameLang': 'ja-Kana'}, {'familyName': 'Joho', 'familyNameLang': 'en'}], 'givenNames': [{'givenName': '太郎', 'givenNameLang': 'ja'}, {'givenName': 'タロウ', 'givenNameLang': 'ja-Kana'}, {'givenName': 'Taro', 'givenNameLang': 'en'}], 'nameIdentifiers': [{'nameIdentifier': 'xxxxxxx', 'nameIdentifierScheme': 'ORCID', 'nameIdentifierURI': 'https://orcid.org/'}, {'nameIdentifier': 'xxxxxxx', 'nameIdentifierScheme': 'CiNii', 'nameIdentifierURI': 'https://ci.nii.ac.jp/'}, {'nameIdentifier': 'xxxxxxx', 'nameIdentifierScheme': 'KAKEN2', 'nameIdentifierURI': 'https://kaken.nii.ac.jp/'}]}], 'item_1617186476635': {'subitem_1522299639480': 'open access', 'subitem_1600958577026': 'http://purl.org/coar/access_right/c_abf2'}, 'item_1617351524846': {'subitem_1523260933860': 'Unknown'}, 'item_1617186499011': [{'subitem_1522650717957': 'ja', 'subitem_1522650727486': 'http://localhost', 'subitem_1522651041219': 'Rights Information'}], 'item_1617610673286': [{'nameIdentifiers': [{'nameIdentifier': 'xxxxxx', 'nameIdentifierScheme': 'ORCID', 'nameIdentifierURI': 'https://orcid.org/'}], 'rightHolderNames': [{'rightHolderLanguage': 'ja', 'rightHolderName': 'Right Holder Name'}]}], 'item_1617186609386': [{'subitem_1522299896455': 'ja', 'subitem_1522300014469': 'Other', 'subitem_1522300048512': 'http://localhost/', 'subitem_1523261968819': 'Sibject1'}], 'item_1617186626617': [{'subitem_description': 'Description\nDescription Description', 'subitem_description_language': 'en', 'subitem_description_type': 'Abstract'}, {'subitem_description': '概要\n概要\n概要\n概要', 'subitem_description_language': 'ja', 'subitem_description_type': 'Abstract'}], 'item_1617186643794': [{'subitem_1522300295150': 'en', 'subitem_1522300316516': 'Publisher'}], 'item_1617186660861': [{'subitem_1522300695726': 'Available', 'subitem_1522300722591': '2021-06-30'}], 'item_1617186702042': [{'subitem_1551255818386': 'jpn'}], 'item_1617258105262': {'resourcetype': 'conference paper', 'resourceuri': 'http://purl.org/coar/resource_type/c_5794'}, 'item_1617349808926': {'subitem_1523263171732': 'Version'}, 'item_1617265215918': {'subitem_1522305645492': 'AO', 'subitem_1600292170262': 'http://purl.org/coar/version/c_b1a7d7d4d402bcce'}, 'item_1617186783814': [{'subitem_identifier_type': 'URI', 'subitem_identifier_uri': 'http://localhost'}], 'item_1617353299429': [{'subitem_1522306207484': 'isVersionOf', 'subitem_1522306287251': {'subitem_1522306382014': 'arXiv', 'subitem_1522306436033': 'xxxxx'}, 'subitem_1523320863692': [{'subitem_1523320867455': 'en', 'subitem_1523320909613': 'Related Title'}]}], 'item_1617186859717': [{'subitem_1522658018441': 'en', 'subitem_1522658031721': 'Temporal'}], 'item_1617186882738': [{'subitem_geolocation_place': [{'subitem_geolocation_place_text': 'Japan'}]}], 'item_1617186901218': [{'subitem_1522399143519': {'subitem_1522399281603': 'ISNI', 'subitem_1522399333375': 'http://xxx'}, 'subitem_1522399412622': [{'subitem_1522399416691': 'en', 'subitem_1522737543681': 'Funder Name'}], 'subitem_1522399571623': {'subitem_1522399585738': 'Award URI', 'subitem_1522399628911': 'Award Number'}, 'subitem_1522399651758': [{'subitem_1522721910626': 'en', 'subitem_1522721929892': 'Award Title'}]}], 'item_1617186920753': [{'subitem_1522646500366': 'ISSN', 'subitem_1522646572813': 'xxxx-xxxx-xxxx'}], 'item_1617186941041': [{'subitem_1522650068558': 'en', 'subitem_1522650091861': 'Source Title'}], 'item_1617186959569': {'subitem_1551256328147': '1'}, 'item_1617186981471': {'subitem_1551256294723': '111'}, 'item_1617186994930': {'subitem_1551256248092': '12'}, 'item_1617187024783': {'subitem_1551256198917': '1'}, 'item_1617187045071': {'subitem_1551256185532': '3'}, 'item_1617187112279': [{'subitem_1551256126428': 'Degree Name', 'subitem_1551256129013': 'en'}], 'item_1617187136212': {'subitem_1551256096004': '2021-06-30'}, 'item_1617944105607': [{'subitem_1551256015892': [{'subitem_1551256027296': 'xxxxxx', 'subitem_1551256029891': 'kakenhi'}], 'subitem_1551256037922': [{'subitem_1551256042287': 'Degree Grantor Name', 'subitem_1551256047619': 'en'}]}], 'item_1617187187528': [{'subitem_1599711633003': [{'subitem_1599711636923': 'Conference Name', 'subitem_1599711645590': 'ja'}], 'subitem_1599711655652': '1', 'subitem_1599711660052': [{'subitem_1599711680082': 'Sponsor', 'subitem_1599711686511': 'ja'}], 'subitem_1599711699392': {'subitem_1599711704251': '2020/12/11', 'subitem_1599711712451': '1', 'subitem_1599711727603': '12', 'subitem_1599711731891': '2000', 'subitem_1599711735410': '1', 'subitem_1599711739022': '12', 'subitem_1599711743722': '2020', 'subitem_1599711745532': 'ja'}, 'subitem_1599711758470': [{'subitem_1599711769260': 'Conference Venue', 'subitem_1599711775943': 'ja'}], 'subitem_1599711788485': [{'subitem_1599711798761': 'Conference Place', 'subitem_1599711803382': 'ja'}], 'subitem_1599711813532': 'JPN'}], 'item_1617605131499': [{'accessrole': 'open_access', 'date': [{'dateType': 'Available', 'dateValue': '2021-07-12'}], 'displaytype': 'simple', 'filename': '1KB.pdf', 'filesize': [{'value': '1 KB'}], 'format': 'text/plain'}, {'filename': ''}], 'item_1617620223087': [{'subitem_1565671149650': 'ja', 'subitem_1565671169640': 'Banner Headline', 'subitem_1565671178623': 'Subheading'}, {'subitem_1565671149650': 'en', 'subitem_1565671169640': 'Banner Headline', 'subitem_1565671178623': 'Subheding'}]}, 'file_path': ['file00000001/1KB.pdf', ''], 'item_type_name': 'デフォルトアイテムタイプ(フル)', 'item_type_id': 15, '$schema': 'https://localhost:8443/items/jsonschema/15', 'identifier_key': 'item_1617186819068', 'errors': None, 'status': 'new', 'id': None, 'item_title': 'ja_conference paperITEM00000001(public_open_access_open_access_simple)'}]
-
+
return list_record
@@ -1044,7 +1047,7 @@ def handle_check_exist_record(list_record) -> list:
exist_url = (
request.host_url + "records/" + str(item_exist.get("recid"))
)
-
+
if item.get("uri") == exist_url:
_edit_mode = item.get("edit_mode")
if not _edit_mode or _edit_mode.lower() not in [
@@ -1237,7 +1240,7 @@ def clean_file_metadata(item_type_id, data):
# clear metadata of file information
is_cleaned = True
file_key = None
- item_map = get_mapping(Mapping.get_record(item_type_id), "jpcoar_mapping")
+ item_map = get_mapping(item_type_id, "jpcoar_mapping")
key = item_map.get("file.URI.@value")
if key:
file_key = key.split(".")[0]
@@ -1279,11 +1282,11 @@ def autofill_thumbnail_metadata(item_type_id, data):
def escape_newline(data):
"""Replace in metadata with \n.
-
+
{"key1":["test test"]} -> {"key1":["test\ntest"]}
:argument
data -- {obj} escape target
- :return
+ :return
obj -- Obj after escaping
"""
if isinstance(data,list):
@@ -1733,21 +1736,53 @@ def handle_item_title(list_record):
:return
"""
+ from weko_items_ui.utils import get_options_and_order_list, get_hide_list_by_schema_form
+ from weko_records.utils import check_info_in_metadata
+
for item in list_record:
error = None
- item_type_mapping = Mapping.get_record(item["item_type_id"])
- item_map = get_mapping(item_type_mapping, "jpcoar_mapping")
+ meta_option, item_type_mapping = get_options_and_order_list(item["item_type_id"])
+ hide_list = get_hide_list_by_schema_form(item["item_type_id"])
+ item_map = get_mapping(item["item_type_id"], "jpcoar_mapping")
# current_app.logger.debug("item_type_mapping: {}".format(item_type_mapping))
# current_app.logger.debug("item_map: {}".format(item_map))
title_data, _title_key = get_data_by_property(
item["metadata"], item_map, "title.@value"
)
- if not title_data:
- error = _("Title is required item.")
- else:
- item["item_title"] = title_data[0]
+ title_lang_data, _title_lang_key = get_data_by_property(
+ item["metadata"], item_map, "title.@attributes.xml:lang"
+ )
+ title_val = None
+ lang_key_list = _title_lang_key.split(",")
+ val_key_list = _title_key.split(",")
+ for val_key in val_key_list:
+ val_parent_key = val_key.split(".")[0]
+ val_sub_key = val_key.split(".")[-1]
+ for lang_key in lang_key_list:
+ if val_parent_key == lang_key.split(".")[0]:
+ prop_hidden = meta_option.get(val_parent_key, {}).get('option', {}).get('hidden', False)
+ for h in hide_list:
+ if h.startswith(val_parent_key) and h.endswith(val_sub_key):
+ prop_hidden = True
+ if (
+ title_lang_data is not None
+ and title_data is not None
+ and title_lang_data is not None
+ and len(title_data) > 0
+ and len(title_lang_data) > 0
+ and not prop_hidden
+ ):
+ title_val = check_info_in_metadata(
+ lang_key, val_key, title_lang_data[0], item["metadata"]
+ )
+ item["item_title"] = title_val
+ if title_val:
+ break
+ if title_val:
+ break
- if error:
+ if not title_val:
+ error = _("Title is required item.")
item["errors"] = item["errors"] + [error] if item.get("errors") else [error]
@@ -1833,7 +1868,7 @@ def check(index_id, index_name_path):
info.name.replace(
'-/-', current_app.config['WEKO_ITEMS_UI_INDEX_PATH_SPLIT']):
index_info = info
-
+
if not index_info: # index does not exist by index path
if index_id:
errors.append(msg_not_exist.format("IndexID, POS_INDEX"))
@@ -2318,7 +2353,7 @@ def prepare_doi_link(item_id):
Returns:
_type_: _description_ {'identifier_grant_jalc_doi_link': 'https://doi.org/aaa.bbb/0000000006', 'identifier_grant_jalc_cr_doi_link': 'https://doi.org/ccc.ddd/0000000006', 'identifier_grant_jalc_dc_doi_link': 'https://doi.org/eee.fff/0000000006', 'identifier_grant_ndl_jalc_doi_link': 'https://doi.org/ggg.hhh/0000000006'}
- """
+ """
item_id = "%010d" % int(item_id)
identifier_setting = prepare_doi_setting()
suffix = identifier_setting.suffix or ""
@@ -2458,7 +2493,7 @@ def register_item_update_publish_status(item, status):
def register_item_custom_sort_order(item):
""" register item custom sort order
-
+
Args:
item (dict): item data
"""
@@ -2908,9 +2943,8 @@ def recursive_sub(keys, node, uri_key, current_type):
warnings = item.get('warnings') or []
if item_type_id != item["item_type_id"]:
item_type_id = item["item_type_id"]
- record = Mapping.get_record(item_type_id)
# current_app.logger.debug("record_hoge: {}".format(record))
- item_map = get_mapping(record, "jpcoar_mapping")
+ item_map = get_mapping(item_type_id, "jpcoar_mapping")
# Resource Type
resourcetype_key = item_map.get("type.@value")
@@ -2954,27 +2988,27 @@ def recursive_sub(keys, node, uri_key, current_type):
"identifierRegistration.@attributes.identifierType", ""
)
identifierRegistration_key = identifierRegistration_key.split(".")[0]
-
+
item_doi = item.get("doi","")
item_doi_prefix = ""
item_doi_suffix = ""
item_cnri = item.get("cnri", "")
-
+
if item_doi and "/" in item_doi:
item_doi_prefix, item_doi_suffix = item_doi.split("/")
else:
item_doi_prefix = item_doi
-
+
item_doi_ra = item.get("doi_ra","")
item_id = item.get('id',"")
checked_registerd_doi_ra = False
existed_doi = False
-
+
if identifierRegistration_key:
item["identifier_key"] = identifierRegistration_key
is_change_identifier = item.get("is_change_identifier", False)
doi_setting = prepare_doi_setting()
-
+
pid_doi = None
if item_id:
try:
@@ -2983,12 +3017,12 @@ def recursive_sub(keys, node, uri_key, current_type):
pid_doi = rec.pid_doi
except PIDDoesNotExistError:
pid_doi=None
-
+
registerd_doi = None
registerd_doi_prefix = None
registerd_doi_suffix = None
registerd_doi_ra = None
-
+
if pid_doi and doi_setting:
doi_value = pid_doi.pid_value
registerd_doi = doi_value.replace("https://doi.org/","")
@@ -3007,7 +3041,7 @@ def recursive_sub(keys, node, uri_key, current_type):
checked_registerd_doi_ra = False
else:
existed_doi = False
-
+
checked_item_doi_ra = False
if item_doi_prefix is not "" and doi_setting:
if doi_setting.jalc_doi == item_doi_prefix:
@@ -3023,7 +3057,7 @@ def recursive_sub(keys, node, uri_key, current_type):
fixed_doi = False
fixed_doi_ra = False
-
+
if is_change_identifier:
item["doi"] = item_doi
elif is_change_identifier == False:
@@ -3031,7 +3065,7 @@ def recursive_sub(keys, node, uri_key, current_type):
item["doi"] = registerd_doi
if registerd_doi != item_doi:
fixed_doi = True
-
+
if is_change_identifier == True:
item["doi_ra"] = item_doi_ra
elif is_change_identifier == False:
@@ -3039,9 +3073,9 @@ def recursive_sub(keys, node, uri_key, current_type):
item["doi_ra"] = registerd_doi_ra
if registerd_doi_ra != item_doi_ra:
fixed_doi_ra = True
-
+
if identifierRegistration_key in item["metadata"]:
- if existed_doi and checked_registerd_doi_ra and checked_item_doi_ra:
+ if existed_doi and checked_registerd_doi_ra and checked_item_doi_ra:
if 'subitem_identifier_reg_type' in item["metadata"][identifierRegistration_key]:
_doi_ra = item["metadata"][identifierRegistration_key]['subitem_identifier_reg_type']
if item.get("is_change_identifier", False) == True:
@@ -3062,7 +3096,7 @@ def recursive_sub(keys, node, uri_key, current_type):
if registerd_doi_ra != item_doi_ra:
fixed_doi_ra = True
- if 'subitem_identifier_reg_text' in item["metadata"][identifierRegistration_key]:
+ if 'subitem_identifier_reg_text' in item["metadata"][identifierRegistration_key]:
_doi = item["metadata"][identifierRegistration_key]['subitem_identifier_reg_text']
if item.get("is_change_identifier", False) == True:
item["metadata"][identifierRegistration_key]['subitem_identifier_reg_text'] = item_doi
@@ -3078,7 +3112,7 @@ def recursive_sub(keys, node, uri_key, current_type):
if item.get("is_change_identifier", False) == False:
item["metadata"][identifierRegistration_key]['subitem_identifier_reg_text'] = registerd_doi
if registerd_doi != item_doi:
- fixed_doi = True
+ fixed_doi = True
else:
del item["metadata"][identifierRegistration_key]
elif item.get("is_change_identifier", False):
@@ -3089,10 +3123,10 @@ def recursive_sub(keys, node, uri_key, current_type):
if fixed_doi:
warnings.append(_('The specified DOI is wrong and fixed with the registered DOI.'))
-
+
if fixed_doi_ra:
warnings.append(_('The specified DOI RA is wrong and fixed with the correct DOI RA of the registered DOI.'))
-
+
if is_change_identifier:
if not (current_app.config["WEKO_HANDLE_ALLOW_REGISTER_CNRI"] and item_cnri):
if item_doi is "":
@@ -3107,8 +3141,8 @@ def recursive_sub(keys, node, uri_key, current_type):
if item_doi_ra not in ("JaLC","Crossref","DataCite","NDL JaLC"):
errors.append(_('DOI_RA should be set by one of JaLC, Crossref, DataCite, NDL JaLC.'))
elif item_doi_prefix:
- errors.append(_('Specified Prefix of DOI is incorrect.'))
-
+ errors.append(_('Specified Prefix of DOI is incorrect.'))
+
item['errors'] = errors
item['warnings'] = warnings
@@ -3441,10 +3475,10 @@ def _get_export_data(export_path, item_types, retrys, fromid="", toid="", retry_
item_types.remove(it)
continue
- record_ids = [(recid.pid_value, recid.object_uuid)
+ record_ids = [(recid.pid_value, recid.object_uuid)
for recid in recids if recid.json and 'publish_status' in recid.json \
and recid.json['publish_status'] in [PublishStatus.PUBLIC.value, PublishStatus.PRIVATE.value]]
-
+
# recidsを削除
del recids
gc.collect()
@@ -3458,6 +3492,11 @@ def _get_export_data(export_path, item_types, retrys, fromid="", toid="", retry_
_file_create_key,
orjson.dumps(write_file_json).decode()
)
+
+ if len(record_ids) == 0:
+ item_types.remove(it)
+ continue
+
for recid, uuid in record_ids:
if counter % current_app.config["WEKO_SEARCH_UI_BULK_EXPORT_LIMIT"] == 0 and item_datas:
# Create export info file
@@ -3511,7 +3550,7 @@ def _get_export_data(export_path, item_types, retrys, fromid="", toid="", retry_
with open(pickle_file_name, 'wb') as f:
pickle.dump(item_datas, f)
-
+
del item_datas
gc.collect()
@@ -3571,7 +3610,7 @@ def _get_export_data(export_path, item_types, retrys, fromid="", toid="", retry_
else:
fromid = item_id_range
toid = item_id_range
-
+
result = None
if not fromid or not toid or (fromid and toid and int(fromid) <= int(toid)):
result = _get_export_data(export_path, item_types, 0, fromid, toid)
@@ -3600,7 +3639,7 @@ def write_files(item_datas, export_path, user_id, retrys):
export_path (str): file creation destination
user_id (int): performing user id
retrys (int): retry time
-
+
Returns:
bool: task is success or failure.
"""
@@ -3784,7 +3823,7 @@ def _check_write_file_info(json):
status = ""
start_time = ""
finish_time = ""
-
+
try:
task_id = get_redis_cache(cache_key)
download_uri = get_redis_cache(cache_uri)
@@ -3961,7 +4000,7 @@ def handle_check_file_metadata(list_record, data_path):
def handle_check_custom_sort_order(list_record):
"""Check CustomSortOrder.
-
+
Args:
list_record (list): List record import.
"""
@@ -4130,20 +4169,21 @@ def get_data_by_property(item_metadata, item_map, mapping_key):
:param mapping_key: Mapping key.
:return: Property key and values.
"""
- key = item_map.get(mapping_key)
+ key_list = item_map.get(mapping_key)
data = []
- if not key:
+ if not key_list:
current_app.logger.error(str(mapping_key) + " jpcoar:mapping " "is not correct")
return None, None
- attribute = item_metadata.get(key.split(".")[0])
- if not attribute:
- return None, key
- else:
- data_result = get_sub_item_value(attribute, key.split(".")[-1])
- if data_result:
- for value in data_result:
- data.append(value)
- return data, key
+ for key in key_list.split(","):
+ attribute = item_metadata.get(key.split(".")[0])
+ if not attribute:
+ return None, key_list
+ else:
+ data_result = get_sub_item_value(attribute, key.split(".")[-1])
+ if data_result:
+ for value in data_result:
+ data.append(value)
+ return data, key_list
def get_filenames_from_metadata(metadata):
@@ -4195,7 +4235,7 @@ def get_billinginfo_from_metadata(metadata):
Args:
metadata (dict): record metadata.
-
+
Returns:
billing_info (dict): Dict billing info from metadata.
"""
@@ -4235,7 +4275,7 @@ def get_billinginfo_from_metadata(metadata):
}
priceinfo.append(priceinfo_data)
second_count += 1
-
+
accessrole_info.append(accessrole_data)
displaytype_info.append(displaytype_data)
billing_file.append(billing_data)
diff --git a/modules/weko-sitemap/weko_sitemap/config.py b/modules/weko-sitemap/weko_sitemap/config.py
index f7a5df0cda..4233c932a4 100644
--- a/modules/weko-sitemap/weko_sitemap/config.py
+++ b/modules/weko-sitemap/weko_sitemap/config.py
@@ -36,6 +36,4 @@
SITEMAP_MAX_URL_COUNT = 10000
WEKO_SITEMAP__ROBOT_TXT = """
-User-agent: Bingbot
-Crawl-delay: 30
"""
diff --git a/modules/weko-sitemap/weko_sitemap/templates/weko_sitemap/robots.txt.tmpl b/modules/weko-sitemap/weko_sitemap/templates/weko_sitemap/robots.txt.tmpl
index 015caae79d..a9b098d2c5 100644
--- a/modules/weko-sitemap/weko_sitemap/templates/weko_sitemap/robots.txt.tmpl
+++ b/modules/weko-sitemap/weko_sitemap/templates/weko_sitemap/robots.txt.tmpl
@@ -1,6 +1,27 @@
User-agent: *
Disallow: /admin/
Disallow: /api/
+Disallow: /oai
+Disallow: /search
+Disallow: /items/ranking
+Disallow: /items/export
+Disallow: /login/
+Disallow: /shibauthorizer
+Disallow: /Shibboleth.sso
+Disallow: /shibboleth-sp
+Disallow: /secure/
+Disallow: /weko/shib
+Disallow: /ping
+Disallow: /static
+Disallow: /data
+Disallow: /records/*/export/json
+Disallow: /records/*/export/bibtex
+
+User-agent: Bingbot
+Crawl-delay: 30
+
+User-agent: PetalBot
+Disallow: /
{{ robot_txt }}
diff --git a/modules/weko-theme/weko_theme/templates/weko_theme/admin_header.html b/modules/weko-theme/weko_theme/templates/weko_theme/admin_header.html
index bee7b9359f..c769954d22 100644
--- a/modules/weko-theme/weko_theme/templates/weko_theme/admin_header.html
+++ b/modules/weko-theme/weko_theme/templates/weko_theme/admin_header.html
@@ -53,9 +53,11 @@
- {%- set username = current_userprofile.username|default(current_user.email) if current_userprofile else None %}
+ {%- set username = current_user.shib_weko_user[0].shib_handle if current_user.shib_weko_user and current_user.shib_weko_user|length > 0 and current_user.shib_weko_user[0].shib_handle else current_user.email %}
- {{ username or current_user.email }}
+