Skip to content

Commit 18821b7

Browse files
committed
Merged dspace-cris-7 into DSC-867
2 parents eed8067 + 74e3cd8 commit 18821b7

33 files changed

Lines changed: 342 additions & 169 deletions

src/app/core/data/item-data.service.spec.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ import { HALEndpointServiceStub } from 'src/app/shared/testing/hal-endpoint-serv
2020
import { testCreateDataImplementation } from './base/create-data.spec';
2121
import { testPatchDataImplementation } from './base/patch-data.spec';
2222
import { testDeleteDataImplementation } from './base/delete-data.spec';
23+
import { RestRequestMethod } from './rest-request-method';
24+
import objectContaining = jasmine.objectContaining;
2325

2426
describe('ItemDataService', () => {
2527
let scheduler: TestScheduler;
@@ -146,11 +148,14 @@ describe('ItemDataService', () => {
146148

147149
beforeEach(() => {
148150
service = initTestService();
149-
result = service.mapToCollection('item-id', 'collection-href');
151+
result = service.mapToCollection('item-id', 'collection-href?query=param');
150152
});
151153

152-
it('should send a POST request', () => {
153-
result.subscribe(() => expect(requestService.send).toHaveBeenCalledWith(jasmine.any(PostRequest)));
154+
it('should send a POST request with stripped query params in collectionHref', () => {
155+
result.subscribe(() => expect(requestService.send).toHaveBeenCalledWith(objectContaining({
156+
method: RestRequestMethod.POST,
157+
body: 'collection-href'
158+
})));
154159
});
155160
});
156161

src/app/core/data/item-data.service.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,8 @@ export abstract class BaseItemDataService extends IdentifiableDataService<Item>
145145
let headers = new HttpHeaders();
146146
headers = headers.append('Content-Type', 'text/uri-list');
147147
options.headers = headers;
148-
return new PostRequest(this.requestService.generateRequestId(), endpointURL, collectionHref, options);
148+
const collectionURI = collectionHref.split('?')[0];
149+
return new PostRequest(this.requestService.generateRequestId(), endpointURL, collectionURI, options);
149150
}),
150151
sendRequest(this.requestService),
151152
switchMap((request: RestRequest) => this.rdbService.buildFromRequestUUID(request.uuid))

src/app/core/data/processes/process-data.service.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ import { dataService } from '../base/data-service.decorator';
1919
import { DeleteData, DeleteDataImpl } from '../base/delete-data';
2020
import { NotificationsService } from '../../../shared/notifications/notifications.service';
2121
import { NoContent } from '../../shared/NoContent.model';
22-
import { SearchData } from '../base/search-data';
22+
import { SearchData, SearchDataImpl } from '../base/search-data';
2323

2424
@Injectable()
2525
@dataService(PROCESS)
2626
export class ProcessDataService extends IdentifiableDataService<Process> implements FindAllData<Process>, DeleteData<Process> {
27-
protected findOwnLink = 'own';
27+
protected findOwnLink = 'search/own';
2828

2929
private findAllData: FindAllData<Process>;
3030
private deleteData: DeleteData<Process>;
@@ -42,6 +42,7 @@ export class ProcessDataService extends IdentifiableDataService<Process> impleme
4242

4343
this.findAllData = new FindAllDataImpl(this.linkPath, requestService, rdbService, objectCache, halService, this.responseMsToLive);
4444
this.deleteData = new DeleteDataImpl(this.linkPath, requestService, rdbService, objectCache, halService, notificationsService, this.responseMsToLive, this.constructIdEndpoint);
45+
this.searchData = new SearchDataImpl(this.linkPath, requestService, rdbService, objectCache, halService, this.responseMsToLive, this.constructIdEndpoint);
4546
}
4647

4748
/**
@@ -139,7 +140,7 @@ export class ProcessDataService extends IdentifiableDataService<Process> impleme
139140
* Return an observable that emits object list
140141
*/
141142
searchItsOwnProcesses(options?: FindListOptions, useCachedVersionIfAvailable?: boolean, reRequestOnStale?: boolean, ...linksToFollow: FollowLinkConfig<Process>[]): Observable<RemoteData<PaginatedList<Process>>> {
142-
return this.searchData.searchBy(this.findOwnLink, options);
143+
return this.searchData.searchBy(this.findOwnLink, options, useCachedVersionIfAvailable, reRequestOnStale, ...linksToFollow);
143144
}
144145

145146
/**

src/app/core/submission/models/edititem-mode.model.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,6 @@ export class EditItemMode extends CacheableObject {
4141
@autoserialize
4242
label: string;
4343

44-
/**
45-
* Security level of this EditItem Mode
46-
* Allowed value are:
47-
* 1 = Admin
48-
* 2 = Owner
49-
* 3 = Admin+Owner
50-
* 4 = Custom
51-
*/
52-
@autoserialize
53-
security: number;
54-
5544
/**
5645
* Name of the Submission Definition used
5746
* for this EditItem mode

src/app/core/submission/vocabularies/vocabulary.service.ts

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
11
import { Injectable } from '@angular/core';
22
import { Observable } from 'rxjs';
33
import { first, map, mergeMap, switchMap } from 'rxjs/operators';
4-
import { FollowLinkConfig, followLink } from '../../../shared/utils/follow-link-config.model';
4+
import { followLink, FollowLinkConfig } from '../../../shared/utils/follow-link-config.model';
55
import { RequestService } from '../../data/request.service';
66
import { RemoteData } from '../../data/remote-data';
77
import { PaginatedList } from '../../data/paginated-list.model';
88
import { Vocabulary } from './models/vocabulary.model';
99
import { VocabularyEntry } from './models/vocabulary-entry.model';
1010
import { hasValue, isNotEmpty } from '../../../shared/empty.util';
11-
import {
12-
getFirstSucceededRemoteDataPayload,
13-
getFirstSucceededRemoteListPayload
14-
} from '../../shared/operators';
11+
import { getFirstSucceededRemoteDataPayload, getFirstSucceededRemoteListPayload } from '../../shared/operators';
1512
import { VocabularyFindOptions } from './models/vocabulary-find-options.model';
1613
import { VocabularyEntryDetail } from './models/vocabulary-entry-detail.model';
1714
import { RequestParam } from '../../cache/models/request-param.model';
@@ -153,8 +150,27 @@ export class VocabularyService {
153150
*/
154151
getPublicVocabularyEntryByValue(vocabularyName: string, value: string): Observable<RemoteData<PaginatedList<VocabularyEntryDetail>>> {
155152
const params: RequestParam[] = [
156-
new RequestParam('filter',value),
157-
new RequestParam('exact','true')
153+
new RequestParam('filter', value),
154+
new RequestParam('exact', 'true')
155+
];
156+
const options = Object.assign(new FindListOptions(), {
157+
searchParams: params,
158+
elementsPerPage: 1,
159+
});
160+
const href$ = this.vocabularyDataService.getFindAllHref(options, vocabularyName + '/entries');
161+
return this.vocabularyEntryDetailDataService.findListByHref(href$);
162+
}
163+
164+
/**
165+
* Get the display value for a hierarchical vocabulary item,
166+
* given the vocabulary name and the entryID of that vocabulary-entry
167+
*
168+
* @param vocabularyName
169+
* @param entryID
170+
*/
171+
getPublicVocabularyEntryByID(vocabularyName: string, entryID: string): Observable<RemoteData<PaginatedList<VocabularyEntryDetail>>> {
172+
const params: RequestParam[] = [
173+
new RequestParam('entryID', entryID)
158174
];
159175
const options = Object.assign(new FindListOptions(), {
160176
searchParams: params,

src/app/cris-layout/cris-layout-matrix/cris-layout-box-container/boxes/metadata/rendering-types/advanced-attachment/advanced-attachment.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
<ng-container *ngIf="attachmentConf.type == AdvancedAttachmentElementType.Metadata">
2121

22-
<p class="word-break m-0" *ngIf="!attachmentConf.truncatable">
22+
<p class="text-break m-0" data-test="attachment-name" *ngIf="!attachmentConf.truncatable">
2323
{{attachment.firstMetadataValue(attachmentConf.name)}}
2424
</p>
2525

src/app/cris-layout/cris-layout-matrix/cris-layout-box-container/boxes/metadata/rendering-types/advanced-attachment/advanced-attachment.component.spec.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,11 @@ describe('AdvancedAttachmentComponent', () => {
208208
expect(entries[0].query(By.css('[data-test="checksum"]'))).toBeTruthy();
209209
});
210210

211+
it('should wrap the title', () => {
212+
const titleElement = de.query(By.css('[data-test="attachment-name"]')).nativeElement;
213+
expect(titleElement.classList).toContain('text-break');
214+
});
215+
211216
describe('and the field has metadata key and value set as value', () => {
212217
beforeEach(() => {
213218
// NOTE: Cannot override providers once components have been compiled, so TestBed needs to be reset

src/app/cris-layout/cris-layout-matrix/cris-layout-box-container/boxes/metadata/rendering-types/attachment/bitstream-attachment-rendering.model.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ export abstract class BitstreamAttachmentRenderingModelComponent extends Bitstre
3434

3535
getBitstreamsByItem(options?: FindListOptions): Observable<PaginatedList<Bitstream>> {
3636
return this.bitstreamDataService
37-
.findShowableBitstreamsByItem(this.item.uuid, this.field.bitstream.bundle, this.getMetadataFilters(), options, false, false, followLink('thumbnail'))
37+
.findShowableBitstreamsByItem(this.item.uuid, this.field.bitstream.bundle, this.getMetadataFilters(), options,
38+
false, false, followLink('thumbnail'), followLink('format'))
3839
.pipe(
3940
getFirstCompletedRemoteData(),
4041
map((response: RemoteData<PaginatedList<Bitstream>>) => {

src/app/cris-layout/cris-layout-matrix/cris-layout-box-container/boxes/metadata/rendering-types/valuepair/valuepair.component.spec.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import { TranslateLoaderMock } from '../../../../../../../shared/mocks/translate
66
import { VocabularyService } from '../../../../../../../core/submission/vocabularies/vocabulary.service';
77
import { Item } from '../../../../../../../core/shared/item.model';
88
import { EMPTY, of } from 'rxjs';
9-
import {AuthService} from '../../../../../../../core/auth/auth.service';
10-
import {AuthServiceStub} from '../../../../../../../shared/testing/auth-service.stub';
9+
import { AuthService } from '../../../../../../../core/auth/auth.service';
10+
import { AuthServiceStub } from '../../../../../../../shared/testing/auth-service.stub';
1111
import { LayoutField } from '../../../../../../../core/layout/models/box.model';
1212
import { DsDatePipe } from '../../../../../../pipes/ds-date.pipe';
1313

@@ -76,14 +76,18 @@ describe('ValuepairComponent', () => {
7676
return of('Italian');
7777
case 'common_iso_languages/en':
7878
return of('English');
79-
case 'types':
79+
case 'types/types:asd':
8080
return of('Value');
8181
default:
8282
return EMPTY;
8383
}
8484
};
8585

86-
const vocabularyServiceSpy = jasmine.createSpyObj('vocabularyService', { getPublicVocabularyEntryByValue: EMPTY });
86+
const vocabularyServiceSpy =
87+
jasmine.createSpyObj(
88+
'vocabularyService',
89+
{ getPublicVocabularyEntryByValue: EMPTY, getPublicVocabularyEntryByID: EMPTY }
90+
);
8791

8892
describe('when the vocabulary has no authority', () => {
8993

@@ -162,7 +166,7 @@ describe('ValuepairComponent', () => {
162166
beforeEach(() => {
163167
fixture = TestBed.createComponent(ValuepairComponent);
164168
component = fixture.componentInstance;
165-
vocabularyServiceSpy.getPublicVocabularyEntryByValue.and.callFake(vocabularyEntriesMock);
169+
vocabularyServiceSpy.getPublicVocabularyEntryByID.and.callFake(vocabularyEntriesMock);
166170
fixture.detectChanges();
167171
});
168172

@@ -172,7 +176,7 @@ describe('ValuepairComponent', () => {
172176

173177

174178
it('should ...', () => {
175-
expect(vocabularyService.getPublicVocabularyEntryByValue).toHaveBeenCalledWith(VOCABULARY_NAME_2, 'asd');
179+
expect(vocabularyService.getPublicVocabularyEntryByID).toHaveBeenCalledWith(VOCABULARY_NAME_2, `${VOCABULARY_NAME_2}:asd`);
176180
});
177181

178182

src/app/cris-layout/cris-layout-matrix/cris-layout-box-container/boxes/metadata/rendering-types/valuepair/valuepair.component.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
import { Component, Inject, OnInit } from '@angular/core';
22

33
import { TranslateService } from '@ngx-translate/core';
4-
import { BehaviorSubject, interval, race } from 'rxjs';
5-
import { map, mapTo, take } from 'rxjs/operators';
4+
import { BehaviorSubject } from 'rxjs';
5+
import { map, take } from 'rxjs/operators';
66

77
import { FieldRenderingType, MetadataBoxFieldRendering } from '../metadata-box.decorator';
88
import { VocabularyService } from '../../../../../../../core/submission/vocabularies/vocabulary.service';
99
import {
10-
getFirstSucceededRemoteDataPayload,
11-
getPaginatedListPayload
10+
getFirstCompletedRemoteData,
11+
getPaginatedListPayload,
12+
getRemoteDataPayload
1213
} from '../../../../../../../core/shared/operators';
1314
import { AuthService } from '../../../../../../../core/auth/auth.service';
1415
import { RenderingTypeValueModelComponent } from '../rendering-type-value.model';
@@ -49,21 +50,20 @@ export class ValuepairComponent extends RenderingTypeValueModelComponent impleme
4950

5051
const vocabularyName = this.renderingSubType;
5152
const authority = this.metadataValue.authority ? this.metadataValue.authority.split(':') : undefined;
52-
const isControlledVocabulary = authority?.length > 1 && authority[0] === vocabularyName;
53-
const metadataValue = isControlledVocabulary ? authority[1] : this.metadataValue.value;
53+
const isControlledVocabulary = authority?.length > 1 && authority[0] === vocabularyName;
5454

55-
const entry$ = this.vocabularyService.getPublicVocabularyEntryByValue(vocabularyName, metadataValue).pipe(
56-
getFirstSucceededRemoteDataPayload(),
57-
getPaginatedListPayload(),
58-
map((res) => res[0]?.display ?? this.metadataValue.value),
59-
);
60-
61-
// fallback values to be shown if the display value cannot be retrieved
62-
const initValue$ = interval(5000).pipe(mapTo(this.metadataValue.value));
55+
let vocabularyEntry$ = isControlledVocabulary ?
56+
this.vocabularyService.getPublicVocabularyEntryByID(vocabularyName, this.metadataValue.authority) :
57+
this.vocabularyService.getPublicVocabularyEntryByValue(vocabularyName, this.metadataValue.value);
6358

64-
race([entry$, initValue$]).pipe(take(1)).subscribe((value: string) => {
65-
this.value$.next(value);
66-
});
59+
vocabularyEntry$.pipe(
60+
getFirstCompletedRemoteData(),
61+
getRemoteDataPayload(),
62+
getPaginatedListPayload(),
63+
map((res) => res?.length > 0 ? res[0] : null),
64+
map((res) => res?.display ?? this.metadataValue.value),
65+
take(1)
66+
).subscribe(value => this.value$.next(value));
6767

6868
}
6969

0 commit comments

Comments
 (0)