-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(vaccination info): Apps connected to EPS can submit a vaccinatio…
…n information lists via the JSON-RPC method `submitVaccinationInfoList`. The information is saved and made available to health department staff via the front end. Refs iris-connect/iris-backlog#274
- Loading branch information
1 parent
412e145
commit 6fa4277
Showing
33 changed files
with
1,188 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
iris-client-bff/src/main/java/iris/client_bff/core/mail/EmailSender.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...va/iris/client_bff/core/EmailAddress.java → ...s/client_bff/core/model/EmailAddress.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
iris-client-bff/src/main/java/iris/client_bff/core/model/FlexibleEnum.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package iris.client_bff.core.model; | ||
|
||
import static org.apache.commons.lang3.StringUtils.*; | ||
|
||
/** | ||
* @author Jens Kutzsche | ||
*/ | ||
public interface FlexibleEnum { | ||
|
||
static String cleanStringForEnum(String string) { | ||
|
||
var cleanString = replaceChars(string, '-', '_'); | ||
cleanString = camelToSnake(cleanString); | ||
|
||
return cleanString.toUpperCase(); | ||
} | ||
|
||
static String camelToSnake(String str) { | ||
return str.replaceAll("([a-z])([A-Z]+)", "$1_$2").toLowerCase(); | ||
} | ||
} |
66 changes: 66 additions & 0 deletions
66
iris-client-bff/src/main/java/iris/client_bff/core/model/PhoneNumber.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package iris.client_bff.core.model; | ||
|
||
import lombok.AccessLevel; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.NoArgsConstructor; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
import java.util.regex.Pattern; | ||
|
||
import javax.persistence.Column; | ||
import javax.persistence.Embeddable; | ||
|
||
import org.springframework.lang.Nullable; | ||
import org.springframework.util.Assert; | ||
import org.springframework.util.StringUtils; | ||
|
||
/** | ||
* @author Oliver Drotbohm | ||
*/ | ||
@Embeddable | ||
@EqualsAndHashCode | ||
@RequiredArgsConstructor(access = AccessLevel.PRIVATE) | ||
@NoArgsConstructor(force = true, access = AccessLevel.PRIVATE) | ||
public class PhoneNumber { | ||
|
||
private static final String REMOVABLE_CHARACTERS_REGEX = "\\(\\)\\s\\-"; | ||
private static final String REMOVABLE_CHARACTERS_SET = "[" + REMOVABLE_CHARACTERS_REGEX + "]"; | ||
public static final String PATTERN = "^[\\+\\(\\)\\s\\-0-9]*?$"; | ||
private static final Pattern REGEX = Pattern.compile(PATTERN); | ||
|
||
private final @Column(name = "phoneNumber") String value; | ||
|
||
public static PhoneNumber of(String number) { | ||
|
||
Assert.hasText(number, "Phone number must not be null or empty!"); | ||
|
||
if (!isValid(number)) { | ||
throw new IllegalArgumentException(String.format("%s is not a valid phone number!", number)); | ||
} | ||
|
||
return new PhoneNumber(number.replaceAll("\\s", "") | ||
.replace("(0)", "") | ||
.replaceAll(REMOVABLE_CHARACTERS_SET, "") | ||
.replace("+", "00") | ||
.replaceAll("^0049", "0")); | ||
} | ||
|
||
@Nullable | ||
@SuppressWarnings("null") | ||
public static PhoneNumber ofNullable(@Nullable String number) { | ||
return StringUtils.hasText(number) ? of(number) : null; | ||
} | ||
|
||
public static boolean isValid(@Nullable String candidate) { | ||
return StringUtils.hasText(candidate) && REGEX.matcher(candidate).matches(); | ||
} | ||
|
||
/* | ||
* (non-Javadoc) | ||
* @see java.lang.Object#toString() | ||
*/ | ||
@Override | ||
public String toString() { | ||
return value; | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
iris-client-bff/src/main/java/iris/client_bff/core/validation/PhoneNumber.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package iris.client_bff.core.validation; | ||
|
||
import static java.lang.annotation.ElementType.*; | ||
import static java.lang.annotation.RetentionPolicy.*; | ||
|
||
import iris.client_bff.core.validation.PhoneNumber.PhoneNumberValidator; | ||
|
||
import java.lang.annotation.Documented; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.Target; | ||
|
||
import javax.validation.Constraint; | ||
import javax.validation.ConstraintValidator; | ||
import javax.validation.ConstraintValidatorContext; | ||
import javax.validation.Payload; | ||
|
||
import com.google.i18n.phonenumbers.NumberParseException; | ||
import com.google.i18n.phonenumbers.PhoneNumberUtil; | ||
|
||
@Target({ METHOD, FIELD, ANNOTATION_TYPE }) | ||
@Retention(RUNTIME) | ||
@Constraint(validatedBy = PhoneNumberValidator.class) | ||
@Documented | ||
public @interface PhoneNumber { | ||
|
||
String message() default "{iris.validation.constraints.PhoneNumber.message}"; | ||
|
||
Class<?>[] groups() default {}; | ||
|
||
Class<? extends Payload>[] payload() default {}; | ||
|
||
public static class PhoneNumberValidator implements ConstraintValidator<PhoneNumber, String> { | ||
|
||
private PhoneNumberUtil util = PhoneNumberUtil.getInstance(); | ||
|
||
@Override | ||
public boolean isValid(final String text, final ConstraintValidatorContext context) { | ||
|
||
if (text == null) { | ||
return true; | ||
} | ||
|
||
try { | ||
|
||
var number = util.parse(text, "DE"); | ||
return util.isValidNumber(number); | ||
|
||
} catch (NumberParseException e) { | ||
return false; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.