add single reference description editor build form

This commit is contained in:
amentis 2024-03-27 11:39:41 +02:00
parent 1d5403fc25
commit c5b1c89a7e
5 changed files with 52 additions and 36 deletions

View File

@ -518,7 +518,10 @@ public class DescriptionServiceImpl implements DescriptionService {
}
private void BuildDescriptionReferencePersist(String fieldId, FieldPersist fieldPersist, List<DescriptionReferencePersist> descriptionReferencePersists) {
if (fieldPersist.getReference() != null) fieldPersist.getReferences().add(fieldPersist.getReference());
if (fieldPersist.getReference() != null) {
if (fieldPersist.getReferences() == null) fieldPersist.setReferences(new ArrayList<>());
fieldPersist.getReferences().add(fieldPersist.getReference());
}
if (!this.conventionService.isListNullOrEmpty(fieldPersist.getReferences())) {
for (ReferencePersist referencePersist : fieldPersist.getReferences()) {
DescriptionReferencePersist descriptionReferencePersist = new DescriptionReferencePersist();

View File

@ -4,6 +4,7 @@ import eu.eudat.commons.types.description.FieldEntity;
import eu.eudat.model.persist.descriptionproperties.FieldPersist;
import java.time.Instant;
import java.util.ArrayList;
import java.util.List;
public class Field {
@ -43,7 +44,10 @@ public class Field {
tempTextListValue = persist.getTextListValue();
if (persist.getExternalIdentifier() != null) this.externalIdentifier = new ExternalIdentifier(persist.getExternalIdentifier());
else this.externalIdentifier = null;
if (persist.getReference() != null) persist.getReferences().add(persist.getReference());
if (persist.getReference() != null) {
if (persist.getReferences() == null) persist.setReferences(new ArrayList<>());
persist.getReferences().add(persist.getReference());
}
if (persist.getReferences() != null && !persist.getReferences().isEmpty()){
tempTextListValue = persist.getReferences().stream().filter(x-> x.getId() != null).map(x-> x.getId().toString()).toList();
}

View File

@ -91,6 +91,7 @@ export interface DescriptionTemplateMultiplicity {
export interface DescriptionTemplateBaseFieldData {
label: string;
fieldType: DescriptionTemplateFieldType;
multipleSelect?: boolean;
}

View File

@ -430,7 +430,20 @@ export class DescriptionFieldEditorModel implements DescriptionFieldPersist {
this.textListValue = item.textListValue;
this.dateValue = item.dateValue;
// this.reference = descriptionReferences?.find(x => x.data?.fieldId == descriptionTemplateField?.id && x.isActive == IsActive.Active)?.reference;
this.reference = descriptionReferences?.filter(x => descriptionTemplateField.data.multipleSelect == false && x.data?.fieldId == descriptionTemplateField?.id && x.isActive == IsActive.Active).map(x => {
return {
id: x.reference.id,
label: x.reference.label,
reference: x.reference.reference,
source: x.reference.source,
typeId: x.reference.type.id,
description: x.reference.source,
definition: x.reference.definition,
abbreviation: x.reference.abbreviation,
sourceType: x.reference.sourceType
}
})[0];
this.references = descriptionReferences?.filter(x => x.data?.fieldId == descriptionTemplateField?.id && x.isActive == IsActive.Active).map(x => {
return {
id: x.reference.id,
@ -444,6 +457,7 @@ export class DescriptionFieldEditorModel implements DescriptionFieldPersist {
sourceType: x.reference.sourceType
}
});
this.externalIdentifier = new DescriptionExternalIdentifierEditorModel(this.validationErrorModel).fromModel(item.externalIdentifier);
}
return this;

View File

@ -294,28 +294,22 @@ export class DmpBlueprintValueEditorModel implements DmpBlueprintValuePersist {
fromModel(item: DmpBlueprintValue, dmpReferences: DmpReference[]): DmpBlueprintValueEditorModel {
this.fieldId = item.fieldId;
this.fieldValue = item.fieldValue;
// TODO check typeId field
if(dmpReferences){
dmpReferences.forEach(dmpReference => {
if(dmpReference.data.blueprintFieldId == this.fieldId && dmpReference.isActive == IsActive.Active){
this.references.push({
data: dmpReference.data,
this.references = dmpReferences?.filter(x => x.data.blueprintFieldId == this.fieldId && x.isActive == IsActive.Active).map(x => {
return {
data: x.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
id: x.reference.id,
label: x.reference.label,
reference: x.reference.reference,
source: x.reference.source,
typeId: x.reference.type?.id,
description: x.reference.source,
definition: x.reference.definition,
abbreviation: x.reference.abbreviation,
sourceType: x.reference.sourceType
}
})
}
})
}
});
return this;
}