Skip to content

Commit 032061d

Browse files
committed
missing error-message
1 parent d4e5096 commit 032061d

5 files changed

Lines changed: 7 additions & 11 deletions

File tree

sormas-backend/src/main/java/de/symeda/sormas/backend/externalmessage/survey/AutomaticSurveyResponseProcessor.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
import javax.ejb.EJB;
1313
import javax.enterprise.context.ApplicationScoped;
1414
import javax.inject.Inject;
15-
import javax.persistence.EntityManager;
16-
import javax.persistence.PersistenceContext;
1715
import javax.transaction.Transactional;
1816

1917
import org.apache.commons.collections4.CollectionUtils;
@@ -35,7 +33,6 @@
3533
import de.symeda.sormas.api.utils.dataprocessing.ProcessingResultStatus;
3634
import de.symeda.sormas.backend.survey.SurveyFacadeEjb;
3735
import de.symeda.sormas.backend.survey.SurveyTokenFacadeEjb;
38-
import de.symeda.sormas.backend.util.ModelConstants;
3936

4037
/**
4138
* Performs the coordinating for patch operations out of Survey-responses.
@@ -54,9 +51,6 @@ public class AutomaticSurveyResponseProcessor {
5451
@EJB
5552
private SurveyTokenFacadeEjb.SurveyTokenFacadeEjbLocal surveyTokenFacade;
5653

57-
@PersistenceContext(unitName = ModelConstants.PERSISTENCE_UNIT_NAME)
58-
private EntityManager em;
59-
6054
public AutomaticSurveyResponseProcessor() {
6155
}
6256

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,14 +312,15 @@ private <T extends EntityDto> T saveDirectEntity(@NotNull EntityDto entityDto) {
312312
public void save(@NotNull List<Tuple<Integer, EntityDto>> entityDtosByKey) {
313313
List<Tuple<Integer, EntityDto>> dtosInProgress = new ArrayList<>(entityDtosByKey);
314314

315+
// ordering is important: root entities must be saved first to avoid OutdatedEntityException as leaf entities seem to update the case.
315316
List<Tuple<Integer, EntityDto>> orderedRootEntities = entityDtosByKey.stream()
316317
.filter(tuple -> leafAttacherDictionary.keySet().stream().noneMatch(leafClass -> leafClass.isInstance(tuple.getSecond())))
317318
.sorted(Comparator.comparing(Tuple::getSecond, new EntityDtoTypeComparator()))
318319
.collect(Collectors.toList());
319320

320321
orderedRootEntities.stream().map(Tuple::getSecond).forEach(this::saveDirectEntity);
321322

322-
// once it's done, leaf entities can be saved.
323+
// once it's done, leaf entities can be saved, as updating root entities will not break
323324
leafAttacherDictionary.forEach((leafClass, attacher) -> {
324325
List<Tuple<Integer, EntityDto>> leaves =
325326
dtosInProgress.stream().filter(t -> leafClass.isInstance(t.getSecond())).collect(Collectors.toList());

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public DataPatchResponse patch(CaseDataPatchRequest request) {
125125

126126
List<PlainSinglePatchResult> patchingTuples = computePatchingTuples(request);
127127

128-
logger.debug("Computed patchingTuples: [{}]", patchingTuples);
128+
logger.trace("Computed patchingTuples: [{}]", patchingTuples);
129129

130130
Predicate<PlainSinglePatchResult> customizableFieldsPredicate =
131131
patchResult -> patchResult.getField().getField().contains(PatchFieldHelper.CUSTOM_PREFIX);

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111
import de.symeda.sormas.api.person.PersonDto;
1212

1313
/**
14-
* Orders {@link AttachedEntityWrapper}s so that {@link CaseDataDto} comes first, {@link PersonDto} second,
15-
* and any other DTO type last.
14+
* Orders {@link EntityDto}s so that root entities come first.
15+
* Needed to properly store the "root-est" entity is persisted first, to avoid {@link de.symeda.sormas.api.utils.OutdatedEntityException} in
16+
* case a leaf modifies the parent.
1617
*/
1718
public class EntityDtoTypeComparator implements Comparator<EntityDto> {
1819

sormas-ui/src/main/java/de/symeda/sormas/ui/externalmessage/ExternalMessageController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ public void processSurveyResponse(String surveyResponseMessageUuid, Runnable suc
168168
? externalMessage.getSurveyResponseData().getLatest().getResult()
169169
: null;
170170

171-
// when button click:
171+
// In case of failure during operation, attempt to process the message again.
172172
if (result == null) {
173173
try {
174174
result = FacadeProvider.getExternalMessageFacade()

0 commit comments

Comments
 (0)