debugging issue commit

This commit is contained in:
lotte
2020-04-03 16:00:52 +02:00
parent 258b1228f3
commit 2eb3d11cd2
15 changed files with 233 additions and 32 deletions

View File

@@ -9,10 +9,14 @@ import { DataService } from '../data/data.service';
import { RequestService } from '../data/request.service';
import { WorkflowItem } from './models/workflowitem.model';
import { HALEndpointService } from '../shared/hal-endpoint.service';
import { FindListOptions } from '../data/request.models';
import { DeleteByIDRequest, FindListOptions } from '../data/request.models';
import { NotificationsService } from '../../shared/notifications/notifications.service';
import { ObjectCacheService } from '../cache/object-cache.service';
import { DSOChangeAnalyzer } from '../data/dso-change-analyzer.service';
import { Observable } from 'rxjs';
import { find, map } from 'rxjs/operators';
import { hasValue } from '../../shared/empty.util';
import { RequestEntry } from '../data/request.reducer';
/**
* A service that provides methods to make REST requests with workflowitems endpoint.
@@ -35,4 +39,38 @@ export class WorkflowItemDataService extends DataService<WorkflowItem> {
super();
}
/**
* Delete an existing Workspace Item on the server
* @param id The Workspace Item's id to be removed
* @return an observable that emits true when the deletion was successful, false when it failed
*/
delete(id: string): Observable<boolean> {
return this.deleteWFI(id, true)
}
sendBack(id: string): Observable<boolean> {
return this.deleteWFI(id, false)
}
private deleteWFI(id: string, expunge: boolean): Observable<boolean> {
const requestId = this.requestService.generateRequestId();
const hrefObs = this.halService.getEndpoint(this.linkPath).pipe(
map((endpoint: string) => this.getIDHref(endpoint, id)),
map((endpoint: string) => endpoint + '?expunge=' + expunge)
);
hrefObs.pipe(
find((href: string) => hasValue(href)),
map((href: string) => {
const request = new DeleteByIDRequest(requestId, href, id);
this.requestService.configure(request);
})
).subscribe();
return this.requestService.getByUUID(requestId).pipe(
find((request: RequestEntry) => request.completed),
map((request: RequestEntry) => request.response.isSuccessful)
);
}
}