mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
[CST-5337] Refactoring in order to comply with new data service
This commit is contained in:
@@ -20,8 +20,8 @@ import {
|
|||||||
qualityAssuranceEventObjectMissingProjectFound
|
qualityAssuranceEventObjectMissingProjectFound
|
||||||
} from '../../../../shared/mocks/notifications.mock';
|
} from '../../../../shared/mocks/notifications.mock';
|
||||||
import { ReplaceOperation } from 'fast-json-patch';
|
import { ReplaceOperation } from 'fast-json-patch';
|
||||||
import {RequestEntry} from '../../../data/request-entry.model';
|
import { RequestEntry } from '../../../data/request-entry.model';
|
||||||
import {FindListOptions} from '../../../data/find-list-options.model';
|
import { FindListOptions } from '../../../data/find-list-options.model';
|
||||||
|
|
||||||
describe('QualityAssuranceEventRestService', () => {
|
describe('QualityAssuranceEventRestService', () => {
|
||||||
let scheduler: TestScheduler;
|
let scheduler: TestScheduler;
|
||||||
@@ -43,7 +43,7 @@ describe('QualityAssuranceEventRestService', () => {
|
|||||||
const topic = 'ENRICH!MORE!PID';
|
const topic = 'ENRICH!MORE!PID';
|
||||||
|
|
||||||
const pageInfo = new PageInfo();
|
const pageInfo = new PageInfo();
|
||||||
const array = [ qualityAssuranceEventObjectMissingPid, qualityAssuranceEventObjectMissingPid2 ];
|
const array = [qualityAssuranceEventObjectMissingPid, qualityAssuranceEventObjectMissingPid2];
|
||||||
const paginatedList = buildPaginatedList(pageInfo, array);
|
const paginatedList = buildPaginatedList(pageInfo, array);
|
||||||
const qaEventObjectRD = createSuccessfulRemoteDataObject(qualityAssuranceEventObjectMissingPid);
|
const qaEventObjectRD = createSuccessfulRemoteDataObject(qualityAssuranceEventObjectMissingPid);
|
||||||
const qaEventObjectMissingProjectRD = createSuccessfulRemoteDataObject(qualityAssuranceEventObjectMissingProjectFound);
|
const qaEventObjectMissingProjectRD = createSuccessfulRemoteDataObject(qualityAssuranceEventObjectMissingProjectFound);
|
||||||
@@ -87,12 +87,13 @@ describe('QualityAssuranceEventRestService', () => {
|
|||||||
buildList: cold('(a)', {
|
buildList: cold('(a)', {
|
||||||
a: paginatedListRD
|
a: paginatedListRD
|
||||||
}),
|
}),
|
||||||
buildFromRequestUUID: jasmine.createSpy('buildFromRequestUUID')
|
buildFromRequestUUID: jasmine.createSpy('buildFromRequestUUID'),
|
||||||
|
buildFromRequestUUIDAndAwait: jasmine.createSpy('buildFromRequestUUIDAndAwait')
|
||||||
});
|
});
|
||||||
|
|
||||||
objectCache = {} as ObjectCacheService;
|
objectCache = {} as ObjectCacheService;
|
||||||
halService = jasmine.createSpyObj('halService', {
|
halService = jasmine.createSpyObj('halService', {
|
||||||
getEndpoint: cold('a|', { a: endpointURL })
|
getEndpoint: cold('a|', { a: endpointURL })
|
||||||
});
|
});
|
||||||
|
|
||||||
notificationsService = {} as NotificationsService;
|
notificationsService = {} as NotificationsService;
|
||||||
@@ -105,17 +106,16 @@ describe('QualityAssuranceEventRestService', () => {
|
|||||||
objectCache,
|
objectCache,
|
||||||
halService,
|
halService,
|
||||||
notificationsService,
|
notificationsService,
|
||||||
http,
|
|
||||||
comparator
|
comparator
|
||||||
);
|
);
|
||||||
|
|
||||||
serviceASAny = service;
|
serviceASAny = service;
|
||||||
|
|
||||||
spyOn(serviceASAny.dataService, 'searchBy').and.callThrough();
|
spyOn(serviceASAny.searchData, 'searchBy').and.callThrough();
|
||||||
spyOn(serviceASAny.dataService, 'findById').and.callThrough();
|
spyOn(serviceASAny, 'findById').and.callThrough();
|
||||||
spyOn(serviceASAny.dataService, 'patch').and.callThrough();
|
spyOn(serviceASAny.patchData, 'patch').and.callThrough();
|
||||||
spyOn(serviceASAny.dataService, 'postOnRelated').and.callThrough();
|
spyOn(serviceASAny, 'postOnRelated').and.callThrough();
|
||||||
spyOn(serviceASAny.dataService, 'deleteOnRelated').and.callThrough();
|
spyOn(serviceASAny, 'deleteOnRelated').and.callThrough();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('getEventsByTopic', () => {
|
describe('getEventsByTopic', () => {
|
||||||
@@ -125,7 +125,7 @@ describe('QualityAssuranceEventRestService', () => {
|
|||||||
serviceASAny.rdbService.buildFromRequestUUID.and.returnValue(observableOf(qaEventObjectRD));
|
serviceASAny.rdbService.buildFromRequestUUID.and.returnValue(observableOf(qaEventObjectRD));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should proxy the call to dataservice.searchBy', () => {
|
it('should proxy the call to searchData.searchBy', () => {
|
||||||
const options: FindListOptions = {
|
const options: FindListOptions = {
|
||||||
searchParams: [
|
searchParams: [
|
||||||
{
|
{
|
||||||
@@ -135,13 +135,13 @@ describe('QualityAssuranceEventRestService', () => {
|
|||||||
]
|
]
|
||||||
};
|
};
|
||||||
service.getEventsByTopic(topic);
|
service.getEventsByTopic(topic);
|
||||||
expect(serviceASAny.dataService.searchBy).toHaveBeenCalledWith('findByTopic', options, true, true);
|
expect(serviceASAny.searchData.searchBy).toHaveBeenCalledWith('findByTopic', options, true, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return a RemoteData<PaginatedList<QualityAssuranceEventObject>> for the object with the given Topic', () => {
|
it('should return a RemoteData<PaginatedList<QualityAssuranceEventObject>> for the object with the given Topic', () => {
|
||||||
const result = service.getEventsByTopic(topic);
|
const result = service.getEventsByTopic(topic);
|
||||||
const expected = cold('(a)', {
|
const expected = cold('(a)', {
|
||||||
a: paginatedListRD
|
a: paginatedListRD
|
||||||
});
|
});
|
||||||
expect(result).toBeObservable(expected);
|
expect(result).toBeObservable(expected);
|
||||||
});
|
});
|
||||||
@@ -154,15 +154,15 @@ describe('QualityAssuranceEventRestService', () => {
|
|||||||
serviceASAny.rdbService.buildFromRequestUUID.and.returnValue(observableOf(qaEventObjectRD));
|
serviceASAny.rdbService.buildFromRequestUUID.and.returnValue(observableOf(qaEventObjectRD));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should proxy the call to dataservice.findById', () => {
|
it('should call findById', () => {
|
||||||
service.getEvent(qualityAssuranceEventObjectMissingPid.id).subscribe(
|
service.getEvent(qualityAssuranceEventObjectMissingPid.id).subscribe(
|
||||||
(res) => {
|
(res) => {
|
||||||
expect(serviceASAny.dataService.findById).toHaveBeenCalledWith(qualityAssuranceEventObjectMissingPid.id, true, true);
|
expect(serviceASAny.findById).toHaveBeenCalledWith(qualityAssuranceEventObjectMissingPid.id, true, true);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return a RemoteData<QualityAssuranceEventObject> for the object with the given URL', () => {
|
it('should return a RemoteData for the object with the given URL', () => {
|
||||||
const result = service.getEvent(qualityAssuranceEventObjectMissingPid.id);
|
const result = service.getEvent(qualityAssuranceEventObjectMissingPid.id);
|
||||||
const expected = cold('(a)', {
|
const expected = cold('(a)', {
|
||||||
a: qaEventObjectRD
|
a: qaEventObjectRD
|
||||||
@@ -176,12 +176,13 @@ describe('QualityAssuranceEventRestService', () => {
|
|||||||
serviceASAny.requestService.getByHref.and.returnValue(observableOf(responseCacheEntry));
|
serviceASAny.requestService.getByHref.and.returnValue(observableOf(responseCacheEntry));
|
||||||
serviceASAny.requestService.getByUUID.and.returnValue(observableOf(responseCacheEntry));
|
serviceASAny.requestService.getByUUID.and.returnValue(observableOf(responseCacheEntry));
|
||||||
serviceASAny.rdbService.buildFromRequestUUID.and.returnValue(observableOf(qaEventObjectRD));
|
serviceASAny.rdbService.buildFromRequestUUID.and.returnValue(observableOf(qaEventObjectRD));
|
||||||
|
serviceASAny.rdbService.buildFromRequestUUIDAndAwait.and.returnValue(observableOf(qaEventObjectRD));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should proxy the call to dataservice.patch', () => {
|
it('should proxy the call to patchData.patch', () => {
|
||||||
service.patchEvent(status, qualityAssuranceEventObjectMissingPid).subscribe(
|
service.patchEvent(status, qualityAssuranceEventObjectMissingPid).subscribe(
|
||||||
(res) => {
|
(res) => {
|
||||||
expect(serviceASAny.dataService.patch).toHaveBeenCalledWith(qualityAssuranceEventObjectMissingPid, operation);
|
expect(serviceASAny.patchData.patch).toHaveBeenCalledWith(qualityAssuranceEventObjectMissingPid, operation);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@@ -202,10 +203,10 @@ describe('QualityAssuranceEventRestService', () => {
|
|||||||
serviceASAny.rdbService.buildFromRequestUUID.and.returnValue(observableOf(qaEventObjectMissingProjectRD));
|
serviceASAny.rdbService.buildFromRequestUUID.and.returnValue(observableOf(qaEventObjectMissingProjectRD));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should proxy the call to dataservice.postOnRelated', () => {
|
it('should call postOnRelated', () => {
|
||||||
service.boundProject(qualityAssuranceEventObjectMissingProjectFound.id, requestUUID).subscribe(
|
service.boundProject(qualityAssuranceEventObjectMissingProjectFound.id, requestUUID).subscribe(
|
||||||
(res) => {
|
(res) => {
|
||||||
expect(serviceASAny.dataService.postOnRelated).toHaveBeenCalledWith(qualityAssuranceEventObjectMissingProjectFound.id, requestUUID);
|
expect(serviceASAny.postOnRelated).toHaveBeenCalledWith(qualityAssuranceEventObjectMissingProjectFound.id, requestUUID);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@@ -226,10 +227,10 @@ describe('QualityAssuranceEventRestService', () => {
|
|||||||
serviceASAny.rdbService.buildFromRequestUUID.and.returnValue(observableOf(createSuccessfulRemoteDataObject({})));
|
serviceASAny.rdbService.buildFromRequestUUID.and.returnValue(observableOf(createSuccessfulRemoteDataObject({})));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should proxy the call to dataservice.deleteOnRelated', () => {
|
it('should call deleteOnRelated', () => {
|
||||||
service.removeProject(qualityAssuranceEventObjectMissingProjectFound.id).subscribe(
|
service.removeProject(qualityAssuranceEventObjectMissingProjectFound.id).subscribe(
|
||||||
(res) => {
|
(res) => {
|
||||||
expect(serviceASAny.dataService.deleteOnRelated).toHaveBeenCalledWith(qualityAssuranceEventObjectMissingProjectFound.id);
|
expect(serviceASAny.deleteOnRelated).toHaveBeenCalledWith(qualityAssuranceEventObjectMissingProjectFound.id);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@@ -1,73 +1,42 @@
|
|||||||
/* eslint-disable max-classes-per-file */
|
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { HttpClient } from '@angular/common/http';
|
|
||||||
import { Store } from '@ngrx/store';
|
|
||||||
|
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
|
import { find, take } from 'rxjs/operators';
|
||||||
|
import { ReplaceOperation } from 'fast-json-patch';
|
||||||
|
|
||||||
import { HALEndpointService } from '../../../shared/hal-endpoint.service';
|
import { HALEndpointService } from '../../../shared/hal-endpoint.service';
|
||||||
import { NotificationsService } from '../../../../shared/notifications/notifications.service';
|
import { NotificationsService } from '../../../../shared/notifications/notifications.service';
|
||||||
import { RemoteDataBuildService } from '../../../cache/builders/remote-data-build.service';
|
import { RemoteDataBuildService } from '../../../cache/builders/remote-data-build.service';
|
||||||
import { RestResponse } from '../../../cache/response.models';
|
|
||||||
import { ObjectCacheService } from '../../../cache/object-cache.service';
|
import { ObjectCacheService } from '../../../cache/object-cache.service';
|
||||||
import { dataService } from '../../../cache/builders/build-decorators';
|
import { dataService } from '../../../data/base/data-service.decorator';
|
||||||
import { RequestService } from '../../../data/request.service';
|
import { RequestService } from '../../../data/request.service';
|
||||||
import { ChangeAnalyzer } from '../../../data/change-analyzer';
|
|
||||||
import { DefaultChangeAnalyzer } from '../../../data/default-change-analyzer.service';
|
|
||||||
import { RemoteData } from '../../../data/remote-data';
|
import { RemoteData } from '../../../data/remote-data';
|
||||||
import { QualityAssuranceEventObject } from '../models/quality-assurance-event.model';
|
import { QualityAssuranceEventObject } from '../models/quality-assurance-event.model';
|
||||||
import { QUALITY_ASSURANCE_EVENT_OBJECT } from '../models/quality-assurance-event-object.resource-type';
|
import { QUALITY_ASSURANCE_EVENT_OBJECT } from '../models/quality-assurance-event-object.resource-type';
|
||||||
import { FollowLinkConfig } from '../../../../shared/utils/follow-link-config.model';
|
import { FollowLinkConfig } from '../../../../shared/utils/follow-link-config.model';
|
||||||
import { PaginatedList } from '../../../data/paginated-list.model';
|
import { PaginatedList } from '../../../data/paginated-list.model';
|
||||||
import { ReplaceOperation } from 'fast-json-patch';
|
|
||||||
import { NoContent } from '../../../shared/NoContent.model';
|
import { NoContent } from '../../../shared/NoContent.model';
|
||||||
import {CoreState} from '../../../core-state.model';
|
import { FindListOptions } from '../../../data/find-list-options.model';
|
||||||
import {FindListOptions} from '../../../data/find-list-options.model';
|
import { IdentifiableDataService } from '../../../data/base/identifiable-data.service';
|
||||||
|
import { CreateData, CreateDataImpl } from '../../../data/base/create-data';
|
||||||
|
import { PatchData, PatchDataImpl } from '../../../data/base/patch-data';
|
||||||
/**
|
import { DeleteData, DeleteDataImpl } from '../../../data/base/delete-data';
|
||||||
* A private DataService implementation to delegate specific methods to.
|
import { SearchData, SearchDataImpl } from '../../../data/base/search-data';
|
||||||
*/
|
import { DefaultChangeAnalyzer } from '../../../data/default-change-analyzer.service';
|
||||||
class DataServiceImpl extends DataService<QualityAssuranceEventObject> {
|
import { hasValue } from '../../../../shared/empty.util';
|
||||||
/**
|
import { DeleteByIDRequest, PostRequest } from '../../../data/request.models';
|
||||||
* The REST endpoint.
|
|
||||||
*/
|
|
||||||
protected linkPath = 'qualityassuranceevents';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initialize service variables
|
|
||||||
* @param {RequestService} requestService
|
|
||||||
* @param {RemoteDataBuildService} rdbService
|
|
||||||
* @param {Store<CoreState>} store
|
|
||||||
* @param {ObjectCacheService} objectCache
|
|
||||||
* @param {HALEndpointService} halService
|
|
||||||
* @param {NotificationsService} notificationsService
|
|
||||||
* @param {HttpClient} http
|
|
||||||
* @param {ChangeAnalyzer<QualityAssuranceEventObject>} comparator
|
|
||||||
*/
|
|
||||||
constructor(
|
|
||||||
protected requestService: RequestService,
|
|
||||||
protected rdbService: RemoteDataBuildService,
|
|
||||||
protected store: Store<CoreState>,
|
|
||||||
protected objectCache: ObjectCacheService,
|
|
||||||
protected halService: HALEndpointService,
|
|
||||||
protected notificationsService: NotificationsService,
|
|
||||||
protected http: HttpClient,
|
|
||||||
protected comparator: ChangeAnalyzer<QualityAssuranceEventObject>) {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The service handling all Quality Assurance topic REST requests.
|
* The service handling all Quality Assurance topic REST requests.
|
||||||
*/
|
*/
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@dataService(QUALITY_ASSURANCE_EVENT_OBJECT)
|
@dataService(QUALITY_ASSURANCE_EVENT_OBJECT)
|
||||||
export class QualityAssuranceEventRestService {
|
export class QualityAssuranceEventRestService extends IdentifiableDataService<QualityAssuranceEventObject> {
|
||||||
/**
|
|
||||||
* A private DataService implementation to delegate specific methods to.
|
private createData: CreateData<QualityAssuranceEventObject>;
|
||||||
*/
|
private searchData: SearchData<QualityAssuranceEventObject>;
|
||||||
private dataService: DataServiceImpl;
|
private patchData: PatchData<QualityAssuranceEventObject>;
|
||||||
|
private deleteData: DeleteData<QualityAssuranceEventObject>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize service variables
|
* Initialize service variables
|
||||||
@@ -76,7 +45,6 @@ export class QualityAssuranceEventRestService {
|
|||||||
* @param {ObjectCacheService} objectCache
|
* @param {ObjectCacheService} objectCache
|
||||||
* @param {HALEndpointService} halService
|
* @param {HALEndpointService} halService
|
||||||
* @param {NotificationsService} notificationsService
|
* @param {NotificationsService} notificationsService
|
||||||
* @param {HttpClient} http
|
|
||||||
* @param {DefaultChangeAnalyzer<QualityAssuranceEventObject>} comparator
|
* @param {DefaultChangeAnalyzer<QualityAssuranceEventObject>} comparator
|
||||||
*/
|
*/
|
||||||
constructor(
|
constructor(
|
||||||
@@ -85,9 +53,13 @@ export class QualityAssuranceEventRestService {
|
|||||||
protected objectCache: ObjectCacheService,
|
protected objectCache: ObjectCacheService,
|
||||||
protected halService: HALEndpointService,
|
protected halService: HALEndpointService,
|
||||||
protected notificationsService: NotificationsService,
|
protected notificationsService: NotificationsService,
|
||||||
protected http: HttpClient,
|
protected comparator: DefaultChangeAnalyzer<QualityAssuranceEventObject>
|
||||||
protected comparator: DefaultChangeAnalyzer<QualityAssuranceEventObject>) {
|
) {
|
||||||
this.dataService = new DataServiceImpl(requestService, rdbService, null, objectCache, halService, notificationsService, http, comparator);
|
super('qualityassuranceevents', requestService, rdbService, objectCache, halService);
|
||||||
|
this.createData = new CreateDataImpl(this.linkPath, requestService, rdbService, objectCache, halService, notificationsService, this.responseMsToLive);
|
||||||
|
this.deleteData = new DeleteDataImpl(this.linkPath, requestService, rdbService, objectCache, halService, notificationsService, this.responseMsToLive, this.constructIdEndpoint);
|
||||||
|
this.patchData = new PatchDataImpl<QualityAssuranceEventObject>(this.linkPath, requestService, rdbService, objectCache, halService, comparator, this.responseMsToLive, this.constructIdEndpoint);
|
||||||
|
this.searchData = new SearchDataImpl(this.linkPath, requestService, rdbService, objectCache, halService, this.responseMsToLive);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -109,14 +81,14 @@ export class QualityAssuranceEventRestService {
|
|||||||
fieldValue: topic
|
fieldValue: topic
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
return this.dataService.searchBy('findByTopic', options, true, true, ...linksToFollow);
|
return this.searchData.searchBy('findByTopic', options, true, true, ...linksToFollow);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clear findByTopic requests from cache
|
* Clear findByTopic requests from cache
|
||||||
*/
|
*/
|
||||||
public clearFindByTopicRequests() {
|
public clearFindByTopicRequests() {
|
||||||
this.requestService.removeByHrefSubstring('findByTopic');
|
this.requestService.setStaleByHrefSubstring('findByTopic');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -130,7 +102,7 @@ export class QualityAssuranceEventRestService {
|
|||||||
* The Quality Assurance event.
|
* The Quality Assurance event.
|
||||||
*/
|
*/
|
||||||
public getEvent(id: string, ...linksToFollow: FollowLinkConfig<QualityAssuranceEventObject>[]): Observable<RemoteData<QualityAssuranceEventObject>> {
|
public getEvent(id: string, ...linksToFollow: FollowLinkConfig<QualityAssuranceEventObject>[]): Observable<RemoteData<QualityAssuranceEventObject>> {
|
||||||
return this.dataService.findById(id, true, true, ...linksToFollow);
|
return this.findById(id, true, true, ...linksToFollow);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -153,7 +125,7 @@ export class QualityAssuranceEventRestService {
|
|||||||
value: status
|
value: status
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
return this.dataService.patch(dso, operation);
|
return this.patchData.patch(dso, operation);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -167,7 +139,7 @@ export class QualityAssuranceEventRestService {
|
|||||||
* The REST response.
|
* The REST response.
|
||||||
*/
|
*/
|
||||||
public boundProject(itemId: string, projectId: string): Observable<RemoteData<QualityAssuranceEventObject>> {
|
public boundProject(itemId: string, projectId: string): Observable<RemoteData<QualityAssuranceEventObject>> {
|
||||||
return this.dataService.postOnRelated(itemId, projectId);
|
return this.postOnRelated(itemId, projectId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -179,6 +151,53 @@ export class QualityAssuranceEventRestService {
|
|||||||
* The REST response.
|
* The REST response.
|
||||||
*/
|
*/
|
||||||
public removeProject(itemId: string): Observable<RemoteData<NoContent>> {
|
public removeProject(itemId: string): Observable<RemoteData<NoContent>> {
|
||||||
return this.dataService.deleteOnRelated(itemId);
|
return this.deleteOnRelated(itemId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Perform a delete operation on an endpoint related item. Ex.: endpoint/<itemId>/related
|
||||||
|
* @param objectId The item id
|
||||||
|
* @return the RestResponse as an Observable
|
||||||
|
*/
|
||||||
|
private deleteOnRelated(objectId: string): Observable<RemoteData<NoContent>> {
|
||||||
|
const requestId = this.requestService.generateRequestId();
|
||||||
|
|
||||||
|
const hrefObs = this.getIDHrefObs(objectId);
|
||||||
|
|
||||||
|
hrefObs.pipe(
|
||||||
|
find((href: string) => hasValue(href)),
|
||||||
|
).subscribe((href: string) => {
|
||||||
|
const request = new DeleteByIDRequest(requestId, href + '/related', objectId);
|
||||||
|
if (hasValue(this.responseMsToLive)) {
|
||||||
|
request.responseMsToLive = this.responseMsToLive;
|
||||||
|
}
|
||||||
|
this.requestService.send(request);
|
||||||
|
});
|
||||||
|
|
||||||
|
return this.rdbService.buildFromRequestUUID<QualityAssuranceEventObject>(requestId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Perform a post on an endpoint related item with ID. Ex.: endpoint/<itemId>/related?item=<relatedItemId>
|
||||||
|
* @param objectId The item id
|
||||||
|
* @param relatedItemId The related item Id
|
||||||
|
* @param body The optional POST body
|
||||||
|
* @return the RestResponse as an Observable
|
||||||
|
*/
|
||||||
|
private postOnRelated(objectId: string, relatedItemId: string, body?: any) {
|
||||||
|
const requestId = this.requestService.generateRequestId();
|
||||||
|
const hrefObs = this.getIDHrefObs(objectId);
|
||||||
|
|
||||||
|
hrefObs.pipe(
|
||||||
|
take(1)
|
||||||
|
).subscribe((href: string) => {
|
||||||
|
const request = new PostRequest(requestId, href + '/related?item=' + relatedItemId, body);
|
||||||
|
if (hasValue(this.responseMsToLive)) {
|
||||||
|
request.responseMsToLive = this.responseMsToLive;
|
||||||
|
}
|
||||||
|
this.requestService.send(request);
|
||||||
|
});
|
||||||
|
|
||||||
|
return this.rdbService.buildFromRequestUUID<QualityAssuranceEventObject>(requestId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -17,8 +17,8 @@ import {
|
|||||||
qualityAssuranceSourceObjectMoreAbstract,
|
qualityAssuranceSourceObjectMoreAbstract,
|
||||||
qualityAssuranceSourceObjectMorePid
|
qualityAssuranceSourceObjectMorePid
|
||||||
} from '../../../../shared/mocks/notifications.mock';
|
} from '../../../../shared/mocks/notifications.mock';
|
||||||
import {RequestEntry} from '../../../data/request-entry.model';
|
import { RequestEntry } from '../../../data/request-entry.model';
|
||||||
import {QualityAssuranceSourceRestService} from './quality-assurance-source-rest.service';
|
import { QualityAssuranceSourceRestService } from './quality-assurance-source-rest.service';
|
||||||
|
|
||||||
describe('QualityAssuranceSourceRestService', () => {
|
describe('QualityAssuranceSourceRestService', () => {
|
||||||
let scheduler: TestScheduler;
|
let scheduler: TestScheduler;
|
||||||
@@ -36,7 +36,7 @@ describe('QualityAssuranceSourceRestService', () => {
|
|||||||
const requestUUID = '8b3c913a-5a4b-438b-9181-be1a5b4a1c8a';
|
const requestUUID = '8b3c913a-5a4b-438b-9181-be1a5b4a1c8a';
|
||||||
|
|
||||||
const pageInfo = new PageInfo();
|
const pageInfo = new PageInfo();
|
||||||
const array = [ qualityAssuranceSourceObjectMorePid, qualityAssuranceSourceObjectMoreAbstract ];
|
const array = [qualityAssuranceSourceObjectMorePid, qualityAssuranceSourceObjectMoreAbstract];
|
||||||
const paginatedList = buildPaginatedList(pageInfo, array);
|
const paginatedList = buildPaginatedList(pageInfo, array);
|
||||||
const qaSourceObjectRD = createSuccessfulRemoteDataObject(qualityAssuranceSourceObjectMorePid);
|
const qaSourceObjectRD = createSuccessfulRemoteDataObject(qualityAssuranceSourceObjectMorePid);
|
||||||
const paginatedListRD = createSuccessfulRemoteDataObject(paginatedList);
|
const paginatedListRD = createSuccessfulRemoteDataObject(paginatedList);
|
||||||
@@ -65,7 +65,7 @@ describe('QualityAssuranceSourceRestService', () => {
|
|||||||
|
|
||||||
objectCache = {} as ObjectCacheService;
|
objectCache = {} as ObjectCacheService;
|
||||||
halService = jasmine.createSpyObj('halService', {
|
halService = jasmine.createSpyObj('halService', {
|
||||||
getEndpoint: cold('a|', { a: endpointURL })
|
getEndpoint: cold('a|', { a: endpointURL })
|
||||||
});
|
});
|
||||||
|
|
||||||
notificationsService = {} as NotificationsService;
|
notificationsService = {} as NotificationsService;
|
||||||
@@ -77,20 +77,18 @@ describe('QualityAssuranceSourceRestService', () => {
|
|||||||
rdbService,
|
rdbService,
|
||||||
objectCache,
|
objectCache,
|
||||||
halService,
|
halService,
|
||||||
notificationsService,
|
notificationsService
|
||||||
http,
|
|
||||||
comparator
|
|
||||||
);
|
);
|
||||||
|
|
||||||
spyOn((service as any).dataService, 'findAllByHref').and.callThrough();
|
spyOn((service as any), 'findListByHref').and.callThrough();
|
||||||
spyOn((service as any).dataService, 'findByHref').and.callThrough();
|
spyOn((service as any), 'findByHref').and.callThrough();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('getSources', () => {
|
describe('getSources', () => {
|
||||||
it('should proxy the call to dataservice.findAllByHref', (done) => {
|
it('should call findListByHref', (done) => {
|
||||||
service.getSources().subscribe(
|
service.getSources().subscribe(
|
||||||
(res) => {
|
(res) => {
|
||||||
expect((service as any).dataService.findAllByHref).toHaveBeenCalledWith(endpointURL, {}, true, true);
|
expect((service as any).findListByHref).toHaveBeenCalledWith(endpointURL, {}, true, true);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
done();
|
done();
|
||||||
@@ -106,10 +104,10 @@ describe('QualityAssuranceSourceRestService', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('getSource', () => {
|
describe('getSource', () => {
|
||||||
it('should proxy the call to dataservice.findByHref', (done) => {
|
it('should call findByHref', (done) => {
|
||||||
service.getSource(qualityAssuranceSourceObjectMorePid.id).subscribe(
|
service.getSource(qualityAssuranceSourceObjectMorePid.id).subscribe(
|
||||||
(res) => {
|
(res) => {
|
||||||
expect((service as any).dataService.findByHref).toHaveBeenCalledWith(endpointURL + '/' + qualityAssuranceSourceObjectMorePid.id, true, true);
|
expect((service as any).findByHref).toHaveBeenCalledWith(endpointURL + '/' + qualityAssuranceSourceObjectMorePid.id, true, true);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
done();
|
done();
|
||||||
|
@@ -1,7 +1,5 @@
|
|||||||
/* eslint-disable max-classes-per-file */
|
/* eslint-disable max-classes-per-file */
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { HttpClient } from '@angular/common/http';
|
|
||||||
import { Store } from '@ngrx/store';
|
|
||||||
|
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
import { mergeMap, take } from 'rxjs/operators';
|
import { mergeMap, take } from 'rxjs/operators';
|
||||||
@@ -10,62 +8,22 @@ import { HALEndpointService } from '../../../shared/hal-endpoint.service';
|
|||||||
import { NotificationsService } from '../../../../shared/notifications/notifications.service';
|
import { NotificationsService } from '../../../../shared/notifications/notifications.service';
|
||||||
import { RemoteDataBuildService } from '../../../cache/builders/remote-data-build.service';
|
import { RemoteDataBuildService } from '../../../cache/builders/remote-data-build.service';
|
||||||
import { ObjectCacheService } from '../../../cache/object-cache.service';
|
import { ObjectCacheService } from '../../../cache/object-cache.service';
|
||||||
import { dataService } from '../../../cache/builders/build-decorators';
|
import { dataService } from '../../../data/base/data-service.decorator';
|
||||||
import { RequestService } from '../../../data/request.service';
|
import { RequestService } from '../../../data/request.service';
|
||||||
import { DataService } from '../../../data/data.service';
|
|
||||||
import { ChangeAnalyzer } from '../../../data/change-analyzer';
|
|
||||||
import { DefaultChangeAnalyzer } from '../../../data/default-change-analyzer.service';
|
|
||||||
import { RemoteData } from '../../../data/remote-data';
|
import { RemoteData } from '../../../data/remote-data';
|
||||||
import { QualityAssuranceSourceObject } from '../models/quality-assurance-source.model';
|
import { QualityAssuranceSourceObject } from '../models/quality-assurance-source.model';
|
||||||
import { QUALITY_ASSURANCE_SOURCE_OBJECT } from '../models/quality-assurance-source-object.resource-type';
|
import { QUALITY_ASSURANCE_SOURCE_OBJECT } from '../models/quality-assurance-source-object.resource-type';
|
||||||
import { FollowLinkConfig } from '../../../../shared/utils/follow-link-config.model';
|
import { FollowLinkConfig } from '../../../../shared/utils/follow-link-config.model';
|
||||||
import { PaginatedList } from '../../../data/paginated-list.model';
|
import { PaginatedList } from '../../../data/paginated-list.model';
|
||||||
import {CoreState} from '../../../core-state.model';
|
import { FindListOptions } from '../../../data/find-list-options.model';
|
||||||
import {FindListOptions} from '../../../data/find-list-options.model';
|
import { IdentifiableDataService } from '../../../data/base/identifiable-data.service';
|
||||||
|
|
||||||
/**
|
|
||||||
* A private DataService implementation to delegate specific methods to.
|
|
||||||
*/
|
|
||||||
class DataServiceImpl extends DataService<QualityAssuranceSourceObject> {
|
|
||||||
/**
|
|
||||||
* The REST endpoint.
|
|
||||||
*/
|
|
||||||
protected linkPath = 'qualityassurancesources';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initialize service variables
|
|
||||||
* @param {RequestService} requestService
|
|
||||||
* @param {RemoteDataBuildService} rdbService
|
|
||||||
* @param {Store<CoreState>} store
|
|
||||||
* @param {ObjectCacheService} objectCache
|
|
||||||
* @param {HALEndpointService} halService
|
|
||||||
* @param {NotificationsService} notificationsService
|
|
||||||
* @param {HttpClient} http
|
|
||||||
* @param {ChangeAnalyzer<QualityAssuranceSourceObject>} comparator
|
|
||||||
*/
|
|
||||||
constructor(
|
|
||||||
protected requestService: RequestService,
|
|
||||||
protected rdbService: RemoteDataBuildService,
|
|
||||||
protected store: Store<CoreState>,
|
|
||||||
protected objectCache: ObjectCacheService,
|
|
||||||
protected halService: HALEndpointService,
|
|
||||||
protected notificationsService: NotificationsService,
|
|
||||||
protected http: HttpClient,
|
|
||||||
protected comparator: ChangeAnalyzer<QualityAssuranceSourceObject>) {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The service handling all Quality Assurance source REST requests.
|
* The service handling all Quality Assurance source REST requests.
|
||||||
*/
|
*/
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@dataService(QUALITY_ASSURANCE_SOURCE_OBJECT)
|
@dataService(QUALITY_ASSURANCE_SOURCE_OBJECT)
|
||||||
export class QualityAssuranceSourceRestService {
|
export class QualityAssuranceSourceRestService extends IdentifiableDataService<QualityAssuranceSourceObject> {
|
||||||
/**
|
|
||||||
* A private DataService implementation to delegate specific methods to.
|
|
||||||
*/
|
|
||||||
private dataService: DataServiceImpl;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize service variables
|
* Initialize service variables
|
||||||
@@ -74,18 +32,15 @@ export class QualityAssuranceSourceRestService {
|
|||||||
* @param {ObjectCacheService} objectCache
|
* @param {ObjectCacheService} objectCache
|
||||||
* @param {HALEndpointService} halService
|
* @param {HALEndpointService} halService
|
||||||
* @param {NotificationsService} notificationsService
|
* @param {NotificationsService} notificationsService
|
||||||
* @param {HttpClient} http
|
|
||||||
* @param {DefaultChangeAnalyzer<QualityAssuranceSourceObject>} comparator
|
|
||||||
*/
|
*/
|
||||||
constructor(
|
constructor(
|
||||||
protected requestService: RequestService,
|
protected requestService: RequestService,
|
||||||
protected rdbService: RemoteDataBuildService,
|
protected rdbService: RemoteDataBuildService,
|
||||||
protected objectCache: ObjectCacheService,
|
protected objectCache: ObjectCacheService,
|
||||||
protected halService: HALEndpointService,
|
protected halService: HALEndpointService,
|
||||||
protected notificationsService: NotificationsService,
|
protected notificationsService: NotificationsService
|
||||||
protected http: HttpClient,
|
) {
|
||||||
protected comparator: DefaultChangeAnalyzer<QualityAssuranceSourceObject>) {
|
super('qualityassurancesources', requestService, rdbService, objectCache, halService);
|
||||||
this.dataService = new DataServiceImpl(requestService, rdbService, null, objectCache, halService, notificationsService, http, comparator);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -99,9 +54,9 @@ export class QualityAssuranceSourceRestService {
|
|||||||
* The list of Quality Assurance source.
|
* The list of Quality Assurance source.
|
||||||
*/
|
*/
|
||||||
public getSources(options: FindListOptions = {}, ...linksToFollow: FollowLinkConfig<QualityAssuranceSourceObject>[]): Observable<RemoteData<PaginatedList<QualityAssuranceSourceObject>>> {
|
public getSources(options: FindListOptions = {}, ...linksToFollow: FollowLinkConfig<QualityAssuranceSourceObject>[]): Observable<RemoteData<PaginatedList<QualityAssuranceSourceObject>>> {
|
||||||
return this.dataService.getBrowseEndpoint(options, 'qualityassurancesources').pipe(
|
return this.getBrowseEndpoint(options).pipe(
|
||||||
take(1),
|
take(1),
|
||||||
mergeMap((href: string) => this.dataService.findAllByHref(href, options, true, true, ...linksToFollow)),
|
mergeMap((href: string) => this.findListByHref(href, options, true, true, ...linksToFollow)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -124,9 +79,9 @@ export class QualityAssuranceSourceRestService {
|
|||||||
*/
|
*/
|
||||||
public getSource(id: string, ...linksToFollow: FollowLinkConfig<QualityAssuranceSourceObject>[]): Observable<RemoteData<QualityAssuranceSourceObject>> {
|
public getSource(id: string, ...linksToFollow: FollowLinkConfig<QualityAssuranceSourceObject>[]): Observable<RemoteData<QualityAssuranceSourceObject>> {
|
||||||
const options = {};
|
const options = {};
|
||||||
return this.dataService.getBrowseEndpoint(options, 'qualityassurancesources').pipe(
|
return this.getBrowseEndpoint(options, 'qualityassurancesources').pipe(
|
||||||
take(1),
|
take(1),
|
||||||
mergeMap((href: string) => this.dataService.findByHref(href + '/' + id, true, true, ...linksToFollow))
|
mergeMap((href: string) => this.findByHref(href + '/' + id, true, true, ...linksToFollow))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -18,7 +18,7 @@ import {
|
|||||||
qualityAssuranceTopicObjectMoreAbstract,
|
qualityAssuranceTopicObjectMoreAbstract,
|
||||||
qualityAssuranceTopicObjectMorePid
|
qualityAssuranceTopicObjectMorePid
|
||||||
} from '../../../../shared/mocks/notifications.mock';
|
} from '../../../../shared/mocks/notifications.mock';
|
||||||
import {RequestEntry} from '../../../data/request-entry.model';
|
import { RequestEntry } from '../../../data/request-entry.model';
|
||||||
|
|
||||||
describe('QualityAssuranceTopicRestService', () => {
|
describe('QualityAssuranceTopicRestService', () => {
|
||||||
let scheduler: TestScheduler;
|
let scheduler: TestScheduler;
|
||||||
@@ -36,7 +36,7 @@ describe('QualityAssuranceTopicRestService', () => {
|
|||||||
const requestUUID = '8b3c913a-5a4b-438b-9181-be1a5b4a1c8a';
|
const requestUUID = '8b3c913a-5a4b-438b-9181-be1a5b4a1c8a';
|
||||||
|
|
||||||
const pageInfo = new PageInfo();
|
const pageInfo = new PageInfo();
|
||||||
const array = [ qualityAssuranceTopicObjectMorePid, qualityAssuranceTopicObjectMoreAbstract ];
|
const array = [qualityAssuranceTopicObjectMorePid, qualityAssuranceTopicObjectMoreAbstract];
|
||||||
const paginatedList = buildPaginatedList(pageInfo, array);
|
const paginatedList = buildPaginatedList(pageInfo, array);
|
||||||
const qaTopicObjectRD = createSuccessfulRemoteDataObject(qualityAssuranceTopicObjectMorePid);
|
const qaTopicObjectRD = createSuccessfulRemoteDataObject(qualityAssuranceTopicObjectMorePid);
|
||||||
const paginatedListRD = createSuccessfulRemoteDataObject(paginatedList);
|
const paginatedListRD = createSuccessfulRemoteDataObject(paginatedList);
|
||||||
@@ -65,7 +65,7 @@ describe('QualityAssuranceTopicRestService', () => {
|
|||||||
|
|
||||||
objectCache = {} as ObjectCacheService;
|
objectCache = {} as ObjectCacheService;
|
||||||
halService = jasmine.createSpyObj('halService', {
|
halService = jasmine.createSpyObj('halService', {
|
||||||
getEndpoint: cold('a|', { a: endpointURL })
|
getEndpoint: cold('a|', { a: endpointURL })
|
||||||
});
|
});
|
||||||
|
|
||||||
notificationsService = {} as NotificationsService;
|
notificationsService = {} as NotificationsService;
|
||||||
@@ -77,20 +77,18 @@ describe('QualityAssuranceTopicRestService', () => {
|
|||||||
rdbService,
|
rdbService,
|
||||||
objectCache,
|
objectCache,
|
||||||
halService,
|
halService,
|
||||||
notificationsService,
|
notificationsService
|
||||||
http,
|
|
||||||
comparator
|
|
||||||
);
|
);
|
||||||
|
|
||||||
spyOn((service as any).dataService, 'findAllByHref').and.callThrough();
|
spyOn((service as any), 'findListByHref').and.callThrough();
|
||||||
spyOn((service as any).dataService, 'findByHref').and.callThrough();
|
spyOn((service as any), 'findByHref').and.callThrough();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('getTopics', () => {
|
describe('getTopics', () => {
|
||||||
it('should proxy the call to dataservice.findAllByHref', (done) => {
|
it('should call findListByHref', (done) => {
|
||||||
service.getTopics().subscribe(
|
service.getTopics().subscribe(
|
||||||
(res) => {
|
(res) => {
|
||||||
expect((service as any).dataService.findAllByHref).toHaveBeenCalledWith(endpointURL, {}, true, true);
|
expect((service as any).findListByHref).toHaveBeenCalledWith(endpointURL, {}, true, true);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
done();
|
done();
|
||||||
@@ -106,10 +104,10 @@ describe('QualityAssuranceTopicRestService', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('getTopic', () => {
|
describe('getTopic', () => {
|
||||||
it('should proxy the call to dataservice.findByHref', (done) => {
|
it('should call findByHref', (done) => {
|
||||||
service.getTopic(qualityAssuranceTopicObjectMorePid.id).subscribe(
|
service.getTopic(qualityAssuranceTopicObjectMorePid.id).subscribe(
|
||||||
(res) => {
|
(res) => {
|
||||||
expect((service as any).dataService.findByHref).toHaveBeenCalledWith(endpointURL + '/' + qualityAssuranceTopicObjectMorePid.id, true, true);
|
expect((service as any).findByHref).toHaveBeenCalledWith(endpointURL + '/' + qualityAssuranceTopicObjectMorePid.id, true, true);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
done();
|
done();
|
||||||
|
@@ -1,7 +1,4 @@
|
|||||||
/* eslint-disable max-classes-per-file */
|
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { HttpClient } from '@angular/common/http';
|
|
||||||
import { Store } from '@ngrx/store';
|
|
||||||
|
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
import { mergeMap, take } from 'rxjs/operators';
|
import { mergeMap, take } from 'rxjs/operators';
|
||||||
@@ -10,62 +7,22 @@ import { HALEndpointService } from '../../../shared/hal-endpoint.service';
|
|||||||
import { NotificationsService } from '../../../../shared/notifications/notifications.service';
|
import { NotificationsService } from '../../../../shared/notifications/notifications.service';
|
||||||
import { RemoteDataBuildService } from '../../../cache/builders/remote-data-build.service';
|
import { RemoteDataBuildService } from '../../../cache/builders/remote-data-build.service';
|
||||||
import { ObjectCacheService } from '../../../cache/object-cache.service';
|
import { ObjectCacheService } from '../../../cache/object-cache.service';
|
||||||
import { dataService } from '../../../cache/builders/build-decorators';
|
|
||||||
import { RequestService } from '../../../data/request.service';
|
import { RequestService } from '../../../data/request.service';
|
||||||
import { DataService } from '../../../data/data.service';
|
|
||||||
import { ChangeAnalyzer } from '../../../data/change-analyzer';
|
|
||||||
import { DefaultChangeAnalyzer } from '../../../data/default-change-analyzer.service';
|
|
||||||
import { RemoteData } from '../../../data/remote-data';
|
import { RemoteData } from '../../../data/remote-data';
|
||||||
import { QualityAssuranceTopicObject } from '../models/quality-assurance-topic.model';
|
import { QualityAssuranceTopicObject } from '../models/quality-assurance-topic.model';
|
||||||
import { QUALITY_ASSURANCE_TOPIC_OBJECT } from '../models/quality-assurance-topic-object.resource-type';
|
|
||||||
import { FollowLinkConfig } from '../../../../shared/utils/follow-link-config.model';
|
import { FollowLinkConfig } from '../../../../shared/utils/follow-link-config.model';
|
||||||
import { PaginatedList } from '../../../data/paginated-list.model';
|
import { PaginatedList } from '../../../data/paginated-list.model';
|
||||||
import {CoreState} from '../../../core-state.model';
|
import { FindListOptions } from '../../../data/find-list-options.model';
|
||||||
import {FindListOptions} from '../../../data/find-list-options.model';
|
import { IdentifiableDataService } from '../../../data/base/identifiable-data.service';
|
||||||
|
import { dataService } from '../../../data/base/data-service.decorator';
|
||||||
/**
|
import { QUALITY_ASSURANCE_TOPIC_OBJECT } from '../models/quality-assurance-topic-object.resource-type';
|
||||||
* A private DataService implementation to delegate specific methods to.
|
|
||||||
*/
|
|
||||||
class DataServiceImpl extends DataService<QualityAssuranceTopicObject> {
|
|
||||||
/**
|
|
||||||
* The REST endpoint.
|
|
||||||
*/
|
|
||||||
protected linkPath = 'qualityassurancetopics';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initialize service variables
|
|
||||||
* @param {RequestService} requestService
|
|
||||||
* @param {RemoteDataBuildService} rdbService
|
|
||||||
* @param {Store<CoreState>} store
|
|
||||||
* @param {ObjectCacheService} objectCache
|
|
||||||
* @param {HALEndpointService} halService
|
|
||||||
* @param {NotificationsService} notificationsService
|
|
||||||
* @param {HttpClient} http
|
|
||||||
* @param {ChangeAnalyzer<QualityAssuranceTopicObject>} comparator
|
|
||||||
*/
|
|
||||||
constructor(
|
|
||||||
protected requestService: RequestService,
|
|
||||||
protected rdbService: RemoteDataBuildService,
|
|
||||||
protected store: Store<CoreState>,
|
|
||||||
protected objectCache: ObjectCacheService,
|
|
||||||
protected halService: HALEndpointService,
|
|
||||||
protected notificationsService: NotificationsService,
|
|
||||||
protected http: HttpClient,
|
|
||||||
protected comparator: ChangeAnalyzer<QualityAssuranceTopicObject>) {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The service handling all Quality Assurance topic REST requests.
|
* The service handling all Quality Assurance topic REST requests.
|
||||||
*/
|
*/
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@dataService(QUALITY_ASSURANCE_TOPIC_OBJECT)
|
@dataService(QUALITY_ASSURANCE_TOPIC_OBJECT)
|
||||||
export class QualityAssuranceTopicRestService {
|
export class QualityAssuranceTopicRestService extends IdentifiableDataService<QualityAssuranceTopicObject> {
|
||||||
/**
|
|
||||||
* A private DataService implementation to delegate specific methods to.
|
|
||||||
*/
|
|
||||||
private dataService: DataServiceImpl;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize service variables
|
* Initialize service variables
|
||||||
@@ -74,18 +31,15 @@ export class QualityAssuranceTopicRestService {
|
|||||||
* @param {ObjectCacheService} objectCache
|
* @param {ObjectCacheService} objectCache
|
||||||
* @param {HALEndpointService} halService
|
* @param {HALEndpointService} halService
|
||||||
* @param {NotificationsService} notificationsService
|
* @param {NotificationsService} notificationsService
|
||||||
* @param {HttpClient} http
|
|
||||||
* @param {DefaultChangeAnalyzer<QualityAssuranceTopicObject>} comparator
|
|
||||||
*/
|
*/
|
||||||
constructor(
|
constructor(
|
||||||
protected requestService: RequestService,
|
protected requestService: RequestService,
|
||||||
protected rdbService: RemoteDataBuildService,
|
protected rdbService: RemoteDataBuildService,
|
||||||
protected objectCache: ObjectCacheService,
|
protected objectCache: ObjectCacheService,
|
||||||
protected halService: HALEndpointService,
|
protected halService: HALEndpointService,
|
||||||
protected notificationsService: NotificationsService,
|
protected notificationsService: NotificationsService
|
||||||
protected http: HttpClient,
|
) {
|
||||||
protected comparator: DefaultChangeAnalyzer<QualityAssuranceTopicObject>) {
|
super('qualityassurancetopics', requestService, rdbService, objectCache, halService);
|
||||||
this.dataService = new DataServiceImpl(requestService, rdbService, null, objectCache, halService, notificationsService, http, comparator);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -99,9 +53,9 @@ export class QualityAssuranceTopicRestService {
|
|||||||
* The list of Quality Assurance topics.
|
* The list of Quality Assurance topics.
|
||||||
*/
|
*/
|
||||||
public getTopics(options: FindListOptions = {}, ...linksToFollow: FollowLinkConfig<QualityAssuranceTopicObject>[]): Observable<RemoteData<PaginatedList<QualityAssuranceTopicObject>>> {
|
public getTopics(options: FindListOptions = {}, ...linksToFollow: FollowLinkConfig<QualityAssuranceTopicObject>[]): Observable<RemoteData<PaginatedList<QualityAssuranceTopicObject>>> {
|
||||||
return this.dataService.getBrowseEndpoint(options, 'qualityassurancetopics').pipe(
|
return this.getBrowseEndpoint(options).pipe(
|
||||||
take(1),
|
take(1),
|
||||||
mergeMap((href: string) => this.dataService.findAllByHref(href, options, true, true, ...linksToFollow)),
|
mergeMap((href: string) => this.findListByHref(href, options, true, true, ...linksToFollow)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -124,9 +78,9 @@ export class QualityAssuranceTopicRestService {
|
|||||||
*/
|
*/
|
||||||
public getTopic(id: string, ...linksToFollow: FollowLinkConfig<QualityAssuranceTopicObject>[]): Observable<RemoteData<QualityAssuranceTopicObject>> {
|
public getTopic(id: string, ...linksToFollow: FollowLinkConfig<QualityAssuranceTopicObject>[]): Observable<RemoteData<QualityAssuranceTopicObject>> {
|
||||||
const options = {};
|
const options = {};
|
||||||
return this.dataService.getBrowseEndpoint(options, 'qualityassurancetopics').pipe(
|
return this.getBrowseEndpoint(options).pipe(
|
||||||
take(1),
|
take(1),
|
||||||
mergeMap((href: string) => this.dataService.findByHref(href + '/' + id, true, true, ...linksToFollow))
|
mergeMap((href: string) => this.findByHref(href + '/' + id, true, true, ...linksToFollow))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user