Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions modules/weko-items-autofill/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1901,20 +1901,20 @@ def test_get_researchmapid_record_data(app, db, itemtypes):

test = [{'item_1617186331708': [{'subitem_1551255647225': 'full-schema', 'subitem_1551255648112': 'en'}, {'subitem_1551255647225': '満艦飾', 'subitem_1551255648112': 'ja'}]}, {'item_1617186419668': [{'creatorNames': [{'creatorName': 'WEKO, 太郎', 'creatorNameLang': 'ja'}]}]}, {'item_1617186626617': [{'subitem_description': '描写', 'subitem_description_language': 'ja', 'subitem_description_type': ''}]}, {'item_1617186643794': [{'subitem_1522300316516': '出版者●●', 'subitem_1522300295150': 'ja'}]}, {'item_1617186660861': [{'subitem_1522300722591': '2024-02-05', 'subitem_1522300695726': '2024-02-05'}]}, {'item_1617186702042': [{'subitem_1551255818386': 'jpn'}]}, {'item_1617258105262': {'resourcetype': 'article'}}, {'item_1617186959569': {'subitem_1551256328147': '123'}}, {'item_1617186981471': {'subitem_1551256294723': '456'}}, {'item_1617187024783': {'subitem_1551256198917': '1'}}, {'item_1617187045071': {'subitem_1551256185532': '10'}}]
with patch("weko_items_autofill.utils.Researchmap.get_data", return_value=data):
result = get_researchmapid_record_data("M1cQhPtdmlrSRFo4", "published_papers", 1358081, 3)
result,_ = get_researchmapid_record_data("M1cQhPtdmlrSRFo4", "published_papers", 1358081, 3)
assert result == test

data_2 = json_data("data/researchmap_test_data_2.json")
data_2 = json.dumps(data_2)
test = [{'item_1617186331708': [{'subitem_1551255647225': 'aaaaa', 'subitem_1551255648112': 'en'}, {'subitem_1551255647225': 'ああああ', 'subitem_1551255648112': 'ja'}]}, {'item_1617186419668': [{'creatorNames': [{'creatorName': 'Author English', 'creatorNameLang': 'en'}]}]}, {'item_1617186626617': [{'subitem_description': '国際・国内誌概要(英語)', 'subitem_description_language': 'en', 'subitem_description_type': ''}, {'subitem_description': '国際・国内誌概要(日本語)', 'subitem_description_language': 'ja', 'subitem_description_type': ''}]}, {'item_1617186643794': [{'subitem_1522300316516': 'pub_english', 'subitem_1522300295150': 'en'}, {'subitem_1522300316516': '出版者・発行元(日本語)', 'subitem_1522300295150': 'ja'}]}, {'item_1617186660861': [{'subitem_1522300722591': '2010-10-10', 'subitem_1522300695726': '2010-10-10'}]}, {'item_1617186702042': [{'subitem_1551255818386': 'eng'}]}, {'item_1617258105262': {'resourcetype': 'article'}}, {'item_1617353299429': [{'subitem_1522306287251': {'subitem_1522306436033': ['10.11501/3140078'], 'subitem_1522306382014': 'DOI'}}]}, {'item_1617186959569': {'subitem_1551256328147': '123'}}, {'item_1617186981471': {'subitem_1551256294723': '456'}}, {'item_1617187024783': {'subitem_1551256198917': '1'}}, {'item_1617187045071': {'subitem_1551256185532': '10'}}]
with patch("weko_items_autofill.utils.Researchmap.get_data", return_value=data_2):
result = get_researchmapid_record_data("M1cQhPtdmlrSRFo4", "published_papers", 1356383, 3)
result,_ = get_researchmapid_record_data("M1cQhPtdmlrSRFo4", "published_papers", 1356383, 3)
assert result == test

result = get_researchmapid_record_data("M1cQhPtdmlrSRFo4", "published_papers", 1356383, 99999)
result,_ = get_researchmapid_record_data("M1cQhPtdmlrSRFo4", "published_papers", 1356383, 99999)
assert result == []

result = get_researchmapid_record_data("M1cQhPtdmlrSRFo4", "published_papers", 1356383, 4)
result,_ = get_researchmapid_record_data("M1cQhPtdmlrSRFo4", "published_papers", 1356383, 4)
assert result == []

data = {
Expand All @@ -1924,18 +1924,18 @@ def test_get_researchmapid_record_data(app, db, itemtypes):
data = json.dumps(data)
with patch("weko_items_autofill.utils.Researchmap.get_data", return_value=data):
with pytest.raises(Exception):
result = get_researchmapid_record_data("M1cQhPtdmlrSRFo4", "published_papers", 999999, 3)
result,_ = get_researchmapid_record_data("M1cQhPtdmlrSRFo4", "published_papers", 999999, 3)

with patch("weko_items_autofill.utils.Researchmap.get_data", return_value=data_2):
app.config.update(WEKO_ITEMS_UI_CRIS_LINKAGE_RESEARCHMAP_MAPPINGS = [{ 'type' : 'xxx' , "rm_name" : 'paper_title', "jpcore_name" : 'dc:title' , "weko_name" :"title"}])
result = get_researchmapid_record_data("M1cQhPtdmlrSRFo4", "published_papers", 1356383, 3)
result,_ = get_researchmapid_record_data("M1cQhPtdmlrSRFo4", "published_papers", 1356383, 3)
assert result == []

with patch("weko_items_autofill.utils.Researchmap.get_data", return_value=data_2):
app.config.update(WEKO_ITEMS_UI_CRIS_LINKAGE_RESEARCHMAP_MAPPINGS=WEKO_ITEMS_UI_CRIS_LINKAGE_RESEARCHMAP_MAPPINGS)
app.config.update(WEKO_ITEMS_UI_CRIS_LINKAGE_RESEARCHMAP_TYPE_MAPPINGS= [{'achievement_type' : 'xxx','detail_type_name':'','JPCOAR_resource_type':'article'}])
test = [{'item_1617186331708': [{'subitem_1551255647225': 'aaaaa', 'subitem_1551255648112': 'en'}, {'subitem_1551255647225': 'ああああ', 'subitem_1551255648112': 'ja'}]}, {'item_1617186419668': [{'creatorNames': [{'creatorName': 'Author English', 'creatorNameLang': 'en'}]}]}, {'item_1617186626617': [{'subitem_description': '国際・国内誌概要(英語)', 'subitem_description_language': 'en', 'subitem_description_type': ''}, {'subitem_description': '国際・国内誌概要(日本語)', 'subitem_description_language': 'ja', 'subitem_description_type': ''}]}, {'item_1617186643794': [{'subitem_1522300316516': 'pub_english', 'subitem_1522300295150': 'en'}, {'subitem_1522300316516': '出版者・発行元(日本語)', 'subitem_1522300295150': 'ja'}]}, {'item_1617186660861': [{'subitem_1522300722591': '2010-10-10', 'subitem_1522300695726': '2010-10-10'}]}, {'item_1617186702042': [{'subitem_1551255818386': 'eng'}]}, {'item_1617353299429': [{'subitem_1522306287251': {'subitem_1522306436033': ['10.11501/3140078'], 'subitem_1522306382014': 'DOI'}}]}, {'item_1617186959569': {'subitem_1551256328147': '123'}}, {'item_1617186981471': {'subitem_1551256294723': '456'}}, {'item_1617187024783': {'subitem_1551256198917': '1'}}, {'item_1617187045071': {'subitem_1551256185532': '10'}}]
result = get_researchmapid_record_data("M1cQhPtdmlrSRFo4", "published_papers", 1356383, 3)
result,_ = get_researchmapid_record_data("M1cQhPtdmlrSRFo4", "published_papers", 1356383, 3)
assert result == test


Expand Down
3 changes: 1 addition & 2 deletions modules/weko-items-autofill/weko_items_autofill/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,5 @@
"pageStart",
"pageEnd",
"conference"

]
"""CrossRef required item"""
"""Researchmap required item"""
4 changes: 3 additions & 1 deletion modules/weko-items-autofill/weko_items_autofill/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1437,7 +1437,8 @@ def __nest_and_merge( weko_name :str ,child_node:str , elements , api_data:dict)

elements = []
for key in lang_json.keys():
elements.append({'@value': lang_json[key] , '@type' : key.upper()})
for val in lang_json[key]:
elements.append({'@value': val , '@type' : key.upper()})

api_data = __nest_and_merge(weko_name ,child_node ,elements ,api_data)

Expand All @@ -1448,6 +1449,7 @@ def __nest_and_merge( weko_name :str ,child_node:str , elements , api_data:dict)
child_node:str = mapping.get('child_node','')
for r_type_mapping in researchtype_mappings:
if r_type_mapping.get('achievement_type') == achievement_type \
and mapping.get('achievement_type') == achievement_type \
and r_type_mapping.get('detail_type_name') == element :
resource_type = r_type_mapping.get('JPCOAR_resource_type')
api_data.update({weko_name : resource_type})
Expand Down
3 changes: 0 additions & 3 deletions modules/weko-items-ui/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,6 @@
'invenio_celery.tasks': [
'weko_items_ui = weko_items_ui.tasks',
],
"invenio_config.module": [
"weko_items_ui = weko_items_ui.config",
],
},
extras_require=extras_require,
install_requires=install_requires,
Expand Down
3 changes: 2 additions & 1 deletion modules/weko-items-ui/weko_items_ui/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@

,{'type' : 'lang' , "rm_name" : 'description', "jpcoar_name" : 'datacite:description' , "weko_name" :"description"}
,{'type' : 'lang' , "rm_name" : 'publisher', "jpcoar_name" : 'dc:publisher' , "weko_name" :"publisher"}
,{'type' : 'lang' , "rm_name" : 'publication_name ', "jpcoar_name" : 'jpcoar:sourceTitle' , "weko_name" :"sourceTitle"}
,{'type' : 'lang' , "rm_name" : 'publication_name', "jpcoar_name" : 'jpcoar:sourceTitle' , "weko_name" :"sourceTitle"}

,{'type' : 'lang' , "rm_name" : 'event', "jpcoar_name" : 'jpcoar:conference' , "weko_name" :"conference" , "child_node" : "conferenceName"}
,{'type' : 'lang' , "rm_name" : 'promoter', "jpcoar_name" : 'jpcoar:conference' , "weko_name" :"conference", "child_node" : "conferenceSponsor"}
Expand All @@ -287,6 +287,7 @@
,{'type' : 'authors' , "rm_name" : 'presenters' , "jpcoar_name" : 'jpcoar:creator' ,"weko_name": 'creator'}
,{'type' : 'identifiers', "rm_name" : "identifiers" , "jpcoar_name" : 'jpcoar:relation' ,"weko_name": 'relation'}
,{'type' : 'simple_value', "rm_name" : 'publication_date', "jpcoar_name" : 'datacite:date' , "weko_name" : "date"}
,{'type' : 'simple' ,"rm_name" : 'total_page', "jpcoar_name" : 'jpcoar:numPages', "weko_name" : "numPages"}
,{'type' : 'simple', "rm_name" : 'volume', "jpcoar_name" : 'jpcoar:volume' , "weko_name" : "volume"}
,{'type' : 'simple', "rm_name" : 'number', "jpcoar_name" : 'jpcoar:issue' , "weko_name" : "issue"}
,{'type' : 'simple', "rm_name" : 'starting_page', "jpcoar_name" : 'jpcoar:pageStart' , "weko_name" : "pageStart"}
Expand Down
3 changes: 1 addition & 2 deletions modules/weko-items-ui/weko_items_ui/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ class CRISLinkageResult(db.Model, Timestamp):

succeed = db.Column(
db.Boolean,
nullable= True,
default = False
nullable= True
)

failed_log = db.Column(
Expand Down
8 changes: 6 additions & 2 deletions modules/weko-items-ui/weko_items_ui/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@ def process_researchmap_queue(body , message):

# 結果の書き戻し
code = json.loads(result.splitlines()[0]).get('code')
is_success = code == 200 or code == 304

# v2api.pdf p17
is_success = code == 200 or code == 201 or code == 204 or code == 304

register_linkage_result(pid_int,is_success ,item_uuid ,result)

Expand Down Expand Up @@ -300,14 +302,16 @@ def __get_recursive( value , value_path ,lang , lang_path,idx):

elif rm_map['type'] == 'identifiers':
identifer_kv = {}
index = 0
for relatedIdentifier in jrc.get(rm_map["weko_name"] ,{}).get('relatedIdentifier', []):
identifierType =relatedIdentifier.get('identifierType')
if identifierType.upper() == "DOI" or identifierType.upper() == "ISBN" :
## 他の項目はresearchmapのAPI定義上更新不可。

value = jrc.get(rm_map["weko_name"]).get('relatedIdentifier')[0].get('value')
value = jrc.get(rm_map["weko_name"]).get('relatedIdentifier')[index].get('value')
identifer_kv = {identifierType.lower():value}
return_data.update({rm_map["rm_name"]:identifer_kv})
index = index + 1
# current_app.logger.debug('identifiers')

elif rm_map['type'] == 'authors':
Expand Down
Loading