diff --git a/src/app/+admin/admin-registries/bitstream-formats/bitstream-formats.component.spec.ts b/src/app/+admin/admin-registries/bitstream-formats/bitstream-formats.component.spec.ts index 5fd2c9cde0..7ff15cad6d 100644 --- a/src/app/+admin/admin-registries/bitstream-formats/bitstream-formats.component.spec.ts +++ b/src/app/+admin/admin-registries/bitstream-formats/bitstream-formats.component.spec.ts @@ -230,10 +230,10 @@ describe('BitstreamFormatsComponent', () => { comp.deleteFormats(); expect(bitstreamFormatService.clearBitStreamFormatRequests).toHaveBeenCalled(); - expect(bitstreamFormatService.delete).toHaveBeenCalledWith(bitstreamFormat1); - expect(bitstreamFormatService.delete).toHaveBeenCalledWith(bitstreamFormat2); - expect(bitstreamFormatService.delete).toHaveBeenCalledWith(bitstreamFormat3); - expect(bitstreamFormatService.delete).toHaveBeenCalledWith(bitstreamFormat4); + expect(bitstreamFormatService.delete).toHaveBeenCalledWith(bitstreamFormat1.id); + expect(bitstreamFormatService.delete).toHaveBeenCalledWith(bitstreamFormat2.id); + expect(bitstreamFormatService.delete).toHaveBeenCalledWith(bitstreamFormat3.id); + expect(bitstreamFormatService.delete).toHaveBeenCalledWith(bitstreamFormat4.id); expect(notificationsServiceStub.success).toHaveBeenCalledWith('admin.registries.bitstream-formats.delete.success.head', 'admin.registries.bitstream-formats.delete.success.amount'); @@ -276,10 +276,10 @@ describe('BitstreamFormatsComponent', () => { comp.deleteFormats(); expect(bitstreamFormatService.clearBitStreamFormatRequests).toHaveBeenCalled(); - expect(bitstreamFormatService.delete).toHaveBeenCalledWith(bitstreamFormat1); - expect(bitstreamFormatService.delete).toHaveBeenCalledWith(bitstreamFormat2); - expect(bitstreamFormatService.delete).toHaveBeenCalledWith(bitstreamFormat3); - expect(bitstreamFormatService.delete).toHaveBeenCalledWith(bitstreamFormat4); + expect(bitstreamFormatService.delete).toHaveBeenCalledWith(bitstreamFormat1.id); + expect(bitstreamFormatService.delete).toHaveBeenCalledWith(bitstreamFormat2.id); + expect(bitstreamFormatService.delete).toHaveBeenCalledWith(bitstreamFormat3.id); + expect(bitstreamFormatService.delete).toHaveBeenCalledWith(bitstreamFormat4.id); expect(notificationsServiceStub.error).toHaveBeenCalledWith('admin.registries.bitstream-formats.delete.failure.head', 'admin.registries.bitstream-formats.delete.failure.amount'); diff --git a/src/app/+admin/admin-registries/bitstream-formats/bitstream-formats.component.ts b/src/app/+admin/admin-registries/bitstream-formats/bitstream-formats.component.ts index ec4003c108..52010e0132 100644 --- a/src/app/+admin/admin-registries/bitstream-formats/bitstream-formats.component.ts +++ b/src/app/+admin/admin-registries/bitstream-formats/bitstream-formats.component.ts @@ -64,7 +64,7 @@ export class BitstreamFormatsComponent implements OnInit { const tasks$ = []; for (const format of formats) { if (hasValue(format.id)) { - tasks$.push(this.bitstreamFormatService.delete(format)); + tasks$.push(this.bitstreamFormatService.delete(format.id)); } } zip(...tasks$).subscribe((results: boolean[]) => { diff --git a/src/app/+item-page/edit-item-page/item-delete/item-delete.component.spec.ts b/src/app/+item-page/edit-item-page/item-delete/item-delete.component.spec.ts index bb9085d31f..a22d81a5dd 100644 --- a/src/app/+item-page/edit-item-page/item-delete/item-delete.component.spec.ts +++ b/src/app/+item-page/edit-item-page/item-delete/item-delete.component.spec.ts @@ -220,7 +220,7 @@ describe('ItemDeleteComponent', () => { spyOn(comp, 'notify'); comp.performAction(); expect(mockItemDataService.delete) - .toHaveBeenCalledWith(mockItem, types.filter((type) => typesSelection[type]).map((type) => type.id)); + .toHaveBeenCalledWith(mockItem.id, types.filter((type) => typesSelection[type]).map((type) => type.id)); expect(comp.notify).toHaveBeenCalled(); }); }); diff --git a/src/app/+item-page/edit-item-page/item-delete/item-delete.component.ts b/src/app/+item-page/edit-item-page/item-delete/item-delete.component.ts index 6fe44c109b..eecbdf8c6f 100644 --- a/src/app/+item-page/edit-item-page/item-delete/item-delete.component.ts +++ b/src/app/+item-page/edit-item-page/item-delete/item-delete.component.ts @@ -312,7 +312,7 @@ export class ItemDeleteComponent ) ), ).subscribe((types) => { - this.itemDataService.delete(this.item, types).pipe(first()).subscribe( + this.itemDataService.delete(this.item.id, types).pipe(first()).subscribe( (succeeded: boolean) => { this.notify(succeeded); } @@ -322,7 +322,7 @@ export class ItemDeleteComponent /** * When the item is successfully delete, navigate to the homepage, otherwise navigate back to the item edit page - * @param response + * @param succeeded */ notify(succeeded: boolean) { if (succeeded) { diff --git a/src/app/core/data/bitstream-format-data.service.spec.ts b/src/app/core/data/bitstream-format-data.service.spec.ts index daf3dea87c..7954416010 100644 --- a/src/app/core/data/bitstream-format-data.service.spec.ts +++ b/src/app/core/data/bitstream-format-data.service.spec.ts @@ -282,7 +282,7 @@ describe('BitstreamFormatDataService', () => { format.id = 'format-id'; const expected = cold('(b|)', {b: true}); - const result = service.delete(format); + const result = service.delete(format.id); expect(result).toBeObservable(expected); }); diff --git a/src/app/core/data/bitstream-format-data.service.ts b/src/app/core/data/bitstream-format-data.service.ts index 5c7029a09f..e8cf030a52 100644 --- a/src/app/core/data/bitstream-format-data.service.ts +++ b/src/app/core/data/bitstream-format-data.service.ts @@ -154,19 +154,19 @@ export class BitstreamFormatDataService extends DataService { /** * Delete an existing DSpace Object on the server - * @param format The DSpace Object to be removed + * @param formatID The DSpace Object'id to be removed * Return an observable that emits true when the deletion was successful, false when it failed */ - delete(format: BitstreamFormat): Observable { + delete(formatID: string): Observable { const requestId = this.requestService.generateRequestId(); const hrefObs = this.halService.getEndpoint(this.linkPath).pipe( - map((endpoint: string) => this.getIDHref(endpoint, format.id))); + map((endpoint: string) => this.getIDHref(endpoint, formatID))); hrefObs.pipe( find((href: string) => hasValue(href)), map((href: string) => { - const request = new DeleteByIDRequest(requestId, href, format.id); + const request = new DeleteByIDRequest(requestId, href, formatID); this.requestService.configure(request); }) ).subscribe(); diff --git a/src/app/core/data/data.service.ts b/src/app/core/data/data.service.ts index 3be1ef9768..7dcfb6bd6e 100644 --- a/src/app/core/data/data.service.ts +++ b/src/app/core/data/data.service.ts @@ -152,7 +152,11 @@ export abstract class DataService { /** * Returns {@link RemoteData} of all object with a list of {@link FollowLinkConfig}, to indicate which embedded * info should be added to the objects + * + * @param options Find list options object * @param linksToFollow List of {@link FollowLinkConfig} that indicate which {@link HALLink}s should be automatically resolved + * @return {Observable>>} + * Return an observable that emits object list */ findAll(options: FindListOptions = {}, ...linksToFollow: Array>): Observable>> { return this.findList(this.getFindAllHref(options), options, ...linksToFollow); @@ -162,6 +166,7 @@ export abstract class DataService { * Returns an observable of {@link RemoteData} of an object, based on href observable, * with a list of {@link FollowLinkConfig}, to automatically resolve {@link HALLink}s of the object * @param href$ Observable of href of object we want to retrieve + * @param options Find list options object * @param linksToFollow List of {@link FollowLinkConfig} that indicate which {@link HALLink}s should be automatically resolved */ protected findList(href$, options: FindListOptions, ...linksToFollow: Array>) { @@ -231,6 +236,7 @@ export abstract class DataService { * Returns a list of observables of {@link RemoteData} of objects, based on an href, with a list of {@link FollowLinkConfig}, * to automatically resolve {@link HALLink}s of the object * @param href The url of object we want to retrieve + * @param findListOptions Find list options object * @param linksToFollow List of {@link FollowLinkConfig} that indicate which {@link HALLink}s should be automatically resolved */ findAllByHref(href: string, findListOptions: FindListOptions = {}, ...linksToFollow: Array>): Observable>> { @@ -259,6 +265,7 @@ export abstract class DataService { * * @param searchMethod The search method for the object * @param options The [[FindListOptions]] object + * @param linksToFollow The array of [[FollowLinkConfig]] * @return {Observable>} * Return an observable that emits response from the server */ @@ -367,16 +374,16 @@ export abstract class DataService { /** * Delete an existing DSpace Object on the server - * @param dso The DSpace Object to be removed + * @param dsoID The DSpace Object' id to be removed * @param copyVirtualMetadata (optional parameter) the identifiers of the relationship types for which the virtual * metadata should be saved as real metadata * @return an observable that emits true when the deletion was successful, false when it failed */ - delete(dso: T, copyVirtualMetadata?: string[]): Observable { + delete(dsoID: string, copyVirtualMetadata?: string[]): Observable { const requestId = this.requestService.generateRequestId(); const hrefObs = this.halService.getEndpoint(this.linkPath).pipe( - map((endpoint: string) => this.getIDHref(endpoint, dso.uuid))); + map((endpoint: string) => this.getIDHref(endpoint, dsoID))); hrefObs.pipe( find((href: string) => hasValue(href)), @@ -388,7 +395,7 @@ export abstract class DataService { + id ); } - const request = new DeleteByIDRequest(requestId, href, dso.uuid); + const request = new DeleteByIDRequest(requestId, href, dsoID); this.requestService.configure(request); }) ).subscribe(); diff --git a/src/app/shared/comcol-forms/delete-comcol-page/delete-comcol-page.component.spec.ts b/src/app/shared/comcol-forms/delete-comcol-page/delete-comcol-page.component.spec.ts index 3b39d36008..dbbeea5bc6 100644 --- a/src/app/shared/comcol-forms/delete-comcol-page/delete-comcol-page.component.spec.ts +++ b/src/app/shared/comcol-forms/delete-comcol-page/delete-comcol-page.component.spec.ts @@ -125,7 +125,7 @@ describe('DeleteComColPageComponent', () => { it('should call delete on the data service', () => { comp.onConfirm(data1); fixture.detectChanges(); - expect(dsoDataService.delete).toHaveBeenCalledWith(data1); + expect(dsoDataService.delete).toHaveBeenCalledWith(data1.id); }); }); diff --git a/src/app/shared/comcol-forms/delete-comcol-page/delete-comcol-page.component.ts b/src/app/shared/comcol-forms/delete-comcol-page/delete-comcol-page.component.ts index 57c860e04f..f5a1a84af5 100644 --- a/src/app/shared/comcol-forms/delete-comcol-page/delete-comcol-page.component.ts +++ b/src/app/shared/comcol-forms/delete-comcol-page/delete-comcol-page.component.ts @@ -43,7 +43,7 @@ export class DeleteComColPageComponent implements * Deletes an existing DSO and redirects to the home page afterwards, showing a notification that states whether or not the deletion was successful */ onConfirm(dso: TDomain) { - this.dsoDataService.delete(dso) + this.dsoDataService.delete(dso.id) .pipe(first()) .subscribe((success: boolean) => { if (success) { diff --git a/src/app/shared/mydspace-actions/workspaceitem/workspaceitem-actions.component.spec.ts b/src/app/shared/mydspace-actions/workspaceitem/workspaceitem-actions.component.spec.ts index 8950966e26..00f5422b27 100644 --- a/src/app/shared/mydspace-actions/workspaceitem/workspaceitem-actions.component.spec.ts +++ b/src/app/shared/mydspace-actions/workspaceitem/workspaceitem-actions.component.spec.ts @@ -1,5 +1,5 @@ import { ChangeDetectionStrategy, Injector, NO_ERRORS_SCHEMA } from '@angular/core'; -import { async, ComponentFixture, fakeAsync, TestBed } from '@angular/core/testing'; +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { Router } from '@angular/router'; import { By } from '@angular/platform-browser'; @@ -141,7 +141,7 @@ describe('WorkspaceitemActionsComponent', () => { fixture.detectChanges(); fixture.whenStable().then(() => { - expect(mockDataService.delete).toHaveBeenCalledWith(mockObject); + expect(mockDataService.delete).toHaveBeenCalledWith(mockObject.id); }); }); diff --git a/src/app/shared/mydspace-actions/workspaceitem/workspaceitem-actions.component.ts b/src/app/shared/mydspace-actions/workspaceitem/workspaceitem-actions.component.ts index 2378c8e251..27512d899e 100644 --- a/src/app/shared/mydspace-actions/workspaceitem/workspaceitem-actions.component.ts +++ b/src/app/shared/mydspace-actions/workspaceitem/workspaceitem-actions.component.ts @@ -1,4 +1,4 @@ -import { Component, Injector, Input, OnDestroy } from '@angular/core'; +import { Component, Injector, Input } from '@angular/core'; import { Router } from '@angular/router'; import { BehaviorSubject } from 'rxjs'; @@ -62,7 +62,7 @@ export class WorkspaceitemActionsComponent extends MyDSpaceActionsComponent { if (result === 'ok') { this.processingDelete$.next(true); - this.objectDataService.delete(this.object) + this.objectDataService.delete(this.object.id) .subscribe((response: boolean) => { this.processingDelete$.next(false); this.handleActionResponse(response);