fix dmp save and view references

This commit is contained in:
amentis 2024-02-21 11:03:11 +02:00
parent 347ed854ae
commit a1394e6629
2 changed files with 22 additions and 3 deletions

View File

@ -657,6 +657,7 @@ public class DmpServiceImpl implements DmpService {
if (referenceEntity == null){
referenceEntity = new ReferenceEntity();
referenceEntity.setId(UUID.randomUUID());
referenceEntity.setLabel(referencePersist.getLabel());
referenceEntity.setIsActive(IsActive.Active);
referenceEntity.setCreatedAt(Instant.now());
referenceEntity.setTypeId(fieldEntity.getReferenceTypeId());

View File

@ -286,7 +286,7 @@ export class DmpPropertiesEditorModel implements DmpPropertiesPersist {
export class DmpBlueprintValueEditorModel implements DmpBlueprintValuePersist {
fieldId: Guid;
fieldValue: string;
references: DmpReferencePersist[];
references: DmpReferencePersist[] = [];
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
@ -297,8 +297,26 @@ export class DmpBlueprintValueEditorModel implements DmpBlueprintValuePersist {
fromModel(item: DmpBlueprintValue, dmpReferences: DmpReference[]): DmpBlueprintValueEditorModel {
this.fieldId = item.fieldId;
this.fieldValue = item.fieldValue;
//TODO: refactor reference type
// this.references = dmpReferences?.filter(x => x.data?.blueprintFieldId === this.fieldId) || [];
// TODO check typeId field
dmpReferences.forEach(dmpReference => {
if(dmpReference.data.blueprintFieldId == this.fieldId){
this.references.push({
data: dmpReference.data,
reference: {
id: dmpReference.reference.id,
label: dmpReference.reference.label,
reference: dmpReference.reference.reference,
source: dmpReference.reference.source,
typeId: null,
description: dmpReference.reference.source,
definition: dmpReference.reference.definition,
abbreviation: dmpReference.reference.abbreviation,
sourceType: dmpReference.reference.sourceType
}
})
}
})
return this;
}