mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
93803: Refactor existing data services
This commit is contained in:
@@ -1,14 +1,12 @@
|
||||
/* eslint-disable max-classes-per-file */
|
||||
import { combineLatest as observableCombineLatest, Observable } from 'rxjs';
|
||||
import { Injectable, OnDestroy } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
import { map, switchMap, take } from 'rxjs/operators';
|
||||
import { FollowLinkConfig } from '../../../shared/utils/follow-link-config.model';
|
||||
import { LinkService } from '../../cache/builders/link.service';
|
||||
import { PaginatedList } from '../../data/paginated-list.model';
|
||||
import { ResponseParsingService } from '../../data/parsing.service';
|
||||
import { RemoteData } from '../../data/remote-data';
|
||||
import { GetRequest} from '../../data/request.models';
|
||||
import { GetRequest } from '../../data/request.models';
|
||||
import { RequestService } from '../../data/request.service';
|
||||
import { DSpaceObject } from '../dspace-object.model';
|
||||
import { GenericConstructor } from '../generic-constructor';
|
||||
@@ -21,7 +19,6 @@ import { SearchResponseParsingService } from '../../data/search-response-parsing
|
||||
import { SearchObjects } from '../../../shared/search/models/search-objects.model';
|
||||
import { FacetValueResponseParsingService } from '../../data/facet-value-response-parsing.service';
|
||||
import { PaginatedSearchOptions } from '../../../shared/search/models/paginated-search-options.model';
|
||||
import { CommunityDataService } from '../../data/community-data.service';
|
||||
import { ViewMode } from '../view-mode.model';
|
||||
import { DSpaceObjectDataService } from '../../data/dspace-object-data.service';
|
||||
import { RemoteDataBuildService } from '../../cache/builders/remote-data-build.service';
|
||||
@@ -34,31 +31,19 @@ import { FacetValues } from '../../../shared/search/models/facet-values.model';
|
||||
import { PaginationService } from '../../pagination/pagination.service';
|
||||
import { SearchConfigurationService } from './search-configuration.service';
|
||||
import { PaginationComponentOptions } from '../../../shared/pagination/pagination-component-options.model';
|
||||
import { DataService } from '../../data/data.service';
|
||||
import { Store } from '@ngrx/store';
|
||||
import { ObjectCacheService } from '../../cache/object-cache.service';
|
||||
import { NotificationsService } from '../../../shared/notifications/notifications.service';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { DSOChangeAnalyzer } from '../../data/dso-change-analyzer.service';
|
||||
import { RestRequest } from '../../data/rest-request.model';
|
||||
import { CoreState } from '../../core-state.model';
|
||||
import { BaseDataService } from '../../data/base/base-data.service';
|
||||
|
||||
/**
|
||||
* A class that lets us delegate some methods to DataService
|
||||
* A limited data service implementation for the 'discover' endpoint
|
||||
* - Overrides {@link BaseDataService.addEmbedParams} in order to make it public
|
||||
*
|
||||
* Doesn't use any of the service's dependencies, they are initialized as undefined
|
||||
* Therefore, equest/response handling methods won't work even though they're defined
|
||||
*/
|
||||
class DataServiceImpl extends DataService<any> {
|
||||
protected linkPath = 'discover';
|
||||
|
||||
constructor(
|
||||
protected requestService: RequestService,
|
||||
protected rdbService: RemoteDataBuildService,
|
||||
protected store: Store<CoreState>,
|
||||
protected objectCache: ObjectCacheService,
|
||||
protected halService: HALEndpointService,
|
||||
protected notificationsService: NotificationsService,
|
||||
protected http: HttpClient,
|
||||
protected comparator: DSOChangeAnalyzer<any>) {
|
||||
super();
|
||||
class SearchDataService extends BaseDataService<any> {
|
||||
constructor() {
|
||||
super('discover', undefined, undefined, undefined, undefined);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -99,31 +84,20 @@ export class SearchService implements OnDestroy {
|
||||
private sub;
|
||||
|
||||
/**
|
||||
* Instance of DataServiceImpl that lets us delegate some methods to DataService
|
||||
* Instance of SearchDataService to forward data service methods to
|
||||
*/
|
||||
private searchDataService: DataServiceImpl;
|
||||
private searchDataService: SearchDataService;
|
||||
|
||||
constructor(private router: Router,
|
||||
private routeService: RouteService,
|
||||
protected requestService: RequestService,
|
||||
private rdb: RemoteDataBuildService,
|
||||
private linkService: LinkService,
|
||||
private halService: HALEndpointService,
|
||||
private communityService: CommunityDataService,
|
||||
private dspaceObjectService: DSpaceObjectDataService,
|
||||
private paginationService: PaginationService,
|
||||
private searchConfigurationService: SearchConfigurationService
|
||||
constructor(
|
||||
private routeService: RouteService,
|
||||
protected requestService: RequestService,
|
||||
private rdb: RemoteDataBuildService,
|
||||
private halService: HALEndpointService,
|
||||
private dspaceObjectService: DSpaceObjectDataService,
|
||||
private paginationService: PaginationService,
|
||||
private searchConfigurationService: SearchConfigurationService,
|
||||
) {
|
||||
this.searchDataService = new DataServiceImpl(
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined
|
||||
);
|
||||
this.searchDataService = new SearchDataService();
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user