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

Commit d30f1f8

Browse files
Merge pull request SORMAS-Foundation#3122 from hzi-braunschweig/feature-2671-2672-2673-SurvnetGateway
SORMAS-Foundation#2671 SORMAS-Foundation#2672 SORMAS-Foundation#2673 Survnet Gateway
2 parents 4957090 + 0c57598 commit d30f1f8

16 files changed

Lines changed: 283 additions & 14 deletions

File tree

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,5 +106,7 @@ public interface ConfigFacade {
106106

107107
SormasToSormasConfig getSormasToSormasConfig();
108108

109+
String getSurvnetGatewayUrl();
110+
109111
String getAuthenticationProvider();
110112
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
import de.symeda.sormas.api.sample.PathogenTestFacade;
6161
import de.symeda.sormas.api.sample.SampleFacade;
6262
import de.symeda.sormas.api.sormastosormas.SormasToSormasFacade;
63+
import de.symeda.sormas.api.survnet.SurvnetGatewayFacade;
6364
import de.symeda.sormas.api.symptoms.SymptomsFacade;
6465
import de.symeda.sormas.api.task.TaskFacade;
6566
import de.symeda.sormas.api.therapy.PrescriptionFacade;
@@ -290,6 +291,10 @@ public static SormasToSormasFacade getSormasToSormasFacade() {
290291
return get().lookupEjbRemote(SormasToSormasFacade.class);
291292
}
292293

294+
public static SurvnetGatewayFacade getSurvnetGatewayFacade() {
295+
return get().lookupEjbRemote(SurvnetGatewayFacade.class);
296+
}
297+
293298
public static AreaFacade getAreaFacade() {
294299
return get().lookupEjbRemote(AreaFacade.class);
295300
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1368,6 +1368,8 @@ public interface Captions {
13681368
String statisticsSpecifySelection = "statisticsSpecifySelection";
13691369
String statisticsStatistics = "statisticsStatistics";
13701370
String statisticsVisualizationType = "statisticsVisualizationType";
1371+
String SurvnetGateway_send = "SurvnetGateway.send";
1372+
String SurvnetGateway_title = "SurvnetGateway.title";
13711373
String Symptoms = "Symptoms";
13721374
String Symptoms_abdominalPain = "Symptoms.abdominalPain";
13731375
String Symptoms_abnormalLungXrayFindings = "Symptoms.abnormalLungXrayFindings";

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -783,6 +783,9 @@ public interface Strings {
783783
String reportedBy = "reportedBy";
784784
String reportedOn = "reportedOn";
785785
String step = "step";
786+
String SurvnetGateway_notificationEntryNotSent = "SurvnetGateway.notificationEntryNotSent";
787+
String SurvnetGateway_notificationEntrySent = "SurvnetGateway.notificationEntrySent";
788+
String SurvnetGateway_notificationErrorSending = "SurvnetGateway.notificationErrorSending";
786789
String text = "text";
787790
String toCase = "toCase";
788791
String total = "total";
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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+
16+
package de.symeda.sormas.api.survnet;
17+
18+
import java.util.List;
19+
20+
import javax.ejb.Remote;
21+
22+
/**
23+
* Gateway to interact with the local SurvNet instance of the health department
24+
*/
25+
@Remote
26+
public interface SurvnetGatewayFacade {
27+
28+
boolean isFeatureEnabled();
29+
30+
/**
31+
* Requests the cases to be sent to SurvNet
32+
*
33+
* @param caseUuids
34+
* @return http response code of the gateway
35+
*/
36+
int sendCases(List<String> caseUuids);
37+
}

sormas-api/src/main/resources/captions.properties

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1906,3 +1906,7 @@ sormasToSormasSharedWith=Shared with
19061906
sormasToSormasSharedBy=By
19071907
sormasToSormasSharedDate=On
19081908
sormasToSormasSentFrom=Sent from
1909+
1910+
# Survnet Gateway
1911+
SurvnetGateway.title=SurvNet
1912+
SurvnetGateway.send=send to own SurvNet instance

sormas-api/src/main/resources/captions_de-DE.properties

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1906,3 +1906,7 @@ sormasToSormasSharedWith=Geteilt mit
19061906
sormasToSormasSharedBy=Von
19071907
sormasToSormasSharedDate=Am
19081908
sormasToSormasSentFrom=Gesendet von
1909+
1910+
# Survnet Gateway
1911+
SurvnetGateway.title=SurvNet
1912+
SurvnetGateway.send=an eigenes SurvNet senden

sormas-api/src/main/resources/strings.properties

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -842,3 +842,8 @@ warningNetworkDiagramTooManyContacts = There are %d contacts and it is possible
842842
confirmNetworkDiagramTooManyContacts = Do you really want to update the diagram?
843843

844844
headingContactTracingFirstContact = First contact with Contact Tracing
845+
846+
# Survnet Gateway
847+
SurvnetGateway.notificationEntrySent = Entry has been sent
848+
SurvnetGateway.notificationEntryNotSent = Entry could not be sent
849+
SurvnetGateway.notificationErrorSending = Error when sending entry

sormas-api/src/main/resources/strings_de-DE.properties

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -842,3 +842,8 @@ warningNetworkDiagramTooManyContacts = Es gibt %d Kontakte und es ist möglich,
842842
confirmNetworkDiagramTooManyContacts = Wollen Sie das Diagramm wirklich aktualisieren?
843843

844844
headingContactTracingFirstContact = Erster Kontakt mit Kontaktverfolgung
845+
846+
# Survnet Gateway
847+
SurvnetGateway.notificationEntrySent = Der Eintrag wurde gesendet
848+
SurvnetGateway.notificationEntryNotSent = Der Eintrag konnte nicht gesendet werden
849+
SurvnetGateway.notificationErrorSending = Fehler beim Senden des Eintrags

sormas-api/src/test/java/de/symeda/sormas/api/i18n/I18nConstantGenerator.java

Lines changed: 44 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
package de.symeda.sormas.api.i18n;
22

3-
import java.io.FileWriter;
3+
import java.io.FileNotFoundException;
44
import java.io.IOException;
55
import java.io.InputStream;
6+
import java.io.UncheckedIOException;
67
import java.io.Writer;
8+
import java.nio.charset.StandardCharsets;
79
import java.nio.file.Files;
810
import java.nio.file.Path;
911
import java.nio.file.Paths;
@@ -13,8 +15,11 @@
1315
import java.util.Enumeration;
1416
import java.util.List;
1517
import java.util.Properties;
18+
import java.util.Scanner;
1619
import java.util.TreeSet;
1720

21+
import org.apache.commons.lang3.StringUtils;
22+
1823
/**
1924
* Generates Constants out of the corresponding property files.
2025
*
@@ -73,8 +78,29 @@ public boolean isIgnoreChildren() {
7378

7479
private void generateI18nConstantClass() throws IOException {
7580

76-
Writer writer = new FileWriter(outputClassFilePath, false);
77-
writeI18nConstantClass(writer);
81+
Path path = Paths.get(outputClassFilePath);
82+
String sep = determineLineSeparator(path);
83+
84+
try (Writer writer = Files.newBufferedWriter(path, StandardCharsets.UTF_8)) {
85+
writeI18nConstantClass(writer, sep);
86+
}
87+
}
88+
89+
/**
90+
* Try to determine line separator from file
91+
*/
92+
private static String determineLineSeparator(Path path) {
93+
if (Files.exists(path)) {
94+
try (Scanner s = new Scanner(path.toFile())) {
95+
String sep = s.findWithinHorizon("\\R", 0);
96+
if (StringUtils.isNoneEmpty(sep)) {
97+
return sep;
98+
}
99+
} catch (FileNotFoundException e) {
100+
throw new UncheckedIOException(e);
101+
}
102+
}
103+
return System.lineSeparator();
78104
}
79105

80106
/**
@@ -87,7 +113,7 @@ private void generateI18nConstantClass() throws IOException {
87113
* Writes the java file into this {@code writer}.
88114
* @throws IOException
89115
*/
90-
void writeI18nConstantClass(Writer writer) throws IOException {
116+
void writeI18nConstantClass(Writer writer, String sep) throws IOException {
91117

92118
Properties properties = new Properties();
93119
InputStream inputStream = I18nProperties.class.getClassLoader().getResourceAsStream(propertiesFileName);
@@ -97,12 +123,18 @@ void writeI18nConstantClass(Writer writer) throws IOException {
97123

98124
Enumeration<?> e = properties.propertyNames();
99125

100-
writer.write("package de.symeda.sormas.api.i18n;\n\n");
101-
writer.write("import javax.annotation.Generated;\n\n");
102-
writer.write("@Generated(value = \"" + getClass().getCanonicalName() + "\")\n");
103-
writer.write("public interface " + outputClassName + " {\n\n");
104-
writer.write(
105-
"\t/*\n\t * Hint for SonarQube issues:\n\t * 1. java:S115: Violation of name convention for constants of this class is accepted: Close as false positive.\n\t */\n\n");
126+
writer.append("package de.symeda.sormas.api.i18n;").append(sep + sep);
127+
writer.append("import javax.annotation.Generated;").append(sep + sep);
128+
writer.append("@Generated(value = \"" + getClass().getCanonicalName() + "\")").append(sep);
129+
writer.append("public interface " + outputClassName + " {").append(sep + sep);
130+
writer.append("\t/*")
131+
.append(sep)
132+
.append("\t * Hint for SonarQube issues:")
133+
.append(sep)
134+
.append("\t * 1. java:S115: Violation of name convention for constants of this class is accepted: Close as false positive.")
135+
.append(sep)
136+
.append("\t */")
137+
.append(sep + sep);
106138

107139
Collection<String> orderedKeys = new TreeSet<String>(new Comparator<String>() {
108140

@@ -120,10 +152,10 @@ public int compare(String s1, String s2) {
120152

121153
for (String key : orderedKeys) {
122154
String constant = key.replaceAll("[\\.\\-]", "_");
123-
writer.write("\tString " + constant + " = \"" + key + "\";\n");
155+
writer.append("\tString " + constant + " = \"" + key + "\";").append(sep);
124156
}
125157

126-
writer.write("}\n");
158+
writer.append("}").append(sep);
127159
writer.flush();
128160
writer.close();
129161
}

0 commit comments

Comments
 (0)