Commits
Ole Hedegaard authored a16af5af695
29 29 | package dk.sundhedsdatastyrelsen.cbs.datacache; |
30 30 | |
31 31 | import com.fasterxml.jackson.databind.ObjectMapper; |
32 32 | import dk.sundhedsdatastyrelsen.cbs.dao.LabResultRecord; |
33 33 | import dk.sundhedsdatastyrelsen.cbs.dao.VaccinationRecord; |
34 34 | import dk.sundhedsdatastyrelsen.cbs.dao.impl.jdbc.LabResultRecordImpl; |
35 35 | import dk.sundhedsdatastyrelsen.cbs.dao.impl.jdbc.VaccinationRecordImpl; |
36 36 | import dk.sundhedsdatastyrelsen.cbs.dto.lab.LabResult; |
37 37 | import dk.sundhedsdatastyrelsen.cbs.dto.vaccination.Vaccination; |
38 38 | import dk.sundhedsdatastyrelsen.fluent.spring.jdbc.Mapper; |
39 - | import dk.vaccinationsregister.schemas._2021._04._01.Covid19VaccinationCardType; |
39 + | import dk.vaccinationsregister.schemas._2013._12._01.GetVaccinationPassportAsPDFResponseType; |
40 40 | import org.springframework.context.annotation.Bean; |
41 41 | import org.springframework.context.annotation.Configuration; |
42 42 | import org.springframework.lang.NonNull; |
43 43 | |
44 44 | import javax.sql.DataSource; |
45 45 | import java.io.IOException; |
46 46 | import java.io.Reader; |
47 47 | import java.util.function.Function; |
48 48 | import java.util.function.Supplier; |
49 49 | |
54 54 | public class DataCacheImplConfiguration { |
55 55 | |
56 56 | |
57 57 | |
58 58 | public ObjectMapper objectMapper() { |
59 59 | return new ObjectMapper().findAndRegisterModules(); |
60 60 | } |
61 61 | |
62 62 | |
63 63 | |
64 - | public Writer<VaccinationRecord<Vaccination, Covid19VaccinationCardType>> vaccinationWriter( |
64 + | public Writer<VaccinationRecord<Vaccination, GetVaccinationPassportAsPDFResponseType>> vaccinationWriter( |
65 65 | final DataSource dataSource, |
66 - | final Mapper<VaccinationRecordImpl<Vaccination, Covid19VaccinationCardType>> mapper) { |
66 + | final Mapper<VaccinationRecordImpl<Vaccination, GetVaccinationPassportAsPDFResponseType>> mapper) { |
67 67 | return writer(dataSource, mapper); |
68 68 | } |
69 69 | |
70 70 | |
71 71 | |
72 - | public Mapper<VaccinationRecordImpl<Vaccination, Covid19VaccinationCardType>> vaccinationMapper( |
73 - | final Supplier<VaccinationRecordImpl<Vaccination, Covid19VaccinationCardType>> constructor, |
72 + | public Mapper<VaccinationRecordImpl<Vaccination, GetVaccinationPassportAsPDFResponseType>> vaccinationMapper( |
73 + | final Supplier<VaccinationRecordImpl<Vaccination, GetVaccinationPassportAsPDFResponseType>> constructor, |
74 74 | final ObjectMapper mapper) { |
75 75 | return mapper( |
76 76 | VaccinationRecord.CATALOG_NAME, |
77 77 | VaccinationRecord.SCHEMA_NAME, |
78 78 | VaccinationRecord.TABLE_NAME, |
79 79 | constructor, |
80 80 | deserializer(mapper, Vaccination.class), |
81 81 | serializer(mapper), |
82 - | deserializer(mapper, Covid19VaccinationCardType.class), |
82 + | deserializer(mapper, GetVaccinationPassportAsPDFResponseType.class), |
83 83 | serializer(mapper)) |
84 84 | .build(); |
85 85 | } |
86 86 | |
87 87 | |
88 88 | |
89 - | public Writer<LabResultRecord<LabResult, Covid19VaccinationCardType>> labResultWriter( |
89 + | public Writer<LabResultRecord<LabResult, GetVaccinationPassportAsPDFResponseType>> labResultWriter( |
90 90 | final DataSource dataSource, |
91 - | final Mapper<LabResultRecordImpl<LabResult, Covid19VaccinationCardType>> mapper) { |
91 + | final Mapper<LabResultRecordImpl<LabResult, GetVaccinationPassportAsPDFResponseType>> mapper) { |
92 92 | return writer(dataSource, mapper); |
93 93 | } |
94 94 | |
95 95 | |
96 96 | |
97 - | public Mapper<LabResultRecordImpl<LabResult, Covid19VaccinationCardType>> labResultMapper( |
98 - | final Supplier<LabResultRecordImpl<LabResult, Covid19VaccinationCardType>> constructor, |
97 + | public Mapper<LabResultRecordImpl<LabResult, GetVaccinationPassportAsPDFResponseType>> labResultMapper( |
98 + | final Supplier<LabResultRecordImpl<LabResult, GetVaccinationPassportAsPDFResponseType>> constructor, |
99 99 | final ObjectMapper mapper) { |
100 100 | return mapper( |
101 101 | LabResultRecord.CATALOG_NAME, |
102 102 | LabResultRecord.SCHEMA_NAME, |
103 103 | LabResultRecord.TABLE_NAME, |
104 104 | constructor, |
105 105 | deserializer(mapper, LabResult.class), |
106 106 | serializer(mapper), |
107 - | deserializer(mapper, Covid19VaccinationCardType.class), |
107 + | deserializer(mapper, GetVaccinationPassportAsPDFResponseType.class), |
108 108 | serializer(mapper)) |
109 109 | .build(); |
110 110 | } |
111 111 | |
112 112 | |
113 113 | |
114 - | public Supplier<VaccinationRecordImpl<Vaccination, Covid19VaccinationCardType>> vaccinationConstructor() { |
114 + | public Supplier<VaccinationRecordImpl<Vaccination, GetVaccinationPassportAsPDFResponseType>> vaccinationConstructor() { |
115 115 | return VaccinationRecordImpl::new; |
116 116 | } |
117 117 | |
118 118 | |
119 119 | |
120 - | public Supplier<LabResultRecordImpl<LabResult, Covid19VaccinationCardType>> labResultConstructor() { |
120 + | public Supplier<LabResultRecordImpl<LabResult, GetVaccinationPassportAsPDFResponseType>> labResultConstructor() { |
121 121 | return LabResultRecordImpl::new; |
122 122 | } |
123 123 | |
124 124 | private static <T> Function<Reader, T> deserializer( final ObjectMapper mapper, final Class<T> clazz) { |
125 125 | return reader -> { |
126 126 | try { |
127 127 | return mapper.readValue(reader, clazz); |
128 128 | } catch (IOException e) { |
129 129 | throw new RuntimeException(e); |
130 130 | } |