1 # We'll be working with XML, so...
4 use Unicode::Normalize;
6 # ... and this has some handy common methods
7 use OpenILS::Application::AppUtils;
9 my $parser = new XML::LibXML;
10 my $U = 'OpenILS::Application::AppUtils';
13 package OpenILS::Application::SuperCat;
18 # All OpenSRF applications must be based on OpenSRF::Application or
19 # a subclass thereof. Makes sense, eh?
20 use OpenILS::Application;
21 use base qw/OpenILS::Application/;
23 # This is the client class, used for connecting to open-ils.storage
24 use OpenSRF::AppSession;
26 # This is an extention of Error.pm that supplies some error types to throw
27 use OpenSRF::EX qw(:try);
29 # This is a helper class for querying the OpenSRF Settings application ...
30 use OpenSRF::Utils::SettingsClient;
32 # ... and here we have the built in logging helper ...
33 use OpenSRF::Utils::Logger qw($logger);
35 # ... and this is our OpenILS object (en|de)coder and psuedo-ORM package.
36 use OpenILS::Utils::Fieldmapper;
47 # we need an XML parser
48 $_parser = new XML::LibXML;
51 $_xslt = new XML::LibXSLT;
53 # parse the MODS xslt ...
54 my $mods33_xslt = $_parser->parse_file(
55 OpenSRF::Utils::SettingsClient
57 ->config_value( dirs => 'xsl' ).
58 "/MARC21slim2MODS33.xsl"
60 # and stash a transformer
61 $record_xslt{mods33}{xslt} = $_xslt->parse_stylesheet( $mods33_xslt );
62 $record_xslt{mods33}{namespace_uri} = 'http://www.loc.gov/mods/v3';
63 $record_xslt{mods33}{docs} = 'http://www.loc.gov/mods/';
64 $record_xslt{mods33}{schema_location} = 'http://www.loc.gov/standards/mods/v3/mods-3-3.xsd';
66 # parse the MODS xslt ...
67 my $mods32_xslt = $_parser->parse_file(
68 OpenSRF::Utils::SettingsClient
70 ->config_value( dirs => 'xsl' ).
71 "/MARC21slim2MODS32.xsl"
73 # and stash a transformer
74 $record_xslt{mods32}{xslt} = $_xslt->parse_stylesheet( $mods32_xslt );
75 $record_xslt{mods32}{namespace_uri} = 'http://www.loc.gov/mods/v3';
76 $record_xslt{mods32}{docs} = 'http://www.loc.gov/mods/';
77 $record_xslt{mods32}{schema_location} = 'http://www.loc.gov/standards/mods/v3/mods-3-2.xsd';
79 # parse the MODS xslt ...
80 my $mods3_xslt = $_parser->parse_file(
81 OpenSRF::Utils::SettingsClient
83 ->config_value( dirs => 'xsl' ).
84 "/MARC21slim2MODS3.xsl"
86 # and stash a transformer
87 $record_xslt{mods3}{xslt} = $_xslt->parse_stylesheet( $mods3_xslt );
88 $record_xslt{mods3}{namespace_uri} = 'http://www.loc.gov/mods/v3';
89 $record_xslt{mods3}{docs} = 'http://www.loc.gov/mods/';
90 $record_xslt{mods3}{schema_location} = 'http://www.loc.gov/standards/mods/v3/mods-3-1.xsd';
92 # parse the MODS xslt ...
93 my $mods_xslt = $_parser->parse_file(
94 OpenSRF::Utils::SettingsClient
96 ->config_value( dirs => 'xsl' ).
97 "/MARC21slim2MODS.xsl"
99 # and stash a transformer
100 $record_xslt{mods}{xslt} = $_xslt->parse_stylesheet( $mods_xslt );
101 $record_xslt{mods}{namespace_uri} = 'http://www.loc.gov/mods/';
102 $record_xslt{mods}{docs} = 'http://www.loc.gov/mods/';
103 $record_xslt{mods}{schema_location} = 'http://www.loc.gov/standards/mods/mods.xsd';
105 # parse the ATOM entry xslt ...
106 my $atom_xslt = $_parser->parse_file(
107 OpenSRF::Utils::SettingsClient
109 ->config_value( dirs => 'xsl' ).
110 "/MARC21slim2ATOM.xsl"
112 # and stash a transformer
113 $record_xslt{atom}{xslt} = $_xslt->parse_stylesheet( $atom_xslt );
114 $record_xslt{atom}{namespace_uri} = 'http://www.w3.org/2005/Atom';
115 $record_xslt{atom}{docs} = 'http://www.ietf.org/rfc/rfc4287.txt';
117 # parse the RDFDC xslt ...
118 my $rdf_dc_xslt = $_parser->parse_file(
119 OpenSRF::Utils::SettingsClient
121 ->config_value( dirs => 'xsl' ).
122 "/MARC21slim2RDFDC.xsl"
124 # and stash a transformer
125 $record_xslt{rdf_dc}{xslt} = $_xslt->parse_stylesheet( $rdf_dc_xslt );
126 $record_xslt{rdf_dc}{namespace_uri} = 'http://purl.org/dc/elements/1.1/';
127 $record_xslt{rdf_dc}{schema_location} = 'http://purl.org/dc/elements/1.1/';
129 # parse the SRWDC xslt ...
130 my $srw_dc_xslt = $_parser->parse_file(
131 OpenSRF::Utils::SettingsClient
133 ->config_value( dirs => 'xsl' ).
134 "/MARC21slim2SRWDC.xsl"
136 # and stash a transformer
137 $record_xslt{srw_dc}{xslt} = $_xslt->parse_stylesheet( $srw_dc_xslt );
138 $record_xslt{srw_dc}{namespace_uri} = 'info:srw/schema/1/dc-schema';
139 $record_xslt{srw_dc}{schema_location} = 'http://www.loc.gov/z3950/agency/zing/srw/dc-schema.xsd';
141 # parse the OAIDC xslt ...
142 my $oai_dc_xslt = $_parser->parse_file(
143 OpenSRF::Utils::SettingsClient
145 ->config_value( dirs => 'xsl' ).
146 "/MARC21slim2OAIDC.xsl"
148 # and stash a transformer
149 $record_xslt{oai_dc}{xslt} = $_xslt->parse_stylesheet( $oai_dc_xslt );
150 $record_xslt{oai_dc}{namespace_uri} = 'http://www.openarchives.org/OAI/2.0/oai_dc/';
151 $record_xslt{oai_dc}{schema_location} = 'http://www.openarchives.org/OAI/2.0/oai_dc.xsd';
153 # parse the RSS xslt ...
154 my $rss_xslt = $_parser->parse_file(
155 OpenSRF::Utils::SettingsClient
157 ->config_value( dirs => 'xsl' ).
158 "/MARC21slim2RSS2.xsl"
160 # and stash a transformer
161 $record_xslt{rss2}{xslt} = $_xslt->parse_stylesheet( $rss_xslt );
163 # parse the FGDC xslt ...
164 my $fgdc_xslt = $_parser->parse_file(
165 OpenSRF::Utils::SettingsClient
167 ->config_value( dirs => 'xsl' ).
168 "/MARC21slim2FGDC.xsl"
170 # and stash a transformer
171 $record_xslt{fgdc}{xslt} = $_xslt->parse_stylesheet( $fgdc_xslt );
172 $record_xslt{fgdc}{docs} = 'http://www.fgdc.gov/metadata/csdgm/index_html';
173 $record_xslt{fgdc}{schema_location} = 'http://www.fgdc.gov/metadata/fgdc-std-001-1998.xsd';
175 register_record_transforms();
180 sub register_record_transforms {
181 for my $type ( keys %record_xslt ) {
182 __PACKAGE__->register_method(
183 method => 'retrieve_record_transform',
184 api_name => "open-ils.supercat.record.$type.retrieve",
188 { desc => "Returns the \U$type\E representation ".
189 "of the requested bibliographic record",
193 desc => 'An OpenILS biblio::record_entry id',
197 { desc => "The bib record in \U$type\E",
202 __PACKAGE__->register_method(
203 method => 'retrieve_isbn_transform',
204 api_name => "open-ils.supercat.isbn.$type.retrieve",
208 { desc => "Returns the \U$type\E representation ".
209 "of the requested bibliographic record",
217 { desc => "The bib record in \U$type\E",
229 return unless ($tree && ref($tree->$field));
231 my @things = $filter->($tree);
232 for my $v ( @{$tree->$field} ){
233 push @things, $filter->($v);
234 push @things, tree_walker($v, $field, $filter);
245 my $page_size = shift || 9;
246 my $page = shift || 0;
248 my ($before_limit,$after_limit) = (0,0);
249 my ($before_offset,$after_offset) = (0,0);
252 $before_limit = $after_limit = int($page_size / 2);
253 $after_limit += 1 if ($page_size % 2);
255 $before_offset = $after_offset = int($page_size / 2);
256 $before_offset += 1 if ($page_size % 2);
257 $before_limit = $after_limit = $page_size;
260 my $_storage = OpenSRF::AppSession->create( 'open-ils.cstore' );
262 my $o_search = { shortname => $ou };
263 if (!$ou || $ou eq '-') {
264 $o_search = { parent_ou => undef };
267 my $orgs = $_storage->request(
268 "open-ils.cstore.direct.actor.org_unit.search",
271 flesh_fields => { aou => [qw/children/] }
275 my @ou_ids = tree_walker($orgs, 'children', sub {shift->id}) if $orgs;
277 $logger->debug("Searching for CNs at orgs [".join(',',@ou_ids)."], based on $ou");
282 my $before = $_storage->request(
283 "open-ils.cstore.direct.asset.call_number.search.atomic",
284 { label => { "<" => { transform => "upper", value => ["upper", $label] } },
285 owning_lib => \@ou_ids,
289 flesh_fields => { acn => [qw/record owning_lib/] },
290 order_by => { acn => "upper(label) desc, id desc, owning_lib desc" },
291 limit => $before_limit,
292 offset => abs($page) * $page_size - $before_offset,
295 push @list, reverse(@$before);
299 my $after = $_storage->request(
300 "open-ils.cstore.direct.asset.call_number.search.atomic",
301 { label => { ">=" => { transform => "upper", value => ["upper", $label] } },
302 owning_lib => \@ou_ids,
306 flesh_fields => { acn => [qw/record owning_lib/] },
307 order_by => { acn => "upper(label), id, owning_lib" },
308 limit => $after_limit,
309 offset => abs($page) * $page_size - $after_offset,
317 __PACKAGE__->register_method(
318 method => 'cn_browse',
319 api_name => 'open-ils.supercat.call_number.browse',
324 Returns the XML representation of the requested bibliographic record's holdings
329 desc => 'The target call number lable',
331 { name => 'org_unit',
332 desc => 'The org unit shortname (or "-" or undef for global) to browse',
334 { name => 'page_size',
335 desc => 'Count of call numbers to retrieve, default is 9',
338 desc => 'The page of call numbers to retrieve, calculated based on page_size. Can be positive, negative or 0.',
342 { desc => 'Call numbers with owning_lib and record fleshed',
348 sub new_books_by_item {
353 my $page_size = shift || 10;
354 my $page = shift || 1;
356 my $offset = $page_size * ($page - 1);
358 my $_storage = OpenSRF::AppSession->create( 'open-ils.cstore' );
361 if ($ou && $ou ne '-') {
362 my $orgs = $_storage->request(
363 "open-ils.cstore.direct.actor.org_unit.search",
364 { shortname => $ou },
366 flesh_fields => { aou => [qw/children/] }
369 @ou_ids = tree_walker($orgs, 'children', sub {shift->id}) if $orgs;
372 $logger->debug("Searching for records with new copies at orgs [".join(',',@ou_ids)."], based on $ou");
373 my $cns = $_storage->request(
374 "open-ils.cstore.json_query.atomic",
375 { select => { acn => ['record'],
376 acp => [{ aggregate => 1 => transform => max => column => create_date => alias => 'create_date'}]
378 from => { 'acn' => { 'acp' => { field => call_number => fkey => 'id' } } },
380 { '+acp' => { deleted => 'f', (@ou_ids) ? ( circ_lib => \@ou_ids) : () },
381 '+acn' => { record => { '>' => 0 } },
383 order_by => { acp => { create_date => { transform => 'max', direction => 'desc' } } },
389 return [ map { $_->{record} } @$cns ];
391 __PACKAGE__->register_method(
392 method => 'new_books_by_item',
393 api_name => 'open-ils.supercat.new_book_list',
398 Returns the XML representation of the requested bibliographic record's holdings
402 { name => 'org_unit',
403 desc => 'The org unit shortname (or "-" or undef for global) to list',
405 { name => 'page_size',
406 desc => 'Count of records to retrieve, default is 10',
409 desc => 'The page of records to retrieve, calculated based on page_size. Starts at 1.',
413 { desc => 'Record IDs',
422 return tag_sf_browse($self, $client, $self->{tag}, $self->{subfield}, @_);
424 __PACKAGE__->register_method(
425 method => 'general_browse',
426 api_name => 'open-ils.supercat.title.browse',
427 tag => 'tnf', subfield => 'a',
431 { desc => "Returns a list of the requested org-scoped record ids held",
433 [ { name => 'value', desc => 'The target title', type => 'string' },
434 { name => 'org_unit', desc => 'The org unit shortname (or "-" or undef for global) to browse', type => 'string' },
435 { name => 'page_size', desc => 'Count of records to retrieve, default is 9', type => 'number' },
436 { name => 'page', desc => 'The page of records retrieve, calculated based on page_size. Can be positive, negative or 0.', type => 'number' }, ],
437 'return' => { desc => 'Record IDs that have copies at the relevant org units', type => 'array' }
440 __PACKAGE__->register_method(
441 method => 'general_browse',
442 api_name => 'open-ils.supercat.author.browse',
443 tag => [qw/100 110 111/], subfield => 'a',
447 { desc => "Returns a list of the requested org-scoped record ids held",
449 [ { name => 'value', desc => 'The target author', type => 'string' },
450 { name => 'org_unit', desc => 'The org unit shortname (or "-" or undef for global) to browse', type => 'string' },
451 { name => 'page_size', desc => 'Count of records to retrieve, default is 9', type => 'number' },
452 { name => 'page', desc => 'The page of records retrieve, calculated based on page_size. Can be positive, negative or 0.', type => 'number' }, ],
453 'return' => { desc => 'Record IDs that have copies at the relevant org units', type => 'array' }
456 __PACKAGE__->register_method(
457 method => 'general_browse',
458 api_name => 'open-ils.supercat.subject.browse',
459 tag => [qw/600 610 611 630 648 650 651 653 655 656 662 690 691 696 697 698 699/], subfield => 'a',
463 { desc => "Returns a list of the requested org-scoped record ids held",
465 [ { name => 'value', desc => 'The target subject', type => 'string' },
466 { name => 'org_unit', desc => 'The org unit shortname (or "-" or undef for global) to browse', type => 'string' },
467 { name => 'page_size', desc => 'Count of records to retrieve, default is 9', type => 'number' },
468 { name => 'page', desc => 'The page of records retrieve, calculated based on page_size. Can be positive, negative or 0.', type => 'number' }, ],
469 'return' => { desc => 'Record IDs that have copies at the relevant org units', type => 'array' }
472 __PACKAGE__->register_method(
473 method => 'general_browse',
474 api_name => 'open-ils.supercat.topic.browse',
475 tag => [qw/650 690/], subfield => 'a',
479 { desc => "Returns a list of the requested org-scoped record ids held",
481 [ { name => 'value', desc => 'The target topical subject', type => 'string' },
482 { name => 'org_unit', desc => 'The org unit shortname (or "-" or undef for global) to browse', type => 'string' },
483 { name => 'page_size', desc => 'Count of records to retrieve, default is 9', type => 'number' },
484 { name => 'page', desc => 'The page of records retrieve, calculated based on page_size. Can be positive, negative or 0.', type => 'number' }, ],
485 'return' => { desc => 'Record IDs that have copies at the relevant org units', type => 'array' }
488 __PACKAGE__->register_method(
489 method => 'general_browse',
490 api_name => 'open-ils.supercat.series.browse',
491 tag => [qw/440 490 800 810 811 830/], subfield => 'a',
495 { desc => "Returns a list of the requested org-scoped record ids held",
497 [ { name => 'value', desc => 'The target series', type => 'string' },
498 { name => 'org_unit', desc => 'The org unit shortname (or "-" or undef for global) to browse', type => 'string' },
499 { name => 'page_size', desc => 'Count of records to retrieve, default is 9', type => 'number' },
500 { name => 'page', desc => 'The page of records retrieve, calculated based on page_size. Can be positive, negative or 0.', type => 'number' }, ],
501 'return' => { desc => 'Record IDs that have copies at the relevant org units', type => 'array' }
511 my $subfield = shift;
514 my $page_size = shift || 9;
515 my $page = shift || 0;
517 my ($before_limit,$after_limit) = (0,0);
518 my ($before_offset,$after_offset) = (0,0);
521 $before_limit = $after_limit = int($page_size / 2);
522 $after_limit += 1 if ($page_size % 2);
524 $before_offset = $after_offset = int($page_size / 2);
525 $before_offset += 1 if ($page_size % 2);
526 $before_limit = $after_limit = $page_size;
529 my $_storage = OpenSRF::AppSession->create( 'open-ils.cstore' );
532 if ($ou && $ou ne '-') {
533 my $orgs = $_storage->request(
534 "open-ils.cstore.direct.actor.org_unit.search",
535 { shortname => $ou },
537 flesh_fields => { aou => [qw/children/] }
540 @ou_ids = tree_walker($orgs, 'children', sub {shift->id}) if $orgs;
543 $logger->debug("Searching for records at orgs [".join(',',@ou_ids)."], based on $ou");
548 my $before = $_storage->request(
549 "open-ils.cstore.json_query.atomic",
550 { select => { mfr => [qw/record value/] },
555 subfield => $subfield,
556 value => { '<' => lc($value) }
560 { select=> { acp => [ 'id' ] },
561 from => { acn => { acp => { field => 'call_number', fkey => 'id' } } },
563 { '+acn' => { record => { '=' => { '+mfr' => 'record' } } },
564 '+acp' => { deleted => 'f', (@ou_ids) ? ( circ_lib => \@ou_ids) : () }
570 { select=> { auri => [ 'id' ] },
571 from => { acn => { auricnm => { field => 'call_number', fkey => 'id', join => { auri => { field => 'id', fkey => 'uri' } } } } },
573 { '+acn' => { record => { '=' => { '+mfr' => 'record' } }, (@ou_ids) ? ( owning_lib => \@ou_ids) : () },
574 '+auri' => { active => 't' }
581 order_by => { mfr => { value => 'desc' } },
582 limit => $before_limit,
583 offset => abs($page) * $page_size - $before_offset,
586 push @list, map { $_->{record} } reverse(@$before);
590 my $after = $_storage->request(
591 "open-ils.cstore.json_query.atomic",
592 { select => { mfr => [qw/record value/] },
597 subfield => $subfield,
598 value => { '>=' => lc($value) }
602 { select=> { acp => [ 'id' ] },
603 from => { acn => { acp => { field => 'call_number', fkey => 'id' } } },
605 { '+acn' => { record => { '=' => { '+mfr' => 'record' } } },
606 '+acp' => { deleted => 'f', (@ou_ids) ? ( circ_lib => \@ou_ids) : () }
612 { select=> { auri => [ 'id' ] },
613 from => { acn => { auricnm => { field => 'call_number', fkey => 'id', join => { auri => { field => 'id', fkey => 'uri' } } } } },
615 { '+acn' => { record => { '=' => { '+mfr' => 'record' } }, (@ou_ids) ? ( owning_lib => \@ou_ids) : () },
616 '+auri' => { active => 't' }
623 order_by => { mfr => { value => 'asc' } },
624 limit => $after_limit,
625 offset => abs($page) * $page_size - $after_offset,
628 push @list, map { $_->{record} } @$after;
633 __PACKAGE__->register_method(
634 method => 'tag_sf_browse',
635 api_name => 'open-ils.supercat.tag.browse',
640 Returns a list of the requested org-scoped record ids held
645 desc => 'The target MARC tag',
647 { name => 'subfield',
648 desc => 'The target MARC subfield',
651 desc => 'The target string',
653 { name => 'org_unit',
654 desc => 'The org unit shortname (or "-" or undef for global) to browse',
656 { name => 'page_size',
657 desc => 'Count of call numbers to retrieve, default is 9',
660 desc => 'The page of call numbers to retrieve, calculated based on page_size. Can be positive, negative or 0.',
664 { desc => 'Record IDs that have copies at the relevant org units',
669 sub holding_data_formats {
672 namespace_uri => 'http://www.loc.gov/MARC21/slim',
673 docs => 'http://www.loc.gov/marcxml/',
674 schema_location => 'http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd',
678 __PACKAGE__->register_method( method => 'holding_data_formats', api_name => 'open-ils.supercat.acn.formats', api_level => 1 );
679 __PACKAGE__->register_method( method => 'holding_data_formats', api_name => 'open-ils.supercat.acp.formats', api_level => 1 );
680 __PACKAGE__->register_method( method => 'holding_data_formats', api_name => 'open-ils.supercat.auri.formats', api_level => 1 );
683 __PACKAGE__->register_method(
684 method => 'retrieve_uri',
685 api_name => 'open-ils.supercat.auri.marcxml.retrieve',
690 Returns a fleshed call number object
695 desc => 'An OpenILS asset::uri id',
699 { desc => 'fleshed uri',
707 my $args = shift || {};
709 return OpenILS::Application::SuperCat::unAPI
710 ->new(OpenSRF::AppSession
711 ->create( 'open-ils.cstore' )
713 "open-ils.cstore.direct.asset.uri.retrieve",
717 auri => [qw/call_number_maps/],
718 auricnm => [qw/call_number/],
719 acn => [qw/owning_lib record/],
726 __PACKAGE__->register_method(
727 method => 'retrieve_copy',
728 api_name => 'open-ils.supercat.acp.marcxml.retrieve',
733 Returns a fleshed call number object
738 desc => 'An OpenILS asset::copy id',
742 { desc => 'fleshed copy',
750 my $args = shift || {};
752 return OpenILS::Application::SuperCat::unAPI
753 ->new(OpenSRF::AppSession
754 ->create( 'open-ils.cstore' )
756 "open-ils.cstore.direct.asset.copy.retrieve",
760 acn => [qw/owning_lib record/],
761 acp => [qw/call_number location status circ_lib stat_cat_entries notes/],
768 __PACKAGE__->register_method(
769 method => 'retrieve_callnumber',
770 api_name => 'open-ils.supercat.acn.marcxml.retrieve',
776 Returns a fleshed call number object
781 desc => 'An OpenILS asset::call_number id',
785 { desc => 'call number with copies',
789 sub retrieve_callnumber {
793 my $args = shift || {};
795 return OpenILS::Application::SuperCat::unAPI
796 ->new(OpenSRF::AppSession
797 ->create( 'open-ils.cstore' )
799 "open-ils.cstore.direct.asset.call_number.retrieve",
803 acn => [qw/owning_lib record copies uri_maps/],
804 auricnm => [qw/uri/],
805 acp => [qw/location status circ_lib stat_cat_entries notes/],
813 __PACKAGE__->register_method(
814 method => 'basic_record_holdings',
815 api_name => 'open-ils.supercat.record.basic_holdings.retrieve',
821 Returns a basic hash representation of the requested bibliographic record's holdings
826 desc => 'An OpenILS biblio::record_entry id',
830 { desc => 'Hash of bib record holdings hierarchy (call numbers and copies)',
834 sub basic_record_holdings {
840 # holdings hold an array of call numbers, which hold an array of copies
841 # holdings => [ label: { library, [ copies: { barcode, location, status, circ_lib } ] } ]
844 my $_storage = OpenSRF::AppSession->create( 'open-ils.cstore' );
846 my $tree = $_storage->request(
847 "open-ils.cstore.direct.biblio.record_entry.retrieve",
851 bre => [qw/call_numbers/],
852 acn => [qw/copies owning_lib/],
853 acp => [qw/location status circ_lib/],
858 my $o_search = { shortname => uc($ou) };
859 if (!$ou || $ou eq '-') {
860 $o_search = { parent_ou => undef };
863 my $orgs = $_storage->request(
864 "open-ils.cstore.direct.actor.org_unit.search",
867 flesh_fields => { aou => [qw/children/] }
871 my @ou_ids = tree_walker($orgs, 'children', sub {shift->id}) if $orgs;
873 $logger->debug("Searching for holdings at orgs [".join(',',@ou_ids)."], based on $ou");
875 for my $cn (@{$tree->call_numbers}) {
876 next unless ( $cn->deleted eq 'f' || $cn->deleted == 0 );
879 for my $c (@{$cn->copies}) {
880 next unless grep {$c->circ_lib->id == $_} @ou_ids;
881 next unless ( $c->deleted eq 'f' || $c->deleted == 0 );
887 $holdings{$cn->label}{'owning_lib'} = $cn->owning_lib->shortname;
889 for my $cp (@{$cn->copies}) {
891 next unless grep { $cp->circ_lib->id == $_ } @ou_ids;
892 next unless ( $cp->deleted eq 'f' || $cp->deleted == 0 );
894 push @{$holdings{$cn->label}{'copies'}}, {
895 barcode => $cp->barcode,
896 status => $cp->status->name,
897 location => $cp->location->name,
898 circlib => $cp->circ_lib->shortname
907 #__PACKAGE__->register_method(
908 # method => 'new_record_holdings',
909 # api_name => 'open-ils.supercat.record.holdings_xml.retrieve',
914 # { desc => <<" DESC",
915 #Returns the XML representation of the requested bibliographic record's holdings
920 # desc => 'An OpenILS biblio::record_entry id',
921 # type => 'number' },
924 # { desc => 'Stream of bib record holdings hierarchy in XML',
930 sub new_record_holdings {
938 $paging = [-1,0] if (!$paging or !ref($paging) or @$paging == 0);
939 my $limit = $$paging[0];
940 my $offset = $$paging[1] || 0;
942 my $_storage = OpenSRF::AppSession->create( 'open-ils.cstore' );
944 my $o_search = { shortname => uc($ou) };
945 if (!$ou || $ou eq '-') {
946 $o_search = { parent_ou => undef };
949 my $orgs = $_storage->request(
950 "open-ils.cstore.direct.actor.org_unit.search",
953 flesh_fields => { aou => [qw/children/] }
957 my @ou_ids = tree_walker($orgs, 'children', sub {shift->id}) if $orgs;
959 $logger->info("Searching for holdings at orgs [".join(',',@ou_ids)."], based on $ou");
961 my %subselect = ( '-or' => [
962 { owning_lib => \@ou_ids },
966 call_number => { '=' => {'+acn'=>'id'} },
974 if ($flesh and $flesh eq 'uris') {
976 owning_lib => \@ou_ids,
978 from => { auricnm => 'auri' },
980 call_number => { '=' => {'+acn'=>'id'} },
981 '+auri' => { active => 't' }
988 my $cns = $_storage->request(
989 "open-ils.cstore.direct.asset.call_number.search.atomic",
996 acn => [qw/copies owning_lib uri_maps/],
997 auricnm => [qw/uri/],
998 acp => [qw/circ_lib location status stat_cat_entries notes/],
999 asce => [qw/stat_cat/],
1001 ( $limit > -1 ? ( limit => $limit ) : () ),
1002 ( $offset ? ( offset => $offset ) : () ),
1003 order_by => { acn => { label => {} } }
1007 my ($year,$month,$day) = reverse( (localtime)[3,4,5] );
1011 $client->respond("<volumes xmlns='http://open-ils.org/spec/holdings/v1'>\n");
1013 for my $cn (@$cns) {
1014 next unless (@{$cn->copies} > 0 or (ref($cn->uri_maps) and @{$cn->uri_maps}));
1016 # We don't want O:A:S:unAPI::acn to return the record, we've got that already
1017 # In the context of BibTemplate, copies aren't necessary because we pull those
1018 # in a separate call
1020 OpenILS::Application::SuperCat::unAPI::acn
1022 ->as_xml( {no_record => 1, no_copies => ($flesh ? 0 : 1)} )
1026 return "</volumes>\n";
1028 __PACKAGE__->register_method(
1029 method => 'new_record_holdings',
1030 api_name => 'open-ils.supercat.record.holdings_xml.retrieve',
1035 { desc => <<" DESC",
1036 Returns the XML representation of the requested bibliographic record's holdings
1041 desc => 'An OpenILS biblio::record_entry ID',
1043 { name => 'orgUnit',
1044 desc => 'An OpenILS actor::org_unit short name that limits the scope of returned holdings',
1046 { name => 'hideCopies',
1047 desc => 'Flag that prevents the inclusion of copies in the returned holdings',
1048 type => 'boolean' },
1050 desc => 'Arry of limit and offset for holdings paging',
1054 { desc => 'Stream of bib record holdings hierarchy in XML',
1064 my $_storage = OpenSRF::AppSession->create( 'open-ils.cstore' );
1066 my $recs = $_storage->request(
1067 'open-ils.cstore.direct.metabib.full_rec.search.atomic',
1068 { tag => { like => '02%'}, value => {like => "$isbn\%"}}
1071 return undef unless (@$recs);
1073 return ($self->method_lookup( 'open-ils.supercat.record.holdings_xml.retrieve')->run( $recs->[0]->record ))[0];
1075 __PACKAGE__->register_method(
1076 method => 'isbn_holdings',
1077 api_name => 'open-ils.supercat.isbn.holdings_xml.retrieve',
1081 { desc => <<" DESC",
1082 Returns the XML representation of the requested bibliographic record's holdings
1091 { desc => 'The bib record holdings hierarchy in XML',
1099 return '' unless $text;
1100 $text =~ s/&/&/gsom;
1101 $text =~ s/</</gsom;
1102 $text =~ s/>/>/gsom;
1103 $text =~ s/"/\\"/gsom;
1107 sub recent_changes {
1110 my $when = shift || '1-01-01';
1113 my $type = 'biblio';
1114 $type = 'authority' if ($self->api_name =~ /authority/o);
1116 my $axis = 'create_date';
1117 $axis = 'edit_date' if ($self->api_name =~ /edit/o);
1119 my $_storage = OpenSRF::AppSession->create( 'open-ils.cstore' );
1121 return $_storage->request(
1122 "open-ils.cstore.direct.$type.record_entry.id_list.atomic",
1123 { $axis => { ">" => $when }, id => { '>' => 0 } },
1124 { order_by => { bre => "$axis desc" }, limit => $limit }
1128 for my $t ( qw/biblio authority/ ) {
1129 for my $a ( qw/import edit/ ) {
1131 __PACKAGE__->register_method(
1132 method => 'recent_changes',
1133 api_name => "open-ils.supercat.$t.record.$a.recent",
1137 { desc => "Returns a list of recently ${a}ed $t records",
1141 desc => "Date to start looking for ${a}ed records",
1142 default => '1-01-01',
1146 desc => "Maximum count to retrieve",
1150 { desc => "An id list of $t records",
1158 sub retrieve_record_marcxml {
1163 my $_storage = OpenSRF::AppSession->create( 'open-ils.cstore' );
1165 my $record = $_storage->request( 'open-ils.cstore.direct.biblio.record_entry.retrieve' => $rid )->gather(1);
1166 return $U->entityize( $record->marc ) if ($record);
1170 __PACKAGE__->register_method(
1171 method => 'retrieve_record_marcxml',
1172 api_name => 'open-ils.supercat.record.marcxml.retrieve',
1176 { desc => <<" DESC",
1177 Returns the MARCXML representation of the requested bibliographic record
1182 desc => 'An OpenILS biblio::record_entry id',
1186 { desc => 'The bib record in MARCXML',
1191 sub retrieve_isbn_marcxml {
1196 my $_storage = OpenSRF::AppSession->create( 'open-ils.cstore' );
1198 my $recs = $_storage->request(
1199 'open-ils.cstore.direct.metabib.full_rec.search.atomic',
1200 { tag => { like => '02%'}, value => {like => "$isbn\%"}}
1203 return undef unless (@$recs);
1205 my $record = $_storage->request( 'open-ils.cstore.direct.biblio.record_entry.retrieve' => $recs->[0]->record )->gather(1);
1206 return $U->entityize( $record->marc ) if ($record);
1210 __PACKAGE__->register_method(
1211 method => 'retrieve_isbn_marcxml',
1212 api_name => 'open-ils.supercat.isbn.marcxml.retrieve',
1216 { desc => <<" DESC",
1217 Returns the MARCXML representation of the requested ISBN
1222 desc => 'An ... um ... ISBN',
1226 { desc => 'The bib record in MARCXML',
1231 sub retrieve_record_transform {
1236 (my $transform = $self->api_name) =~ s/^.+record\.([^\.]+)\.retrieve$/$1/o;
1238 my $_storage = OpenSRF::AppSession->create( 'open-ils.cstore' );
1239 #$_storage->connect;
1241 my $record = $_storage->request(
1242 'open-ils.cstore.direct.biblio.record_entry.retrieve',
1246 return undef unless ($record);
1248 return $U->entityize($record_xslt{$transform}{xslt}->transform( $_parser->parse_string( $record->marc ) )->toString);
1251 sub retrieve_isbn_transform {
1256 my $_storage = OpenSRF::AppSession->create( 'open-ils.cstore' );
1258 my $recs = $_storage->request(
1259 'open-ils.cstore.direct.metabib.full_rec.search.atomic',
1260 { tag => { like => '02%'}, value => {like => "$isbn\%"}}
1263 return undef unless (@$recs);
1265 (my $transform = $self->api_name) =~ s/^.+isbn\.([^\.]+)\.retrieve$/$1/o;
1267 my $record = $_storage->request( 'open-ils.cstore.direct.biblio.record_entry.retrieve' => $recs->[0]->record )->gather(1);
1269 return undef unless ($record);
1271 return $U->entityize($record_xslt{$transform}{xslt}->transform( $_parser->parse_string( $record->marc ) )->toString);
1274 sub retrieve_record_objects {
1279 $ids = [$ids] unless (ref $ids);
1280 $ids = [grep {$_} @$ids];
1282 return [] unless (@$ids);
1284 my $_storage = OpenSRF::AppSession->create( 'open-ils.cstore' );
1285 return $_storage->request('open-ils.cstore.direct.biblio.record_entry.search.atomic' => { id => [grep {$_} @$ids] })->gather(1);
1287 __PACKAGE__->register_method(
1288 method => 'retrieve_record_objects',
1289 api_name => 'open-ils.supercat.record.object.retrieve',
1293 { desc => <<" DESC",
1294 Returns the Fieldmapper object representation of the requested bibliographic records
1299 desc => 'OpenILS biblio::record_entry ids',
1303 { desc => 'The bib records',
1309 sub retrieve_isbn_object {
1314 return undef unless ($isbn);
1316 my $_storage = OpenSRF::AppSession->create( 'open-ils.cstore' );
1317 my $recs = $_storage->request(
1318 'open-ils.cstore.direct.metabib.full_rec.search.atomic',
1319 { tag => { like => '02%'}, value => {like => "$isbn\%"}}
1322 return undef unless (@$recs);
1324 return $_storage->request(
1325 'open-ils.cstore.direct.biblio.record_entry.search.atomic',
1326 { id => $recs->[0]->record }
1329 __PACKAGE__->register_method(
1330 method => 'retrieve_isbn_object',
1331 api_name => 'open-ils.supercat.isbn.object.retrieve',
1335 { desc => <<" DESC",
1336 Returns the Fieldmapper object representation of the requested bibliographic record
1345 { desc => 'The bib record',
1352 sub retrieve_metarecord_mods {
1357 my $_storage = OpenSRF::AppSession->connect( 'open-ils.cstore' );
1359 # Get the metarecord in question
1362 'open-ils.cstore.direct.metabib.metarecord.retrieve' => $rid
1365 # Now get the map of all bib records for the metarecord
1368 'open-ils.cstore.direct.metabib.metarecord_source_map.search.atomic',
1369 {metarecord => $rid}
1372 $logger->debug("Adding ".scalar(@$recs)." bib record to the MODS of the metarecord");
1374 # and retrieve the lead (master) record as MODS
1376 $self ->method_lookup('open-ils.supercat.record.mods.retrieve')
1377 ->run($mr->master_record);
1378 my $master_mods = $_parser->parse_string($master)->documentElement;
1379 $master_mods->setNamespace( "http://www.loc.gov/mods/", "mods", 1 );
1381 # ... and a MODS clone to populate, with guts removed.
1382 my $mods = $_parser->parse_string($master)->documentElement;
1383 $mods->setNamespace( "http://www.loc.gov/mods/", "mods", 1 );
1384 ($mods) = $mods->findnodes('//mods:mods');
1385 $mods->removeChildNodes;
1387 # Add the metarecord ID as a (locally defined) info URI
1388 my $recordInfo = $mods
1390 ->createElement("mods:recordInfo");
1392 my $recordIdentifier = $mods
1394 ->createElement("mods:recordIdentifier");
1396 my ($year,$month,$day) = reverse( (localtime)[3,4,5] );
1401 $recordIdentifier->appendTextNode(
1402 sprintf("tag:open-ils.org,$year-\%0.2d-\%0.2d:metabib-metarecord/$id", $month, $day)
1405 $recordInfo->appendChild($recordIdentifier);
1406 $mods->appendChild($recordInfo);
1408 # Grab the title, author and ISBN for the master record and populate the metarecord
1409 my ($title) = $master_mods->findnodes( './mods:titleInfo[not(@type)]' );
1412 $title->setNamespace( "http://www.loc.gov/mods/", "mods", 1 );
1413 $title = $mods->ownerDocument->importNode($title);
1414 $mods->appendChild($title);
1417 my ($author) = $master_mods->findnodes( './mods:name[mods:role/mods:text[text()="creator"]]' );
1419 $author->setNamespace( "http://www.loc.gov/mods/", "mods", 1 );
1420 $author = $mods->ownerDocument->importNode($author);
1421 $mods->appendChild($author);
1424 my ($isbn) = $master_mods->findnodes( './mods:identifier[@type="isbn"]' );
1426 $isbn->setNamespace( "http://www.loc.gov/mods/", "mods", 1 );
1427 $isbn = $mods->ownerDocument->importNode($isbn);
1428 $mods->appendChild($isbn);
1431 # ... and loop over the constituent records
1432 for my $map ( @$recs ) {
1436 $self ->method_lookup('open-ils.supercat.record.mods.retrieve')
1437 ->run($map->source);
1439 my $part_mods = $_parser->parse_string($rec);
1440 $part_mods->documentElement->setNamespace( "http://www.loc.gov/mods/", "mods", 1 );
1441 ($part_mods) = $part_mods->findnodes('//mods:mods');
1443 for my $node ( ($part_mods->findnodes( './mods:subject' )) ) {
1444 $node->setNamespace( "http://www.loc.gov/mods/", "mods", 1 );
1445 $node = $mods->ownerDocument->importNode($node);
1446 $mods->appendChild( $node );
1449 my $relatedItem = $mods
1451 ->createElement("mods:relatedItem");
1453 $relatedItem->setAttribute( type => 'constituent' );
1455 my $identifier = $mods
1457 ->createElement("mods:identifier");
1459 $identifier->setAttribute( type => 'uri' );
1461 my $subRecordInfo = $mods
1463 ->createElement("mods:recordInfo");
1465 my $subRecordIdentifier = $mods
1467 ->createElement("mods:recordIdentifier");
1469 my $subid = $map->source;
1470 $subRecordIdentifier->appendTextNode(
1471 sprintf("tag:open-ils.org,$year-\%0.2d-\%0.2d:biblio-record_entry/$subid",
1476 $subRecordInfo->appendChild($subRecordIdentifier);
1478 $relatedItem->appendChild( $subRecordInfo );
1480 my ($tor) = $part_mods->findnodes( './mods:typeOfResource' );
1481 $tor->setNamespace( "http://www.loc.gov/mods/", "mods", 1 ) if ($tor);
1482 $tor = $mods->ownerDocument->importNode($tor) if ($tor);
1483 $relatedItem->appendChild($tor) if ($tor);
1485 if ( my ($part_isbn) = $part_mods->findnodes( './mods:identifier[@type="isbn"]' ) ) {
1486 $part_isbn->setNamespace( "http://www.loc.gov/mods/", "mods", 1 );
1487 $part_isbn = $mods->ownerDocument->importNode($part_isbn);
1488 $relatedItem->appendChild( $part_isbn );
1491 $isbn = $mods->appendChild( $part_isbn->cloneNode(1) );
1495 $mods->appendChild( $relatedItem );
1499 $_storage->disconnect;
1501 return $U->entityize($mods->toString);
1504 __PACKAGE__->register_method(
1505 method => 'retrieve_metarecord_mods',
1506 api_name => 'open-ils.supercat.metarecord.mods.retrieve',
1510 { desc => <<" DESC",
1511 Returns the MODS representation of the requested metarecord
1515 { name => 'metarecordId',
1516 desc => 'An OpenILS metabib::metarecord id',
1520 { desc => 'The metarecord in MODS',
1525 sub list_metarecord_formats {
1528 { namespace_uri => 'http://www.loc.gov/mods/',
1529 docs => 'http://www.loc.gov/mods/',
1530 schema_location => 'http://www.loc.gov/standards/mods/mods.xsd',
1535 for my $type ( keys %metarecord_xslt ) {
1538 { namespace_uri => $metarecord_xslt{$type}{namespace_uri},
1539 docs => $metarecord_xslt{$type}{docs},
1540 schema_location => $metarecord_xslt{$type}{schema_location},
1547 __PACKAGE__->register_method(
1548 method => 'list_metarecord_formats',
1549 api_name => 'open-ils.supercat.metarecord.formats',
1553 { desc => <<" DESC",
1554 Returns the list of valid metarecord formats that supercat understands.
1557 { desc => 'The format list',
1563 sub list_record_formats {
1566 { namespace_uri => 'http://www.loc.gov/MARC21/slim',
1567 docs => 'http://www.loc.gov/marcxml/',
1568 schema_location => 'http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd',
1573 for my $type ( keys %record_xslt ) {
1576 { namespace_uri => $record_xslt{$type}{namespace_uri},
1577 docs => $record_xslt{$type}{docs},
1578 schema_location => $record_xslt{$type}{schema_location},
1585 __PACKAGE__->register_method(
1586 method => 'list_record_formats',
1587 api_name => 'open-ils.supercat.record.formats',
1591 { desc => <<" DESC",
1592 Returns the list of valid record formats that supercat understands.
1595 { desc => 'The format list',
1599 __PACKAGE__->register_method(
1600 method => 'list_record_formats',
1601 api_name => 'open-ils.supercat.isbn.formats',
1605 { desc => <<" DESC",
1606 Returns the list of valid record formats that supercat understands.
1609 { desc => 'The format list',
1622 throw OpenSRF::EX::InvalidArg ('I need an ISBN please')
1623 unless (length($isbn) >= 10);
1625 my $_storage = OpenSRF::AppSession->create( 'open-ils.cstore' );
1627 # Create a storage session, since we'll be making muliple requests.
1630 # Find the record that has that ISBN.
1631 my $bibrec = $_storage->request(
1632 'open-ils.cstore.direct.metabib.full_rec.search.atomic',
1633 { tag => '020', subfield => 'a', value => { like => lc($isbn).'%'} }
1636 # Go away if we don't have one.
1637 return {} unless (@$bibrec);
1639 # Find the metarecord for that bib record.
1640 my $mr = $_storage->request(
1641 'open-ils.cstore.direct.metabib.metarecord_source_map.search.atomic',
1642 {source => $bibrec->[0]->record}
1645 # Find the other records for that metarecord.
1646 my $records = $_storage->request(
1647 'open-ils.cstore.direct.metabib.metarecord_source_map.search.atomic',
1648 {metarecord => $mr->[0]->metarecord}
1651 # Just to be safe. There's currently no unique constraint on sources...
1652 my %unique_recs = map { ($_->source, 1) } @$records;
1653 my @rec_list = sort keys %unique_recs;
1655 # And now fetch the ISBNs for thos records.
1659 'open-ils.cstore.direct.metabib.full_rec.search',
1660 { tag => '020', subfield => 'a', record => $_ }
1661 )->gather(1) for (@rec_list);
1663 # We're done with the storage server session.
1664 $_storage->disconnect;
1666 # Return the oISBN data structure. This will be XMLized at a higher layer.
1668 { metarecord => $mr->[0]->metarecord,
1669 record_list => { map { $_ ? ($_->record, $_->value) : () } @$recs } };
1672 __PACKAGE__->register_method(
1674 api_name => 'open-ils.supercat.oisbn',
1678 { desc => <<" DESC",
1679 Returns the ISBN list for the metarecord of the requested isbn
1684 desc => 'An ISBN. Duh.',
1688 { desc => 'record to isbn map',
1693 package OpenILS::Application::SuperCat::unAPI;
1694 use base qw/OpenILS::Application::SuperCat/;
1697 die "dummy superclass, use a real class";
1703 return unless ($obj);
1705 $class = ref($class) || $class;
1707 if ($class eq __PACKAGE__) {
1708 return unless (ref($obj));
1709 $class .= '::' . $obj->json_hint;
1712 return bless { obj => $obj } => $class;
1717 return $self->{obj};
1720 package OpenILS::Application::SuperCat::unAPI::auri;
1721 use base qw/OpenILS::Application::SuperCat::unAPI/;
1727 my $xml = ' <uri xmlns="http://open-ils.org/spec/holdings/v1" ';
1728 $xml .= 'id="tag:open-ils.org:asset-uri/' . $self->obj->id . '" ';
1729 $xml .= 'use_restriction="' . $self->escape( $self->obj->use_restriction ) . '" ';
1730 $xml .= 'label="' . $self->escape( $self->obj->label ) . '" ';
1731 $xml .= 'href="' . $self->escape( $self->obj->href ) . '">';
1733 if (!$args->{no_volumes}) {
1734 if (ref($self->obj->call_number_maps) && @{ $self->obj->call_number_maps }) {
1735 $xml .= " <volumes>\n" . join(
1738 OpenILS::Application::SuperCat::unAPI
1739 ->new( $_->call_number )
1740 ->as_xml({ %$args, no_uris=>1, no_copies=>1 })
1741 } @{ $self->obj->call_number_maps }
1742 ) . " </volumes>\n";
1745 $xml .= " <volumes/>\n";
1749 $xml .= " </uri>\n";
1754 package OpenILS::Application::SuperCat::unAPI::acn;
1755 use base qw/OpenILS::Application::SuperCat::unAPI/;
1761 my $xml = ' <volume xmlns="http://open-ils.org/spec/holdings/v1" ';
1763 $xml .= 'id="tag:open-ils.org:asset-call_number/' . $self->obj->id . '" ';
1764 $xml .= 'lib="' . $self->escape( $self->obj->owning_lib->shortname ) . '" ';
1765 $xml .= 'label="' . $self->escape( $self->obj->label ) . '">';
1768 if (!$args->{no_copies}) {
1769 if (ref($self->obj->copies) && @{ $self->obj->copies }) {
1770 $xml .= " <copies>\n" . join(
1773 OpenILS::Application::SuperCat::unAPI
1775 ->as_xml({ %$args, no_volume=>1 })
1776 } @{ $self->obj->copies }
1780 $xml .= " <copies/>\n";
1784 if (!$args->{no_uris}) {
1785 if (ref($self->obj->uri_maps) && @{ $self->obj->uri_maps }) {
1786 $xml .= " <uris>\n" . join(
1789 OpenILS::Application::SuperCat::unAPI
1791 ->as_xml({ %$args, no_volumes=>1 })
1792 } @{ $self->obj->uri_maps }
1796 $xml .= " <uris/>\n";
1801 $xml .= ' <owning_lib xmlns="http://open-ils.org/spec/actors/v1" ';
1802 $xml .= 'id="tag:open-ils.org:actor-org_unit/' . $self->obj->owning_lib->id . '" ';
1803 $xml .= 'shortname="'.$self->escape( $self->obj->owning_lib->shortname ) .'" ';
1804 $xml .= 'name="'.$self->escape( $self->obj->owning_lib->name ) .'"/>';
1807 unless ($args->{no_record}) {
1808 my $rec_tag = "tag:open-ils.org:biblio-record_entry/".$self->obj->record->id.'/'.$self->escape( $self->obj->owning_lib->shortname ) ;
1810 my $r_doc = $parser->parse_string($self->obj->record->marc);
1811 $r_doc->documentElement->setAttribute( id => $rec_tag );
1812 $xml .= $U->entityize($r_doc->documentElement->toString);
1815 $xml .= " </volume>\n";
1820 package OpenILS::Application::SuperCat::unAPI::acp;
1821 use base qw/OpenILS::Application::SuperCat::unAPI/;
1827 my $xml = ' <copy xmlns="http://open-ils.org/spec/holdings/v1" '.
1828 'id="tag:open-ils.org:asset-copy/' . $self->obj->id . '" ';
1830 $xml .= $_ . '="' . $self->escape( $self->obj->$_ ) . '" ' for (qw/
1831 create_date edit_date copy_number circulate deposit ref holdable deleted
1832 deposit_amount price barcode circ_modifier circ_as_type opac_visible
1837 $xml .= ' <status ident="' . $self->obj->status->id . '">' . $self->escape( $self->obj->status->name ) . "</status>\n";
1838 $xml .= ' <location ident="' . $self->obj->location->id . '">' . $self->escape( $self->obj->location->name ) . "</location>\n";
1839 $xml .= ' <circlib ident="' . $self->obj->circ_lib->id . '">' . $self->escape( $self->obj->circ_lib->name ) . "</circlib>\n";
1841 $xml .= ' <circ_lib xmlns="http://open-ils.org/spec/actors/v1" ';
1842 $xml .= 'id="tag:open-ils.org:actor-org_unit/' . $self->obj->circ_lib->id . '" ';
1843 $xml .= 'shortname="'.$self->escape( $self->obj->circ_lib->shortname ) .'" ';
1844 $xml .= 'name="'.$self->escape( $self->obj->circ_lib->name ) .'"/>';
1847 $xml .= " <copy_notes>\n";
1848 if (ref($self->obj->notes) && $self->obj->notes) {
1849 for my $note ( @{$self->obj->notes} ) {
1850 next unless ( $note->pub eq 't' );
1851 $xml .= sprintf(' <copy_note date="%s" title="%s">%s</copy_note>',$note->create_date, $self->escape($note->title), $self->escape($note->value));
1856 $xml .= " </copy_notes>\n";
1857 $xml .= " <statcats>\n";
1859 if (ref($self->obj->stat_cat_entries) && $self->obj->stat_cat_entries) {
1860 for my $sce ( @{$self->obj->stat_cat_entries} ) {
1861 next unless ( $sce->stat_cat->opac_visible eq 't' );
1862 $xml .= sprintf(' <statcat name="%s">%s</statcat>',$self->escape($sce->stat_cat->name) ,$self->escape($sce->value));
1866 $xml .= " </statcats>\n";
1868 unless ($args->{no_volume}) {
1869 if (ref($self->obj->call_number)) {
1870 $xml .= OpenILS::Application::SuperCat::unAPI
1871 ->new( $self->obj->call_number )
1872 ->as_xml({ %$args, no_copies=>1 });
1874 $xml .= " <volume/>\n";
1878 $xml .= " </copy>\n";
1885 # vim: noet:ts=4:sw=4