@@ -43,7 +43,7 @@ public class BusinessDtoFacade {
4343 @ EJB
4444 private UserFacadeEjb .UserFacadeEjbLocal userFacade ;
4545
46- private final Map <Class <? extends EntityDto >, Function <? extends EntityDto , ? extends EntityDto >> dtoSaveDictionary = new HashMap <>();
46+ private final Map <Class <? extends EntityDto >, Function <? extends EntityDto , ? extends EntityDto >> directDtoSaveDictionary = new HashMap <>();
4747
4848 private final Map <Class <? extends EntityDto >, Function <CaseDataDto , ? extends EntityDto >> dtoRetrieverDictionary = new HashMap <>();
4949
@@ -76,7 +76,7 @@ private void registerSaveOperations() {
7676 }
7777
7878 private <T extends EntityDto > void registerSave (Class <T > dtoClass , Function <T , T > consumer ) {
79- dtoSaveDictionary .put (dtoClass , consumer );
79+ directDtoSaveDictionary .put (dtoClass , consumer );
8080 }
8181
8282 private void registerFetchOperations () {
@@ -110,17 +110,21 @@ private void registerFetchByI18nOperationsCreateUpdate() {
110110 caseDataDto -> personFacade .getByUuid (caseDataDto .getPerson ().getUuid ()));
111111 registerFetchByI18nCreateUpdate (
112112 ImmunizationDto .I18N_PREFIX ,
113- caseDataDto -> {
114- ImmunizationDto build = ImmunizationDto .build (caseDataDto .getPerson ());
115- build .setRelatedCase (caseDataDto .toReference ());
116- return build ;
117- });
113+ createImmunizationDtoFromCaseFct ());
118114
119115 registerFetchByI18nCreateUpdate (
120116 VaccinationDto .I18N_PREFIX ,
121117 caseDataDto -> VaccinationDto .build (userFacade .getCurrentUserAsReference ()));
122118 }
123119
120+ private static Function <CaseDataDto , EntityDto > createImmunizationDtoFromCaseFct () {
121+ return caseDataDto -> {
122+ ImmunizationDto build = ImmunizationDto .build (caseDataDto .getPerson ());
123+ build .setRelatedCase (caseDataDto .toReference ());
124+ return build ;
125+ };
126+ }
127+
124128 private void registerFetchByI18nRead (String i18nName , Function <CaseDataDto , List <? extends EntityDto >> fct ) {
125129 dtoRetrieverByI18nDictionaryRead .put (i18nName , fct );
126130 }
@@ -208,7 +212,7 @@ public Set<String> fetchablePrefixes() {
208212 public <T extends EntityDto > T save (@ NotNull EntityDto entityDto ) {
209213 Class <? extends EntityDto > entityDtoClass = entityDto .getClass ();
210214
211- return Optional .ofNullable ((Function <T , T >) dtoSaveDictionary .get (entityDtoClass ))
215+ return Optional .ofNullable ((Function <T , T >) directDtoSaveDictionary .get (entityDtoClass ))
212216 .orElseThrow (() -> new IllegalStateException (String .format ("No save function defined for: [%s]" , entityDtoClass )))
213217 .apply ((T ) entityDto );
214218 }
0 commit comments