Skip to content

Commit 995ff87

Browse files
[DURACOM-426] add authority enrichment
1 parent 1aef155 commit 995ff87

38 files changed

Lines changed: 945 additions & 127 deletions

src/app/browse-by/browse-by-taxonomy/browse-by-taxonomy.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ export class BrowseByTaxonomyComponent implements OnInit, OnChanges, OnDestroy {
128128
this.selectedItems = [];
129129
this.facetType = browseDefinition.facetType;
130130
this.vocabularyName = browseDefinition.vocabulary;
131-
this.vocabularyOptions = { name: this.vocabularyName, closed: true };
131+
this.vocabularyOptions = { name: this.vocabularyName, metadata: null, scope: null, closed: true };
132132
this.description = this.translate.instant(`browse.metadata.${this.vocabularyName}.tree.description`);
133133
}));
134134
this.subs.push(this.scope$.subscribe(() => {

src/app/core/data-services-map.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,4 +136,5 @@ export const LAZY_DATA_SERVICES: LazyDataServicesMap = new Map([
136136
[SUGGESTION_TARGET.value, () => import('./notifications/suggestions/target/suggestion-target-data.service').then(m => m.SuggestionTargetDataService)],
137137
[DUPLICATE.value, () => import('./submission/submission-duplicate-data.service').then(m => m.SubmissionDuplicateDataService)],
138138
[CorrectionType.type.value, () => import('./submission/correctiontype-data.service').then(m => m.CorrectionTypeDataService)],
139+
139140
]);

src/app/core/data/external-source-data.service.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,17 @@ export class ExternalSourceDataService extends IdentifiableDataService<ExternalS
6666
);
6767
}
6868

69+
/**
70+
* Get the endpoint for an external source's entryValues by given entry id
71+
* @param externalSourceId The id of the external source to fetch entry for
72+
* @param entryId The id of the external source entry to retrieve
73+
*/
74+
getEntryIDHref(externalSourceId: string, entryId: string): Observable<string> {
75+
return this.getBrowseEndpoint().pipe(
76+
map((href) => href + '/' + externalSourceId + '/entryValues/' + entryId),
77+
);
78+
}
79+
6980
/**
7081
* Get the entries for an external source
7182
* @param externalSourceId The id of the external source to fetch entries for
@@ -111,4 +122,18 @@ export class ExternalSourceDataService extends IdentifiableDataService<ExternalS
111122
public searchBy(searchMethod: string, options?: FindListOptions, useCachedVersionIfAvailable?: boolean, reRequestOnStale?: boolean, ...linksToFollow: FollowLinkConfig<ExternalSource>[]): Observable<RemoteData<PaginatedList<ExternalSource>>> {
112123
return this.searchData.searchBy(searchMethod, options, useCachedVersionIfAvailable, reRequestOnStale, ...linksToFollow);
113124
}
125+
126+
/**
127+
* Get an entry for an external source by given entry id
128+
* @param externalSourceId The id of the external source to fetch entries for
129+
* @param entryId The id of the entry to retrieve
130+
*/
131+
getExternalSourceEntryById(externalSourceId: string, entryId: string): Observable<RemoteData<ExternalSourceEntry>> {
132+
const href$ = this.getEntryIDHref(externalSourceId, entryId).pipe(
133+
isNotEmptyOperator(),
134+
distinctUntilChanged(),
135+
);
136+
137+
return this.findByHref(href$) as any;
138+
}
114139
}

src/app/core/json-patch/builder/json-patch-operations-builder.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ import {
2424
NewPatchReplaceOperationAction,
2525
} from '../json-patch-operations.actions';
2626
import { JsonPatchOperationPathObject } from './json-patch-operation-path-combiner';
27+
import { Metadata } from "@dspace/core/shared/metadata.utils";
28+
import { ConfidenceType } from "@dspace/core/shared/confidence-type";
2729

2830
/**
2931
* Provides methods to dispatch JsonPatch Operations Actions
@@ -45,13 +47,14 @@ export class JsonPatchOperationsBuilder {
4547
* A boolean representing if the value to be added is the first of an array
4648
* @param plain
4749
* A boolean representing if the value to be added is a plain text value
50+
* @param languages
4851
*/
49-
add(path: JsonPatchOperationPathObject, value, first = false, plain = false) {
52+
add(path: JsonPatchOperationPathObject, value, first = false, plain = false, languages: string[] = null) {
5053
this.store.dispatch(
5154
new NewPatchAddOperationAction(
5255
path.rootElement,
5356
path.subRootElement,
54-
path.path, this.prepareValue(value, plain, first)));
57+
path.path, this.prepareValue(value, plain, first, languages)));
5558
}
5659

5760
/**
@@ -63,8 +66,10 @@ export class JsonPatchOperationsBuilder {
6366
* the value to update the referenced path
6467
* @param plain
6568
* a boolean representing if the value to be added is a plain text value
69+
* @param securityLevel
70+
* @param language
6671
*/
67-
replace(path: JsonPatchOperationPathObject, value, plain = false) {
72+
replace(path: JsonPatchOperationPathObject, value, plain = false, language = null) {
6873
if (hasNoValue(value) || (typeof value === 'object' && hasNoValue(value.value))) {
6974
this.remove(path);
7075
} else {
@@ -73,7 +78,7 @@ export class JsonPatchOperationsBuilder {
7378
path.rootElement,
7479
path.subRootElement,
7580
path.path,
76-
this.prepareValue(value, plain, false)));
81+
this.prepareValue(value, plain, false, language)));
7782
}
7883
}
7984

@@ -124,7 +129,7 @@ export class JsonPatchOperationsBuilder {
124129
path.path));
125130
}
126131

127-
protected prepareValue(value: any, plain: boolean, first: boolean) {
132+
protected prepareValue(value: any, plain: boolean, first: boolean, languages: string[] = null) {
128133
let operationValue: any = null;
129134
if (hasValue(value)) {
130135
if (plain) {

src/app/core/shared/form/models/form-field-metadata-value.model.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
VIRTUAL_METADATA_PREFIX,
1212
} from '../../metadata.models';
1313
import { PLACEHOLDER_PARENT_METADATA } from '../ds-dynamic-form-constants';
14+
import { Metadata } from "../../metadata.utils";
1415

1516
export interface OtherInformation {
1617
[name: string]: string;
@@ -48,7 +49,7 @@ export class FormFieldMetadataValueObject implements MetadataValueInterface {
4849
this.display = display || value;
4950

5051
this.confidence = confidence;
51-
if (authority != null && (isEmpty(confidence) || confidence === -1)) {
52+
if (Metadata.hasValidAuthority(authority) && (isEmpty(confidence) || confidence === -1)) {
5253
this.confidence = ConfidenceType.CF_ACCEPTED;
5354
} else if (isNotEmpty(confidence)) {
5455
this.confidence = confidence;
@@ -68,7 +69,7 @@ export class FormFieldMetadataValueObject implements MetadataValueInterface {
6869
* Returns true if this this object has an authority value
6970
*/
7071
hasAuthority(): boolean {
71-
return isNotEmpty(this.authority);
72+
return Metadata.hasValidAuthority(this.authority);
7273
}
7374

7475
/**

src/app/core/shared/form/models/form-field.model.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,9 @@ export class FormFieldModel {
126126
@autoserialize
127127
value: any;
128128

129+
/**
130+
* The visibility object for this field
131+
*/
129132
@autoserialize
130133
visibility: SectionVisibility;
131134
}

src/app/core/submission/submission-rest.service.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,15 @@ export class SubmissionRestService {
9191
* The identifier for the object
9292
* @param collectionId
9393
* The owning collection for the object
94+
* @param projections
9495
*/
95-
protected getEndpointByIDHref(endpoint, resourceID, collectionId?: string): string {
96+
protected getEndpointByIDHref(endpoint, resourceID, collectionId?: string, projections: string[] = []): string {
9697
let url = isNotEmpty(resourceID) ? `${endpoint}/${resourceID}` : `${endpoint}`;
9798
url = new URLCombiner(url, '?embed=item,sections,collection').toString();
99+
100+
projections.forEach((projection) => {
101+
url = new URLCombiner(url, '&projection=' + projection).toString();
102+
});
98103
if (collectionId) {
99104
url = new URLCombiner(url, `&owningCollection=${collectionId}`).toString();
100105
}
@@ -135,9 +140,9 @@ export class SubmissionRestService {
135140
* @return Observable<SubmitDataResponseDefinitionObject>
136141
* server response
137142
*/
138-
public getDataById(linkName: string, id: string, useCachedVersionIfAvailable = false): Observable<SubmitDataResponseDefinitionObject> {
143+
public getDataById(linkName: string, id: string, useCachedVersionIfAvailable = false, projections: string[] = []): Observable<SubmitDataResponseDefinitionObject> {
139144
return this.halService.getEndpoint(linkName).pipe(
140-
map((endpointURL: string) => this.getEndpointByIDHref(endpointURL, id)),
145+
map((endpointURL: string) => this.getEndpointByIDHref(endpointURL, id, null, projections)),
141146
filter((href: string) => isNotEmpty(href)),
142147
distinctUntilChanged(),
143148
mergeMap((endpointURL: string) => {

src/app/core/submission/vocabularies/models/vocabulary-entry-detail.model.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { typedObject } from '@dspace/core/cache/builders/build-decorators';
1+
import { link, typedObject } from '@dspace/core/cache/builders/build-decorators';
22
import { HALLink } from '@dspace/core/shared/hal-link.model';
33
import {
44
autoserialize,
@@ -8,6 +8,9 @@ import {
88

99
import { VOCABULARY_ENTRY_DETAIL } from './vocabularies.resource-type';
1010
import { VocabularyEntry } from './vocabulary-entry.model';
11+
import { Observable } from "rxjs";
12+
import { RemoteData } from "@dspace/core/data/remote-data";
13+
import { PaginatedList } from "@dspace/core/data/paginated-list.model";
1114

1215
/**
1316
* Model class for a VocabularyEntryDetail
@@ -37,7 +40,21 @@ export class VocabularyEntryDetail extends VocabularyEntry {
3740
self: HALLink;
3841
vocabulary: HALLink;
3942
parent: HALLink;
40-
children
43+
children: HALLink;
4144
};
4245

46+
/**
47+
* The submitter for this SubmissionObject
48+
* Will be undefined unless the submitter {@link HALLink} has been resolved.
49+
*/
50+
@link(VOCABULARY_ENTRY_DETAIL)
51+
parent?: Observable<RemoteData<VocabularyEntryDetail>>;
52+
53+
/**
54+
* The submitter for this SubmissionObject
55+
* Will be undefined unless the submitter {@link HALLink} has been resolved.
56+
*/
57+
@link(VOCABULARY_ENTRY_DETAIL, true)
58+
children?: Observable<RemoteData<PaginatedList<VocabularyEntryDetail>>>;
59+
4360
}

src/app/core/submission/vocabularies/models/vocabulary-entry.model.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { PLACEHOLDER_PARENT_METADATA } from '../../../shared/form/ds-dynamic-for
1212
import { OtherInformation } from '../../../shared/form/models/form-field-metadata-value.model';
1313
import { ListableObject } from '../../../shared/object-collection/listable-object.model';
1414
import { VOCABULARY_ENTRY } from './vocabularies.resource-type';
15+
import { Metadata } from "@dspace/core/shared/metadata.utils";
1516

1617
/**
1718
* Model class for a VocabularyEntry
@@ -44,6 +45,12 @@ export class VocabularyEntry extends ListableObject {
4445
@autoserialize
4546
otherInformation: OtherInformation;
4647

48+
/**
49+
* A value representing security level value of the metadata
50+
*/
51+
@autoserialize
52+
securityLevel: number;
53+
4754
/**
4855
* A string representing the kind of vocabulary entry
4956
*/
@@ -66,7 +73,7 @@ export class VocabularyEntry extends ListableObject {
6673
* @return boolean
6774
*/
6875
hasAuthority(): boolean {
69-
return isNotEmpty(this.authority);
76+
return Metadata.hasValidAuthority(this.authority);
7077
}
7178

7279
/**

src/app/core/submission/vocabularies/models/vocabulary-find-options.model.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ import { isNotEmpty } from '@dspace/shared/utils/empty.util';
88
*/
99
export class VocabularyFindOptions extends FindListOptions {
1010

11-
constructor(public query: string = '',
11+
constructor(public collection,
12+
public metadata,
13+
public query: string = '',
1214
public filter?: string,
1315
public exact?: boolean,
1416
public entryID?: string,
@@ -19,7 +21,12 @@ export class VocabularyFindOptions extends FindListOptions {
1921
super();
2022

2123
const searchParams = [];
22-
24+
if (isNotEmpty(metadata)) {
25+
searchParams.push(new RequestParam('metadata', metadata));
26+
}
27+
if (isNotEmpty(collection)) {
28+
searchParams.push(new RequestParam('collection', collection));
29+
}
2330
if (isNotEmpty(query)) {
2431
searchParams.push(new RequestParam('query', query));
2532
}

0 commit comments

Comments
 (0)