Merge pull request #347 from atmire/DS-4107_Metadata_as_map

DS-4107 Metadata as map updates for Angular
This commit is contained in:
Tim Donohue
2019-02-21 14:22:37 -06:00
committed by GitHub
61 changed files with 1222 additions and 826 deletions

View File

@@ -35,12 +35,15 @@ import { Item } from '../shared/item.model';
import { DSpaceObject } from '../shared/dspace-object.model';
import { BrowseEntrySearchOptions } from './browse-entry-search-options.model';
/**
* Service that performs all actions that have to do with browse.
*/
@Injectable()
export class BrowseService {
protected linkPath = 'browses';
private static toSearchKeyArray(metadatumKey: string): string[] {
const keyParts = metadatumKey.split('.');
private static toSearchKeyArray(metadataKey: string): string[] {
const keyParts = metadataKey.split('.');
const searchFor = [];
searchFor.push('*');
for (let i = 0; i < keyParts.length - 1; i++) {
@@ -48,7 +51,7 @@ export class BrowseService {
const nextPart = [...prevParts, '*'].join('.');
searchFor.push(nextPart);
}
searchFor.push(metadatumKey);
searchFor.push(metadataKey);
return searchFor;
}
@@ -180,8 +183,8 @@ export class BrowseService {
return this.rdb.toRemoteDataObservable(requestEntry$, payload$);
}
getBrowseURLFor(metadatumKey: string, linkPath: string): Observable<string> {
const searchKeyArray = BrowseService.toSearchKeyArray(metadatumKey);
getBrowseURLFor(metadataKey: string, linkPath: string): Observable<string> {
const searchKeyArray = BrowseService.toSearchKeyArray(metadataKey);
return this.getBrowseDefinitions().pipe(
getRemoteDataPayload(),
map((browseDefinitions: BrowseDefinition[]) => browseDefinitions
@@ -192,7 +195,7 @@ export class BrowseService {
),
map((def: BrowseDefinition) => {
if (isEmpty(def) || isEmpty(def._links) || isEmpty(def._links[linkPath])) {
throw new Error(`A browse endpoint for ${linkPath} on ${metadatumKey} isn't configured`);
throw new Error(`A browse endpoint for ${linkPath} on ${metadataKey} isn't configured`);
} else {
return def._links[linkPath];
}