);
# if any items have no call_number label and a value should be
- # applied automatically (via org settings), keep a record-level
- # copy handy so we can use the same call number for all such copies
- my $auto_callnumber;
+ # applied automatically (via org settings), we want to use the same
+ # call number label for every copy per org per record.
+ my $auto_callnumber = {};
for my $item_id (@$item_ids) {
my $e = new_editor(requestor => $requestor, xact => 1);
# appply defaults values from org settings as needed
# if $auto_callnumber is unset, it will be set within
- apply_import_item_defaults($e, $item, \$auto_callnumber);
+ apply_import_item_defaults($e, $item, $auto_callnumber);
if($evt) {
$$report_args{evt} = $evt;
}
sub apply_import_item_defaults {
- my ($e, $item, $auto_cn_ref) = @_;
+ my ($e, $item, $auto_cn) = @_;
my $org = $item->owning_lib || $item->circ_lib;
my %c = %item_defaults_cache;
if ($set->('call_number.auto')) {
- if (!$$auto_cn_ref) {
+ if (!$auto_cn->{$org}) {
my $pfx = $set->('call_number.prefix') || 'VAN';
# use the ID of the first item to differentiate this
# call number from others linked to the same record
- $$auto_cn_ref = $pfx . $item->record . $item->id;
+ $auto_cn->{$org} = $pfx . $item->record . $item->id;
}
- $logger->info("vl: using auto call number $$auto_cn_ref");
- $item->call_number($$auto_cn_ref);
+ $logger->info("vl: using auto call number ".$auto_cn->{$org});
+ $item->call_number($auto_cn->{$org});
} else {
$logger->error("vl: no call number or default for item ".$item->id);
'vandelay.item.circ_modifier.default',
attr_set.owning_lib
);
+
+ -- make sure the value from the org setting is still valid
+ PERFORM 1 FROM config.circ_modifier WHERE code = attr_set.circ_modifier;
+ IF NOT FOUND THEN
+ attr_set.import_error := 'import.item.invalid.circ_modifier';
+ attr_set.error_detail := tmp_attr_set.circ_mod;
+ RETURN NEXT attr_set; CONTINUE;
+ END IF;
+
ELSE
SELECT code INTO attr_set.circ_modifier FROM config.circ_modifier WHERE code = tmp_attr_set.circ_mod;
'vandelay.item.copy_location.default',
attr_set.owning_lib
);
+
+ -- make sure the value from the org setting is still valid
+ PERFORM 1 FROM asset.copy_location WHERE id = attr_set.location;
+ IF NOT FOUND THEN
+ attr_set.import_error := 'import.item.invalid.location';
+ attr_set.error_detail := tmp_attr_set.cs;
+ RETURN NEXT attr_set; CONTINUE;
+ END IF;
ELSE
-- search up the org unit tree for a matching copy location
+
CREATE OR REPLACE FUNCTION vandelay.ingest_bib_items ( ) RETURNS TRIGGER AS $func$
DECLARE
attr_def BIGINT;
'vandelay.item.circ_modifier.default',
attr_set.owning_lib
);
+
+ -- make sure the value from the org setting is still valid
+ PERFORM 1 FROM config.circ_modifier WHERE code = attr_set.circ_modifier;
+ IF NOT FOUND THEN
+ attr_set.import_error := 'import.item.invalid.circ_modifier';
+ attr_set.error_detail := tmp_attr_set.circ_mod;
+ RETURN NEXT attr_set; CONTINUE;
+ END IF;
+
ELSE
SELECT code INTO attr_set.circ_modifier FROM config.circ_modifier WHERE code = tmp_attr_set.circ_mod;
'vandelay.item.copy_location.default',
attr_set.owning_lib
);
+
+ -- make sure the value from the org setting is still valid
+ PERFORM 1 FROM asset.copy_location WHERE id = attr_set.location;
+ IF NOT FOUND THEN
+ attr_set.import_error := 'import.item.invalid.location';
+ attr_set.error_detail := tmp_attr_set.cs;
+ RETURN NEXT attr_set; CONTINUE;
+ END IF;
ELSE
-- search up the org unit tree for a matching copy location