Skip to content

Commit

Permalink
Merge pull request #132 from abes-esr/develop
Browse files Browse the repository at this point in the history
CDE-465 : Ajout controle sur publication_type
  • Loading branch information
SamuelQuetin authored Oct 24, 2024
2 parents 87dbec8 + eab2fe7 commit 7871236
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 30 deletions.
10 changes: 8 additions & 2 deletions src/main/java/fr/abes/kbart2kafka/service/FileService.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import fr.abes.kbart2kafka.dto.LigneKbartDto;
import fr.abes.kbart2kafka.exception.IllegalDateException;
import fr.abes.kbart2kafka.exception.IllegalFileFormatException;
import fr.abes.kbart2kafka.utils.PUBLICATION_TYPE;
import fr.abes.kbart2kafka.utils.Utils;
import jakarta.annotation.PostConstruct;
import lombok.extern.slf4j.Slf4j;
Expand All @@ -13,6 +14,7 @@
import org.springframework.beans.factory.annotation.Value;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.stereotype.Service;
import org.yaml.snakeyaml.util.EnumUtils;

import java.io.BufferedReader;
import java.io.File;
Expand Down Expand Up @@ -72,8 +74,7 @@ private void executeMultiThread(File fichier) throws IllegalFileFormatException
try {
kbartsToSend.add(mapper.writeValueAsString(constructDto(tsvElementsOnOneLine, cpt.get(), nbLignesFichier)));
} catch (IllegalDateException | IllegalFileFormatException | JsonProcessingException e) {
log.debug("Erreur dans le fichier en entrée à la ligne " + cpt.get() + " : " + e.getMessage());
log.error(e.getMessage());
log.error("Erreur dans le fichier en entrée à la ligne " + cpt.get() + " : " + e.getMessage());
isOnError.set(true);
}
});
Expand Down Expand Up @@ -134,6 +135,11 @@ private LigneKbartDto constructDto(String[] line, Integer ligneCourante, Integer
kbartLineInDtoObject.setCoverage_depth(line[13]);
kbartLineInDtoObject.setNotes(line[14]);
kbartLineInDtoObject.setPublisher_name(line[15]);
try {
PUBLICATION_TYPE.valueOf(line[16]);
} catch (IllegalArgumentException ex) {
throw new IllegalFileFormatException("La valeur de PUBLICATION_TYPE est invalide");
}
kbartLineInDtoObject.setPublication_type(line[16]);
kbartLineInDtoObject.setDate_monograph_published_print(Utils.reformatDateKbart(line[17]));
kbartLineInDtoObject.setDate_monograph_published_online(Utils.reformatDateKbart(line[18]));
Expand Down
28 changes: 0 additions & 28 deletions src/test/java/fr/abes/kbart2kafka/service/FileServiceTest.java

This file was deleted.

0 comments on commit 7871236

Please sign in to comment.