sub load_record {
my $self = shift;
my $ctx = $self->ctx;
- $ctx->{page} = 'record';
+ $ctx->{page} = 'record';
+ #load metabib_field variables
+ $self->fetch_metabib_field_xpath_and_label;
my $org = $self->cgi->param('loc') || $ctx->{aou_tree}->()->id;
my $depth = $self->cgi->param('depth') || 0;
my $cgi = $self->cgi;
my $ctx = $self->ctx;
my $e = $self->editor;
+
+ #load metabib_field variables
+ $self->fetch_metabib_field_xpath_and_label;
$ctx->{page} = 'rresult' unless $internal;
$ctx->{ids} = [];
return $marc_xml;
}
+#Not sure if Util.pm is the place for this. However since Search.pm
+#and Record.pm need to use fetch_metabib_field_xpath_and_label
+#I decided to put it in Util.pm
+sub fetch_metabib_field_xpath_and_label {
+ my $self = shift;
+ my $ctx = $self->ctx;
+ $ctx->{metabib_field_xpath} = [];
+ my $_storage = OpenSRF::AppSession->create( 'open-ils.cstore' );
+ my $xpath = $_storage->request(
+ 'open-ils.cstore.direct.config.metabib_field.search.atomic',
+ {'display_field' => 'true'}
+ )->gather(1);
+
+ #push the xpath and label data into $ctx
+ foreach my $row (@$xpath) {
+ #I could not figure out how to push hashes onto the $ctx->{metabib_field_xpath} variable,
+ #so to get this working I made $ctx->{metabib_field_xpath} and array and pushed
+ #the metabib_field data onto it
+ push(@{$ctx->{metabib_field_xpath}}, { xpath => $row->xpath , label => $row->label });
+ }
+}
+
1;
--- /dev/null
+ALTER TABLE config.metabib_field ADD COLUMN display_field BOOL NOT NULL DEFAULT TRUE;
BLOCK get_marc_attrs;
xml = args.marc_xml;
args.isbns = [];
- FOR isbn IN xml.findnodes('//*[@tag="020"]/*[@code="a"]');
+ #ideally these variables would be available as
+ #ctx.metabib_field_xpath.identifier.isbn.
+ #I could not get ctx to work like this, so I
+ #have turned it into an array, and here
+ #I am looping over the array until I find ISBN
+ #as the label. This loop to find ISBN is only
+ #a proof of concept to show that the database
+ #values can be used inisde misc_utils. Ideally
+ #there would be no loop and each findnode
+ #could reference ctx.metabib_field_xpath.identifer.*
+ #or whatever keys are appropriate to retrieve the
+ #needed xpath
+ FOREACH xpath_and_label IN ctx.metabib_field_xpath;
+ IF xpath_and_label.label == 'ISBN';
+ isbn_xpath = xpath_and_label.xpath;
+ isbn_xpath = isbn_xpath.replace('marc:([a-z]*)', '*[local-name()="$1"]');
+ END;
+ END;
+
+ FOR isbn IN xml.findnodes(isbn_xpath);
args.isbns.push(isbn.textContent);
END;
args.upcs = [];