Skip to content

Commit 18d564d

Browse files
committed
continued self review
1 parent a927df5 commit 18d564d

5 files changed

Lines changed: 15 additions & 41 deletions

File tree

sormas-api/src/main/java/de/symeda/sormas/api/patch/DataPatchFailure.java

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ public class DataPatchFailure implements Serializable {
2222
@Nullable
2323
private Object providedFieldValue;
2424

25-
@Nullable
26-
private String description;
27-
2825
public DataPatchFailureCause getDataPatchFailureCause() {
2926
return dataPatchFailureCause;
3027
}
@@ -52,19 +49,10 @@ public DataPatchFailure setProvidedFieldValue(Object providedFieldValue) {
5249
return this;
5350
}
5451

55-
public String getDescription() {
56-
return description;
57-
}
58-
59-
public DataPatchFailure setDescription(String description) {
60-
this.description = description;
61-
return this;
62-
}
63-
6452
@Override
6553
public String toString() {
6654
return "DataPatchFailure{" + "dataPatchFailureCause=" + dataPatchFailureCause + ", existingFieldValue=" + existingFieldValue
67-
+ ", providedFieldValue=" + providedFieldValue + ", description='" + description + '\'' + '}';
55+
+ ", providedFieldValue=" + providedFieldValue + "\"" + '\'' + '}';
6856
}
6957

7058
@Override
@@ -74,12 +62,11 @@ public boolean equals(Object o) {
7462
DataPatchFailure that = (DataPatchFailure) o;
7563
return dataPatchFailureCause == that.dataPatchFailureCause
7664
&& Objects.equals(existingFieldValue, that.existingFieldValue)
77-
&& Objects.equals(providedFieldValue, that.providedFieldValue)
78-
&& Objects.equals(description, that.description);
65+
&& Objects.equals(providedFieldValue, that.providedFieldValue);
7966
}
8067

8168
@Override
8269
public int hashCode() {
83-
return Objects.hash(dataPatchFailureCause, existingFieldValue, providedFieldValue, description);
70+
return Objects.hash(dataPatchFailureCause, existingFieldValue, providedFieldValue);
8471
}
8572
}

sormas-backend/src/main/java/de/symeda/sormas/backend/patch/DataPatcherImpl.java

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
import de.symeda.sormas.backend.common.ConfigFacadeEjb;
3030
import de.symeda.sormas.backend.feature.FeatureConfigurationFacadeEjb;
3131
import de.symeda.sormas.backend.json.ObjectMapperProvider;
32-
import de.symeda.sormas.backend.patch.mapping.PatchEqualityCheckersRegistry;
3332
import de.symeda.sormas.backend.patch.mapping.FieldCustomMapperRegistry;
33+
import de.symeda.sormas.backend.patch.mapping.PatchEqualityCheckersRegistry;
3434
import de.symeda.sormas.backend.patch.mapping.ValueMapperRegistry;
3535
import 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

sormas-backend/src/main/java/de/symeda/sormas/backend/patch/PatchFieldHelper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public Set<Tuple<String, PathFailureCause>> extractFieldTuples(Set<String> field
6767
}
6868

6969
@NotNull
70-
private Stream<String> splitMultipleFieldsPath(String path) {
70+
public Stream<String> splitMultipleFieldsPath(String path) {
7171
int openingParenthesisIndex = path.indexOf("(");
7272
String prefix = path.substring(0, openingParenthesisIndex);
7373

sormas-backend/src/main/java/de/symeda/sormas/backend/patch/PropertyAccessor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public static Tuple<Tuple<Class<?>, Object>, PropertyAccessFailure> getPropertyT
8989
})
9090
.orElseGet(() -> Tuple.of(null, PropertyAccessFailure.FIELD_DOES_NOT_EXIST));
9191
} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
92-
logger.info("Could not get property type for [{}], [{}]", fieldName, bean.getClass().getSimpleName(), e);
92+
logger.info("Could not get property type for [{}], [{}]", fieldName, bean, e);
9393
return null;
9494
}
9595
}
@@ -109,7 +109,7 @@ public static Tuple<Class<?>, PropertyAccessFailure> getPropertyType(
109109
return new Tuple<>(propertyType, null);
110110
}).orElse(FIELD_DOES_NOT_EXIST);
111111
} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
112-
logger.info("Could not get property type for [{}], [{}]", fieldName, bean.getClass().getSimpleName(), e);
112+
logger.info("Could not get property type for [{}], [{}]", fieldName, bean, e);
113113
return FIELD_DOES_NOT_EXIST;
114114
}
115115
}

sormas-ui/src/main/java/de/symeda/sormas/ui/externalmessage/surveyresponse/SurveyResponseFailurePanel.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,6 @@ public SurveyResponseFailurePanel(Map<String, DataPatchFailure> failures, Displa
7070
.setId("currentValue")
7171
.setExpandRatio(2);
7272

73-
grid.addColumn(entry -> entry.getValue().getDescription() != null ? entry.getValue().getDescription() : "")
74-
.setCaption(I18nProperties.getCaption(Captions.surveyResponseDescription))
75-
.setId("description")
76-
.setExpandRatio(3);
77-
7873
grid.setHeightByRows(Math.max(failureEntries.size(), 1));
7974

8075
addComponent(grid);

0 commit comments

Comments
 (0)