From a6fb4a6303ab47ac1f54218cdad1d05168d40af4 Mon Sep 17 00:00:00 2001 From: Yura Bondarenko Date: Mon, 5 Sep 2022 10:55:58 +0200 Subject: [PATCH] 93803: Update DataService constructor signatures Override linkPath/responseMsToLive/constructIdEndpoint - in class body for inheritable classes (for clarity: it's the first thing you'd read, variable name is right there) - in constructor for composable classes * wrapped services must be 'synchronized' with their wrapper * moved these overrides up in the argument list for emphasis (implementing a new composable feature? first thing is to use the same endpoint!) --- .../browse/browse-definition-data.service.ts | 6 ++- .../core/config/config-data.service.spec.ts | 2 +- ...submission-accesses-config-data.service.ts | 4 +- .../submission-forms-config-data.service.ts | 4 +- .../submission-uploads-config-data.service.ts | 4 +- .../core/data/access-status-data.service.ts | 3 +- .../core/data/base/base-data.service.spec.ts | 2 +- src/app/core/data/base/base-data.service.ts | 53 +++++++++++++++---- src/app/core/data/base/create-data.spec.ts | 2 +- src/app/core/data/base/create-data.ts | 4 +- src/app/core/data/base/delete-data.spec.ts | 2 +- src/app/core/data/base/delete-data.ts | 6 +-- src/app/core/data/base/find-all-data.spec.ts | 2 +- src/app/core/data/base/find-all-data.ts | 4 +- .../base/identifiable-data.service.spec.ts | 2 +- .../data/base/identifiable-data.service.ts | 15 +++--- src/app/core/data/base/patch-data.spec.ts | 2 +- src/app/core/data/base/patch-data.ts | 6 +-- src/app/core/data/base/put-data.spec.ts | 2 +- src/app/core/data/base/put-data.ts | 4 +- src/app/core/data/base/search-data.spec.ts | 2 +- src/app/core/data/base/search-data.ts | 4 +- src/app/core/data/bitstream-data.service.ts | 10 ++-- .../data/bitstream-format-data.service.ts | 7 ++- src/app/core/data/bundle-data.service.ts | 6 ++- src/app/core/data/collection-data.service.ts | 4 +- src/app/core/data/comcol-data.service.spec.ts | 7 ++- src/app/core/data/comcol-data.service.ts | 13 +++-- src/app/core/data/community-data.service.ts | 4 +- .../core/data/configuration-data.service.ts | 3 +- src/app/core/data/dso-redirect.service.ts | 14 +++-- .../core/data/dspace-object-data.service.ts | 13 +++-- src/app/core/data/entity-type-data.service.ts | 8 +-- .../core/data/external-source-data.service.ts | 6 ++- .../authorization-data.service.ts | 5 +- .../feature-data.service.ts | 2 +- src/app/core/data/href-only-data.service.ts | 2 +- src/app/core/data/item-data.service.ts | 16 +++--- .../core/data/item-request-data.service.ts | 4 +- .../core/data/item-template-data.service.ts | 10 ++-- .../core/data/metadata-field-data.service.ts | 12 +++-- .../core/data/metadata-schema-data.service.ts | 12 +++-- .../data/processes/process-data.service.ts | 6 ++- .../data/processes/script-data.service.ts | 6 ++- .../core/data/relationship-data.service.ts | 9 ++-- .../data/relationship-type-data.service.ts | 8 +-- src/app/core/data/root-data.service.ts | 5 +- src/app/core/data/site-data.service.ts | 6 ++- src/app/core/data/version-data.service.ts | 5 +- .../core/data/version-history-data.service.ts | 3 +- .../core/data/workflow-action-data.service.ts | 2 +- src/app/core/eperson/eperson-data.service.ts | 12 +++-- src/app/core/eperson/group-data.service.ts | 12 +++-- .../core/feedback/feedback-data.service.ts | 6 ++- .../core/orcid/orcid-history-data.service.ts | 4 +- .../core/orcid/orcid-queue-data.service.ts | 9 ++-- .../researcher-profile-data.service.ts | 13 +++-- .../resource-policy-data.service.ts | 12 +++-- src/app/core/shared/search/search.service.ts | 4 +- .../statistics/usage-report-data.service.ts | 6 ++- .../submission-cc-license-data.service.ts | 3 +- .../submission-cc-license-url-data.service.ts | 6 ++- .../vocabulary-entry-details.data.service.ts | 8 +-- .../vocabularies/vocabulary.data.service.ts | 6 ++- .../submission/workflowitem-data.service.ts | 9 ++-- .../submission/workspaceitem-data.service.ts | 8 +-- .../core/tasks/claimed-task-data.service.ts | 4 +- src/app/core/tasks/pool-task-data.service.ts | 5 +- src/app/core/tasks/tasks.service.spec.ts | 2 +- src/app/core/tasks/tasks.service.ts | 6 +-- 70 files changed, 294 insertions(+), 184 deletions(-) diff --git a/src/app/core/browse/browse-definition-data.service.ts b/src/app/core/browse/browse-definition-data.service.ts index 32c3b44e14..0bb60b1104 100644 --- a/src/app/core/browse/browse-definition-data.service.ts +++ b/src/app/core/browse/browse-definition-data.service.ts @@ -22,6 +22,8 @@ import { dataService } from '../data/base/data-service.decorator'; }) @dataService(BROWSE_DEFINITION) export class BrowseDefinitionDataService extends IdentifiableDataService implements FindAllData { + protected linkPath = 'browses'; + private findAllData: FindAllDataImpl; constructor( @@ -30,9 +32,9 @@ export class BrowseDefinitionDataService extends IdentifiableDataService> { diff --git a/src/app/core/data/access-status-data.service.ts b/src/app/core/data/access-status-data.service.ts index 2f641456fa..6635369726 100644 --- a/src/app/core/data/access-status-data.service.ts +++ b/src/app/core/data/access-status-data.service.ts @@ -17,6 +17,7 @@ import { dataService } from './base/data-service.decorator'; @Injectable() @dataService(ACCESS_STATUS) export class AccessStatusDataService extends BaseDataService { + protected linkPath = 'accessStatus'; constructor( protected requestService: RequestService, @@ -24,7 +25,7 @@ export class AccessStatusDataService extends BaseDataService protected objectCache: ObjectCacheService, protected halService: HALEndpointService, ) { - super('accessStatus', requestService, rdbService, objectCache, halService); + super(requestService, rdbService, objectCache, halService); } /** diff --git a/src/app/core/data/base/base-data.service.spec.ts b/src/app/core/data/base/base-data.service.spec.ts index cd8b8c3e32..19310004fa 100644 --- a/src/app/core/data/base/base-data.service.spec.ts +++ b/src/app/core/data/base/base-data.service.spec.ts @@ -32,7 +32,7 @@ class TestService extends BaseDataService { protected objectCache: ObjectCacheService, protected halService: HALEndpointService, ) { - super(undefined, requestService, rdbService, objectCache, halService); + super(requestService, rdbService, objectCache, halService); } public getBrowseEndpoint(options: FindListOptions = {}, linkPath: string = this.linkPath): Observable { diff --git a/src/app/core/data/base/base-data.service.ts b/src/app/core/data/base/base-data.service.ts index d8caa6c1c8..3618583428 100644 --- a/src/app/core/data/base/base-data.service.ts +++ b/src/app/core/data/base/base-data.service.ts @@ -8,7 +8,7 @@ import { AsyncSubject, from as observableFrom, Observable, of as observableOf } from 'rxjs'; import { map, mergeMap, skipWhile, switchMap, take, tap, toArray } from 'rxjs/operators'; -import { hasValue, isNotEmpty, isNotEmptyOperator } from '../../../shared/empty.util'; +import { hasValue, isEmpty, isNotEmpty, isNotEmptyOperator } from '../../../shared/empty.util'; import { FollowLinkConfig } from '../../../shared/utils/follow-link-config.model'; import { RemoteDataBuildService } from '../../cache/builders/remote-data-build.service'; import { RequestParam } from '../../cache/models/request-param.model'; @@ -31,13 +31,23 @@ import { HALDataService } from './hal-data-service.interface'; * * All DataService (or DataService feature) classes must * - extend this class (or {@link IdentifiableDataService}) - * - implement any DataService features it requires in order to forward calls to it + * - specify a {@link linkPath} + * - implement any DataService features it requires in order to forward calls to it. + * {@link linkPath} and {@link responseMsToLive} must be passed through. * * ``` * export class SomeDataService extends BaseDataService implements CreateData, SearchData { + * protected linkPath = 'something'; + * protected responseMsToLive = 3 * 60 * 1000; // not required + * * private createData: CreateData; * private searchData: SearchDataData; * + * constructor(...) { + * this.createData = new CreateDataImpl(this.linkPath, this.responseMsToLive, ...); + * this.searchData = new SearchDataImpl(this.linkPath, this.responseMsToLive, ...); + * } + * * create(...) { * return this.createData.create(...); * } @@ -49,19 +59,40 @@ import { HALDataService } from './hal-data-service.interface'; * ``` */ export class BaseDataService implements HALDataService { - constructor( - protected linkPath: string, - protected requestService: RequestService, - protected rdbService: RemoteDataBuildService, - protected objectCache: ObjectCacheService, - protected halService: HALEndpointService, - protected responseMsToLive?: number, - ) { - } + /** + * The REST endpoint this data service communicates with + */ + protected linkPath: string; /** * Allows subclasses to reset the response cache time. */ + protected responseMsToLive?: number; + + /** + * @param requestService + * @param rdbService + * @param objectCache + * @param halService + * @param linkPath Optionally sets the {@link linkPath}; to be used by composable features. + * @param responseMsToLive Optionally sets the {@link responseMsToLive}; to be used by composable features. + */ + constructor( + protected requestService: RequestService, + protected rdbService: RemoteDataBuildService, + protected objectCache: ObjectCacheService, + protected halService: HALEndpointService, + linkPath?: string, + responseMsToLive?: number, + ) { + if (isEmpty(this.linkPath) && isNotEmpty(linkPath)) { + this.linkPath = linkPath; + } + if (isEmpty(this.responseMsToLive) && isNotEmpty(responseMsToLive)) { + this.responseMsToLive = responseMsToLive; + } + } + /** * Get the endpoint for browsing diff --git a/src/app/core/data/base/create-data.spec.ts b/src/app/core/data/base/create-data.spec.ts index ceefd3c51d..1936be5c98 100644 --- a/src/app/core/data/base/create-data.spec.ts +++ b/src/app/core/data/base/create-data.spec.ts @@ -31,7 +31,7 @@ class TestService extends CreateDataImpl { protected halService: HALEndpointService, protected notificationsService: NotificationsService, ) { - super(undefined, requestService, rdbService, objectCache, halService, notificationsService, undefined); + super(undefined, undefined, requestService, rdbService, objectCache, halService, notificationsService); } public getBrowseEndpoint(options: FindListOptions = {}, linkPath: string = this.linkPath): Observable { diff --git a/src/app/core/data/base/create-data.ts b/src/app/core/data/base/create-data.ts index 3ffcd9adf2..faaadf45e7 100644 --- a/src/app/core/data/base/create-data.ts +++ b/src/app/core/data/base/create-data.ts @@ -45,14 +45,14 @@ export interface CreateData { export class CreateDataImpl extends BaseDataService implements CreateData { constructor( protected linkPath: string, + protected responseMsToLive: number, protected requestService: RequestService, protected rdbService: RemoteDataBuildService, protected objectCache: ObjectCacheService, protected halService: HALEndpointService, protected notificationsService: NotificationsService, - protected responseMsToLive: number, ) { - super(linkPath, requestService, rdbService, objectCache, halService, responseMsToLive); + super(requestService, rdbService, objectCache, halService, linkPath, responseMsToLive); } /** diff --git a/src/app/core/data/base/delete-data.spec.ts b/src/app/core/data/base/delete-data.spec.ts index 4c4a2ded6d..bdca855c98 100644 --- a/src/app/core/data/base/delete-data.spec.ts +++ b/src/app/core/data/base/delete-data.spec.ts @@ -36,7 +36,7 @@ class TestService extends DeleteDataImpl { protected halService: HALEndpointService, protected notificationsService: NotificationsService, ) { - super(undefined, requestService, rdbService, objectCache, halService, notificationsService, undefined, constructIdEndpointDefault); + super(undefined, undefined, constructIdEndpointDefault, requestService, rdbService, objectCache, halService, notificationsService); } public getBrowseEndpoint(options: FindListOptions = {}, linkPath: string = this.linkPath): Observable { diff --git a/src/app/core/data/base/delete-data.ts b/src/app/core/data/base/delete-data.ts index 2e34f0957c..514a65dc2f 100644 --- a/src/app/core/data/base/delete-data.ts +++ b/src/app/core/data/base/delete-data.ts @@ -46,15 +46,15 @@ export interface DeleteData { export class DeleteDataImpl extends IdentifiableDataService implements DeleteData { constructor( protected linkPath: string, + protected responseMsToLive: number, + protected constructIdEndpoint: ConstructIdEndpoint, protected requestService: RequestService, protected rdbService: RemoteDataBuildService, protected objectCache: ObjectCacheService, protected halService: HALEndpointService, protected notificationsService: NotificationsService, - protected responseMsToLive: number, - protected constructIdEndpoint: ConstructIdEndpoint, ) { - super(linkPath, requestService, rdbService, objectCache, halService, responseMsToLive, constructIdEndpoint); + super(requestService, rdbService, objectCache, halService); if (hasNoValue(constructIdEndpoint)) { throw new Error(`DeleteDataImpl initialized without a constructIdEndpoint method (linkPath: ${linkPath})`); } diff --git a/src/app/core/data/base/find-all-data.spec.ts b/src/app/core/data/base/find-all-data.spec.ts index 3caa8990f6..6312d70424 100644 --- a/src/app/core/data/base/find-all-data.spec.ts +++ b/src/app/core/data/base/find-all-data.spec.ts @@ -71,7 +71,7 @@ class TestService extends FindAllDataImpl { protected objectCache: ObjectCacheService, protected halService: HALEndpointService, ) { - super(undefined, requestService, rdbService, objectCache, halService, undefined); + super(undefined, undefined, requestService, rdbService, objectCache, halService); } public getBrowseEndpoint(options: FindListOptions = {}, linkPath: string = this.linkPath): Observable { diff --git a/src/app/core/data/base/find-all-data.ts b/src/app/core/data/base/find-all-data.ts index c2330af243..04ee426598 100644 --- a/src/app/core/data/base/find-all-data.ts +++ b/src/app/core/data/base/find-all-data.ts @@ -61,13 +61,13 @@ export interface FindAllData { export class FindAllDataImpl extends BaseDataService implements FindAllData { constructor( protected linkPath: string, + protected responseMsToLive: number, protected requestService: RequestService, protected rdbService: RemoteDataBuildService, protected objectCache: ObjectCacheService, protected halService: HALEndpointService, - protected responseMsToLive: number, ) { - super(linkPath, requestService, rdbService, objectCache, halService, responseMsToLive); + super(requestService, rdbService, objectCache, halService, linkPath, responseMsToLive); } /** diff --git a/src/app/core/data/base/identifiable-data.service.spec.ts b/src/app/core/data/base/identifiable-data.service.spec.ts index d08f1141fc..015c7593b0 100644 --- a/src/app/core/data/base/identifiable-data.service.spec.ts +++ b/src/app/core/data/base/identifiable-data.service.spec.ts @@ -29,7 +29,7 @@ class TestService extends IdentifiableDataService { protected objectCache: ObjectCacheService, protected halService: HALEndpointService, ) { - super(undefined, requestService, rdbService, objectCache, halService); + super(requestService, rdbService, objectCache, halService); } public getBrowseEndpoint(options: FindListOptions = {}, linkPath: string = this.linkPath): Observable { diff --git a/src/app/core/data/base/identifiable-data.service.ts b/src/app/core/data/base/identifiable-data.service.ts index 904f925765..a2fb7cc1b7 100644 --- a/src/app/core/data/base/identifiable-data.service.ts +++ b/src/app/core/data/base/identifiable-data.service.ts @@ -28,21 +28,22 @@ export const constructIdEndpointDefault = (endpoint, resourceID) => `${endpoint} /** * A type of data service that deals with objects that have an ID. - * - * The effective endpoint to use for the ID can be adjusted by providing a different {@link ConstructIdEndpoint} method. - * This method is passed as an argument so that it can be set on data service features without having to override them. */ export class IdentifiableDataService extends BaseDataService { + /** + * A method to construct the effective endpoint to use for the ID. + * Also passed as an optional constructor argument so that it can be set on data service features without having to override them. + * @protected + */ + protected constructIdEndpoint: ConstructIdEndpoint = constructIdEndpointDefault; + constructor( - protected linkPath: string, protected requestService: RequestService, protected rdbService: RemoteDataBuildService, protected objectCache: ObjectCacheService, protected halService: HALEndpointService, - protected responseMsToLive?: number, - protected constructIdEndpoint: ConstructIdEndpoint = constructIdEndpointDefault, ) { - super(linkPath, requestService, rdbService, objectCache, halService, responseMsToLive); + super(requestService, rdbService, objectCache, halService); } /** diff --git a/src/app/core/data/base/patch-data.spec.ts b/src/app/core/data/base/patch-data.spec.ts index 601188ae7d..4962d2e28a 100644 --- a/src/app/core/data/base/patch-data.spec.ts +++ b/src/app/core/data/base/patch-data.spec.ts @@ -38,7 +38,7 @@ class TestService extends PatchDataImpl { protected halService: HALEndpointService, protected comparator: ChangeAnalyzer, ) { - super(undefined, requestService, rdbService, objectCache, halService, comparator, undefined, constructIdEndpointDefault); + super(undefined, undefined, constructIdEndpointDefault, requestService, rdbService, objectCache, halService, comparator); } public getBrowseEndpoint(options: FindListOptions = {}, linkPath: string = this.linkPath): Observable { diff --git a/src/app/core/data/base/patch-data.ts b/src/app/core/data/base/patch-data.ts index 558de928c4..f361629400 100644 --- a/src/app/core/data/base/patch-data.ts +++ b/src/app/core/data/base/patch-data.ts @@ -65,15 +65,15 @@ export interface PatchData { export class PatchDataImpl extends IdentifiableDataService implements PatchData { constructor( protected linkPath: string, + protected responseMsToLive: number, + protected constructIdEndpoint: ConstructIdEndpoint, protected requestService: RequestService, protected rdbService: RemoteDataBuildService, protected objectCache: ObjectCacheService, protected halService: HALEndpointService, protected comparator: ChangeAnalyzer, - protected responseMsToLive: number, - protected constructIdEndpoint: ConstructIdEndpoint, ) { - super(linkPath, requestService, rdbService, objectCache, halService, responseMsToLive, constructIdEndpoint); + super(requestService, rdbService, objectCache, halService); if (hasNoValue(constructIdEndpoint)) { throw new Error(`PatchDataImpl initialized without a constructIdEndpoint method (linkPath: ${linkPath})`); } diff --git a/src/app/core/data/base/put-data.spec.ts b/src/app/core/data/base/put-data.spec.ts index 01b5caea5b..173121572b 100644 --- a/src/app/core/data/base/put-data.spec.ts +++ b/src/app/core/data/base/put-data.spec.ts @@ -30,7 +30,7 @@ class TestService extends PutDataImpl { protected objectCache: ObjectCacheService, protected halService: HALEndpointService, ) { - super(undefined, requestService, rdbService, objectCache, halService, undefined); + super(undefined, undefined, requestService, rdbService, objectCache, halService); } public getBrowseEndpoint(options: FindListOptions = {}, linkPath: string = this.linkPath): Observable { diff --git a/src/app/core/data/base/put-data.ts b/src/app/core/data/base/put-data.ts index bd2a8d2929..82491e9264 100644 --- a/src/app/core/data/base/put-data.ts +++ b/src/app/core/data/base/put-data.ts @@ -39,13 +39,13 @@ export interface PutData { export class PutDataImpl extends BaseDataService implements PutData { constructor( protected linkPath: string, + protected responseMsToLive: number, protected requestService: RequestService, protected rdbService: RemoteDataBuildService, protected objectCache: ObjectCacheService, protected halService: HALEndpointService, - protected responseMsToLive: number, ) { - super(linkPath, requestService, rdbService, objectCache, halService, responseMsToLive); + super(requestService, rdbService, objectCache, halService, linkPath, responseMsToLive); } /** diff --git a/src/app/core/data/base/search-data.spec.ts b/src/app/core/data/base/search-data.spec.ts index 7abf26b5b8..b0ad185b73 100644 --- a/src/app/core/data/base/search-data.spec.ts +++ b/src/app/core/data/base/search-data.spec.ts @@ -68,7 +68,7 @@ class TestService extends SearchDataImpl { protected objectCache: ObjectCacheService, protected halService: HALEndpointService, ) { - super(undefined, requestService, rdbService, objectCache, halService, undefined); + super(undefined, undefined, requestService, rdbService, objectCache, halService); } public getBrowseEndpoint(options: FindListOptions = {}, linkPath: string = this.linkPath): Observable { diff --git a/src/app/core/data/base/search-data.ts b/src/app/core/data/base/search-data.ts index 12cae77c3a..d0204e83a2 100644 --- a/src/app/core/data/base/search-data.ts +++ b/src/app/core/data/base/search-data.ts @@ -80,14 +80,14 @@ export class SearchDataImpl extends BaseDataService implements SearchData, PatchData, DeleteData { + protected linkPath = 'bitstreams'; + private searchData: SearchDataImpl; private patchData: PatchDataImpl; private deleteData: DeleteDataImpl; @@ -56,11 +58,11 @@ export class BitstreamDataService extends IdentifiableDataService imp protected comparator: DSOChangeAnalyzer, protected notificationsService: NotificationsService, ) { - super('bitstreams', requestService, rdbService, objectCache, halService); + super(requestService, rdbService, objectCache, halService); - this.searchData = new SearchDataImpl(this.linkPath, requestService, rdbService, objectCache, halService, this.responseMsToLive); - this.patchData = new PatchDataImpl(this.linkPath, requestService, rdbService, objectCache, halService, comparator, this.responseMsToLive, this.constructIdEndpoint); - this.deleteData = new DeleteDataImpl(this.linkPath, requestService, rdbService, objectCache, halService, notificationsService, this.responseMsToLive, this.constructIdEndpoint); + this.searchData = new SearchDataImpl(this.linkPath, this.responseMsToLive, requestService, rdbService, objectCache, halService); + this.patchData = new PatchDataImpl(this.linkPath, this.responseMsToLive, this.constructIdEndpoint, requestService, rdbService, objectCache, halService, comparator); + this.deleteData = new DeleteDataImpl(this.linkPath, this.responseMsToLive, this.constructIdEndpoint, requestService, rdbService, objectCache, halService, notificationsService); } /** diff --git a/src/app/core/data/bitstream-format-data.service.ts b/src/app/core/data/bitstream-format-data.service.ts index 0104389815..587100b1de 100644 --- a/src/app/core/data/bitstream-format-data.service.ts +++ b/src/app/core/data/bitstream-format-data.service.ts @@ -41,7 +41,6 @@ const selectedBitstreamFormatSelector = createSelector( @Injectable() @dataService(BITSTREAM_FORMAT) export class BitstreamFormatDataService extends IdentifiableDataService implements FindAllData, DeleteData { - protected linkPath = 'bitstreamformats'; private findAllData: FindAllDataImpl; @@ -55,10 +54,10 @@ export class BitstreamFormatDataService extends IdentifiableDataService, ) { - super('bitstreamformats', requestService, rdbService, objectCache, halService); + super(requestService, rdbService, objectCache, halService); - this.findAllData = new FindAllDataImpl(this.linkPath, requestService, rdbService, objectCache, halService, this.responseMsToLive); - this.deleteData = new DeleteDataImpl(this.linkPath, requestService, rdbService, objectCache, halService, notificationsService, this.responseMsToLive, this.constructIdEndpoint); + this.findAllData = new FindAllDataImpl(this.linkPath, this.responseMsToLive, requestService, rdbService, objectCache, halService); + this.deleteData = new DeleteDataImpl(this.linkPath, this.responseMsToLive, this.constructIdEndpoint, requestService, rdbService, objectCache, halService, notificationsService); } /** diff --git a/src/app/core/data/bundle-data.service.ts b/src/app/core/data/bundle-data.service.ts index e85c0c2bee..dbd5781446 100644 --- a/src/app/core/data/bundle-data.service.ts +++ b/src/app/core/data/bundle-data.service.ts @@ -32,6 +32,8 @@ import { dataService } from './base/data-service.decorator'; ) @dataService(BUNDLE) export class BundleDataService extends IdentifiableDataService implements PatchData { + protected linkPath = 'bundles'; + private bitstreamsEndpoint = 'bitstreams'; private patchData: PatchDataImpl; @@ -43,9 +45,9 @@ export class BundleDataService extends IdentifiableDataService implement protected halService: HALEndpointService, protected comparator: DSOChangeAnalyzer, ) { - super('bundles', requestService, rdbService, objectCache, halService); + super(requestService, rdbService, objectCache, halService); - this.patchData = new PatchDataImpl(this.linkPath, requestService, rdbService, objectCache, halService, comparator, this.responseMsToLive, this.constructIdEndpoint); + this.patchData = new PatchDataImpl(this.linkPath, this.responseMsToLive, this.constructIdEndpoint, requestService, rdbService, objectCache, halService, comparator); } /** diff --git a/src/app/core/data/collection-data.service.ts b/src/app/core/data/collection-data.service.ts index 405b35c1f9..fd3d6f4066 100644 --- a/src/app/core/data/collection-data.service.ts +++ b/src/app/core/data/collection-data.service.ts @@ -38,6 +38,8 @@ import { dataService } from './base/data-service.decorator'; @Injectable() @dataService(COLLECTION) export class CollectionDataService extends ComColDataService { + protected linkPath = 'collections'; + protected errorTitle = 'collection.source.update.notifications.error.title'; protected contentSourceError = 'collection.source.update.notifications.error.content'; @@ -52,7 +54,7 @@ export class CollectionDataService extends ComColDataService { protected communityDataService: CommunityDataService, protected translate: TranslateService, ) { - super('collections', requestService, rdbService, objectCache, halService, comparator, notificationsService, bitstreamDataService); + super(requestService, rdbService, objectCache, halService, comparator, notificationsService, bitstreamDataService); } /** diff --git a/src/app/core/data/comcol-data.service.spec.ts b/src/app/core/data/comcol-data.service.spec.ts index 758cbad97a..8c70fd9895 100644 --- a/src/app/core/data/comcol-data.service.spec.ts +++ b/src/app/core/data/comcol-data.service.spec.ts @@ -33,6 +33,7 @@ const communitiesEndpoint = 'https://rest.api/core/communities'; const communityEndpoint = `${communitiesEndpoint}/${scopeID}`; class TestService extends ComColDataService { + protected linkPath = 'something'; constructor( protected requestService: RequestService, @@ -45,9 +46,8 @@ class TestService extends ComColDataService { protected http: HttpClient, protected bitstreamDataService: BitstreamDataService, protected comparator: DSOChangeAnalyzer, - protected linkPath: string ) { - super('something', requestService, rdbService, objectCache, halService, comparator, notificationsService, bitstreamDataService); + super(requestService, rdbService, objectCache, halService, comparator, notificationsService, bitstreamDataService); } protected getFindByParentHref(parentUUID: string): Observable { @@ -131,8 +131,7 @@ describe('ComColDataService', () => { notificationsService, http, bitstreamDataService, - comparator, - LINK_NAME + comparator ); } diff --git a/src/app/core/data/comcol-data.service.ts b/src/app/core/data/comcol-data.service.ts index 6392f389b6..7ad4836d43 100644 --- a/src/app/core/data/comcol-data.service.ts +++ b/src/app/core/data/comcol-data.service.ts @@ -37,7 +37,6 @@ export abstract class ComColDataService extend private deleteData: DeleteData; protected constructor( - protected linkPath: string, protected requestService: RequestService, protected rdbService: RemoteDataBuildService, protected objectCache: ObjectCacheService, @@ -46,13 +45,13 @@ export abstract class ComColDataService extend protected notificationsService: NotificationsService, protected bitstreamDataService: BitstreamDataService, ) { - super(linkPath, requestService, rdbService, objectCache, halService); + super(requestService, rdbService, objectCache, halService); - this.createData = new CreateDataImpl(this.linkPath, requestService, rdbService, objectCache, halService, notificationsService, this.responseMsToLive); - this.findAllData = new FindAllDataImpl(this.linkPath, requestService, rdbService, objectCache, halService, this.responseMsToLive); - this.searchData = new SearchDataImpl(this.linkPath, requestService, rdbService, objectCache, halService, this.responseMsToLive); - this.patchData = new PatchDataImpl(this.linkPath, requestService, rdbService, objectCache, halService, comparator, this.responseMsToLive, this.constructIdEndpoint); - this.deleteData = new DeleteDataImpl(this.linkPath, requestService, rdbService, objectCache, halService, notificationsService, this.responseMsToLive, this.constructIdEndpoint); + this.createData = new CreateDataImpl(this.linkPath, this.responseMsToLive, requestService, rdbService, objectCache, halService, notificationsService); + this.findAllData = new FindAllDataImpl(this.linkPath, this.responseMsToLive, requestService, rdbService, objectCache, halService, ); + this.searchData = new SearchDataImpl(this.linkPath, this.responseMsToLive, requestService, rdbService, objectCache, halService, ); + this.patchData = new PatchDataImpl(this.linkPath, this.responseMsToLive, this.constructIdEndpoint, requestService, rdbService, objectCache, halService, comparator); + this.deleteData = new DeleteDataImpl(this.linkPath, this.responseMsToLive, this.constructIdEndpoint, requestService, rdbService, objectCache, halService, notificationsService); } /** diff --git a/src/app/core/data/community-data.service.ts b/src/app/core/data/community-data.service.ts index 8623d414b2..06792be2d9 100644 --- a/src/app/core/data/community-data.service.ts +++ b/src/app/core/data/community-data.service.ts @@ -22,6 +22,8 @@ import { dataService } from './base/data-service.decorator'; @Injectable() @dataService(COMMUNITY) export class CommunityDataService extends ComColDataService { + protected linkPath = 'communities'; + protected topLinkPath = 'search/top'; constructor( @@ -33,7 +35,7 @@ export class CommunityDataService extends ComColDataService { protected notificationsService: NotificationsService, protected bitstreamDataService: BitstreamDataService, ) { - super('communities', requestService, rdbService, objectCache, halService, comparator, notificationsService, bitstreamDataService); + super(requestService, rdbService, objectCache, halService, comparator, notificationsService, bitstreamDataService); } getEndpoint() { diff --git a/src/app/core/data/configuration-data.service.ts b/src/app/core/data/configuration-data.service.ts index de044e25e3..3dfdd5ef08 100644 --- a/src/app/core/data/configuration-data.service.ts +++ b/src/app/core/data/configuration-data.service.ts @@ -17,6 +17,7 @@ import { dataService } from './base/data-service.decorator'; * Data Service responsible for retrieving Configuration properties */ export class ConfigurationDataService extends IdentifiableDataService { + protected linkPath = 'properties'; constructor( protected requestService: RequestService, @@ -24,7 +25,7 @@ export class ConfigurationDataService extends IdentifiableDataService { + // interpolate id/uuid as query parameter + constructIdEndpoint = (endpoint: string, resourceID: string): string => + endpoint.replace(/{\?id}/, `?id=${resourceID}`) + .replace(/{\?uuid}/, `?uuid=${resourceID}`); + constructor( protected requestService: RequestService, protected rdbService: RemoteDataBuildService, protected objectCache: ObjectCacheService, protected halService: HALEndpointService, ) { - super( - undefined, requestService, rdbService, objectCache, halService, undefined, - // interpolate id/uuid as query parameter - (endpoint: string, resourceID: string): string => { - return endpoint.replace(/{\?id}/, `?id=${resourceID}`) - .replace(/{\?uuid}/, `?uuid=${resourceID}`); - }, - ); + super(requestService, rdbService, objectCache, halService); } /** diff --git a/src/app/core/data/dspace-object-data.service.ts b/src/app/core/data/dspace-object-data.service.ts index 2ad024133c..ff815cb3df 100644 --- a/src/app/core/data/dspace-object-data.service.ts +++ b/src/app/core/data/dspace-object-data.service.ts @@ -11,6 +11,13 @@ import { dataService } from './base/data-service.decorator'; @Injectable() @dataService(DSPACE_OBJECT) export class DSpaceObjectDataService extends IdentifiableDataService { + protected linkPath = 'dso'; + + // interpolate uuid as query parameter + protected constructIdEndpoint = (endpoint: string, resourceID: string): string => { + return endpoint.replace(/{\?uuid}/, `?uuid=${resourceID}`); + }; + constructor( protected requestService: RequestService, protected rdbService: RemoteDataBuildService, @@ -18,11 +25,7 @@ export class DSpaceObjectDataService extends IdentifiableDataService { - return endpoint.replace(/{\?uuid}/, `?uuid=${resourceID}`); - }, + requestService, rdbService, objectCache, halService, ); } } diff --git a/src/app/core/data/entity-type-data.service.ts b/src/app/core/data/entity-type-data.service.ts index 4020ff638d..9eb0cf5188 100644 --- a/src/app/core/data/entity-type-data.service.ts +++ b/src/app/core/data/entity-type-data.service.ts @@ -22,6 +22,8 @@ import { FindAllData, FindAllDataImpl } from './base/find-all-data'; */ @Injectable() export class EntityTypeDataService extends BaseDataService implements FindAllData, SearchData { + protected linkPath = 'entitytypes'; + private findAllData: FindAllData; private searchData: SearchDataImpl; @@ -32,10 +34,10 @@ export class EntityTypeDataService extends BaseDataService implements protected halService: HALEndpointService, protected relationshipTypeService: RelationshipTypeDataService, ) { - super('entitytypes', requestService, rdbService, objectCache, halService); + super(requestService, rdbService, objectCache, halService); - this.findAllData = new FindAllDataImpl(this.linkPath, requestService, rdbService, objectCache, halService, this.responseMsToLive); - this.searchData = new SearchDataImpl(this.linkPath, requestService, rdbService, objectCache, halService, this.responseMsToLive); + this.findAllData = new FindAllDataImpl(this.linkPath, this.responseMsToLive, requestService, rdbService, objectCache, halService); + this.searchData = new SearchDataImpl(this.linkPath, this.responseMsToLive, requestService, rdbService, objectCache, halService); } getBrowseEndpoint(options, linkPath?: string): Observable { diff --git a/src/app/core/data/external-source-data.service.ts b/src/app/core/data/external-source-data.service.ts index c7b71790a3..ec8e65777b 100644 --- a/src/app/core/data/external-source-data.service.ts +++ b/src/app/core/data/external-source-data.service.ts @@ -21,6 +21,8 @@ import { SearchData, SearchDataImpl } from './base/search-data'; */ @Injectable() export class ExternalSourceDataService extends IdentifiableDataService implements SearchData { + protected linkPath = 'externalsources'; + private searchData: SearchData; constructor( @@ -29,9 +31,9 @@ export class ExternalSourceDataService extends IdentifiableDataService implements SearchData { protected linkPath = 'authorizations'; + protected searchByObjectPath = 'object'; private searchData: SearchDataImpl; @@ -40,9 +41,9 @@ export class AuthorizationDataService extends BaseDataService imp protected halService: HALEndpointService, protected siteService: SiteDataService, ) { - super('authorizations', requestService, rdbService, objectCache, halService); + super(requestService, rdbService, objectCache, halService); - this.searchData = new SearchDataImpl(this.linkPath, requestService, rdbService, objectCache, halService, this.responseMsToLive); + this.searchData = new SearchDataImpl(this.linkPath, this.responseMsToLive, requestService, rdbService, objectCache, halService); } /** diff --git a/src/app/core/data/feature-authorization/feature-data.service.ts b/src/app/core/data/feature-authorization/feature-data.service.ts index eda8791153..3e84024785 100644 --- a/src/app/core/data/feature-authorization/feature-data.service.ts +++ b/src/app/core/data/feature-authorization/feature-data.service.ts @@ -22,6 +22,6 @@ export class FeatureDataService extends BaseDataService { protected objectCache: ObjectCacheService, protected halService: HALEndpointService, ) { - super('features', requestService, rdbService, objectCache, halService); + super(requestService, rdbService, objectCache, halService); } } diff --git a/src/app/core/data/href-only-data.service.ts b/src/app/core/data/href-only-data.service.ts index 0a765de101..5192c45fa3 100644 --- a/src/app/core/data/href-only-data.service.ts +++ b/src/app/core/data/href-only-data.service.ts @@ -52,7 +52,7 @@ export class HrefOnlyDataService implements HALDataService { protected objectCache: ObjectCacheService, protected halService: HALEndpointService, ) { - this.dataService = new BaseDataService(undefined, requestService, rdbService, objectCache, halService); + this.dataService = new BaseDataService(requestService, rdbService, objectCache, halService); } /** diff --git a/src/app/core/data/item-data.service.ts b/src/app/core/data/item-data.service.ts index 11179d1e77..016c8c3625 100644 --- a/src/app/core/data/item-data.service.ts +++ b/src/app/core/data/item-data.service.ts @@ -39,7 +39,7 @@ import { StatusCodeOnlyResponseParsingService } from './status-code-only-respons import { sendRequest } from '../shared/request.operators'; import { RestRequest } from './rest-request.model'; import { FindListOptions } from './find-list-options.model'; -import { ConstructIdEndpoint, IdentifiableDataService } from './base/identifiable-data.service'; +import { IdentifiableDataService } from './base/identifiable-data.service'; import { PatchData, PatchDataImpl } from './base/patch-data'; import { DeleteData, DeleteDataImpl } from './base/delete-data'; import { RestRequestMethod } from './rest-request-method'; @@ -58,7 +58,6 @@ export abstract class BaseItemDataService extends IdentifiableDataService private deleteData: DeleteData; protected constructor( - protected linkPath, protected requestService: RequestService, protected rdbService: RemoteDataBuildService, protected objectCache: ObjectCacheService, @@ -67,13 +66,12 @@ export abstract class BaseItemDataService extends IdentifiableDataService protected comparator: DSOChangeAnalyzer, protected browseService: BrowseService, protected bundleService: BundleDataService, - protected constructIdEndpoint: ConstructIdEndpoint = (endpoint, resourceID) => `${endpoint}/${resourceID}`, ) { - super(linkPath, requestService, rdbService, objectCache, halService, undefined, constructIdEndpoint); + super(requestService, rdbService, objectCache, halService); - this.createData = new CreateDataImpl(this.linkPath, requestService, rdbService, objectCache, halService, notificationsService, this.responseMsToLive); - this.patchData = new PatchDataImpl(this.linkPath, requestService, rdbService, objectCache, halService, comparator, this.responseMsToLive, this.constructIdEndpoint); - this.deleteData = new DeleteDataImpl(this.linkPath, requestService, rdbService, objectCache, halService, notificationsService, this.responseMsToLive, this.constructIdEndpoint); + this.createData = new CreateDataImpl(this.linkPath, this.responseMsToLive, requestService, rdbService, objectCache, halService, notificationsService); + this.patchData = new PatchDataImpl(this.linkPath, this.responseMsToLive, this.constructIdEndpoint, requestService, rdbService, objectCache, halService, comparator); + this.deleteData = new DeleteDataImpl(this.linkPath, this.responseMsToLive, this.constructIdEndpoint, requestService, rdbService, objectCache, halService, notificationsService); } /** @@ -388,6 +386,8 @@ export abstract class BaseItemDataService extends IdentifiableDataService @Injectable() @dataService(ITEM) export class ItemDataService extends BaseItemDataService { + protected linkPath = 'items'; + constructor( protected requestService: RequestService, protected rdbService: RemoteDataBuildService, @@ -398,6 +398,6 @@ export class ItemDataService extends BaseItemDataService { protected browseService: BrowseService, protected bundleService: BundleDataService, ) { - super('items', requestService, rdbService, objectCache, halService, notificationsService, comparator, browseService, bundleService); + super(requestService, rdbService, objectCache, halService, notificationsService, comparator, browseService, bundleService); } } diff --git a/src/app/core/data/item-request-data.service.ts b/src/app/core/data/item-request-data.service.ts index ff6025f7ac..6781badfb0 100644 --- a/src/app/core/data/item-request-data.service.ts +++ b/src/app/core/data/item-request-data.service.ts @@ -23,13 +23,15 @@ import { IdentifiableDataService } from './base/identifiable-data.service'; providedIn: 'root', }) export class ItemRequestDataService extends IdentifiableDataService { + protected linkPath = 'itemrequests'; + constructor( protected requestService: RequestService, protected rdbService: RemoteDataBuildService, protected objectCache: ObjectCacheService, protected halService: HALEndpointService, ) { - super('itemrequests', requestService, rdbService, objectCache, halService); + super(requestService, rdbService, objectCache, halService); } getItemRequestEndpoint(): Observable { diff --git a/src/app/core/data/item-template-data.service.ts b/src/app/core/data/item-template-data.service.ts index 634c966dba..b8e8ec6301 100644 --- a/src/app/core/data/item-template-data.service.ts +++ b/src/app/core/data/item-template-data.service.ts @@ -22,6 +22,8 @@ import { CreateDataImpl } from './base/create-data'; * Data service for interacting with Item templates via their Collection */ class CollectionItemTemplateDataService extends IdentifiableDataService { + protected linkPath = 'itemtemplates'; + private createData: CreateDataImpl; constructor( @@ -32,10 +34,10 @@ class CollectionItemTemplateDataService extends IdentifiableDataService { protected notificationsService: NotificationsService, protected collectionService: CollectionDataService, ) { - super('itemtemplates', requestService, rdbService, objectCache, halService, undefined); + super(requestService, rdbService, objectCache, halService); // We only intend to use createOnEndpoint, so this inner data service feature doesn't need an endpoint at all - this.createData = new CreateDataImpl(undefined, requestService, rdbService, objectCache, halService, notificationsService, this.responseMsToLive); + this.createData = new CreateDataImpl(this.linkPath, this.responseMsToLive, requestService, rdbService, objectCache, halService, notificationsService); } /** @@ -65,6 +67,8 @@ class CollectionItemTemplateDataService extends IdentifiableDataService { */ @Injectable() export class ItemTemplateDataService extends BaseItemDataService { + protected linkPath = 'itemtemplates'; + private byCollection: CollectionItemTemplateDataService; constructor( @@ -78,7 +82,7 @@ export class ItemTemplateDataService extends BaseItemDataService { protected bundleService: BundleDataService, protected collectionService: CollectionDataService, ) { - super('itemtemplates', requestService, rdbService, objectCache, halService, notificationsService, comparator, browseService, bundleService); + super(requestService, rdbService, objectCache, halService, notificationsService, comparator, browseService, bundleService); this.byCollection = new CollectionItemTemplateDataService(requestService, rdbService, objectCache, halService, notificationsService, collectionService); } diff --git a/src/app/core/data/metadata-field-data.service.ts b/src/app/core/data/metadata-field-data.service.ts index db9361ee4c..519b68f40c 100644 --- a/src/app/core/data/metadata-field-data.service.ts +++ b/src/app/core/data/metadata-field-data.service.ts @@ -29,6 +29,8 @@ import { dataService } from './base/data-service.decorator'; @Injectable() @dataService(METADATA_FIELD) export class MetadataFieldDataService extends IdentifiableDataService implements CreateData, PutData, DeleteData, SearchData { + protected linkPath = 'metadatafields'; + private createData: CreateData; private searchData: SearchData; private putData: PutData; @@ -44,12 +46,12 @@ export class MetadataFieldDataService extends IdentifiableDataService implements FindAllData, DeleteData { + protected linkPath = 'metadataschemas'; + private createData: CreateData; private findAllData: FindAllData; private putData: PutData; @@ -39,12 +41,12 @@ export class MetadataSchemaDataService extends IdentifiableDataService implements FindAllData { + protected linkPath = 'processes'; + private findAllData: FindAllData; constructor( @@ -29,9 +31,9 @@ export class ProcessDataService extends IdentifiableDataService impleme protected halService: HALEndpointService, protected bitstreamDataService: BitstreamDataService, ) { - super('processes', requestService, rdbService, objectCache, halService); + super(requestService, rdbService, objectCache, halService); - this.findAllData = new FindAllDataImpl(this.linkPath, requestService, rdbService, objectCache, halService, this.responseMsToLive); + this.findAllData = new FindAllDataImpl(this.linkPath, this.responseMsToLive, requestService, rdbService, objectCache, halService); } /** diff --git a/src/app/core/data/processes/script-data.service.ts b/src/app/core/data/processes/script-data.service.ts index ed228612ef..39666da86b 100644 --- a/src/app/core/data/processes/script-data.service.ts +++ b/src/app/core/data/processes/script-data.service.ts @@ -28,6 +28,8 @@ export const METADATA_EXPORT_SCRIPT_NAME = 'metadata-export'; @Injectable() @dataService(SCRIPT) export class ScriptDataService extends IdentifiableDataService