Skip to content

Commit 29a111a

Browse files
FrancescoMolinaroatarix83
authored andcommitted
Merged in task/dspace-cris-2023_02_x/DSC-2028 (pull request DSpace#2545)
Task/dspace cris 2023 02 x/DSC-2028 Approved-by: Giuseppe Digilio
2 parents ddbd43a + 2df6906 commit 29a111a

12 files changed

Lines changed: 27 additions & 32 deletions

File tree

src/app/collection-page/collection-page.component.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ import { RouterStub } from '../shared/testing/router.stub';
1414
import { environment } from 'src/environments/environment.test';
1515
import { createSuccessfulRemoteDataObject$ } from '../shared/remote-data.utils';
1616
import { Collection } from '../core/shared/collection.model';
17-
import { SearchService } from '../core/shared/search/search.service';
1817
import { By } from '@angular/platform-browser';
1918
import { FormsModule } from '@angular/forms';
2019
import { RouterTestingModule } from '@angular/router/testing';
2120
import { TranslateModule } from '@ngx-translate/core';
2221
import { VarDirective } from '../shared/utils/var.directive';
2322
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
2423
import { Bitstream } from '../core/shared/bitstream.model';
24+
import { SearchManager } from '../core/browse/search-manager';
2525

2626
describe('CollectionPageComponent', () => {
2727
let component: CollectionPageComponent;
@@ -33,7 +33,7 @@ describe('CollectionPageComponent', () => {
3333
let paginationServiceSpy: jasmine.SpyObj<PaginationService>;
3434
let authorizationDataServiceSpy: jasmine.SpyObj<AuthorizationDataService>;
3535
let dsoNameServiceSpy: jasmine.SpyObj<DSONameService>;
36-
let searchServiceSpy: jasmine.SpyObj<SearchService>;
36+
let searchServiceSpy: jasmine.SpyObj<SearchManager>;
3737
let aroute = new ActivatedRouteStub();
3838
let router = new RouterStub();
3939

@@ -44,7 +44,7 @@ describe('CollectionPageComponent', () => {
4444
paginationServiceSpy = jasmine.createSpyObj('PaginationService', ['getCurrentPagination', 'getCurrentSort', 'clearPagination']);
4545
authorizationDataServiceSpy = jasmine.createSpyObj('AuthorizationDataService', ['isAuthorized']);
4646
collectionDataServiceSpy = jasmine.createSpyObj('CollectionDataService', ['findById', 'getAuthorizedCollection']);
47-
searchServiceSpy = jasmine.createSpyObj('SearchService', ['search']);
47+
searchServiceSpy = jasmine.createSpyObj('SearchManager', ['search']);
4848
dsoNameServiceSpy = jasmine.createSpyObj('DSONameService', ['getName']);
4949

5050
await TestBed.configureTestingModule({
@@ -58,7 +58,7 @@ describe('CollectionPageComponent', () => {
5858
{ provide: PaginationService, useValue: paginationServiceSpy },
5959
{ provide: AuthorizationDataService, useValue: authorizationDataServiceSpy },
6060
{ provide: DSONameService, useValue: dsoNameServiceSpy },
61-
{ provide: SearchService, useValue: searchServiceSpy },
61+
{ provide: SearchManager, useValue: searchServiceSpy },
6262
{ provide: APP_CONFIG, useValue: environment },
6363
{ provide: PLATFORM_ID, useValue: 'browser' },
6464
]

src/app/collection-page/collection-page.component.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ import { ActivatedRoute, Router } from '@angular/router';
44
import { BehaviorSubject, combineLatest as observableCombineLatest, Observable, Subject } from 'rxjs';
55
import { filter, map, mergeMap, startWith, switchMap, take } from 'rxjs/operators';
66
import { PaginatedSearchOptions } from '../shared/search/models/paginated-search-options.model';
7-
import { SearchService } from '../core/shared/search/search.service';
87
import { SortDirection, SortOptions } from '../core/cache/models/sort-options.model';
9-
import { CollectionDataService } from '../core/data/collection-data.service';
108
import { PaginatedList } from '../core/data/paginated-list.model';
119
import { RemoteData } from '../core/data/remote-data';
1210
import { Bitstream } from '../core/shared/bitstream.model';
@@ -30,6 +28,7 @@ import { redirectOn4xx } from '../core/shared/authorized.operators';
3028
import { BROWSE_LINKS_TO_FOLLOW } from '../core/browse/browse.service';
3129
import { DSONameService } from '../core/breadcrumbs/dso-name.service';
3230
import { APP_CONFIG, AppConfig } from '../../../src/config/app-config.interface';
31+
import { SearchManager } from '../core/browse/search-manager';
3332

3433
@Component({
3534
selector: 'ds-collection-page',
@@ -64,8 +63,7 @@ export class CollectionPageComponent implements OnInit {
6463

6564
constructor(
6665
@Inject(PLATFORM_ID) private platformId: Object,
67-
private collectionDataService: CollectionDataService,
68-
private searchService: SearchService,
66+
private searchManager: SearchManager,
6967
private route: ActivatedRoute,
7068
private router: Router,
7169
private authService: AuthService,
@@ -113,14 +111,13 @@ export class CollectionPageComponent implements OnInit {
113111
getFirstSucceededRemoteData(),
114112
map((rd) => rd.payload.id),
115113
switchMap((id: string) => {
116-
return this.searchService.search<Item>(
114+
return this.searchManager.search<Item>(
117115
new PaginatedSearchOptions({
118116
scope: id,
119117
pagination: currentPagination,
120118
sort: currentSort,
121119
dsoTypes: [DSpaceObjectType.ITEM],
122120
forcedEmbeddedKeys: ['metrics'],
123-
projection: 'preventMetadataSecurity'
124121
}), null, true, true, ...BROWSE_LINKS_TO_FOLLOW)
125122
.pipe(toDSpaceObjectListRD()) as Observable<RemoteData<PaginatedList<Item>>>;
126123
}),

src/app/core/browse/search-manager.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export class SearchManager {
4545
* @returns {Observable<RemoteData<PaginatedList<Item>>>}
4646
*/
4747
getBrowseItemsFor(filterValue: string, filterAuthority: string, options: BrowseEntrySearchOptions, ...linksToFollow: FollowLinkConfig<any>[]): Observable<RemoteData<PaginatedList<Item>>> {
48-
const browseOptions = Object.assign({}, options, { projection: 'preventMetadataSecurity' });
48+
const browseOptions = Object.assign({}, options, { projection: options.projection ?? 'preventMetadataSecurity' });
4949
return this.browseService.getBrowseItemsFor(filterValue, filterAuthority, browseOptions, ...linksToFollow)
5050
.pipe(this.completeWithExtraData());
5151
}
@@ -67,7 +67,8 @@ export class SearchManager {
6767
useCachedVersionIfAvailable = true,
6868
reRequestOnStale = true,
6969
...linksToFollow: FollowLinkConfig<T>[]): Observable<RemoteData<SearchObjects<T>>> {
70-
return this.searchService.search(searchOptions, responseMsToLive, useCachedVersionIfAvailable, reRequestOnStale, ...linksToFollow)
70+
const optionsWithDefaultProjection = Object.assign(new PaginatedSearchOptions({}), searchOptions, { projection: searchOptions.projection ?? 'preventMetadataSecurity' });
71+
return this.searchService.search(optionsWithDefaultProjection, responseMsToLive, useCachedVersionIfAvailable, reRequestOnStale, ...linksToFollow)
7172
.pipe(this.completeSearchObjectsWithExtraData());
7273
}
7374

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ describe('CrisrefComponent', () => {
2020
let fixture: ComponentFixture<CrisrefComponent>;
2121

2222
const itemService = jasmine.createSpyObj('ItemDataService', {
23-
findById: jasmine.createSpy('findById')
23+
findByIdWithProjections: jasmine.createSpy('findByIdWithProjections')
2424
});
2525
const metadataValue = Object.assign(new MetadataValue(), {
2626
'value': 'test item title',
@@ -106,7 +106,7 @@ describe('CrisrefComponent', () => {
106106
beforeEach(() => {
107107
fixture = TestBed.createComponent(CrisrefComponent);
108108
component = fixture.componentInstance;
109-
itemService.findById.and.returnValue(createSuccessfulRemoteDataObject$(testPerson));
109+
itemService.findByIdWithProjections.and.returnValue(createSuccessfulRemoteDataObject$(testPerson));
110110
fixture.detectChanges();
111111
});
112112

src/app/my-dspace-page/my-dspace-page.component.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
[configurationList]="(configurationList$ | async)"
1010
[context]="context"
1111
[viewModeList]="viewModeList"
12-
[projection]="projection"
1312
[showThumbnails]="false"
1413
[selectable]="(currentConfiguration$ | async) === workflowType"
1514
[selectionConfig]="{ repeatable: true, listId: listId }"

src/app/my-dspace-page/my-dspace-page.component.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,6 @@ export class MyDSpacePageComponent implements OnInit {
6060
*/
6161
roleTypeEnum = RoleType;
6262

63-
/**
64-
* Projection to use during the search
65-
*/
66-
projection = 'preventMetadataSecurity';
6763

6864
/**
6965
* List of available view mode

src/app/shared/browse-most-elements/abstract-browse-elements.component.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { CollectionElementLinkType } from '../object-collection/collection-eleme
33
import { Component, Input, OnChanges, OnInit, PLATFORM_ID, inject } from '@angular/core';
44
import { isPlatformServer } from '@angular/common';
55

6-
import { SearchService } from '../../core/shared/search/search.service';
76
import { PaginatedSearchOptions } from '../search/models/paginated-search-options.model';
87
import { DSpaceObject } from '../../core/shared/dspace-object.model';
98
import { SearchResult } from '../search/models/search-result.model';
@@ -21,6 +20,7 @@ import { BehaviorSubject, Observable, mergeMap } from 'rxjs';
2120
import { Item } from '../../core/shared/item.model';
2221
import { getItemPageRoute } from '../../item-page/item-page-routing-paths';
2322
import { TopSection } from '../../core/layout/models/section.model';
23+
import { SearchManager } from '../../core/browse/search-manager';
2424

2525
@Component({
2626
template: ''
@@ -29,7 +29,7 @@ export abstract class AbstractBrowseElementsComponent implements OnInit, OnChang
2929

3030
protected readonly appConfig = inject(APP_CONFIG);
3131
protected readonly platformId = inject(PLATFORM_ID);
32-
protected readonly searchService = inject(SearchService);
32+
protected readonly searchManager = inject(SearchManager);
3333

3434
protected abstract followMetricsLink: boolean; // to be overridden
3535
protected abstract followThumbnailLink: boolean; // to be overridden
@@ -47,7 +47,7 @@ export abstract class AbstractBrowseElementsComponent implements OnInit, OnChang
4747
/**
4848
* Optional projection to use during the search
4949
*/
50-
@Input() projection = 'preventMetadataSecurity';
50+
@Input() projection;
5151

5252
/**
5353
* Whether to show the badge label or not
@@ -96,10 +96,12 @@ export abstract class AbstractBrowseElementsComponent implements OnInit, OnChang
9696
this.paginatedSearchOptions = Object.assign(new PaginatedSearchOptions({}), this.paginatedSearchOptions, {
9797
projection: this.projection
9898
});
99+
99100
this.paginatedSearchOptions$ = new BehaviorSubject<PaginatedSearchOptions>(this.paginatedSearchOptions);
101+
100102
this.searchResults$ = this.paginatedSearchOptions$.asObservable().pipe(
101103
mergeMap((paginatedSearchOptions) =>
102-
this.searchService.search(paginatedSearchOptions, null, true, true, ...followLinks),
104+
this.searchManager.search(paginatedSearchOptions, null, true, true, ...followLinks),
103105
),
104106
getAllCompletedRemoteData(),
105107
);

src/app/shared/browse-most-elements/browse-most-elements.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export class BrowseMostElementsComponent implements OnInit, OnChanges {
2525
/**
2626
* Optional projection to use during the search
2727
*/
28-
@Input() projection = 'preventMetadataSecurity';
28+
@Input() projection;
2929

3030
/**
3131
* Whether to show the badge label or not

src/app/shared/browse-most-elements/themed-browse-most-elements.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export class ThemedBrowseMostElementsComponent extends ThemedComponent<BrowseMos
1919

2020
@Input() paginatedSearchOptions: PaginatedSearchOptions;
2121

22-
@Input() projection = 'preventMetadataSecurity';
22+
@Input() projection: string;
2323

2424
@Input() showLabel: boolean;
2525

src/app/shared/metadata-link-view/metadata-link-view.component.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ describe('MetadataLinkViewComponent', () => {
9090
});
9191

9292
itemService = jasmine.createSpyObj('ItemDataService', {
93-
findById: jasmine.createSpy('findById')
93+
findByIdWithProjections: jasmine.createSpy('findByIdWithProjections')
9494
});
9595

9696
beforeEach(waitForAsync(() => {
@@ -110,7 +110,7 @@ describe('MetadataLinkViewComponent', () => {
110110
describe('Check metadata without authority', () => {
111111
beforeEach(() => {
112112
fixture = TestBed.createComponent(MetadataLinkViewComponent);
113-
itemService.findById.and.returnValue(createSuccessfulRemoteDataObject$(testOrgunit));
113+
itemService.findByIdWithProjections.and.returnValue(createSuccessfulRemoteDataObject$(testOrgunit));
114114
component = fixture.componentInstance;
115115
component.item = testPerson;
116116
component.metadata = testMetadataValueWithoutAuthority;
@@ -135,7 +135,7 @@ describe('MetadataLinkViewComponent', () => {
135135
describe('when item is found with orcid', () => {
136136
beforeEach(() => {
137137
fixture = TestBed.createComponent(MetadataLinkViewComponent);
138-
itemService.findById.and.returnValue(createSuccessfulRemoteDataObject$(testPerson));
138+
itemService.findByIdWithProjections.and.returnValue(createSuccessfulRemoteDataObject$(testPerson));
139139
component = fixture.componentInstance;
140140
component.item = testPerson;
141141
component.metadata = testMetadataValueWithAuthority;
@@ -162,7 +162,7 @@ describe('MetadataLinkViewComponent', () => {
162162
describe('when item is found without orcid', () => {
163163
beforeEach(() => {
164164
fixture = TestBed.createComponent(MetadataLinkViewComponent);
165-
itemService.findById.and.returnValue(createSuccessfulRemoteDataObject$(testOrgunit));
165+
itemService.findByIdWithProjections.and.returnValue(createSuccessfulRemoteDataObject$(testOrgunit));
166166
component = fixture.componentInstance;
167167
component.item = testPerson;
168168
component.metadata = testMetadataValueWithAuthority;
@@ -189,7 +189,7 @@ describe('MetadataLinkViewComponent', () => {
189189
describe('when item is not found', () => {
190190
beforeEach(() => {
191191
fixture = TestBed.createComponent(MetadataLinkViewComponent);
192-
itemService.findById.and.returnValue(createFailedRemoteDataObject$());
192+
itemService.findByIdWithProjections.and.returnValue(createFailedRemoteDataObject$());
193193
component = fixture.componentInstance;
194194
component.item = testPerson;
195195
component.metadata = testMetadataValueWithAuthority;

0 commit comments

Comments
 (0)