diff --git a/src/app/core/browse/browse-definition-data.service.ts b/src/app/core/browse/browse-definition-data.service.ts index 0bb60b1104..32c3b44e14 100644 --- a/src/app/core/browse/browse-definition-data.service.ts +++ b/src/app/core/browse/browse-definition-data.service.ts @@ -22,8 +22,6 @@ 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( @@ -32,9 +30,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 6635369726..2f641456fa 100644 --- a/src/app/core/data/access-status-data.service.ts +++ b/src/app/core/data/access-status-data.service.ts @@ -17,7 +17,6 @@ import { dataService } from './base/data-service.decorator'; @Injectable() @dataService(ACCESS_STATUS) export class AccessStatusDataService extends BaseDataService { - protected linkPath = 'accessStatus'; constructor( protected requestService: RequestService, @@ -25,7 +24,7 @@ export class AccessStatusDataService extends BaseDataService protected objectCache: ObjectCacheService, protected halService: HALEndpointService, ) { - super(requestService, rdbService, objectCache, halService); + super('accessStatus', 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 19310004fa..cd8b8c3e32 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(requestService, rdbService, objectCache, halService); + super(undefined, 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 3618583428..d8caa6c1c8 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, isEmpty, isNotEmpty, isNotEmptyOperator } from '../../../shared/empty.util'; +import { hasValue, 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,23 +31,13 @@ import { HALDataService } from './hal-data-service.interface'; * * All DataService (or DataService feature) classes must * - extend this class (or {@link IdentifiableDataService}) - * - 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. + * - implement any DataService features it requires in order to forward calls to it * * ``` * 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(...); * } @@ -59,40 +49,19 @@ import { HALDataService } from './hal-data-service.interface'; * ``` */ export class BaseDataService implements HALDataService { - /** - * 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 linkPath: string, protected requestService: RequestService, protected rdbService: RemoteDataBuildService, protected objectCache: ObjectCacheService, protected halService: HALEndpointService, - linkPath?: string, - responseMsToLive?: number, + protected responseMsToLive?: number, ) { - if (isEmpty(this.linkPath) && isNotEmpty(linkPath)) { - this.linkPath = linkPath; - } - if (isEmpty(this.responseMsToLive) && isNotEmpty(responseMsToLive)) { - this.responseMsToLive = responseMsToLive; - } } + /** + * Allows subclasses to reset the response cache time. + */ /** * 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 1936be5c98..ceefd3c51d 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, undefined, requestService, rdbService, objectCache, halService, notificationsService); + super(undefined, requestService, rdbService, objectCache, halService, notificationsService, undefined); } 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 faaadf45e7..3ffcd9adf2 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(requestService, rdbService, objectCache, halService, linkPath, responseMsToLive); + super(linkPath, requestService, rdbService, objectCache, halService, responseMsToLive); } /** diff --git a/src/app/core/data/base/delete-data.spec.ts b/src/app/core/data/base/delete-data.spec.ts index bdca855c98..4c4a2ded6d 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, undefined, constructIdEndpointDefault, requestService, rdbService, objectCache, halService, notificationsService); + super(undefined, requestService, rdbService, objectCache, halService, notificationsService, undefined, constructIdEndpointDefault); } 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 514a65dc2f..2e34f0957c 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(requestService, rdbService, objectCache, halService); + super(linkPath, requestService, rdbService, objectCache, halService, responseMsToLive, constructIdEndpoint); 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 6312d70424..3caa8990f6 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, undefined, requestService, rdbService, objectCache, halService); + super(undefined, requestService, rdbService, objectCache, halService, undefined); } 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 04ee426598..c2330af243 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(requestService, rdbService, objectCache, halService, linkPath, responseMsToLive); + super(linkPath, requestService, rdbService, objectCache, halService, 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 015c7593b0..d08f1141fc 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(requestService, rdbService, objectCache, halService); + super(undefined, 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 a2fb7cc1b7..904f925765 100644 --- a/src/app/core/data/base/identifiable-data.service.ts +++ b/src/app/core/data/base/identifiable-data.service.ts @@ -28,22 +28,21 @@ 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(requestService, rdbService, objectCache, halService); + super(linkPath, requestService, rdbService, objectCache, halService, responseMsToLive); } /** diff --git a/src/app/core/data/base/patch-data.spec.ts b/src/app/core/data/base/patch-data.spec.ts index 4962d2e28a..601188ae7d 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, undefined, constructIdEndpointDefault, requestService, rdbService, objectCache, halService, comparator); + super(undefined, requestService, rdbService, objectCache, halService, comparator, undefined, constructIdEndpointDefault); } 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 f361629400..558de928c4 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(requestService, rdbService, objectCache, halService); + super(linkPath, requestService, rdbService, objectCache, halService, responseMsToLive, constructIdEndpoint); 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 173121572b..01b5caea5b 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, undefined, requestService, rdbService, objectCache, halService); + super(undefined, requestService, rdbService, objectCache, halService, undefined); } 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 82491e9264..bd2a8d2929 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(requestService, rdbService, objectCache, halService, linkPath, responseMsToLive); + super(linkPath, requestService, rdbService, objectCache, halService, responseMsToLive); } /** diff --git a/src/app/core/data/base/search-data.spec.ts b/src/app/core/data/base/search-data.spec.ts index b0ad185b73..7abf26b5b8 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, undefined, requestService, rdbService, objectCache, halService); + super(undefined, requestService, rdbService, objectCache, halService, undefined); } 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 d0204e83a2..12cae77c3a 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; @@ -58,11 +56,11 @@ export class BitstreamDataService extends IdentifiableDataService imp protected comparator: DSOChangeAnalyzer, protected notificationsService: NotificationsService, ) { - super(requestService, rdbService, objectCache, halService); + super('bitstreams', 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); + 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); } /** diff --git a/src/app/core/data/bitstream-format-data.service.ts b/src/app/core/data/bitstream-format-data.service.ts index 587100b1de..0104389815 100644 --- a/src/app/core/data/bitstream-format-data.service.ts +++ b/src/app/core/data/bitstream-format-data.service.ts @@ -41,6 +41,7 @@ const selectedBitstreamFormatSelector = createSelector( @Injectable() @dataService(BITSTREAM_FORMAT) export class BitstreamFormatDataService extends IdentifiableDataService implements FindAllData, DeleteData { + protected linkPath = 'bitstreamformats'; private findAllData: FindAllDataImpl; @@ -54,10 +55,10 @@ export class BitstreamFormatDataService extends IdentifiableDataService, ) { - super(requestService, rdbService, objectCache, halService); + super('bitstreamformats', requestService, rdbService, objectCache, halService); - 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); + 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); } /** diff --git a/src/app/core/data/bundle-data.service.ts b/src/app/core/data/bundle-data.service.ts index dbd5781446..e85c0c2bee 100644 --- a/src/app/core/data/bundle-data.service.ts +++ b/src/app/core/data/bundle-data.service.ts @@ -32,8 +32,6 @@ 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; @@ -45,9 +43,9 @@ export class BundleDataService extends IdentifiableDataService implement protected halService: HALEndpointService, protected comparator: DSOChangeAnalyzer, ) { - super(requestService, rdbService, objectCache, halService); + super('bundles', requestService, rdbService, objectCache, halService); - this.patchData = new PatchDataImpl(this.linkPath, this.responseMsToLive, this.constructIdEndpoint, requestService, rdbService, objectCache, halService, comparator); + this.patchData = new PatchDataImpl(this.linkPath, requestService, rdbService, objectCache, halService, comparator, this.responseMsToLive, this.constructIdEndpoint); } /** diff --git a/src/app/core/data/collection-data.service.ts b/src/app/core/data/collection-data.service.ts index fd3d6f4066..405b35c1f9 100644 --- a/src/app/core/data/collection-data.service.ts +++ b/src/app/core/data/collection-data.service.ts @@ -38,8 +38,6 @@ 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'; @@ -54,7 +52,7 @@ export class CollectionDataService extends ComColDataService { protected communityDataService: CommunityDataService, protected translate: TranslateService, ) { - super(requestService, rdbService, objectCache, halService, comparator, notificationsService, bitstreamDataService); + super('collections', 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 8c70fd9895..758cbad97a 100644 --- a/src/app/core/data/comcol-data.service.spec.ts +++ b/src/app/core/data/comcol-data.service.spec.ts @@ -33,7 +33,6 @@ const communitiesEndpoint = 'https://rest.api/core/communities'; const communityEndpoint = `${communitiesEndpoint}/${scopeID}`; class TestService extends ComColDataService { - protected linkPath = 'something'; constructor( protected requestService: RequestService, @@ -46,8 +45,9 @@ class TestService extends ComColDataService { protected http: HttpClient, protected bitstreamDataService: BitstreamDataService, protected comparator: DSOChangeAnalyzer, + protected linkPath: string ) { - super(requestService, rdbService, objectCache, halService, comparator, notificationsService, bitstreamDataService); + super('something', requestService, rdbService, objectCache, halService, comparator, notificationsService, bitstreamDataService); } protected getFindByParentHref(parentUUID: string): Observable { @@ -131,7 +131,8 @@ describe('ComColDataService', () => { notificationsService, http, bitstreamDataService, - comparator + comparator, + LINK_NAME ); } diff --git a/src/app/core/data/comcol-data.service.ts b/src/app/core/data/comcol-data.service.ts index 7ad4836d43..6392f389b6 100644 --- a/src/app/core/data/comcol-data.service.ts +++ b/src/app/core/data/comcol-data.service.ts @@ -37,6 +37,7 @@ export abstract class ComColDataService extend private deleteData: DeleteData; protected constructor( + protected linkPath: string, protected requestService: RequestService, protected rdbService: RemoteDataBuildService, protected objectCache: ObjectCacheService, @@ -45,13 +46,13 @@ export abstract class ComColDataService extend protected notificationsService: NotificationsService, protected bitstreamDataService: BitstreamDataService, ) { - super(requestService, rdbService, objectCache, halService); + super(linkPath, requestService, rdbService, objectCache, halService); - 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); + 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); } /** diff --git a/src/app/core/data/community-data.service.ts b/src/app/core/data/community-data.service.ts index 06792be2d9..8623d414b2 100644 --- a/src/app/core/data/community-data.service.ts +++ b/src/app/core/data/community-data.service.ts @@ -22,8 +22,6 @@ import { dataService } from './base/data-service.decorator'; @Injectable() @dataService(COMMUNITY) export class CommunityDataService extends ComColDataService { - protected linkPath = 'communities'; - protected topLinkPath = 'search/top'; constructor( @@ -35,7 +33,7 @@ export class CommunityDataService extends ComColDataService { protected notificationsService: NotificationsService, protected bitstreamDataService: BitstreamDataService, ) { - super(requestService, rdbService, objectCache, halService, comparator, notificationsService, bitstreamDataService); + super('communities', 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 3dfdd5ef08..de044e25e3 100644 --- a/src/app/core/data/configuration-data.service.ts +++ b/src/app/core/data/configuration-data.service.ts @@ -17,7 +17,6 @@ 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, @@ -25,7 +24,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(requestService, rdbService, objectCache, halService); + 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}`); + }, + ); } /** diff --git a/src/app/core/data/dspace-object-data.service.ts b/src/app/core/data/dspace-object-data.service.ts index ff815cb3df..2ad024133c 100644 --- a/src/app/core/data/dspace-object-data.service.ts +++ b/src/app/core/data/dspace-object-data.service.ts @@ -11,13 +11,6 @@ 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, @@ -25,7 +18,11 @@ export class DSpaceObjectDataService extends IdentifiableDataService { + return endpoint.replace(/{\?uuid}/, `?uuid=${resourceID}`); + }, ); } } diff --git a/src/app/core/data/entity-type-data.service.ts b/src/app/core/data/entity-type-data.service.ts index 9eb0cf5188..4020ff638d 100644 --- a/src/app/core/data/entity-type-data.service.ts +++ b/src/app/core/data/entity-type-data.service.ts @@ -22,8 +22,6 @@ 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; @@ -34,10 +32,10 @@ export class EntityTypeDataService extends BaseDataService implements protected halService: HALEndpointService, protected relationshipTypeService: RelationshipTypeDataService, ) { - super(requestService, rdbService, objectCache, halService); + super('entitytypes', requestService, rdbService, objectCache, halService); - 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.findAllData = new FindAllDataImpl(this.linkPath, requestService, rdbService, objectCache, halService, this.responseMsToLive); + this.searchData = new SearchDataImpl(this.linkPath, requestService, rdbService, objectCache, halService, this.responseMsToLive); } 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 ec8e65777b..c7b71790a3 100644 --- a/src/app/core/data/external-source-data.service.ts +++ b/src/app/core/data/external-source-data.service.ts @@ -21,8 +21,6 @@ import { SearchData, SearchDataImpl } from './base/search-data'; */ @Injectable() export class ExternalSourceDataService extends IdentifiableDataService implements SearchData { - protected linkPath = 'externalsources'; - private searchData: SearchData; constructor( @@ -31,9 +29,9 @@ export class ExternalSourceDataService extends IdentifiableDataService implements SearchData { protected linkPath = 'authorizations'; - protected searchByObjectPath = 'object'; private searchData: SearchDataImpl; @@ -41,9 +40,9 @@ export class AuthorizationDataService extends BaseDataService imp protected halService: HALEndpointService, protected siteService: SiteDataService, ) { - super(requestService, rdbService, objectCache, halService); + super('authorizations', requestService, rdbService, objectCache, halService); - this.searchData = new SearchDataImpl(this.linkPath, this.responseMsToLive, requestService, rdbService, objectCache, halService); + this.searchData = new SearchDataImpl(this.linkPath, requestService, rdbService, objectCache, halService, this.responseMsToLive); } /** 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 3e84024785..eda8791153 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(requestService, rdbService, objectCache, halService); + super('features', 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 5192c45fa3..0a765de101 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(requestService, rdbService, objectCache, halService); + this.dataService = new BaseDataService(undefined, 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 016c8c3625..11179d1e77 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 { IdentifiableDataService } from './base/identifiable-data.service'; +import { ConstructIdEndpoint, 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,6 +58,7 @@ export abstract class BaseItemDataService extends IdentifiableDataService private deleteData: DeleteData; protected constructor( + protected linkPath, protected requestService: RequestService, protected rdbService: RemoteDataBuildService, protected objectCache: ObjectCacheService, @@ -66,12 +67,13 @@ export abstract class BaseItemDataService extends IdentifiableDataService protected comparator: DSOChangeAnalyzer, protected browseService: BrowseService, protected bundleService: BundleDataService, + protected constructIdEndpoint: ConstructIdEndpoint = (endpoint, resourceID) => `${endpoint}/${resourceID}`, ) { - super(requestService, rdbService, objectCache, halService); + super(linkPath, requestService, rdbService, objectCache, halService, undefined, 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); + 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); } /** @@ -386,8 +388,6 @@ 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(requestService, rdbService, objectCache, halService, notificationsService, comparator, browseService, bundleService); + super('items', 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 6781badfb0..ff6025f7ac 100644 --- a/src/app/core/data/item-request-data.service.ts +++ b/src/app/core/data/item-request-data.service.ts @@ -23,15 +23,13 @@ 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(requestService, rdbService, objectCache, halService); + super('itemrequests', 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 b8e8ec6301..634c966dba 100644 --- a/src/app/core/data/item-template-data.service.ts +++ b/src/app/core/data/item-template-data.service.ts @@ -22,8 +22,6 @@ 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( @@ -34,10 +32,10 @@ class CollectionItemTemplateDataService extends IdentifiableDataService { protected notificationsService: NotificationsService, protected collectionService: CollectionDataService, ) { - super(requestService, rdbService, objectCache, halService); + super('itemtemplates', requestService, rdbService, objectCache, halService, undefined); // We only intend to use createOnEndpoint, so this inner data service feature doesn't need an endpoint at all - this.createData = new CreateDataImpl(this.linkPath, this.responseMsToLive, requestService, rdbService, objectCache, halService, notificationsService); + this.createData = new CreateDataImpl(undefined, requestService, rdbService, objectCache, halService, notificationsService, this.responseMsToLive); } /** @@ -67,8 +65,6 @@ class CollectionItemTemplateDataService extends IdentifiableDataService { */ @Injectable() export class ItemTemplateDataService extends BaseItemDataService { - protected linkPath = 'itemtemplates'; - private byCollection: CollectionItemTemplateDataService; constructor( @@ -82,7 +78,7 @@ export class ItemTemplateDataService extends BaseItemDataService { protected bundleService: BundleDataService, protected collectionService: CollectionDataService, ) { - super(requestService, rdbService, objectCache, halService, notificationsService, comparator, browseService, bundleService); + super('itemtemplates', 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 519b68f40c..db9361ee4c 100644 --- a/src/app/core/data/metadata-field-data.service.ts +++ b/src/app/core/data/metadata-field-data.service.ts @@ -29,8 +29,6 @@ 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; @@ -46,12 +44,12 @@ export class MetadataFieldDataService extends IdentifiableDataService implements FindAllData, DeleteData { - protected linkPath = 'metadataschemas'; - private createData: CreateData; private findAllData: FindAllData; private putData: PutData; @@ -41,12 +39,12 @@ export class MetadataSchemaDataService extends IdentifiableDataService implements FindAllData { - protected linkPath = 'processes'; - private findAllData: FindAllData; constructor( @@ -31,9 +29,9 @@ export class ProcessDataService extends IdentifiableDataService impleme protected halService: HALEndpointService, protected bitstreamDataService: BitstreamDataService, ) { - super(requestService, rdbService, objectCache, halService); + super('processes', requestService, rdbService, objectCache, halService); - this.findAllData = new FindAllDataImpl(this.linkPath, this.responseMsToLive, requestService, rdbService, objectCache, halService); + this.findAllData = new FindAllDataImpl(this.linkPath, requestService, rdbService, objectCache, halService, this.responseMsToLive); } /** diff --git a/src/app/core/data/processes/script-data.service.ts b/src/app/core/data/processes/script-data.service.ts index 39666da86b..ed228612ef 100644 --- a/src/app/core/data/processes/script-data.service.ts +++ b/src/app/core/data/processes/script-data.service.ts @@ -28,8 +28,6 @@ export const METADATA_EXPORT_SCRIPT_NAME = 'metadata-export'; @Injectable() @dataService(SCRIPT) export class ScriptDataService extends IdentifiableDataService