This repository has been archived by the owner on Sep 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix disabled test * Add assert to test case * Change visibility of constructors * github action: use commit SHA * VACCINECER-853: update libs * VACCINECER-853: update libs * Add cantonCodeSender validation * VACCINECER-955: validate canton * VACCINECER-890 create indexes * VACCINECER-890 create indexes only for postgres * Revert "VACCINECER-977: update pdf" This reverts commit 161006a * Validate address and city length * VACCINECER-977: update pdf * Feature/vaccinecer 950 import csv (#43) VACCINECER-950: added a rest controller for upload of csv * Update pom.xml updated version to 1.2.0 * VACCINECER-950: updated validation and added unit tests * VACCINECER-950: added content type log * VACCINECER-950: removed content type check * VACCINECER-950: fixed build * VACCINECER-950: updated the pdf file names to also include UVCI. * VACCINECER-684: updated countrie value sets * VACCINECER-684: updated Taiwan display name Co-authored-by: Yannik Inniger <[email protected]> Co-authored-by: Fabien Cerf <[email protected]> Co-authored-by: Yannik Inniger <[email protected]> Co-authored-by: Fabien Cerf <[email protected]> Co-authored-by: George Papadopoulos <[email protected]> Co-authored-by: Nicola Keller <[email protected]>
- Loading branch information
1 parent
6d7bbd8
commit 1cce0c9
Showing
54 changed files
with
10,794 additions
and
679 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
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
19 changes: 19 additions & 0 deletions
19
src/main/java/ch/admin/bag/covidcertificate/api/exception/CsvError.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,19 @@ | ||
package ch.admin.bag.covidcertificate.api.exception; | ||
|
||
import lombok.Getter; | ||
import lombok.ToString; | ||
|
||
@Getter | ||
@ToString | ||
public class CsvError extends CreateCertificateError { | ||
private final byte[] csv; | ||
|
||
public CsvError(CreateCertificateError createCertificateError, byte[] csv) { | ||
super( | ||
createCertificateError.getErrorCode(), | ||
createCertificateError.getErrorMessage(), | ||
createCertificateError.getHttpStatus() | ||
); | ||
this.csv = csv; | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/main/java/ch/admin/bag/covidcertificate/api/exception/CsvException.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,14 @@ | ||
package ch.admin.bag.covidcertificate.api.exception; | ||
|
||
import lombok.Getter; | ||
import org.springframework.core.NestedRuntimeException; | ||
|
||
@Getter | ||
public class CsvException extends NestedRuntimeException { | ||
private final CsvError error; | ||
|
||
public CsvException(CsvError error) { | ||
super(error.getErrorMessage()); | ||
this.error = error; | ||
} | ||
} |
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
106 changes: 106 additions & 0 deletions
106
src/main/java/ch/admin/bag/covidcertificate/api/request/CertificateCsvBean.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,106 @@ | ||
package ch.admin.bag.covidcertificate.api.request; | ||
|
||
import ch.admin.bag.covidcertificate.api.exception.CreateCertificateException; | ||
import com.opencsv.bean.CsvBindByName; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.ToString; | ||
|
||
import java.time.LocalDate; | ||
import java.util.List; | ||
|
||
import static ch.admin.bag.covidcertificate.api.Constants.INVALID_ADDRESS; | ||
import static ch.admin.bag.covidcertificate.api.Constants.INVALID_DATE_OF_BIRTH; | ||
|
||
@Getter | ||
@ToString | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public abstract class CertificateCsvBean { | ||
|
||
@CsvBindByName(column = "id") | ||
private String id; | ||
@CsvBindByName(column = "givenName") | ||
private String givenName; | ||
@CsvBindByName(column = "familyName") | ||
private String familyName; | ||
@CsvBindByName(column = "dateOfBirth") | ||
private String dateOfBirth; | ||
@CsvBindByName(column = "language") | ||
private String language; | ||
@CsvBindByName(column = "streetAndNr") | ||
private String streetAndNr; | ||
@CsvBindByName(column = "zipCode") | ||
private String zipCode; | ||
@CsvBindByName(column = "city") | ||
private String city; | ||
@CsvBindByName(column = "cantonCodeSender") | ||
private String cantonCodeSender; | ||
@CsvBindByName(column = "error") | ||
private String error; | ||
|
||
public abstract CertificateCreateDto mapToCreateDto(); | ||
|
||
public void setError(String error) { | ||
this.error = error; | ||
} | ||
|
||
protected VaccinationCertificateCreateDto mapToCreateDto(VaccinationCertificateDataDto dataDto) { | ||
return new VaccinationCertificateCreateDto( | ||
mapToPersonDto(), | ||
List.of(dataDto), | ||
getLanguage(), | ||
mapToAddressDto() | ||
); | ||
} | ||
|
||
protected TestCertificateCreateDto mapToCreateDto(TestCertificateDataDto dataDto) { | ||
return new TestCertificateCreateDto( | ||
mapToPersonDto(), | ||
List.of(dataDto), | ||
getLanguage(), | ||
mapToAddressDto() | ||
); | ||
} | ||
|
||
protected RecoveryCertificateCreateDto mapToCreateDto(RecoveryCertificateDataDto dataDto) { | ||
return new RecoveryCertificateCreateDto( | ||
mapToPersonDto(), | ||
List.of(dataDto), | ||
getLanguage(), | ||
mapToAddressDto() | ||
); | ||
} | ||
|
||
private CovidCertificatePersonDto mapToPersonDto() { | ||
LocalDate birthDate; | ||
try { | ||
birthDate = LocalDate.parse(getDateOfBirth()); | ||
} catch (Exception e) { | ||
throw new CreateCertificateException(INVALID_DATE_OF_BIRTH); | ||
} | ||
return new CovidCertificatePersonDto( | ||
new CovidCertificatePersonNameDto( | ||
getFamilyName(), | ||
getGivenName() | ||
), | ||
birthDate | ||
); | ||
} | ||
|
||
private CovidCertificateAddressDto mapToAddressDto() { | ||
int zipCode; | ||
try { | ||
zipCode = Integer.parseInt(this.zipCode); | ||
} catch (NumberFormatException e) { | ||
throw new CreateCertificateException(INVALID_ADDRESS); | ||
} | ||
return new CovidCertificateAddressDto( | ||
streetAndNr, | ||
zipCode, | ||
city, | ||
cantonCodeSender | ||
); | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
src/main/java/ch/admin/bag/covidcertificate/api/request/CertificateType.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,5 @@ | ||
package ch.admin.bag.covidcertificate.api.request; | ||
|
||
public enum CertificateType { | ||
recovery, test, vaccination | ||
} |
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
39 changes: 39 additions & 0 deletions
39
src/main/java/ch/admin/bag/covidcertificate/api/request/RecoveryCertificateCsvBean.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,39 @@ | ||
package ch.admin.bag.covidcertificate.api.request; | ||
|
||
import ch.admin.bag.covidcertificate.api.exception.CreateCertificateException; | ||
import com.opencsv.bean.CsvBindByName; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.ToString; | ||
|
||
import java.time.LocalDate; | ||
|
||
import static ch.admin.bag.covidcertificate.api.Constants.INVALID_DATE_OF_FIRST_POSITIVE_TEST_RESULT; | ||
|
||
@Getter | ||
@ToString | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class RecoveryCertificateCsvBean extends CertificateCsvBean { | ||
|
||
@CsvBindByName(column = "dateOfFirstPositiveTestResult") | ||
private String dateOfFirstPositiveTestResult; | ||
@CsvBindByName(column = "countryOfTest") | ||
private String countryOfTest; | ||
|
||
@Override | ||
public RecoveryCertificateCreateDto mapToCreateDto() { | ||
LocalDate dateOfFirstPositiveTestResult; | ||
try { | ||
dateOfFirstPositiveTestResult = LocalDate.parse(this.dateOfFirstPositiveTestResult); | ||
} catch (Exception e) { | ||
throw new CreateCertificateException(INVALID_DATE_OF_FIRST_POSITIVE_TEST_RESULT); | ||
} | ||
RecoveryCertificateDataDto dataDto = new RecoveryCertificateDataDto( | ||
dateOfFirstPositiveTestResult, | ||
countryOfTest | ||
); | ||
return super.mapToCreateDto(dataDto); | ||
} | ||
} |
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.