forked from hazza/dspace-angular
adapted remote data build method to aggregate relation remotedata arrays
This commit is contained in:

committed by
Lotte Hofstede

parent
2b74c3034a
commit
fbb64a6031
@@ -31,14 +31,14 @@ export class Item extends DSpaceObject {
|
||||
/**
|
||||
* An array of Collections that are direct parents of this Item
|
||||
*/
|
||||
parents: Array<RemoteData<Collection>>;
|
||||
parents: RemoteData<Collection[]>;
|
||||
|
||||
/**
|
||||
* The Collection that owns this Item
|
||||
*/
|
||||
owner: Collection;
|
||||
|
||||
bundles: Array<RemoteData<Bundle>>;
|
||||
bundles: RemoteData<Bundle[]>;
|
||||
|
||||
|
||||
/**
|
||||
@@ -63,13 +63,11 @@ export class Item extends DSpaceObject {
|
||||
* Retrieves all files that should be displayed on the item page of this item
|
||||
* @returns {Observable<Array<Observable<Bitstream>>>} an array of all Bitstreams in the "ORIGINAL" bundle
|
||||
*/
|
||||
getFiles(): Observable<Array<Observable<Bitstream>>> {
|
||||
getFiles(): Observable<Bitstream[]> {
|
||||
const bundle: Observable <Bundle> = this.getBundle("ORIGINAL");
|
||||
return bundle.map(bundle => {
|
||||
if (hasValue(bundle) && Array.isArray(bundle.bitstreams)) {
|
||||
return bundle.bitstreams.map(bitstream => bitstream.payload)
|
||||
}
|
||||
});
|
||||
return bundle
|
||||
.filter(bundle => hasValue(bundle))
|
||||
.flatMap(bundle => bundle.bitstreams.payload);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -78,9 +76,8 @@ export class Item extends DSpaceObject {
|
||||
* @returns {Observable<Bundle>} the Bundle that belongs to this item with the given name
|
||||
*/
|
||||
getBundle(name: String): Observable<Bundle> {
|
||||
return Observable.combineLatest(
|
||||
...this.bundles.map(b => b.payload),
|
||||
(...bundles: Array<Bundle>) => bundles)
|
||||
return this.bundles.payload
|
||||
.filter(bundles => hasValue(bundles))
|
||||
.map(bundles => {
|
||||
return bundles.find((bundle: Bundle) => {
|
||||
return bundle.name === name
|
||||
@@ -88,12 +85,4 @@ export class Item extends DSpaceObject {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves all direct parent collections of this item
|
||||
* @returns {Array<Observable<Collection>>} an array of all Collections that contain this item
|
||||
*/
|
||||
getCollections(): Array<Observable<Collection>> {
|
||||
return this.parents.map(collection => collection.payload.map(parent => parent));
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user