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

Commit 5f5d37e

Browse files
author
barnabartha
committed
Merge branch 'development' into feature-2890-CampaignDataByJurisdiction
# Conflicts: # sormas-ui/src/main/java/de/symeda/sormas/ui/campaign/campaigndata/CampaignFormDataEditForm.java
2 parents 673bd53 + 08917ab commit 5f5d37e

138 files changed

Lines changed: 3643 additions & 369 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.

SERVER_DEV_SETUP.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22

33
# Installing a SORMAS Server for development
4-
**Note: This guide explains how to configure a SORMAS server on Linux and Windows systems for development. Please note that there is no database setup because the script supposes the use of the Docker Postgresql image (see [SORMAS-Docker][https://github.com/hzi-braunschweig/SORMAS-Docker]).**
4+
**Note: This guide explains how to configure a SORMAS server on Linux and Windows systems for development. Please note that there is no database setup because the script supposes the use of the Docker Postgresql image (see [SORMAS-Docker](https://github.com/hzi-braunschweig/SORMAS-Docker)).**
55

66
## Content
77
* [Prerequisites](#prerequisites)
@@ -50,6 +50,10 @@ See [Keycloak](SERVER_SETUP.md#keycloak-server) for how to install Docker locall
5050

5151
If you are doing active development on Keycloak (themes, authentication mechanisms, translations, etc.) it's recommended to install the standalone variant.
5252

53+
## VAADIN Debug Mode
54+
55+
To enable [VAADIN Debug Mode](https://vaadin.com/docs/v8/framework/advanced/advanced-debug.html), go to ``sormas-ui/src/main/webapp/WEB-INF/web.xml`` and set ``productionMode`` to ``false``.
56+
Make sure not to commit your changes to these files, for example by using .gitignore. To access the debug Window, got to <url>/sormas-ui/?debug. You may need to log in as admin once first.
5357

5458
## Other components
5559

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/event/DashboardEventDto.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,12 @@ public class DashboardEventDto implements Serializable {
3030
public static final String I18N_PREFIX = "Event";
3131

3232
public static final String EVENT_STATUS = "eventStatus";
33+
public static final String EVENT_INVESTIGATION_STATUS = "eventInvestigationStatus";
3334
public static final String DISEASE = "disease";
3435

3536
private String uuid;
3637
private EventStatus eventStatus;
38+
private EventInvestigationStatus eventInvestigationStatus;
3739
private Disease disease;
3840
private String diseaseDetails;
3941
private Date eventDate;
@@ -48,6 +50,7 @@ public class DashboardEventDto implements Serializable {
4850
public DashboardEventDto(
4951
String uuid,
5052
EventStatus eventStatus,
53+
EventInvestigationStatus eventInvestigationStatus,
5154
Disease disease,
5255
String diseaseDetails,
5356
Date eventDate,
@@ -64,6 +67,7 @@ public DashboardEventDto(
6467

6568
this.uuid = uuid;
6669
this.eventStatus = eventStatus;
70+
this.eventInvestigationStatus = eventInvestigationStatus;
6771
this.disease = disease;
6872
this.diseaseDetails = diseaseDetails;
6973
this.eventDate = eventDate;
@@ -92,6 +96,14 @@ public void setEventStatus(EventStatus eventStatus) {
9296
this.eventStatus = eventStatus;
9397
}
9498

99+
public EventInvestigationStatus getEventInvestigationStatus() {
100+
return eventInvestigationStatus;
101+
}
102+
103+
public void setEventInvestigationStatus(EventInvestigationStatus eventInvestigationStatus) {
104+
this.eventInvestigationStatus = eventInvestigationStatus;
105+
}
106+
95107
public Disease getDisease() {
96108
return disease;
97109
}
@@ -154,7 +166,7 @@ public DistrictReferenceDto getDistrict() {
154166

155167
@Override
156168
public String toString() {
157-
return EventReferenceDto.buildCaption(getDisease(), getDiseaseDetails(), getEventStatus(), getEventDate());
169+
return EventReferenceDto.buildCaption(getDisease(), getDiseaseDetails(), getEventStatus(), getEventInvestigationStatus(), getEventDate());
158170
}
159171

160172
public EventJurisdictionDto getJurisdiction() {

sormas-api/src/main/java/de/symeda/sormas/api/event/EventActionIndexDto.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public class EventActionIndexDto implements Serializable {
3535
public static final String EVENT_START_DATE = "eventStartDate";
3636
public static final String EVENT_END_DATE = "eventEndDate";
3737
public static final String EVENT_STATUS = "eventStatus";
38+
public static final String EVENT_INVESTIGATION_STATUS = "eventInvestigationStatus";
3839
public static final String ACTION_TITLE = "actionTitle";
3940
public static final String ACTION_CREATION_DATE = "actionCreationDate";
4041
public static final String ACTION_CHANGE_DATE = "actionChangeDate";
@@ -47,6 +48,7 @@ public class EventActionIndexDto implements Serializable {
4748
private Date eventStartDate;
4849
private Date eventEndDate;
4950
private EventStatus eventStatus;
51+
private EventInvestigationStatus eventInvestigationStatus;
5052
private String actionTitle;
5153
private Date actionCreationDate;
5254
private Date actionChangeDate;
@@ -60,6 +62,7 @@ public EventActionIndexDto(
6062
Date eventStartDate,
6163
Date eventEndDate,
6264
EventStatus eventStatus,
65+
EventInvestigationStatus eventInvestigationStatus,
6366
String actionTitle,
6467
Date actionCreationDate,
6568
Date actionChangeDate,
@@ -74,6 +77,7 @@ public EventActionIndexDto(
7477
this.eventStartDate = eventStartDate;
7578
this.eventEndDate = eventEndDate;
7679
this.eventStatus = eventStatus;
80+
this.eventInvestigationStatus = eventInvestigationStatus;
7781
this.actionTitle = actionTitle;
7882
this.actionCreationDate = actionCreationDate;
7983
this.actionChangeDate = actionChangeDate;
@@ -122,6 +126,14 @@ public void setEventStatus(EventStatus eventStatus) {
122126
this.eventStatus = eventStatus;
123127
}
124128

129+
public EventInvestigationStatus getEventInvestigationStatus() {
130+
return eventInvestigationStatus;
131+
}
132+
133+
public void setEventInvestigationStatus(EventInvestigationStatus eventInvestigationStatus) {
134+
this.eventInvestigationStatus = eventInvestigationStatus;
135+
}
136+
125137
public String getActionTitle() {
126138
return actionTitle;
127139
}

sormas-api/src/main/java/de/symeda/sormas/api/event/EventCriteria.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,12 @@ public class EventCriteria extends BaseCriteria implements Serializable {
4141
public static final String SURVEILLANCE_OFFICER = "surveillanceOfficer";
4242
public static final String FREE_TEXT = "freeText";
4343
public static final String EVENT_STATUS = "eventStatus";
44+
public static final String EVENT_INVESTIGATION_STATUS = "eventInvestigationStatus";
4445
public static final String DISTRICT = "district";
4546
public static final String REGION = "region";
4647

4748
private EventStatus eventStatus;
49+
private EventInvestigationStatus eventInvestigationStatus;
4850
private Disease disease;
4951
private UserRole reportingUserRole;
5052
private Boolean deleted = Boolean.FALSE;
@@ -83,6 +85,19 @@ public void setEventStatus(EventStatus eventStatus) {
8385
this.eventStatus = eventStatus;
8486
}
8587

88+
public EventInvestigationStatus getEventInvestigationStatus() {
89+
return eventInvestigationStatus;
90+
}
91+
92+
public void setEventInvestigationStatus(EventInvestigationStatus eventInvestigationStatus) {
93+
this.eventInvestigationStatus = eventInvestigationStatus;
94+
}
95+
96+
public EventCriteria eventInvestigationStatus(EventInvestigationStatus eventInvestigationStatus) {
97+
this.eventInvestigationStatus = eventInvestigationStatus;
98+
return this;
99+
}
100+
86101
public Disease getDisease() {
87102
return disease;
88103
}

0 commit comments

Comments
 (0)