Skip to content

Commit

Permalink
Merge pull request #103 from DP-3T/feature/interops
Browse files Browse the repository at this point in the history
Feature/interops
  • Loading branch information
ubhaller authored Mar 10, 2021
2 parents 8a489a3 + 38aac87 commit aeed565
Show file tree
Hide file tree
Showing 24 changed files with 1,361 additions and 205 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ public abstract class WSBaseConfig implements SchedulingConfigurer, WebMvcConfig
protected final Logger logger = LoggerFactory.getLogger(getClass());
final SignatureAlgorithm algorithm = SignatureAlgorithm.ES256;

@Value("${ws.interops.countrycodes:}")
List<String> interOpsCountryCodes;

@Value("${ws.headers.protected:}")
List<String> protectedHeaders;

Expand All @@ -76,7 +79,7 @@ public void addResourceHandlers(ResourceHandlerRegistry registry) {

@Bean
public GaenConfigController gaenConfigController(Messages messages) {
return new GaenConfigController(messages);
return new GaenConfigController(messages, interOpsCountryCodes);
}

@Bean
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package org.dpppt.switzerland.backend.sdk.config.ws.config.mock;

import java.util.List;
import org.dpppt.switzerland.backend.sdk.config.ws.controller.GaenConfigController;
import org.dpppt.switzerland.backend.sdk.config.ws.model.ConfigResponse;
import org.dpppt.switzerland.backend.sdk.config.ws.poeditor.Messages;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
Expand All @@ -15,7 +17,9 @@
@Profile("mock-forceupdate")
public class MockForceUpdateConfig {


@Value("${ws.interops.countrycodes:}")
List<String> interOpsCountryCodes;

@Bean
@Primary
public GaenConfigController gaenConfigController(Messages messages) {
Expand All @@ -25,7 +29,7 @@ public GaenConfigController gaenConfigController(Messages messages) {
public class MockForceUpdateController extends GaenConfigController {

public MockForceUpdateController(Messages messages) {
super(messages);
super(messages, interOpsCountryCodes);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package org.dpppt.switzerland.backend.sdk.config.ws.config.mock;

import java.util.List;
import org.dpppt.switzerland.backend.sdk.config.ws.controller.GaenConfigController;
import org.dpppt.switzerland.backend.sdk.config.ws.helper.MockHelper;
import org.dpppt.switzerland.backend.sdk.config.ws.model.ConfigResponse;
import org.dpppt.switzerland.backend.sdk.config.ws.poeditor.Messages;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
Expand All @@ -16,6 +18,8 @@
@Profile("mock-infobox")
public class MockInfoBoxConfig {

@Value("${ws.interops.countrycodes:}")
List<String> interOpsCountryCodes;

@Bean
@Primary
Expand All @@ -26,7 +30,7 @@ public GaenConfigController gaenConfigController(Messages messages) {
public class MockInfoBoxController extends GaenConfigController {

public MockInfoBoxController(Messages messages) {
super(messages);
super(messages, interOpsCountryCodes);
}

@Override
Expand All @@ -40,7 +44,7 @@ public MockInfoBoxController(Messages messages) {
@Documentation(description = "Version of the OS", example = "ios13.6") String osversion,
@Documentation(description = "Build number of the app", example = "ios-200619.2333.175") String buildnr) {
ResponseEntity<ConfigResponse> response = super.getConfig(appversion, osversion, buildnr);
response.getBody().setInfoBox(MockHelper.mockConfigResponseWithInfoBox(true).getInfoBox());
response.getBody().setInfoBox(MockHelper.mockConfigResponseWithInfoBox(true, messages).getInfoBox());
return response;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@

package org.dpppt.switzerland.backend.sdk.config.ws.controller;

import ch.ubique.openapi.docannotations.Documentation;
import java.time.Duration;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;

import org.dpppt.switzerland.backend.sdk.config.ws.helper.IOS136InfoBoxHelper;
import org.dpppt.switzerland.backend.sdk.config.ws.helper.MockHelper;
import org.dpppt.switzerland.backend.sdk.config.ws.helper.TestLocationHelper;
Expand All @@ -37,8 +37,6 @@
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import ch.ubique.openapi.docannotations.Documentation;

/**
*
* @CrossOrigin(origins = { "https://editor.swagger.io" })
Expand Down Expand Up @@ -95,11 +93,14 @@ public class GaenConfigController {

private static final Logger logger = LoggerFactory.getLogger(GaenConfigController.class);

private final Messages messages;
protected final Messages messages;
private final List<String> interOpsCountryCodes;
private final TestLocationHelper testLocationHelper;

public GaenConfigController(Messages messages) {
public GaenConfigController(Messages messages,
List<String> interOpsCountryCodes) {
this.messages = messages;
this.interOpsCountryCodes = interOpsCountryCodes;
this.testLocationHelper = new TestLocationHelper(messages);
}

Expand All @@ -120,6 +121,7 @@ public GaenConfigController(Messages messages) {
@Documentation(description = "Version of the OS", example = "ios13.6") @RequestParam String osversion,
@Documentation(description = "Build number of the app", example = "ios-200619.2333.175") @RequestParam String buildnr) {
ConfigResponse config = new ConfigResponse();
config.setInterOpsCountries(interOpsCountryCodes);
config.setWhatToDoPositiveTestTexts(whatToDoPositiveTestTexts(messages));
config.setTestLocations(testLocationHelper.getTestLocations());

Expand Down Expand Up @@ -176,7 +178,7 @@ public GaenConfigController(Messages messages) {
@Documentation(description = "Version of the App installed", example = "ios-1.0.7") @RequestParam String appversion,
@Documentation(description = "Version of the OS", example = "ios13.6") @RequestParam String osversion,
@Documentation(description = "Build number of the app", example = "ios-200619.2333.175") @RequestParam String buildnr) {
ConfigResponse body = MockHelper.mockConfigResponseWithInfoBox(true);
ConfigResponse body = MockHelper.mockConfigResponseWithInfoBox(true, messages);
return ResponseEntity.ok(body);
}

Expand Down Expand Up @@ -441,15 +443,12 @@ private WhatToDoPositiveTestTexts getWhatToDoPositiveTestText(Messages messages,
setEnterCovidcodeBoxText(messages.getMessage("inform_detail_box_text", locale));
setEnterCovidcodeBoxButtonTitle(messages.getMessage("inform_detail_box_button", locale));

setInfoBox(null); // no infobox needed at the moment
setInfoBox(getWhatToDoPositiveTestTextInfoBox(messages, locale));

setFaqEntries(Arrays.asList(new FaqEntry() {
{
setTitle(messages.getMessage("inform_detail_faq1_title", locale));
setText(messages.getMessage("inform_detail_faq1_text", locale));
setLinkTitle(messages.getMessage("infoline_coronavirus_number", locale));
setLinkUrl(
"tel://" + messages.getMessage("infoline_coronavirus_number", locale).replace(" ", ""));
setIconAndroid("ic_verified_user");
setIconIos("ic-verified-user");
}
Expand All @@ -471,4 +470,16 @@ private WhatToDoPositiveTestTexts getWhatToDoPositiveTestText(Messages messages,
}
};
}

private InfoBox getWhatToDoPositiveTestTextInfoBox(Messages messages, Locale locale) {
InfoBox infoBox = new InfoBox();
infoBox.setTitle(
messages.getMessage("inform_detail_infobox1_title", locale));
infoBox.setMsg(messages.getMessage("inform_detail_infobox1_text", locale));
infoBox.setUrlTitle(messages.getMessage("infoline_coronavirus_number", locale));
infoBox.setUrl("tel:" + messages.getMessage("infoline_coronavirus_number", locale).replace(" ", ""));
infoBox.setIsDismissible(false);
infoBox.setHearingImpairedInfo(messages.getMessage("hearing_impaired_info", locale));
return infoBox;
}
}
Original file line number Diff line number Diff line change
@@ -1,105 +1,122 @@
package org.dpppt.switzerland.backend.sdk.config.ws.helper;

import java.util.Locale;
import org.dpppt.switzerland.backend.sdk.config.ws.model.ConfigResponse;
import org.dpppt.switzerland.backend.sdk.config.ws.model.InfoBox;
import org.dpppt.switzerland.backend.sdk.config.ws.model.InfoBoxCollection;
import org.dpppt.switzerland.backend.sdk.config.ws.model.SDKConfig;
import org.dpppt.switzerland.backend.sdk.config.ws.poeditor.Messages;

public class MockHelper {

public static ConfigResponse mockConfigResponseWithInfoBox(boolean dismissible) {
public static ConfigResponse mockConfigResponseWithInfoBox(boolean dismissible,
Messages messages) {
ConfigResponse configResponse = new ConfigResponse();

String hearingImpairedInfo = messages.getMessage("hearing_impaired_info", Locale.forLanguageTag("de"));

InfoBox infoBoxde = new InfoBox();
infoBoxde.setMsg("Hier steht ein Text. Das kann ein Hinweis sein. Je länger umso mehr Platz DE");
infoBoxde.setTitle("Hinweis DE");
infoBoxde.setUrlTitle("Und ein externer Link DE");
infoBoxde.setUrl("https://www.bag.admin.ch/bag/de/home.html");
infoBoxde.setIsDismissible(dismissible);
infoBoxde.setHearingImpairedInfo(hearingImpairedInfo + " DE");

InfoBox infoBoxfr = new InfoBox();
infoBoxfr.setMsg("Hier steht ein Text. Das kann ein Hinweis sein. Je länger umso mehr Platz FR");
infoBoxfr.setTitle("Hinweis FR");
infoBoxfr.setUrlTitle("Und ein externer Link FR");
infoBoxfr.setUrl("https://www.bag.admin.ch/bag/fr/home.html");
infoBoxfr.setIsDismissible(dismissible);
infoBoxfr.setHearingImpairedInfo(hearingImpairedInfo + " FR");

InfoBox infoBoxit = new InfoBox();
infoBoxit.setMsg("Hier steht ein Text. Das kann ein Hinweis sein. Je länger umso mehr Platz IT");
infoBoxit.setTitle("Hinweis IT");
infoBoxit.setUrlTitle("Und ein externer Link IT");
infoBoxit.setUrl("https://www.bag.admin.ch/bag/it/home.html");
infoBoxit.setIsDismissible(dismissible);
infoBoxit.setHearingImpairedInfo(hearingImpairedInfo + " IT");

InfoBox infoBoxen = new InfoBox();
infoBoxen.setMsg("Hier steht ein Text. Das kann ein Hinweis sein. Je länger umso mehr Platz EN");
infoBoxen.setTitle("Hinweis EN");
infoBoxen.setUrlTitle("Und ein externer Link EN");
infoBoxen.setUrl("https://www.bag.admin.ch/bag/en/home.html");
infoBoxen.setIsDismissible(dismissible);
infoBoxen.setHearingImpairedInfo(hearingImpairedInfo + " EN");

InfoBox infoBoxpt = new InfoBox();
infoBoxpt.setMsg("Hier steht ein Text. Das kann ein Hinweis sein. Je länger umso mehr Platz PT");
infoBoxpt.setTitle("Hinweis PT");
infoBoxpt.setUrlTitle("Und ein externer Link PT");
infoBoxpt.setUrl("https://www.bag.admin.ch/bag/pt/home.html");
infoBoxpt.setIsDismissible(dismissible);
infoBoxpt.setHearingImpairedInfo(hearingImpairedInfo + " PT");

InfoBox infoBoxes = new InfoBox();
infoBoxes.setMsg("Hier steht ein Text. Das kann ein Hinweis sein. Je länger umso mehr Platz ES");
infoBoxes.setTitle("Hinweis ES");
infoBoxes.setUrlTitle("Und ein externer Link ES");
infoBoxes.setUrl("https://www.bag.admin.ch/bag/en/home.html");
infoBoxes.setIsDismissible(dismissible);
infoBoxes.setHearingImpairedInfo(hearingImpairedInfo + " ES");

InfoBox infoBoxsq = new InfoBox();
infoBoxsq.setMsg("Hier steht ein Text. Das kann ein Hinweis sein. Je länger umso mehr Platz SQ");
infoBoxsq.setTitle("Hinweis SQ");
infoBoxsq.setUrlTitle("Und ein externer Link SQ");
infoBoxsq.setUrl("https://www.bag.admin.ch/bag/en/home.html");
infoBoxsq.setIsDismissible(dismissible);
infoBoxsq.setHearingImpairedInfo(hearingImpairedInfo + " SQ");

InfoBox infoBoxbs = new InfoBox();
infoBoxbs.setMsg("Hier steht ein Text. Das kann ein Hinweis sein. Je länger umso mehr Platz BS");
infoBoxbs.setTitle("Hinweis BS");
infoBoxbs.setUrlTitle("Und ein externer Link BS");
infoBoxbs.setUrl("https://www.bag.admin.ch/bag/en/home.html");
infoBoxbs.setIsDismissible(dismissible);
infoBoxbs.setHearingImpairedInfo(hearingImpairedInfo + " BS");

InfoBox infoBoxhr = new InfoBox();
infoBoxhr.setMsg("Hier steht ein Text. Das kann ein Hinweis sein. Je länger umso mehr Platz HR");
infoBoxhr.setTitle("Hinweis HR");
infoBoxhr.setUrlTitle("Und ein externer Link HR");
infoBoxhr.setUrl("https://www.bag.admin.ch/bag/en/home.html");
infoBoxhr.setIsDismissible(dismissible);
infoBoxhr.setHearingImpairedInfo(hearingImpairedInfo + " HR");

InfoBox infoBoxrm = new InfoBox();
infoBoxrm.setMsg("Hier steht ein Text. Das kann ein Hinweis sein. Je länger umso mehr Platz RM");
infoBoxrm.setTitle("Hinweis RM");
infoBoxrm.setUrlTitle("Und ein externer Link RM");
infoBoxrm.setUrl("https://www.bag.admin.ch/bag/en/home.html");
infoBoxrm.setIsDismissible(dismissible);
infoBoxrm.setHearingImpairedInfo(hearingImpairedInfo + " RM");

InfoBox infoBoxsr = new InfoBox();
infoBoxsr.setMsg("Hier steht ein Text. Das kann ein Hinweis sein. Je länger umso mehr Platz SR");
infoBoxsr.setTitle("Hinweis SR");
infoBoxsr.setUrlTitle("Und ein externer Link SR");
infoBoxsr.setUrl("https://www.bag.admin.ch/bag/en/home.html");
infoBoxsr.setIsDismissible(dismissible);
infoBoxsr.setHearingImpairedInfo(hearingImpairedInfo + " SR");

InfoBox Infoboxtr = new InfoBox();
Infoboxtr.setMsg("Hier steht ein Text. Das kann ein Hinweis sein. Je länger umso mehr Platz TR");
Infoboxtr.setTitle("Hinweis TR");
Infoboxtr.setUrlTitle("Und ein externer Link TR");
Infoboxtr.setUrl("https://www.bag.admin.ch/bag/en/home.html");
Infoboxtr.setIsDismissible(dismissible);
InfoBox infoBoxtr = new InfoBox();
infoBoxtr.setMsg("Hier steht ein Text. Das kann ein Hinweis sein. Je länger umso mehr Platz TR");
infoBoxtr.setTitle("Hinweis TR");
infoBoxtr.setUrlTitle("Und ein externer Link TR");
infoBoxtr.setUrl("https://www.bag.admin.ch/bag/en/home.html");
infoBoxtr.setIsDismissible(dismissible);
infoBoxtr.setHearingImpairedInfo(hearingImpairedInfo + " TR");

InfoBox infoBoxti = new InfoBox();
infoBoxti.setMsg("Hier steht ein Text. Das kann ein Hinweis sein. Je länger umso mehr Platz TI");
infoBoxti.setTitle("Hinweis TI");
infoBoxti.setUrlTitle("Und ein externer Link TI");
infoBoxti.setUrl("https://www.bag.admin.ch/bag/en/home.html");
infoBoxti.setIsDismissible(dismissible);
infoBoxti.setHearingImpairedInfo(hearingImpairedInfo + " TI");

InfoBoxCollection collection = new InfoBoxCollection();
collection.setDeInfoBox(infoBoxde);
Expand All @@ -113,7 +130,7 @@ public static ConfigResponse mockConfigResponseWithInfoBox(boolean dismissible)
collection.setBsInfoBox(infoBoxbs);
collection.setRmInfoBox(infoBoxrm);
collection.setSrInfoBox(infoBoxsr);
collection.setTrInfobox(Infoboxtr);
collection.setTrInfobox(infoBoxtr);
collection.setTiInfobox(infoBoxti);

configResponse.setInfoBox(collection);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@

package org.dpppt.switzerland.backend.sdk.config.ws.model;

import java.util.Map;
import java.util.ArrayList;
import java.util.List;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import ch.ubique.openapi.docannotations.Documentation;
Expand All @@ -36,6 +37,9 @@ public class ConfigResponse {
@Documentation(description = "GAEN epidemiological parameters for Android")
private GAENSDKConfig androidGaenSdkConfig = new GAENSDKConfig();

@Documentation(description = "list of ISO 3166-1 alpha-2 country codes describing the available interops countries")
private List<String> interOpsCountries = new ArrayList<>();

public boolean isForceUpdate() {
return forceUpdate;
}
Expand Down Expand Up @@ -84,4 +88,11 @@ public void setTestLocations(TestLocationCollection testLocations) {
this.testLocations = testLocations;
}

public List<String> getInterOpsCountries() {
return interOpsCountries;
}

public void setInterOpsCountries(List<String> interOpsCountries) {
this.interOpsCountries = interOpsCountries;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public class InfoBox {
private String urlTitle;
@Documentation(description = "If true, the user can dismiss the message", example = "true")
private boolean isDismissible = false;
@Documentation(description = "Text to display in hearing impaired pop up")
private String hearingImpairedInfo;

public String getInfoId() {
return Integer.toString(
Expand Down Expand Up @@ -78,4 +80,12 @@ public boolean getIsDismissible() {
public void setIsDismissible(boolean isDismissible) {
this.isDismissible = isDismissible;
}

public String getHearingImpairedInfo() {
return hearingImpairedInfo;
}

public void setHearingImpairedInfo(String hearingImpairedInfo) {
this.hearingImpairedInfo = hearingImpairedInfo;
}
}
Loading

0 comments on commit aeed565

Please sign in to comment.