folio-migration-tools 1.10.0__tar.gz → 1.10.0b1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {folio_migration_tools-1.10.0 → folio_migration_tools-1.10.0b1}/PKG-INFO +2 -3
- {folio_migration_tools-1.10.0 → folio_migration_tools-1.10.0b1}/pyproject.toml +15 -15
- {folio_migration_tools-1.10.0 → folio_migration_tools-1.10.0b1}/src/folio_migration_tools/__main__.py +0 -9
- {folio_migration_tools-1.10.0 → folio_migration_tools-1.10.0b1}/src/folio_migration_tools/circulation_helper.py +5 -6
- {folio_migration_tools-1.10.0 → folio_migration_tools-1.10.0b1}/src/folio_migration_tools/folder_structure.py +6 -16
- {folio_migration_tools-1.10.0 → folio_migration_tools-1.10.0b1}/src/folio_migration_tools/helper.py +6 -7
- {folio_migration_tools-1.10.0 → folio_migration_tools-1.10.0b1}/src/folio_migration_tools/holdings_helper.py +3 -4
- {folio_migration_tools-1.10.0 → folio_migration_tools-1.10.0b1}/src/folio_migration_tools/library_configuration.py +0 -12
- {folio_migration_tools-1.10.0 → folio_migration_tools-1.10.0b1}/src/folio_migration_tools/mapper_base.py +6 -7
- {folio_migration_tools-1.10.0 → folio_migration_tools-1.10.0b1}/src/folio_migration_tools/mapping_file_transformation/user_mapper.py +0 -4
- {folio_migration_tools-1.10.0 → folio_migration_tools-1.10.0b1}/src/folio_migration_tools/marc_rules_transformation/conditions.py +29 -0
- {folio_migration_tools-1.10.0 → folio_migration_tools-1.10.0b1}/src/folio_migration_tools/marc_rules_transformation/marc_file_processor.py +9 -19
- folio_migration_tools-1.10.0b1/src/folio_migration_tools/marc_rules_transformation/rules_mapper_authorities.py +242 -0
- {folio_migration_tools-1.10.0 → folio_migration_tools-1.10.0b1}/src/folio_migration_tools/marc_rules_transformation/rules_mapper_base.py +15 -10
- {folio_migration_tools-1.10.0 → folio_migration_tools-1.10.0b1}/src/folio_migration_tools/marc_rules_transformation/rules_mapper_bibs.py +2 -3
- {folio_migration_tools-1.10.0 → folio_migration_tools-1.10.0b1}/src/folio_migration_tools/marc_rules_transformation/rules_mapper_holdings.py +5 -6
- {folio_migration_tools-1.10.0 → folio_migration_tools-1.10.0b1}/src/folio_migration_tools/migration_report.py +6 -17
- folio_migration_tools-1.10.0b1/src/folio_migration_tools/migration_tasks/authority_transformer.py +118 -0
- {folio_migration_tools-1.10.0 → folio_migration_tools-1.10.0b1}/src/folio_migration_tools/migration_tasks/batch_poster.py +298 -219
- {folio_migration_tools-1.10.0 → folio_migration_tools-1.10.0b1}/src/folio_migration_tools/migration_tasks/bibs_transformer.py +2 -2
- {folio_migration_tools-1.10.0 → folio_migration_tools-1.10.0b1}/src/folio_migration_tools/migration_tasks/holdings_csv_transformer.py +9 -9
- {folio_migration_tools-1.10.0 → folio_migration_tools-1.10.0b1}/src/folio_migration_tools/migration_tasks/holdings_marc_transformer.py +3 -3
- {folio_migration_tools-1.10.0 → folio_migration_tools-1.10.0b1}/src/folio_migration_tools/migration_tasks/items_transformer.py +4 -6
- {folio_migration_tools-1.10.0 → folio_migration_tools-1.10.0b1}/src/folio_migration_tools/migration_tasks/loans_migrator.py +18 -19
- {folio_migration_tools-1.10.0 → folio_migration_tools-1.10.0b1}/src/folio_migration_tools/migration_tasks/manual_fee_fines_transformer.py +3 -3
- {folio_migration_tools-1.10.0 → folio_migration_tools-1.10.0b1}/src/folio_migration_tools/migration_tasks/migration_task_base.py +6 -15
- {folio_migration_tools-1.10.0 → folio_migration_tools-1.10.0b1}/src/folio_migration_tools/migration_tasks/orders_transformer.py +3 -4
- {folio_migration_tools-1.10.0 → folio_migration_tools-1.10.0b1}/src/folio_migration_tools/migration_tasks/requests_migrator.py +9 -10
- {folio_migration_tools-1.10.0 → folio_migration_tools-1.10.0b1}/src/folio_migration_tools/migration_tasks/reserves_migrator.py +4 -5
- {folio_migration_tools-1.10.0 → folio_migration_tools-1.10.0b1}/src/folio_migration_tools/migration_tasks/user_transformer.py +5 -15
- {folio_migration_tools-1.10.0 → folio_migration_tools-1.10.0b1}/src/folio_migration_tools/translations/en.json +7 -0
- folio_migration_tools-1.10.0/src/folio_migration_tools/i18n_cache.py +0 -79
- {folio_migration_tools-1.10.0 → folio_migration_tools-1.10.0b1}/README.md +0 -0
- {folio_migration_tools-1.10.0 → folio_migration_tools-1.10.0b1}/src/folio_migration_tools/__init__.py +0 -0
- {folio_migration_tools-1.10.0 → folio_migration_tools-1.10.0b1}/src/folio_migration_tools/colors.py +0 -0
- {folio_migration_tools-1.10.0 → folio_migration_tools-1.10.0b1}/src/folio_migration_tools/config_file_load.py +0 -0
- {folio_migration_tools-1.10.0 → folio_migration_tools-1.10.0b1}/src/folio_migration_tools/custom_dict.py +0 -0
- {folio_migration_tools-1.10.0 → folio_migration_tools-1.10.0b1}/src/folio_migration_tools/custom_exceptions.py +0 -0
- {folio_migration_tools-1.10.0 → folio_migration_tools-1.10.0b1}/src/folio_migration_tools/extradata_writer.py +0 -0
- {folio_migration_tools-1.10.0 → folio_migration_tools-1.10.0b1}/src/folio_migration_tools/i18n_config.py +0 -0
- {folio_migration_tools-1.10.0 → folio_migration_tools-1.10.0b1}/src/folio_migration_tools/mapping_file_transformation/__init__.py +0 -0
- {folio_migration_tools-1.10.0 → folio_migration_tools-1.10.0b1}/src/folio_migration_tools/mapping_file_transformation/courses_mapper.py +0 -0
- {folio_migration_tools-1.10.0 → folio_migration_tools-1.10.0b1}/src/folio_migration_tools/mapping_file_transformation/holdings_mapper.py +0 -0
- {folio_migration_tools-1.10.0 → folio_migration_tools-1.10.0b1}/src/folio_migration_tools/mapping_file_transformation/item_mapper.py +0 -0
- {folio_migration_tools-1.10.0 → folio_migration_tools-1.10.0b1}/src/folio_migration_tools/mapping_file_transformation/manual_fee_fines_mapper.py +0 -0
- {folio_migration_tools-1.10.0 → folio_migration_tools-1.10.0b1}/src/folio_migration_tools/mapping_file_transformation/mapping_file_mapper_base.py +0 -0
- {folio_migration_tools-1.10.0 → folio_migration_tools-1.10.0b1}/src/folio_migration_tools/mapping_file_transformation/notes_mapper.py +0 -0
- {folio_migration_tools-1.10.0 → folio_migration_tools-1.10.0b1}/src/folio_migration_tools/mapping_file_transformation/order_mapper.py +0 -0
- {folio_migration_tools-1.10.0 → folio_migration_tools-1.10.0b1}/src/folio_migration_tools/mapping_file_transformation/organization_mapper.py +0 -0
- {folio_migration_tools-1.10.0 → folio_migration_tools-1.10.0b1}/src/folio_migration_tools/mapping_file_transformation/ref_data_mapping.py +0 -0
- {folio_migration_tools-1.10.0 → folio_migration_tools-1.10.0b1}/src/folio_migration_tools/marc_rules_transformation/__init__.py +0 -0
- {folio_migration_tools-1.10.0 → folio_migration_tools-1.10.0b1}/src/folio_migration_tools/marc_rules_transformation/holdings_statementsparser.py +0 -0
- {folio_migration_tools-1.10.0 → folio_migration_tools-1.10.0b1}/src/folio_migration_tools/marc_rules_transformation/hrid_handler.py +0 -0
- {folio_migration_tools-1.10.0 → folio_migration_tools-1.10.0b1}/src/folio_migration_tools/marc_rules_transformation/loc_language_codes.xml +0 -0
- {folio_migration_tools-1.10.0 → folio_migration_tools-1.10.0b1}/src/folio_migration_tools/marc_rules_transformation/marc_reader_wrapper.py +0 -0
- {folio_migration_tools-1.10.0 → folio_migration_tools-1.10.0b1}/src/folio_migration_tools/migration_tasks/__init__.py +0 -0
- {folio_migration_tools-1.10.0 → folio_migration_tools-1.10.0b1}/src/folio_migration_tools/migration_tasks/courses_migrator.py +0 -0
- {folio_migration_tools-1.10.0 → folio_migration_tools-1.10.0b1}/src/folio_migration_tools/migration_tasks/organization_transformer.py +0 -0
- {folio_migration_tools-1.10.0 → folio_migration_tools-1.10.0b1}/src/folio_migration_tools/task_configuration.py +0 -0
- {folio_migration_tools-1.10.0 → folio_migration_tools-1.10.0b1}/src/folio_migration_tools/transaction_migration/__init__.py +0 -0
- {folio_migration_tools-1.10.0 → folio_migration_tools-1.10.0b1}/src/folio_migration_tools/transaction_migration/legacy_loan.py +0 -0
- {folio_migration_tools-1.10.0 → folio_migration_tools-1.10.0b1}/src/folio_migration_tools/transaction_migration/legacy_request.py +0 -0
- {folio_migration_tools-1.10.0 → folio_migration_tools-1.10.0b1}/src/folio_migration_tools/transaction_migration/legacy_reserve.py +0 -0
- {folio_migration_tools-1.10.0 → folio_migration_tools-1.10.0b1}/src/folio_migration_tools/transaction_migration/transaction_result.py +0 -0
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: folio-migration-tools
|
|
3
|
-
Version: 1.10.
|
|
3
|
+
Version: 1.10.0b1
|
|
4
4
|
Summary: A tool allowing you to migrate data from legacy ILS:s (Library systems) into FOLIO LSP
|
|
5
5
|
Keywords: FOLIO,ILS,LSP,Library Systems,MARC21,Library data
|
|
6
6
|
Author: Theodor Tolstoy, Lisa Sjögren, Brooks Travis, Jeremy Nelson, Clinton Bradford
|
|
7
7
|
Author-email: Theodor Tolstoy <github.teddes@tolstoy.se>, Brooks Travis <brooks.travis@gmail.com>
|
|
8
8
|
License-Expression: MIT
|
|
9
|
-
Requires-Dist: folioclient>=1.0.
|
|
9
|
+
Requires-Dist: folioclient>=1.0.1
|
|
10
10
|
Requires-Dist: pyhumps>=3.7.3,<4.0.0
|
|
11
11
|
Requires-Dist: defusedxml>=0.7.1,<1.0.0
|
|
12
12
|
Requires-Dist: python-dateutil>=2.8.2,<3.0.0
|
|
@@ -18,7 +18,6 @@ Requires-Dist: deepdiff>=6.2.3,<7.0.0
|
|
|
18
18
|
Requires-Dist: pyaml>=21.10.1,<22.0.0
|
|
19
19
|
Requires-Dist: python-i18n>=0.3.9,<1.0.0
|
|
20
20
|
Requires-Dist: art>=6.5,<7.0
|
|
21
|
-
Requires-Dist: folio-data-import>=0.5.0,<0.6.0
|
|
22
21
|
Requires-Python: >=3.10, <4.0
|
|
23
22
|
Project-URL: Documentation, https://folio-migration-tools.readthedocs.io/en/latest/
|
|
24
23
|
Project-URL: Homepage, https://github.com/folio-fse/folio_migration_tools
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "folio_migration_tools"
|
|
3
|
-
version = "1.10.
|
|
3
|
+
version = "1.10.0b1"
|
|
4
4
|
description = "A tool allowing you to migrate data from legacy ILS:s (Library systems) into FOLIO LSP"
|
|
5
5
|
authors = [
|
|
6
6
|
{name = "Theodor Tolstoy", email = "github.teddes@tolstoy.se"},
|
|
@@ -14,19 +14,19 @@ readme = "README.md"
|
|
|
14
14
|
keywords = ["FOLIO", "ILS", "LSP", "Library Systems", "MARC21", "Library data"]
|
|
15
15
|
requires-python = ">=3.10,<4.0"
|
|
16
16
|
dependencies = [
|
|
17
|
-
"folioclient>=1.0.
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
17
|
+
"folioclient>=1.0.1",
|
|
18
|
+
"pyhumps>=3.7.3,<4.0.0",
|
|
19
|
+
"defusedxml>=0.7.1,<1.0.0",
|
|
20
|
+
"python-dateutil>=2.8.2,<3.0.0",
|
|
21
|
+
"folio-uuid>=1.0.0,<2.0.0",
|
|
22
|
+
"pymarc>=5.2.3,<6.0.0",
|
|
23
|
+
"pydantic>=2.12.3,<3.0.0",
|
|
24
|
+
"argparse-prompt>=0.0.5,<1.0.0",
|
|
25
|
+
"deepdiff>=6.2.3,<7.0.0",
|
|
26
|
+
"pyaml>=21.10.1,<22.0.0",
|
|
27
|
+
"python-i18n>=0.3.9,<1.0.0",
|
|
28
|
+
"art>=6.5,<7.0",
|
|
29
|
+
# "folio-data-import>=0.4.1"
|
|
30
30
|
]
|
|
31
31
|
|
|
32
32
|
[dependency-groups]
|
|
@@ -48,8 +48,8 @@ dev = [
|
|
|
48
48
|
"ipykernel>=6.29.5,<7.0.0",
|
|
49
49
|
"pytest-asyncio>=0.23.0,<0.24.0",
|
|
50
50
|
"lxml>=6.0.2",
|
|
51
|
+
"ty>=0.0.1a27",
|
|
51
52
|
"pyrefly>=0.43.1",
|
|
52
|
-
"ruff>=0.14.13",
|
|
53
53
|
]
|
|
54
54
|
docs = [
|
|
55
55
|
"m2r>=0.2.1,<0.3.0",
|
|
@@ -4,7 +4,6 @@ import logging
|
|
|
4
4
|
import sys
|
|
5
5
|
from os import environ
|
|
6
6
|
from pathlib import Path
|
|
7
|
-
from warnings import warn
|
|
8
7
|
|
|
9
8
|
import httpx
|
|
10
9
|
import humps
|
|
@@ -127,14 +126,6 @@ def main():
|
|
|
127
126
|
i18n.set("locale", args.report_language)
|
|
128
127
|
config_file, library_config = prep_library_config(args)
|
|
129
128
|
try:
|
|
130
|
-
if args.task_name == "AuthorityTransformer":
|
|
131
|
-
warn(
|
|
132
|
-
"The AuthorityTransformer has been removed."
|
|
133
|
-
" Please update your configuration accordingly."
|
|
134
|
-
" Use Data Import to load authority records.",
|
|
135
|
-
DeprecationWarning,
|
|
136
|
-
stacklevel=2,
|
|
137
|
-
)
|
|
138
129
|
migration_task_config = next(
|
|
139
130
|
t for t in config_file["migration_tasks"] if t["name"] == args.task_name
|
|
140
131
|
)
|
|
@@ -11,7 +11,6 @@ import i18n
|
|
|
11
11
|
from folioclient import FolioClient, FolioClientError, FolioConnectionError, FolioValidationError
|
|
12
12
|
|
|
13
13
|
from folio_migration_tools.helper import Helper
|
|
14
|
-
from folio_migration_tools.i18n_cache import i18n_t
|
|
15
14
|
from folio_migration_tools.migration_report import MigrationReport
|
|
16
15
|
from folio_migration_tools.transaction_migration.legacy_loan import LegacyLoan
|
|
17
16
|
from folio_migration_tools.transaction_migration.legacy_request import LegacyRequest
|
|
@@ -38,7 +37,7 @@ class CirculationHelper:
|
|
|
38
37
|
def get_user_by_barcode(self, user_barcode):
|
|
39
38
|
if user_barcode in self.missing_patron_barcodes:
|
|
40
39
|
self.migration_report.add_general_statistics(
|
|
41
|
-
|
|
40
|
+
i18n.t("Users already detected as missing")
|
|
42
41
|
)
|
|
43
42
|
logging.info("User is already detected as missing")
|
|
44
43
|
return {}
|
|
@@ -56,7 +55,7 @@ class CirculationHelper:
|
|
|
56
55
|
def get_item_by_barcode(self, item_barcode):
|
|
57
56
|
if item_barcode in self.missing_item_barcodes:
|
|
58
57
|
self.migration_report.add_general_statistics(
|
|
59
|
-
|
|
58
|
+
i18n.t("Items already detected as missing")
|
|
60
59
|
)
|
|
61
60
|
logging.info("Item is already detected as missing")
|
|
62
61
|
return {}
|
|
@@ -141,7 +140,7 @@ class CirculationHelper:
|
|
|
141
140
|
path = "/circulation/check-out-by-barcode"
|
|
142
141
|
try:
|
|
143
142
|
if legacy_loan.patron_barcode in self.missing_patron_barcodes:
|
|
144
|
-
error_message =
|
|
143
|
+
error_message = i18n.t("Patron barcode already detected as missing")
|
|
145
144
|
logging.error(
|
|
146
145
|
f"{error_message} Patron barcode: {legacy_loan.patron_barcode} "
|
|
147
146
|
f"Item Barcode:{legacy_loan.item_barcode}"
|
|
@@ -190,7 +189,7 @@ class CirculationHelper:
|
|
|
190
189
|
elif "find user with matching barcode" in error_message_from_folio:
|
|
191
190
|
self.missing_patron_barcodes.add(legacy_loan.patron_barcode)
|
|
192
191
|
error_message = f"No patron with barcode {legacy_loan.patron_barcode} in FOLIO"
|
|
193
|
-
stat_message =
|
|
192
|
+
stat_message = i18n.t("Patron barcode not in FOLIO")
|
|
194
193
|
return TransactionResult(
|
|
195
194
|
False,
|
|
196
195
|
False,
|
|
@@ -249,7 +248,7 @@ class CirculationHelper:
|
|
|
249
248
|
False,
|
|
250
249
|
None,
|
|
251
250
|
"Connection error",
|
|
252
|
-
|
|
251
|
+
i18n.t("Connection error during checkout"),
|
|
253
252
|
)
|
|
254
253
|
|
|
255
254
|
@staticmethod
|
|
@@ -22,8 +22,6 @@ class FolderStructure:
|
|
|
22
22
|
self.add_time_stamp_to_file_names = add_time_stamp_to_file_names
|
|
23
23
|
self.iteration_identifier = iteration_identifier
|
|
24
24
|
self.base_folder = Path(base_path)
|
|
25
|
-
# Ensure the base folder exists and is a directory. This differs from other folders, which
|
|
26
|
-
# are created if missing.
|
|
27
25
|
if not self.base_folder.is_dir():
|
|
28
26
|
logging.critical("Base Folder Path is not a folder. Exiting.")
|
|
29
27
|
sys.exit(1)
|
|
@@ -45,10 +43,6 @@ class FolderStructure:
|
|
|
45
43
|
self.reports_folder = self.iteration_folder / "reports"
|
|
46
44
|
self.verify_folder(self.reports_folder)
|
|
47
45
|
|
|
48
|
-
# Raw migration reports directory
|
|
49
|
-
self.raw_reports_folder = self.reports_folder / ".raw"
|
|
50
|
-
self.verify_folder(self.raw_reports_folder)
|
|
51
|
-
|
|
52
46
|
def log_folder_structure(self):
|
|
53
47
|
logging.info("Mapping files folder is %s", self.mapping_files_folder)
|
|
54
48
|
logging.info("Git ignore is set up correctly")
|
|
@@ -104,10 +98,6 @@ class FolderStructure:
|
|
|
104
98
|
|
|
105
99
|
self.migration_reports_file = self.reports_folder / f"report{self.file_template}.md"
|
|
106
100
|
|
|
107
|
-
self.migration_reports_raw_file = (
|
|
108
|
-
self.raw_reports_folder / f"raw_report{self.file_template}.json"
|
|
109
|
-
)
|
|
110
|
-
|
|
111
101
|
self.srs_records_path = (
|
|
112
102
|
self.results_folder / f"folio_srs_{object_type_string}{self.file_template}.json"
|
|
113
103
|
)
|
|
@@ -120,6 +110,9 @@ class FolderStructure:
|
|
|
120
110
|
self.instance_id_map_path = (
|
|
121
111
|
self.results_folder / f"{str(FOLIONamespaces.instances.name).lower()}_id_map.json"
|
|
122
112
|
)
|
|
113
|
+
self.auth_id_map_path = (
|
|
114
|
+
self.results_folder / f"{str(FOLIONamespaces.authorities.name).lower()}_id_map.json"
|
|
115
|
+
)
|
|
123
116
|
|
|
124
117
|
self.holdings_id_map_path = (
|
|
125
118
|
self.results_folder / f"{str(FOLIONamespaces.holdings.name).lower()}_id_map.json"
|
|
@@ -138,13 +131,10 @@ class FolderStructure:
|
|
|
138
131
|
self.item_statuses_map_path = self.mapping_files_folder / "item_statuses.tsv"
|
|
139
132
|
|
|
140
133
|
def verify_folder(self, folder_path: Path):
|
|
141
|
-
if
|
|
142
|
-
logging.critical("
|
|
134
|
+
if not folder_path.is_dir():
|
|
135
|
+
logging.critical("There is no folder located at %s. Exiting.", folder_path)
|
|
136
|
+
logging.critical("Create a folder by calling\n\tmkdir %s", folder_path)
|
|
143
137
|
sys.exit(1)
|
|
144
|
-
|
|
145
|
-
if not folder_path.exists():
|
|
146
|
-
logging.info("Creating missing folder %s", folder_path)
|
|
147
|
-
folder_path.mkdir(parents=True, exist_ok=True)
|
|
148
138
|
else:
|
|
149
139
|
logging.info("Located %s", folder_path)
|
|
150
140
|
|
{folio_migration_tools-1.10.0 → folio_migration_tools-1.10.0b1}/src/folio_migration_tools/helper.py
RENAMED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import json
|
|
2
2
|
import logging
|
|
3
|
-
|
|
4
|
-
from folio_migration_tools.i18n_cache import i18n_t
|
|
3
|
+
import i18n
|
|
5
4
|
|
|
6
5
|
|
|
7
6
|
class Helper:
|
|
@@ -10,15 +9,15 @@ class Helper:
|
|
|
10
9
|
report_file, total_records: int, mapped_folio_fields, mapped_legacy_fields
|
|
11
10
|
):
|
|
12
11
|
details_start = (
|
|
13
|
-
"<details><summary>" +
|
|
12
|
+
"<details><summary>" + i18n.t("Click to expand field report") + "</summary>\n\n"
|
|
14
13
|
)
|
|
15
14
|
details_end = "</details>\n"
|
|
16
|
-
report_file.write("\n## " +
|
|
15
|
+
report_file.write("\n## " + i18n.t("Mapped FOLIO fields") + "\n")
|
|
17
16
|
# report_file.write(f"{blurbs[header]}\n")
|
|
18
17
|
|
|
19
18
|
d_sorted = {k: mapped_folio_fields[k] for k in sorted(mapped_folio_fields)}
|
|
20
19
|
report_file.write(details_start)
|
|
21
|
-
columns = [
|
|
20
|
+
columns = [i18n.t("FOLIO Field"), i18n.t("Mapped"), i18n.t("Unmapped")]
|
|
22
21
|
report_file.write(" | ".join(columns) + "\n")
|
|
23
22
|
report_file.write("|".join(len(columns) * ["---"]) + "\n")
|
|
24
23
|
for k, v in d_sorted.items():
|
|
@@ -33,12 +32,12 @@ class Helper:
|
|
|
33
32
|
)
|
|
34
33
|
report_file.write(details_end)
|
|
35
34
|
|
|
36
|
-
report_file.write("\n## " +
|
|
35
|
+
report_file.write("\n## " + i18n.t("Mapped Legacy fields") + "\n")
|
|
37
36
|
# report_file.write(f"{blurbs[header]}\n")
|
|
38
37
|
|
|
39
38
|
d_sorted = {k: mapped_legacy_fields[k] for k in sorted(mapped_legacy_fields)}
|
|
40
39
|
report_file.write(details_start)
|
|
41
|
-
columns = [
|
|
40
|
+
columns = [i18n.t("Legacy Field"), i18n.t("Present"), i18n.t("Mapped"), i18n.t("Unmapped")]
|
|
42
41
|
report_file.write("|".join(columns) + "\n")
|
|
43
42
|
report_file.write("|".join(len(columns) * ["---"]) + "\n")
|
|
44
43
|
for k, v in d_sorted.items():
|
|
@@ -5,7 +5,6 @@ from uuid import uuid4
|
|
|
5
5
|
|
|
6
6
|
from folio_migration_tools import custom_exceptions
|
|
7
7
|
from folio_migration_tools import helper
|
|
8
|
-
from folio_migration_tools.i18n_cache import i18n_t
|
|
9
8
|
from folio_migration_tools.migration_report import MigrationReport
|
|
10
9
|
|
|
11
10
|
|
|
@@ -55,7 +54,7 @@ class HoldingsHelper:
|
|
|
55
54
|
values.append(str(uuid4()))
|
|
56
55
|
migration_report.add(
|
|
57
56
|
"HoldingsMerging",
|
|
58
|
-
|
|
57
|
+
i18n.t("Holding prevented from merging by holdingsTypeId"),
|
|
59
58
|
)
|
|
60
59
|
return "-".join(values)
|
|
61
60
|
except Exception as exception:
|
|
@@ -100,12 +99,12 @@ class HoldingsHelper:
|
|
|
100
99
|
)
|
|
101
100
|
migration_report.add(
|
|
102
101
|
"HoldingsMerging",
|
|
103
|
-
|
|
102
|
+
i18n.t("Duplicate key based on current merge criteria. Records merged"),
|
|
104
103
|
)
|
|
105
104
|
else:
|
|
106
105
|
migration_report.add(
|
|
107
106
|
"HoldingsMerging",
|
|
108
|
-
|
|
107
|
+
i18n.t("Previously transformed holdings record loaded"),
|
|
109
108
|
)
|
|
110
109
|
prev_holdings[stored_key] = stored_holding
|
|
111
110
|
return prev_holdings
|
|
@@ -62,18 +62,6 @@ class FileDefinition(BaseModel):
|
|
|
62
62
|
),
|
|
63
63
|
),
|
|
64
64
|
] = True
|
|
65
|
-
data_import_marc: Annotated[
|
|
66
|
-
bool,
|
|
67
|
-
Field(
|
|
68
|
-
title="Data import MARC",
|
|
69
|
-
description=(
|
|
70
|
-
"If set to true, successfully processed MARC records from this file will "
|
|
71
|
-
"be included in the MARC file for data import generated by the parent task for "
|
|
72
|
-
"inventory records created from this file. Only applied for MARC-based "
|
|
73
|
-
"transformations."
|
|
74
|
-
),
|
|
75
|
-
),
|
|
76
|
-
] = True
|
|
77
65
|
|
|
78
66
|
|
|
79
67
|
class IlsFlavour(str, Enum):
|
|
@@ -21,7 +21,6 @@ from folio_migration_tools.custom_exceptions import (
|
|
|
21
21
|
)
|
|
22
22
|
from folio_migration_tools.extradata_writer import ExtradataWriter
|
|
23
23
|
from folio_migration_tools.helper import Helper
|
|
24
|
-
from folio_migration_tools.i18n_cache import i18n_t
|
|
25
24
|
from folio_migration_tools.library_configuration import FileDefinition, LibraryConfiguration
|
|
26
25
|
from folio_migration_tools.mapping_file_transformation.ref_data_mapping import (
|
|
27
26
|
RefDataMapping,
|
|
@@ -235,10 +234,10 @@ class MapperBase:
|
|
|
235
234
|
self.migration_report.add("FieldMappingErrors", error)
|
|
236
235
|
error.id = error.id or index_or_id
|
|
237
236
|
error.log_it()
|
|
238
|
-
self.migration_report.add_general_statistics(
|
|
237
|
+
self.migration_report.add_general_statistics(i18n.t("Field Mapping Errors found"))
|
|
239
238
|
|
|
240
239
|
def handle_transformation_process_error(self, idx, error: TransformationProcessError):
|
|
241
|
-
self.migration_report.add_general_statistics(
|
|
240
|
+
self.migration_report.add_general_statistics(i18n.t("Transformation process error"))
|
|
242
241
|
logging.critical("%s\t%s", idx, error)
|
|
243
242
|
print(f"\n{error.message}: {error.data_value}")
|
|
244
243
|
sys.exit(1)
|
|
@@ -247,7 +246,7 @@ class MapperBase:
|
|
|
247
246
|
self, records_processed: int, error: TransformationRecordFailedError
|
|
248
247
|
):
|
|
249
248
|
self.migration_report.add(
|
|
250
|
-
"GeneralStatistics",
|
|
249
|
+
"GeneralStatistics", i18n.t("FAILED Records failed due to an error")
|
|
251
250
|
)
|
|
252
251
|
error.index_or_id = error.index_or_id or records_processed
|
|
253
252
|
error.log_it()
|
|
@@ -302,7 +301,7 @@ class MapperBase:
|
|
|
302
301
|
for id_string in legacy_map.values():
|
|
303
302
|
legacy_map_file.write(f"{json.dumps(id_string)}\n")
|
|
304
303
|
self.migration_report.add(
|
|
305
|
-
"GeneralStatistics",
|
|
304
|
+
"GeneralStatistics", i18n.t("Unique ID:s written to legacy map")
|
|
306
305
|
)
|
|
307
306
|
logging.info("Wrote legacy id map to %s", path)
|
|
308
307
|
|
|
@@ -358,7 +357,7 @@ class MapperBase:
|
|
|
358
357
|
def add_legacy_id_to_admin_note(self, folio_record: dict, legacy_id: str):
|
|
359
358
|
if not legacy_id:
|
|
360
359
|
raise TransformationFieldMappingError(
|
|
361
|
-
legacy_id,
|
|
360
|
+
legacy_id, i18n.t("Legacy id is empty"), legacy_id
|
|
362
361
|
)
|
|
363
362
|
if "administrativeNotes" not in folio_record:
|
|
364
363
|
folio_record["administrativeNotes"] = []
|
|
@@ -498,7 +497,7 @@ class MapperBase:
|
|
|
498
497
|
)
|
|
499
498
|
self.migration_report.add(
|
|
500
499
|
"StatisticalCodeMapping",
|
|
501
|
-
|
|
500
|
+
i18n.t("Mapping not set up"),
|
|
502
501
|
)
|
|
503
502
|
return ""
|
|
504
503
|
|
|
@@ -115,10 +115,6 @@ class UserMapper(MappingFileMapperBase):
|
|
|
115
115
|
|
|
116
116
|
if self.task_config.remove_request_preferences:
|
|
117
117
|
del clean_folio_object["requestPreference"]
|
|
118
|
-
|
|
119
|
-
if self.task_config.remove_username:
|
|
120
|
-
del clean_folio_object["username"]
|
|
121
|
-
|
|
122
118
|
self.report_folio_mapping_no_schema(clean_folio_object)
|
|
123
119
|
self.report_legacy_mapping_no_schema(legacy_user)
|
|
124
120
|
|
|
@@ -47,6 +47,8 @@ class Conditions:
|
|
|
47
47
|
if object_type == "bibs":
|
|
48
48
|
self.setup_reference_data_for_all()
|
|
49
49
|
self.setup_reference_data_for_bibs()
|
|
50
|
+
elif object_type == "auth":
|
|
51
|
+
self.setup_reference_data_for_auth()
|
|
50
52
|
else:
|
|
51
53
|
self.setup_reference_data_for_all()
|
|
52
54
|
self.setup_reference_data_for_items_and_holdings(default_call_number_type_name)
|
|
@@ -148,6 +150,15 @@ class Conditions:
|
|
|
148
150
|
if not self.folio.class_types:
|
|
149
151
|
raise TransformationProcessError("", "No class_types in FOLIO")
|
|
150
152
|
|
|
153
|
+
def setup_reference_data_for_auth(self):
|
|
154
|
+
self.authority_note_types = list(
|
|
155
|
+
self.folio.folio_get_all(
|
|
156
|
+
"/authority-note-types", "authorityNoteTypes", self.folio.cql_all, 1000
|
|
157
|
+
)
|
|
158
|
+
)
|
|
159
|
+
logging.info(f"{len(self.authority_note_types)} \tAuthority note types")
|
|
160
|
+
logging.info(f"{len(self.folio.identifier_types)} \tidentifier types") # type: ignore
|
|
161
|
+
|
|
151
162
|
def get_condition(
|
|
152
163
|
self, name, legacy_id, value, parameter=None, marc_field: field.Field | None = None
|
|
153
164
|
):
|
|
@@ -419,6 +430,24 @@ class Conditions:
|
|
|
419
430
|
parameter.get("name", ""),
|
|
420
431
|
) from ee
|
|
421
432
|
|
|
433
|
+
def condition_set_authority_note_type_id(
|
|
434
|
+
self, legacy_id, _, parameter, marc_field: field.Field
|
|
435
|
+
):
|
|
436
|
+
try:
|
|
437
|
+
t = self.get_ref_data_tuple_by_name(
|
|
438
|
+
self.authority_note_types, "authority_note_types", parameter["name"]
|
|
439
|
+
)
|
|
440
|
+
self.mapper.migration_report.add("MappedNoteTypes", t[1])
|
|
441
|
+
return t[0]
|
|
442
|
+
except Exception as ee:
|
|
443
|
+
logging.error(ee)
|
|
444
|
+
raise TransformationProcessError(
|
|
445
|
+
legacy_id,
|
|
446
|
+
f"Authority note type mapping error.\tParameter: {parameter.get('name', '')}\t"
|
|
447
|
+
f"MARC Field: {marc_field}. Is mapping rules and ref data aligned?",
|
|
448
|
+
parameter.get("name", ""),
|
|
449
|
+
) from ee
|
|
450
|
+
|
|
422
451
|
def condition_set_classification_type_id(
|
|
423
452
|
self, legacy_id, value, parameter, marc_field: field.Field
|
|
424
453
|
):
|
|
@@ -93,8 +93,8 @@ class MarcFileProcessor:
|
|
|
93
93
|
legacy_ids,
|
|
94
94
|
self.object_type,
|
|
95
95
|
)
|
|
96
|
-
|
|
97
|
-
|
|
96
|
+
if getattr(self.mapper.task_configuration, "data_import_marc", False):
|
|
97
|
+
self.save_marc_record(marc_record, folio_rec, self.object_type)
|
|
98
98
|
Helper.write_to_file(self.created_objects_file, folio_rec)
|
|
99
99
|
self.mapper.migration_report.add_general_statistics(
|
|
100
100
|
i18n.t("Inventory records written to disk")
|
|
@@ -131,23 +131,13 @@ class MarcFileProcessor:
|
|
|
131
131
|
):
|
|
132
132
|
self.mapper.remove_from_id_map(folio_rec.get("formerIds", []))
|
|
133
133
|
|
|
134
|
-
def save_marc_record(
|
|
135
|
-
self
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
if (
|
|
142
|
-
getattr(self.mapper.task_configuration, "data_import_marc", False)
|
|
143
|
-
and file_def.data_import_marc
|
|
144
|
-
):
|
|
145
|
-
self.mapper.save_data_import_marc_record(
|
|
146
|
-
self.data_import_marc_file,
|
|
147
|
-
object_type,
|
|
148
|
-
marc_record,
|
|
149
|
-
folio_rec,
|
|
150
|
-
)
|
|
134
|
+
def save_marc_record(self, marc_record: Record, folio_rec: Dict, object_type: FOLIONamespaces):
|
|
135
|
+
self.mapper.save_data_import_marc_record(
|
|
136
|
+
self.data_import_marc_file,
|
|
137
|
+
object_type,
|
|
138
|
+
marc_record,
|
|
139
|
+
folio_rec,
|
|
140
|
+
)
|
|
151
141
|
|
|
152
142
|
def save_srs_record(
|
|
153
143
|
self,
|