Skip to content

Commit 011b103

Browse files
committed
Showing excluded fields within modal and within download
1 parent 50c918d commit 011b103

8 files changed

Lines changed: 68 additions & 41 deletions

File tree

sormas-api/src/main/java/de/symeda/sormas/api/externalmessage/survey/ExternalMessageSurveyResponseRequest.java

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,13 @@ public class ExternalMessageSurveyResponseRequest implements Serializable {
4545
@NotNull
4646
private Map<String, Object> patchDictionary;
4747

48+
/**
49+
* Contains fields that were excluded from the patch dictionary, meant for fields that may not start with the prefix.
50+
* The prefix allows to safely exclude fields that are not meant to be mapped into SORMAS.
51+
*/
52+
@NotNull
53+
private Map<String, Object> excludedPatchDictionary;
54+
4855
/**
4956
* Origin that wants the patch operation.
5057
* Can be used within {@link de.symeda.sormas.api.patch.mapping.FieldCustomMapper}.
@@ -180,6 +187,15 @@ public ExternalMessageSurveyResponseRequest setSkipIfAlreadyProcessed(boolean sk
180187
return this;
181188
}
182189

190+
public Map<String, Object> getExcludedPatchDictionary() {
191+
return excludedPatchDictionary;
192+
}
193+
194+
public ExternalMessageSurveyResponseRequest setExcludedPatchDictionary(Map<String, Object> excludedPatchDictionary) {
195+
this.excludedPatchDictionary = excludedPatchDictionary;
196+
return this;
197+
}
198+
183199
@Override
184200
public boolean equals(Object o) {
185201
if (o == null || getClass() != o.getClass())
@@ -195,6 +211,7 @@ public boolean equals(Object o) {
195211
&& replacementStrategy == that.replacementStrategy
196212
&& emptyValueBehavior == that.emptyValueBehavior
197213
&& Objects.equals(patchDictionary, that.patchDictionary)
214+
&& Objects.equals(excludedPatchDictionary, that.excludedPatchDictionary)
198215
&& Objects.equals(origin, that.origin)
199216
&& Objects.equals(inputLanguages, that.inputLanguages);
200217
}
@@ -210,6 +227,7 @@ public int hashCode() {
210227
replacementStrategy,
211228
emptyValueBehavior,
212229
patchDictionary,
230+
excludedPatchDictionary,
213231
origin,
214232
inputLanguages,
215233
allowFallbackValues,
@@ -221,7 +239,8 @@ public String toString() {
221239
return "ExternalMessageSurveyResponseRequest{" + "token='" + token + '\'' + ", externalSurveyId='" + externalSurveyId + '\''
222240
+ ", externalRespondentId='" + externalRespondentId + '\'' + ", responseReceivedDate=" + responseReceivedDate
223241
+ ", patchedInCaseOfFailures=" + patchedInCaseOfFailures + ", replacementStrategy=" + replacementStrategy + ", emptyValueBehavior="
224-
+ emptyValueBehavior + ", patchDictionary=" + patchDictionary + ", origin='" + origin + '\'' + ", inputLanguages=" + inputLanguages
225-
+ ", allowFallbackValues=" + allowFallbackValues + ", skipIfAlreadyProcessed=" + skipIfAlreadyProcessed + '}';
242+
+ emptyValueBehavior + ", patchDictionary=" + patchDictionary + ", excludedPatchDictionary=" + excludedPatchDictionary + ", origin='"
243+
+ origin + '\'' + ", inputLanguages=" + inputLanguages + ", allowFallbackValues=" + allowFallbackValues + ", skipIfAlreadyProcessed="
244+
+ skipIfAlreadyProcessed + '}';
226245
}
227246
}

sormas-api/src/main/java/de/symeda/sormas/api/i18n/Captions.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2038,6 +2038,7 @@ public interface Captions {
20382038
String surveyResponseApplied = "surveyResponseApplied";
20392039
String surveyResponseMetadata = "surveyResponseMetadata";
20402040
String surveyResponsePatchDictionary = "surveyResponsePatchDictionary";
2041+
String surveyResponseExcludedFieldsDictionary = "surveyResponseExcludedFieldsDictionary";
20412042
String surveyResponseProcessingResult = "surveyResponseProcessingResult";
20422043
String surveyResponseValidFields = "surveyResponseValidFields";
20432044
String surveyResponseIgnoreField = "surveyResponseIgnoreField";

sormas-api/src/main/resources/captions.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3776,6 +3776,7 @@ surveyResponseCaseLink=Case
37763776
surveyResponseApplied=Applied
37773777
surveyResponseMetadata=Metadata
37783778
surveyResponsePatchDictionary=Patch Dictionary
3779+
surveyResponseExcludedFieldsDictionary=Ignored fields Dictionary
37793780
surveyResponseProcessingResult=Processing Result
37803781
surveyResponseValidFields=Valid Fields
37813782
surveyResponseIgnoreField=Ignore

sormas-backend/src/main/java/de/symeda/sormas/backend/externalmessage/ExternalMessageFacadeEjb.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ public List<ExternalMessageDto> saveAndProcessSurveyResponses(Date since) {
318318

319319
if (since == null) { // TODO: use shorter default range
320320
int hoursRange =
321-
Integer.parseInt(Optional.ofNullable(systemConfigurationValueFacade.getValue(SURVEY_PERIOD_INTERVAL_HOURS)).orElse("1680"));
321+
Integer.parseInt(Optional.ofNullable(systemConfigurationValueFacade.getValue(SURVEY_PERIOD_INTERVAL_HOURS)).orElse("50000"));
322322

323323
since = DateHelper.addSeconds(new Date(), -(hoursRange * 3600));
324324
}

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

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
package de.symeda.sormas.backend.patch;
22

3-
import java.util.AbstractMap;
4-
import java.util.Arrays;
5-
import java.util.Collection;
6-
import java.util.List;
7-
import java.util.Map;
8-
import java.util.Optional;
9-
import java.util.Set;
3+
import java.util.*;
104
import java.util.function.Function;
115
import java.util.function.Predicate;
126
import java.util.function.Supplier;
@@ -28,20 +22,8 @@
2822
import de.symeda.sormas.api.Disease;
2923
import de.symeda.sormas.api.EntityDto;
3024
import de.symeda.sormas.api.caze.CaseDataDto;
31-
import de.symeda.sormas.api.patch.CaseDataPatchRequest;
32-
import de.symeda.sormas.api.patch.DataPatchFailure;
33-
import de.symeda.sormas.api.patch.DataPatchFailureCause;
34-
import de.symeda.sormas.api.patch.DataPatchResponse;
35-
import de.symeda.sormas.api.patch.DataPatcher;
36-
import de.symeda.sormas.api.patch.DataReplacementStrategy;
37-
import de.symeda.sormas.api.patch.EmptyValueBehavior;
38-
import de.symeda.sormas.api.patch.SinglePatchResult;
39-
import de.symeda.sormas.api.patch.mapping.FieldCustomMapper;
40-
import de.symeda.sormas.api.patch.mapping.FieldPatchRequest;
41-
import de.symeda.sormas.api.patch.mapping.GroupedFieldsRequest;
42-
import de.symeda.sormas.api.patch.mapping.GroupedFieldsResponse;
43-
import de.symeda.sormas.api.patch.mapping.ValueMappingResult;
44-
import de.symeda.sormas.api.patch.mapping.ValuePatchRequest;
25+
import de.symeda.sormas.api.patch.*;
26+
import de.symeda.sormas.api.patch.mapping.*;
4527
import de.symeda.sormas.api.person.PersonDto;
4628
import de.symeda.sormas.api.utils.Tuple;
4729
import de.symeda.sormas.api.utils.fieldvisibility.FieldVisibilityCheckers;
@@ -291,9 +273,11 @@ private boolean anyFieldPatchedWithPrefix(Map<String, Object> validPatchDictiona
291273

292274
Optional<Exception> exception = PropertyAccessor.setNestedProperty(target, relativeFieldName, typedValue);
293275
if (exception.isPresent()) {
276+
Exception e = exception.orElseThrow();
277+
logger.error("Setting nested property failed", e);
294278
return singlePatchResult.setFailure(
295279
new DataPatchFailure().setDataPatchFailureCause(DataPatchFailureCause.TECHNICAL)
296-
.setDescription(exception.orElseThrow().getMessage())
280+
.setDescription(e.getMessage())
297281
.setProvidedFieldValue(untypedTargetValue));
298282
} else {
299283
return singlePatchResult.setValue(untypedTargetValue);

sormas-backend/src/main/java/de/symeda/sormas/backend/patch/alias/PathAliasHelper.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ public class PathAliasHelper {
3434

3535
public static final Map<String, String> DEFAULT_ALIAS_DICTIONARY = buildDefaultAliasDictionary();
3636

37+
/**
38+
* Can be used as OUT: for displaying purposes but not for in.
39+
*/
3740
public static final Map<String, Set<String>> DEFAULT_FORBIDDEN_ALIASES_DICTIONARY =
3841
Map.of("Location", Set.of("Person.address", "Exposure.location"));
3942

@@ -96,7 +99,8 @@ public Tuple<String, PathFailureCause> resolveAlias(String pathWithPotentialAlia
9699
* Objective is to retrieve a path WITH an alias to get the Field ID as in the data dictionary.
97100
*
98101
* @param pathWithoutAlias
99-
* @return
102+
* field that may or may not contain a "physical-path" that must be "shortened" to the Field ID.
103+
* @return path that is "shortened" to a path using the Field ID (alias).
100104
*/
101105
public String toAliasPath(String pathWithoutAlias) {
102106
Set<Map.Entry<String, String>> reduce = Stream.concat(

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

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,7 @@
2020

2121
import com.vaadin.server.ExternalResource;
2222
import com.vaadin.server.Sizeable;
23-
import com.vaadin.ui.Button;
24-
import com.vaadin.ui.Grid;
25-
import com.vaadin.ui.Label;
26-
import com.vaadin.ui.Link;
27-
import com.vaadin.ui.UI;
28-
import com.vaadin.ui.VerticalLayout;
29-
import com.vaadin.ui.Window;
23+
import com.vaadin.ui.*;
3024
import com.vaadin.ui.themes.ValoTheme;
3125

3226
import de.symeda.sormas.api.FacadeProvider;
@@ -100,9 +94,6 @@ public SurveyResponseDetailsWindow(ExternalMessageDto externalMessage, Runnable
10094
dictionaryGrid.setItems(entries);
10195
dictionaryGrid.setHeightByRows(Math.max(entries.size(), 1));
10296

103-
// VaadinUiUtil.showWarningPopup(String.format("Entries: [%s]", entries));
104-
// VaadinUiUtil.showWarningPopup(String.format("finalDisplayData: [%s]", finalDisplayData));
105-
10697
dictionaryGrid.addColumn(entry -> resolveFieldName(entry.getKey(), finalDisplayData))
10798
.setCaption(I18nProperties.getCaption(Captions.surveyResponseField))
10899
.setExpandRatio(2);
@@ -118,6 +109,33 @@ public SurveyResponseDetailsWindow(ExternalMessageDto externalMessage, Runnable
118109
layout.addComponent(dictionaryGrid);
119110
}
120111

112+
// --- Ignored patch dictionary Patch Dictionary section ---
113+
Label excludedFieldsDictionaryLabel = new Label(I18nProperties.getCaption(Captions.surveyResponseExcludedFieldsDictionary));
114+
CssStyles.style(excludedFieldsDictionaryLabel, CssStyles.H3);
115+
layout.addComponent(excludedFieldsDictionaryLabel);
116+
117+
Map<String, Object> excludedFieldsDictionary = request.getExcludedPatchDictionary();
118+
if (excludedFieldsDictionary != null && !excludedFieldsDictionary.isEmpty()) {
119+
List<Map.Entry<String, Object>> entries = excludedFieldsDictionary.entrySet().stream().collect(Collectors.toList());
120+
121+
final DisplayablePartialRetrievalResponse finalDisplayData = displayData;
122+
123+
Grid<Map.Entry<String, Object>> dictionaryGrid = new Grid<>();
124+
dictionaryGrid.setSizeFull();
125+
dictionaryGrid.setItems(entries);
126+
dictionaryGrid.setHeightByRows(Math.max(entries.size(), 1));
127+
128+
dictionaryGrid.addColumn(entry -> resolveFieldName(entry.getKey(), finalDisplayData))
129+
.setCaption(I18nProperties.getCaption(Captions.surveyResponseField))
130+
.setExpandRatio(2);
131+
132+
dictionaryGrid.addColumn(entry -> entry.getValue() != null ? entry.getValue().toString() : "")
133+
.setCaption(I18nProperties.getCaption(Captions.surveyResponseSubmittedValue))
134+
.setExpandRatio(2);
135+
136+
layout.addComponent(dictionaryGrid);
137+
}
138+
121139
// --- Processing Result section ---
122140
if (result != null) {
123141
Label resultHeading = new Label(I18nProperties.getCaption(Captions.surveyResponseProcessingResult));

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,16 @@ public SurveyResponseFailurePanel(Map<String, DataPatchFailure> failures, Displa
5959
.setId("cause")
6060
.setExpandRatio(2);
6161

62-
grid.addColumn(entry -> resolveCurrentValue(entry.getKey(), displayData))
63-
.setCaption(I18nProperties.getCaption(Captions.surveyResponseCurrentCaseValue))
64-
.setId("currentValue")
65-
.setExpandRatio(2);
66-
6762
grid.addColumn(entry -> entry.getValue().getProvidedFieldValue() != null ? entry.getValue().getProvidedFieldValue().toString() : "")
6863
.setCaption(I18nProperties.getCaption(Captions.surveyResponseSubmittedValue))
6964
.setId("submittedValue")
7065
.setExpandRatio(2);
7166

67+
grid.addColumn(entry -> resolveCurrentValue(entry.getKey(), displayData))
68+
.setCaption(I18nProperties.getCaption(Captions.surveyResponseCurrentCaseValue))
69+
.setId("currentValue")
70+
.setExpandRatio(2);
71+
7272
grid.addColumn(entry -> entry.getValue().getDescription() != null ? entry.getValue().getDescription() : "")
7373
.setCaption(I18nProperties.getCaption(Captions.surveyResponseDescription))
7474
.setId("description")

0 commit comments

Comments
 (0)