@@ -65,6 +65,13 @@ import {
6565} from './request.models' ;
6666import { RequestService } from './request.service' ;
6767
68+ /**
69+ * Filter for metadata value to be used for rest API
70+ */
71+ export interface MetadataFilter {
72+ metadataName : string ;
73+ metadataValue : string ;
74+ }
6875/**
6976 * A service to retrieve {@link Bitstream}s from the REST API
7077 */
@@ -379,4 +386,152 @@ export class BitstreamDataService extends IdentifiableDataService<Bitstream> imp
379386 return this . rdbService . buildFromRequestUUIDAndAwait ( requestId , ( ) => observableCombineLatest ( bitstreams . map ( ( bitstream : Bitstream ) => this . invalidateByHref ( bitstream . _links . self . href ) ) ) ) ;
380387 }
381388
389+ /**
390+ * Returns an observable of {@link RemoteData} of a {@link Bitstream} that is not marked
391+ * hidden (that hasn't got the metadata `bitstream.hide` or its value is not true/yes).
392+ * resolve {@link HALLink}s of the object
393+ *
394+ * @param uuid The item UUID to retrieve bitstreams from
395+ * @param bundlename Bundle type of the bitstreams
396+ * @param metadataFilters Array of object we want to filter by
397+ * @param options The {@link FindListOptions} for the request
398+ * @param useCachedVersionIfAvailable If this is true, the request will only be sent if there's
399+ * no valid cached version. Defaults to true
400+ * @param reRequestOnStale Whether or not the request should automatically be re-
401+ * requested after the response becomes stale
402+ * @param linksToFollow List of {@link FollowLinkConfig} that indicate which
403+ * {@link HALLink}s should be automatically resolved
404+ */
405+ findShowableBitstreamsByItem (
406+ uuid : string ,
407+ bundlename : string ,
408+ metadataFilters : MetadataFilter [ ] ,
409+ options : FindListOptions = { } ,
410+ useCachedVersionIfAvailable = true ,
411+ reRequestOnStale = true ,
412+ ...linksToFollow : FollowLinkConfig < Bitstream > [ ]
413+ ) : Observable < RemoteData < PaginatedList < Bitstream > > > {
414+ const searchParams = [ ] ;
415+ searchParams . push ( new RequestParam ( 'uuid' , uuid ) ) ;
416+ searchParams . push ( new RequestParam ( 'name' , bundlename ) ) ;
417+
418+ metadataFilters . forEach ( ( entry : MetadataFilter ) => {
419+ searchParams . push ( new RequestParam ( 'filterMetadata' , entry . metadataName ) ) ;
420+ searchParams . push ( new RequestParam ( 'filterMetadataValue' , entry . metadataValue ) ) ;
421+ } ) ;
422+
423+ const hrefObs = this . getSearchByHref (
424+ 'showableByItem' ,
425+ { searchParams } ,
426+ ...linksToFollow ,
427+ ) ;
428+
429+ return this . findListByHref (
430+ hrefObs ,
431+ options ,
432+ useCachedVersionIfAvailable ,
433+ reRequestOnStale ,
434+ ...linksToFollow ,
435+ ) ;
436+ }
437+
438+
439+ /**
440+ * Returns an observable of {@link RemoteData} of a {@link Bitstream}, based on a handle and an
441+ * optional sequenceId or filename, with a list of {@link FollowLinkConfig}, to automatically
442+ * resolve {@link HALLink}s of the object
443+ *
444+ * @param uuid The item UUID to retrieve bitstreams from
445+ * @param bundlename Bundle type of the bitstreams
446+ * @param metadataFilters Array of object we want to filter by
447+ * @param options The {@link FindListOptions} for the request
448+ * @param useCachedVersionIfAvailable If this is true, the request will only be sent if there's
449+ * no valid cached version. Defaults to true
450+ * @param reRequestOnStale Whether or not the request should automatically be re-
451+ * requested after the response becomes stale
452+ * @param linksToFollow List of {@link FollowLinkConfig} that indicate which
453+ * {@link HALLink}s should be automatically resolved
454+ */
455+ findByItem (
456+ uuid : string ,
457+ bundlename : string ,
458+ metadataFilters : MetadataFilter [ ] ,
459+ options : FindListOptions ,
460+ useCachedVersionIfAvailable = true ,
461+ reRequestOnStale = true ,
462+ ...linksToFollow : FollowLinkConfig < Bitstream > [ ]
463+ ) : Observable < RemoteData < PaginatedList < Bitstream > > > {
464+ const searchParams = [ ] ;
465+ searchParams . push ( new RequestParam ( 'uuid' , uuid ) ) ;
466+ searchParams . push ( new RequestParam ( 'name' , bundlename ) ) ;
467+
468+ metadataFilters . forEach ( ( entry : MetadataFilter ) => {
469+ searchParams . push ( new RequestParam ( 'filterMetadata' , entry . metadataName ) ) ;
470+ searchParams . push ( new RequestParam ( 'filterMetadataValue' , entry . metadataValue ) ) ;
471+ } ) ;
472+
473+ const hrefObs = this . getSearchByHref (
474+ 'byItemId' ,
475+ { searchParams } ,
476+ ...linksToFollow ,
477+ ) ;
478+
479+ return this . findListByHref (
480+ hrefObs ,
481+ options ,
482+ useCachedVersionIfAvailable ,
483+ reRequestOnStale ,
484+ ...linksToFollow ,
485+ ) ;
486+ }
487+
488+ /**
489+ * Returns an observable of {@link RemoteData} of a {@link Bitstream} that is not marked
490+ * hidden (that hasn't got the metadata `bitstream.hide` or its value is not true/yes).
491+ * resolve {@link HALLink}s of the object
492+ *
493+ * @param uuid The item UUID to retrieve bitstreams from
494+ * @param bundlename Bundle type of the bitstreams
495+ * @param metadataFilters Array of object we want to filter by
496+ * @param options The {@link FindListOptions} for the request
497+ * @param useCachedVersionIfAvailable If this is true, the request will only be sent if there's
498+ * no valid cached version. Defaults to true
499+ * @param reRequestOnStale Whether or not the request should automatically be re-
500+ * requested after the response becomes stale
501+ * @param linksToFollow List of {@link FollowLinkConfig} that indicate which
502+ * {@link HALLink}s should be automatically resolved
503+ */
504+ showableByItem (
505+ uuid : string ,
506+ bundlename : string ,
507+ metadataFilters : MetadataFilter [ ] ,
508+ options : FindListOptions ,
509+ useCachedVersionIfAvailable = true ,
510+ reRequestOnStale = true ,
511+ ...linksToFollow : FollowLinkConfig < Bitstream > [ ]
512+ ) : Observable < RemoteData < PaginatedList < Bitstream > > > {
513+ const searchParams = [ ] ;
514+ searchParams . push ( new RequestParam ( 'uuid' , uuid ) ) ;
515+ searchParams . push ( new RequestParam ( 'name' , bundlename ) ) ;
516+
517+ metadataFilters . forEach ( ( entry : MetadataFilter ) => {
518+ searchParams . push ( new RequestParam ( 'filterMetadata' , entry . metadataName ) ) ;
519+ searchParams . push ( new RequestParam ( 'filterMetadataValue' , entry . metadataValue ) ) ;
520+ } ) ;
521+
522+ const hrefObs = this . getSearchByHref (
523+ 'showableByItem' ,
524+ { searchParams } ,
525+ ...linksToFollow ,
526+ ) ;
527+
528+ return this . findListByHref (
529+ hrefObs ,
530+ options ,
531+ useCachedVersionIfAvailable ,
532+ reRequestOnStale ,
533+ ...linksToFollow ,
534+ ) ;
535+ }
536+
382537}
0 commit comments