Skip to content

Commit

Permalink
CDE-204 : Maj Spring
Browse files Browse the repository at this point in the history
Correction LigneKbartDto
Ajout debug dans producer
  • Loading branch information
pierre-maraval committed Sep 19, 2023
1 parent 4d1b8d3 commit 7cb9cf3
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 6 deletions.
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.0.5</version>
<version>3.1.3</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>fr.abes</groupId>
Expand Down Expand Up @@ -154,7 +154,7 @@
<dependency>
<groupId>com.opencsv</groupId>
<artifactId>opencsv</artifactId>
<version>5.7.1</version>
<version>5.8</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
Expand All @@ -177,7 +177,7 @@
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-xml</artifactId>
<version>2.13.2</version>
<version>2.15.2</version>
</dependency>

<!-- TEST -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ public ObjectMapper objectMapper() {
ObjectMapper objectMapper = builder.build();
objectMapper.registerModule(new JavaTimeModule());
return objectMapper;
// return JsonMapper.builder().addModule(new JavaTimeModule()).build();
}

@Bean
Expand Down
28 changes: 27 additions & 1 deletion src/main/java/fr/abes/bestppn/dto/kafka/LigneKbartDto.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package fr.abes.bestppn.dto.kafka;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.opencsv.bean.CsvBindByName;
import com.opencsv.bean.CsvBindByPosition;
import lombok.Data;
Expand All @@ -11,80 +12,105 @@
public class LigneKbartDto {
@CsvBindByName(column = "publication_title")
@CsvBindByPosition(position = 0)
@JsonProperty("publication_title")
private String publicationTitle;
@CsvBindByName(column = "print_identifier")
@CsvBindByPosition(position = 1)
@JsonProperty("print_identifier")
private String printIdentifier;
@CsvBindByName(column = "online_identifier")
@CsvBindByPosition(position = 2)
@JsonProperty("online_identifier")
private String onlineIdentifier;
@CsvBindByName(column = "date_first_issue_online")
@CsvBindByPosition(position = 3)
@JsonProperty("date_first_issue_online")
private String dateFirstIssueOnline;
@CsvBindByName(column = "num_first_vol_online")
@CsvBindByPosition(position = 4)
@JsonProperty("num_first_vol_online")
private Integer numFirstVolOnline;
@CsvBindByName(column = "num_first_issue_online")
@CsvBindByPosition(position = 5)
@JsonProperty("num_first_issue_online")
private Integer numFirstIssueOnline;
@CsvBindByName(column = "date_last_issue_online")
@CsvBindByPosition(position = 6)
@JsonProperty("date_last_issue_online")
private String dateLastIssueOnline;
@CsvBindByName(column = "num_last_vol_online")
@CsvBindByPosition(position = 7)
@JsonProperty("num_last_vol_online")
private Integer numLastVolOnline;
@CsvBindByName(column = "num_last_issue_online")
@CsvBindByPosition(position = 8)
@JsonProperty("num_last_issue_online")
private Integer numLastIssueOnline;
@CsvBindByName(column = "title_url")
@CsvBindByPosition(position = 9)
@JsonProperty("title_url")
private String titleUrl;
@CsvBindByName(column = "first_author")
@CsvBindByPosition(position = 10)
@JsonProperty("first_author")
private String firstAuthor;
@CsvBindByName(column = "title_id")
@CsvBindByPosition(position = 11)
@JsonProperty("title_id")
private String titleId;
@CsvBindByName(column = "embargo_info")
@CsvBindByPosition(position = 12)
@JsonProperty("embargo_info")
private String embargoInfo;
@CsvBindByName(column = "coverage_depth")
@CsvBindByPosition(position = 13)
@JsonProperty("coverage_depth")
private String coverageDepth;
@CsvBindByName(column = "notes")
@CsvBindByPosition(position = 14)
@JsonProperty("notes")
private String notes;
@CsvBindByName(column = "publisher_name")
@CsvBindByPosition(position = 15)
@JsonProperty("publisher_name")
private String publisherName;
@CsvBindByName(column = "publication_type")
@CsvBindByPosition(position = 16)
@JsonProperty("publication_type")
private String publicationType;
@CsvBindByName(column = "date_monograph_published_print")
@CsvBindByPosition(position = 17)
@JsonProperty("date_monograph_published_print")
private String dateMonographPublishedPrint;
@CsvBindByName(column = "date_monograph_published_online")
@CsvBindByPosition(position = 18)
@JsonProperty("date_monograph_published_online")
private String dateMonographPublishedOnline;
@CsvBindByName(column = "monograph_volume")
@CsvBindByPosition(position = 19)
@JsonProperty("monograph_volume")
private Integer monographVolume;
@CsvBindByName(column = "monograph_edition")
@CsvBindByPosition(position = 20)
@JsonProperty("monograph_edition")
private String monographEdition;
@CsvBindByName(column = "first_editor")
@CsvBindByPosition(position = 21)
@JsonProperty("first_editor")
private String firstEditor;
@CsvBindByName(column = "parent_publication_title_id")
@CsvBindByPosition(position = 22)
@JsonProperty("parent_publication_title_id")
private String parentPublicationTitleId;
@CsvBindByName(column = "preceding_publication_title_id")
@CsvBindByPosition(position = 23)
@JsonProperty("preceding_publication_title_id")
private String precedingPublicationTitleId;
@CsvBindByName(column = "access_type")
@CsvBindByPosition(position = 24)
@JsonProperty("access_type")
private String accessType;
@CsvBindByName(column = "access_type")
@CsvBindByName(column = "bestPpn")
@CsvBindByPosition(position = 25)
private String bestPpn;

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/fr/abes/bestppn/kafka/TopicConsumer.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public class TopicConsumer {
* Listener Kafka qui écoute un topic et récupère les messages dès qu'ils y arrivent.
* @param lignesKbart message kafka récupéré par le Consumer Kafka
*/
@KafkaListener(topics = {"${topic.name.source.kbart}"}, groupId = "lignesKbart", containerFactory = "kafkaKbartListenerContainerFactory")
@KafkaListener(topics = {"${topic.name.source.kbart}"}, groupId = "lignesKbartTest", containerFactory = "kafkaKbartListenerContainerFactory")
public void listenKbartFromKafka(ConsumerRecord<String, String> lignesKbart) {
try {
String filename = "";
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/fr/abes/bestppn/kafka/TopicProducer.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public void sendKbart(List<LigneKbartDto> kbart, Headers headers) throws JsonPro
}
setHeadersAndSend(headers, mapper.writeValueAsString(ligne), topicKbart);
}
log.debug("message envoyé vers {}", topicKbart);
}


Expand All @@ -55,13 +56,15 @@ public void sendPrintNotice(List<PpnKbartProviderDto> ppnKbartProviderDtoList, H
for (PpnKbartProviderDto ppnToCreate : ppnKbartProviderDtoList) {
setHeadersAndSend(headers, mapper.writeValueAsString(ppnToCreate), topicNoticeImprimee);
}
log.debug("message envoyé vers {}", topicNoticeImprimee);
}

@Transactional(transactionManager = "kafkaTransactionManager")
public void sendPpnExNihilo(List<LigneKbartDto> ppnFromKbartToCreate, Headers headers) throws JsonProcessingException {
for (LigneKbartDto ligne : ppnFromKbartToCreate) {
setHeadersAndSend(headers, mapper.writeValueAsString(ligne), topicKbartPpnToCreate);
}
log.debug("message envoyé vers {}", topicKbartPpnToCreate);
}

private void setHeadersAndSend(Headers headers, String value, String topic) {
Expand Down

0 comments on commit 7cb9cf3

Please sign in to comment.