change build dmp persist for validation with reference single option
This commit is contained in:
parent
a1437fd314
commit
943e7bc23e
|
@ -1074,7 +1074,7 @@ public class DmpServiceImpl implements DmpService {
|
||||||
if (!this.conventionService.isListNullOrEmpty(sectionEntity.getFields())){
|
if (!this.conventionService.isListNullOrEmpty(sectionEntity.getFields())){
|
||||||
for (eu.eudat.commons.types.dmpblueprint.FieldEntity fieldEntity: sectionEntity.getFields()) {
|
for (eu.eudat.commons.types.dmpblueprint.FieldEntity fieldEntity: sectionEntity.getFields()) {
|
||||||
|
|
||||||
if (!this.conventionService.isListNullOrEmpty(dmpReferenceEntities)) {
|
if (!this.conventionService.isListNullOrEmpty(dmpReferenceEntities) && fieldEntity.getCategory().equals(DmpBlueprintFieldCategory.ReferenceType)) {
|
||||||
List<ReferencePersist> referencePersists = new ArrayList<>();
|
List<ReferencePersist> referencePersists = new ArrayList<>();
|
||||||
for (DmpReferenceEntity dmpReferenceEntity : dmpReferenceEntities) {
|
for (DmpReferenceEntity dmpReferenceEntity : dmpReferenceEntities) {
|
||||||
DmpReferenceData referenceData = this.jsonHandlingService.fromJsonSafe(DmpReferenceData.class, dmpReferenceEntity.getData());
|
DmpReferenceData referenceData = this.jsonHandlingService.fromJsonSafe(DmpReferenceData.class, dmpReferenceEntity.getData());
|
||||||
|
@ -1082,21 +1082,21 @@ public class DmpServiceImpl implements DmpService {
|
||||||
ReferenceEntity reference = referencesFromAllFields.stream().filter(x -> x.getId().equals(dmpReferenceEntity.getReferenceId())).collect(Collectors.toList()).getFirst();
|
ReferenceEntity reference = referencesFromAllFields.stream().filter(x -> x.getId().equals(dmpReferenceEntity.getReferenceId())).collect(Collectors.toList()).getFirst();
|
||||||
if (referenceData.getBlueprintFieldId().equals(fieldEntity.getId()) && reference != null) {
|
if (referenceData.getBlueprintFieldId().equals(fieldEntity.getId()) && reference != null) {
|
||||||
referencePersists.add(this.buildReferencePersist(reference));
|
referencePersists.add(this.buildReferencePersist(reference));
|
||||||
// found reference
|
|
||||||
dmpBlueprintValues.put(fieldEntity.getId(), this.buildDmpBlueprintValuePersist(fieldEntity.getId(), null, referencePersists));
|
|
||||||
}
|
}
|
||||||
|
// put references
|
||||||
|
dmpBlueprintValues.put(fieldEntity.getId(), this.buildDmpBlueprintValuePersist(fieldEntity.getId(), null, referencePersists, ((ReferenceTypeFieldEntity)fieldEntity).getMultipleSelect()));
|
||||||
}
|
}
|
||||||
} else if (!this.conventionService.isListNullOrEmpty(data.getDmpBlueprintValues())) {
|
} else if (!this.conventionService.isListNullOrEmpty(data.getDmpBlueprintValues())) {
|
||||||
for (DmpBlueprintValueEntity value : data.getDmpBlueprintValues()) {
|
for (DmpBlueprintValueEntity value : data.getDmpBlueprintValues()) {
|
||||||
if (value.getFieldId().equals(fieldEntity.getId())) {
|
if (value.getFieldId().equals(fieldEntity.getId())) {
|
||||||
// found value
|
// found value
|
||||||
dmpBlueprintValues.put(fieldEntity.getId(), this.buildDmpBlueprintValuePersist(fieldEntity.getId(), value.getValue(), null));
|
dmpBlueprintValues.put(fieldEntity.getId(), this.buildDmpBlueprintValuePersist(fieldEntity.getId(), value.getValue(), null, null));
|
||||||
} else {
|
} else {
|
||||||
dmpBlueprintValues.put(fieldEntity.getId(), this.buildDmpBlueprintValuePersist(fieldEntity.getId(), null, null));
|
dmpBlueprintValues.put(fieldEntity.getId(), this.buildDmpBlueprintValuePersist(fieldEntity.getId(), null, null, null));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
dmpBlueprintValues.put(fieldEntity.getId(), this.buildDmpBlueprintValuePersist(fieldEntity.getId(), null, null));
|
dmpBlueprintValues.put(fieldEntity.getId(), this.buildDmpBlueprintValuePersist(fieldEntity.getId(), null, null, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1157,13 +1157,15 @@ public class DmpServiceImpl implements DmpService {
|
||||||
return persist;
|
return persist;
|
||||||
}
|
}
|
||||||
|
|
||||||
private @NotNull DmpBlueprintValuePersist buildDmpBlueprintValuePersist(UUID fieldId, String fieldValue, List<ReferencePersist> referencePersists){
|
private @NotNull DmpBlueprintValuePersist buildDmpBlueprintValuePersist(UUID fieldId, String fieldValue, List<ReferencePersist> referencePersists, Boolean multipleSelect){
|
||||||
DmpBlueprintValuePersist persist = new DmpBlueprintValuePersist();
|
DmpBlueprintValuePersist persist = new DmpBlueprintValuePersist();
|
||||||
|
|
||||||
persist.setFieldId(fieldId);
|
persist.setFieldId(fieldId);
|
||||||
|
|
||||||
if (!this.conventionService.isListNullOrEmpty(referencePersists)){
|
if (!this.conventionService.isListNullOrEmpty(referencePersists) && multipleSelect){
|
||||||
persist.setReferences(referencePersists);
|
persist.setReferences(referencePersists);
|
||||||
|
}else if (!this.conventionService.isListNullOrEmpty(referencePersists)){
|
||||||
|
persist.setReference(referencePersists.getFirst());
|
||||||
}else if (fieldValue != null){
|
}else if (fieldValue != null){
|
||||||
persist.setFieldValue(fieldValue);
|
persist.setFieldValue(fieldValue);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue