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

Commit 72227a9

Browse files
author
FredrikSchäferVitagroup
committed
Merge branch 'development' into 3820-demis-testResultText
# Conflicts: # sormas-backend/src/main/resources/sql/sormas_schema.sql
2 parents 4548882 + 0dcb04e commit 72227a9

279 files changed

Lines changed: 5872 additions & 1259 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

sormas-api/src/main/java/de/symeda/sormas/api/EntityDtoAccessHelper.java

Lines changed: 58 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,31 @@
1+
/*
2+
* SORMAS® - Surveillance Outbreak Response Management & Analysis System
3+
* Copyright © 2016-2020 Helmholtz-Zentrum für Infektionsforschung GmbH (HZI)
4+
* This program is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
* This program is distributed in the hope that it will be useful,
9+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+
* GNU General Public License for more details.
12+
* You should have received a copy of the GNU General Public License
13+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
14+
*/
15+
116
package de.symeda.sormas.api;
217

318
import java.lang.reflect.InvocationTargetException;
419
import java.lang.reflect.Method;
520
import java.util.Arrays;
21+
import java.util.Date;
622
import java.util.HashMap;
723
import java.util.Map;
824

25+
import org.apache.commons.lang3.StringUtils;
26+
27+
import de.symeda.sormas.api.caze.BirthDateDto;
28+
import de.symeda.sormas.api.caze.BurialInfoDto;
929
import de.symeda.sormas.api.utils.DataHelper;
1030

1131
public class EntityDtoAccessHelper {
@@ -14,8 +34,8 @@ public static Object getPropertyValue(HasUuid entity, String propertyKey) throws
1434
if (entity == null) {
1535
return null;
1636
}
17-
Class<? extends HasUuid> entityClass = entity.getClass();
18-
while (entityClass != null) {
37+
Class<?> entityClass = entity.getClass();
38+
while (HasUuid.class.isAssignableFrom(entityClass)) {
1939
Method[] declaredMethods = entityClass.getDeclaredMethods();
2040
for (Method method : declaredMethods) {
2141
String methodName = method.getName();
@@ -26,8 +46,7 @@ public static Object getPropertyValue(HasUuid entity, String propertyKey) throws
2646
}
2747
}
2848
}
29-
Class<?> superclass = entityClass.getSuperclass();
30-
entityClass = HasUuid.class.isAssignableFrom(superclass) ? (Class<? extends HasUuid>) superclass : null;
49+
entityClass = entityClass.getSuperclass();
3150
}
3251
throw new IllegalArgumentException("No property " + propertyKey + " in class " + entity.getClass().getSimpleName());
3352
}
@@ -45,18 +64,18 @@ public static Object getPropertyPathValue(HasUuid entity, String propertyPath, I
4564
}
4665
boolean isResolvable = referenceDtoResolver != null && ReferenceDto.class.isAssignableFrom(currentEntity.getClass());
4766

48-
if (!HasUuid.class.isAssignableFrom(currentEntity.getClass())) {
49-
String errorPropertyPath = entity.getClass().getSimpleName() + "." + String.join(".", Arrays.copyOfRange(propertyKeys, 0, i));
50-
throw new IllegalArgumentException(errorPropertyPath + " is not an EntityDto or ReferenceDto");
51-
}
5267
Object propertyValue = null;
5368
try {
5469
propertyValue = getPropertyValue((HasUuid) currentEntity, propertyKeys[i]);
5570
} catch (InvocationTargetException | IllegalAccessException e) {
56-
throw new IllegalArgumentException(e);
71+
throwIllegalArgumentException(e, entity, propertyKeys, i);
72+
} catch (ClassCastException e) {
73+
String entityClass = currentEntity.getClass().getSimpleName();
74+
String message = entityClass + "." + propertyKeys[i] + " cannot be resolved.";
75+
throwIllegalArgumentException(new IllegalArgumentException(message, e), entity, propertyKeys, i);
5776
} catch (IllegalArgumentException e) {
5877
if (!isResolvable) {
59-
throw e;
78+
throwIllegalArgumentException(e, entity, propertyKeys, i);
6079
}
6180
}
6281
if (propertyValue != null) {
@@ -65,8 +84,8 @@ public static Object getPropertyPathValue(HasUuid entity, String propertyPath, I
6584
if (isResolvable) {
6685
try {
6786
currentEntity = getPropertyValue(referenceDtoResolver.resolve((ReferenceDto) currentEntity), propertyKeys[i]);
68-
} catch (InvocationTargetException | IllegalAccessException e) {
69-
throw new IllegalArgumentException(e);
87+
} catch (InvocationTargetException | IllegalAccessException | IllegalArgumentException e) {
88+
throwIllegalArgumentException(e, entity, propertyKeys, i);
7089
}
7190
} else {
7291
currentEntity = null;
@@ -76,8 +95,33 @@ public static Object getPropertyPathValue(HasUuid entity, String propertyPath, I
7695
return currentEntity;
7796
}
7897

79-
public static String getPropertyPathValueString(HasUuid entity, String propertyPath, IReferenceDtoResolver referenceDtoResolver) {
80-
return DataHelper.valueToString(getPropertyPathValue(entity, propertyPath, referenceDtoResolver));
98+
private static void throwIllegalArgumentException(Exception e, HasUuid entity, String[] propertyKeys, int i) {
99+
String errorPropertyPath = cleanDictionaryClassNames(entity.getClass().getSimpleName())
100+
+ (i > 0 ? "." : "")
101+
+ StringUtils.join(Arrays.copyOfRange(propertyKeys, 0, i), ".");
102+
throw new IllegalArgumentException("In " + errorPropertyPath + ": " + cleanDictionaryClassNames(e.getMessage()), e);
103+
}
104+
105+
public static Object getPropertyPathValueString(HasUuid entity, String propertyPath, IReferenceDtoResolver referenceDtoResolver) {
106+
Object value = getPropertyPathValue(entity, propertyPath, referenceDtoResolver);
107+
return formatObject(value);
108+
}
109+
110+
public static Object formatObject(Object value) {
111+
if (value == null) {
112+
return null;
113+
} else if (value instanceof Date
114+
|| value instanceof BurialInfoDto
115+
|| value instanceof BirthDateDto
116+
|| value.getClass().equals(Boolean.class)) {
117+
return DataHelper.valueToString(value);
118+
} else {
119+
return value;
120+
}
121+
}
122+
123+
public static String cleanDictionaryClassNames(String className) {
124+
return className.replaceAll("(Reference)?Dto", "");
81125
}
82126

83127
public interface IReferenceDtoResolver {

sormas-api/src/main/java/de/symeda/sormas/api/FacadeProvider.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
import de.symeda.sormas.api.contact.ContactFacade;
3535
import de.symeda.sormas.api.disease.DiseaseConfigurationFacade;
3636
import de.symeda.sormas.api.disease.DiseaseFacade;
37+
import de.symeda.sormas.api.docgeneneration.DocumentTemplateFacade;
38+
import de.symeda.sormas.api.docgeneneration.EventDocumentFacade;
3739
import de.symeda.sormas.api.docgeneneration.QuarantineOrderFacade;
3840
import de.symeda.sormas.api.document.DocumentFacade;
3941
import de.symeda.sormas.api.epidata.EpiDataFacade;
@@ -317,6 +319,14 @@ public static QuarantineOrderFacade getQuarantineOrderFacade() {
317319
return get().lookupEjbRemote(QuarantineOrderFacade.class);
318320
}
319321

322+
public static EventDocumentFacade getEventDocumentFacade() {
323+
return get().lookupEjbRemote(EventDocumentFacade.class);
324+
}
325+
326+
public static DocumentTemplateFacade getDocumentTemplateFacade() {
327+
return get().lookupEjbRemote(DocumentTemplateFacade.class);
328+
}
329+
320330
public static ExternalJournalFacade getExternalJournalFacade() {
321331
return get().lookupEjbRemote(ExternalJournalFacade.class);
322332
}

sormas-api/src/main/java/de/symeda/sormas/api/campaign/diagram/CampaignDiagramSeries.java

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
import java.io.Serializable;
44
import java.util.Objects;
55

6+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
67
import de.symeda.sormas.api.AgeGroup;
78

9+
@JsonIgnoreProperties(ignoreUnknown = true)
810
public class CampaignDiagramSeries implements Serializable {
911

1012
private static final long serialVersionUID = 1420672609912364060L;
@@ -14,6 +16,8 @@ public class CampaignDiagramSeries implements Serializable {
1416
private String referenceValue;
1517
private String stack;
1618
private AgeGroup populationGroup;
19+
private String caption;
20+
private String color;
1721

1822
public CampaignDiagramSeries() {
1923
}
@@ -57,6 +61,22 @@ public void setStack(String stack) {
5761
this.stack = stack;
5862
}
5963

64+
public String getCaption() {
65+
return caption;
66+
}
67+
68+
public void setCaption(String caption) {
69+
this.caption = caption;
70+
}
71+
72+
public String getColor() {
73+
return color;
74+
}
75+
76+
public void setColor(String color) {
77+
this.color = color;
78+
}
79+
6080
/**
6181
* Needed. Otherwise hibernate will persist whenever loading,
6282
* because hibernate types creates new instances that aren't equal.
@@ -72,6 +92,8 @@ public boolean equals(Object o) {
7292
&& Objects.equals(formId, that.formId)
7393
&& Objects.equals(referenceValue, that.referenceValue)
7494
&& Objects.equals(stack, that.stack)
95+
&& Objects.equals(caption, that.caption)
96+
&& Objects.equals(color, that.color)
7597
&& Objects.equals(populationGroup, that.populationGroup);
7698
}
7799

@@ -85,6 +107,6 @@ public void setPopulationGroup(AgeGroup populationGroup) {
85107

86108
@Override
87109
public int hashCode() {
88-
return Objects.hash(fieldId, formId, referenceValue, stack, populationGroup);
110+
return Objects.hash(fieldId, formId, referenceValue, stack, caption, color, populationGroup);
89111
}
90112
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package de.symeda.sormas.api.campaign.diagram;
22

33
public enum DiagramType {
4-
COLUMN
4+
COLUMN,
5+
BAR
56
}

sormas-api/src/main/java/de/symeda/sormas/api/caze/CaseCriteria.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import de.symeda.sormas.api.infrastructure.PointOfEntryReferenceDto;
3030
import de.symeda.sormas.api.person.PersonReferenceDto;
3131
import de.symeda.sormas.api.person.PresentCondition;
32+
import de.symeda.sormas.api.person.SymptomJournalStatus;
3233
import de.symeda.sormas.api.region.CommunityReferenceDto;
3334
import de.symeda.sormas.api.region.DistrictReferenceDto;
3435
import de.symeda.sormas.api.region.RegionReferenceDto;
@@ -62,6 +63,7 @@ public class CaseCriteria extends BaseCriteria implements Cloneable {
6263
public static final String BIRTHDATE_MM = "birthdateMM";
6364
public static final String BIRTHDATE_DD = "birthdateDD";
6465
public static final String FOLLOW_UP_UNTIL_TO = "followUpUntilTo";
66+
public static final String SYMPTOM_JOURNAL_STATUS = "symptomJournalStatus";
6567
public static final String FACILITY_TYPE_GROUP = "facilityTypeGroup";
6668
public static final String FACILITY_TYPE = "facilityType";
6769
public static final String INCLUDE_CASES_FROM_OTHER_JURISDICTIONS = "includeCasesFromOtherJurisdictions";
@@ -107,6 +109,7 @@ public class CaseCriteria extends BaseCriteria implements Cloneable {
107109
private FollowUpStatus followUpStatus;
108110
private Date followUpUntilTo;
109111
private Date followUpUntilFrom;
112+
private SymptomJournalStatus symptomJournalStatus;
110113
private Date reportDateTo;
111114
private FacilityTypeGroup facilityTypeGroup;
112115
private FacilityType facilityType;
@@ -529,6 +532,14 @@ public CaseCriteria reportDateTo(Date reportDateTo) {
529532
return this;
530533
}
531534

535+
public SymptomJournalStatus getSymptomJournalStatus() {
536+
return symptomJournalStatus;
537+
}
538+
539+
public void setSymptomJournalStatus(SymptomJournalStatus symptomJournalStatus) {
540+
this.symptomJournalStatus = symptomJournalStatus;
541+
}
542+
532543
public Date getReportDateTo() {
533544
return reportDateTo;
534545
}

sormas-api/src/main/java/de/symeda/sormas/api/caze/CaseFollowUpDto.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,29 @@
2121

2222
import de.symeda.sormas.api.Disease;
2323
import de.symeda.sormas.api.followup.FollowUpDto;
24+
import de.symeda.sormas.api.person.SymptomJournalStatus;
2425

2526
public class CaseFollowUpDto extends FollowUpDto {
2627

2728
private static final long serialVersionUID = -7782443664670559221L;
2829

30+
public static final String SYMPTOM_JOURNAL_STATUS = "symptomJournalStatus";
31+
2932
private Date symptomsOnsetDate;
3033

3134
private final CaseJurisdictionDto jurisdiction;
35+
private SymptomJournalStatus symptomJournalStatus;
3236

3337
//@formatter:off
3438
public CaseFollowUpDto(String uuid, String personFirstName, String personLastName,
35-
Date reportDate, Date symptomsOnsetDate, Date followUpUntil, Disease disease,
36-
String caseReportingUserUuid, String caseRegionUuid, String caseDistrictUuid,
39+
Date reportDate, Date symptomsOnsetDate, Date followUpUntil, SymptomJournalStatus symptomJournalStatus,
40+
Disease disease, String caseReportingUserUuid, String caseRegionUuid, String caseDistrictUuid,
3741
String caseCommunityUud, String caseHealthFacilityUuid, String casePointOfEntryUuid
3842
) {
3943
//formatter:on
4044
super(uuid, personFirstName, personLastName, reportDate, followUpUntil, disease);
4145
this.symptomsOnsetDate = symptomsOnsetDate;
46+
this.symptomJournalStatus = symptomJournalStatus;
4247
this.jurisdiction = new CaseJurisdictionDto(
4348
caseReportingUserUuid,
4449
caseRegionUuid,
@@ -59,4 +64,12 @@ public Date getSymptomsOnsetDate() {
5964
public void setSymptomsOnsetDate(Date symptomsOnsetDate) {
6065
this.symptomsOnsetDate = symptomsOnsetDate;
6166
}
67+
68+
public SymptomJournalStatus getSymptomJournalStatus() {
69+
return symptomJournalStatus;
70+
}
71+
72+
public void setSymptomJournalStatus(SymptomJournalStatus symptomJournalStatus) {
73+
this.symptomJournalStatus = symptomJournalStatus;
74+
}
6275
}

sormas-api/src/main/java/de/symeda/sormas/api/caze/CaseIndexDetailedDto.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import de.symeda.sormas.api.person.ApproximateAgeType;
99
import de.symeda.sormas.api.person.PresentCondition;
1010
import de.symeda.sormas.api.person.Sex;
11+
import de.symeda.sormas.api.person.SymptomJournalStatus;
1112
import de.symeda.sormas.api.user.UserReferenceDto;
1213
import de.symeda.sormas.api.utils.PersonalData;
1314
import de.symeda.sormas.api.utils.SensitiveData;
@@ -70,7 +71,7 @@ public CaseIndexDetailedDto(long id, String uuid, String epidNumber, String exte
7071
String healthFacilityUuid, String healthFacilityName, String healthFacilityDetails,
7172
String pointOfEntryUuid, String pointOfEntryName, String pointOfEntryDetails, String surveillanceOfficerUuid, CaseOutcome outcome,
7273
Integer age, ApproximateAgeType ageType, Integer birthdateDD, Integer birthdateMM, Integer birthdateYYYY, Sex sex,
73-
Date quarantineTo, Float completeness, FollowUpStatus followUpStatus, Date followUpUntil, Date changeDate, Long facilityId,
74+
Date quarantineTo, Float completeness, FollowUpStatus followUpStatus, Date followUpUntil, SymptomJournalStatus symptomJournalStatus, Date changeDate, Long facilityId,
7475
String city, String street, String houseNumber, String additionalInformation, String postalCode, String phone,
7576
String reportingUserFirstName, String reportingUserLastName, Date symptomOnsetDate,
7677
int visitCount, long eventCount, Date latestSampleDateTime, long sampleCount) {
@@ -79,7 +80,7 @@ public CaseIndexDetailedDto(long id, String uuid, String epidNumber, String exte
7980
presentCondition, reportDate, reportingUserUuid, creationDate, regionUuid, districtUuid, districtName, communityUuid,
8081
healthFacilityUuid, healthFacilityName, healthFacilityDetails, pointOfEntryUuid, pointOfEntryName, pointOfEntryDetails, surveillanceOfficerUuid, outcome,
8182
age, ageType, birthdateDD, birthdateMM, birthdateYYYY, sex,
82-
quarantineTo, completeness, followUpStatus, followUpUntil, changeDate, facilityId, visitCount);
83+
quarantineTo, completeness, followUpStatus, followUpUntil, symptomJournalStatus, changeDate, facilityId, visitCount);
8384
//@formatter:on
8485

8586
this.city = city;

sormas-api/src/main/java/de/symeda/sormas/api/caze/CaseIndexDto.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import de.symeda.sormas.api.person.ApproximateAgeType;
2828
import de.symeda.sormas.api.person.PresentCondition;
2929
import de.symeda.sormas.api.person.Sex;
30+
import de.symeda.sormas.api.person.SymptomJournalStatus;
3031
import de.symeda.sormas.api.utils.PersonalData;
3132
import de.symeda.sormas.api.utils.SensitiveData;
3233
import de.symeda.sormas.api.utils.pseudonymization.PseudonymizableIndexDto;
@@ -65,6 +66,7 @@ public class CaseIndexDto extends PseudonymizableIndexDto implements Serializabl
6566
public static final String QUARANTINE_TO = "quarantineTo";
6667
public static final String FOLLOW_UP_STATUS = "followUpStatus";
6768
public static final String FOLLOW_UP_UNTIL = "followUpUntil";
69+
public static final String SYMPTOM_JOURNAL_STATUS = "symptomJournalStatus";
6870

6971
private long id;
7072
private String uuid;
@@ -99,6 +101,7 @@ public class CaseIndexDto extends PseudonymizableIndexDto implements Serializabl
99101
private Date quarantineTo;
100102
private FollowUpStatus followUpStatus;
101103
private Date followUpUntil;
104+
private SymptomJournalStatus symptomJournalStatus;
102105
private Integer visitCount;
103106

104107
private CaseJurisdictionDto jurisdiction;
@@ -110,14 +113,14 @@ public CaseIndexDto(long id, String uuid, String epidNumber, String externalID,
110113
String districtUuid, String districtName, String communityUuid, String healthFacilityUuid, String healthFacilityName, String healthFacilityDetails,
111114
String pointOfEntryUuid, String pointOfEntryName, String pointOfEntryDetails, String surveillanceOfficerUuid, CaseOutcome outcome,
112115
Integer age, ApproximateAgeType ageType, Integer birthdateDD, Integer birthdateMM, Integer birthdateYYYY, Sex sex, Date quarantineTo,
113-
Float completeness, FollowUpStatus followUpStatus, Date followUpUntil, Date changeDate, Long facilityId) {
116+
Float completeness, FollowUpStatus followUpStatus, Date followUpUntil, SymptomJournalStatus symptomJournalStatus, Date changeDate, Long facilityId) {
114117
this(id, uuid, epidNumber, externalID, externalToken, personFirstName, personLastName, disease,
115118
diseaseDetails, caseClassification, investigationStatus,
116119
presentCondition, reportDate, reportingUserUuid, creationDate, regionUuid,
117120
districtUuid, districtName, communityUuid, healthFacilityUuid, healthFacilityName, healthFacilityDetails,
118121
pointOfEntryUuid, pointOfEntryName, pointOfEntryDetails, surveillanceOfficerUuid, outcome,
119122
age, ageType, birthdateDD, birthdateMM, birthdateYYYY, sex, quarantineTo,
120-
completeness, followUpStatus, followUpUntil, changeDate, facilityId, null
123+
completeness, followUpStatus, followUpUntil, symptomJournalStatus, changeDate, facilityId, null
121124
);
122125
}
123126
//@formatter:on
@@ -129,7 +132,7 @@ public CaseIndexDto(long id, String uuid, String epidNumber, String externalID,
129132
String districtUuid, String districtName, String communityUuid, String healthFacilityUuid, String healthFacilityName, String healthFacilityDetails,
130133
String pointOfEntryUuid, String pointOfEntryName, String pointOfEntryDetails, String surveillanceOfficerUuid, CaseOutcome outcome,
131134
Integer age, ApproximateAgeType ageType, Integer birthdateDD, Integer birthdateMM, Integer birthdateYYYY, Sex sex, Date quarantineTo,
132-
Float completeness, FollowUpStatus followUpStatus, Date followUpUntil,
135+
Float completeness, FollowUpStatus followUpStatus, Date followUpUntil, SymptomJournalStatus symptomJournalStatus,
133136
Date changeDate, Long facilityId, // XXX: unused, only here for TypedQuery mapping
134137
Integer visitCount) {
135138
//@formatter:on
@@ -160,6 +163,7 @@ public CaseIndexDto(long id, String uuid, String epidNumber, String externalID,
160163
this.completeness = completeness;
161164
this.followUpStatus = followUpStatus;
162165
this.followUpUntil = followUpUntil;
166+
this.symptomJournalStatus = symptomJournalStatus;
163167

164168
this.jurisdiction = new CaseJurisdictionDto(reportingUserUuid, regionUuid, districtUuid, communityUuid, healthFacilityUuid, pointOfEntryUuid);
165169
}
@@ -386,6 +390,14 @@ public void setFollowUpUntil(Date followUpUntil) {
386390
this.followUpUntil = followUpUntil;
387391
}
388392

393+
public SymptomJournalStatus getSymptomJournalStatus() {
394+
return symptomJournalStatus;
395+
}
396+
397+
public void setSymptomJournalStatus(SymptomJournalStatus symptomJournalStatus) {
398+
this.symptomJournalStatus = symptomJournalStatus;
399+
}
400+
389401
public Integer getVisitCount() {
390402
return visitCount;
391403
}

0 commit comments

Comments
 (0)