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

Commit 896fb31

Browse files
lgallgal
authored andcommitted
Merge remote-tracking branch 'remotes/origin/development' into 2087_extend-geocoding-service
2 parents b047ad2 + c27c5ff commit 896fb31

113 files changed

Lines changed: 3825 additions & 489 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.
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
package de.symeda.sormas.api;
2+
3+
import java.lang.reflect.InvocationTargetException;
4+
import java.lang.reflect.Method;
5+
import java.util.Arrays;
6+
import java.util.HashMap;
7+
import java.util.Map;
8+
9+
import de.symeda.sormas.api.utils.DataHelper;
10+
11+
public class EntityDtoAccessHelper {
12+
13+
public static Object getPropertyValue(HasUuid entity, String propertyKey) throws InvocationTargetException, IllegalAccessException {
14+
if (entity == null) {
15+
return null;
16+
}
17+
Class<? extends HasUuid> entityClass = entity.getClass();
18+
while (entityClass != null) {
19+
Method[] declaredMethods = entityClass.getDeclaredMethods();
20+
for (Method method : declaredMethods) {
21+
String methodName = method.getName();
22+
if (methodName.startsWith("get") || methodName.startsWith("is")) {
23+
String propertyName = methodName.replaceAll("(^(is|get))|((Reference)?Dto$)", "").toUpperCase();
24+
if (propertyName.equals(propertyKey.toUpperCase())) {
25+
return method.invoke(entity);
26+
}
27+
}
28+
}
29+
Class<?> superclass = entityClass.getSuperclass();
30+
entityClass = HasUuid.class.isAssignableFrom(superclass) ? (Class<? extends HasUuid>) superclass : null;
31+
}
32+
throw new IllegalArgumentException("No property " + propertyKey + " in class " + entity.getClass().getSimpleName());
33+
}
34+
35+
public static Object getPropertyPathValue(HasUuid entity, String propertyPath) {
36+
return getPropertyPathValue(entity, propertyPath, null);
37+
}
38+
39+
public static Object getPropertyPathValue(HasUuid entity, String propertyPath, IReferenceDtoResolver referenceDtoResolver) {
40+
String[] propertyKeys = propertyPath.split("[.]");
41+
Object currentEntity = entity;
42+
for (int i = 0; i < propertyKeys.length; i++) {
43+
if (currentEntity == null) {
44+
return null;
45+
}
46+
boolean isResolvable = referenceDtoResolver != null && ReferenceDto.class.isAssignableFrom(currentEntity.getClass());
47+
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+
}
52+
Object propertyValue = null;
53+
try {
54+
propertyValue = getPropertyValue((HasUuid) currentEntity, propertyKeys[i]);
55+
} catch (InvocationTargetException | IllegalAccessException e) {
56+
throw new IllegalArgumentException(e);
57+
} catch (IllegalArgumentException e) {
58+
if (!isResolvable) {
59+
throw e;
60+
}
61+
}
62+
if (propertyValue != null) {
63+
currentEntity = propertyValue;
64+
} else {
65+
if (isResolvable) {
66+
try {
67+
currentEntity = getPropertyValue(referenceDtoResolver.resolve((ReferenceDto) currentEntity), propertyKeys[i]);
68+
} catch (InvocationTargetException | IllegalAccessException e) {
69+
throw new IllegalArgumentException(e);
70+
}
71+
} else {
72+
currentEntity = null;
73+
}
74+
}
75+
}
76+
return currentEntity;
77+
}
78+
79+
public static String getPropertyPathValueString(HasUuid entity, String propertyPath, IReferenceDtoResolver referenceDtoResolver) {
80+
return DataHelper.valueToString(getPropertyPathValue(entity, propertyPath, referenceDtoResolver));
81+
}
82+
83+
public interface IReferenceDtoResolver {
84+
85+
EntityDto resolve(ReferenceDto referenceDto);
86+
}
87+
88+
public static class CachedReferenceDtoResolver implements IReferenceDtoResolver {
89+
90+
private Map<String, EntityDto> referenceCache = new HashMap<>();
91+
private IReferenceDtoResolver referenceDtoResolver;
92+
93+
public CachedReferenceDtoResolver(IReferenceDtoResolver referenceDtoResolver) {
94+
this.referenceDtoResolver = referenceDtoResolver;
95+
}
96+
97+
public EntityDto resolve(ReferenceDto referenceDto) {
98+
if (referenceDto != null) {
99+
EntityDto entityDto = referenceCache.get(referenceDto.getUuid());
100+
if (entityDto != null) {
101+
return entityDto;
102+
}
103+
}
104+
if (referenceDtoResolver != null) {
105+
EntityDto resolvedEntity = referenceDtoResolver.resolve(referenceDto);
106+
addReference(referenceDto, resolvedEntity);
107+
return resolvedEntity;
108+
}
109+
return null;
110+
}
111+
112+
public void addReference(ReferenceDto referenceDto, EntityDto entityDto) {
113+
if (referenceDto != null && entityDto != null) {
114+
referenceCache.put(referenceDto.getUuid(), entityDto);
115+
}
116+
}
117+
}
118+
}

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import de.symeda.sormas.api.contact.ContactFacade;
3737
import de.symeda.sormas.api.disease.DiseaseConfigurationFacade;
3838
import de.symeda.sormas.api.disease.DiseaseFacade;
39+
import de.symeda.sormas.api.docgeneneration.QuarantineOrderFacade;
3940
import de.symeda.sormas.api.epidata.EpiDataFacade;
4041
import de.symeda.sormas.api.event.EventFacade;
4142
import de.symeda.sormas.api.event.EventParticipantFacade;
@@ -305,11 +306,15 @@ public static AreaFacade getAreaFacade() {
305306
return get().lookupEjbRemote(AreaFacade.class);
306307
}
307308

308-
public static ExternalJournalFacade getExternalJournalFacade() {
309+
public static QuarantineOrderFacade getQuarantineOrderFacade() {
310+
return get().lookupEjbRemote(QuarantineOrderFacade.class);
311+
}
312+
313+
public static ExternalJournalFacade getExternalJournalFacade() {
309314
return get().lookupEjbRemote(ExternalJournalFacade.class);
310-
}
315+
}
311316

312-
@SuppressWarnings("unchecked")
317+
@SuppressWarnings("unchecked")
313318
public <P> P lookupEjbRemote(Class<P> clazz) {
314319
try {
315320
return (P) get().ic.lookup(buildJndiLookupName(clazz));

sormas-api/src/main/java/de/symeda/sormas/api/contact/ContactReferenceDto.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,9 @@ public static class PersonName implements Serializable {
116116
@SensitiveData
117117
private String lastName;
118118

119+
public PersonName() {
120+
}
121+
119122
public PersonName(String firstName, String lastName) {
120123
this.firstName = firstName;
121124
this.lastName = lastName;

sormas-api/src/main/java/de/symeda/sormas/api/contact/QuarantineType.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package de.symeda.sormas.api.contact;
22

3+
import java.util.Arrays;
4+
import java.util.List;
5+
36
import de.symeda.sormas.api.CountryHelper;
47
import de.symeda.sormas.api.i18n.I18nProperties;
58
import de.symeda.sormas.api.utils.HideForCountriesExcept;
@@ -18,6 +21,12 @@ public enum QuarantineType {
1821
UNKNOWN,
1922
OTHER;
2023

24+
public static final List<QuarantineType> QUARANTINE_IN_EFFECT = Arrays.asList(HOME, INSTITUTIONELL, HOSPITAL, HOTEL, ASYLUM_ACCOMMODATION);
25+
26+
public static boolean isQuarantineInEffect(QuarantineType quarantineType) {
27+
return QUARANTINE_IN_EFFECT.contains(quarantineType);
28+
}
29+
2130
public String toString() {
2231
return I18nProperties.getEnumCaption(this);
2332
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package de.symeda.sormas.api.docgeneneration;
2+
3+
import java.io.IOException;
4+
import java.util.List;
5+
import java.util.Properties;
6+
7+
import javax.ejb.Remote;
8+
9+
import de.symeda.sormas.api.ReferenceDto;
10+
11+
@Remote
12+
public interface QuarantineOrderFacade {
13+
14+
byte[] getGeneratedDocument(String templateName, ReferenceDto rootEntityReference, Properties extraProperties) throws IOException;
15+
16+
byte[] getTemplate(String templateName) throws IOException;
17+
18+
List<String> getAvailableTemplates();
19+
20+
boolean isExistingTemplate(String templateName);
21+
22+
List<String> getAdditionalVariables(String templateName) throws IOException;
23+
24+
void writeQuarantineTemplate(String fileName, byte[] document) throws IOException;
25+
26+
boolean deleteQuarantineTemplate(String fileName);
27+
}

sormas-api/src/main/java/de/symeda/sormas/api/feature/FeatureType.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ public enum FeatureType {
3333
CASE_SURVEILANCE,
3434
CONTACT_TRACING }),
3535
INFRASTRUCTURE_TYPE_AREA(true, false, null),
36-
CASE_FOLLOWUP(true, false, null);
36+
CASE_FOLLOWUP(true, false, null),
37+
TASK_NOTIFICATIONS(true, true, null),
38+
OTHER_NOTIFICATIONS(true, true, null);
3739

3840
/**
3941
* Server feature means that the feature only needs to be configured once per server since they define the way the system

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ public interface Captions {
272272
String CaseData_sharedToCountry = "CaseData.sharedToCountry";
273273
String CaseData_smallpoxVaccinationReceived = "CaseData.smallpoxVaccinationReceived";
274274
String CaseData_smallpoxVaccinationScar = "CaseData.smallpoxVaccinationScar";
275+
String CaseData_sormasToSormasOriginInfo = "CaseData.sormasToSormasOriginInfo";
275276
String CaseData_surveillanceOfficer = "CaseData.surveillanceOfficer";
276277
String CaseData_symptoms = "CaseData.symptoms";
277278
String CaseData_therapy = "CaseData.therapy";
@@ -286,6 +287,7 @@ public interface Captions {
286287
String CaseData_wasInQuarantineBeforeIsolation = "CaseData.wasInQuarantineBeforeIsolation";
287288
String caseDefaultView = "caseDefaultView";
288289
String caseDetailedView = "caseDetailedView";
290+
String caseDocuments = "caseDocuments";
289291
String caseEditData = "caseEditData";
290292
String caseEvents = "caseEvents";
291293
String caseEventsResetDateFilter = "caseEventsResetDateFilter";
@@ -699,6 +701,15 @@ public interface Captions {
699701
String districtAllDistricts = "districtAllDistricts";
700702
String districtArchivedDistricts = "districtArchivedDistricts";
701703
String districtName = "districtName";
704+
String DocumentTemplate = "DocumentTemplate";
705+
String DocumentTemplate_documentTemplateGuide = "DocumentTemplate.documentTemplateGuide";
706+
String DocumentTemplate_exampleTemplateLibreOffice = "DocumentTemplate.exampleTemplateLibreOffice";
707+
String DocumentTemplate_exampleTemplateWord = "DocumentTemplate.exampleTemplateWord";
708+
String DocumentTemplate_plural = "DocumentTemplate.plural";
709+
String DocumentTemplate_QuarantineOrder = "DocumentTemplate.QuarantineOrder";
710+
String DocumentTemplate_QuarantineOrder_create = "DocumentTemplate.QuarantineOrder.create";
711+
String DocumentTemplate_QuarantineOrder_templates = "DocumentTemplate.QuarantineOrder.templates";
712+
String DocumentTemplate_uploadTemplate = "DocumentTemplate.uploadTemplate";
702713
String EpiData = "EpiData";
703714
String EpiData_animalCondition = "EpiData.animalCondition";
704715
String EpiData_animalVaccinationStatus = "EpiData.animalVaccinationStatus";
@@ -1355,6 +1366,7 @@ public interface Captions {
13551366
String SormasToSormasOptions_pseudonymizePersonalData = "SormasToSormasOptions.pseudonymizePersonalData";
13561367
String SormasToSormasOptions_pseudonymizeSensitiveData = "SormasToSormasOptions.pseudonymizeSensitiveData";
13571368
String SormasToSormasOptions_withAssociatedContacts = "SormasToSormasOptions.withAssociatedContacts";
1369+
String SormasToSormasOptions_withSamples = "SormasToSormasOptions.withSamples";
13581370
String sormasToSormasSentFrom = "sormasToSormasSentFrom";
13591371
String sormasToSormasShare = "sormasToSormasShare";
13601372
String sormasToSormasSharedBy = "sormasToSormasSharedBy";
@@ -1665,6 +1677,8 @@ public interface Captions {
16651677
String View_configuration_devMode_short = "View.configuration.devMode.short";
16661678
String View_configuration_districts = "View.configuration.districts";
16671679
String View_configuration_districts_short = "View.configuration.districts.short";
1680+
String View_configuration_documentTemplates = "View.configuration.documentTemplates";
1681+
String View_configuration_documentTemplates_short = "View.configuration.documentTemplates.short";
16681682
String View_configuration_facilities = "View.configuration.facilities";
16691683
String View_configuration_facilities_short = "View.configuration.facilities.short";
16701684
String View_configuration_laboratories = "View.configuration.laboratories";
@@ -1679,6 +1693,8 @@ public interface Captions {
16791693
String View_configuration_populationdata_short = "View.configuration.populationdata.short";
16801694
String View_configuration_regions = "View.configuration.regions";
16811695
String View_configuration_regions_short = "View.configuration.regions.short";
1696+
String View_configuration_templates = "View.configuration.templates";
1697+
String View_configuration_templates_short = "View.configuration.templates.short";
16821698
String View_configuration_userrights = "View.configuration.userrights";
16831699
String View_configuration_userrights_short = "View.configuration.userrights.short";
16841700
String View_contacts = "View.contacts";

0 commit comments

Comments
 (0)