folio-migration-tools 1.9.1__tar.gz → 1.9.3__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.9.1 → folio_migration_tools-1.9.3}/PKG-INFO +1 -1
- {folio_migration_tools-1.9.1 → folio_migration_tools-1.9.3}/pyproject.toml +1 -1
- {folio_migration_tools-1.9.1 → folio_migration_tools-1.9.3}/src/folio_migration_tools/mapping_file_transformation/holdings_mapper.py +18 -1
- {folio_migration_tools-1.9.1 → folio_migration_tools-1.9.3}/src/folio_migration_tools/mapping_file_transformation/mapping_file_mapper_base.py +15 -6
- {folio_migration_tools-1.9.1 → folio_migration_tools-1.9.3}/src/folio_migration_tools/mapping_file_transformation/user_mapper.py +39 -31
- {folio_migration_tools-1.9.1 → folio_migration_tools-1.9.3}/src/folio_migration_tools/marc_rules_transformation/conditions.py +239 -30
- {folio_migration_tools-1.9.1 → folio_migration_tools-1.9.3}/src/folio_migration_tools/marc_rules_transformation/holdings_statementsparser.py +99 -65
- {folio_migration_tools-1.9.1 → folio_migration_tools-1.9.3}/src/folio_migration_tools/marc_rules_transformation/marc_file_processor.py +6 -1
- {folio_migration_tools-1.9.1 → folio_migration_tools-1.9.3}/src/folio_migration_tools/marc_rules_transformation/rules_mapper_base.py +10 -0
- {folio_migration_tools-1.9.1 → folio_migration_tools-1.9.3}/src/folio_migration_tools/marc_rules_transformation/rules_mapper_bibs.py +1 -1
- {folio_migration_tools-1.9.1 → folio_migration_tools-1.9.3}/src/folio_migration_tools/migration_tasks/batch_poster.py +82 -33
- {folio_migration_tools-1.9.1 → folio_migration_tools-1.9.3}/src/folio_migration_tools/migration_tasks/holdings_csv_transformer.py +0 -17
- {folio_migration_tools-1.9.1 → folio_migration_tools-1.9.3}/src/folio_migration_tools/migration_tasks/holdings_marc_transformer.py +22 -11
- {folio_migration_tools-1.9.1 → folio_migration_tools-1.9.3}/src/folio_migration_tools/migration_tasks/items_transformer.py +21 -9
- {folio_migration_tools-1.9.1 → folio_migration_tools-1.9.3}/src/folio_migration_tools/migration_tasks/loans_migrator.py +20 -4
- {folio_migration_tools-1.9.1 → folio_migration_tools-1.9.3}/src/folio_migration_tools/task_configuration.py +3 -1
- {folio_migration_tools-1.9.1 → folio_migration_tools-1.9.3}/src/folio_migration_tools/test_infrastructure/mocked_classes.py +5 -0
- {folio_migration_tools-1.9.1 → folio_migration_tools-1.9.3}/src/folio_migration_tools/transaction_migration/legacy_loan.py +8 -2
- {folio_migration_tools-1.9.1 → folio_migration_tools-1.9.3}/src/folio_migration_tools/translations/en.json +9 -0
- {folio_migration_tools-1.9.1 → folio_migration_tools-1.9.3}/LICENSE +0 -0
- {folio_migration_tools-1.9.1 → folio_migration_tools-1.9.3}/README.md +0 -0
- {folio_migration_tools-1.9.1 → folio_migration_tools-1.9.3}/src/folio_migration_tools/__init__.py +0 -0
- {folio_migration_tools-1.9.1 → folio_migration_tools-1.9.3}/src/folio_migration_tools/__main__.py +0 -0
- {folio_migration_tools-1.9.1 → folio_migration_tools-1.9.3}/src/folio_migration_tools/circulation_helper.py +0 -0
- {folio_migration_tools-1.9.1 → folio_migration_tools-1.9.3}/src/folio_migration_tools/colors.py +0 -0
- {folio_migration_tools-1.9.1 → folio_migration_tools-1.9.3}/src/folio_migration_tools/config_file_load.py +0 -0
- {folio_migration_tools-1.9.1 → folio_migration_tools-1.9.3}/src/folio_migration_tools/custom_dict.py +0 -0
- {folio_migration_tools-1.9.1 → folio_migration_tools-1.9.3}/src/folio_migration_tools/custom_exceptions.py +0 -0
- {folio_migration_tools-1.9.1 → folio_migration_tools-1.9.3}/src/folio_migration_tools/extradata_writer.py +0 -0
- {folio_migration_tools-1.9.1 → folio_migration_tools-1.9.3}/src/folio_migration_tools/folder_structure.py +0 -0
- {folio_migration_tools-1.9.1 → folio_migration_tools-1.9.3}/src/folio_migration_tools/helper.py +0 -0
- {folio_migration_tools-1.9.1 → folio_migration_tools-1.9.3}/src/folio_migration_tools/holdings_helper.py +0 -0
- {folio_migration_tools-1.9.1 → folio_migration_tools-1.9.3}/src/folio_migration_tools/i18n_config.py +0 -0
- {folio_migration_tools-1.9.1 → folio_migration_tools-1.9.3}/src/folio_migration_tools/library_configuration.py +0 -0
- {folio_migration_tools-1.9.1 → folio_migration_tools-1.9.3}/src/folio_migration_tools/mapper_base.py +0 -0
- {folio_migration_tools-1.9.1 → folio_migration_tools-1.9.3}/src/folio_migration_tools/mapping_file_transformation/__init__.py +0 -0
- {folio_migration_tools-1.9.1 → folio_migration_tools-1.9.3}/src/folio_migration_tools/mapping_file_transformation/courses_mapper.py +0 -0
- {folio_migration_tools-1.9.1 → folio_migration_tools-1.9.3}/src/folio_migration_tools/mapping_file_transformation/item_mapper.py +0 -0
- {folio_migration_tools-1.9.1 → folio_migration_tools-1.9.3}/src/folio_migration_tools/mapping_file_transformation/manual_fee_fines_mapper.py +0 -0
- {folio_migration_tools-1.9.1 → folio_migration_tools-1.9.3}/src/folio_migration_tools/mapping_file_transformation/notes_mapper.py +0 -0
- {folio_migration_tools-1.9.1 → folio_migration_tools-1.9.3}/src/folio_migration_tools/mapping_file_transformation/order_mapper.py +0 -0
- {folio_migration_tools-1.9.1 → folio_migration_tools-1.9.3}/src/folio_migration_tools/mapping_file_transformation/organization_mapper.py +0 -0
- {folio_migration_tools-1.9.1 → folio_migration_tools-1.9.3}/src/folio_migration_tools/mapping_file_transformation/ref_data_mapping.py +0 -0
- {folio_migration_tools-1.9.1 → folio_migration_tools-1.9.3}/src/folio_migration_tools/marc_rules_transformation/__init__.py +0 -0
- {folio_migration_tools-1.9.1 → folio_migration_tools-1.9.3}/src/folio_migration_tools/marc_rules_transformation/hrid_handler.py +0 -0
- {folio_migration_tools-1.9.1 → folio_migration_tools-1.9.3}/src/folio_migration_tools/marc_rules_transformation/loc_language_codes.xml +0 -0
- {folio_migration_tools-1.9.1 → folio_migration_tools-1.9.3}/src/folio_migration_tools/marc_rules_transformation/marc_reader_wrapper.py +0 -0
- {folio_migration_tools-1.9.1 → folio_migration_tools-1.9.3}/src/folio_migration_tools/marc_rules_transformation/rules_mapper_authorities.py +0 -0
- {folio_migration_tools-1.9.1 → folio_migration_tools-1.9.3}/src/folio_migration_tools/marc_rules_transformation/rules_mapper_holdings.py +0 -0
- {folio_migration_tools-1.9.1 → folio_migration_tools-1.9.3}/src/folio_migration_tools/migration_report.py +0 -0
- {folio_migration_tools-1.9.1 → folio_migration_tools-1.9.3}/src/folio_migration_tools/migration_tasks/__init__.py +0 -0
- {folio_migration_tools-1.9.1 → folio_migration_tools-1.9.3}/src/folio_migration_tools/migration_tasks/authority_transformer.py +0 -0
- {folio_migration_tools-1.9.1 → folio_migration_tools-1.9.3}/src/folio_migration_tools/migration_tasks/bibs_transformer.py +0 -0
- {folio_migration_tools-1.9.1 → folio_migration_tools-1.9.3}/src/folio_migration_tools/migration_tasks/courses_migrator.py +0 -0
- {folio_migration_tools-1.9.1 → folio_migration_tools-1.9.3}/src/folio_migration_tools/migration_tasks/manual_fee_fines_transformer.py +0 -0
- {folio_migration_tools-1.9.1 → folio_migration_tools-1.9.3}/src/folio_migration_tools/migration_tasks/migration_task_base.py +0 -0
- {folio_migration_tools-1.9.1 → folio_migration_tools-1.9.3}/src/folio_migration_tools/migration_tasks/orders_transformer.py +0 -0
- {folio_migration_tools-1.9.1 → folio_migration_tools-1.9.3}/src/folio_migration_tools/migration_tasks/organization_transformer.py +0 -0
- {folio_migration_tools-1.9.1 → folio_migration_tools-1.9.3}/src/folio_migration_tools/migration_tasks/requests_migrator.py +0 -0
- {folio_migration_tools-1.9.1 → folio_migration_tools-1.9.3}/src/folio_migration_tools/migration_tasks/reserves_migrator.py +0 -0
- {folio_migration_tools-1.9.1 → folio_migration_tools-1.9.3}/src/folio_migration_tools/migration_tasks/user_transformer.py +0 -0
- {folio_migration_tools-1.9.1 → folio_migration_tools-1.9.3}/src/folio_migration_tools/test_infrastructure/__init__.py +0 -0
- {folio_migration_tools-1.9.1 → folio_migration_tools-1.9.3}/src/folio_migration_tools/transaction_migration/__init__.py +0 -0
- {folio_migration_tools-1.9.1 → folio_migration_tools-1.9.3}/src/folio_migration_tools/transaction_migration/legacy_request.py +0 -0
- {folio_migration_tools-1.9.1 → folio_migration_tools-1.9.3}/src/folio_migration_tools/transaction_migration/legacy_reserve.py +0 -0
- {folio_migration_tools-1.9.1 → folio_migration_tools-1.9.3}/src/folio_migration_tools/transaction_migration/transaction_result.py +0 -0
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import ast
|
|
2
|
+
import json
|
|
3
|
+
import logging
|
|
2
4
|
|
|
3
5
|
import i18n
|
|
4
6
|
from folio_uuid.folio_uuid import FOLIONamespaces
|
|
5
7
|
from folioclient import FolioClient
|
|
6
8
|
|
|
7
|
-
from folio_migration_tools.custom_exceptions import TransformationRecordFailedError
|
|
9
|
+
from folio_migration_tools.custom_exceptions import TransformationProcessError, TransformationRecordFailedError
|
|
8
10
|
from folio_migration_tools.library_configuration import (
|
|
9
11
|
FileDefinition,
|
|
10
12
|
LibraryConfiguration,
|
|
@@ -59,6 +61,21 @@ class HoldingsMapper(MappingFileMapperBase):
|
|
|
59
61
|
"name",
|
|
60
62
|
"CallNumberTypeMapping",
|
|
61
63
|
)
|
|
64
|
+
self.holdings_sources = self.get_holdings_sources()
|
|
65
|
+
|
|
66
|
+
def get_holdings_sources(self):
|
|
67
|
+
res = {}
|
|
68
|
+
holdings_sources = list(
|
|
69
|
+
self.folio_client.folio_get_all("/holdings-sources", "holdingsRecordsSources")
|
|
70
|
+
)
|
|
71
|
+
logging.info("Fetched %s holdingsRecordsSources from tenant", len(holdings_sources))
|
|
72
|
+
res = {n["name"].upper(): n["id"] for n in holdings_sources}
|
|
73
|
+
if "FOLIO" not in res:
|
|
74
|
+
raise TransformationProcessError("", "No holdings source with name FOLIO in tenant")
|
|
75
|
+
if "MARC" not in res:
|
|
76
|
+
raise TransformationProcessError("", "No holdings source with name MARC in tenant")
|
|
77
|
+
logging.info(json.dumps(res, indent=4))
|
|
78
|
+
return res
|
|
62
79
|
|
|
63
80
|
def perform_additional_mappings(self, legacy_ids, folio_rec, file_def):
|
|
64
81
|
self.handle_suppression(folio_rec, file_def)
|
|
@@ -171,14 +171,15 @@ class MappingFileMapperBase(MapperBase):
|
|
|
171
171
|
object_type: FOLIONamespaces,
|
|
172
172
|
accept_duplicate_ids: bool = False,
|
|
173
173
|
):
|
|
174
|
+
folio_object = {}
|
|
174
175
|
if self.ignore_legacy_identifier:
|
|
175
|
-
|
|
176
|
+
folio_object.update(
|
|
176
177
|
{
|
|
177
178
|
"id": str(uuid.uuid4()),
|
|
178
179
|
"type": "object",
|
|
179
|
-
}
|
|
180
|
-
index_or_id,
|
|
180
|
+
}
|
|
181
181
|
)
|
|
182
|
+
return folio_object, index_or_id
|
|
182
183
|
|
|
183
184
|
if not (
|
|
184
185
|
legacy_id := " ".join(
|
|
@@ -205,13 +206,21 @@ class MappingFileMapperBase(MapperBase):
|
|
|
205
206
|
)
|
|
206
207
|
else:
|
|
207
208
|
self.unique_record_ids.add(generated_id)
|
|
208
|
-
|
|
209
|
+
folio_object.update(
|
|
209
210
|
{
|
|
210
211
|
"id": generated_id,
|
|
211
212
|
"type": "object",
|
|
212
|
-
}
|
|
213
|
-
legacy_id,
|
|
213
|
+
}
|
|
214
214
|
)
|
|
215
|
+
if object_type == FOLIONamespaces.holdings and hasattr(self, "holdings_sources"):
|
|
216
|
+
folio_object['sourceId'] = self.holdings_sources.get("FOLIO")
|
|
217
|
+
elif object_type == FOLIONamespaces.holdings and not hasattr(self, "holdings_sources"):
|
|
218
|
+
raise TransformationProcessError(
|
|
219
|
+
index_or_id,
|
|
220
|
+
"Holdings source not set in the mapper",
|
|
221
|
+
None
|
|
222
|
+
)
|
|
223
|
+
return folio_object, legacy_id
|
|
215
224
|
|
|
216
225
|
def get_statistical_code(self, legacy_item: dict, folio_prop_name: str, index_or_id):
|
|
217
226
|
if self.statistical_codes_mapping:
|
|
@@ -59,8 +59,8 @@ class UserMapper(MappingFileMapperBase):
|
|
|
59
59
|
True,
|
|
60
60
|
)
|
|
61
61
|
self.notes_mapper.migration_report = self.migration_report
|
|
62
|
-
self.setup_departments_mapping(departments_mapping)
|
|
63
|
-
self.setup_groups_mapping(groups_map)
|
|
62
|
+
self.departments_mapping = self.setup_departments_mapping(departments_mapping)
|
|
63
|
+
self.groups_mapping = self.setup_groups_mapping(groups_map)
|
|
64
64
|
|
|
65
65
|
for m in self.record_map["data"]:
|
|
66
66
|
if m["folio_field"].startswith("customFields"):
|
|
@@ -120,7 +120,8 @@ class UserMapper(MappingFileMapperBase):
|
|
|
120
120
|
|
|
121
121
|
return clean_folio_object
|
|
122
122
|
|
|
123
|
-
|
|
123
|
+
@staticmethod
|
|
124
|
+
def get_users(source_file, file_format: str):
|
|
124
125
|
csv.register_dialect("tsv", delimiter="\t")
|
|
125
126
|
if file_format == "tsv":
|
|
126
127
|
reader = csv.DictReader(source_file, dialect="tsv")
|
|
@@ -156,12 +157,25 @@ class UserMapper(MappingFileMapperBase):
|
|
|
156
157
|
"No Departments mapping set up. Set up a departments mapping file "
|
|
157
158
|
" or remove the mapping of the Departments field",
|
|
158
159
|
)
|
|
159
|
-
|
|
160
|
-
self.departments_mapping,
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
160
|
+
if len(self.departments_mapping.mapped_legacy_keys) == 1 and self.library_configuration.multi_field_delimiter in legacy_user.get(self.departments_mapping.mapped_legacy_keys[0], ""):
|
|
161
|
+
split_departments = legacy_user.get(self.departments_mapping.mapped_legacy_keys[0], "").split(
|
|
162
|
+
self.library_configuration.multi_field_delimiter
|
|
163
|
+
)
|
|
164
|
+
return self.library_configuration.multi_field_delimiter.join([
|
|
165
|
+
self.get_mapped_name(
|
|
166
|
+
self.departments_mapping,
|
|
167
|
+
{self.departments_mapping.mapped_legacy_keys[0]: dept},
|
|
168
|
+
index_or_id,
|
|
169
|
+
True,
|
|
170
|
+
) for dept in split_departments
|
|
171
|
+
])
|
|
172
|
+
else:
|
|
173
|
+
return self.get_mapped_name(
|
|
174
|
+
self.departments_mapping,
|
|
175
|
+
legacy_user,
|
|
176
|
+
index_or_id,
|
|
177
|
+
True,
|
|
178
|
+
)
|
|
165
179
|
elif folio_prop_name in ["expirationDate", "enrollmentDate", "personal.dateOfBirth"]:
|
|
166
180
|
return self.get_parsed_date(mapped_value, folio_prop_name)
|
|
167
181
|
return mapped_value
|
|
@@ -184,27 +198,21 @@ class UserMapper(MappingFileMapperBase):
|
|
|
184
198
|
return ""
|
|
185
199
|
|
|
186
200
|
def setup_groups_mapping(self, groups_map):
|
|
187
|
-
|
|
188
|
-
self.
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
)
|
|
196
|
-
else:
|
|
197
|
-
self.groups_mapping = None
|
|
201
|
+
return RefDataMapping(
|
|
202
|
+
self.folio_client,
|
|
203
|
+
"/groups",
|
|
204
|
+
"usergroups",
|
|
205
|
+
groups_map,
|
|
206
|
+
"group",
|
|
207
|
+
"UserGroupMapping",
|
|
208
|
+
) if groups_map else None
|
|
198
209
|
|
|
199
210
|
def setup_departments_mapping(self, departments_mapping):
|
|
200
|
-
|
|
201
|
-
self.
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
)
|
|
209
|
-
else:
|
|
210
|
-
self.departments_mapping = None
|
|
211
|
+
return RefDataMapping(
|
|
212
|
+
self.folio_client,
|
|
213
|
+
"/departments",
|
|
214
|
+
"departments",
|
|
215
|
+
departments_mapping,
|
|
216
|
+
"name",
|
|
217
|
+
"DepartmentsMapping",
|
|
218
|
+
) if departments_mapping else None
|
|
@@ -90,6 +90,7 @@ class Conditions:
|
|
|
90
90
|
logging.info("%s\tholding_note_types", len(self.folio.holding_note_types)) # type: ignore
|
|
91
91
|
logging.info("%s\tcall_number_types", len(self.folio.call_number_types)) # type: ignore
|
|
92
92
|
self.setup_and_validate_holdings_types()
|
|
93
|
+
self.ill_policies = self.folio.folio_get_all("/ill-policies", "illPolicies")
|
|
93
94
|
# Raise for empty settings
|
|
94
95
|
if not self.folio.holding_note_types:
|
|
95
96
|
raise TransformationProcessError("", "No holding_note_types in FOLIO")
|
|
@@ -466,36 +467,6 @@ class Conditions:
|
|
|
466
467
|
def condition_char_select(self, legacy_id, value, parameter, marc_field: field.Field):
|
|
467
468
|
return value[parameter["from"] : parameter["to"]]
|
|
468
469
|
|
|
469
|
-
def condition_set_receipt_status(self, legacy_id, value, parameter, marc_field: field.Field):
|
|
470
|
-
if len(value) < 7:
|
|
471
|
-
self.mapper.migration_report.add(
|
|
472
|
-
"ReceiptStatusMapping", i18n.t("008 is too short") + f": {value}"
|
|
473
|
-
)
|
|
474
|
-
return ""
|
|
475
|
-
try:
|
|
476
|
-
status_map = {
|
|
477
|
-
"0": "Unknown",
|
|
478
|
-
"1": "Other receipt or acquisition status",
|
|
479
|
-
"2": "Received and complete or ceased",
|
|
480
|
-
"3": "On order",
|
|
481
|
-
"4": "Currently received",
|
|
482
|
-
"5": "Not currently received",
|
|
483
|
-
"6": "External access",
|
|
484
|
-
}
|
|
485
|
-
mapped_value = status_map[value[6]]
|
|
486
|
-
self.mapper.migration_report.add(
|
|
487
|
-
"ReceiptStatusMapping",
|
|
488
|
-
i18n.t(
|
|
489
|
-
"%{value} mapped to %{mapped_value}", value=value[6], mapped_value=mapped_value
|
|
490
|
-
),
|
|
491
|
-
)
|
|
492
|
-
|
|
493
|
-
return
|
|
494
|
-
except Exception:
|
|
495
|
-
self.mapper.migration_report.add(
|
|
496
|
-
"ReceiptStatusMapping", i18n.t("%{value} not found in map.", value=value)
|
|
497
|
-
)
|
|
498
|
-
return "Unknown"
|
|
499
470
|
|
|
500
471
|
def condition_set_identifier_type_id_by_name(
|
|
501
472
|
self, legacy_id, value, parameter, marc_field: field.Field
|
|
@@ -915,3 +886,241 @@ class Conditions:
|
|
|
915
886
|
legacy_id,
|
|
916
887
|
f"Subject source not found for {value} {marc_field}",
|
|
917
888
|
)
|
|
889
|
+
|
|
890
|
+
def condition_set_receipt_status(
|
|
891
|
+
self, legacy_id, value, parameter, marc_field: field.Field
|
|
892
|
+
):
|
|
893
|
+
"""
|
|
894
|
+
This method maps the receipt status based on the 008 field.
|
|
895
|
+
This condition is not available in FOLIO's MARC mapping engine and
|
|
896
|
+
will require use of a supplemental mapping rules file in the
|
|
897
|
+
HoldingsMarcTransformer task definition.
|
|
898
|
+
"""
|
|
899
|
+
if len(value) < 7:
|
|
900
|
+
self.mapper.migration_report.add(
|
|
901
|
+
"ReceiptStatusMapping", i18n.t("008 is too short") + f": {value}"
|
|
902
|
+
)
|
|
903
|
+
return ""
|
|
904
|
+
|
|
905
|
+
status_map = {
|
|
906
|
+
"0": "Unknown",
|
|
907
|
+
"1": "Other receipt or acquisition status",
|
|
908
|
+
"2": "Received and complete or ceased",
|
|
909
|
+
"3": "On order",
|
|
910
|
+
"4": "Currently received",
|
|
911
|
+
"5": "Not currently received",
|
|
912
|
+
"6": "External access",
|
|
913
|
+
}
|
|
914
|
+
|
|
915
|
+
try:
|
|
916
|
+
mapped_value = status_map[value[6]]
|
|
917
|
+
self.mapper.migration_report.add(
|
|
918
|
+
"ReceiptStatusMapping",
|
|
919
|
+
i18n.t(
|
|
920
|
+
"%{value} mapped to %{mapped_value}",
|
|
921
|
+
value=value[6],
|
|
922
|
+
mapped_value=mapped_value,
|
|
923
|
+
),
|
|
924
|
+
)
|
|
925
|
+
return mapped_value
|
|
926
|
+
except Exception:
|
|
927
|
+
self.mapper.migration_report.add(
|
|
928
|
+
"ReceiptStatusMapping", i18n.t("%{value} not found in map.", value=value[6])
|
|
929
|
+
)
|
|
930
|
+
return ""
|
|
931
|
+
|
|
932
|
+
def condition_set_acquisition_method(
|
|
933
|
+
self, legacy_id, value, parameter, marc_field: field.Field
|
|
934
|
+
):
|
|
935
|
+
"""
|
|
936
|
+
This method maps the acquisition method based on the 008 field.
|
|
937
|
+
This condition is not available in FOLIO's MARC mapping engine and
|
|
938
|
+
will require use of a supplemental mapping rules file in the
|
|
939
|
+
HoldingsMarcTransformer task definition.
|
|
940
|
+
"""
|
|
941
|
+
if len(value) < 8:
|
|
942
|
+
self.mapper.migration_report.add(
|
|
943
|
+
"ReceiptStatusMapping", i18n.t("008 is too short") + f": {value}"
|
|
944
|
+
)
|
|
945
|
+
return ""
|
|
946
|
+
|
|
947
|
+
try:
|
|
948
|
+
acq_methods = {
|
|
949
|
+
"c": "Cooperative or consortial purchase",
|
|
950
|
+
"d": "Deposit",
|
|
951
|
+
"e": "Exchange",
|
|
952
|
+
"f": "Free",
|
|
953
|
+
"g": "Gift",
|
|
954
|
+
"l": "Legal deposit",
|
|
955
|
+
"m": "Membership",
|
|
956
|
+
"n": "Non-library purchase",
|
|
957
|
+
"p": "Purchase",
|
|
958
|
+
"q": "Lease",
|
|
959
|
+
"u": "Unknown",
|
|
960
|
+
"z": "Other method of acquisition",
|
|
961
|
+
}
|
|
962
|
+
mapped_value = acq_methods[value[7]]
|
|
963
|
+
self.mapper.migration_report.add(
|
|
964
|
+
"MethodOfAcquisitionMapping",
|
|
965
|
+
i18n.t(
|
|
966
|
+
"%{value} mapped to %{mapped_value}", value=value[7], mapped_value=mapped_value
|
|
967
|
+
),
|
|
968
|
+
)
|
|
969
|
+
return mapped_value
|
|
970
|
+
except Exception:
|
|
971
|
+
self.mapper.migration_report.add(
|
|
972
|
+
"MethodOfAcquisitionMapping", i18n.t("%{value} not found in map.", value=value[8])
|
|
973
|
+
)
|
|
974
|
+
return ""
|
|
975
|
+
|
|
976
|
+
def condition_set_retention_policy(
|
|
977
|
+
self, legacy_id, value, parameter, marc_field: field.Field
|
|
978
|
+
):
|
|
979
|
+
"""
|
|
980
|
+
This method maps the retention policy based on the 008 field.
|
|
981
|
+
This condition is not available in FOLIO's MARC mapping engine and
|
|
982
|
+
will require use of a supplemental mapping rules file in the
|
|
983
|
+
HoldingsMarcTransformer task definition.
|
|
984
|
+
"""
|
|
985
|
+
if len(value) < 13:
|
|
986
|
+
self.mapper.migration_report.add(
|
|
987
|
+
"RetentionPolicyMapping", i18n.t("008 is too short") + f": {value}"
|
|
988
|
+
)
|
|
989
|
+
return ""
|
|
990
|
+
value = value.replace("|", " ").replace("#", " ") # Replace pipe with space for mapping consistency
|
|
991
|
+
try:
|
|
992
|
+
retention_policies = {
|
|
993
|
+
"0": "Unknown",
|
|
994
|
+
"1": "Other general retention policy",
|
|
995
|
+
"2": "Retained except as replaced by updates",
|
|
996
|
+
"3": "Sample issue retained",
|
|
997
|
+
"4": "Retained until replaced by microform",
|
|
998
|
+
"5": "Retained until replaced by cumulation, replacement volume, or revision",
|
|
999
|
+
"6": "Retained for a limited period",
|
|
1000
|
+
"7": "Not retained",
|
|
1001
|
+
"8": "Permanently retained",
|
|
1002
|
+
}
|
|
1003
|
+
mapped_value = retention_policies[value[12]]
|
|
1004
|
+
self.mapper.migration_report.add(
|
|
1005
|
+
"RetentionPolicyMapping",
|
|
1006
|
+
i18n.t(
|
|
1007
|
+
"%{value} mapped to %{mapped_value}",
|
|
1008
|
+
value=value[12],
|
|
1009
|
+
mapped_value=mapped_value,
|
|
1010
|
+
),
|
|
1011
|
+
)
|
|
1012
|
+
if value[12] == "6":
|
|
1013
|
+
policy_types = {
|
|
1014
|
+
"l": "Latest",
|
|
1015
|
+
"p": "Previous",
|
|
1016
|
+
}
|
|
1017
|
+
unit_types = {
|
|
1018
|
+
"m": "Day",
|
|
1019
|
+
"w": "Month",
|
|
1020
|
+
"y": "Year",
|
|
1021
|
+
"e": "Edition",
|
|
1022
|
+
"i": "Issue",
|
|
1023
|
+
"s": "Supplement"
|
|
1024
|
+
}
|
|
1025
|
+
try:
|
|
1026
|
+
specific_retention_policy = ""
|
|
1027
|
+
if value[13].strip() or value[15].strip():
|
|
1028
|
+
if value[14].strip() and int(value[14]) > 1:
|
|
1029
|
+
specific_retention_policy = f"{policy_types.get(value[13], '')} {value[14]} {unit_types.get(value[15], '')}s retained".strip()
|
|
1030
|
+
else:
|
|
1031
|
+
specific_retention_policy = f"{policy_types.get(value[13], '')} {unit_types.get(value[15], '')} retained".strip()
|
|
1032
|
+
if specific_retention_policy:
|
|
1033
|
+
self.mapper.migration_report.add(
|
|
1034
|
+
"RetentionPolicyMapping",
|
|
1035
|
+
i18n.t(
|
|
1036
|
+
"Retention policy 6 indicates a limited period. Specific retention period will be mapped from 008/13-15",
|
|
1037
|
+
)
|
|
1038
|
+
)
|
|
1039
|
+
return specific_retention_policy
|
|
1040
|
+
else:
|
|
1041
|
+
raise ValueError(
|
|
1042
|
+
"Specific retention policy is empty or invalid in 008/13-15"
|
|
1043
|
+
)
|
|
1044
|
+
except ValueError:
|
|
1045
|
+
self.mapper.migration_report.add(
|
|
1046
|
+
"RetentionPolicyMapping",
|
|
1047
|
+
i18n.t("Invalid specific retention policy in 008/13-15: %{value}", value=value[13:16]),
|
|
1048
|
+
)
|
|
1049
|
+
return mapped_value
|
|
1050
|
+
except Exception:
|
|
1051
|
+
self.mapper.migration_report.add(
|
|
1052
|
+
"RetentionPolicyMapping", i18n.t("%{value} not found in map.", value=value[12])
|
|
1053
|
+
)
|
|
1054
|
+
return ""
|
|
1055
|
+
|
|
1056
|
+
def condition_set_ill_policy(
|
|
1057
|
+
self, legacy_id, value, parameter, marc_field: field.Field
|
|
1058
|
+
):
|
|
1059
|
+
"""
|
|
1060
|
+
This method maps the ILL policy based on the 008 field.
|
|
1061
|
+
This condition is not available in FOLIO's MARC mapping engine and
|
|
1062
|
+
will require use of a supplemental mapping rules file in the
|
|
1063
|
+
HoldingsMarcTransformer task definition."""
|
|
1064
|
+
if len(value) < 21:
|
|
1065
|
+
self.mapper.migration_report.add(
|
|
1066
|
+
"ILLPolicyMapping", i18n.t("008 is too short") + f": {value}"
|
|
1067
|
+
)
|
|
1068
|
+
return ""
|
|
1069
|
+
try:
|
|
1070
|
+
ill_policies = {
|
|
1071
|
+
"a": "Will lend",
|
|
1072
|
+
"b": "Will not lend",
|
|
1073
|
+
"c": "Will lend hard copy only",
|
|
1074
|
+
"l": "Limited lending policy",
|
|
1075
|
+
"u": "Unknown",
|
|
1076
|
+
}
|
|
1077
|
+
mapped_value = ill_policies[value[20]]
|
|
1078
|
+
self.mapper.migration_report.add(
|
|
1079
|
+
"ILLPolicyMapping",
|
|
1080
|
+
i18n.t("%{value} mapped to %{mapped_value}", value=value[20], mapped_value=mapped_value),
|
|
1081
|
+
)
|
|
1082
|
+
ill_policy_id = self.get_ref_data_tuple_by_name(
|
|
1083
|
+
self.ill_policies, "ill_policies", mapped_value
|
|
1084
|
+
)
|
|
1085
|
+
return ill_policy_id[0] if ill_policy_id else ""
|
|
1086
|
+
except Exception:
|
|
1087
|
+
self.mapper.migration_report.add(
|
|
1088
|
+
"ILLPolicyMapping", i18n.t("%{value} not found in map.", value=value[20])
|
|
1089
|
+
)
|
|
1090
|
+
return ""
|
|
1091
|
+
|
|
1092
|
+
def condition_set_digitization_policy(
|
|
1093
|
+
self, legacy_id, value, parameter, marc_field: field.Field
|
|
1094
|
+
):
|
|
1095
|
+
"""
|
|
1096
|
+
This method maps the digitization policy based on the 008 field.
|
|
1097
|
+
This condition is not available in FOLIO's MARC mapping engine and
|
|
1098
|
+
will require use of a supplemental mapping rules file in the
|
|
1099
|
+
HoldingsMarcTransformer task definition.
|
|
1100
|
+
"""
|
|
1101
|
+
if len(value) < 22:
|
|
1102
|
+
self.mapper.migration_report.add(
|
|
1103
|
+
"DigitizationPolicyMapping", i18n.t("008 is too short") + f": {value}"
|
|
1104
|
+
)
|
|
1105
|
+
return ""
|
|
1106
|
+
try:
|
|
1107
|
+
digitization_policies = {
|
|
1108
|
+
"a": "Will reproduce",
|
|
1109
|
+
"b": "Will not reproduce",
|
|
1110
|
+
"u": "Unknown",
|
|
1111
|
+
}
|
|
1112
|
+
mapped_value = digitization_policies[value[21]]
|
|
1113
|
+
self.mapper.migration_report.add(
|
|
1114
|
+
"DigitizationPolicyMapping",
|
|
1115
|
+
i18n.t(
|
|
1116
|
+
"%{value} mapped to %{mapped_value}",
|
|
1117
|
+
value=value[21],
|
|
1118
|
+
mapped_value=mapped_value,
|
|
1119
|
+
),
|
|
1120
|
+
)
|
|
1121
|
+
return mapped_value
|
|
1122
|
+
except Exception:
|
|
1123
|
+
self.mapper.migration_report.add(
|
|
1124
|
+
"DigitizationPolicyMapping", i18n.t("%{value} not found in map.", value=value[21])
|
|
1125
|
+
)
|
|
1126
|
+
return ""
|