Skip to content

Commit

Permalink
Merge branch 'development' of https://github.com/hzi-braunschweig/SOR…
Browse files Browse the repository at this point in the history
…MAS-Project into development

� Conflicts:
�	sormas-backend/src/main/java/de/symeda/sormas/backend/externalmessage/ExternalMessageFacadeEjb.java
�	sormas-backend/src/main/java/de/symeda/sormas/backend/externalmessage/labmessage/TestReportFacadeEjb.java
�	sormas-backend/src/test/java/de/symeda/sormas/backend/externalmessage/ExternalMessageFacadeEjbMappingTest.java
  • Loading branch information
razvancornita committed Oct 10, 2022
2 parents df25e25 + 4f461c7 commit 36f89b9
Show file tree
Hide file tree
Showing 477 changed files with 7,357 additions and 2,442 deletions.
3 changes: 3 additions & 0 deletions docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ If you're interested in participating in the development of SORMAS, please follo
If you have problems setting up your development environment or need assistance in choosing the first issue to work on, please get in touch with us by joining our [Gitter channel](https://gitter.im/SORMAS-Project) or contacting us at [email protected].
Additionally, our [Wiki](https://github.com/hzi-braunschweig/SORMAS-Project/wiki) contains some specific development guides that cover common issues like adding new fields to an entity that we suggest to check out before you start implementing something related to those topics.

* [Technical User Guides](https://github.com/hzi-braunschweig/SORMAS-Project/wiki#technical-user-guides)
* [Development Guides](https://github.com/hzi-braunschweig/SORMAS-Project/wiki#development-guides)

### Development Contributing Guidelines

In addition to the guidelines covered in the Development Environment Setup Instructions, please ensure to adhere to the following principles and procedures while developing code for SORMAS:
Expand Down
16 changes: 15 additions & 1 deletion docs/TROUBLESHOOTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,25 @@ Performance logging can be used to find out which part of the code or system mig
Performance logs can be analyzed in detail using the `PerformanceLogAnalysisGenerator`. To use this tool, set the `PerformanceLoggingInterceptor`'s log level
to `TRACE` as described above and reproduce the scenario you want to investigate on the server instance.

After this, process the debug log file (default path: `/opt/domains/sormas/logs/application.debug`) using the `PerformanceLogAnalysisGenerator`. This will
After this, process the debug log file (default path: `/opt/domains/sormas/logs/application.debug`) using the `PerformanceLogAnalysisGenerator`.
The log file's path is specified as the program argument when calling `PerformanceLogAnalysisGenerator`'s `main` method. Processing the log file will
generate three files (`<logfileName>.csv`, `<logfileName>.txt`, `<logfileName>.html`) to further investigate method runtimes.

`<logfileName>.html` provides a navigable overview of methods along with runtime statistics (total, min, max and average time) and calls to sub methods.

Sometimes it is convenient to analyze a number of different scenarios in a row. To do so, produce snippets of the `application.debug` log using `tail` for each
of the scenarios to be investigated:

1. start `tail -f <logfileName> > <snippetDirectory>/<snippet.debug>`

2. replay the steps to be analyzed

3. stop `tail -f`

The `PerformanceLogAnalysisGenerator` can now batch process all of the snippets by pointing to the directory instead of a log file.
Calling `PerformanceLogAnalysisGenerator.main` with argument `<snippetDirectory>` generates the analysis files (`.csv`, `.txt`, `.html`)
for each file `*.debug` in this directory. The generated files will be placed in `<snippetDirectory>`, too.

### Log Slow SQL Queries in PostgreSQL

You can enable the logging of slow SQL queries in your PostgreSQL server in `postgresql.conf`:
Expand Down
4 changes: 4 additions & 0 deletions sormas-api/src/main/java/de/symeda/sormas/api/EntityDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;

import de.symeda.sormas.api.audit.AuditInclude;
import de.symeda.sormas.api.audit.AuditedClass;
import de.symeda.sormas.api.i18n.Validations;
import de.symeda.sormas.api.utils.FieldConstraints;
import de.symeda.sormas.api.utils.Outbreaks;
Expand All @@ -39,6 +41,7 @@
* will reduce data transferred to something between 20% and 50% -
* especially for fields that are not needed for all diseases
*/
@AuditedClass
@JsonInclude(JsonInclude.Include.NON_NULL)
public abstract class EntityDto implements Serializable, Cloneable, HasUuid {

Expand All @@ -54,6 +57,7 @@ public abstract class EntityDto implements Serializable, Cloneable, HasUuid {
@Outbreaks
@Pattern(regexp = UUID_REGEX, message = Validations.uuidPatternNotMatching)
@Size(min = FieldConstraints.CHARACTER_LIMIT_UUID_MIN, max = FieldConstraints.CHARACTER_LIMIT_UUID_MAX, message = Validations.textSizeNotInRange)
@AuditInclude
private String uuid;

protected EntityDto() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,20 @@

import org.apache.commons.lang3.ObjectUtils;

import de.symeda.sormas.api.audit.AuditInclude;
import de.symeda.sormas.api.audit.AuditedClass;
import de.symeda.sormas.api.i18n.Validations;
import de.symeda.sormas.api.utils.Required;
import de.symeda.sormas.api.uuid.HasUuid;

@AuditedClass
public abstract class ReferenceDto implements Serializable, HasUuid, Comparable<ReferenceDto> {

public static final String CAPTION = "caption";
public static final String NO_REFERENCE_UUID = "SORMAS-CONSTID-NO-REFERENCE";

@Required
@AuditInclude
@Pattern(regexp = UUID_REGEX, message = Validations.uuidPatternNotMatching)
private String uuid;
private String caption;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package de.symeda.sormas.api.audit;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
* This annotation is used to mark fields (in DTOs or certain important classes referenced by DTO fields) which should
* be included in the audit log. It can be applied to fields and, if need be, to methods returning a specifically
* crafted audit representation. The audit logger will pick up the field if the containing class is annotated
* with {@link AuditedClass}.
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({
ElementType.FIELD,
ElementType.METHOD })
public @interface AuditInclude {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package de.symeda.sormas.api.audit;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
* This annotation is used to mark DTO as auditable. This annotation being present causes the log line to contain at
* least the class name. If more information is required, the fields to be included in the log line can be marked with
* {@link AuditInclude}.
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface AuditedClass {
}
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,7 @@ public class CaseDataDto extends SormasToSormasShareableDto {
private YesNoUnknown postpartum;
private Trimester trimester;
private FollowUpStatus followUpStatus;
@SensitiveData
@Size(max = CHARACTER_LIMIT_BIG, message = Validations.textTooLong)
private String followUpComment;
private Date followUpUntil;
Expand Down Expand Up @@ -574,6 +575,7 @@ public class CaseDataDto extends SormasToSormasShareableDto {
private boolean notACaseReasonOther;

@HideForCountriesExcept
@SensitiveData
@Size(max = FieldConstraints.CHARACTER_LIMIT_TEXT, message = Validations.textTooLong)
private String notACaseReasonDetails;
private Date followUpStatusChangeDate;
Expand All @@ -592,6 +594,7 @@ public class CaseDataDto extends SormasToSormasShareableDto {
private Map<String, String> externalData;
private boolean deleted;
private DeletionReason deletionReason;
@SensitiveData
@Size(max = FieldConstraints.CHARACTER_LIMIT_TEXT, message = Validations.textTooLong)
private String otherDeletionReason;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,36 @@ public CaseIndexDetailedDto(long id, String uuid, String epidNumber, String exte
this.responsibleCommunity = responsibleCommunity;
}

public CaseIndexDetailedDto(
long id, String uuid, String epidNumber, String externalID, String externalToken, String internalToken,
String personUuid, String personFirstName, String personLastName,
Disease disease, DiseaseVariant diseaseVariant, String diseaseDetails,
CaseClassification caseClassification, InvestigationStatus investigationStatus, PresentCondition presentCondition,
Date reportDate, Date creationDate,
String regionUuid, String districtUuid,
String healthFacilityUuid, String healthFacilityName, String healthFacilityDetails,
String pointOfEntryUuid, String pointOfEntryName, String pointOfEntryDetails, String surveillanceOfficerUuid,
CaseOutcome outcome, Integer age, ApproximateAgeType ageType, Integer birthdateDD, Integer birthdateMM, Integer birthdateYYYY,
Sex sex, Date quarantineTo, Float completeness, FollowUpStatus followUpStatus, Date followUpUntil,
SymptomJournalStatus symptomJournalStatus, VaccinationStatus vaccinationStatus, Date changeDate, Long facilityId,
String responsibleRegionUuid, String responsibleDistrictUuid, String responsibleDistrictName, boolean isInJurisdiction,
//detailed fields
YesNoUnknown reInfection, String city, String street, String houseNumber, String additionalInformation,
String postalCode, String phone, String reportingUserUuid, String reportingUserFirstName, String reportingUserLastName,
Date symptomOnsetDate, String responsibleRegion, String responsibleCommunity, int visitCount,
Date latestSampleDateTime, long sampleCount, Date latestChangedDate) {
this(id, uuid, epidNumber, externalID, externalToken, internalToken, personUuid, personFirstName, personLastName,
disease, diseaseVariant, diseaseDetails, caseClassification, investigationStatus, presentCondition,
reportDate, creationDate, regionUuid, districtUuid, healthFacilityUuid, healthFacilityName,
healthFacilityDetails, pointOfEntryUuid, pointOfEntryName, pointOfEntryDetails, surveillanceOfficerUuid,
outcome, age, ageType, birthdateDD, birthdateMM, birthdateYYYY, sex, quarantineTo, completeness,
followUpStatus, followUpUntil, symptomJournalStatus, vaccinationStatus, changeDate, facilityId,
responsibleRegionUuid, responsibleDistrictUuid, responsibleDistrictName, isInJurisdiction, reInfection,
city, street, houseNumber, additionalInformation, postalCode, phone, reportingUserUuid,
reportingUserFirstName, reportingUserLastName, symptomOnsetDate, responsibleRegion, responsibleCommunity,
visitCount, 0, latestSampleDateTime, sampleCount, latestChangedDate);
}

public YesNoUnknown getReInfection() {
return reInfection;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package de.symeda.sormas.api.caze;

import java.util.Collection;
import java.util.Date;

import de.symeda.sormas.api.utils.IgnoreForUrl;
Expand All @@ -11,6 +12,7 @@ public class CaseSimilarityCriteria extends BaseCriteria implements Cloneable {

private CaseCriteria caseCriteria;
private String personUuid;
private Collection<String> personUuids;
private Date reportDate;

@Override
Expand Down Expand Up @@ -54,8 +56,24 @@ public CaseSimilarityCriteria caseCriteria(CaseCriteria caseCriteria) {
}

public static CaseSimilarityCriteria forCase(CaseDataDto caze, String personUuid) {
CaseCriteria caseCriteria = new CaseCriteria().disease(caze.getDisease()).region(CaseLogic.getRegionWithFallback(caze));
return new CaseSimilarityCriteria().personUuid(personUuid).caseCriteria(buildCaseCriteria(caze)).reportDate(caze.getReportDate());
}

public static CaseSimilarityCriteria forCase(CaseDataDto caze, Collection<String> personUuids) {
return new CaseSimilarityCriteria().personUuids(personUuids).caseCriteria(buildCaseCriteria(caze)).reportDate(caze.getReportDate());
}

private static CaseCriteria buildCaseCriteria(CaseDataDto caze) {
return new CaseCriteria().disease(caze.getDisease()).region(CaseLogic.getRegionWithFallback(caze));
}

public CaseSimilarityCriteria personUuids(Collection<String> personUuids) {
this.personUuids = personUuids;

return this;
}

return new CaseSimilarityCriteria().personUuid(personUuid).caseCriteria(caseCriteria).reportDate(caze.getReportDate());
public Collection<String> getPersonUuids() {
return personUuids;
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package de.symeda.sormas.api.contact;

import java.util.Date;
import java.util.List;

import de.symeda.sormas.api.Disease;
import de.symeda.sormas.api.caze.CaseReferenceDto;
import de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto;
import de.symeda.sormas.api.person.PersonReferenceDto;
import de.symeda.sormas.api.utils.criteria.BaseCriteria;

Expand All @@ -12,14 +14,17 @@ public class ContactSimilarityCriteria extends BaseCriteria implements Cloneable
private static final long serialVersionUID = 6902101244020083789L;

private PersonReferenceDto person;
private List<PersonReferenceDto> persons;
private CaseReferenceDto caze;
private List<CaseReferenceDto> resultingCases;
private Disease disease;
private Date lastContactDate;
private Date reportDate;
private Date relevantDate;
private ContactClassification contactClassification;
private Boolean excludePseudonymized;
private Boolean noResultingCase;
private DistrictReferenceDto district;

public ContactSimilarityCriteria() {

Expand Down Expand Up @@ -47,6 +52,15 @@ public ContactSimilarityCriteria withPerson(PersonReferenceDto person) {
return this;
}

public List<PersonReferenceDto> getPersons() {
return persons;
}

public ContactSimilarityCriteria withPersons(List<PersonReferenceDto> persons) {
this.persons = persons;
return this;
}

public CaseReferenceDto getCaze() {
return caze;
}
Expand All @@ -60,6 +74,16 @@ public ContactSimilarityCriteria withCaze(CaseReferenceDto caze) {
return this;
}

public List<CaseReferenceDto> getResultingCases() {
return resultingCases;
}

public ContactSimilarityCriteria withResultingCases(List<CaseReferenceDto> resultingCases) {
this.resultingCases = resultingCases;

return this;
}

public Disease getDisease() {
return disease;
}
Expand Down Expand Up @@ -135,4 +159,14 @@ public ContactSimilarityCriteria withNoResultingCase(Boolean noResultingCase) {
this.noResultingCase = noResultingCase;
return this;
}

public DistrictReferenceDto getDistrict() {
return district;
}

public ContactSimilarityCriteria withDistrict(DistrictReferenceDto district) {
this.district = district;

return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.io.Serializable;
import java.util.Date;

import de.symeda.sormas.api.audit.AuditInclude;
import de.symeda.sormas.api.caze.CaseReferenceDto;
import de.symeda.sormas.api.sample.SampleReferenceDto;
import de.symeda.sormas.api.user.UserReferenceDto;
Expand All @@ -19,7 +20,7 @@ public class ExternalMessageCriteria extends BaseCriteria implements Serializabl
public static final String BIRTH_DATE_TO = "birthDateTo";
public static final String ASSIGNEE = "assignee";
public static final String TYPE = "type";

@AuditInclude
private String uuid;
private ExternalMessageType type;
private ExternalMessageStatus externalMessageStatus;
Expand Down
Loading

0 comments on commit 36f89b9

Please sign in to comment.