From 5ce70d21f1d364d9574704b51a27054d70b068eb Mon Sep 17 00:00:00 2001 From: SamuelQuetin Date: Tue, 19 Dec 2023 11:31:19 +0100 Subject: [PATCH] modif objet logkbart ajout nb line + order by --- src/main/java/fr/abes/logskbart/dto/LigneLogDto.java | 1 + src/main/java/fr/abes/logskbart/dto/LogKbartDto.java | 1 + src/main/java/fr/abes/logskbart/entity/LogKbart.java | 5 +++++ src/main/java/fr/abes/logskbart/kafka/LogsListener.java | 5 +++-- .../fr/abes/logskbart/repository/LogKbartRepository.java | 2 +- src/main/java/fr/abes/logskbart/service/LogsService.java | 2 +- src/main/java/fr/abes/logskbart/utils/LogsMapper.java | 2 ++ 7 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/main/java/fr/abes/logskbart/dto/LigneLogDto.java b/src/main/java/fr/abes/logskbart/dto/LigneLogDto.java index 67da42b..e9eabd6 100644 --- a/src/main/java/fr/abes/logskbart/dto/LigneLogDto.java +++ b/src/main/java/fr/abes/logskbart/dto/LigneLogDto.java @@ -8,4 +8,5 @@ public class LigneLogDto { private String level; private String message; + private Integer nbLine; } diff --git a/src/main/java/fr/abes/logskbart/dto/LogKbartDto.java b/src/main/java/fr/abes/logskbart/dto/LogKbartDto.java index 44b3c57..a109df0 100644 --- a/src/main/java/fr/abes/logskbart/dto/LogKbartDto.java +++ b/src/main/java/fr/abes/logskbart/dto/LogKbartDto.java @@ -17,6 +17,7 @@ public class LogKbartDto { private String loggerFqcn; private Integer threadId; private Integer threadPriority; + private Integer nbLine; @Getter @Setter private static class InstantDto { diff --git a/src/main/java/fr/abes/logskbart/entity/LogKbart.java b/src/main/java/fr/abes/logskbart/entity/LogKbart.java index bdbb780..60e8cd0 100644 --- a/src/main/java/fr/abes/logskbart/entity/LogKbart.java +++ b/src/main/java/fr/abes/logskbart/entity/LogKbart.java @@ -53,6 +53,9 @@ public class LogKbart implements Serializable { @Column(name = "THREAD_PRIORITY") private Integer threadPriority; + @Column(name = "NB_LINE") + private Integer nbLine; + @Override public String toString() { return "LogKbart{" + @@ -62,6 +65,8 @@ public String toString() { ", level=" + level + ", message='" + message + '\'' + ", loggerFqcn='" + loggerFqcn + '\'' + + ", nbLine='" + nbLine + '\'' + + '}'; } diff --git a/src/main/java/fr/abes/logskbart/kafka/LogsListener.java b/src/main/java/fr/abes/logskbart/kafka/LogsListener.java index 1e51799..b948994 100644 --- a/src/main/java/fr/abes/logskbart/kafka/LogsListener.java +++ b/src/main/java/fr/abes/logskbart/kafka/LogsListener.java @@ -53,12 +53,13 @@ public void listenInfoKbart2KafkaAndErrorKbart2Kafka(ConsumerRecord 1) ? listMessage[1] : ""; + logKbart.setNbLine(Integer.parseInt((nbLineOrigine.isEmpty() ? "-1" : nbLineOrigine) )); logKbart.log(); @@ -73,7 +74,7 @@ public void listenInfoKbart2KafkaAndErrorKbart2Kafka(ConsumerRecord { - List findAllByPackageNameAndTimestampBetween(String filename, Date debut, Date fin); + List findAllByPackageNameAndTimestampBetweenOrderByNbLineAscTimestampAsc(String filename, Date debut, Date fin); } diff --git a/src/main/java/fr/abes/logskbart/service/LogsService.java b/src/main/java/fr/abes/logskbart/service/LogsService.java index d69f83f..0aeaf99 100644 --- a/src/main/java/fr/abes/logskbart/service/LogsService.java +++ b/src/main/java/fr/abes/logskbart/service/LogsService.java @@ -24,6 +24,6 @@ public List getLogKbartForPackage(String packageName, Date date) { Calendar dateFin = (Calendar) dateChargement.clone(); dateFin.add(Calendar.DAY_OF_MONTH, 1); log.debug("packageName {}, Date début {}, Date fin {}", packageName, dateChargement.getTime(), dateFin.getTime()); - return repository.findAllByPackageNameAndTimestampBetween(packageName, dateChargement.getTime(), dateFin.getTime()); + return repository.findAllByPackageNameAndTimestampBetweenOrderByNbLineAscTimestampAsc(packageName, dateChargement.getTime(), dateFin.getTime()); } } diff --git a/src/main/java/fr/abes/logskbart/utils/LogsMapper.java b/src/main/java/fr/abes/logskbart/utils/LogsMapper.java index f757b66..c914bab 100644 --- a/src/main/java/fr/abes/logskbart/utils/LogsMapper.java +++ b/src/main/java/fr/abes/logskbart/utils/LogsMapper.java @@ -33,6 +33,7 @@ public LogKbart convert(MappingContext context) { target.setThreadId(source.getThreadId()); target.setThreadPriority(source.getThreadPriority()); target.setLoggerName(source.getLoggerName()); + target.setNbLine(source.getNbLine()); return target; } }; @@ -47,6 +48,7 @@ public LigneLogDto convert(MappingContext context) { LigneLogDto target = new LigneLogDto(); target.setLevel(source.getLevel().toString()); target.setMessage(source.getMessage()); + target.setNbLine(source.getNbLine()); return target; } };