- $db->save_ds(
- id => $mfn,
- ds => $ds,
- prefix => $input->{name},
- ) if ($ds && !$stats);
-
- $indexer->add(
- id => $input->{name} . "/" . $mfn,
- ds => $ds,
- type => $config->{$use_indexer}->{type},
- ) if ($indexer && $ds);
-
- if ($marc_fh) {
- my $marc = new MARC::Record;
- $marc->encoding( 'utf-8' );
- $marc->add_fields( WebPAC::Normalize::_get_marc_fields() );
- print $marc_fh $marc->as_usmarc;
+ my $ds = WebPAC::Normalize::data_structure(
+ row => $row,
+ rules => $rules,
+ lookup => $lookup_hash,
+ config => create_ds_config( $db_config, $database, $input, $mfn ),
+ marc_encoding => 'utf-8',
+ load_row_coderef => sub {
+ my ($database,$input,$mfn) = @_;
+ return $store->load_row(
+ database => $database,
+ input => $input,
+ id => $mfn,
+ );
+ },
+ );
+
+ $log->debug("ds = ", sub { dump($ds) }) if ($ds);
+
+ $store->save_ds(
+ database => $database,
+ input => $input_name,
+ id => $mfn,
+ ds => $ds,
+ ) if ($ds && !$stats);
+
+ $indexer->add(
+ id => "${input_name}/${mfn}",
+ ds => $ds,
+ type => $config->get($indexer_config)->{type},
+ ) if ($indexer && $ds);
+
+ if ($marc) {
+ my $i = 0;
+
+ while (my $fields = WebPAC::Normalize::_get_marc_fields( fetch_next => 1 ) ) {
+ $marc->add(
+ id => $mfn . ( $i ? "/$i" : '' ),
+ fields => $fields,
+ leader => WebPAC::Normalize::_get_marc_leader(),
+ row => $row,
+ );
+ $i++;