mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-08 02:24:11 +00:00
[CST-3088] Removed metadata and collection params when making vocabulary requests
This commit is contained in:
@@ -8,9 +8,7 @@ import { isNotEmpty } from '../../../../shared/empty.util';
|
|||||||
*/
|
*/
|
||||||
export class VocabularyFindOptions extends FindListOptions {
|
export class VocabularyFindOptions extends FindListOptions {
|
||||||
|
|
||||||
constructor(public collection,
|
constructor(public query: string = '',
|
||||||
public metadata,
|
|
||||||
public query: string = '',
|
|
||||||
public filter?: string,
|
public filter?: string,
|
||||||
public exact?: boolean,
|
public exact?: boolean,
|
||||||
public entryID?: string,
|
public entryID?: string,
|
||||||
@@ -21,12 +19,7 @@ export class VocabularyFindOptions extends FindListOptions {
|
|||||||
super();
|
super();
|
||||||
|
|
||||||
const searchParams = [];
|
const searchParams = [];
|
||||||
if (isNotEmpty(metadata)) {
|
|
||||||
searchParams.push(new RequestParam('metadata', metadata))
|
|
||||||
}
|
|
||||||
if (isNotEmpty(collection)) {
|
|
||||||
searchParams.push(new RequestParam('collection', collection))
|
|
||||||
}
|
|
||||||
if (isNotEmpty(query)) {
|
if (isNotEmpty(query)) {
|
||||||
searchParams.push(new RequestParam('query', query))
|
searchParams.push(new RequestParam('query', query))
|
||||||
}
|
}
|
||||||
|
@@ -13,7 +13,7 @@ import { VocabularyEntriesRequest } from '../../data/request.models';
|
|||||||
import { RequestParam } from '../../cache/models/request-param.model';
|
import { RequestParam } from '../../cache/models/request-param.model';
|
||||||
import { PageInfo } from '../../shared/page-info.model';
|
import { PageInfo } from '../../shared/page-info.model';
|
||||||
import { PaginatedList } from '../../data/paginated-list';
|
import { PaginatedList } from '../../data/paginated-list';
|
||||||
import { createSuccessfulRemoteDataObject } from '../../../shared/remote-data.utils';
|
import { createSuccessfulRemoteDataObject, createSuccessfulRemoteDataObject$ } from '../../../shared/remote-data.utils';
|
||||||
import { RequestEntry } from '../../data/request.reducer';
|
import { RequestEntry } from '../../data/request.reducer';
|
||||||
import { RestResponse } from '../../cache/response.models';
|
import { RestResponse } from '../../cache/response.models';
|
||||||
import { VocabularyService } from './vocabulary.service';
|
import { VocabularyService } from './vocabulary.service';
|
||||||
@@ -67,6 +67,27 @@ describe('VocabularyService', () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const vocabularyEntry: any = {
|
||||||
|
display: 'testValue1',
|
||||||
|
value: 'testValue1',
|
||||||
|
otherInformation: {},
|
||||||
|
type: 'vocabularyEntry'
|
||||||
|
};
|
||||||
|
|
||||||
|
const vocabularyEntry2: any = {
|
||||||
|
display: 'testValue2',
|
||||||
|
value: 'testValue2',
|
||||||
|
otherInformation: {},
|
||||||
|
type: 'vocabularyEntry'
|
||||||
|
};
|
||||||
|
|
||||||
|
const vocabularyEntry3: any = {
|
||||||
|
display: 'testValue3',
|
||||||
|
value: 'testValue3',
|
||||||
|
otherInformation: {},
|
||||||
|
type: 'vocabularyEntry'
|
||||||
|
};
|
||||||
|
|
||||||
const vocabularyEntryParentDetail: any = {
|
const vocabularyEntryParentDetail: any = {
|
||||||
authority: 'authorityId2',
|
authority: 'authorityId2',
|
||||||
display: 'testParent',
|
display: 'testParent',
|
||||||
@@ -148,10 +169,10 @@ describe('VocabularyService', () => {
|
|||||||
const collectionUUID = '8b39g7ya-5a4b-438b-851f-be1d5b4a1c5a';
|
const collectionUUID = '8b39g7ya-5a4b-438b-851f-be1d5b4a1c5a';
|
||||||
const entryID = 'dsfsfsdf-5a4b-438b-851f-be1d5b4a1c5a';
|
const entryID = 'dsfsfsdf-5a4b-438b-851f-be1d5b4a1c5a';
|
||||||
const searchRequestURL = `https://rest.api/rest/api/submission/vocabularies/search/byMetadataAndCollection?metadata=${metadata}&collection=${collectionUUID}`;
|
const searchRequestURL = `https://rest.api/rest/api/submission/vocabularies/search/byMetadataAndCollection?metadata=${metadata}&collection=${collectionUUID}`;
|
||||||
const entriesRequestURL = `https://rest.api/rest/api/submission/vocabularies/${vocabulary.id}/entries?metadata=${metadata}&collection=${collectionUUID}`;
|
const entriesRequestURL = `https://rest.api/rest/api/submission/vocabularies/${vocabulary.id}/entries`;
|
||||||
const entriesByValueRequestURL = `https://rest.api/rest/api/submission/vocabularies/${vocabulary.id}/entries?metadata=${metadata}&collection=${collectionUUID}&filter=test&exact=false`;
|
const entriesByValueRequestURL = `https://rest.api/rest/api/submission/vocabularies/${vocabulary.id}/entries?filter=test&exact=false`;
|
||||||
const entryByValueRequestURL = `https://rest.api/rest/api/submission/vocabularies/${vocabulary.id}/entries?metadata=${metadata}&collection=${collectionUUID}&filter=test&exact=true`;
|
const entryByValueRequestURL = `https://rest.api/rest/api/submission/vocabularies/${vocabulary.id}/entries?filter=test&exact=true`;
|
||||||
const entryByIDRequestURL = `https://rest.api/rest/api/submission/vocabularies/${vocabulary.id}/entries?metadata=${metadata}&collection=${collectionUUID}&entryID=${entryID}`;
|
const entryByIDRequestURL = `https://rest.api/rest/api/submission/vocabularies/${vocabulary.id}/entries?entryID=${entryID}`;
|
||||||
const vocabularyOptions: VocabularyOptions = {
|
const vocabularyOptions: VocabularyOptions = {
|
||||||
name: vocabularyId,
|
name: vocabularyId,
|
||||||
metadata: metadata,
|
metadata: metadata,
|
||||||
@@ -160,16 +181,19 @@ describe('VocabularyService', () => {
|
|||||||
}
|
}
|
||||||
const pageInfo = new PageInfo();
|
const pageInfo = new PageInfo();
|
||||||
const array = [vocabulary, hierarchicalVocabulary];
|
const array = [vocabulary, hierarchicalVocabulary];
|
||||||
|
const arrayEntries = [vocabularyEntry, vocabularyEntry2, vocabularyEntry3];
|
||||||
const childrenEntries = [vocabularyEntryChildDetail, vocabularyEntryChild2Detail];
|
const childrenEntries = [vocabularyEntryChildDetail, vocabularyEntryChild2Detail];
|
||||||
const paginatedList = new PaginatedList(pageInfo, array);
|
const paginatedList = new PaginatedList(pageInfo, array);
|
||||||
|
const paginatedListEntries = new PaginatedList(pageInfo, arrayEntries);
|
||||||
const childrenPaginatedList = new PaginatedList(pageInfo, childrenEntries);
|
const childrenPaginatedList = new PaginatedList(pageInfo, childrenEntries);
|
||||||
const vocabularyRD = createSuccessfulRemoteDataObject(vocabulary);
|
const vocabularyRD = createSuccessfulRemoteDataObject(vocabulary);
|
||||||
|
const vocabularyEntriesRD = createSuccessfulRemoteDataObject$(paginatedListEntries);
|
||||||
const vocabularyEntryDetailParentRD = createSuccessfulRemoteDataObject(vocabularyEntryParentDetail);
|
const vocabularyEntryDetailParentRD = createSuccessfulRemoteDataObject(vocabularyEntryParentDetail);
|
||||||
const vocabularyEntryChildrenRD = createSuccessfulRemoteDataObject(childrenPaginatedList);
|
const vocabularyEntryChildrenRD = createSuccessfulRemoteDataObject(childrenPaginatedList);
|
||||||
const paginatedListRD = createSuccessfulRemoteDataObject(paginatedList);
|
const paginatedListRD = createSuccessfulRemoteDataObject(paginatedList);
|
||||||
const getRequestEntry$ = (successful: boolean) => {
|
const getRequestEntries$ = (successful: boolean) => {
|
||||||
return observableOf({
|
return observableOf({
|
||||||
response: { isSuccessful: successful, payload: vocabulary } as any
|
response: { isSuccessful: successful, payload: arrayEntries } as any
|
||||||
} as RequestEntry)
|
} as RequestEntry)
|
||||||
};
|
};
|
||||||
objectCache = {} as ObjectCacheService;
|
objectCache = {} as ObjectCacheService;
|
||||||
@@ -312,8 +336,8 @@ describe('VocabularyService', () => {
|
|||||||
describe('', () => {
|
describe('', () => {
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
requestService = getMockRequestService(getRequestEntry$(true));
|
requestService = getMockRequestService(getRequestEntries$(true));
|
||||||
rdbService = getMockRemoteDataBuildService();
|
rdbService = getMockRemoteDataBuildService(undefined, vocabularyEntriesRD);
|
||||||
spyOn(rdbService, 'toRemoteDataObservable').and.callThrough();
|
spyOn(rdbService, 'toRemoteDataObservable').and.callThrough();
|
||||||
service = initTestService();
|
service = initTestService();
|
||||||
});
|
});
|
||||||
@@ -329,10 +353,10 @@ describe('VocabularyService', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should call RemoteDataBuildService to create the RemoteData Observable', () => {
|
it('should call RemoteDataBuildService to create the RemoteData Observable', () => {
|
||||||
service.getVocabularyEntries(vocabularyOptions, pageInfo);
|
scheduler.schedule(() => service.getVocabularyEntries(vocabularyOptions, pageInfo));
|
||||||
|
scheduler.flush();
|
||||||
|
|
||||||
expect(rdbService.toRemoteDataObservable).toHaveBeenCalled();
|
expect(rdbService.toRemoteDataObservable).toHaveBeenCalled();
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -347,7 +371,8 @@ describe('VocabularyService', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should call RemoteDataBuildService to create the RemoteData Observable', () => {
|
it('should call RemoteDataBuildService to create the RemoteData Observable', () => {
|
||||||
service.getVocabularyEntriesByValue('test', false, vocabularyOptions, pageInfo);
|
scheduler.schedule(() => service.getVocabularyEntriesByValue('test', false, vocabularyOptions, pageInfo));
|
||||||
|
scheduler.flush();
|
||||||
|
|
||||||
expect(rdbService.toRemoteDataObservable).toHaveBeenCalled();
|
expect(rdbService.toRemoteDataObservable).toHaveBeenCalled();
|
||||||
|
|
||||||
@@ -365,7 +390,8 @@ describe('VocabularyService', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should call RemoteDataBuildService to create the RemoteData Observable', () => {
|
it('should call RemoteDataBuildService to create the RemoteData Observable', () => {
|
||||||
service.getVocabularyEntryByValue('test', vocabularyOptions);
|
scheduler.schedule(() => service.getVocabularyEntryByValue('test', vocabularyOptions));
|
||||||
|
scheduler.flush();
|
||||||
|
|
||||||
expect(rdbService.toRemoteDataObservable).toHaveBeenCalled();
|
expect(rdbService.toRemoteDataObservable).toHaveBeenCalled();
|
||||||
|
|
||||||
@@ -383,7 +409,8 @@ describe('VocabularyService', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should call RemoteDataBuildService to create the RemoteData Observable', () => {
|
it('should call RemoteDataBuildService to create the RemoteData Observable', () => {
|
||||||
service.getVocabularyEntryByID('test', vocabularyOptions);
|
scheduler.schedule(() => service.getVocabularyEntryByID('test', vocabularyOptions));
|
||||||
|
scheduler.flush();
|
||||||
|
|
||||||
expect(rdbService.toRemoteDataObservable).toHaveBeenCalled();
|
expect(rdbService.toRemoteDataObservable).toHaveBeenCalled();
|
||||||
|
|
||||||
@@ -495,8 +522,6 @@ describe('VocabularyService', () => {
|
|||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
null,
|
|
||||||
null,
|
|
||||||
pageInfo.elementsPerPage,
|
pageInfo.elementsPerPage,
|
||||||
pageInfo.currentPage
|
pageInfo.currentPage
|
||||||
);
|
);
|
||||||
@@ -522,8 +547,6 @@ describe('VocabularyService', () => {
|
|||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
null,
|
|
||||||
null,
|
|
||||||
pageInfo.elementsPerPage,
|
pageInfo.elementsPerPage,
|
||||||
pageInfo.currentPage
|
pageInfo.currentPage
|
||||||
);
|
);
|
||||||
|
@@ -150,8 +150,6 @@ export class VocabularyService {
|
|||||||
getVocabularyEntries(vocabularyOptions: VocabularyOptions, pageInfo: PageInfo): Observable<RemoteData<PaginatedList<VocabularyEntry>>> {
|
getVocabularyEntries(vocabularyOptions: VocabularyOptions, pageInfo: PageInfo): Observable<RemoteData<PaginatedList<VocabularyEntry>>> {
|
||||||
|
|
||||||
const options: VocabularyFindOptions = new VocabularyFindOptions(
|
const options: VocabularyFindOptions = new VocabularyFindOptions(
|
||||||
vocabularyOptions.scope,
|
|
||||||
vocabularyOptions.metadata,
|
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
@@ -179,8 +177,6 @@ export class VocabularyService {
|
|||||||
*/
|
*/
|
||||||
getVocabularyEntriesByValue(value: string, exact: boolean, vocabularyOptions: VocabularyOptions, pageInfo: PageInfo): Observable<RemoteData<PaginatedList<VocabularyEntry>>> {
|
getVocabularyEntriesByValue(value: string, exact: boolean, vocabularyOptions: VocabularyOptions, pageInfo: PageInfo): Observable<RemoteData<PaginatedList<VocabularyEntry>>> {
|
||||||
const options: VocabularyFindOptions = new VocabularyFindOptions(
|
const options: VocabularyFindOptions = new VocabularyFindOptions(
|
||||||
vocabularyOptions.scope,
|
|
||||||
vocabularyOptions.metadata,
|
|
||||||
null,
|
null,
|
||||||
value,
|
value,
|
||||||
exact,
|
exact,
|
||||||
@@ -229,8 +225,6 @@ export class VocabularyService {
|
|||||||
getVocabularyEntryByID(ID: string, vocabularyOptions: VocabularyOptions): Observable<VocabularyEntry> {
|
getVocabularyEntryByID(ID: string, vocabularyOptions: VocabularyOptions): Observable<VocabularyEntry> {
|
||||||
const pageInfo = new PageInfo()
|
const pageInfo = new PageInfo()
|
||||||
const options: VocabularyFindOptions = new VocabularyFindOptions(
|
const options: VocabularyFindOptions = new VocabularyFindOptions(
|
||||||
vocabularyOptions.scope,
|
|
||||||
vocabularyOptions.metadata,
|
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
@@ -335,8 +329,6 @@ export class VocabularyService {
|
|||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
null,
|
|
||||||
null,
|
|
||||||
pageInfo.elementsPerPage,
|
pageInfo.elementsPerPage,
|
||||||
pageInfo.currentPage
|
pageInfo.currentPage
|
||||||
);
|
);
|
||||||
@@ -358,8 +350,6 @@ export class VocabularyService {
|
|||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
null,
|
|
||||||
null,
|
|
||||||
pageInfo.elementsPerPage,
|
pageInfo.elementsPerPage,
|
||||||
pageInfo.currentPage
|
pageInfo.currentPage
|
||||||
);
|
);
|
||||||
|
Reference in New Issue
Block a user