type => 'string' }
}
);
+
+ __PACKAGE__->register_method(
+ method => 'retrieve_isbn_transform',
+ api_name => "open-ils.supercat.isbn.$type.retrieve",
+ api_level => 1,
+ argc => 1,
+ signature =>
+ { desc => "Returns the \U$type\E representation ".
+ "of the requested bibliographic record",
+ params =>
+ [
+ { name => 'isbn',
+ desc => 'An ISBN',
+ type => 'string' },
+ ],
+ 'return' =>
+ { desc => "The bib record in \U$type\E",
+ type => 'string' }
+ }
+ );
}
}
}
);
-
-
-sub record_holdings {
+sub isbn_holdings {
my $self = shift;
my $client = shift;
- my $bib = shift;
+ my $isbn = shift;
my $_storage = OpenSRF::AppSession->create( 'open-ils.cstore' );
- if (!$holdings_data_cache{status}) {
- $holdings_data_cache{status} = {
- map { ($_->id => $_) } @{ $_storage->request( "open-ils.cstore.direct.config.copy_status.search.atomic", {id => {'<>' => undef}} )->gather(1) }
- };
- $holdings_data_cache{location} = {
- map { ($_->id => $_) } @{ $_storage->request( "open-ils.cstore.direct.asset.copy_location.retrieve.all.atomic", {id => {'<>' => undef}} )->gather(1) }
- };
- $holdings_data_cache{ou} =
- {
- map {
- ($_->id => $_)
- } @{$_storage->request( "open-ils.cstore.direct.actor.org_unit.search.atomic" => { id => { '<>' => undef } } )->gather(1)}
- };
- $holdings_data_cache{statcat} =
- {
- map {
- ($_->id => $_)
- } @{$_storage->request( "open-ils.cstore.direct.asset.stat_cat_entry.search.atomic" => { id => { '<>' => undef } } )->gather(1)}
- };
- }
-
-
- my ($year,$month,$day) = reverse( (localtime)[3,4,5] );
- $year += 1900;
- $month += 1;
-
- my $xml = "<volumes xmlns='http://open-ils.org/spec/holdings/v1'>";
-
- for my $cn ( @{$_storage->request( "open-ils.cstore.direct.asset.call_number.search.atomic" => {record => $bib} )->gather(1)} ) {
- (my $cn_class = $cn->class_name) =~ s/::/-/gso;
- $cn_class =~ s/Fieldmapper-//gso;
- my $cn_tag = sprintf("tag:open-ils.org,$year-\%0.2d-\%0.2d:$cn_class/".$cn->id, $month, $day);
-
- my $cn_lib = $holdings_data_cache{ou}{$cn->owning_lib}->shortname;
-
- my $cn_label = $cn->label;
-
- $xml .= "<volume id='$cn_tag' lib='$cn_lib' label='$cn_label'><copies>";
-
- for my $cp ( @{$_storage->request( "open-ils.cstore.direct.asset.copy.search.atomic" => {call_number => $cn->id} )->gather(1)} ) {
- (my $cp_class = $cn->class_name) =~ s/::/-/gso;
- $cp_class =~ s/Fieldmapper-//gso;
- my $cp_tag = sprintf("tag:open-ils.org,$year-\%0.2d-\%0.2d:$cp_class/".$cp->id, $month, $day);
-
- my $cp_stat = $holdings_data_cache{status}{$cp->status}->name;
-
- my $cp_loc = $holdings_data_cache{location}{$cp->location}->name;
-
- my $cp_lib = $holdings_data_cache{ou}{$cp->circ_lib}->shortname;
-
- my $cp_bc = $cp->barcode;
-
- $xml .= "<copy id='$cp_tag' barcode='$cp_bc'><status>$cp_stat</status><location>$cp_loc</location><circlib>$cp_lib</circlib><notes>";
-
- for my $note ( @{$_storage->request( "open-ils.cstore.direct.asset.copy_note.search.atomic" => {id => $cp->id, pub => "t" })->gather(1)} ) {
- $xml .= sprintf('<note date="%s" title="%s">%s</note>',$note->create_date, escape($note->title), escape($note->value));
- }
-
- $xml .= "</notes><statcats>";
-
- for my $sce ( @{$_storage->request( "open-ils.cstore.direct.asset.stat_cat_entry_copy_map.search.atomic" => { owning_copy => $cp->id })->gather(1)} ) {
- my $sc = $holdings_data_cache{statcat}{$sce->stat_cat_entry};
- $xml .= sprintf('<statcat>%s</statcat>',escape($sc->value));
- }
-
- $xml .= "</statcats></copy>";
- }
-
- $xml .= "</volume>";
- }
+ my $recs = $_storage->request(
+ 'open-ils.cstore.direct.metabib.full_rec.search.atomic',
+ { tag => { like => '02%'}, value => {like => "$isbn\%"}}
+ )->gather(1);
- $xml .= "</volumes>";
+ return undef unless (@$recs);
- return $xml;
+ return ($self->method_lookup( 'open-ils.supercat.record.holdings_xml.retrieve')->run( $recs->[0]->record ))[0];
}
+__PACKAGE__->register_method(
+ method => 'isbn_holdings',
+ api_name => 'open-ils.supercat.isbn.holdings_xml.retrieve',
+ api_level => 1,
+ argc => 1,
+ signature =>
+ { desc => <<" DESC",
+Returns the XML representation of the requested bibliographic record's holdings
+ DESC
+ params =>
+ [
+ { name => 'isbn',
+ desc => 'An isbn',
+ type => 'string' },
+ ],
+ 'return' =>
+ { desc => 'The bib record holdings hierarchy in XML',
+ type => 'string' }
+ }
+);
sub escape {
my $text = shift;
}
);
+sub retrieve_isbn_marcxml {
+ my $self = shift;
+ my $client = shift;
+ my $isbn = shift;
+
+ my $_storage = OpenSRF::AppSession->create( 'open-ils.cstore' );
+
+ my $recs = $_storage->request(
+ 'open-ils.cstore.direct.metabib.full_rec.search.atomic',
+ { tag => { like => '02%'}, value => {like => "$isbn\%"}}
+ )->gather(1);
+
+ return undef unless (@$recs);
+
+ my $record = $_storage->request( 'open-ils.cstore.direct.biblio.record_entry.retrieve' => $recs->[0]->record )->gather(1);
+ return entityize( $record->marc ) if ($record);
+ return undef;
+}
+
+__PACKAGE__->register_method(
+ method => 'retrieve_isbn_marcxml',
+ api_name => 'open-ils.supercat.isbn.marcxml.retrieve',
+ api_level => 1,
+ argc => 1,
+ signature =>
+ { desc => <<" DESC",
+Returns the MARCXML representation of the requested ISBN
+ DESC
+ params =>
+ [
+ { name => 'ISBN',
+ desc => 'An ... um ... ISBN',
+ type => 'string' },
+ ],
+ 'return' =>
+ { desc => 'The bib record in MARCXML',
+ type => 'string' }
+ }
+);
+
sub retrieve_record_transform {
my $self = shift;
my $client = shift;
return entityize($record_xslt{$transform}{xslt}->transform( $_parser->parse_string( $record->marc ) )->toString);
}
+sub retrieve_isbn_transform {
+ my $self = shift;
+ my $client = shift;
+ my $isbn = shift;
+
+ my $_storage = OpenSRF::AppSession->create( 'open-ils.cstore' );
+
+ my $recs = $_storage->request(
+ 'open-ils.cstore.direct.metabib.full_rec.search.atomic',
+ { tag => { like => '02%'}, value => {like => "$isbn\%"}}
+ )->gather(1);
+
+ return undef unless (@$recs);
+
+ (my $transform = $self->api_name) =~ s/^.+isbn\.([^\.]+)\.retrieve$/$1/o;
+
+ my $record = $_storage->request( 'open-ils.cstore.direct.biblio.record_entry.retrieve' => $recs->[0]->record )->gather(1);
+
+ return undef unless ($record);
+
+ return entityize($record_xslt{$transform}{xslt}->transform( $_parser->parse_string( $record->marc ) )->toString);
+}
+
sub retrieve_record_objects {
my $self = shift;
my $client = shift;
type => 'array' }
}
);
+__PACKAGE__->register_method(
+ method => 'list_record_formats',
+ api_name => 'open-ils.supercat.isbn.formats',
+ api_level => 1,
+ argc => 0,
+ signature =>
+ { desc => <<" DESC",
+Returns the list of valid record formats that supercat understands.
+ DESC
+ 'return' =>
+ { desc => 'The format list',
+ type => 'array' }
+ }
+);
sub oISBN {
if (!$format) {
my $body = "Content-type: application/xml; charset=utf-8\n\n";
- if ($uri =~ m{^tag:[^:]+:([^\/]+)/(\d+)}o) {
+ if ($uri =~ m{^tag:[^:]+:([^\/]+)/([^/]+)(?:/(.+))$}o) {
$id = $2;
$lib = $3;
$type = 'record';
->request("open-ils.supercat.$type.formats")
->gather(1);
- if ($type eq 'record') {
+ if ($type eq 'record' or $type eq 'isbn') {
$body .= <<" FORMATS";
<formats id='$uri'>
<format name='opac' type='text/html'/>
return Apache2::Const::OK;
}
- if ($uri =~ m{^tag:[^:]+:([^\/]+)/(\d+)(?:/(.+))?}o) {
+ if ($uri =~ m{^tag:[^:]+:([^\/]+)/([^/]+)(?:/(.+))?}o) {
$id = $2;
$lib = $3;
$type = 'record';
- $type = 'metarecord' if ($1 =~ /^m/o);
+ $type = 'metarecord' if ($1 =~ /^metabib/o);
+ $type = 'isbn' if ($1 =~ /^isbn/o);
$command = 'retrieve';
}
return 302;
} elsif (OpenILS::WWW::SuperCat::Feed->exists($base_format)) {
my $feed = create_record_feed(
+ $type,
$format => [ $id ],
$base,
$lib,
<type>text/html</type>
</format>";
- if ($1 eq 'record') {
+ if ($1 eq 'record' or $1 eq 'isbn') {
print "<format>
<name>htmlholdings</name>
<type>text/html</type>
return 302;
} elsif (OpenILS::WWW::SuperCat::Feed->exists($base_format)) {
my $feed = create_record_feed(
+ $type,
$format => [ $id ],
undef, undef,
$flesh_feed
}
my $feed = create_record_feed(
+ 'record',
$type,
[ map { $_->target_biblio_record_entry } @{ $bucket->items } ],
$unapi,
my $list = $supercat->request("open-ils.supercat.$rtype.record.$axis.recent", $date, $limit)->gather(1);
- if ($type eq 'opac') {
- print "Location: $root/../../en-US/skin/default/xml/rresult.xml?rt=list&" .
- join('&', map { "rl=" . $_ } @$list) .
- "\n\n";
- return 302;
- }
+ #if ($type eq 'opac') {
+ # print "Location: $root/../../en-US/skin/default/xml/rresult.xml?rt=list&" .
+ # join('&', map { "rl=" . $_ } @$list) .
+ # "\n\n";
+ # return 302;
+ #}
- my $feed = create_record_feed( $type, $list, $unapi, undef, $flesh_feed);
+ my $feed = create_record_feed( 'record', $type, $list, $unapi, undef, $flesh_feed);
$feed->root($root);
if ($date) {
}
my $feed = create_record_feed(
+ 'record',
$type,
[ map { $_->[0] } @{$recs->{ids}}[$offset .. $offset + $limit - 1] ],
$unapi,
}
sub create_record_feed {
+ my $search = shift;
my $type = shift;
my $records = shift;
my $unapi = shift;
my $rec = $record;
my $item_tag = "tag:$host,$year:biblio-record_entry/$rec/$lib";
+ $item_tag = "tag:$host,$year:isbn/$rec/$lib" if ($search eq 'isbn');
my $xml = $supercat->request(
- "open-ils.supercat.record.$type.retrieve",
+ "open-ils.supercat.$search.$type.retrieve",
$rec
)->gather(1);
next unless $xml;
next unless $node;
if ($lib && $type eq 'marcxml' && $flesh) {
- $xml = $supercat->request( "open-ils.supercat.record.holdings_xml.retrieve", $rec, $lib )->gather(1);
+ $xml = $supercat->request( "open-ils.supercat.$search.holdings_xml.retrieve", $rec, $lib )->gather(1);
$node->add_holdings($xml);
}