mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-09 19:13:08 +00:00
scope now uses DSO endpoint instead of PID
This commit is contained in:
@@ -10,10 +10,9 @@ module.exports = {
|
||||
// The REST API server settings.
|
||||
rest: {
|
||||
ssl: true,
|
||||
host: 'dspace7.4science.it',
|
||||
host: 'dspace7-internal.atmire.com',
|
||||
port: 443,
|
||||
// NOTE: Space is capitalized because 'namespace' is a reserved string in TypeScript
|
||||
nameSpace: '/dspace-spring-rest/api'
|
||||
nameSpace: '/rest/api'
|
||||
},
|
||||
// Caching settings
|
||||
cache: {
|
||||
|
@@ -1,6 +1,6 @@
|
||||
import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { flatMap, } from 'rxjs/operators';
|
||||
import { flatMap, switchMap, } from 'rxjs/operators';
|
||||
import { PaginatedList } from '../core/data/paginated-list';
|
||||
import { RemoteData } from '../core/data/remote-data';
|
||||
import { DSpaceObject } from '../core/shared/dspace-object.model';
|
||||
@@ -83,7 +83,7 @@ export class SearchPageComponent implements OnInit {
|
||||
this.resultsRD$.next(results);
|
||||
});
|
||||
this.scopeListRD$ = this.searchConfigService.getCurrentScope('').pipe(
|
||||
flatMap((scopeId) => this.service.getScopes(scopeId))
|
||||
switchMap((scopeId) => this.service.getScopes(scopeId))
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -27,7 +27,7 @@ import { SearchQueryResponse } from './search-query-response.model';
|
||||
import { SearchFilterConfig } from './search-filter-config.model';
|
||||
import { CommunityDataService } from '../../core/data/community-data.service';
|
||||
import { ViewMode } from '../../core/shared/view-mode.model';
|
||||
import { PIDService } from '../../core/data/pid.service';
|
||||
import { DSpaceObjectDataService } from '../../core/data/dspace-object-data.service';
|
||||
|
||||
@Component({ template: '' })
|
||||
class DummyComponent {
|
||||
@@ -57,7 +57,7 @@ describe('SearchService', () => {
|
||||
{ provide: RemoteDataBuildService, useValue: {} },
|
||||
{ provide: HALEndpointService, useValue: {} },
|
||||
{ provide: CommunityDataService, useValue: {}},
|
||||
{ provide: PIDService, useValue: {}},
|
||||
{ provide: DSpaceObjectDataService, useValue: {}},
|
||||
SearchService
|
||||
],
|
||||
});
|
||||
@@ -114,7 +114,7 @@ describe('SearchService', () => {
|
||||
{ provide: RemoteDataBuildService, useValue: remoteDataBuildService },
|
||||
{ provide: HALEndpointService, useValue: halService },
|
||||
{ provide: CommunityDataService, useValue: {}},
|
||||
{ provide: PIDService, useValue: {}},
|
||||
{ provide: DSpaceObjectDataService, useValue: {}},
|
||||
SearchService
|
||||
],
|
||||
});
|
||||
|
@@ -7,7 +7,7 @@ import {
|
||||
UrlSegmentGroup
|
||||
} from '@angular/router';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { flatMap, map } from 'rxjs/operators';
|
||||
import { flatMap, map, switchMap } from 'rxjs/operators';
|
||||
import { RemoteDataBuildService } from '../../core/cache/builders/remote-data-build.service';
|
||||
import {
|
||||
FacetConfigSuccessResponse,
|
||||
@@ -24,7 +24,7 @@ import { RequestService } from '../../core/data/request.service';
|
||||
import { DSpaceObject } from '../../core/shared/dspace-object.model';
|
||||
import { GenericConstructor } from '../../core/shared/generic-constructor';
|
||||
import { HALEndpointService } from '../../core/shared/hal-endpoint.service';
|
||||
import { configureRequest } from '../../core/shared/operators';
|
||||
import { configureRequest, getSucceededRemoteData } from '../../core/shared/operators';
|
||||
import { URLCombiner } from '../../core/url-combiner/url-combiner';
|
||||
import { hasValue, isEmpty, isNotEmpty } from '../../shared/empty.util';
|
||||
import { NormalizedSearchResult } from '../normalized-search-result.model';
|
||||
@@ -43,8 +43,8 @@ import { PaginatedSearchOptions } from '../paginated-search-options.model';
|
||||
import { Community } from '../../core/shared/community.model';
|
||||
import { CommunityDataService } from '../../core/data/community-data.service';
|
||||
import { ViewMode } from '../../core/shared/view-mode.model';
|
||||
import { PIDService } from '../../core/data/pid.service';
|
||||
import { ResourceType } from '../../core/shared/resource-type';
|
||||
import { DSpaceObjectDataService } from '../../core/data/dspace-object-data.service';
|
||||
|
||||
/**
|
||||
* Service that performs all general actions that have to do with the search page
|
||||
@@ -73,7 +73,7 @@ export class SearchService implements OnDestroy {
|
||||
private rdb: RemoteDataBuildService,
|
||||
private halService: HALEndpointService,
|
||||
private communityService: CommunityDataService,
|
||||
private pidService: PIDService
|
||||
private dspaceObjectService: DSpaceObjectDataService
|
||||
) {
|
||||
}
|
||||
|
||||
@@ -267,9 +267,9 @@ export class SearchService implements OnDestroy {
|
||||
return top;
|
||||
}
|
||||
|
||||
const scopeObject: Observable<RemoteData<DSpaceObject>> = this.pidService.findById(scopeId).filter((dsoRD: RemoteData<DSpaceObject>) => !dsoRD.isLoading);
|
||||
const scopeObject: Observable<RemoteData<DSpaceObject>> = this.dspaceObjectService.findById(scopeId).pipe(getSucceededRemoteData());
|
||||
const scopeList: Observable<DSpaceObject[]> = scopeObject.pipe(
|
||||
flatMap((dsoRD: RemoteData<DSpaceObject>) => {
|
||||
switchMap((dsoRD: RemoteData<DSpaceObject>) => {
|
||||
if (dsoRD.payload.type === ResourceType.Community) {
|
||||
const community: Community = dsoRD.payload as Community;
|
||||
return Observable.combineLatest(community.subcommunities, community.collections, (subCommunities, collections) => {
|
||||
|
@@ -21,7 +21,6 @@ import { CollectionDataService } from './data/collection-data.service';
|
||||
import { CommunityDataService } from './data/community-data.service';
|
||||
import { DebugResponseParsingService } from './data/debug-response-parsing.service';
|
||||
import { DSOResponseParsingService } from './data/dso-response-parsing.service';
|
||||
import { PIDService } from './data/pid.service';
|
||||
import { SearchResponseParsingService } from './data/search-response-parsing.service';
|
||||
import { DSpaceRESTv2Service } from './dspace-rest-v2/dspace-rest-v2.service';
|
||||
import { FormBuilderService } from '../shared/form/builder/form-builder.service';
|
||||
@@ -63,6 +62,7 @@ import { RegistryMetadatafieldsResponseParsingService } from './data/registry-me
|
||||
import { RegistryBitstreamformatsResponseParsingService } from './data/registry-bitstreamformats-response-parsing.service';
|
||||
import { NotificationsService } from '../shared/notifications/notifications.service';
|
||||
import { UploaderService } from '../shared/uploader/uploader.service';
|
||||
import { DSpaceObjectDataService } from './data/dspace-object-data.service';
|
||||
|
||||
const IMPORTS = [
|
||||
CommonModule,
|
||||
@@ -125,7 +125,7 @@ const PROVIDERS = [
|
||||
IntegrationResponseParsingService,
|
||||
UploaderService,
|
||||
UUIDService,
|
||||
PIDService,
|
||||
DSpaceObjectDataService,
|
||||
// register AuthInterceptor as HttpInterceptor
|
||||
{
|
||||
provide: HTTP_INTERCEPTORS,
|
||||
|
@@ -80,8 +80,7 @@ export abstract class DataService<TNormalized extends NormalizedObject, TDomain>
|
||||
.map((endpoint: string) => this.getFindByIDHref(endpoint, id));
|
||||
|
||||
hrefObs
|
||||
.filter((href: string) => hasValue(href))
|
||||
.take(1)
|
||||
.first((href: string) => hasValue(href))
|
||||
.subscribe((href: string) => {
|
||||
const request = new FindByIDRequest(this.requestService.generateRequestId(), href, id);
|
||||
this.requestService.configure(request);
|
||||
|
@@ -3,28 +3,28 @@ import { TestScheduler } from '../../../../node_modules/rxjs';
|
||||
import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service';
|
||||
import { DSpaceObject } from '../shared/dspace-object.model';
|
||||
import { HALEndpointService } from '../shared/hal-endpoint.service';
|
||||
import { PIDService } from './pid.service';
|
||||
import { FindByIDRequest } from './request.models';
|
||||
import { RequestService } from './request.service';
|
||||
import { DSpaceObjectDataService } from './dspace-object-data.service';
|
||||
|
||||
describe('PIDService', () => {
|
||||
describe('DSpaceObjectDataService', () => {
|
||||
let scheduler: TestScheduler;
|
||||
let service: PIDService;
|
||||
let service: DSpaceObjectDataService;
|
||||
let halService: HALEndpointService;
|
||||
let requestService: RequestService;
|
||||
let rdbService: RemoteDataBuildService;
|
||||
const testObject = {
|
||||
id: '9b4f22f4-164a-49db-8817-3316b6ee5746'
|
||||
uuid: '9b4f22f4-164a-49db-8817-3316b6ee5746'
|
||||
} as DSpaceObject;
|
||||
const pidLink = 'https://rest.api/rest/api/pid/find{?id}';
|
||||
const requestURL = `https://rest.api/rest/api/pid/find?id=${testObject.id}`;
|
||||
const dsoLink = 'https://rest.api/rest/api/dso/find{?uuid}';
|
||||
const requestURL = `https://rest.api/rest/api/dso/find?uuid=${testObject.uuid}`;
|
||||
const requestUUID = '34cfed7c-f597-49ef-9cbe-ea351f0023c2';
|
||||
|
||||
beforeEach(() => {
|
||||
scheduler = getTestScheduler();
|
||||
|
||||
halService = jasmine.createSpyObj('halService', {
|
||||
getEndpoint: cold('a', { a: pidLink })
|
||||
getEndpoint: cold('a', { a: dsoLink })
|
||||
});
|
||||
requestService = jasmine.createSpyObj('requestService', {
|
||||
generateRequestId: requestUUID,
|
||||
@@ -38,7 +38,7 @@ describe('PIDService', () => {
|
||||
})
|
||||
});
|
||||
|
||||
service = new PIDService(
|
||||
service = new DSpaceObjectDataService(
|
||||
requestService,
|
||||
rdbService,
|
||||
halService
|
||||
@@ -46,22 +46,22 @@ describe('PIDService', () => {
|
||||
});
|
||||
|
||||
describe('findById', () => {
|
||||
it('should call HALEndpointService with the path to the pid endpoint', () => {
|
||||
scheduler.schedule(() => service.findById(testObject.id));
|
||||
it('should call HALEndpointService with the path to the dso endpoint', () => {
|
||||
scheduler.schedule(() => service.findById(testObject.uuid));
|
||||
scheduler.flush();
|
||||
|
||||
expect(halService.getEndpoint).toHaveBeenCalledWith('pid');
|
||||
expect(halService.getEndpoint).toHaveBeenCalledWith('dso');
|
||||
});
|
||||
|
||||
it('should configure the proper FindByIDRequest', () => {
|
||||
scheduler.schedule(() => service.findById(testObject.id));
|
||||
scheduler.schedule(() => service.findById(testObject.uuid));
|
||||
scheduler.flush();
|
||||
|
||||
expect(requestService.configure).toHaveBeenCalledWith(new FindByIDRequest(requestUUID, requestURL, testObject.id));
|
||||
expect(requestService.configure).toHaveBeenCalledWith(new FindByIDRequest(requestUUID, requestURL, testObject.uuid));
|
||||
});
|
||||
|
||||
it('should return a RemoteData<DSpaceObject> for the object with the given ID', () => {
|
||||
const result = service.findById(testObject.id);
|
||||
const result = service.findById(testObject.uuid);
|
||||
const expected = cold('a', {
|
||||
a: {
|
||||
payload: testObject
|
@@ -1,8 +1,6 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Store } from '@ngrx/store';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { hasValue } from '../../shared/empty.util';
|
||||
import { BrowseService } from '../browse/browse.service';
|
||||
import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service';
|
||||
import { NormalizedDSpaceObject } from '../cache/models/normalized-dspace-object.model';
|
||||
import { ResponseCacheService } from '../cache/response-cache.service';
|
||||
@@ -11,12 +9,11 @@ import { DSpaceObject } from '../shared/dspace-object.model';
|
||||
import { HALEndpointService } from '../shared/hal-endpoint.service';
|
||||
import { DataService } from './data.service';
|
||||
import { RemoteData } from './remote-data';
|
||||
import { FindByIDRequest } from './request.models';
|
||||
import { RequestService } from './request.service';
|
||||
|
||||
/* tslint:disable:max-classes-per-file */
|
||||
class DataServiceImpl extends DataService<NormalizedDSpaceObject, DSpaceObject> {
|
||||
protected linkPath = 'pid';
|
||||
protected linkPath = 'dso';
|
||||
|
||||
constructor(
|
||||
protected responseCache: ResponseCacheService,
|
||||
@@ -32,13 +29,13 @@ class DataServiceImpl extends DataService<NormalizedDSpaceObject, DSpaceObject>
|
||||
}
|
||||
|
||||
getFindByIDHref(endpoint, resourceID): string {
|
||||
return endpoint.replace(/\{\?id\}/,`?id=${resourceID}`);
|
||||
return endpoint.replace(/\{\?uuid\}/,`?uuid=${resourceID}`);
|
||||
}
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class PIDService {
|
||||
protected linkPath = 'pid';
|
||||
export class DSpaceObjectDataService {
|
||||
protected linkPath = 'dso';
|
||||
private dataService: DataServiceImpl;
|
||||
|
||||
constructor(
|
||||
@@ -48,7 +45,7 @@ export class PIDService {
|
||||
this.dataService = new DataServiceImpl(null, requestService, rdbService, null, halService);
|
||||
}
|
||||
|
||||
findById(id: string): Observable<RemoteData<DSpaceObject>> {
|
||||
return this.dataService.findById(id);
|
||||
findById(uuid: string): Observable<RemoteData<DSpaceObject>> {
|
||||
return this.dataService.findById(uuid);
|
||||
}
|
||||
}
|
@@ -1,5 +1,5 @@
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { filter, flatMap, map, tap } from 'rxjs/operators';
|
||||
import { filter, first, flatMap, map, tap } from 'rxjs/operators';
|
||||
import { hasValueOperator } from '../../shared/empty.util';
|
||||
import { DSOSuccessResponse } from '../cache/response-cache.models';
|
||||
import { ResponseCacheEntry } from '../cache/response-cache.reducer';
|
||||
@@ -45,3 +45,7 @@ export const configureRequest = (requestService: RequestService) =>
|
||||
export const getRemoteDataPayload = () =>
|
||||
<T>(source: Observable<RemoteData<T>>): Observable<T> =>
|
||||
source.pipe(map((remoteData: RemoteData<T>) => remoteData.payload));
|
||||
|
||||
export const getSucceededRemoteData = () =>
|
||||
<T>(source: Observable<RemoteData<T>>): Observable<RemoteData<T>> =>
|
||||
source.pipe(first((rd: RemoteData<T>) => rd.hasSucceeded));
|
||||
|
Reference in New Issue
Block a user