-
Notifications
You must be signed in to change notification settings - Fork 523
[DSpace-CRIS] Porting of authority framework functionalities (Frontend) #4956
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 39 commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
bf14771
[DURACOM-413] port custom url functionality
FrancescoMolinaro 66bd310
Merge remote-tracking branch 'gitHub/main' into task/main/DURACOM-413
FrancescoMolinaro b42bf55
[DURACOM-413] additional tests
FrancescoMolinaro e88a40d
[DURACOM-413] update labels, fix sync script, adapt section handling
FrancescoMolinaro c93cb50
[DURACOM-413] update error handling/validation + resync translations
FrancescoMolinaro 75937c4
Merge remote-tracking branch 'gitHub/main' into task/main/DURACOM-413
FrancescoMolinaro d1c1ecf
[DURACOM-413] fix lint
FrancescoMolinaro 8bdfd01
[DURACOM-426] init integration of authority framework
FrancescoMolinaro a9dc8ec
Merge branch 'task/main/DURACOM-413' into task/main/DURACOM-426
FrancescoMolinaro 8c073ff
[DURACOM-426] port metadata link components for authorithy
FrancescoMolinaro d262480
[DURACOM-426] fix some tests
FrancescoMolinaro 9c5e6bb
[DURACOM-426] fix some unit tests
FrancescoMolinaro a514b6e
[DURACOM-426] fix tests and lint
FrancescoMolinaro a9ee4e5
[DURACOM-426] add authority link for md representation
FrancescoMolinaro 306029c
Merge remote-tracking branch 'gitHub/main' into task/main/DURACOM-426
FrancescoMolinaro 36c77fe
[DURACOM-426] clean up, add example, minor restyle, fix templates
FrancescoMolinaro e9f3df5
[DURACOM-426] improve tests
FrancescoMolinaro 5b6fa80
[DURACOM-426] refactor
FrancescoMolinaro b29dc1e
[DURACOM-426] improve title configurability in popover, add link view…
FrancescoMolinaro 3f35069
[DURACOM-426] add labels, fix facets labels,fix onebox other info tem…
FrancescoMolinaro 1258bc2
[DURACOM-426] filter data labels
FrancescoMolinaro 36e34a2
[DURACOM-426] revert changes to lables, except for english
FrancescoMolinaro d2c0749
[DURACOM-426] add config example, remove unnecessary config
FrancescoMolinaro 1aef155
[DURACOM-426] clean config, add labels
FrancescoMolinaro 995ff87
[DURACOM-426] add authority enrichment
FrancescoMolinaro efc488a
[DURACOM-426] fix tests
FrancescoMolinaro 252c249
[DURACOM-426] fix test and model update
FrancescoMolinaro e316b11
[DURACOM-426] add vocabulary template in item field, adapt tests
FrancescoMolinaro 317c1ee
Merge remote-tracking branch 'gitHub/main' into task/main/DURACOM-426
FrancescoMolinaro be381eb
[DURACOM-426] fix lint
FrancescoMolinaro a19ef43
[DURACOM-426] refactor
FrancescoMolinaro 837b47e
Merge remote-tracking branch 'gitHub/main' into task/main/DURACOM-426
FrancescoMolinaro ca4edf7
Merge remote-tracking branch 'gitHub/main' into task/main/DURACOM-426
FrancescoMolinaro a15ad30
[DURACOM-426] remove unused method and duplicated config example
FrancescoMolinaro 5160bf9
[DURACOM-426] revert changes to sync script
FrancescoMolinaro 4575977
[DURACOM-426] fix authority link layout
FrancescoMolinaro d8a3873
[DURACOM-426] config refactor, add typesdoc, fix popover issue, fix s…
FrancescoMolinaro c37f216
[DURACOM-426] fix test
FrancescoMolinaro 15ff78d
[DURACOM-426] accessibility fixes, fix issue with sticky popover dire…
FrancescoMolinaro f9389d4
[DURACOM-426] fix identifier for form removal
FrancescoMolinaro File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,151 @@ | ||
| import { Injectable } from '@angular/core'; | ||
| import { FollowAuthorityMetadata } from '@dspace/config/search-follow-metadata.interface'; | ||
| import { | ||
| hasValue, | ||
| isNotEmpty, | ||
| } from '@dspace/shared/utils/empty.util'; | ||
| import isArray from 'lodash/isArray'; | ||
| import { | ||
| Observable, | ||
| of, | ||
| } from 'rxjs'; | ||
| import { | ||
| map, | ||
| switchMap, | ||
| } from 'rxjs/operators'; | ||
| import { SearchService } from 'src/app/shared/search/search.service'; | ||
|
|
||
| import { environment } from '../../../environments/environment'; | ||
| import { ItemDataService } from '../data/item-data.service'; | ||
| import { PaginatedList } from '../data/paginated-list.model'; | ||
| import { RemoteData } from '../data/remote-data'; | ||
| import { WORKFLOWITEM } from '../eperson/models/workflowitem.resource-type'; | ||
| import { WORKSPACEITEM } from '../eperson/models/workspaceitem.resource-type'; | ||
| import { DSpaceObject } from '../shared/dspace-object.model'; | ||
| import { FollowLinkConfig } from '../shared/follow-link-config.model'; | ||
| import { Item } from '../shared/item.model'; | ||
| import { ITEM } from '../shared/item.resource-type'; | ||
| import { MetadataValue } from '../shared/metadata.models'; | ||
| import { Metadata } from '../shared/metadata.utils'; | ||
| import { getFirstCompletedRemoteData } from '../shared/operators'; | ||
| import { PaginatedSearchOptions } from '../shared/search/models/paginated-search-options.model'; | ||
| import { SearchObjects } from '../shared/search/models/search-objects.model'; | ||
| import { BrowseService } from './browse.service'; | ||
|
|
||
| /** | ||
| * The service aims to manage browse requests and subsequent extra fetch requests. | ||
| */ | ||
| @Injectable({ providedIn: 'root' }) | ||
| export class SearchManager { | ||
|
|
||
| constructor( | ||
| protected itemService: ItemDataService, | ||
| protected browseService: BrowseService, | ||
| protected searchService: SearchService, | ||
| ) { | ||
| } | ||
|
|
||
| /** | ||
| * Method to retrieve a paginated list of search results from the server | ||
| * @param {PaginatedSearchOptions} searchOptions The configuration necessary to perform this search | ||
| * @param responseMsToLive The amount of milliseconds for the response to live in cache | ||
| * @param useCachedVersionIfAvailable If this is true, the request will only be sent if there's | ||
| * no valid cached version. Defaults to true | ||
| * @param reRequestOnStale Whether or not the request should automatically be re-requested after | ||
| * the response becomes stale | ||
| * @param linksToFollow List of {@link FollowLinkConfig} that indicate which {@link HALLink}s should be automatically resolved | ||
| * @returns {Observable<RemoteData<SearchObjects<T>>>} Emits a paginated list with all search results found | ||
| */ | ||
| search<T extends DSpaceObject>( | ||
| searchOptions?: PaginatedSearchOptions, | ||
| responseMsToLive?: number, | ||
| useCachedVersionIfAvailable = true, | ||
| reRequestOnStale = true, | ||
| ...linksToFollow: FollowLinkConfig<T>[]): Observable<RemoteData<SearchObjects<T>>> { | ||
| return this.searchService.search(searchOptions, responseMsToLive, useCachedVersionIfAvailable, reRequestOnStale, ...linksToFollow) | ||
| .pipe(this.completeSearchObjectsWithExtraData()); | ||
| } | ||
|
|
||
|
|
||
| protected completeWithExtraData() { | ||
| return switchMap((itemsRD: RemoteData<PaginatedList<Item>>) => { | ||
| if (itemsRD.isSuccess) { | ||
| return this.fetchExtraData(itemsRD.payload.page).pipe(map(() => { | ||
| return itemsRD; | ||
| })); | ||
| } | ||
| return of(itemsRD); | ||
| }); | ||
| } | ||
|
|
||
| protected completeSearchObjectsWithExtraData<T extends DSpaceObject>() { | ||
| return switchMap((searchObjectsRD: RemoteData<SearchObjects<T>>) => { | ||
| if (searchObjectsRD.isSuccess) { | ||
| const items: Item[] = searchObjectsRD.payload.page | ||
| .map((searchResult) => isNotEmpty(searchResult?._embedded?.indexableObject) ? searchResult._embedded.indexableObject : searchResult.indexableObject) as any; | ||
| return this.fetchExtraData(items).pipe(map(() => { | ||
| return searchObjectsRD; | ||
| })); | ||
| } | ||
| return of(searchObjectsRD); | ||
| }); | ||
| } | ||
|
|
||
| protected fetchExtraData<T extends DSpaceObject>(objects: T[]): Observable<any> { | ||
|
|
||
| const items: Item[] = objects | ||
| .map((object: any) => { | ||
| if (object.type === ITEM.value) { | ||
| return object as Item; | ||
| } else if (object.type === WORKSPACEITEM.value || object.type === WORKFLOWITEM.value) { | ||
| return object?._embedded?.item as Item; | ||
| } else { | ||
| // Handle workflow task here, where the item is embedded in a workflowitem | ||
| return object?._embedded?.workflowitem?._embedded?.item as Item; | ||
| } | ||
|
|
||
| }) | ||
| .filter((item) => hasValue(item)); | ||
|
|
||
| const uuidList = this.extractUUID(items, environment.searchResult.followAuthorityMetadata, environment.searchResult.followAuthorityMaxItemLimit); | ||
|
|
||
| return uuidList.length > 0 ? this.itemService.findAllById(uuidList).pipe( | ||
| getFirstCompletedRemoteData(), | ||
| map(data => { | ||
| if (data.hasSucceeded) { | ||
| return of(data); | ||
| } else { | ||
| of(null); | ||
| } | ||
| }), | ||
| ) : of(null); | ||
| } | ||
|
|
||
| protected extractUUID(items: Item[], metadataToFollow: FollowAuthorityMetadata[], numberOfElementsToReturn?: number): string[] { | ||
| const uuidMap = {}; | ||
|
|
||
| items.forEach((item) => { | ||
| metadataToFollow.forEach((followMetadata: FollowAuthorityMetadata) => { | ||
| if (item.entityType === followMetadata.type) { | ||
| if (isArray(followMetadata.metadata)) { | ||
| followMetadata.metadata.forEach((metadata) => { | ||
| Metadata.all(item.metadata, metadata, null, null, false, environment.searchResult.followAuthorityMetadataValuesLimit) | ||
| .filter((metadataValue: MetadataValue) => Metadata.hasValidItemAuthority(metadataValue.authority)) | ||
| .forEach((metadataValue: MetadataValue) => uuidMap[metadataValue.authority] = metadataValue); | ||
| }); | ||
| } else { | ||
| Metadata.all(item.metadata, followMetadata.metadata, null, null, false, environment.searchResult.followAuthorityMetadataValuesLimit) | ||
| .filter((metadataValue: MetadataValue) => Metadata.hasValidItemAuthority(metadataValue.authority)) | ||
| .forEach((metadataValue: MetadataValue) => uuidMap[metadataValue.authority] = metadataValue); | ||
| } | ||
| } | ||
| }); | ||
| }); | ||
|
|
||
| if (hasValue(numberOfElementsToReturn) && numberOfElementsToReturn > 0) { | ||
| return Object.keys(uuidMap).slice(0, numberOfElementsToReturn); | ||
| } | ||
|
|
||
| return Object.keys(uuidMap); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.