diff --git a/src/app/core/data/base/find-all-data.ts b/src/app/core/data/base/find-all-data.ts index c2330af243..57884e537e 100644 --- a/src/app/core/data/base/find-all-data.ts +++ b/src/app/core/data/base/find-all-data.ts @@ -39,17 +39,6 @@ export interface FindAllData { * Return an observable that emits object list */ findAll(options?: FindListOptions, useCachedVersionIfAvailable?: boolean, reRequestOnStale?: boolean, ...linksToFollow: FollowLinkConfig[]): Observable>>; - - /** - * Create the HREF with given options object - * - * @param options The [[FindListOptions]] object - * @param linkPath The link path for the object - * @return {Observable} - * Return an observable that emits created HREF - * @param linksToFollow List of {@link FollowLinkConfig} that indicate which {@link HALLink}s should be automatically resolved - */ - getFindAllHref?(options: FindListOptions, linkPath?: string, ...linksToFollow: FollowLinkConfig[]): Observable; } /** diff --git a/src/app/core/data/base/patch-data.ts b/src/app/core/data/base/patch-data.ts index 558de928c4..732f71636e 100644 --- a/src/app/core/data/base/patch-data.ts +++ b/src/app/core/data/base/patch-data.ts @@ -50,7 +50,7 @@ export interface PatchData { * Return a list of operations representing the difference between an object and its latest value in the cache. * @param object the object to resolve to a list of patch operations */ - createPatchFromCache?(object: T): Observable; + createPatchFromCache(object: T): Observable; } /** diff --git a/src/app/core/data/base/search-data.ts b/src/app/core/data/base/search-data.ts index ba8fac9888..751bff5c3a 100644 --- a/src/app/core/data/base/search-data.ts +++ b/src/app/core/data/base/search-data.ts @@ -48,17 +48,6 @@ export interface SearchData { * Return an observable that emits response from the server */ searchBy(searchMethod: string, options?: FindListOptions, useCachedVersionIfAvailable?: boolean, reRequestOnStale?: boolean, ...linksToFollow: FollowLinkConfig[]): Observable>>; - - /** - * Create the HREF for a specific object's search method with given options object - * - * @param searchMethod The search method for the object - * @param options The [[FindListOptions]] object - * @return {Observable} - * Return an observable that emits created HREF - * @param linksToFollow List of {@link FollowLinkConfig} that indicate which {@link HALLink}s should be automatically resolved - */ - getSearchByHref?(searchMethod: string, options?: FindListOptions, ...linksToFollow: FollowLinkConfig[]): Observable; } /** diff --git a/src/app/core/data/bitstream-data.service.ts b/src/app/core/data/bitstream-data.service.ts index 0e0c939d9e..6bdcefe187 100644 --- a/src/app/core/data/bitstream-data.service.ts +++ b/src/app/core/data/bitstream-data.service.ts @@ -33,6 +33,7 @@ import { NotificationsService } from '../../shared/notifications/notifications.s import { NoContent } from '../shared/NoContent.model'; import { IdentifiableDataService } from './base/identifiable-data.service'; import { dataService } from './base/data-service.decorator'; +import { Operation } from 'fast-json-patch'; /** * A service to retrieve {@link Bitstream}s from the REST API @@ -244,6 +245,14 @@ export class BitstreamDataService extends IdentifiableDataService imp return this.patchData.update(object); } + /** + * Return a list of operations representing the difference between an object and its latest value in the cache. + * @param object the object to resolve to a list of patch operations + */ + public createPatchFromCache(object: Bitstream): Observable { + return this.patchData.createPatchFromCache(object); + } + /** * Delete an existing object on the server * @param objectId The id of the object to be removed diff --git a/src/app/core/data/bundle-data.service.ts b/src/app/core/data/bundle-data.service.ts index e85c0c2bee..19f0e73706 100644 --- a/src/app/core/data/bundle-data.service.ts +++ b/src/app/core/data/bundle-data.service.ts @@ -167,4 +167,12 @@ export class BundleDataService extends IdentifiableDataService implement public update(object: Bundle): Observable> { return this.patchData.update(object); } + + /** + * Return a list of operations representing the difference between an object and its latest value in the cache. + * @param object the object to resolve to a list of patch operations + */ + public createPatchFromCache(object: Bundle): Observable { + return this.patchData.createPatchFromCache(object); + } } diff --git a/src/app/core/data/comcol-data.service.ts b/src/app/core/data/comcol-data.service.ts index 6392f389b6..abc9046cd0 100644 --- a/src/app/core/data/comcol-data.service.ts +++ b/src/app/core/data/comcol-data.service.ts @@ -28,6 +28,7 @@ import { RequestService } from './request.service'; import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service'; import { NotificationsService } from '../../shared/notifications/notifications.service'; import { DSOChangeAnalyzer } from './dso-change-analyzer.service'; +import { Operation } from 'fast-json-patch'; export abstract class ComColDataService extends IdentifiableDataService implements CreateData, FindAllData, SearchData, PatchData, DeleteData { private createData: CreateData; @@ -191,32 +192,6 @@ export abstract class ComColDataService extend return this.findAllData.findAll(options, useCachedVersionIfAvailable, reRequestOnStale, ...linksToFollow); } - /** - * Create the HREF with given options object - * - * @param options The [[FindListOptions]] object - * @param linkPath The link path for the object - * @return {Observable} - * Return an observable that emits created HREF - * @param linksToFollow List of {@link FollowLinkConfig} that indicate which {@link HALLink}s should be automatically resolved - */ - public getFindAllHref(options?: FindListOptions, linkPath?: string, ...linksToFollow: FollowLinkConfig[]): Observable { - return this.findAllData.getFindAllHref(options, linkPath, ...linksToFollow); - } - - /** - * Create the HREF for a specific object's search method with given options object - * - * @param searchMethod The search method for the object - * @param options The [[FindListOptions]] object - * @return {Observable} - * Return an observable that emits created HREF - * @param linksToFollow List of {@link FollowLinkConfig} that indicate which {@link HALLink}s should be automatically resolved - */ - public getSearchByHref(searchMethod: string, options?: FindListOptions, ...linksToFollow: FollowLinkConfig[]): Observable { - return this.searchData.getSearchByHref(searchMethod, options, ...linksToFollow); - } - /** * Make a new FindListRequest with given search method * @@ -261,6 +236,14 @@ export abstract class ComColDataService extend return this.patchData.update(object); } + /** + * Return a list of operations representing the difference between an object and its latest value in the cache. + * @param object the object to resolve to a list of patch operations + */ + public createPatchFromCache(object: T): Observable { + return this.patchData.createPatchFromCache(object); + } + /** * Delete an existing object on the server * @param objectId The id of the object to be removed diff --git a/src/app/core/data/community-data.service.ts b/src/app/core/data/community-data.service.ts index 8623d414b2..efb6d50e84 100644 --- a/src/app/core/data/community-data.service.ts +++ b/src/app/core/data/community-data.service.ts @@ -36,13 +36,16 @@ export class CommunityDataService extends ComColDataService { super('communities', requestService, rdbService, objectCache, halService, comparator, notificationsService, bitstreamDataService); } + // this method is overridden in order to make it public getEndpoint() { return this.halService.getEndpoint(this.linkPath); } findTop(options: FindListOptions = {}, ...linksToFollow: FollowLinkConfig[]): Observable>> { - const hrefObs = this.getFindAllHref(options, this.topLinkPath); - return this.findListByHref(hrefObs, undefined, true, true, ...linksToFollow); + return this.getEndpoint().pipe( + map(href => `${href}/search/top`), + switchMap(href => this.findListByHref(href, options, true, true, ...linksToFollow)) + ); } protected getFindByParentHref(parentUUID: string): Observable { diff --git a/src/app/core/data/item-data.service.ts b/src/app/core/data/item-data.service.ts index 11179d1e77..09268a0282 100644 --- a/src/app/core/data/item-data.service.ts +++ b/src/app/core/data/item-data.service.ts @@ -345,6 +345,14 @@ export abstract class BaseItemDataService extends IdentifiableDataService return this.patchData.update(object); } + /** + * Return a list of operations representing the difference between an object and its latest value in the cache. + * @param object the object to resolve to a list of patch operations + */ + public createPatchFromCache(object: Item): Observable { + return this.patchData.createPatchFromCache(object); + } + /** * Delete an existing object on the server * @param objectId The id of the object to be removed diff --git a/src/app/core/data/metadata-field-data.service.ts b/src/app/core/data/metadata-field-data.service.ts index db9361ee4c..d05e3533d3 100644 --- a/src/app/core/data/metadata-field-data.service.ts +++ b/src/app/core/data/metadata-field-data.service.ts @@ -165,19 +165,6 @@ export class MetadataFieldDataService extends IdentifiableDataService} - * Return an observable that emits created HREF - * @param linksToFollow List of {@link FollowLinkConfig} that indicate which {@link HALLink}s should be automatically resolved - */ - public getSearchByHref(searchMethod: string, options?: FindListOptions, ...linksToFollow: FollowLinkConfig[]): Observable { - return this.searchData.getSearchByHref(searchMethod, options, ...linksToFollow); - } - /** * Make a new FindListRequest with given search method * diff --git a/src/app/core/data/relationship-data.service.ts b/src/app/core/data/relationship-data.service.ts index cab6a1ae13..d14a609a96 100644 --- a/src/app/core/data/relationship-data.service.ts +++ b/src/app/core/data/relationship-data.service.ts @@ -546,17 +546,4 @@ export class RelationshipDataService extends IdentifiableDataService[]): Observable>> { return this.searchData.searchBy(searchMethod, options, useCachedVersionIfAvailable, reRequestOnStale, ...linksToFollow); } - - /** - * Create the HREF for a specific object's search method with given options object - * - * @param searchMethod The search method for the object - * @param options The [[FindListOptions]] object - * @return {Observable} - * Return an observable that emits created HREF - * @param linksToFollow List of {@link FollowLinkConfig} that indicate which {@link HALLink}s should be automatically resolved - */ - getSearchByHref(searchMethod: string, options: FindListOptions, ...linksToFollow: FollowLinkConfig[]): Observable { - return this.searchData.getSearchByHref(searchMethod, options, ...linksToFollow); - } } diff --git a/src/app/core/data/version-data.service.ts b/src/app/core/data/version-data.service.ts index ee7bdb2028..67c249fe0a 100644 --- a/src/app/core/data/version-data.service.ts +++ b/src/app/core/data/version-data.service.ts @@ -17,6 +17,7 @@ import { RestRequestMethod } from './rest-request-method'; import { DefaultChangeAnalyzer } from './default-change-analyzer.service'; import { IdentifiableDataService } from './base/identifiable-data.service'; import { dataService } from './base/data-service.decorator'; +import { Operation } from 'fast-json-patch'; /** * Service responsible for handling requests related to the Version object @@ -89,4 +90,13 @@ export class VersionDataService extends IdentifiableDataService impleme public commitUpdates(method?: RestRequestMethod): void { this.patchData.commitUpdates(method); } + + /** + * Return a list of operations representing the difference between an object and its latest value in the cache. + * @param object the object to resolve to a list of patch operations + */ + public createPatchFromCache(object: Version): Observable { + return this.patchData.createPatchFromCache(object); + } + } diff --git a/src/app/core/eperson/eperson-data.service.spec.ts b/src/app/core/eperson/eperson-data.service.spec.ts index aa07194992..ce0b1f3ee4 100644 --- a/src/app/core/eperson/eperson-data.service.spec.ts +++ b/src/app/core/eperson/eperson-data.service.spec.ts @@ -118,24 +118,24 @@ describe('EPersonDataService', () => { }); it('search email scope and no query', () => { - spyOn(service, 'getSearchByHref').and.returnValue(epersonsEndpoint); + spyOn((service as any).searchData, 'getSearchByHref').and.returnValue(epersonsEndpoint); spyOn(service, 'findByHref').and.returnValue(createSuccessfulRemoteDataObject$(null)); service.searchByScope('email', ''); const options = Object.assign(new FindListOptions(), { searchParams: [Object.assign(new RequestParam('email', encodeURIComponent('')))] }); - expect(service.getSearchByHref).toHaveBeenCalledWith('byEmail', options); + expect((service as any).searchData.getSearchByHref).toHaveBeenCalledWith('byEmail', options); expect(service.findByHref).toHaveBeenCalledWith(epersonsEndpoint, true, true); }); it('search email scope with a query', () => { - spyOn(service, 'getSearchByHref').and.returnValue(epersonsEndpoint); + spyOn((service as any).searchData, 'getSearchByHref').and.returnValue(epersonsEndpoint); spyOn(service, 'findByHref').and.returnValue(createSuccessfulRemoteDataObject$(EPersonMock)); service.searchByScope('email', EPersonMock.email); const options = Object.assign(new FindListOptions(), { searchParams: [Object.assign(new RequestParam('email', encodeURIComponent(EPersonMock.email)))] }); - expect(service.getSearchByHref).toHaveBeenCalledWith('byEmail', options); + expect((service as any).searchData.getSearchByHref).toHaveBeenCalledWith('byEmail', options); expect(service.findByHref).toHaveBeenCalledWith(epersonsEndpoint, true, true); }); }); diff --git a/src/app/core/eperson/eperson-data.service.ts b/src/app/core/eperson/eperson-data.service.ts index 2313d2b20e..8f9312d732 100644 --- a/src/app/core/eperson/eperson-data.service.ts +++ b/src/app/core/eperson/eperson-data.service.ts @@ -45,7 +45,7 @@ export class EPersonDataService extends IdentifiableDataService impleme protected searchByMetadataPath = 'byMetadata'; private createData: CreateData; - private searchData: SearchData; + private searchData: SearchDataImpl; private patchData: PatchData; private deleteData: DeleteData; @@ -128,7 +128,7 @@ export class EPersonDataService extends IdentifiableDataService impleme public getEPersonByEmail(query: string, useCachedVersionIfAvailable = true, reRequestOnStale = true, ...linksToFollow: FollowLinkConfig[]): Observable> { const findListOptions = new FindListOptions(); findListOptions.searchParams = [new RequestParam('email', encodeURIComponent(query))]; - const href$ = this.getSearchByHref(this.searchByEmailPath, findListOptions, ...linksToFollow); + const href$ = this.searchData.getSearchByHref(this.searchByEmailPath, findListOptions, ...linksToFollow); return this.findByHref(href$, useCachedVersionIfAvailable, reRequestOnStale, ...linksToFollow); } @@ -363,19 +363,6 @@ export class EPersonDataService extends IdentifiableDataService impleme return this.searchData.searchBy(searchMethod, options, useCachedVersionIfAvailable, reRequestOnStale, ...linksToFollow); } - /** - * Create the HREF for a specific object's search method with given options object - * - * @param searchMethod The search method for the object - * @param options The [[FindListOptions]] object - * @return {Observable} - * Return an observable that emits created HREF - * @param linksToFollow List of {@link FollowLinkConfig} that indicate which {@link HALLink}s should be automatically resolved - */ - getSearchByHref(searchMethod: string, options?: FindListOptions, ...linksToFollow: FollowLinkConfig[]): Observable { - return this.searchData.getSearchByHref(searchMethod, options, ...linksToFollow); - } - /** * Return a list of operations representing the difference between an object and its latest value in the cache. * @param object the object to resolve to a list of patch operations @@ -384,14 +371,28 @@ export class EPersonDataService extends IdentifiableDataService impleme return this.patchData.createPatchFromCache(object); } + /** + * Send a patch request for a specified object + * @param {T} object The object to send a patch request for + * @param {Operation[]} operations The patch operations to be performed + */ patch(object: EPerson, operations: Operation[]): Observable> { return this.patchData.patch(object, operations); } + /** + * Add a new patch to the object cache + * The patch is derived from the differences between the given object and its version in the object cache + * @param {DSpaceObject} object The given object + */ update(object: EPerson): Observable> { return this.patchData.update(object); } + /** + * Commit current object changes to the server + * @param method The RestRequestMethod for which de server sync buffer should be committed + */ commitUpdates(method?: RestRequestMethod): void { this.patchData.commitUpdates(method); } diff --git a/src/app/core/eperson/group-data.service.ts b/src/app/core/eperson/group-data.service.ts index 6e6d1fbb9b..2ea3ffeef3 100644 --- a/src/app/core/eperson/group-data.service.ts +++ b/src/app/core/eperson/group-data.service.ts @@ -342,15 +342,11 @@ export class GroupDataService extends IdentifiableDataService { return this.createData.create(object, ...params); } - // + searchBy(searchMethod: string, options?: FindListOptions, useCachedVersionIfAvailable?: boolean, reRequestOnStale?: boolean, ...linksToFollow: FollowLinkConfig[]): Observable>> { return this.searchData.searchBy(searchMethod, options, useCachedVersionIfAvailable, reRequestOnStale, ...linksToFollow); } - getSearchByHref(searchMethod: string, options?: FindListOptions, ...linksToFollow: FollowLinkConfig[]): Observable { - return this.searchData.getSearchByHref(searchMethod, options, ...linksToFollow); - } - public createPatchFromCache(object: Group): Observable { return this.patchData.createPatchFromCache(object); } diff --git a/src/app/core/submission/submission-cc-license-url-data.service.ts b/src/app/core/submission/submission-cc-license-url-data.service.ts index 3934ea7cb2..3d5dedb505 100644 --- a/src/app/core/submission/submission-cc-license-url-data.service.ts +++ b/src/app/core/submission/submission-cc-license-url-data.service.ts @@ -20,7 +20,7 @@ import { dataService } from '../data/base/data-service.decorator'; @Injectable() @dataService(SUBMISSION_CC_LICENSE_URL) export class SubmissionCcLicenseUrlDataService extends BaseDataService implements SearchData { - private searchData: SearchData; + private searchData: SearchDataImpl; constructor( protected requestService: RequestService, @@ -40,7 +40,7 @@ export class SubmissionCcLicenseUrlDataService extends BaseDataService): Observable { - return this.getSearchByHref( + return this.searchData.getSearchByHref( 'rightsByQuestions',{ searchParams: [ { @@ -64,19 +64,6 @@ export class SubmissionCcLicenseUrlDataService extends BaseDataService} - * Return an observable that emits created HREF - * @param linksToFollow List of {@link FollowLinkConfig} that indicate which {@link HALLink}s should be automatically resolved - */ - public getSearchByHref(searchMethod: string, options?: FindListOptions, ...linksToFollow: FollowLinkConfig[]): Observable { - return this.searchData.getSearchByHref(searchMethod, options, ...linksToFollow); - } - /** * Make a new FindListRequest with given search method * diff --git a/src/app/core/submission/vocabularies/vocabulary-entry-details.data.service.ts b/src/app/core/submission/vocabularies/vocabulary-entry-details.data.service.ts index ab7646042e..184b4c1e97 100644 --- a/src/app/core/submission/vocabularies/vocabulary-entry-details.data.service.ts +++ b/src/app/core/submission/vocabularies/vocabulary-entry-details.data.service.ts @@ -43,19 +43,6 @@ export class VocabularyEntryDetailsDataService extends IdentifiableDataService} - * Return an observable that emits created HREF - * @param linksToFollow List of {@link FollowLinkConfig} that indicate which {@link HALLink}s should be automatically resolved - */ - public getFindAllHref(options: FindListOptions, linkPath?: string, ...linksToFollow: FollowLinkConfig[]): Observable { - return this.findAllData.getFindAllHref(options, linkPath, ...linksToFollow); - } - /** * Returns {@link RemoteData} of all object with a list of {@link FollowLinkConfig}, to indicate which embedded * info should be added to the objects @@ -91,17 +78,4 @@ export class VocabularyEntryDetailsDataService extends IdentifiableDataService[]): Observable>> { return this.searchData.searchBy(searchMethod, options, useCachedVersionIfAvailable, reRequestOnStale, ...linksToFollow); } - - /** - * Create the HREF for a specific object's search method with given options object - * - * @param searchMethod The search method for the object - * @param options The [[FindListOptions]] object - * @return {Observable} - * Return an observable that emits created HREF - * @param linksToFollow List of {@link FollowLinkConfig} that indicate which {@link HALLink}s should be automatically resolved - */ - public getSearchByHref(searchMethod: string, options?: FindListOptions, ...linksToFollow): Observable { - return this.searchData.getSearchByHref(searchMethod, options, ...linksToFollow); - } } diff --git a/src/app/core/submission/vocabularies/vocabulary.data.service.ts b/src/app/core/submission/vocabularies/vocabulary.data.service.ts index ef642a6793..a67b67ced7 100644 --- a/src/app/core/submission/vocabularies/vocabulary.data.service.ts +++ b/src/app/core/submission/vocabularies/vocabulary.data.service.ts @@ -40,19 +40,6 @@ export class VocabularyDataService extends IdentifiableDataService i this.findAllData = new FindAllDataImpl(this.linkPath, requestService, rdbService, objectCache, halService, this.responseMsToLive); } - /** - * Create the HREF with given options object - * - * @param options The [[FindListOptions]] object - * @param linkPath The link path for the object - * @return {Observable} - * Return an observable that emits created HREF - * @param linksToFollow List of {@link FollowLinkConfig} that indicate which {@link HALLink}s should be automatically resolved - */ - public getFindAllHref(options: FindListOptions, linkPath?: string, ...linksToFollow: FollowLinkConfig[]): Observable { - return this.findAllData.getFindAllHref(options, linkPath, ...linksToFollow); - } - /** * Returns {@link RemoteData} of all object with a list of {@link FollowLinkConfig}, to indicate which embedded * info should be added to the objects diff --git a/src/app/core/submission/vocabularies/vocabulary.service.spec.ts b/src/app/core/submission/vocabularies/vocabulary.service.spec.ts index ed379c812a..faa5823520 100644 --- a/src/app/core/submission/vocabularies/vocabulary.service.spec.ts +++ b/src/app/core/submission/vocabularies/vocabulary.service.spec.ts @@ -253,7 +253,7 @@ describe('VocabularyService', () => { spyOn((service as any).vocabularyDataService, 'findById').and.callThrough(); spyOn((service as any).vocabularyDataService, 'findAll').and.callThrough(); spyOn((service as any).vocabularyDataService, 'findByHref').and.callThrough(); - spyOn((service as any).vocabularyDataService, 'getFindAllHref').and.returnValue(observableOf(entriesRequestURL)); + spyOn((service as any).vocabularyDataService.findAllData, 'getFindAllHref').and.returnValue(observableOf(entriesRequestURL)); }); afterEach(() => { @@ -421,8 +421,8 @@ describe('VocabularyService', () => { spyOn((service as any).vocabularyEntryDetailDataService, 'findByHref').and.callThrough(); spyOn((service as any).vocabularyEntryDetailDataService, 'findListByHref').and.callThrough(); spyOn((service as any).vocabularyEntryDetailDataService, 'searchBy').and.callThrough(); - spyOn((service as any).vocabularyEntryDetailDataService, 'getSearchByHref').and.returnValue(observableOf(searchRequestURL)); - spyOn((service as any).vocabularyEntryDetailDataService, 'getFindAllHref').and.returnValue(observableOf(entryDetailChildrenRequestURL)); + spyOn((service as any).vocabularyEntryDetailDataService.searchData, 'getSearchByHref').and.returnValue(observableOf(searchRequestURL)); + spyOn((service as any).vocabularyEntryDetailDataService.findAllData, 'getFindAllHref').and.returnValue(observableOf(entryDetailChildrenRequestURL)); spyOn((service as any).vocabularyEntryDetailDataService, 'getBrowseEndpoint').and.returnValue(observableOf(entryDetailEndpointURL)); }); diff --git a/src/app/core/submission/vocabularies/vocabulary.service.ts b/src/app/core/submission/vocabularies/vocabulary.service.ts index d29b19d97b..4a0b161f68 100644 --- a/src/app/core/submission/vocabularies/vocabulary.service.ts +++ b/src/app/core/submission/vocabularies/vocabulary.service.ts @@ -281,8 +281,10 @@ export class VocabularyService { pageInfo.elementsPerPage, pageInfo.currentPage ); - return this.vocabularyEntryDetailDataService.getFindAllHref(options, linkPath).pipe( - mergeMap((href) => this.vocabularyEntryDetailDataService.findListByHref(href, options, useCachedVersionIfAvailable, reRequestOnStale, ...linksToFollow)), + + return this.vocabularyEntryDetailDataService.getBrowseEndpoint().pipe( + map(href => `${href}/${name}:${value}/children`), + switchMap(href => this.vocabularyEntryDetailDataService.findListByHref(href, options, useCachedVersionIfAvailable, reRequestOnStale, ...linksToFollow)) ); } diff --git a/src/app/core/submission/workflowitem-data.service.spec.ts b/src/app/core/submission/workflowitem-data.service.spec.ts index 7d1bcbb381..3f6ec54fda 100644 --- a/src/app/core/submission/workflowitem-data.service.spec.ts +++ b/src/app/core/submission/workflowitem-data.service.spec.ts @@ -118,7 +118,7 @@ describe('WorkflowItemDataService test', () => { service = initTestService(); spyOn((service as any), 'findByHref').and.callThrough(); - spyOn((service as any), 'getSearchByHref').and.returnValue(searchRequestURL$); + spyOn((service as any).searchData, 'getSearchByHref').and.returnValue(searchRequestURL$); }); afterEach(() => { diff --git a/src/app/core/submission/workflowitem-data.service.ts b/src/app/core/submission/workflowitem-data.service.ts index c8cf9dd02f..47d18470d3 100644 --- a/src/app/core/submission/workflowitem-data.service.ts +++ b/src/app/core/submission/workflowitem-data.service.ts @@ -108,23 +108,10 @@ export class WorkflowItemDataService extends IdentifiableDataService[]): Observable> { const findListOptions = new FindListOptions(); findListOptions.searchParams = [new RequestParam('uuid', encodeURIComponent(uuid))]; - const href$ = this.getSearchByHref(this.searchByItemLinkPath, findListOptions, ...linksToFollow); + const href$ = this.searchData.getSearchByHref(this.searchByItemLinkPath, findListOptions, ...linksToFollow); return this.findByHref(href$, useCachedVersionIfAvailable, reRequestOnStale, ...linksToFollow); } - /** - * Create the HREF for a specific object's search method with given options object - * - * @param searchMethod The search method for the object - * @param options The [[FindListOptions]] object - * @return {Observable} - * Return an observable that emits created HREF - * @param linksToFollow List of {@link FollowLinkConfig} that indicate which {@link HALLink}s should be automatically resolved - */ - public getSearchByHref(searchMethod: string, options?: FindListOptions, ...linksToFollow): Observable { - return this.searchData.getSearchByHref(searchMethod, options, ...linksToFollow); - } - /** * Make a new FindListRequest with given search method * diff --git a/src/app/core/tasks/tasks.service.spec.ts b/src/app/core/tasks/tasks.service.spec.ts index 5d9d57a11e..88b573e098 100644 --- a/src/app/core/tasks/tasks.service.spec.ts +++ b/src/app/core/tasks/tasks.service.spec.ts @@ -111,7 +111,7 @@ describe('TasksService', () => { it('should call findByHref with the href generated by getSearchByHref', () => { - spyOn(service, 'getSearchByHref').and.returnValue(observableOf('generatedHref')); + spyOn((service as any).searchData, 'getSearchByHref').and.returnValue(observableOf('generatedHref')); spyOn(service, 'findByHref').and.returnValue(observableOf(null)); const followLinks = {}; @@ -121,7 +121,7 @@ describe('TasksService', () => { scheduler.schedule(() => service.searchTask('method', options, followLinks as any).subscribe()); scheduler.flush(); - expect(service.getSearchByHref).toHaveBeenCalledWith('method', options, followLinks as any); + expect((service as any).searchData.getSearchByHref).toHaveBeenCalledWith('method', options, followLinks as any); expect(service.findByHref).toHaveBeenCalledWith('generatedHref', false, true); }); }); diff --git a/src/app/core/tasks/tasks.service.ts b/src/app/core/tasks/tasks.service.ts index c2112d8e80..aaad31af21 100644 --- a/src/app/core/tasks/tasks.service.ts +++ b/src/app/core/tasks/tasks.service.ts @@ -23,7 +23,7 @@ import { IdentifiableDataService } from '../data/base/identifiable-data.service' * An abstract class that provides methods to handle task requests. todo: data in name */ export abstract class TasksService extends IdentifiableDataService implements SearchData { - private searchData: SearchData; + private searchData: SearchDataImpl; protected constructor( protected linkPath: string, @@ -119,7 +119,7 @@ export abstract class TasksService extends Identifiab * links to follow */ public searchTask(searchMethod: string, options: FindListOptions = {}, ...linksToFollow: FollowLinkConfig[]): Observable> { - const hrefObs = this.getSearchByHref(searchMethod, options, ...linksToFollow); + const hrefObs = this.searchData.getSearchByHref(searchMethod, options, ...linksToFollow); return hrefObs.pipe( find((href: string) => hasValue(href)), mergeMap((href) => this.findByHref(href, false, true).pipe( @@ -161,19 +161,6 @@ export abstract class TasksService extends Identifiab return options; } - /** - * Create the HREF for a specific object's search method with given options object - * - * @param searchMethod The search method for the object - * @param options The [[FindListOptions]] object - * @return {Observable} - * Return an observable that emits created HREF - * @param linksToFollow List of {@link FollowLinkConfig} that indicate which {@link HALLink}s should be automatically resolved - */ - public getSearchByHref(searchMethod: string, options?: FindListOptions, ...linksToFollow: FollowLinkConfig[]): Observable { - return this.searchData.getSearchByHref(searchMethod, options, ...linksToFollow); - } - /** * Make a new FindListRequest with given search method *