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) { 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())) { if (!this.conventionService.isListNullOrEmpty(fieldPersist.getReferences())) {
for (ReferencePersist referencePersist : fieldPersist.getReferences()) { for (ReferencePersist referencePersist : fieldPersist.getReferences()) {
DescriptionReferencePersist descriptionReferencePersist = new DescriptionReferencePersist(); 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 eu.eudat.model.persist.descriptionproperties.FieldPersist;
import java.time.Instant; import java.time.Instant;
import java.util.ArrayList;
import java.util.List; import java.util.List;
public class Field { public class Field {
@ -43,7 +44,10 @@ public class Field {
tempTextListValue = persist.getTextListValue(); tempTextListValue = persist.getTextListValue();
if (persist.getExternalIdentifier() != null) this.externalIdentifier = new ExternalIdentifier(persist.getExternalIdentifier()); if (persist.getExternalIdentifier() != null) this.externalIdentifier = new ExternalIdentifier(persist.getExternalIdentifier());
else this.externalIdentifier = null; 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()){ if (persist.getReferences() != null && !persist.getReferences().isEmpty()){
tempTextListValue = persist.getReferences().stream().filter(x-> x.getId() != null).map(x-> x.getId().toString()).toList(); 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 { export interface DescriptionTemplateBaseFieldData {
label: string; label: string;
fieldType: DescriptionTemplateFieldType; fieldType: DescriptionTemplateFieldType;
multipleSelect?: boolean;
} }

View File

@ -430,20 +430,34 @@ export class DescriptionFieldEditorModel implements DescriptionFieldPersist {
this.textListValue = item.textListValue; this.textListValue = item.textListValue;
this.dateValue = item.dateValue; 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 => { this.references = descriptionReferences?.filter(x => x.data?.fieldId == descriptionTemplateField?.id && x.isActive == IsActive.Active).map(x => {
return { return {
id: x.reference.id, id: x.reference.id,
label: x.reference.label, label: x.reference.label,
reference: x.reference.reference, reference: x.reference.reference,
source: x.reference.source, source: x.reference.source,
typeId: x.reference.type.id, typeId: x.reference.type.id,
description: x.reference.source, description: x.reference.source,
definition: x.reference.definition, definition: x.reference.definition,
abbreviation: x.reference.abbreviation, abbreviation: x.reference.abbreviation,
sourceType: x.reference.sourceType sourceType: x.reference.sourceType
} }
}); });
this.externalIdentifier = new DescriptionExternalIdentifierEditorModel(this.validationErrorModel).fromModel(item.externalIdentifier); this.externalIdentifier = new DescriptionExternalIdentifierEditorModel(this.validationErrorModel).fromModel(item.externalIdentifier);
} }
return this; return this;

View File

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