From 306f4f65ebcd501288da4b915f932a367583fbd2 Mon Sep 17 00:00:00 2001 From: Paurikova2 <107862249+Paurikova2@users.noreply.github.com> Date: Fri, 22 Sep 2023 11:03:15 +0200 Subject: [PATCH] fixed error with loading data into workflowitem dict (#96) fixed error with loading data into workflowitem dict --- data_pump/item.py | 4 ++-- data_pump/var_declarations.py | 1 + main.data_pump.py | 15 ++++++++------- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/data_pump/item.py b/data_pump/item.py index 68de29b..8af0e2a 100644 --- a/data_pump/item.py +++ b/data_pump/item.py @@ -9,6 +9,7 @@ def import_item(metadata_class, handle_class, workflowitem_id_dict, + workspaceitem_id_dict, item_id_dict, collection_id_dict, eperson_id_dict, @@ -23,14 +24,13 @@ def import_item(metadata_class, workspaceitem_json_name = "workspaceitem.json" saved_workspace_json_name = "workspaceitem_dict.json" workflowitem_json_name = 'workflowitem.json' - saved_workflow_json_name = "workflow_dict.json" + saved_workflow_json_name = "workflowitem_dict.json" item_url = 'clarin/import/item' saved_item_json_name = "item_dict.json" workflowitem_url = 'clarin/import/workflowitem' imported_workspaceitem = 0 imported_workflowitem = 0 imported_item = 0 - workspaceitem_id_dict = {} # create dict from items by item id item_json_list = read_json(item_json_name) items_dict = {} diff --git a/data_pump/var_declarations.py b/data_pump/var_declarations.py index 9092d13..917671d 100644 --- a/data_pump/var_declarations.py +++ b/data_pump/var_declarations.py @@ -8,6 +8,7 @@ collection2logo_dict = {} item_id_dict = {} workflowitem_id_dict = {} +workspaceitem_id_dict = {} bitstreamformat_id_dict = {} primaryBitstream_dict = {} bitstream2bundle_dict = {} diff --git a/main.data_pump.py b/main.data_pump.py index 183e6c3..830c636 100644 --- a/main.data_pump.py +++ b/main.data_pump.py @@ -37,9 +37,9 @@ def at_the_end_of_import(handle_class_p, statistics_dict): " expected and imported " + str(value[1])) -def insert_data_into_dicts(eperson_json_name, user_registraion_json_name, +def load_data_into_dicts(eperson_json_name, user_registraion_json_name, group_json_name, community_json_name, collection_json_name, - item_json_name, workspace_json_name, workflow_json_name, + item_json_name, workspaceitem_json_name, workflow_json_name, bitstreamformat_json_name, bundle_json_name, bitstream_json_name, insert_data): if not insert_data: @@ -50,7 +50,7 @@ def insert_data_into_dicts(eperson_json_name, user_registraion_json_name, var.community_id_dict = create_dict_from_json(community_json_name) var.collection_id_dict = create_dict_from_json(collection_json_name) var.item_id_dict = create_dict_from_json(item_json_name) - var.workflowitem_id_dict = create_dict_from_json(workspace_json_name) + var.workspaceitem_id_dict = create_dict_from_json(workspaceitem_json_name) var.workflowitem_id_dict = create_dict_from_json(workflow_json_name) var.bitstreamformat_id_dict = create_dict_from_json(bitstreamformat_json_name) var.bundle_id_dict = create_dict_from_json(bundle_json_name) @@ -59,7 +59,7 @@ def insert_data_into_dicts(eperson_json_name, user_registraion_json_name, if __name__ == "__main__": parser = argparse.ArgumentParser(description='Upload values into dictionaries') - parser.add_argument('--insert_dict_bool', + parser.add_argument('--load_dict_bool', help='bool value if we load values into dict', required=False, type=bool, default=False) parser.add_argument('--save_dict_bool', @@ -76,18 +76,18 @@ def insert_data_into_dicts(eperson_json_name, user_registraion_json_name, if email_s_off not in ("y", "yes"): sys.exit() - insert_data_into_dicts("eperson_dict.json", + load_data_into_dicts("eperson_dict.json", "user_registration_dict.json", "epersongroup_dict.json", "community_dict.json", "collection_dict.json", "item_dict.json", - "workflowitem_dict.json", "workspaceitem_dict.json", + "workflowitem_dict.json", "bitstreamformatregistry_dict.json", "bundle_dict.json", "bitstream_dict.json", - args.insert_dict_bool) + args.load_dict_bool) handle_class = Handle() metadata_class = Metadata(var.statistics_dict, args.save_dict_bool) @@ -130,6 +130,7 @@ def insert_data_into_dicts(eperson_json_name, user_registraion_json_name, import_item(metadata_class, handle_class, var.workflowitem_id_dict, + var.workspaceitem_id_dict, var.item_id_dict, var.collection_id_dict, var.eperson_id_dict,