fix prefiling without get

This commit is contained in:
Efstratios Giannopoulos 2024-04-18 12:34:46 +03:00
parent c762613509
commit b1a17faa40
1 changed files with 9 additions and 4 deletions

View File

@ -350,9 +350,14 @@ public class PrefillingSourceServiceImpl implements PrefillingSourceService {
ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria(); ExternalReferenceCriteria externalReferenceCriteria = new ExternalReferenceCriteria();
externalReferenceCriteria.setLike(model.getPrefillId()); externalReferenceCriteria.setLike(model.getPrefillId());
ExternalDataResult externalData = this.externalFetcherService.getExternalData(Stream.of(prefillingSourceDefinition.getGetConfiguration()).collect(Collectors.toList()), externalReferenceCriteria, null); Map<String, String> data = new HashMap<>();
if (externalData == null || this.conventionService.isListNullOrEmpty(externalData.getResults())) { if (prefillingSourceDefinition.getGetConfiguration() != null){
return null; ExternalDataResult externalData = this.externalFetcherService.getExternalData(Stream.of(prefillingSourceDefinition.getGetConfiguration()).collect(Collectors.toList()), externalReferenceCriteria, null);
if (externalData != null && !this.conventionService.isListNullOrEmpty(externalData.getResults())) {
data = externalData.getResults().getFirst();
}
} else {
data = model.getData() == null ? new HashMap<>() : model.getData();
} }
DescriptionTemplateEntity descriptionTemplateEntity = this.entityManager.find(DescriptionTemplateEntity.class, model.getDescriptionTemplateId()); DescriptionTemplateEntity descriptionTemplateEntity = this.entityManager.find(DescriptionTemplateEntity.class, model.getDescriptionTemplateId());
@ -363,7 +368,7 @@ public class PrefillingSourceServiceImpl implements PrefillingSourceService {
FieldSet descriptionTemplateFields = fieldSet.extractPrefixed(this.conventionService.asPrefix(Description._descriptionTemplate)); FieldSet descriptionTemplateFields = fieldSet.extractPrefixed(this.conventionService.asPrefix(Description._descriptionTemplate));
description.setDescriptionTemplate(this.builderFactory.builder(DescriptionTemplateBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(descriptionTemplateFields, descriptionTemplateEntity)); description.setDescriptionTemplate(this.builderFactory.builder(DescriptionTemplateBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(descriptionTemplateFields, descriptionTemplateEntity));
return mapPrefilledEntityToDescription(description, descriptionTemplateDefinition, prefillingSourceDefinition, prefillingSourceEntity.getLabel(), externalData.getResults().getFirst());//TODO return mapPrefilledEntityToDescription(description, descriptionTemplateDefinition, prefillingSourceDefinition, prefillingSourceEntity.getLabel(), data);
} }
private Description mapPrefilledEntityToDescription(Description description, DefinitionEntity descriptionTemplateDefinition, PrefillingSourceDefinitionEntity prefillingSourceDefinition, String type, Map<String, String> externalData){ private Description mapPrefilledEntityToDescription(Description description, DefinitionEntity descriptionTemplateDefinition, PrefillingSourceDefinitionEntity prefillingSourceDefinition, String type, Map<String, String> externalData){