2929import de .symeda .sormas .backend .common .ConfigFacadeEjb ;
3030import de .symeda .sormas .backend .feature .FeatureConfigurationFacadeEjb ;
3131import de .symeda .sormas .backend .json .ObjectMapperProvider ;
32- import de .symeda .sormas .backend .patch .mapping .PatchEqualityCheckersRegistry ;
3332import de .symeda .sormas .backend .patch .mapping .FieldCustomMapperRegistry ;
33+ import de .symeda .sormas .backend .patch .mapping .PatchEqualityCheckersRegistry ;
3434import de .symeda .sormas .backend .patch .mapping .ValueMapperRegistry ;
3535import de .symeda .sormas .backend .util .CollectorUtils ;
3636
@@ -71,6 +71,7 @@ public DataPatcherImpl(
7171 BusinessDtoFacade businessDtoFacade ,
7272 FeatureConfigurationFacadeEjb .FeatureConfigurationFacadeEjbLocal featureConfigurationFacade ,
7373 ConfigFacadeEjb .ConfigFacadeEjbLocal configFacade ) {
74+
7475 this .patchFieldHelper = patchFieldHelper ;
7576 this .valueMapperRegistry = valueMapperRegistry ;
7677 this .fieldCustomMapperRegistry = fieldCustomMapperRegistry ;
@@ -102,9 +103,8 @@ public DataPatchResponse patch(CaseDataPatchRequest request) {
102103 try {
103104 return produceSinglePatchResult (request , singleFieldPatchResult , disease , target );
104105 } catch (RuntimeException e ) {
105- logger .error ("Failure during patch operation" , e );
106- return singlePatchResult
107- .setFailure (new DataPatchFailure ().setDataPatchFailureCause (DataPatchFailureCause .TECHNICAL ).setDescription (e .getMessage ()));
106+ logger .error ("Failure during patch operation for request: [{}], [{}]" , request , singleFieldPatchResult , e );
107+ return singlePatchResult .setFailure (new DataPatchFailure ().setDataPatchFailureCause (DataPatchFailureCause .TECHNICAL ));
108108 }
109109
110110 }).collect (Collectors .toList ());
@@ -230,11 +230,9 @@ private void saveDTOsIfAppropriate(Map<String, AttachedEntityWrapper> entityCach
230230 Optional <Exception > exception = PropertyAccessor .setNestedProperty (target , relativeFieldName , typedValue );
231231 if (exception .isPresent ()) {
232232 Exception e = exception .orElseThrow ();
233- logger .error ("Setting nested property failed" , e );
233+ logger .error ("Setting nested property failed for: field [{}] on [{}] with value: [{}]" , relativeFieldName , target , typedValue , e );
234234 return singlePatchResult .setFailure (
235- new DataPatchFailure ().setDataPatchFailureCause (DataPatchFailureCause .TECHNICAL )
236- .setDescription (e .getMessage ())
237- .setProvidedFieldValue (untypedTargetValue ));
235+ new DataPatchFailure ().setDataPatchFailureCause (DataPatchFailureCause .TECHNICAL ).setProvidedFieldValue (untypedTargetValue ));
238236 } else {
239237 return singlePatchResult .setValue (untypedTargetValue );
240238 }
@@ -328,15 +326,8 @@ private List<SingleFieldPatchResult> computePatchingTuples(CaseDataPatchRequest
328326
329327 @ NotNull
330328 private Stream <SingleFieldPatchResult > splitMultipleFieldsPath (Map .Entry <String , Object > entry ) {
331- String path = entry .getKey ();
332- int openingParenthesisIndex = path .indexOf ("(" );
333- String prefix = path .substring (0 , openingParenthesisIndex );
334-
335- int closeParen = path .indexOf (')' );
336-
337- String restPath = path .substring (openingParenthesisIndex + 1 , closeParen );
338-
339- return Arrays .stream (restPath .split ("\\ |" )).map (suffix -> new SingleFieldPatchResult (prefix + suffix , null , entry .getValue ()));
329+ return patchFieldHelper .splitMultipleFieldsPath (entry .getKey ())
330+ .map (singlePath -> new SingleFieldPatchResult (singlePath , null , entry .getValue ()));
340331 }
341332
342333 private @ NotNull Predicate <Map .Entry <String , Object >> buildAdequateDictionaryValuePredicate (CaseDataPatchRequest request ) {
@@ -350,6 +341,7 @@ private Stream<SingleFieldPatchResult> splitMultipleFieldsPath(Map.Entry<String,
350341 if (caseData == null ) {
351342 throw new IllegalStateException (String .format ("No case found for uuid: [%s]" , caseUuid ));
352343 }
344+
353345 return caseData ;
354346 }
355347
0 commit comments