net: NetService;
displayHighlights: {[name: string]: string | string[]} = {};
- constructor(record: IdlObject, orgId: number, orgDepth: number) {
+ constructor(record: IdlObject, orgId: number, orgDepth?: number) {
this.id = Number(record.id());
this.record = record;
this.orgId = orgId;
.map(f => f.name);
}
+ // newstyle
+ getBibSummaries(bibIds: number[],
+ orgId: number, isStaff?: boolean): Observable<BibRecordSummary> {
+
+ if (bibIds.length === 0) { return from([]); }
+
+ let method = 'open-ils.search.biblio.record.catalog_summary';
+ if (isStaff) { method += '.staff'; }
+
+ return this.net.request('open-ils.search', method, orgId, bibIds)
+ .pipe(map(bibSummary => {
+ const summary = new BibRecordSummary(bibSummary.record, orgId);
+ summary.net = this.net; // inject
+ summary.display = bibSummary.display;
+ summary.attributes = bibSummary.attributes;
+ summary.holdCount = bibSummary.hold_count;
+ summary.holdingsSummary = bibSummary.copy_counts;
+ return summary;
+ }));
+ }
+
// Note when multiple IDs are provided, responses are emitted in order
// of receipt, not necessarily in the requested ID order.
getBibSummary(bibIds: number | number[],
this.cat.search(this.searchContext)
.then(ok => {
this.cat.fetchFacets(this.searchContext);
- this.cat.fetchBibSummaries(this.searchContext)
- .then(ok2 => this.fleshSearchResults());
+ this.cat.fetchBibSummaries(this.searchContext);
});
}
}
return false;
}
- fleshSearchResults(): void {
- const records = this.searchContext.result.records;
- if (!records || records.length === 0) { return; }
-
- // Flesh the creator / editor fields with the user object.
- this.bib.fleshBibUsers(records.map(r => r.record));
- }
-
searchIsDone(): boolean {
return this.searchContext.searchState === CatalogSearchState.COMPLETE;
}
use OpenSRF::Utils::Logger qw/:logger/;
-
-use OpenSRF::Utils::JSON;
-
use Time::HiRes qw(time sleep);
use OpenSRF::EX qw(:try);
use Digest::MD5 qw(md5_hex);
}
+__PACKAGE__->register_method(
+ method => 'catalog_record_summary',
+ api_name => 'open-ils.search.biblio.record.catalog_summary',
+ stream => 1,
+ max_bundle_count => 1,
+ signature => {
+ desc => 'Stream of record data suitable for catalog display',
+ params => [
+ {desc => 'Context org unit ID', type => 'number'},
+ {desc => 'Array of Record IDs', type => 'array'}
+ ],
+ return => {
+ desc => 'Stream of record summary objects'
+ }
+ }
+);
+
+__PACKAGE__->register_method(
+ method => 'catalog_record_summary',
+ api_name => 'open-ils.search.biblio.record.catalog_summary.staff',
+ stream => 1,
+ max_bundle_count => 1,
+ signature => q/see open-ils.search.biblio.record.catalog_summary/
+);
+
+sub catalog_record_summary {
+ my ($self, $client, $org_id, $record_ids) = @_;
+
+ my $e = new_editor();
+
+ for my $rec_id (@$record_ids) {
+
+ my ($bre, $display, $attributes) = get_one_catalog_record($e, $rec_id);
+
+ my $copy_counts =
+ record_id_to_copy_count($self, $client, $org_id, $rec_id);
+
+ my $hold_count = $U->simplereq(
+ 'open-ils.circ',
+ 'open-ils.circ.bre.holds.count', $rec_id);
+
+ $client->respond({
+ id => $rec_id,
+ record => $bre,
+ display => $display,
+ attributes => $attributes,
+ copy_counts => $copy_counts,
+ hold_count => $hold_count
+ });
+ }
+
+ return undef;
+}
+
+sub get_one_catalog_record {
+ my ($e, $rec_id) = @_;
+
+ my $bre = $e->retrieve_biblio_record_entry([$rec_id, {
+ flesh => 1,
+ flesh_fields => {
+ bre => [qw/compressed_display_entries mattrs creator editor/]
+ }
+ }]) or return ();
+
+ my $display = {};
+ $display->{$_->name} = OpenSRF::Utils::JSON->JSON2perl($_->value)
+ foreach @{$bre->compressed_display_entries};
+
+ # Create an object of 'mraf' attributes.
+ # Any attribute can be multi so dedupe and array-ify all of them.
+ my $attributes = {};
+ for my $attr (@{$bre->mattrs}) {
+ $attributes->{$attr->attr} = {} unless $attributes->{$attr->attr};
+ $attributes->{$attr->attr}->{$attr->value} = 1; # avoid dupes
+ }
+ $attributes->{$_} = [keys %{$attributes->{$_}}] for keys %$attributes;
+
+ # clear bulk
+ $bre->clear_marc;
+ $bre->clear_mattrs;
+ $bre->clear_compressed_display_entries;
+
+ return ($bre, $display, $attributes);
+}
+
+
1;