<!-- <repository_identifier>mydomain.org</repository_identifier> -->
<!-- <delimiter>:</delimiter> -->
<!-- <sample_identifier>oai:mydomain.org:12345</sample_identifier> -->
- <!-- <list_sets>false</list_sets> -->
<!--
The metadataformat element contains the schema for the oai_dc and marcxml metadata formats.
use OpenSRF::Utils::Logger qw($logger);
use XML::LibXML;
use XML::LibXSLT;
+my $U = 'OpenILS::Application::AppUtils';
my (
$_parser,
my $max_count = shift;
my $deleted_record = shift || 'yes';
- my $query = {};
+ my $query = $set ? _set_spec_to_query($set) : {};
$query->{'rec_id'} = ($max_count eq 1) ? $rec_id : {'>=' => $rec_id} ;
- $query->{'set_spec'} = $set if ( $set ); # unsupported
$query->{'deleted'} = 'f' unless ( $deleted_record eq 'yes' );
$query->{'datestamp'} = {'>=', $from} if ( $from && !$until ) ;
$query->{'datestamp'} = {'<=', $until} if ( !$from && $until ) ;
}
);
+sub _set_spec_to_query {
+ my $self = shift;
+ my $set_spec = shift;
+
+ if (index($set_spec, 'ORG_UNIT:') == 0) {
+ my $shortname = (split ':', $set_spec)[-1];
+ my $org_unit = OpenSRF::AppSession
+ ->create('open-ils.actor')
+ ->request('open-ils.actor.org_unit.retrieve_by_shortname', $shortname)
+ ->gather(1);
+ if ($org_unit && ref($org_unit) ne 'HASH') {
+ return {
+ 'id' => {'=' => ['oai.bib_is_visible_at_org', 'id', $org_unit->id]}
+ };
+ }
+ }
+ return {};
+}
+
1;
$scheme,
$delimiter,
$sample_identifier,
- $list_sets,
$oai_metadataformats,
$oai_sets,
$oai,
$scheme = $app_settings->{'scheme'} || 'oai';
$delimiter = $app_settings->{'delimiter'} || ':';
$sample_identifier = $app_settings->{'sample_identifier'} || $scheme . $delimiter . $repository_identifier . $delimiter . '12345' ;
- $list_sets = $app_settings->{'list_sets'} || 0;
- if ( $list_sets ) {
- _load_oaisets_authority();
- _load_oaisets_biblio();
- }
+ _load_oaisets_authority();
+ _load_oaisets_biblio();
_load_oai_metadataformats();
return Apache2::Const::OK;
return unless ($node->opac_visible =~ /^[y1t]+/i);
- my $spec = ($parent) ? $parent . ':' . $node->shortname : $node->shortname ;
+ my $ou_hierarchy_string = ($parent) ? $parent . ':' . $node->shortname : $node->shortname ;
+ my $spec = 'ORG_UNIT:'.$ou_hierarchy_string;
$oai_sets->{$spec} = {id => $node->id, record_class => 'biblio' };
$oai_sets->{$node->id} = {setSpec => $spec, setName => $node->name, record_class => 'biblio' };
my $kids = $node->children;
- _load_oaisets_biblio($_, $types, $spec) for (@$kids);
+ _load_oaisets_biblio($_, $types, $ou_hierarchy_string) for (@$kids);
}
ORDER BY
are.id;
+CREATE OR REPLACE function oai.bib_is_visible_at_org(bib BIGINT, org INT) RETURNS BOOL AS $F$
+WITH orgs AS (SELECT array_accum(id) id FROM actor.org_unit_descendants(org))
+SELECT EXISTS (SELECT 1 FROM asset.copy_vis_attr_cache, orgs WHERE vis_attr_vector @@ search.calculate_visibility_attribute_test('circ_lib', orgs.id)::query_int AND bib=record)
+$F$ LANGUAGE SQL STABLE;
+
ORDER BY
are.id;
+CREATE OR REPLACE function oai.bib_is_visible_at_org(bib BIGINT, org INT) RETURNS BOOL AS $F$
+WITH orgs AS (SELECT array_accum(id) id FROM actor.org_unit_descendants(org))
+SELECT EXISTS (SELECT 1 FROM asset.copy_vis_attr_cache, orgs WHERE vis_attr_vector @@ search.calculate_visibility_attribute_test('circ_lib', orgs.id)::query_int AND bib=record)
+$F$ LANGUAGE SQL STABLE;
+
COMMIT;