mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-15 22:13:02 +00:00
added builders for bundles and bitstreams
This commit is contained in:
34
src/app/core/cache/models/item-builder.ts
vendored
34
src/app/core/cache/models/item-builder.ts
vendored
@@ -6,6 +6,11 @@ import { Store } from "@ngrx/store";
|
||||
import { CoreState } from "../../core.reducers";
|
||||
import { NormalizedItem } from "./normalized-item.model";
|
||||
import { ListRemoteDataBuilder, SingleRemoteDataBuilder } from "./remote-data-builder";
|
||||
import { Request } from "../../data/request.models";
|
||||
import { hasValue } from "../../../shared/empty.util";
|
||||
import { RequestConfigureAction, RequestExecuteAction } from "../../data/request.actions";
|
||||
import { BundleRDBuilder } from "./bundle-builder";
|
||||
import { NormalizedBundle } from "./normalized-bundle.model";
|
||||
|
||||
export class ItemBuilder {
|
||||
|
||||
@@ -15,13 +20,36 @@ export class ItemBuilder {
|
||||
protected requestService: RequestService,
|
||||
protected store: Store<CoreState>,
|
||||
protected href: string,
|
||||
protected nc: NormalizedItem
|
||||
protected normalized: NormalizedItem
|
||||
) {
|
||||
}
|
||||
|
||||
build(): Item {
|
||||
//TODO
|
||||
return Object.assign(new Item(), this.nc);
|
||||
let links: any = {};
|
||||
|
||||
if (hasValue(this.normalized.bundles)) {
|
||||
this.normalized.bundles.forEach((href: string) => {
|
||||
const isCached = this.objectCache.hasBySelfLink(href);
|
||||
const isPending = this.requestService.isPending(href);
|
||||
|
||||
if (!(isCached || isPending)) {
|
||||
const request = new Request(href, NormalizedBundle);
|
||||
this.store.dispatch(new RequestConfigureAction(request));
|
||||
this.store.dispatch(new RequestExecuteAction(href));
|
||||
}
|
||||
});
|
||||
|
||||
links.bundles = this.normalized.bundles.map((href: string) => {
|
||||
return new BundleRDBuilder(
|
||||
this.objectCache,
|
||||
this.responseCache,
|
||||
this.requestService,
|
||||
this.store,
|
||||
href
|
||||
).build();
|
||||
});
|
||||
}
|
||||
return Object.assign(new Item(), this.normalized, links);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user