Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CDE-465 : Ajout controle sur publication_type #132

Merged
merged 2 commits into from
Oct 24, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading