Skip to content

Commit

Permalink
CDE-170 : Fix envoi des dates
Browse files Browse the repository at this point in the history
Envoi des dates dans Kafka en string au lieu de champ date, transfo effectuée par kafka connect avant l'insertion en base
déplacement url registry dans application-dev.properties
  • Loading branch information
pierre-maraval committed Sep 28, 2023
1 parent 6aa32dc commit 832d63d
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 65 deletions.
5 changes: 4 additions & 1 deletion src/main/java/fr/abes/bestppn/configuration/KafkaConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ public class KafkaConfig {
@Value("${spring.kafka.consumer.properties.isolation.level}")
private String isolationLevel;

@Value("${spring.kafka.registry.url}")
private String registryUrl;

@Bean
public ConsumerFactory<String, String> consumerKbartFactory() {
Map<String, Object> props = new HashMap<>();
Expand All @@ -58,7 +61,7 @@ public Map<String, Object> producerConfigs() {
props.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapAddress);
props.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class);
props.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, KafkaAvroSerializer.class);
props.put(AbstractKafkaAvroSerDeConfig.SCHEMA_REGISTRY_URL_CONFIG, "http://cafeier-dev.v212.abes.fr:8081/");
props.put(AbstractKafkaAvroSerDeConfig.SCHEMA_REGISTRY_URL_CONFIG, registryUrl);
return props;
}

Expand Down
70 changes: 35 additions & 35 deletions src/main/java/fr/abes/bestppn/dto/connect/LigneKbartConnect.java

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/main/java/fr/abes/bestppn/utils/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,17 +101,17 @@ public static LocalDate convertDateToLocalDate(Date dateToConvert) {
* @param debut : indique s'il s'agit d'une date de début : true : date de début, false : date de fin
* @return la date formattée
*/
public static LocalDate formatDate(String date, boolean debut) {
public static String formatDate(String date, boolean debut) {
if (date == null) return null;
String yearRegExp = "([\\d]{4})";
String dateRegExp = "\\d{4}-\\d{2}-\\d{2}";
int day = (debut) ? 1 : 31;
int month = (debut) ? Calendar.JANUARY : Calendar.DECEMBER;
if (date.matches(yearRegExp)) {
return new GregorianCalendar(Integer.parseInt(date), month, day).toZonedDateTime().toLocalDate();
return new GregorianCalendar(Integer.parseInt(date), month, day).toZonedDateTime().toLocalDate().toString();
}
if (date.matches(dateRegExp)) {
return LocalDate.parse(date);
return date;
}
return null;
}
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/application-dev.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Producer properties
spring.kafka.producer.bootstrap-servers=
spring.kafka.consumer.bootstrap-servers=
spring.kafka.registry.url=

url.onlineId2Ppn=
url.printId2Ppn=
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/application-prod.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Producer properties
spring.kafka.producer.bootstrap-servers=
spring.kafka.consumer.bootstrap-servers=
spring.kafka.registry.url=

url.onlineId2Ppn=
url.printId2Ppn=
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/application-test.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Producer properties
spring.kafka.producer.bootstrap-servers=
spring.kafka.consumer.bootstrap-servers=
spring.kafka.registry.url=

url.onlineId2Ppn=
url.printId2Ppn=
Expand Down
32 changes: 6 additions & 26 deletions src/main/resources/avro/ligne_kbart_convergence.avsc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"type": "record",
"name": "LigneKbartConnect",
"namespace": "fr.abes.bestppn",
"version": "7",
"version": "9",
"fields": [
{
"name": "PUBLICATION_TITLE",
Expand All @@ -18,12 +18,7 @@
},
{
"name": "DATE_FIRST_ISSUE_ONLINE",
"type":
["null",
{
"type": "int",
"logicalType": "date"
}]
"type": ["null", "string"]
},
{
"name": "NUM_FIRST_VOL_ONLINE",
Expand All @@ -35,12 +30,7 @@
},
{
"name": "DATE_LAST_ISSUE_ONLINE",
"type":
["null",
{
"type": "int",
"logicalType": "date"
}]
"type": ["null", "string"]
},
{
"name": "NUM_LAST_VOL_ONLINE",
Expand Down Expand Up @@ -84,21 +74,11 @@
},
{
"name": "DATE_MONOGRAPH_PUBLISHED_PRINT",
"type":
["null",
{
"type": "int",
"logicalType": "date"
}]
"type": ["null", "string"]
},
{
"name": "DATE_MONOGRAPH_PUBLISHED_ONLIN",
"type":
["null",
{
"type": "int",
"logicalType": "date"
}]
"type": ["null", "string"]
},
{
"name": "MONOGRAPH_VOLUME",
Expand Down Expand Up @@ -126,7 +106,7 @@
},
{
"name": "PROVIDER_PACKAGE_PACKAGE",
"type": ["null", "string"]
"type": "string"
},
{
"name": "PROVIDER_PACKAGE_DATE_P",
Expand Down

0 comments on commit 832d63d

Please sign in to comment.