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

Commit 05665a1

Browse files
SORMAS-Foundation#2672 SurvnetGatewayFacade that triggers rest interface of converter
1 parent 7a76e7d commit 05665a1

3 files changed

Lines changed: 114 additions & 0 deletions

File tree

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
}
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+
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
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.backend.survnet;
17+
18+
import java.util.List;
19+
import java.util.concurrent.TimeUnit;
20+
21+
import javax.ejb.EJB;
22+
import javax.ejb.Stateless;
23+
import javax.ws.rs.client.ClientBuilder;
24+
import javax.ws.rs.client.Entity;
25+
import javax.ws.rs.core.Response;
26+
27+
import org.apache.commons.lang3.StringUtils;
28+
29+
import de.symeda.sormas.api.survnet.SurvnetGatewayFacade;
30+
import de.symeda.sormas.backend.common.ConfigFacadeEjb.ConfigFacadeEjbLocal;
31+
32+
@Stateless(name = "SurvnetGatewayFacade")
33+
public class SurvnetGatewayFacadeEjb implements SurvnetGatewayFacade {
34+
35+
@EJB
36+
private ConfigFacadeEjbLocal configFacade;
37+
38+
@Override
39+
public boolean isFeatureEnabled() {
40+
return StringUtils.isNoneBlank(configFacade.getSurvnetGatewayUrl());
41+
}
42+
43+
@Override
44+
public int sendCases(List<String> caseUuids) {
45+
ExportParameters params = new ExportParameters();
46+
params.setCaseUuids(caseUuids);
47+
48+
String serviceUrl = configFacade.getSurvnetGatewayUrl().trim();
49+
50+
Response response = ClientBuilder.newBuilder()
51+
.connectTimeout(30, TimeUnit.SECONDS)
52+
.build()
53+
.target(serviceUrl)
54+
.path("export")
55+
.request()
56+
.post(Entity.json(params));
57+
return response.getStatus();
58+
}
59+
60+
public static class ExportParameters {
61+
62+
private List<String> caseUuids;
63+
64+
public List<String> getCaseUuids() {
65+
return caseUuids;
66+
}
67+
68+
public void setCaseUuids(List<String> caseUuids) {
69+
this.caseUuids = caseUuids;
70+
}
71+
}
72+
}

0 commit comments

Comments
 (0)