Skip to content
This repository was archived by the owner on May 5, 2021. It is now read-only.

Commit 8423696

Browse files
authored
Merge pull request SORMAS-Foundation#2694 from hzi-braunschweig/feature-2642-PlaceOfResidenceFilterStatistics
Feature 2642 place of residence filter statistics
2 parents 7eced93 + 8bfde1c commit 8423696

8 files changed

Lines changed: 59 additions & 68 deletions

File tree

sormas-api/src/main/java/de/symeda/sormas/api/statistics/StatisticsCaseAttribute.java

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,12 @@ public enum StatisticsCaseAttribute {
5656
PLACE_OF_RESIDENCE(StatisticsCaseAttributeGroup.PERSON,
5757
true,
5858
true,
59+
false,
5960
StatisticsCaseSubAttribute.PERSON_REGION,
6061
StatisticsCaseSubAttribute.PERSON_DISTRICT,
6162
StatisticsCaseSubAttribute.PERSON_COMMUNITY,
6263
StatisticsCaseSubAttribute.PERSON_CITY,
63-
StatisticsCaseSubAttribute.PERSON_POSTCODE,
64-
StatisticsCaseSubAttribute.PERSON_ADDRESS),
64+
StatisticsCaseSubAttribute.PERSON_POSTCODE),
6565

6666
SEX(StatisticsCaseAttributeGroup.PERSON, true, true),
6767
AGE_INTERVAL_1_YEAR(StatisticsCaseAttributeGroup.PERSON, false, true),
@@ -78,6 +78,7 @@ public enum StatisticsCaseAttribute {
7878
private final StatisticsCaseAttributeGroup attributeGroup;
7979
private final boolean sortByCaption;
8080
private final boolean unknownValueAllowed;
81+
private boolean usedForVisualisation = true;
8182
private final StatisticsCaseSubAttribute[] subAttributes;
8283

8384
StatisticsCaseAttribute(
@@ -92,6 +93,20 @@ public enum StatisticsCaseAttribute {
9293
this.subAttributes = subAttributes;
9394
}
9495

96+
StatisticsCaseAttribute(
97+
StatisticsCaseAttributeGroup attributeGroup,
98+
boolean sortByCaption,
99+
boolean unknownValueAllowed,
100+
boolean usedForVisualisation,
101+
StatisticsCaseSubAttribute... subAttributes) {
102+
103+
this.usedForVisualisation = usedForVisualisation;
104+
this.attributeGroup = attributeGroup;
105+
this.sortByCaption = sortByCaption;
106+
this.unknownValueAllowed = unknownValueAllowed;
107+
this.subAttributes = subAttributes;
108+
}
109+
95110
public StatisticsCaseAttributeGroup getAttributeGroup() {
96111
return attributeGroup;
97112
}
@@ -100,6 +115,10 @@ public boolean isSortByCaption() {
100115
return sortByCaption;
101116
}
102117

118+
public boolean isUsedForVisualisation() {
119+
return usedForVisualisation;
120+
}
121+
103122
public boolean isUnknownValueAllowed() {
104123
return unknownValueAllowed;
105124
}

sormas-api/src/main/java/de/symeda/sormas/api/statistics/StatisticsCaseCriteria.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ public class StatisticsCaseCriteria implements Serializable {
7878
private List<CommunityReferenceDto> personCommunities;
7979
private String personCity;
8080
private String personPostcode;
81-
private String personAddress;
8281
private List<UserRole> reportingUserRoles;
8382

8483
public List<Year> getOnsetYears() {
@@ -217,10 +216,6 @@ public String getPersonPostcode() {
217216
return personPostcode;
218217
}
219218

220-
public String getPersonAddress() {
221-
return personAddress;
222-
}
223-
224219
public List<UserRole> getReportingUserRoles() {
225220
return reportingUserRoles;
226221
}
@@ -435,11 +430,6 @@ public StatisticsCaseCriteria setPersonPostcode(String personPostcode) {
435430
return this;
436431
}
437432

438-
public StatisticsCaseCriteria setPersonAddress(String personAddress) {
439-
this.personAddress = personAddress;
440-
return this;
441-
}
442-
443433
public StatisticsCaseCriteria reportingUserRoles(List<UserRole> reportingUserRoles) {
444434
this.reportingUserRoles = reportingUserRoles;
445435
return this;

sormas-api/src/main/java/de/symeda/sormas/api/statistics/StatisticsCaseSubAttribute.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,11 @@ public enum StatisticsCaseSubAttribute {
3333
DISTRICT(false, true),
3434
COMMUNITY(false, true),
3535
FACILITY(false, true),
36-
PERSON_REGION(true, false),
37-
PERSON_DISTRICT(true, false),
38-
PERSON_COMMUNITY(true, false),
39-
PERSON_CITY(true, false),
40-
PERSON_POSTCODE(true, false),
41-
PERSON_ADDRESS(true, false);
36+
PERSON_REGION(false, false),
37+
PERSON_DISTRICT(false, false),
38+
PERSON_COMMUNITY(false, false),
39+
PERSON_CITY(false, false),
40+
PERSON_POSTCODE(false, false);
4241

4342
private boolean usedForFilters;
4443
private boolean usedForGrouping;

sormas-backend/src/main/java/de/symeda/sormas/backend/caze/CaseStatisticsFacadeEjb.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -347,8 +347,7 @@ public Pair<String, List<Object>> buildCaseCountQuery(
347347
|| caseCriteria.getPersonDistricts() != null
348348
|| caseCriteria.getPersonCommunities() != null
349349
|| caseCriteria.getPersonCity() != null
350-
|| caseCriteria.getPersonPostcode() != null
351-
|| caseCriteria.getPersonAddress() != null) {
350+
|| caseCriteria.getPersonPostcode() != null) {
352351
caseJoinBuilder.append(" LEFT JOIN ")
353352
.append(Person.TABLE_NAME)
354353
.append(" ON ")
@@ -366,8 +365,7 @@ public Pair<String, List<Object>> buildCaseCountQuery(
366365
|| caseCriteria.getPersonDistricts() != null
367366
|| caseCriteria.getPersonCommunities() != null
368367
|| caseCriteria.getPersonCity() != null
369-
|| caseCriteria.getPersonPostcode() != null
370-
|| caseCriteria.getPersonAddress() != null) {
368+
|| caseCriteria.getPersonPostcode() != null) {
371369
caseJoinBuilder.append(" LEFT JOIN ")
372370
.append(Location.TABLE_NAME)
373371
.append(" ON ")

sormas-ui/src/main/java/de/symeda/sormas/ui/statistics/StatisticsFilterResidenceElement.java

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,12 @@ public class StatisticsFilterResidenceElement extends StatisticsFilterElement {
2525
StatisticsFilterValuesElement communityElement;
2626
StatisticsFilterSimpleTextElement cityElement;
2727
StatisticsFilterSimpleTextElement postcodeElement;
28-
StatisticsFilterSimpleTextElement addressElement;
2928

3029
public StatisticsFilterResidenceElement(int rowIndex) {
3130
setSpacing(true);
3231
addStyleName(CssStyles.LAYOUT_MINIMAL);
3332
setWidth(100, Unit.PERCENTAGE);
3433

35-
HorizontalLayout regionDistrictCommunityLayout = new HorizontalLayout();
36-
3734
VerticalLayout firstColumnLayout = new VerticalLayout();
3835
VerticalLayout secondColumnLayout = new VerticalLayout();
3936

@@ -57,23 +54,17 @@ public StatisticsFilterResidenceElement(int rowIndex) {
5754
rowIndex);
5855
cityElement = new StatisticsFilterSimpleTextElement(I18nProperties.getCaption(Captions.city), rowIndex);
5956
postcodeElement = new StatisticsFilterSimpleTextElement(I18nProperties.getCaption(Captions.postcode), rowIndex);
60-
addressElement = new StatisticsFilterSimpleTextElement(I18nProperties.getCaption(Captions.address), rowIndex);
6157

6258
firstColumnLayout.addComponent(regionElement);
6359
secondColumnLayout.addComponent(districtElement);
6460

6561
firstColumnLayout.addComponent(communityElement);
62+
secondColumnLayout.addComponent(cityElement);
6663

67-
regionDistrictCommunityLayout.addComponent(firstColumnLayout);
68-
regionDistrictCommunityLayout.addComponent(secondColumnLayout);
69-
70-
HorizontalLayout cityPostcodeAddressLayout = new HorizontalLayout();
71-
72-
cityPostcodeAddressLayout.addComponent(new VerticalLayout(cityElement));
73-
cityPostcodeAddressLayout.addComponent(new VerticalLayout(postcodeElement));
74-
cityPostcodeAddressLayout.addComponent(new VerticalLayout(addressElement));
64+
firstColumnLayout.addComponent(postcodeElement);
7565

76-
addComponent(new VerticalLayout(regionDistrictCommunityLayout, cityPostcodeAddressLayout));
66+
addComponent(firstColumnLayout);
67+
addComponent(secondColumnLayout);
7768

7869
regionElement.setValueChangeListener(e -> {
7970
districtElement.updateDropdownContent();
@@ -136,10 +127,6 @@ public String getPostcode() {
136127
return postcodeElement.getSelectedValues().get(0).getStringValue();
137128
}
138129

139-
public String getAddress() {
140-
return addressElement.getSelectedValues().get(0).getStringValue();
141-
}
142-
143130
@Override
144131
public List<TokenizableValue> getSelectedValues() {
145132
throw new UnsupportedOperationException("You should call one of the dedicated getters instead");

sormas-ui/src/main/java/de/symeda/sormas/ui/statistics/StatisticsFilterValuesElement.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,6 @@ private List<TokenizableValue> getFilterValues() {
233233
return createCommunityTokens(residenceElement.getSelectedDistricts());
234234
case PERSON_CITY:
235235
case PERSON_POSTCODE:
236-
case PERSON_ADDRESS:
237236
return new ArrayList<>();
238237
default:
239238
throw new IllegalArgumentException(this.toString());

sormas-ui/src/main/java/de/symeda/sormas/ui/statistics/StatisticsView.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1271,9 +1271,6 @@ private void fillCaseCriteria(boolean showCaseIncidence) {
12711271
if (residenceElement.getPostcode() != null) {
12721272
caseCriteria.setPersonPostcode(residenceElement.getPostcode());
12731273
}
1274-
if (residenceElement.getAddress() != null) {
1275-
caseCriteria.setPersonAddress(residenceElement.getAddress());
1276-
}
12771274
break;
12781275
case REPORTING_USER_ROLE:
12791276
if (filterElement.getSelectedValues() != null) {

sormas-ui/src/main/java/de/symeda/sormas/ui/statistics/StatisticsVisualizationElement.java

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -82,34 +82,36 @@ private void createAndAddComponents() {
8282

8383
// Add attributes belonging to the current group
8484
for (StatisticsCaseAttribute attribute : attributeGroup.getAttributes()) {
85-
Command attributeCommand = selectedItem -> {
86-
resetSubAttributeDropdown();
87-
this.attribute = attribute;
88-
this.subAttribute = null;
89-
displayedAttributeItem.setText(attribute.toString());
90-
removeSelections(displayedAttributeItem);
91-
selectedItem.setStyleName("selected-filter");
92-
93-
// Build sub attribute dropdown
94-
if (attribute.getSubAttributes().length > 0) {
95-
for (StatisticsCaseSubAttribute subAttribute : attribute.getSubAttributes()) {
96-
if (subAttribute.isUsedForGrouping()) {
97-
Command subAttributeCommand = selectedSubItem -> {
98-
this.subAttribute = subAttribute;
99-
displayedSubAttributeItem.setText(subAttribute.toString());
100-
removeSelections(displayedSubAttributeItem);
101-
selectedSubItem.setStyleName("selected-filter");
102-
};
103-
104-
displayedSubAttributeItem.addItem(subAttribute.toString(), subAttributeCommand);
85+
if (attribute.isUsedForVisualisation()) {
86+
Command attributeCommand = selectedItem -> {
87+
resetSubAttributeDropdown();
88+
this.attribute = attribute;
89+
this.subAttribute = null;
90+
displayedAttributeItem.setText(attribute.toString());
91+
removeSelections(displayedAttributeItem);
92+
selectedItem.setStyleName("selected-filter");
93+
94+
// Build sub attribute dropdown
95+
if (attribute.getSubAttributes().length > 0) {
96+
for (StatisticsCaseSubAttribute subAttribute : attribute.getSubAttributes()) {
97+
if (subAttribute.isUsedForGrouping()) {
98+
Command subAttributeCommand = selectedSubItem -> {
99+
this.subAttribute = subAttribute;
100+
displayedSubAttributeItem.setText(subAttribute.toString());
101+
removeSelections(displayedSubAttributeItem);
102+
selectedSubItem.setStyleName("selected-filter");
103+
};
104+
105+
displayedSubAttributeItem.addItem(subAttribute.toString(), subAttributeCommand);
106+
}
105107
}
106-
}
107108

108-
addComponent(displayedSubAttributeDropdown);
109-
}
110-
};
109+
addComponent(displayedSubAttributeDropdown);
110+
}
111+
};
111112

112-
displayedAttributeItem.addItem(attribute.toString(), attributeCommand);
113+
displayedAttributeItem.addItem(attribute.toString(), attributeCommand);
114+
}
113115
}
114116
}
115117

0 commit comments

Comments
 (0)