From 2a50899fb83da221ac54bfb9a0dc5f8b86d7a753 Mon Sep 17 00:00:00 2001 From: EryneKL <97091460+EryneKL@users.noreply.github.com> Date: Fri, 8 Dec 2023 08:16:05 +0100 Subject: [PATCH 01/12] =?UTF-8?q?FEAT=20:=20CDE-310=20ajouter=20logs=20dan?= =?UTF-8?q?s=20retour=20du=20ws=20best=20ppn=20=20:=20=20=20=20=20=20-=20c?= =?UTF-8?q?r=C3=A9ation=20de=20la=20classe=20PpnDto.java=20=20=20=20=20=20?= =?UTF-8?q?-=20cr=C3=A9ation=20de=20la=20classe=20PpnWithLogsDto.java=20?= =?UTF-8?q?=20=20=20=20=20-=20modification=20de=20la=20classe=20PpnWithTyp?= =?UTF-8?q?eDto.java=20en=20extends=20PpnDto=20=20=20=20=20=20-=20ajout=20?= =?UTF-8?q?d'un=20param=C3=A8tre=20"logs"=20dans=20le=20contr=C3=B4leur=20?= =?UTF-8?q?BestPpnController.java?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bestppn/controller/BestPpnController.java | 3 ++- src/main/java/fr/abes/bestppn/dto/PpnDto.java | 15 +++++++++++++++ .../java/fr/abes/bestppn/dto/PpnWithLogsDto.java | 16 ++++++++++++++++ .../abes/bestppn/dto/wscall/PpnWithTypeDto.java | 3 ++- 4 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 src/main/java/fr/abes/bestppn/dto/PpnDto.java create mode 100644 src/main/java/fr/abes/bestppn/dto/PpnWithLogsDto.java diff --git a/src/main/java/fr/abes/bestppn/controller/BestPpnController.java b/src/main/java/fr/abes/bestppn/controller/BestPpnController.java index 81237f3..82e076b 100644 --- a/src/main/java/fr/abes/bestppn/controller/BestPpnController.java +++ b/src/main/java/fr/abes/bestppn/controller/BestPpnController.java @@ -41,7 +41,8 @@ public String bestPpn(@RequestParam(name = "provider") String provider, @Request @RequestParam(name = "publication_type") String publicationType, @RequestParam(name = "online_identifier", required = false) String onlineIdentifier, @RequestParam(name = "print_identifier", required = false) String printIdentifier, @RequestParam(name = "titleUrl", required = false) String titleUrl, @RequestParam(name = "date_monograph_published_online", required = false) String dateMonographPublishedOnline, @RequestParam(name = "date_monograph_published_print", required = false) String dateMonographPublishedPrint, - @RequestParam(name = "first_author", required = false) String firstAuthor, @RequestParam(name = "force", required = false) Boolean force) throws IOException { + @RequestParam(name = "first_author", required = false) String firstAuthor, @RequestParam(name = "force", required = false) Boolean force, + @RequestParam(name = "logs", required = false) Boolean logs) throws IOException { try { LigneKbartDto ligneKbartDto = new LigneKbartDto(); ligneKbartDto.setPublicationType(publicationType); diff --git a/src/main/java/fr/abes/bestppn/dto/PpnDto.java b/src/main/java/fr/abes/bestppn/dto/PpnDto.java new file mode 100644 index 0000000..0273e7d --- /dev/null +++ b/src/main/java/fr/abes/bestppn/dto/PpnDto.java @@ -0,0 +1,15 @@ +package fr.abes.bestppn.dto; + +import fr.abes.bestppn.utils.TYPE_SUPPORT; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +public abstract class PpnDto { + + private String ppn; + + private TYPE_SUPPORT typeSupport; + +} diff --git a/src/main/java/fr/abes/bestppn/dto/PpnWithLogsDto.java b/src/main/java/fr/abes/bestppn/dto/PpnWithLogsDto.java new file mode 100644 index 0000000..86b9f29 --- /dev/null +++ b/src/main/java/fr/abes/bestppn/dto/PpnWithLogsDto.java @@ -0,0 +1,16 @@ +package fr.abes.bestppn.dto; + +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +public class PpnWithLogsDto extends PpnDto { + + private List logs; + + public PpnWithLogsDto(){ + + } +} diff --git a/src/main/java/fr/abes/bestppn/dto/wscall/PpnWithTypeDto.java b/src/main/java/fr/abes/bestppn/dto/wscall/PpnWithTypeDto.java index 72812d0..4858c0f 100644 --- a/src/main/java/fr/abes/bestppn/dto/wscall/PpnWithTypeDto.java +++ b/src/main/java/fr/abes/bestppn/dto/wscall/PpnWithTypeDto.java @@ -1,5 +1,6 @@ package fr.abes.bestppn.dto.wscall; +import fr.abes.bestppn.dto.PpnDto; import fr.abes.bestppn.utils.TYPE_DOCUMENT; import fr.abes.bestppn.utils.TYPE_SUPPORT; import lombok.Data; @@ -7,7 +8,7 @@ @Data @NoArgsConstructor -public class PpnWithTypeDto { +public class PpnWithTypeDto extends PpnDto { private String ppn; private TYPE_SUPPORT typeSupport; From 45b4fe5a1fad44497435c1e736585d38bd8db513 Mon Sep 17 00:00:00 2001 From: EryneKL <97091460+EryneKL@users.noreply.github.com> Date: Fri, 8 Dec 2023 14:37:22 +0100 Subject: [PATCH 02/12] FEAT : CDE-310 ajouter logs dans retour du ws best ppn : - renommage de la classe PpnWithLogsDto.java en PpnWithErrorsDto.java --- src/main/java/fr/abes/bestppn/dto/PpnDto.java | 11 +++++++-- .../fr/abes/bestppn/dto/PpnWithErrorsDto.java | 23 +++++++++++++++++++ .../fr/abes/bestppn/dto/PpnWithLogsDto.java | 16 ------------- .../dto/kafka/PpnWithDestinationDto.java | 16 +++++++++---- .../bestppn/dto/wscall/PpnWithTypeDto.java | 16 ++++++------- 5 files changed, 51 insertions(+), 31 deletions(-) create mode 100644 src/main/java/fr/abes/bestppn/dto/PpnWithErrorsDto.java delete mode 100644 src/main/java/fr/abes/bestppn/dto/PpnWithLogsDto.java diff --git a/src/main/java/fr/abes/bestppn/dto/PpnDto.java b/src/main/java/fr/abes/bestppn/dto/PpnDto.java index 0273e7d..860d744 100644 --- a/src/main/java/fr/abes/bestppn/dto/PpnDto.java +++ b/src/main/java/fr/abes/bestppn/dto/PpnDto.java @@ -1,10 +1,12 @@ package fr.abes.bestppn.dto; import fr.abes.bestppn.utils.TYPE_SUPPORT; -import lombok.Data; +import lombok.Getter; +import lombok.Setter; import lombok.NoArgsConstructor; -@Data +@Getter +@Setter @NoArgsConstructor public abstract class PpnDto { @@ -12,4 +14,9 @@ public abstract class PpnDto { private TYPE_SUPPORT typeSupport; + public PpnDto(String ppn, TYPE_SUPPORT typeSupport) { + this.ppn = ppn; + this.typeSupport = typeSupport; + } + } diff --git a/src/main/java/fr/abes/bestppn/dto/PpnWithErrorsDto.java b/src/main/java/fr/abes/bestppn/dto/PpnWithErrorsDto.java new file mode 100644 index 0000000..b556651 --- /dev/null +++ b/src/main/java/fr/abes/bestppn/dto/PpnWithErrorsDto.java @@ -0,0 +1,23 @@ +package fr.abes.bestppn.dto; + +import fr.abes.bestppn.utils.TYPE_SUPPORT; +import lombok.Getter; +import lombok.Setter; + +import java.util.List; + +@Getter +@Setter +public class PpnWithErrorsDto extends PpnDto { + + private List errors; + + public PpnWithErrorsDto(String ppn, TYPE_SUPPORT typeSupport, List errors){ + super(ppn, typeSupport); + this.errors = errors; + } + + public void addError(String error) { + this.errors.add(error); + } +} diff --git a/src/main/java/fr/abes/bestppn/dto/PpnWithLogsDto.java b/src/main/java/fr/abes/bestppn/dto/PpnWithLogsDto.java deleted file mode 100644 index 86b9f29..0000000 --- a/src/main/java/fr/abes/bestppn/dto/PpnWithLogsDto.java +++ /dev/null @@ -1,16 +0,0 @@ -package fr.abes.bestppn.dto; - -import lombok.Data; -import lombok.NoArgsConstructor; - -import java.util.List; - -@Data -public class PpnWithLogsDto extends PpnDto { - - private List logs; - - public PpnWithLogsDto(){ - - } -} diff --git a/src/main/java/fr/abes/bestppn/dto/kafka/PpnWithDestinationDto.java b/src/main/java/fr/abes/bestppn/dto/kafka/PpnWithDestinationDto.java index dcde83c..963a836 100644 --- a/src/main/java/fr/abes/bestppn/dto/kafka/PpnWithDestinationDto.java +++ b/src/main/java/fr/abes/bestppn/dto/kafka/PpnWithDestinationDto.java @@ -1,12 +1,20 @@ package fr.abes.bestppn.dto.kafka; +import fr.abes.bestppn.dto.PpnDto; import fr.abes.bestppn.utils.DESTINATION_TOPIC; +import fr.abes.bestppn.utils.TYPE_SUPPORT; import lombok.AllArgsConstructor; -import lombok.Data; +import lombok.Getter; +import lombok.Setter; -@Data +@Getter +@Setter @AllArgsConstructor -public class PpnWithDestinationDto { - private String ppn; +public class PpnWithDestinationDto extends PpnDto { private DESTINATION_TOPIC destination; + + public PpnWithDestinationDto(String ppn, TYPE_SUPPORT typeSupport, DESTINATION_TOPIC destination) { + super(ppn, typeSupport); + this.destination = destination; + } } diff --git a/src/main/java/fr/abes/bestppn/dto/wscall/PpnWithTypeDto.java b/src/main/java/fr/abes/bestppn/dto/wscall/PpnWithTypeDto.java index 4858c0f..4709968 100644 --- a/src/main/java/fr/abes/bestppn/dto/wscall/PpnWithTypeDto.java +++ b/src/main/java/fr/abes/bestppn/dto/wscall/PpnWithTypeDto.java @@ -3,32 +3,30 @@ import fr.abes.bestppn.dto.PpnDto; import fr.abes.bestppn.utils.TYPE_DOCUMENT; import fr.abes.bestppn.utils.TYPE_SUPPORT; -import lombok.Data; +import lombok.Getter; +import lombok.Setter; import lombok.NoArgsConstructor; -@Data +@Getter +@Setter @NoArgsConstructor public class PpnWithTypeDto extends PpnDto { - private String ppn; - private TYPE_SUPPORT typeSupport; private TYPE_DOCUMENT typeDocument; private Boolean providerPresent = false; public PpnWithTypeDto(String ppn, TYPE_SUPPORT typeSupport, TYPE_DOCUMENT typeDocument) { - this.ppn = ppn; - this.typeSupport = typeSupport; + super(ppn, typeSupport); this.typeDocument = typeDocument; } public PpnWithTypeDto(String ppn, TYPE_SUPPORT typeSupport) { - this.ppn = ppn; - this.typeSupport = typeSupport; + super(ppn, typeSupport); } public PpnWithTypeDto(String ppn) { - this.ppn = ppn; + super.setPpn(ppn); } public boolean isProviderPresent() { From 6d5699614d88c14f6aa1d8c720884e76e80da95e Mon Sep 17 00:00:00 2001 From: EryneKL <97091460+EryneKL@users.noreply.github.com> Date: Mon, 11 Dec 2023 18:24:37 +0100 Subject: [PATCH 03/12] =?UTF-8?q?FEAT=20:=20CDE-310=20ajouter=20erreurs=20?= =?UTF-8?q?dans=20retour=20du=20ws=20best=20ppn=20=20:=20=20=20=20=20=20-?= =?UTF-8?q?=20modification=20du=20retour=20de=20la=20m=C3=A9thode=20bestPp?= =?UTF-8?q?n=20dans=20le=20controller=20BestPpnController.java=20=20=20=20?= =?UTF-8?q?=20=20-=20modofication=20du=20retour=20de=20la=20m=C3=A9thode?= =?UTF-8?q?=20getBestPpn=20dans=20BestPpnService.java=20=20=20=20=20=20-?= =?UTF-8?q?=20adaptation=20de=20la=20m=C3=A9thode=20processConsumerRecord?= =?UTF-8?q?=20dans=20KbartService.java=20=20=20=20=20=20-=20suppression=20?= =?UTF-8?q?de=20l'ancienne=20classe=20PpnDto.java=20=20=20=20=20=20-=20sup?= =?UTF-8?q?pression=20de=20la=20classe=20PpnWithErrorsDto.java=20=20=20=20?= =?UTF-8?q?=20=20-=20rebase=20from=20develop=20de=20la=20dto=20PpnWithType?= =?UTF-8?q?Dto.java=20=20=20=20=20=20-=20renommage=20de=20la=20dto=20PpnWi?= =?UTF-8?q?thDestinationDto.java=20en=20PpnDto.java=20et=20ajout=20de=20va?= =?UTF-8?q?riables=20et=20de=20constructeurs=20=20=20=20=20=20-=20adaptati?= =?UTF-8?q?on=20des=20TU?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bestppn/controller/BestPpnController.java | 10 ++-- src/main/java/fr/abes/bestppn/dto/PpnDto.java | 22 -------- .../fr/abes/bestppn/dto/PpnWithErrorsDto.java | 23 -------- .../fr/abes/bestppn/dto/kafka/PpnDto.java | 53 +++++++++++++++++++ .../dto/kafka/PpnWithDestinationDto.java | 20 ------- .../bestppn/dto/wscall/PpnWithTypeDto.java | 19 +++---- .../abes/bestppn/service/BestPpnService.java | 34 ++++++++---- .../fr/abes/bestppn/service/KbartService.java | 14 ++--- .../controller/BestPpnControllerTest.java | 12 ++--- .../bestppn/service/BestPpnServiceTest.java | 30 +++++------ 10 files changed, 122 insertions(+), 115 deletions(-) delete mode 100644 src/main/java/fr/abes/bestppn/dto/PpnDto.java delete mode 100644 src/main/java/fr/abes/bestppn/dto/PpnWithErrorsDto.java create mode 100644 src/main/java/fr/abes/bestppn/dto/kafka/PpnDto.java delete mode 100644 src/main/java/fr/abes/bestppn/dto/kafka/PpnWithDestinationDto.java diff --git a/src/main/java/fr/abes/bestppn/controller/BestPpnController.java b/src/main/java/fr/abes/bestppn/controller/BestPpnController.java index 82e076b..0a26966 100644 --- a/src/main/java/fr/abes/bestppn/controller/BestPpnController.java +++ b/src/main/java/fr/abes/bestppn/controller/BestPpnController.java @@ -1,6 +1,7 @@ package fr.abes.bestppn.controller; import fr.abes.bestppn.dto.kafka.LigneKbartDto; +import fr.abes.bestppn.dto.kafka.PpnDto; import fr.abes.bestppn.exception.BestPpnException; import fr.abes.bestppn.exception.IllegalDoiException; import fr.abes.bestppn.service.BestPpnService; @@ -37,12 +38,12 @@ public BestPpnController(BestPpnService service) { } ) @GetMapping(value = "/bestPpn") - public String bestPpn(@RequestParam(name = "provider") String provider, @RequestParam(name = "publication_title", required = false) String publicationTitle, + public PpnDto bestPpn(@RequestParam(name = "provider") String provider, @RequestParam(name = "publication_title", required = false) String publicationTitle, @RequestParam(name = "publication_type") String publicationType, @RequestParam(name = "online_identifier", required = false) String onlineIdentifier, @RequestParam(name = "print_identifier", required = false) String printIdentifier, @RequestParam(name = "titleUrl", required = false) String titleUrl, @RequestParam(name = "date_monograph_published_online", required = false) String dateMonographPublishedOnline, @RequestParam(name = "date_monograph_published_print", required = false) String dateMonographPublishedPrint, @RequestParam(name = "first_author", required = false) String firstAuthor, @RequestParam(name = "force", required = false) Boolean force, - @RequestParam(name = "logs", required = false) Boolean logs) throws IOException { + @RequestParam(name = "errors", required = false) Boolean errors) throws IOException { try { LigneKbartDto ligneKbartDto = new LigneKbartDto(); ligneKbartDto.setPublicationType(publicationType); @@ -54,11 +55,12 @@ public String bestPpn(@RequestParam(name = "provider") String provider, @Request ligneKbartDto.setDateMonographPublishedOnline((dateMonographPublishedOnline != null) ? dateMonographPublishedOnline : ""); ligneKbartDto.setFirstAuthor((firstAuthor != null) ? firstAuthor : ""); boolean injectKafka = (force != null) ? force : false; - return service.getBestPpn(ligneKbartDto, provider, injectKafka).getPpn(); + boolean sendErrors = (errors != null) ? errors : false; + return service.getBestPpn(ligneKbartDto, provider, injectKafka, sendErrors); } catch (URISyntaxException e) { throw new IllegalArgumentException("Une url dans le champ title_url du kbart n'est pas correcte"); } catch (BestPpnException | RestClientException | IllegalArgumentException | IllegalDoiException e) { - return e.getMessage(); + return new PpnDto(e.getMessage()); } } } diff --git a/src/main/java/fr/abes/bestppn/dto/PpnDto.java b/src/main/java/fr/abes/bestppn/dto/PpnDto.java deleted file mode 100644 index 860d744..0000000 --- a/src/main/java/fr/abes/bestppn/dto/PpnDto.java +++ /dev/null @@ -1,22 +0,0 @@ -package fr.abes.bestppn.dto; - -import fr.abes.bestppn.utils.TYPE_SUPPORT; -import lombok.Getter; -import lombok.Setter; -import lombok.NoArgsConstructor; - -@Getter -@Setter -@NoArgsConstructor -public abstract class PpnDto { - - private String ppn; - - private TYPE_SUPPORT typeSupport; - - public PpnDto(String ppn, TYPE_SUPPORT typeSupport) { - this.ppn = ppn; - this.typeSupport = typeSupport; - } - -} diff --git a/src/main/java/fr/abes/bestppn/dto/PpnWithErrorsDto.java b/src/main/java/fr/abes/bestppn/dto/PpnWithErrorsDto.java deleted file mode 100644 index b556651..0000000 --- a/src/main/java/fr/abes/bestppn/dto/PpnWithErrorsDto.java +++ /dev/null @@ -1,23 +0,0 @@ -package fr.abes.bestppn.dto; - -import fr.abes.bestppn.utils.TYPE_SUPPORT; -import lombok.Getter; -import lombok.Setter; - -import java.util.List; - -@Getter -@Setter -public class PpnWithErrorsDto extends PpnDto { - - private List errors; - - public PpnWithErrorsDto(String ppn, TYPE_SUPPORT typeSupport, List errors){ - super(ppn, typeSupport); - this.errors = errors; - } - - public void addError(String error) { - this.errors.add(error); - } -} diff --git a/src/main/java/fr/abes/bestppn/dto/kafka/PpnDto.java b/src/main/java/fr/abes/bestppn/dto/kafka/PpnDto.java new file mode 100644 index 0000000..3753d3c --- /dev/null +++ b/src/main/java/fr/abes/bestppn/dto/kafka/PpnDto.java @@ -0,0 +1,53 @@ +package fr.abes.bestppn.dto.kafka; + +import fr.abes.bestppn.utils.DESTINATION_TOPIC; +import fr.abes.bestppn.utils.TYPE_SUPPORT; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import org.springframework.lang.Nullable; +import java.util.ArrayList; +import java.util.List; + +@Getter +@Setter +@NoArgsConstructor +public class PpnDto { + + @Nullable + private String ppn; + + private TYPE_SUPPORT typeSupport; + + private DESTINATION_TOPIC destination; + + private String error; + + public PpnDto(String ppn, DESTINATION_TOPIC destination) { + this.ppn = ppn; + this.destination = destination; + } + + public PpnDto(String ppn, DESTINATION_TOPIC destination, TYPE_SUPPORT typeSupport) { + this.ppn = ppn; + this.destination = destination; + this.typeSupport = typeSupport; + } + + public PpnDto(String ppn, DESTINATION_TOPIC destination, String error) { + this.ppn = ppn; + this.destination = destination; + this.error = error; + } + + public PpnDto(String ppn, DESTINATION_TOPIC destination, TYPE_SUPPORT typeSupport, String error) { + this.ppn = ppn; + this.destination = destination; + this.typeSupport = typeSupport; + this.error = error; + } + + public PpnDto (String error) { + this.error = error; + } +} diff --git a/src/main/java/fr/abes/bestppn/dto/kafka/PpnWithDestinationDto.java b/src/main/java/fr/abes/bestppn/dto/kafka/PpnWithDestinationDto.java deleted file mode 100644 index 963a836..0000000 --- a/src/main/java/fr/abes/bestppn/dto/kafka/PpnWithDestinationDto.java +++ /dev/null @@ -1,20 +0,0 @@ -package fr.abes.bestppn.dto.kafka; - -import fr.abes.bestppn.dto.PpnDto; -import fr.abes.bestppn.utils.DESTINATION_TOPIC; -import fr.abes.bestppn.utils.TYPE_SUPPORT; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.Setter; - -@Getter -@Setter -@AllArgsConstructor -public class PpnWithDestinationDto extends PpnDto { - private DESTINATION_TOPIC destination; - - public PpnWithDestinationDto(String ppn, TYPE_SUPPORT typeSupport, DESTINATION_TOPIC destination) { - super(ppn, typeSupport); - this.destination = destination; - } -} diff --git a/src/main/java/fr/abes/bestppn/dto/wscall/PpnWithTypeDto.java b/src/main/java/fr/abes/bestppn/dto/wscall/PpnWithTypeDto.java index 4709968..72812d0 100644 --- a/src/main/java/fr/abes/bestppn/dto/wscall/PpnWithTypeDto.java +++ b/src/main/java/fr/abes/bestppn/dto/wscall/PpnWithTypeDto.java @@ -1,32 +1,33 @@ package fr.abes.bestppn.dto.wscall; -import fr.abes.bestppn.dto.PpnDto; import fr.abes.bestppn.utils.TYPE_DOCUMENT; import fr.abes.bestppn.utils.TYPE_SUPPORT; -import lombok.Getter; -import lombok.Setter; +import lombok.Data; import lombok.NoArgsConstructor; -@Getter -@Setter +@Data @NoArgsConstructor -public class PpnWithTypeDto extends PpnDto { +public class PpnWithTypeDto { + private String ppn; + private TYPE_SUPPORT typeSupport; private TYPE_DOCUMENT typeDocument; private Boolean providerPresent = false; public PpnWithTypeDto(String ppn, TYPE_SUPPORT typeSupport, TYPE_DOCUMENT typeDocument) { - super(ppn, typeSupport); + this.ppn = ppn; + this.typeSupport = typeSupport; this.typeDocument = typeDocument; } public PpnWithTypeDto(String ppn, TYPE_SUPPORT typeSupport) { - super(ppn, typeSupport); + this.ppn = ppn; + this.typeSupport = typeSupport; } public PpnWithTypeDto(String ppn) { - super.setPpn(ppn); + this.ppn = ppn; } public boolean isProviderPresent() { diff --git a/src/main/java/fr/abes/bestppn/service/BestPpnService.java b/src/main/java/fr/abes/bestppn/service/BestPpnService.java index f81d605..60dfb05 100644 --- a/src/main/java/fr/abes/bestppn/service/BestPpnService.java +++ b/src/main/java/fr/abes/bestppn/service/BestPpnService.java @@ -1,7 +1,7 @@ package fr.abes.bestppn.service; import fr.abes.bestppn.dto.kafka.LigneKbartDto; -import fr.abes.bestppn.dto.kafka.PpnWithDestinationDto; +import fr.abes.bestppn.dto.kafka.PpnDto; import fr.abes.bestppn.dto.wscall.PpnWithTypeDto; import fr.abes.bestppn.dto.wscall.ResultDat2PpnWebDto; import fr.abes.bestppn.dto.wscall.ResultWsSudocDto; @@ -57,7 +57,7 @@ public BestPpnService(WsService service, NoticeService noticeService, TopicProdu this.checkUrlService = checkUrlService; } - public PpnWithDestinationDto getBestPpn(LigneKbartDto kbart, String provider, boolean injectKafka) throws IOException, BestPpnException, URISyntaxException, RestClientException, IllegalArgumentException, IllegalDoiException { + public PpnDto getBestPpn(LigneKbartDto kbart, String provider, boolean injectKafka, boolean sendErrors) throws IOException, BestPpnException, URISyntaxException, RestClientException, IllegalArgumentException, IllegalDoiException { Map ppnElecScoredList = new HashMap<>(); Set ppnPrintResultList = new HashSet<>(); @@ -82,7 +82,7 @@ public PpnWithDestinationDto getBestPpn(LigneKbartDto kbart, String provider, bo feedPpnListFromDat(kbart, ppnElecScoredList, ppnPrintResultList); } - return getBestPpnByScore(kbart, ppnElecScoredList, ppnPrintResultList, injectKafka); + return getBestPpnByScore(kbart, ppnElecScoredList, ppnPrintResultList, injectKafka, sendErrors); } private void feedPpnListFromOnline(LigneKbartDto kbart, String provider, Map ppnElecScoredList, Set ppnPrintResultList) throws IOException, URISyntaxException, IllegalArgumentException, BestPpnException { @@ -172,7 +172,7 @@ private void setScoreToPpnElect(int score, Map ppnElecScoredLis log.info("PPN Electronique : " + ppn + " / score : " + ppnElecScoredList.get(ppn.getPpn())); } - public PpnWithDestinationDto getBestPpnByScore(LigneKbartDto kbart, Map ppnElecResultList, Set ppnPrintResultList, boolean isForced) throws BestPpnException { + public PpnDto getBestPpnByScore(LigneKbartDto kbart, Map ppnElecResultList, Set ppnPrintResultList, boolean isForced, boolean sendErrors) throws BestPpnException { Map ppnElecScore = Utils.getMaxValuesFromMap(ppnElecResultList); return switch (ppnElecScore.size()) { case 0 -> { @@ -180,12 +180,20 @@ public PpnWithDestinationDto getBestPpnByScore(LigneKbartDto kbart, Map { kbart.setErrorType("Aucun ppn trouvé"); - yield new PpnWithDestinationDto(null, DESTINATION_TOPIC.NO_PPN_FOUND_SUDOC); + if(sendErrors) { + yield new PpnDto(null, DESTINATION_TOPIC.NO_PPN_FOUND_SUDOC, "Aucun ppn électronique trouvé."); + } else { + yield new PpnDto(null, DESTINATION_TOPIC.NO_PPN_FOUND_SUDOC); + } } case 1 -> { kbart.setErrorType("Ppn imprimé trouvé : " + ppnPrintResultList.stream().toList().get(0)); - yield new PpnWithDestinationDto(ppnPrintResultList.stream().toList().get(0),DESTINATION_TOPIC.PRINT_PPN_SUDOC); + if(sendErrors) { + yield new PpnDto(ppnPrintResultList.stream().toList().get(0),DESTINATION_TOPIC.PRINT_PPN_SUDOC, TYPE_SUPPORT.IMPRIME, "Ppn imprimé trouvé à la place d'un ppn électronique : " + ppnPrintResultList.stream().toList().get(0)); + } else { + yield new PpnDto(ppnPrintResultList.stream().toList().get(0),DESTINATION_TOPIC.PRINT_PPN_SUDOC, TYPE_SUPPORT.IMPRIME); + } } default -> { @@ -194,14 +202,18 @@ yield switch (ppnPrintResultList.size()) { // vérification du forçage if (isForced) { log.error(errorString); - yield new PpnWithDestinationDto("",DESTINATION_TOPIC.BEST_PPN_BACON); + if (sendErrors) { + yield new PpnDto("",DESTINATION_TOPIC.BEST_PPN_BACON, "Plusieurs ppn imprimés (" + String.join(", ", ppnPrintResultList) + ") ont été trouvés."); + } else { + yield new PpnDto("",DESTINATION_TOPIC.BEST_PPN_BACON); + } } else { throw new BestPpnException(errorString); } } }; } - case 1 -> new PpnWithDestinationDto(ppnElecScore.keySet().stream().findFirst().get(), DESTINATION_TOPIC.BEST_PPN_BACON); + case 1 -> new PpnDto(ppnElecScore.keySet().stream().findFirst().get(), DESTINATION_TOPIC.BEST_PPN_BACON, TYPE_SUPPORT.ELECTRONIQUE); default -> { String listPpn = String.join(", ", ppnElecScore.keySet()); @@ -210,7 +222,11 @@ yield switch (ppnPrintResultList.size()) { // vérification du forçage if (isForced) { log.error(errorString); - yield new PpnWithDestinationDto("", DESTINATION_TOPIC.BEST_PPN_BACON); + if (sendErrors) { + yield new PpnDto("", DESTINATION_TOPIC.BEST_PPN_BACON, errorString); + } else { + yield new PpnDto("", DESTINATION_TOPIC.BEST_PPN_BACON); + } } else { throw new BestPpnException(errorString); } diff --git a/src/main/java/fr/abes/bestppn/service/KbartService.java b/src/main/java/fr/abes/bestppn/service/KbartService.java index c41196a..4d2bf1b 100644 --- a/src/main/java/fr/abes/bestppn/service/KbartService.java +++ b/src/main/java/fr/abes/bestppn/service/KbartService.java @@ -2,7 +2,7 @@ import fr.abes.LigneKbartImprime; import fr.abes.bestppn.dto.kafka.LigneKbartDto; -import fr.abes.bestppn.dto.kafka.PpnWithDestinationDto; +import fr.abes.bestppn.dto.kafka.PpnDto; import fr.abes.bestppn.entity.bacon.Provider; import fr.abes.bestppn.entity.bacon.ProviderPackage; import fr.abes.bestppn.exception.BestPpnException; @@ -59,13 +59,13 @@ public void processConsumerRecord(LigneKbartDto ligneFromKafka, String providerN log.info("Début calcul BestPpn pour la ligne " + ligneFromKafka); if (ligneFromKafka.isBestPpnEmpty()) { log.info(ligneFromKafka.toString()); - PpnWithDestinationDto ppnWithDestinationDto = service.getBestPpn(ligneFromKafka, providerName, isForced); - switch (ppnWithDestinationDto.getDestination()) { + PpnDto ppnDto = service.getBestPpn(ligneFromKafka, providerName, isForced, false); + switch (ppnDto.getDestination()) { case BEST_PPN_BACON -> { - ligneFromKafka.setBestPpn(ppnWithDestinationDto.getPpn()); + ligneFromKafka.setBestPpn(ppnDto.getPpn()); executionReportService.addNbBestPpnFind(); } - case PRINT_PPN_SUDOC -> ppnToCreate.add(getLigneKbartImprime(ppnWithDestinationDto, ligneFromKafka)); + case PRINT_PPN_SUDOC -> ppnToCreate.add(getLigneKbartImprime(ppnDto, ligneFromKafka)); case NO_PPN_FOUND_SUDOC -> { if (ligneFromKafka.getPublicationType().equals("monograph")) { ppnFromKbartToCreate.add(ligneFromKafka); @@ -95,9 +95,9 @@ public void clearListesKbart() { ppnFromKbartToCreate.clear(); } - private static LigneKbartImprime getLigneKbartImprime(PpnWithDestinationDto ppnWithDestinationDto, LigneKbartDto ligneFromKafka) { + private static LigneKbartImprime getLigneKbartImprime(PpnDto ppnDto, LigneKbartDto ligneFromKafka) { return LigneKbartImprime.newBuilder() - .setPpn(ppnWithDestinationDto.getPpn()) + .setPpn(ppnDto.getPpn()) .setPublicationTitle(ligneFromKafka.getPublicationTitle()) .setPrintIdentifier(ligneFromKafka.getPrintIdentifier()) .setOnlineIdentifier(ligneFromKafka.getOnlineIdentifier()) diff --git a/src/test/java/fr/abes/bestppn/controller/BestPpnControllerTest.java b/src/test/java/fr/abes/bestppn/controller/BestPpnControllerTest.java index 625f382..cf0a10d 100644 --- a/src/test/java/fr/abes/bestppn/controller/BestPpnControllerTest.java +++ b/src/test/java/fr/abes/bestppn/controller/BestPpnControllerTest.java @@ -3,7 +3,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import fr.abes.bestppn.configuration.MapperConfig; import fr.abes.bestppn.configuration.RestConfiguration; -import fr.abes.bestppn.dto.kafka.PpnWithDestinationDto; +import fr.abes.bestppn.dto.kafka.PpnDto; import fr.abes.bestppn.exception.BestPpnException; import fr.abes.bestppn.exception.ExceptionControllerHandler; import fr.abes.bestppn.exception.IllegalDoiException; @@ -59,8 +59,8 @@ void init() { @Test @DisplayName("test controller with wrong number of parameters") - void testBestPpnControllerWrongNumberOfParameters() throws Exception, IllegalDoiException { - Mockito.when(service.getBestPpn(Mockito.any(), Mockito.anyString(), Mockito.anyBoolean())).thenReturn(new PpnWithDestinationDto("1111111111", DESTINATION_TOPIC.BEST_PPN_BACON)); + void testBestPpnControllerWrongNumberOfParameters() throws Exception { + Mockito.when(service.getBestPpn(Mockito.any(), Mockito.anyString(), Mockito.anyBoolean(), Mockito.anyBoolean())).thenReturn(new PpnDto("1111111111", DESTINATION_TOPIC.BEST_PPN_BACON)); this.mockMvc.perform(get("/api/v1/bestPpn").characterEncoding(StandardCharsets.UTF_8)) .andExpect(status().isBadRequest()) .andExpect(result -> Assertions.assertTrue((result.getResolvedException() instanceof MissingServletRequestParameterException))) @@ -75,7 +75,7 @@ void testBestPpnControllerWrongNumberOfParameters() throws Exception, IllegalDoi @Test @DisplayName("test controller with wrong URL format") void testBestPpnControllerBadUrlFormat() throws Exception { - Mockito.when(service.getBestPpn(Mockito.any(), Mockito.anyString(), Mockito.anyBoolean())).thenThrow(new URISyntaxException("test", "Format d'URL incorrect")); + Mockito.when(service.getBestPpn(Mockito.any(), Mockito.anyString(), Mockito.anyBoolean(), Mockito.anyBoolean())).thenThrow(new URISyntaxException("test", "Format d'URL incorrect")); this.mockMvc.perform(get("/api/v1/bestPpn?provider=cairn&publication_type=monograph&print_identifier=9781111111111&title_url=test").characterEncoding(StandardCharsets.UTF_8)) .andExpect(status().isBadRequest()) .andExpect(result -> Assertions.assertTrue((result.getResolvedException() instanceof IllegalArgumentException))) @@ -85,7 +85,7 @@ void testBestPpnControllerBadUrlFormat() throws Exception { @Test @DisplayName("test controller with BestPpnException") void testBestPpnControllerBestPpnException() throws Exception { - Mockito.when(service.getBestPpn(Mockito.any(), Mockito.anyString(), Mockito.anyBoolean())).thenThrow(new BestPpnException("Plusieurs ppn imprimés")); + Mockito.when(service.getBestPpn(Mockito.any(), Mockito.anyString(), Mockito.anyBoolean(), Mockito.anyBoolean())).thenThrow(new BestPpnException("Plusieurs ppn imprimés")); this.mockMvc.perform(get("/api/v1/bestPpn?provider=cairn&publication_type=monograph&print_identifier=9781111111111&title_url=test").characterEncoding(StandardCharsets.UTF_8)) .andExpect(status().isOk()) .andExpect(result -> Assertions.assertTrue(result.getResponse().getContentAsString(StandardCharsets.UTF_8).contains("Plusieurs ppn imprimés"))); @@ -94,7 +94,7 @@ void testBestPpnControllerBestPpnException() throws Exception { @Test @DisplayName("test controller Ok") void testBestPpnControllerOk() throws Exception { - Mockito.when(service.getBestPpn(Mockito.any(), Mockito.anyString(), Mockito.anyBoolean())).thenReturn(new PpnWithDestinationDto("1111111111", DESTINATION_TOPIC.BEST_PPN_BACON)); + Mockito.when(service.getBestPpn(Mockito.any(), Mockito.anyString(), Mockito.anyBoolean(), Mockito.anyBoolean())).thenReturn(new PpnDto("1111111111", DESTINATION_TOPIC.BEST_PPN_BACON)); this.mockMvc.perform(get("/api/v1/bestPpn?provider=cairn&publication_type=monograph&print_identifier=9781111111111&title_url=test").characterEncoding(StandardCharsets.UTF_8)) .andExpect(status().isOk()) .andExpect(result -> Assertions.assertTrue(result.getResponse().getContentAsString(StandardCharsets.UTF_8).contains("111111111"))); diff --git a/src/test/java/fr/abes/bestppn/service/BestPpnServiceTest.java b/src/test/java/fr/abes/bestppn/service/BestPpnServiceTest.java index b6781e8..ccb7ed5 100644 --- a/src/test/java/fr/abes/bestppn/service/BestPpnServiceTest.java +++ b/src/test/java/fr/abes/bestppn/service/BestPpnServiceTest.java @@ -3,7 +3,7 @@ import com.fasterxml.jackson.dataformat.xml.JacksonXmlModule; import com.fasterxml.jackson.dataformat.xml.XmlMapper; import fr.abes.bestppn.dto.kafka.LigneKbartDto; -import fr.abes.bestppn.dto.kafka.PpnWithDestinationDto; +import fr.abes.bestppn.dto.kafka.PpnDto; import fr.abes.bestppn.dto.wscall.PpnWithTypeDto; import fr.abes.bestppn.dto.wscall.ResultDat2PpnWebDto; import fr.abes.bestppn.dto.wscall.ResultWsSudocDto; @@ -122,7 +122,7 @@ void getBestPpnTest01() throws IOException, BestPpnException, URISyntaxException Mockito.when(noticeService.getNoticeByPpn(Mockito.anyString())).thenReturn(this.noticeElec); // Appel du service - PpnWithDestinationDto result = bestPpnService.getBestPpn(kbart, provider, false); + PpnDto result = bestPpnService.getBestPpn(kbart, provider, false, false); // Vérification Assertions.assertEquals("100000001", result.getPpn()); @@ -173,7 +173,7 @@ void getBestPpnTest01_WithProviderInNoticeIsPresent() throws IOException, BestPp Mockito.when(noticeService.getNoticeByPpn(Mockito.anyString())).thenReturn(this.noticeElec); // Appel du service - PpnWithDestinationDto result = bestPpnService.getBestPpn(kbart, provider, false); + PpnDto result = bestPpnService.getBestPpn(kbart, provider, false, false); // Vérification Assertions.assertEquals("100000001", result.getPpn()); @@ -231,7 +231,7 @@ void getBestPpnTest02() throws IOException, BestPpnException, URISyntaxException Mockito.when(noticeService.getNoticeByPpn(Mockito.anyString())).thenReturn(this.noticeElec); // Appel du service - PpnWithDestinationDto result = bestPpnService.getBestPpn(kbart, provider, false); + PpnDto result = bestPpnService.getBestPpn(kbart, provider, false, false); // Vérification Assertions.assertEquals("100000001", result.getPpn()); @@ -289,7 +289,7 @@ void getBestPpnTest03() throws IOException, BestPpnException, URISyntaxException Mockito.when(noticeService.getNoticeByPpn(Mockito.anyString())).thenReturn(this.noticeElec); // Appel du service - PpnWithDestinationDto result = bestPpnService.getBestPpn(kbart, provider, false); + PpnDto result = bestPpnService.getBestPpn(kbart, provider, false, false); // Vérification Assertions.assertEquals("100000001", result.getPpn()); @@ -341,7 +341,7 @@ void getBestPpnTest04() throws IOException, URISyntaxException { Mockito.when(noticeService.getNoticeByPpn(Mockito.anyString())).thenReturn(this.noticeElec); // Vérification - BestPpnException result = Assertions.assertThrows(BestPpnException.class, ()-> bestPpnService.getBestPpn(kbart, provider, false)); + BestPpnException result = Assertions.assertThrows(BestPpnException.class, ()-> bestPpnService.getBestPpn(kbart, provider, false, false)); Assertions.assertEquals("Kbart : publication title : Titre / publication_type : serial / online_identifier : 1292-8399 / print_identifier : 2-84358-095-1 : Les ppn électroniques 100000001, 100000002 ont le même score" , result.getLocalizedMessage()); } @@ -387,7 +387,7 @@ void getBestPpnTest06() throws IOException, BestPpnException, URISyntaxException Mockito.when(service.callDat2Ppn(Mockito.anyString(), Mockito.anyString(), Mockito.anyString())).thenReturn(resultDat2PpnWeb); // Appel de la méthode - PpnWithDestinationDto result = bestPpnService.getBestPpn(kbart, provider, false); + PpnDto result = bestPpnService.getBestPpn(kbart, provider, false, false); // Vérification Assertions.assertEquals("300000001", result.getPpn()); @@ -429,7 +429,7 @@ void getBestPpnTest06_NoBestPpnByDat2Ppn() throws IOException, BestPpnException, Mockito.when(noticeService.getNoticeByPpn("300000002")).thenReturn(noticePrint); // Appel de la méthode - PpnWithDestinationDto result = bestPpnService.getBestPpn(kbart, provider, false); + PpnDto result = bestPpnService.getBestPpn(kbart, provider, false, false); // Vérification Assertions.assertNull(result.getPpn()); @@ -481,7 +481,7 @@ void getBestPpnTest07() throws IOException, BestPpnException, URISyntaxException Mockito.when(noticeService.getNoticeByPpn(Mockito.anyString())).thenReturn(this.noticeElec); // Appel du service - PpnWithDestinationDto result = bestPpnService.getBestPpn(kbart, provider, false); + PpnDto result = bestPpnService.getBestPpn(kbart, provider, false, false); // Vérification Assertions.assertEquals("100000001", result.getPpn()); @@ -532,7 +532,7 @@ void getBestPpnTest08() throws IOException, BestPpnException, URISyntaxException Mockito.when(checkUrlService.checkUrlInNotice(Mockito.anyString(), Mockito.any())).thenReturn(true); // Appel du service - PpnWithDestinationDto result = bestPpnService.getBestPpn(kbart, provider, false); + PpnDto result = bestPpnService.getBestPpn(kbart, provider, false, false); // Vérification Assertions.assertEquals("200000001", result.getPpn()); @@ -614,7 +614,7 @@ void getBestPpnTest09() throws IOException, BestPpnException, URISyntaxException ThreadContext.put("package","truc_truc_2000-12-31.tsv"); Mockito.when(checkUrlService.checkUrlInNotice(Mockito.anyString(), Mockito.anyString())).thenReturn(true); // Appel du service - PpnWithDestinationDto result = bestPpnService.getBestPpn(kbart, provider, false); + PpnDto result = bestPpnService.getBestPpn(kbart, provider, false, false); // Vérification Assertions.assertEquals("123456789", result.getPpn()); @@ -629,7 +629,7 @@ void bestPpnWithScoreTest1() throws BestPpnException { ppnElecResultList.put("100000001", 10); Set ppnPrintResultList = new HashSet<>(); - PpnWithDestinationDto result = bestPpnService.getBestPpnByScore(kbart, ppnElecResultList, ppnPrintResultList, false); + PpnDto result = bestPpnService.getBestPpnByScore(kbart, ppnElecResultList, ppnPrintResultList, false, false); Assertions.assertEquals("100000001", result.getPpn()); Assertions.assertEquals(DESTINATION_TOPIC.BEST_PPN_BACON, result.getDestination()); } @@ -643,7 +643,7 @@ void bestPpnWithScoreTest2() throws BestPpnException { ppnElecResultList.put("100000002", 10); Set ppnPrintResultList = new HashSet<>(); - PpnWithDestinationDto result = bestPpnService.getBestPpnByScore(kbart, ppnElecResultList, ppnPrintResultList, false); + PpnDto result = bestPpnService.getBestPpnByScore(kbart, ppnElecResultList, ppnPrintResultList, false, false); Assertions.assertEquals("100000002", result.getPpn()); Assertions.assertEquals(DESTINATION_TOPIC.BEST_PPN_BACON, result.getDestination()); } @@ -657,7 +657,7 @@ void bestPpnWithScoreTest3() throws BestPpnException { ppnElecResultList.put("100000002", 10); Set ppnPrintResultList = new HashSet<>(); - PpnWithDestinationDto result = bestPpnService.getBestPpnByScore(kbart, ppnElecResultList, ppnPrintResultList, true); + PpnDto result = bestPpnService.getBestPpnByScore(kbart, ppnElecResultList, ppnPrintResultList, true, false); Assertions.assertEquals("", result.getPpn()); } @@ -672,7 +672,7 @@ void bestPpnWithScoreTest4() throws BestPpnException { ppnPrintResultList.add("100000001"); ppnPrintResultList.add("100000002"); - PpnWithDestinationDto result = bestPpnService.getBestPpnByScore(kbart, ppnElecResultList, ppnPrintResultList, true); + PpnDto result = bestPpnService.getBestPpnByScore(kbart, ppnElecResultList, ppnPrintResultList, true, false); Assertions.assertEquals("", result.getPpn()); } From b27c39cc9ad14b1829d8aba61a1a3579115f104f Mon Sep 17 00:00:00 2001 From: EryneKL <97091460+EryneKL@users.noreply.github.com> Date: Tue, 12 Dec 2023 08:56:03 +0100 Subject: [PATCH 04/12] =?UTF-8?q?FEAT=20:=20CDE-310=20ajouter=20erreurs=20?= =?UTF-8?q?dans=20retour=20du=20ws=20best=20ppn=20=20:=20=20=20=20=20=20-?= =?UTF-8?q?=20cr=C3=A9ation=20de=20la=20classe=20PpnControllerDto.java=20?= =?UTF-8?q?=20=20=20=20=20-=20adaptation=20de=20la=20classe=20BestPpnContr?= =?UTF-8?q?oller.java=20=20=20=20=20=20-=20adaptation=20de=20la=20classe?= =?UTF-8?q?=20PpnDto.java?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bestppn/controller/BestPpnController.java | 18 +++++----- .../fr/abes/bestppn/dto/PpnControllerDto.java | 35 +++++++++++++++++++ .../fr/abes/bestppn/dto/kafka/PpnDto.java | 17 ++++----- 3 files changed, 52 insertions(+), 18 deletions(-) create mode 100644 src/main/java/fr/abes/bestppn/dto/PpnControllerDto.java diff --git a/src/main/java/fr/abes/bestppn/controller/BestPpnController.java b/src/main/java/fr/abes/bestppn/controller/BestPpnController.java index 0a26966..57cacb0 100644 --- a/src/main/java/fr/abes/bestppn/controller/BestPpnController.java +++ b/src/main/java/fr/abes/bestppn/controller/BestPpnController.java @@ -1,5 +1,6 @@ package fr.abes.bestppn.controller; +import fr.abes.bestppn.dto.PpnControllerDto; import fr.abes.bestppn.dto.kafka.LigneKbartDto; import fr.abes.bestppn.dto.kafka.PpnDto; import fr.abes.bestppn.exception.BestPpnException; @@ -38,12 +39,12 @@ public BestPpnController(BestPpnService service) { } ) @GetMapping(value = "/bestPpn") - public PpnDto bestPpn(@RequestParam(name = "provider") String provider, @RequestParam(name = "publication_title", required = false) String publicationTitle, - @RequestParam(name = "publication_type") String publicationType, @RequestParam(name = "online_identifier", required = false) String onlineIdentifier, - @RequestParam(name = "print_identifier", required = false) String printIdentifier, @RequestParam(name = "titleUrl", required = false) String titleUrl, - @RequestParam(name = "date_monograph_published_online", required = false) String dateMonographPublishedOnline, @RequestParam(name = "date_monograph_published_print", required = false) String dateMonographPublishedPrint, - @RequestParam(name = "first_author", required = false) String firstAuthor, @RequestParam(name = "force", required = false) Boolean force, - @RequestParam(name = "errors", required = false) Boolean errors) throws IOException { + public PpnControllerDto bestPpn(@RequestParam(name = "provider") String provider, @RequestParam(name = "publication_title", required = false) String publicationTitle, + @RequestParam(name = "publication_type") String publicationType, @RequestParam(name = "online_identifier", required = false) String onlineIdentifier, + @RequestParam(name = "print_identifier", required = false) String printIdentifier, @RequestParam(name = "titleUrl", required = false) String titleUrl, + @RequestParam(name = "date_monograph_published_online", required = false) String dateMonographPublishedOnline, @RequestParam(name = "date_monograph_published_print", required = false) String dateMonographPublishedPrint, + @RequestParam(name = "first_author", required = false) String firstAuthor, @RequestParam(name = "force", required = false) Boolean force, + @RequestParam(name = "errors", required = false) Boolean errors) throws IOException { try { LigneKbartDto ligneKbartDto = new LigneKbartDto(); ligneKbartDto.setPublicationType(publicationType); @@ -56,11 +57,12 @@ public PpnDto bestPpn(@RequestParam(name = "provider") String provider, @Request ligneKbartDto.setFirstAuthor((firstAuthor != null) ? firstAuthor : ""); boolean injectKafka = (force != null) ? force : false; boolean sendErrors = (errors != null) ? errors : false; - return service.getBestPpn(ligneKbartDto, provider, injectKafka, sendErrors); + PpnDto ppnDto = service.getBestPpn(ligneKbartDto, provider, injectKafka, sendErrors); + return new PpnControllerDto(ppnDto.getPpn(), ppnDto.getTypeSupport(), ppnDto.getError()); } catch (URISyntaxException e) { throw new IllegalArgumentException("Une url dans le champ title_url du kbart n'est pas correcte"); } catch (BestPpnException | RestClientException | IllegalArgumentException | IllegalDoiException e) { - return new PpnDto(e.getMessage()); + return new PpnControllerDto(e.getMessage()); } } } diff --git a/src/main/java/fr/abes/bestppn/dto/PpnControllerDto.java b/src/main/java/fr/abes/bestppn/dto/PpnControllerDto.java new file mode 100644 index 0000000..c772f4a --- /dev/null +++ b/src/main/java/fr/abes/bestppn/dto/PpnControllerDto.java @@ -0,0 +1,35 @@ +package fr.abes.bestppn.dto; + +import com.fasterxml.jackson.annotation.JsonInclude; +import fr.abes.bestppn.utils.TYPE_SUPPORT; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import org.springframework.lang.Nullable; + +@Getter +@Setter +@NoArgsConstructor +public class PpnControllerDto { + @Nullable + @JsonInclude(JsonInclude.Include.NON_NULL) + private String ppn; + + @Nullable + @JsonInclude(JsonInclude.Include.NON_NULL) + private TYPE_SUPPORT typeSupport; + + @Nullable + @JsonInclude(JsonInclude.Include.NON_NULL) + private String error; + + public PpnControllerDto (String ppn, TYPE_SUPPORT typeSupport, String error) { + this.ppn = ppn; + this.typeSupport = typeSupport; + this.error = error; + } + + public PpnControllerDto (String error) { + this.error = error; + } +} diff --git a/src/main/java/fr/abes/bestppn/dto/kafka/PpnDto.java b/src/main/java/fr/abes/bestppn/dto/kafka/PpnDto.java index 3753d3c..832f48e 100644 --- a/src/main/java/fr/abes/bestppn/dto/kafka/PpnDto.java +++ b/src/main/java/fr/abes/bestppn/dto/kafka/PpnDto.java @@ -6,8 +6,6 @@ import lombok.NoArgsConstructor; import lombok.Setter; import org.springframework.lang.Nullable; -import java.util.ArrayList; -import java.util.List; @Getter @Setter @@ -17,37 +15,36 @@ public class PpnDto { @Nullable private String ppn; + @Nullable private TYPE_SUPPORT typeSupport; + @Nullable private DESTINATION_TOPIC destination; + @Nullable private String error; - public PpnDto(String ppn, DESTINATION_TOPIC destination) { + public PpnDto (String ppn, DESTINATION_TOPIC destination) { this.ppn = ppn; this.destination = destination; } - public PpnDto(String ppn, DESTINATION_TOPIC destination, TYPE_SUPPORT typeSupport) { + public PpnDto (String ppn, DESTINATION_TOPIC destination, TYPE_SUPPORT typeSupport) { this.ppn = ppn; this.destination = destination; this.typeSupport = typeSupport; } - public PpnDto(String ppn, DESTINATION_TOPIC destination, String error) { + public PpnDto (String ppn, DESTINATION_TOPIC destination, String error) { this.ppn = ppn; this.destination = destination; this.error = error; } - public PpnDto(String ppn, DESTINATION_TOPIC destination, TYPE_SUPPORT typeSupport, String error) { + public PpnDto (String ppn, DESTINATION_TOPIC destination, TYPE_SUPPORT typeSupport, String error) { this.ppn = ppn; this.destination = destination; this.typeSupport = typeSupport; this.error = error; } - - public PpnDto (String error) { - this.error = error; - } } From cddcae5ba1db962f88f37764cab3c9ba7e85e2bf Mon Sep 17 00:00:00 2001 From: EryneKL <97091460+EryneKL@users.noreply.github.com> Date: Tue, 12 Dec 2023 09:08:32 +0100 Subject: [PATCH 05/12] =?UTF-8?q?FEAT=20:=20CDE-310=20ajouter=20erreurs=20?= =?UTF-8?q?dans=20retour=20du=20ws=20best=20ppn=20=20:=20=20=20=20=20=20-?= =?UTF-8?q?=20renommage=20des=20param=C3=A8tres=20"error"=20en=20"log"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/abes/bestppn/controller/BestPpnController.java | 4 ++-- .../java/fr/abes/bestppn/dto/PpnControllerDto.java | 10 +++++----- src/main/java/fr/abes/bestppn/dto/kafka/PpnDto.java | 10 +++++----- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/main/java/fr/abes/bestppn/controller/BestPpnController.java b/src/main/java/fr/abes/bestppn/controller/BestPpnController.java index 57cacb0..c5ca8f4 100644 --- a/src/main/java/fr/abes/bestppn/controller/BestPpnController.java +++ b/src/main/java/fr/abes/bestppn/controller/BestPpnController.java @@ -44,7 +44,7 @@ public PpnControllerDto bestPpn(@RequestParam(name = "provider") String provider @RequestParam(name = "print_identifier", required = false) String printIdentifier, @RequestParam(name = "titleUrl", required = false) String titleUrl, @RequestParam(name = "date_monograph_published_online", required = false) String dateMonographPublishedOnline, @RequestParam(name = "date_monograph_published_print", required = false) String dateMonographPublishedPrint, @RequestParam(name = "first_author", required = false) String firstAuthor, @RequestParam(name = "force", required = false) Boolean force, - @RequestParam(name = "errors", required = false) Boolean errors) throws IOException { + @RequestParam(name = "log", required = false) Boolean errors) throws IOException { try { LigneKbartDto ligneKbartDto = new LigneKbartDto(); ligneKbartDto.setPublicationType(publicationType); @@ -58,7 +58,7 @@ public PpnControllerDto bestPpn(@RequestParam(name = "provider") String provider boolean injectKafka = (force != null) ? force : false; boolean sendErrors = (errors != null) ? errors : false; PpnDto ppnDto = service.getBestPpn(ligneKbartDto, provider, injectKafka, sendErrors); - return new PpnControllerDto(ppnDto.getPpn(), ppnDto.getTypeSupport(), ppnDto.getError()); + return new PpnControllerDto(ppnDto.getPpn(), ppnDto.getTypeSupport(), ppnDto.getLog()); } catch (URISyntaxException e) { throw new IllegalArgumentException("Une url dans le champ title_url du kbart n'est pas correcte"); } catch (BestPpnException | RestClientException | IllegalArgumentException | IllegalDoiException e) { diff --git a/src/main/java/fr/abes/bestppn/dto/PpnControllerDto.java b/src/main/java/fr/abes/bestppn/dto/PpnControllerDto.java index c772f4a..9a0daff 100644 --- a/src/main/java/fr/abes/bestppn/dto/PpnControllerDto.java +++ b/src/main/java/fr/abes/bestppn/dto/PpnControllerDto.java @@ -21,15 +21,15 @@ public class PpnControllerDto { @Nullable @JsonInclude(JsonInclude.Include.NON_NULL) - private String error; + private String log; - public PpnControllerDto (String ppn, TYPE_SUPPORT typeSupport, String error) { + public PpnControllerDto (String ppn, TYPE_SUPPORT typeSupport, String log) { this.ppn = ppn; this.typeSupport = typeSupport; - this.error = error; + this.log = log; } - public PpnControllerDto (String error) { - this.error = error; + public PpnControllerDto (String log) { + this.log = log; } } diff --git a/src/main/java/fr/abes/bestppn/dto/kafka/PpnDto.java b/src/main/java/fr/abes/bestppn/dto/kafka/PpnDto.java index 832f48e..6118f26 100644 --- a/src/main/java/fr/abes/bestppn/dto/kafka/PpnDto.java +++ b/src/main/java/fr/abes/bestppn/dto/kafka/PpnDto.java @@ -22,7 +22,7 @@ public class PpnDto { private DESTINATION_TOPIC destination; @Nullable - private String error; + private String log; public PpnDto (String ppn, DESTINATION_TOPIC destination) { this.ppn = ppn; @@ -35,16 +35,16 @@ public PpnDto (String ppn, DESTINATION_TOPIC destination, TYPE_SUPPORT typeSuppo this.typeSupport = typeSupport; } - public PpnDto (String ppn, DESTINATION_TOPIC destination, String error) { + public PpnDto (String ppn, DESTINATION_TOPIC destination, String log) { this.ppn = ppn; this.destination = destination; - this.error = error; + this.log = log; } - public PpnDto (String ppn, DESTINATION_TOPIC destination, TYPE_SUPPORT typeSupport, String error) { + public PpnDto (String ppn, DESTINATION_TOPIC destination, TYPE_SUPPORT typeSupport, String log) { this.ppn = ppn; this.destination = destination; this.typeSupport = typeSupport; - this.error = error; + this.log = log; } } From d907e9e36158470cdba31d67b3a2c7dab64b8828 Mon Sep 17 00:00:00 2001 From: EryneKL <97091460+EryneKL@users.noreply.github.com> Date: Tue, 12 Dec 2023 11:02:14 +0100 Subject: [PATCH 06/12] =?UTF-8?q?FEAT=20:=20CDE-302=20acc=C3=A9der=20aux?= =?UTF-8?q?=20logs=20de=20l'algo=20vest-ppn=20sur=20la=20prod=20:=20=20=20?= =?UTF-8?q?=20=20=20-=20modification=20d'un=20param=C3=A8tre=20dans=20PpnD?= =?UTF-8?q?to.java=20=20=20=20=20=20-=20modification=20d'un=20param=C3=A8t?= =?UTF-8?q?re=20dans=20PpnControllerDto.java=20=20=20=20=20=20-=20adaptati?= =?UTF-8?q?on=20de=20BestPpnService.java=20et=20ajout=20des=20lignes=20de?= =?UTF-8?q?=20logs=20=20=20=20=20=20-=20adaptation=20du=20BestPpnControlle?= =?UTF-8?q?r.java=20et=20renommage=20de=20variable=20=20=20=20=20=20-=20ad?= =?UTF-8?q?aptation=20des=20TU?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bestppn/controller/BestPpnController.java | 14 +++-- .../fr/abes/bestppn/dto/PpnControllerDto.java | 12 ++-- .../fr/abes/bestppn/dto/kafka/PpnDto.java | 12 ++-- .../abes/bestppn/service/BestPpnService.java | 59 +++++++++++++------ .../bestppn/service/BestPpnServiceTest.java | 12 ++-- 5 files changed, 73 insertions(+), 36 deletions(-) diff --git a/src/main/java/fr/abes/bestppn/controller/BestPpnController.java b/src/main/java/fr/abes/bestppn/controller/BestPpnController.java index c5ca8f4..a4b0a57 100644 --- a/src/main/java/fr/abes/bestppn/controller/BestPpnController.java +++ b/src/main/java/fr/abes/bestppn/controller/BestPpnController.java @@ -17,6 +17,8 @@ import java.io.IOException; import java.net.URISyntaxException; +import java.util.ArrayList; +import java.util.List; @Tag(name = "Calcul du meilleur PPN", description = "API de calcul du meilleur PPN pour une ligne tsv") @CrossOrigin(origins = "*") @@ -44,7 +46,7 @@ public PpnControllerDto bestPpn(@RequestParam(name = "provider") String provider @RequestParam(name = "print_identifier", required = false) String printIdentifier, @RequestParam(name = "titleUrl", required = false) String titleUrl, @RequestParam(name = "date_monograph_published_online", required = false) String dateMonographPublishedOnline, @RequestParam(name = "date_monograph_published_print", required = false) String dateMonographPublishedPrint, @RequestParam(name = "first_author", required = false) String firstAuthor, @RequestParam(name = "force", required = false) Boolean force, - @RequestParam(name = "log", required = false) Boolean errors) throws IOException { + @RequestParam(name = "log", required = false) Boolean log) throws IOException { try { LigneKbartDto ligneKbartDto = new LigneKbartDto(); ligneKbartDto.setPublicationType(publicationType); @@ -56,13 +58,15 @@ public PpnControllerDto bestPpn(@RequestParam(name = "provider") String provider ligneKbartDto.setDateMonographPublishedOnline((dateMonographPublishedOnline != null) ? dateMonographPublishedOnline : ""); ligneKbartDto.setFirstAuthor((firstAuthor != null) ? firstAuthor : ""); boolean injectKafka = (force != null) ? force : false; - boolean sendErrors = (errors != null) ? errors : false; - PpnDto ppnDto = service.getBestPpn(ligneKbartDto, provider, injectKafka, sendErrors); - return new PpnControllerDto(ppnDto.getPpn(), ppnDto.getTypeSupport(), ppnDto.getLog()); + boolean sendLog = (log != null) ? log : false; + PpnDto ppnDto = service.getBestPpn(ligneKbartDto, provider, injectKafka, sendLog); + return new PpnControllerDto(ppnDto.getPpn(), ppnDto.getTypeSupport(), ppnDto.getLogs()); } catch (URISyntaxException e) { throw new IllegalArgumentException("Une url dans le champ title_url du kbart n'est pas correcte"); } catch (BestPpnException | RestClientException | IllegalArgumentException | IllegalDoiException e) { - return new PpnControllerDto(e.getMessage()); + List logs = new ArrayList<>(); + logs.add(e.getMessage()); + return new PpnControllerDto(logs); } } } diff --git a/src/main/java/fr/abes/bestppn/dto/PpnControllerDto.java b/src/main/java/fr/abes/bestppn/dto/PpnControllerDto.java index 9a0daff..a969e3c 100644 --- a/src/main/java/fr/abes/bestppn/dto/PpnControllerDto.java +++ b/src/main/java/fr/abes/bestppn/dto/PpnControllerDto.java @@ -7,6 +7,8 @@ import lombok.Setter; import org.springframework.lang.Nullable; +import java.util.List; + @Getter @Setter @NoArgsConstructor @@ -21,15 +23,15 @@ public class PpnControllerDto { @Nullable @JsonInclude(JsonInclude.Include.NON_NULL) - private String log; + private List logs; - public PpnControllerDto (String ppn, TYPE_SUPPORT typeSupport, String log) { + public PpnControllerDto (String ppn, TYPE_SUPPORT typeSupport, List logs) { this.ppn = ppn; this.typeSupport = typeSupport; - this.log = log; + this.logs = logs; } - public PpnControllerDto (String log) { - this.log = log; + public PpnControllerDto (List logs) { + this.logs = logs; } } diff --git a/src/main/java/fr/abes/bestppn/dto/kafka/PpnDto.java b/src/main/java/fr/abes/bestppn/dto/kafka/PpnDto.java index 6118f26..87bd419 100644 --- a/src/main/java/fr/abes/bestppn/dto/kafka/PpnDto.java +++ b/src/main/java/fr/abes/bestppn/dto/kafka/PpnDto.java @@ -7,6 +7,8 @@ import lombok.Setter; import org.springframework.lang.Nullable; +import java.util.List; + @Getter @Setter @NoArgsConstructor @@ -22,7 +24,7 @@ public class PpnDto { private DESTINATION_TOPIC destination; @Nullable - private String log; + private List logs; public PpnDto (String ppn, DESTINATION_TOPIC destination) { this.ppn = ppn; @@ -35,16 +37,16 @@ public PpnDto (String ppn, DESTINATION_TOPIC destination, TYPE_SUPPORT typeSuppo this.typeSupport = typeSupport; } - public PpnDto (String ppn, DESTINATION_TOPIC destination, String log) { + public PpnDto (String ppn, DESTINATION_TOPIC destination, List logs) { this.ppn = ppn; this.destination = destination; - this.log = log; + this.logs = logs; } - public PpnDto (String ppn, DESTINATION_TOPIC destination, TYPE_SUPPORT typeSupport, String log) { + public PpnDto (String ppn, DESTINATION_TOPIC destination, TYPE_SUPPORT typeSupport, List logs) { this.ppn = ppn; this.destination = destination; this.typeSupport = typeSupport; - this.log = log; + this.logs = logs; } } diff --git a/src/main/java/fr/abes/bestppn/service/BestPpnService.java b/src/main/java/fr/abes/bestppn/service/BestPpnService.java index 60dfb05..0e347a0 100644 --- a/src/main/java/fr/abes/bestppn/service/BestPpnService.java +++ b/src/main/java/fr/abes/bestppn/service/BestPpnService.java @@ -11,6 +11,7 @@ import fr.abes.bestppn.kafka.TopicProducer; import fr.abes.bestppn.utils.*; import lombok.Getter; +import lombok.Setter; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; @@ -18,10 +19,7 @@ import java.io.IOException; import java.net.URISyntaxException; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; +import java.util.*; @Service @Getter @@ -49,6 +47,10 @@ public class BestPpnService { private final CheckUrlService checkUrlService; + private List kbartLineLogs; + + @Setter + private Boolean sendLogs; public BestPpnService(WsService service, NoticeService noticeService, TopicProducer topicProducer, CheckUrlService checkUrlService) { this.service = service; @@ -57,18 +59,22 @@ public BestPpnService(WsService service, NoticeService noticeService, TopicProdu this.checkUrlService = checkUrlService; } - public PpnDto getBestPpn(LigneKbartDto kbart, String provider, boolean injectKafka, boolean sendErrors) throws IOException, BestPpnException, URISyntaxException, RestClientException, IllegalArgumentException, IllegalDoiException { + public PpnDto getBestPpn(LigneKbartDto kbart, String provider, boolean injectKafka, boolean sendLogs) throws IOException, BestPpnException, URISyntaxException, RestClientException, IllegalArgumentException, IllegalDoiException { + kbartLineLogs = new ArrayList<>(); + this.sendLogs = sendLogs; Map ppnElecScoredList = new HashMap<>(); Set ppnPrintResultList = new HashSet<>(); if (!kbart.getPublicationType().isEmpty()) { provider = kbart.getPublicationType().equals(PUBLICATION_TYPE.serial.toString()) ? "" : provider; if (kbart.getOnlineIdentifier() != null && !kbart.getOnlineIdentifier().isEmpty()) { + if (sendLogs) kbartLineLogs.add("paramètres en entrée : type : " + kbart.getPublicationType() + " / id : " + kbart.getOnlineIdentifier() + " / provider : " + provider); log.debug("paramètres en entrée : type : " + kbart.getPublicationType() + " / id : " + kbart.getOnlineIdentifier() + " / provider : " + provider); feedPpnListFromOnline(kbart, provider, ppnElecScoredList, ppnPrintResultList); } if (kbart.getPrintIdentifier() != null && !kbart.getPrintIdentifier().isEmpty()) { + if (sendLogs) kbartLineLogs.add("paramètres en entrée : type : " + kbart.getPublicationType() + " / id : " + kbart.getPrintIdentifier() + " / provider : " + provider); log.debug("paramètres en entrée : type : " + kbart.getPublicationType() + " / id : " + kbart.getPrintIdentifier() + " / provider : " + provider); feedPpnListFromPrint(kbart, provider, ppnElecScoredList, ppnPrintResultList); } @@ -82,10 +88,11 @@ public PpnDto getBestPpn(LigneKbartDto kbart, String provider, boolean injectKaf feedPpnListFromDat(kbart, ppnElecScoredList, ppnPrintResultList); } - return getBestPpnByScore(kbart, ppnElecScoredList, ppnPrintResultList, injectKafka, sendErrors); + return getBestPpnByScore(kbart, ppnElecScoredList, ppnPrintResultList, injectKafka); } private void feedPpnListFromOnline(LigneKbartDto kbart, String provider, Map ppnElecScoredList, Set ppnPrintResultList) throws IOException, URISyntaxException, IllegalArgumentException, BestPpnException { + if (sendLogs) kbartLineLogs.add("Entrée dans onlineId2Ppn"); log.debug("Entrée dans onlineId2Ppn"); try { setScoreToEveryPpnFromResultWS(service.callOnlineId2Ppn(kbart.getPublicationType(), kbart.getOnlineIdentifier(), provider), kbart.getTitleUrl(), this.scoreOnlineId2PpnElect, ppnElecScoredList, ppnPrintResultList); @@ -95,6 +102,7 @@ private void feedPpnListFromOnline(LigneKbartDto kbart, String provider, Map ppnElecScoredList, Set ppnPrintResultList) throws IOException, URISyntaxException, IllegalArgumentException, BestPpnException { + if (sendLogs) kbartLineLogs.add("Entrée dans printId2Ppn"); log.debug("Entrée dans printId2Ppn"); try { ResultWsSudocDto resultCallWs = service.callPrintId2Ppn(kbart.getPublicationType(), kbart.getPrintIdentifier(), provider); @@ -114,14 +122,17 @@ private void feedPpnListFromPrint(LigneKbartDto kbart, String provider, Map ppnElecScoredList, Set ppnPrintResultList) throws IOException { ResultDat2PpnWebDto resultDat2PpnWeb = null; if (!kbart.getAnneeFromDate_monograph_published_online().isEmpty()) { + if (sendLogs) kbartLineLogs.add("Appel dat2ppn : date_monograph_published_online : " + kbart.getAnneeFromDate_monograph_published_online() + " / publication_title : " + kbart.getPublicationTitle() + " auteur : " + kbart.getAuthor()); log.debug("Appel dat2ppn : date_monograph_published_online : " + kbart.getAnneeFromDate_monograph_published_online() + " / publication_title : " + kbart.getPublicationTitle() + " auteur : " + kbart.getAuthor()); resultDat2PpnWeb = service.callDat2Ppn(kbart.getAnneeFromDate_monograph_published_online(), kbart.getAuthor(), kbart.getPublicationTitle()); } else if (ppnElecScoredList.isEmpty() && !kbart.getAnneeFromDate_monograph_published_print().isEmpty()) { + if (sendLogs) kbartLineLogs.add("Appel dat2ppn : date_monograph_published_print : " + kbart.getAnneeFromDate_monograph_published_print() + " / publication_title : " + kbart.getPublicationTitle() + " auteur : " + kbart.getAuthor()); log.debug("Appel dat2ppn : date_monograph_published_print : " + kbart.getAnneeFromDate_monograph_published_print() + " / publication_title : " + kbart.getPublicationTitle() + " auteur : " + kbart.getAuthor()); resultDat2PpnWeb = service.callDat2Ppn(kbart.getAnneeFromDate_monograph_published_print(), kbart.getAuthor(), kbart.getPublicationTitle()); } if(resultDat2PpnWeb != null && !resultDat2PpnWeb.getPpns().isEmpty()) { for (String ppn : resultDat2PpnWeb.getPpns()) { + if (sendLogs) kbartLineLogs.add("résultat : ppn " + ppn); log.debug("résultat : ppn " + ppn); NoticeXml notice = noticeService.getNoticeByPpn(ppn); if (notice.isNoticeElectronique()) { @@ -140,6 +151,7 @@ private void feedPpnListFromDoi(String doi, String provider, Map ppnWithTypeDto.getTypeSupport().equals(TYPE_SUPPORT.ELECTRONIQUE)).count(); for (PpnWithTypeDto ppn : resultCallWs.getPpns()) { if(ppn.getTypeSupport().equals(TYPE_SUPPORT.IMPRIME)) { + if (sendLogs) kbartLineLogs.add("PPN Imprimé : " + ppn); log.info("PPN Imprimé : " + ppn); ppnPrintResultList.add(ppn.getPpn()); } else if (ppn.getTypeDocument() != TYPE_DOCUMENT.MONOGRAPHIE || ppn.isProviderPresent() || checkUrlService.checkUrlInNotice(ppn.getPpn(), titleUrl)){ setScoreToPpnElect(score, ppnElecResultList, nbPpnElec, ppn); } else { + if (sendLogs) kbartLineLogs.add("Le PPN " + ppn + " n'a pas de provider trouvé"); log.error("Le PPN " + ppn + " n'a pas de provider trouvé"); } } @@ -169,19 +183,21 @@ private void setScoreToPpnElect(int score, Map ppnElecScoredLis } else { ppnElecScoredList.put(ppn.getPpn(), (score / nbPpnElec)); } + if (sendLogs) kbartLineLogs.add("PPN Electronique : " + ppn + " / score : " + ppnElecScoredList.get(ppn.getPpn())); log.info("PPN Electronique : " + ppn + " / score : " + ppnElecScoredList.get(ppn.getPpn())); } - public PpnDto getBestPpnByScore(LigneKbartDto kbart, Map ppnElecResultList, Set ppnPrintResultList, boolean isForced, boolean sendErrors) throws BestPpnException { + public PpnDto getBestPpnByScore(LigneKbartDto kbart, Map ppnElecResultList, Set ppnPrintResultList, boolean isForced) throws BestPpnException { Map ppnElecScore = Utils.getMaxValuesFromMap(ppnElecResultList); return switch (ppnElecScore.size()) { case 0 -> { - log.info("Aucun ppn électronique trouvé." + kbart); + if (sendLogs) kbartLineLogs.add("Aucun ppn électronique trouvé. " + kbart); + log.info("Aucun ppn électronique trouvé. " + kbart); yield switch (ppnPrintResultList.size()) { case 0 -> { kbart.setErrorType("Aucun ppn trouvé"); - if(sendErrors) { - yield new PpnDto(null, DESTINATION_TOPIC.NO_PPN_FOUND_SUDOC, "Aucun ppn électronique trouvé."); + if(sendLogs) { + yield new PpnDto(null, DESTINATION_TOPIC.NO_PPN_FOUND_SUDOC, kbartLineLogs); } else { yield new PpnDto(null, DESTINATION_TOPIC.NO_PPN_FOUND_SUDOC); } @@ -189,8 +205,9 @@ yield switch (ppnPrintResultList.size()) { case 1 -> { kbart.setErrorType("Ppn imprimé trouvé : " + ppnPrintResultList.stream().toList().get(0)); - if(sendErrors) { - yield new PpnDto(ppnPrintResultList.stream().toList().get(0),DESTINATION_TOPIC.PRINT_PPN_SUDOC, TYPE_SUPPORT.IMPRIME, "Ppn imprimé trouvé à la place d'un ppn électronique : " + ppnPrintResultList.stream().toList().get(0)); + if(sendLogs) { + kbartLineLogs.add("Ppn imprimé trouvé : " + ppnPrintResultList.stream().toList().get(0)); + yield new PpnDto(ppnPrintResultList.stream().toList().get(0),DESTINATION_TOPIC.PRINT_PPN_SUDOC, TYPE_SUPPORT.IMPRIME, kbartLineLogs); } else { yield new PpnDto(ppnPrintResultList.stream().toList().get(0),DESTINATION_TOPIC.PRINT_PPN_SUDOC, TYPE_SUPPORT.IMPRIME); } @@ -202,8 +219,9 @@ yield switch (ppnPrintResultList.size()) { // vérification du forçage if (isForced) { log.error(errorString); - if (sendErrors) { - yield new PpnDto("",DESTINATION_TOPIC.BEST_PPN_BACON, "Plusieurs ppn imprimés (" + String.join(", ", ppnPrintResultList) + ") ont été trouvés."); + if (sendLogs) { + kbartLineLogs.add("Plusieurs ppn imprimés (" + String.join(", ", ppnPrintResultList) + ") ont été trouvés."); + yield new PpnDto("",DESTINATION_TOPIC.BEST_PPN_BACON, kbartLineLogs); } else { yield new PpnDto("",DESTINATION_TOPIC.BEST_PPN_BACON); } @@ -213,7 +231,13 @@ yield switch (ppnPrintResultList.size()) { } }; } - case 1 -> new PpnDto(ppnElecScore.keySet().stream().findFirst().get(), DESTINATION_TOPIC.BEST_PPN_BACON, TYPE_SUPPORT.ELECTRONIQUE); + case 1 -> { + if (sendLogs) { + yield new PpnDto(ppnElecScore.keySet().stream().findFirst().get(), DESTINATION_TOPIC.BEST_PPN_BACON, TYPE_SUPPORT.ELECTRONIQUE, kbartLineLogs); + } else { + yield new PpnDto(ppnElecScore.keySet().stream().findFirst().get(), DESTINATION_TOPIC.BEST_PPN_BACON, TYPE_SUPPORT.ELECTRONIQUE); + } + } default -> { String listPpn = String.join(", ", ppnElecScore.keySet()); @@ -222,8 +246,9 @@ yield switch (ppnPrintResultList.size()) { // vérification du forçage if (isForced) { log.error(errorString); - if (sendErrors) { - yield new PpnDto("", DESTINATION_TOPIC.BEST_PPN_BACON, errorString); + if (sendLogs) { + kbartLineLogs.add(errorString); + yield new PpnDto("", DESTINATION_TOPIC.BEST_PPN_BACON, kbartLineLogs); } else { yield new PpnDto("", DESTINATION_TOPIC.BEST_PPN_BACON); } diff --git a/src/test/java/fr/abes/bestppn/service/BestPpnServiceTest.java b/src/test/java/fr/abes/bestppn/service/BestPpnServiceTest.java index ccb7ed5..f0620e8 100644 --- a/src/test/java/fr/abes/bestppn/service/BestPpnServiceTest.java +++ b/src/test/java/fr/abes/bestppn/service/BestPpnServiceTest.java @@ -629,7 +629,8 @@ void bestPpnWithScoreTest1() throws BestPpnException { ppnElecResultList.put("100000001", 10); Set ppnPrintResultList = new HashSet<>(); - PpnDto result = bestPpnService.getBestPpnByScore(kbart, ppnElecResultList, ppnPrintResultList, false, false); + bestPpnService.setSendLogs(false); + PpnDto result = bestPpnService.getBestPpnByScore(kbart, ppnElecResultList, ppnPrintResultList, false); Assertions.assertEquals("100000001", result.getPpn()); Assertions.assertEquals(DESTINATION_TOPIC.BEST_PPN_BACON, result.getDestination()); } @@ -643,7 +644,8 @@ void bestPpnWithScoreTest2() throws BestPpnException { ppnElecResultList.put("100000002", 10); Set ppnPrintResultList = new HashSet<>(); - PpnDto result = bestPpnService.getBestPpnByScore(kbart, ppnElecResultList, ppnPrintResultList, false, false); + bestPpnService.setSendLogs(false); + PpnDto result = bestPpnService.getBestPpnByScore(kbart, ppnElecResultList, ppnPrintResultList, false); Assertions.assertEquals("100000002", result.getPpn()); Assertions.assertEquals(DESTINATION_TOPIC.BEST_PPN_BACON, result.getDestination()); } @@ -657,7 +659,8 @@ void bestPpnWithScoreTest3() throws BestPpnException { ppnElecResultList.put("100000002", 10); Set ppnPrintResultList = new HashSet<>(); - PpnDto result = bestPpnService.getBestPpnByScore(kbart, ppnElecResultList, ppnPrintResultList, true, false); + bestPpnService.setSendLogs(false); + PpnDto result = bestPpnService.getBestPpnByScore(kbart, ppnElecResultList, ppnPrintResultList, true); Assertions.assertEquals("", result.getPpn()); } @@ -672,7 +675,8 @@ void bestPpnWithScoreTest4() throws BestPpnException { ppnPrintResultList.add("100000001"); ppnPrintResultList.add("100000002"); - PpnDto result = bestPpnService.getBestPpnByScore(kbart, ppnElecResultList, ppnPrintResultList, true, false); + bestPpnService.setSendLogs(false); + PpnDto result = bestPpnService.getBestPpnByScore(kbart, ppnElecResultList, ppnPrintResultList, true); Assertions.assertEquals("", result.getPpn()); } From c933c04c7f7490698ddd3a11419fd54fb9818cc9 Mon Sep 17 00:00:00 2001 From: EryneKL <97091460+EryneKL@users.noreply.github.com> Date: Tue, 12 Dec 2023 12:14:38 +0100 Subject: [PATCH 07/12] =?UTF-8?q?FEAT=20:=20CDE-302=20acc=C3=A9der=20aux?= =?UTF-8?q?=20logs=20de=20l'algo=20vest-ppn=20sur=20la=20prod=20:=20=20=20?= =?UTF-8?q?=20=20=20-=20renommage=20de=20la=20classe=20PpnDto.java=20en=20?= =?UTF-8?q?BestPpn.java=20et=20d=C3=A9placemment=20dans=20le=20package=20\?= =?UTF-8?q?model=20=20=20=20=20=20-=20renommage=20de=20la=20classe=20PpnCo?= =?UTF-8?q?ntrollerDto.java=20en=20BestPpnDto.java?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bestppn/controller/BestPpnController.java | 22 +++---- ...{PpnControllerDto.java => BestPpnDto.java} | 6 +- .../kafka/PpnDto.java => model/BestPpn.java} | 12 ++-- .../abes/bestppn/service/BestPpnService.java | 65 ++++++++++--------- .../fr/abes/bestppn/service/KbartService.java | 14 ++-- .../controller/BestPpnControllerTest.java | 7 +- .../bestppn/service/BestPpnServiceTest.java | 36 +++++----- 7 files changed, 83 insertions(+), 79 deletions(-) rename src/main/java/fr/abes/bestppn/dto/{PpnControllerDto.java => BestPpnDto.java} (80%) rename src/main/java/fr/abes/bestppn/{dto/kafka/PpnDto.java => model/BestPpn.java} (75%) diff --git a/src/main/java/fr/abes/bestppn/controller/BestPpnController.java b/src/main/java/fr/abes/bestppn/controller/BestPpnController.java index a4b0a57..38dfa53 100644 --- a/src/main/java/fr/abes/bestppn/controller/BestPpnController.java +++ b/src/main/java/fr/abes/bestppn/controller/BestPpnController.java @@ -1,8 +1,8 @@ package fr.abes.bestppn.controller; -import fr.abes.bestppn.dto.PpnControllerDto; +import fr.abes.bestppn.dto.BestPpnDto; import fr.abes.bestppn.dto.kafka.LigneKbartDto; -import fr.abes.bestppn.dto.kafka.PpnDto; +import fr.abes.bestppn.model.BestPpn; import fr.abes.bestppn.exception.BestPpnException; import fr.abes.bestppn.exception.IllegalDoiException; import fr.abes.bestppn.service.BestPpnService; @@ -41,12 +41,12 @@ public BestPpnController(BestPpnService service) { } ) @GetMapping(value = "/bestPpn") - public PpnControllerDto bestPpn(@RequestParam(name = "provider") String provider, @RequestParam(name = "publication_title", required = false) String publicationTitle, - @RequestParam(name = "publication_type") String publicationType, @RequestParam(name = "online_identifier", required = false) String onlineIdentifier, - @RequestParam(name = "print_identifier", required = false) String printIdentifier, @RequestParam(name = "titleUrl", required = false) String titleUrl, - @RequestParam(name = "date_monograph_published_online", required = false) String dateMonographPublishedOnline, @RequestParam(name = "date_monograph_published_print", required = false) String dateMonographPublishedPrint, - @RequestParam(name = "first_author", required = false) String firstAuthor, @RequestParam(name = "force", required = false) Boolean force, - @RequestParam(name = "log", required = false) Boolean log) throws IOException { + public BestPpnDto bestPpn(@RequestParam(name = "provider") String provider, @RequestParam(name = "publication_title", required = false) String publicationTitle, + @RequestParam(name = "publication_type") String publicationType, @RequestParam(name = "online_identifier", required = false) String onlineIdentifier, + @RequestParam(name = "print_identifier", required = false) String printIdentifier, @RequestParam(name = "titleUrl", required = false) String titleUrl, + @RequestParam(name = "date_monograph_published_online", required = false) String dateMonographPublishedOnline, @RequestParam(name = "date_monograph_published_print", required = false) String dateMonographPublishedPrint, + @RequestParam(name = "first_author", required = false) String firstAuthor, @RequestParam(name = "force", required = false) Boolean force, + @RequestParam(name = "log", required = false) Boolean log) throws IOException { try { LigneKbartDto ligneKbartDto = new LigneKbartDto(); ligneKbartDto.setPublicationType(publicationType); @@ -59,14 +59,14 @@ public PpnControllerDto bestPpn(@RequestParam(name = "provider") String provider ligneKbartDto.setFirstAuthor((firstAuthor != null) ? firstAuthor : ""); boolean injectKafka = (force != null) ? force : false; boolean sendLog = (log != null) ? log : false; - PpnDto ppnDto = service.getBestPpn(ligneKbartDto, provider, injectKafka, sendLog); - return new PpnControllerDto(ppnDto.getPpn(), ppnDto.getTypeSupport(), ppnDto.getLogs()); + BestPpn bestPpn = service.getBestPpn(ligneKbartDto, provider, injectKafka, sendLog); + return new BestPpnDto(bestPpn.getPpn(), bestPpn.getTypeSupport(), bestPpn.getLogs()); } catch (URISyntaxException e) { throw new IllegalArgumentException("Une url dans le champ title_url du kbart n'est pas correcte"); } catch (BestPpnException | RestClientException | IllegalArgumentException | IllegalDoiException e) { List logs = new ArrayList<>(); logs.add(e.getMessage()); - return new PpnControllerDto(logs); + return new BestPpnDto(logs); } } } diff --git a/src/main/java/fr/abes/bestppn/dto/PpnControllerDto.java b/src/main/java/fr/abes/bestppn/dto/BestPpnDto.java similarity index 80% rename from src/main/java/fr/abes/bestppn/dto/PpnControllerDto.java rename to src/main/java/fr/abes/bestppn/dto/BestPpnDto.java index a969e3c..833f544 100644 --- a/src/main/java/fr/abes/bestppn/dto/PpnControllerDto.java +++ b/src/main/java/fr/abes/bestppn/dto/BestPpnDto.java @@ -12,7 +12,7 @@ @Getter @Setter @NoArgsConstructor -public class PpnControllerDto { +public class BestPpnDto { @Nullable @JsonInclude(JsonInclude.Include.NON_NULL) private String ppn; @@ -25,13 +25,13 @@ public class PpnControllerDto { @JsonInclude(JsonInclude.Include.NON_NULL) private List logs; - public PpnControllerDto (String ppn, TYPE_SUPPORT typeSupport, List logs) { + public BestPpnDto(String ppn, TYPE_SUPPORT typeSupport, List logs) { this.ppn = ppn; this.typeSupport = typeSupport; this.logs = logs; } - public PpnControllerDto (List logs) { + public BestPpnDto(List logs) { this.logs = logs; } } diff --git a/src/main/java/fr/abes/bestppn/dto/kafka/PpnDto.java b/src/main/java/fr/abes/bestppn/model/BestPpn.java similarity index 75% rename from src/main/java/fr/abes/bestppn/dto/kafka/PpnDto.java rename to src/main/java/fr/abes/bestppn/model/BestPpn.java index 87bd419..c5878b6 100644 --- a/src/main/java/fr/abes/bestppn/dto/kafka/PpnDto.java +++ b/src/main/java/fr/abes/bestppn/model/BestPpn.java @@ -1,4 +1,4 @@ -package fr.abes.bestppn.dto.kafka; +package fr.abes.bestppn.model; import fr.abes.bestppn.utils.DESTINATION_TOPIC; import fr.abes.bestppn.utils.TYPE_SUPPORT; @@ -12,7 +12,7 @@ @Getter @Setter @NoArgsConstructor -public class PpnDto { +public class BestPpn { @Nullable private String ppn; @@ -26,24 +26,24 @@ public class PpnDto { @Nullable private List logs; - public PpnDto (String ppn, DESTINATION_TOPIC destination) { + public BestPpn(String ppn, DESTINATION_TOPIC destination) { this.ppn = ppn; this.destination = destination; } - public PpnDto (String ppn, DESTINATION_TOPIC destination, TYPE_SUPPORT typeSupport) { + public BestPpn(String ppn, DESTINATION_TOPIC destination, TYPE_SUPPORT typeSupport) { this.ppn = ppn; this.destination = destination; this.typeSupport = typeSupport; } - public PpnDto (String ppn, DESTINATION_TOPIC destination, List logs) { + public BestPpn(String ppn, DESTINATION_TOPIC destination, List logs) { this.ppn = ppn; this.destination = destination; this.logs = logs; } - public PpnDto (String ppn, DESTINATION_TOPIC destination, TYPE_SUPPORT typeSupport, List logs) { + public BestPpn(String ppn, DESTINATION_TOPIC destination, TYPE_SUPPORT typeSupport, List logs) { this.ppn = ppn; this.destination = destination; this.typeSupport = typeSupport; diff --git a/src/main/java/fr/abes/bestppn/service/BestPpnService.java b/src/main/java/fr/abes/bestppn/service/BestPpnService.java index 0e347a0..0696491 100644 --- a/src/main/java/fr/abes/bestppn/service/BestPpnService.java +++ b/src/main/java/fr/abes/bestppn/service/BestPpnService.java @@ -1,7 +1,7 @@ package fr.abes.bestppn.service; import fr.abes.bestppn.dto.kafka.LigneKbartDto; -import fr.abes.bestppn.dto.kafka.PpnDto; +import fr.abes.bestppn.model.BestPpn; import fr.abes.bestppn.dto.wscall.PpnWithTypeDto; import fr.abes.bestppn.dto.wscall.ResultDat2PpnWebDto; import fr.abes.bestppn.dto.wscall.ResultWsSudocDto; @@ -50,7 +50,7 @@ public class BestPpnService { private List kbartLineLogs; @Setter - private Boolean sendLogs; + private Boolean isSendLogs; public BestPpnService(WsService service, NoticeService noticeService, TopicProducer topicProducer, CheckUrlService checkUrlService) { this.service = service; @@ -59,10 +59,10 @@ public BestPpnService(WsService service, NoticeService noticeService, TopicProdu this.checkUrlService = checkUrlService; } - public PpnDto getBestPpn(LigneKbartDto kbart, String provider, boolean injectKafka, boolean sendLogs) throws IOException, BestPpnException, URISyntaxException, RestClientException, IllegalArgumentException, IllegalDoiException { + public BestPpn getBestPpn(LigneKbartDto kbart, String provider, boolean injectKafka, boolean sendLogs) throws IOException, BestPpnException, URISyntaxException, RestClientException, IllegalArgumentException, IllegalDoiException { kbartLineLogs = new ArrayList<>(); - this.sendLogs = sendLogs; + this.isSendLogs = sendLogs; Map ppnElecScoredList = new HashMap<>(); Set ppnPrintResultList = new HashSet<>(); @@ -92,7 +92,7 @@ public PpnDto getBestPpn(LigneKbartDto kbart, String provider, boolean injectKaf } private void feedPpnListFromOnline(LigneKbartDto kbart, String provider, Map ppnElecScoredList, Set ppnPrintResultList) throws IOException, URISyntaxException, IllegalArgumentException, BestPpnException { - if (sendLogs) kbartLineLogs.add("Entrée dans onlineId2Ppn"); + if (isSendLogs) kbartLineLogs.add("Entrée dans onlineId2Ppn"); log.debug("Entrée dans onlineId2Ppn"); try { setScoreToEveryPpnFromResultWS(service.callOnlineId2Ppn(kbart.getPublicationType(), kbart.getOnlineIdentifier(), provider), kbart.getTitleUrl(), this.scoreOnlineId2PpnElect, ppnElecScoredList, ppnPrintResultList); @@ -102,7 +102,7 @@ private void feedPpnListFromOnline(LigneKbartDto kbart, String provider, Map ppnElecScoredList, Set ppnPrintResultList) throws IOException, URISyntaxException, IllegalArgumentException, BestPpnException { - if (sendLogs) kbartLineLogs.add("Entrée dans printId2Ppn"); + if (isSendLogs) kbartLineLogs.add("Entrée dans printId2Ppn"); log.debug("Entrée dans printId2Ppn"); try { ResultWsSudocDto resultCallWs = service.callPrintId2Ppn(kbart.getPublicationType(), kbart.getPrintIdentifier(), provider); @@ -122,17 +122,17 @@ private void feedPpnListFromPrint(LigneKbartDto kbart, String provider, Map ppnElecScoredList, Set ppnPrintResultList) throws IOException { ResultDat2PpnWebDto resultDat2PpnWeb = null; if (!kbart.getAnneeFromDate_monograph_published_online().isEmpty()) { - if (sendLogs) kbartLineLogs.add("Appel dat2ppn : date_monograph_published_online : " + kbart.getAnneeFromDate_monograph_published_online() + " / publication_title : " + kbart.getPublicationTitle() + " auteur : " + kbart.getAuthor()); + if (isSendLogs) kbartLineLogs.add("Appel dat2ppn : date_monograph_published_online : " + kbart.getAnneeFromDate_monograph_published_online() + " / publication_title : " + kbart.getPublicationTitle() + " auteur : " + kbart.getAuthor()); log.debug("Appel dat2ppn : date_monograph_published_online : " + kbart.getAnneeFromDate_monograph_published_online() + " / publication_title : " + kbart.getPublicationTitle() + " auteur : " + kbart.getAuthor()); resultDat2PpnWeb = service.callDat2Ppn(kbart.getAnneeFromDate_monograph_published_online(), kbart.getAuthor(), kbart.getPublicationTitle()); } else if (ppnElecScoredList.isEmpty() && !kbart.getAnneeFromDate_monograph_published_print().isEmpty()) { - if (sendLogs) kbartLineLogs.add("Appel dat2ppn : date_monograph_published_print : " + kbart.getAnneeFromDate_monograph_published_print() + " / publication_title : " + kbart.getPublicationTitle() + " auteur : " + kbart.getAuthor()); + if (isSendLogs) kbartLineLogs.add("Appel dat2ppn : date_monograph_published_print : " + kbart.getAnneeFromDate_monograph_published_print() + " / publication_title : " + kbart.getPublicationTitle() + " auteur : " + kbart.getAuthor()); log.debug("Appel dat2ppn : date_monograph_published_print : " + kbart.getAnneeFromDate_monograph_published_print() + " / publication_title : " + kbart.getPublicationTitle() + " auteur : " + kbart.getAuthor()); resultDat2PpnWeb = service.callDat2Ppn(kbart.getAnneeFromDate_monograph_published_print(), kbart.getAuthor(), kbart.getPublicationTitle()); } if(resultDat2PpnWeb != null && !resultDat2PpnWeb.getPpns().isEmpty()) { for (String ppn : resultDat2PpnWeb.getPpns()) { - if (sendLogs) kbartLineLogs.add("résultat : ppn " + ppn); + if (isSendLogs) kbartLineLogs.add("résultat : ppn " + ppn); log.debug("résultat : ppn " + ppn); NoticeXml notice = noticeService.getNoticeByPpn(ppn); if (notice.isNoticeElectronique()) { @@ -151,7 +151,7 @@ private void feedPpnListFromDoi(String doi, String provider, Map ppnWithTypeDto.getTypeSupport().equals(TYPE_SUPPORT.ELECTRONIQUE)).count(); for (PpnWithTypeDto ppn : resultCallWs.getPpns()) { if(ppn.getTypeSupport().equals(TYPE_SUPPORT.IMPRIME)) { - if (sendLogs) kbartLineLogs.add("PPN Imprimé : " + ppn); + if (isSendLogs) kbartLineLogs.add("PPN Imprimé : " + ppn); log.info("PPN Imprimé : " + ppn); ppnPrintResultList.add(ppn.getPpn()); } else if (ppn.getTypeDocument() != TYPE_DOCUMENT.MONOGRAPHIE || ppn.isProviderPresent() || checkUrlService.checkUrlInNotice(ppn.getPpn(), titleUrl)){ setScoreToPpnElect(score, ppnElecResultList, nbPpnElec, ppn); } else { - if (sendLogs) kbartLineLogs.add("Le PPN " + ppn + " n'a pas de provider trouvé"); + if (isSendLogs) kbartLineLogs.add("Le PPN " + ppn + " n'a pas de provider trouvé"); log.error("Le PPN " + ppn + " n'a pas de provider trouvé"); } } @@ -183,33 +183,33 @@ private void setScoreToPpnElect(int score, Map ppnElecScoredLis } else { ppnElecScoredList.put(ppn.getPpn(), (score / nbPpnElec)); } - if (sendLogs) kbartLineLogs.add("PPN Electronique : " + ppn + " / score : " + ppnElecScoredList.get(ppn.getPpn())); + if (isSendLogs) kbartLineLogs.add("PPN Electronique : " + ppn + " / score : " + ppnElecScoredList.get(ppn.getPpn())); log.info("PPN Electronique : " + ppn + " / score : " + ppnElecScoredList.get(ppn.getPpn())); } - public PpnDto getBestPpnByScore(LigneKbartDto kbart, Map ppnElecResultList, Set ppnPrintResultList, boolean isForced) throws BestPpnException { + public BestPpn getBestPpnByScore(LigneKbartDto kbart, Map ppnElecResultList, Set ppnPrintResultList, boolean isForced) throws BestPpnException { Map ppnElecScore = Utils.getMaxValuesFromMap(ppnElecResultList); return switch (ppnElecScore.size()) { case 0 -> { - if (sendLogs) kbartLineLogs.add("Aucun ppn électronique trouvé. " + kbart); + if (isSendLogs) kbartLineLogs.add("Aucun ppn électronique trouvé. " + kbart); log.info("Aucun ppn électronique trouvé. " + kbart); yield switch (ppnPrintResultList.size()) { case 0 -> { kbart.setErrorType("Aucun ppn trouvé"); - if(sendLogs) { - yield new PpnDto(null, DESTINATION_TOPIC.NO_PPN_FOUND_SUDOC, kbartLineLogs); + if(isSendLogs) { + yield new BestPpn(null, DESTINATION_TOPIC.NO_PPN_FOUND_SUDOC, kbartLineLogs); } else { - yield new PpnDto(null, DESTINATION_TOPIC.NO_PPN_FOUND_SUDOC); + yield new BestPpn(null, DESTINATION_TOPIC.NO_PPN_FOUND_SUDOC); } } case 1 -> { kbart.setErrorType("Ppn imprimé trouvé : " + ppnPrintResultList.stream().toList().get(0)); - if(sendLogs) { + if(isSendLogs) { kbartLineLogs.add("Ppn imprimé trouvé : " + ppnPrintResultList.stream().toList().get(0)); - yield new PpnDto(ppnPrintResultList.stream().toList().get(0),DESTINATION_TOPIC.PRINT_PPN_SUDOC, TYPE_SUPPORT.IMPRIME, kbartLineLogs); + yield new BestPpn(ppnPrintResultList.stream().toList().get(0),DESTINATION_TOPIC.PRINT_PPN_SUDOC, TYPE_SUPPORT.IMPRIME, kbartLineLogs); } else { - yield new PpnDto(ppnPrintResultList.stream().toList().get(0),DESTINATION_TOPIC.PRINT_PPN_SUDOC, TYPE_SUPPORT.IMPRIME); + yield new BestPpn(ppnPrintResultList.stream().toList().get(0),DESTINATION_TOPIC.PRINT_PPN_SUDOC, TYPE_SUPPORT.IMPRIME); } } @@ -219,11 +219,11 @@ yield switch (ppnPrintResultList.size()) { // vérification du forçage if (isForced) { log.error(errorString); - if (sendLogs) { + if (isSendLogs) { kbartLineLogs.add("Plusieurs ppn imprimés (" + String.join(", ", ppnPrintResultList) + ") ont été trouvés."); - yield new PpnDto("",DESTINATION_TOPIC.BEST_PPN_BACON, kbartLineLogs); + yield new BestPpn("",DESTINATION_TOPIC.BEST_PPN_BACON, kbartLineLogs); } else { - yield new PpnDto("",DESTINATION_TOPIC.BEST_PPN_BACON); + yield new BestPpn("",DESTINATION_TOPIC.BEST_PPN_BACON); } } else { throw new BestPpnException(errorString); @@ -232,10 +232,10 @@ yield switch (ppnPrintResultList.size()) { }; } case 1 -> { - if (sendLogs) { - yield new PpnDto(ppnElecScore.keySet().stream().findFirst().get(), DESTINATION_TOPIC.BEST_PPN_BACON, TYPE_SUPPORT.ELECTRONIQUE, kbartLineLogs); + if (isSendLogs) { + yield new BestPpn(ppnElecScore.keySet().stream().findFirst().get(), DESTINATION_TOPIC.BEST_PPN_BACON, TYPE_SUPPORT.ELECTRONIQUE, kbartLineLogs); } else { - yield new PpnDto(ppnElecScore.keySet().stream().findFirst().get(), DESTINATION_TOPIC.BEST_PPN_BACON, TYPE_SUPPORT.ELECTRONIQUE); + yield new BestPpn(ppnElecScore.keySet().stream().findFirst().get(), DESTINATION_TOPIC.BEST_PPN_BACON, TYPE_SUPPORT.ELECTRONIQUE); } } @@ -246,11 +246,11 @@ yield switch (ppnPrintResultList.size()) { // vérification du forçage if (isForced) { log.error(errorString); - if (sendLogs) { + if (isSendLogs) { kbartLineLogs.add(errorString); - yield new PpnDto("", DESTINATION_TOPIC.BEST_PPN_BACON, kbartLineLogs); + yield new BestPpn("", DESTINATION_TOPIC.BEST_PPN_BACON, kbartLineLogs); } else { - yield new PpnDto("", DESTINATION_TOPIC.BEST_PPN_BACON); + yield new BestPpn("", DESTINATION_TOPIC.BEST_PPN_BACON); } } else { throw new BestPpnException(errorString); @@ -258,4 +258,9 @@ yield switch (ppnPrintResultList.size()) { } }; } + + public void sendLog(String log, Boolean sendlogs) { + + } + } diff --git a/src/main/java/fr/abes/bestppn/service/KbartService.java b/src/main/java/fr/abes/bestppn/service/KbartService.java index 4d2bf1b..b4ab032 100644 --- a/src/main/java/fr/abes/bestppn/service/KbartService.java +++ b/src/main/java/fr/abes/bestppn/service/KbartService.java @@ -2,7 +2,7 @@ import fr.abes.LigneKbartImprime; import fr.abes.bestppn.dto.kafka.LigneKbartDto; -import fr.abes.bestppn.dto.kafka.PpnDto; +import fr.abes.bestppn.model.BestPpn; import fr.abes.bestppn.entity.bacon.Provider; import fr.abes.bestppn.entity.bacon.ProviderPackage; import fr.abes.bestppn.exception.BestPpnException; @@ -59,13 +59,13 @@ public void processConsumerRecord(LigneKbartDto ligneFromKafka, String providerN log.info("Début calcul BestPpn pour la ligne " + ligneFromKafka); if (ligneFromKafka.isBestPpnEmpty()) { log.info(ligneFromKafka.toString()); - PpnDto ppnDto = service.getBestPpn(ligneFromKafka, providerName, isForced, false); - switch (ppnDto.getDestination()) { + BestPpn bestPpn = service.getBestPpn(ligneFromKafka, providerName, isForced, false); + switch (bestPpn.getDestination()) { case BEST_PPN_BACON -> { - ligneFromKafka.setBestPpn(ppnDto.getPpn()); + ligneFromKafka.setBestPpn(bestPpn.getPpn()); executionReportService.addNbBestPpnFind(); } - case PRINT_PPN_SUDOC -> ppnToCreate.add(getLigneKbartImprime(ppnDto, ligneFromKafka)); + case PRINT_PPN_SUDOC -> ppnToCreate.add(getLigneKbartImprime(bestPpn, ligneFromKafka)); case NO_PPN_FOUND_SUDOC -> { if (ligneFromKafka.getPublicationType().equals("monograph")) { ppnFromKbartToCreate.add(ligneFromKafka); @@ -95,9 +95,9 @@ public void clearListesKbart() { ppnFromKbartToCreate.clear(); } - private static LigneKbartImprime getLigneKbartImprime(PpnDto ppnDto, LigneKbartDto ligneFromKafka) { + private static LigneKbartImprime getLigneKbartImprime(BestPpn bestPpn, LigneKbartDto ligneFromKafka) { return LigneKbartImprime.newBuilder() - .setPpn(ppnDto.getPpn()) + .setPpn(bestPpn.getPpn()) .setPublicationTitle(ligneFromKafka.getPublicationTitle()) .setPrintIdentifier(ligneFromKafka.getPrintIdentifier()) .setOnlineIdentifier(ligneFromKafka.getOnlineIdentifier()) diff --git a/src/test/java/fr/abes/bestppn/controller/BestPpnControllerTest.java b/src/test/java/fr/abes/bestppn/controller/BestPpnControllerTest.java index cf0a10d..608e992 100644 --- a/src/test/java/fr/abes/bestppn/controller/BestPpnControllerTest.java +++ b/src/test/java/fr/abes/bestppn/controller/BestPpnControllerTest.java @@ -3,10 +3,9 @@ import com.fasterxml.jackson.databind.ObjectMapper; import fr.abes.bestppn.configuration.MapperConfig; import fr.abes.bestppn.configuration.RestConfiguration; -import fr.abes.bestppn.dto.kafka.PpnDto; +import fr.abes.bestppn.model.BestPpn; import fr.abes.bestppn.exception.BestPpnException; import fr.abes.bestppn.exception.ExceptionControllerHandler; -import fr.abes.bestppn.exception.IllegalDoiException; import fr.abes.bestppn.service.BestPpnService; import fr.abes.bestppn.utils.DESTINATION_TOPIC; import org.junit.jupiter.api.Assertions; @@ -60,7 +59,7 @@ void init() { @Test @DisplayName("test controller with wrong number of parameters") void testBestPpnControllerWrongNumberOfParameters() throws Exception { - Mockito.when(service.getBestPpn(Mockito.any(), Mockito.anyString(), Mockito.anyBoolean(), Mockito.anyBoolean())).thenReturn(new PpnDto("1111111111", DESTINATION_TOPIC.BEST_PPN_BACON)); + Mockito.when(service.getBestPpn(Mockito.any(), Mockito.anyString(), Mockito.anyBoolean(), Mockito.anyBoolean())).thenReturn(new BestPpn("1111111111", DESTINATION_TOPIC.BEST_PPN_BACON)); this.mockMvc.perform(get("/api/v1/bestPpn").characterEncoding(StandardCharsets.UTF_8)) .andExpect(status().isBadRequest()) .andExpect(result -> Assertions.assertTrue((result.getResolvedException() instanceof MissingServletRequestParameterException))) @@ -94,7 +93,7 @@ void testBestPpnControllerBestPpnException() throws Exception { @Test @DisplayName("test controller Ok") void testBestPpnControllerOk() throws Exception { - Mockito.when(service.getBestPpn(Mockito.any(), Mockito.anyString(), Mockito.anyBoolean(), Mockito.anyBoolean())).thenReturn(new PpnDto("1111111111", DESTINATION_TOPIC.BEST_PPN_BACON)); + Mockito.when(service.getBestPpn(Mockito.any(), Mockito.anyString(), Mockito.anyBoolean(), Mockito.anyBoolean())).thenReturn(new BestPpn("1111111111", DESTINATION_TOPIC.BEST_PPN_BACON)); this.mockMvc.perform(get("/api/v1/bestPpn?provider=cairn&publication_type=monograph&print_identifier=9781111111111&title_url=test").characterEncoding(StandardCharsets.UTF_8)) .andExpect(status().isOk()) .andExpect(result -> Assertions.assertTrue(result.getResponse().getContentAsString(StandardCharsets.UTF_8).contains("111111111"))); diff --git a/src/test/java/fr/abes/bestppn/service/BestPpnServiceTest.java b/src/test/java/fr/abes/bestppn/service/BestPpnServiceTest.java index f0620e8..155e963 100644 --- a/src/test/java/fr/abes/bestppn/service/BestPpnServiceTest.java +++ b/src/test/java/fr/abes/bestppn/service/BestPpnServiceTest.java @@ -3,7 +3,7 @@ import com.fasterxml.jackson.dataformat.xml.JacksonXmlModule; import com.fasterxml.jackson.dataformat.xml.XmlMapper; import fr.abes.bestppn.dto.kafka.LigneKbartDto; -import fr.abes.bestppn.dto.kafka.PpnDto; +import fr.abes.bestppn.model.BestPpn; import fr.abes.bestppn.dto.wscall.PpnWithTypeDto; import fr.abes.bestppn.dto.wscall.ResultDat2PpnWebDto; import fr.abes.bestppn.dto.wscall.ResultWsSudocDto; @@ -122,7 +122,7 @@ void getBestPpnTest01() throws IOException, BestPpnException, URISyntaxException Mockito.when(noticeService.getNoticeByPpn(Mockito.anyString())).thenReturn(this.noticeElec); // Appel du service - PpnDto result = bestPpnService.getBestPpn(kbart, provider, false, false); + BestPpn result = bestPpnService.getBestPpn(kbart, provider, false, false); // Vérification Assertions.assertEquals("100000001", result.getPpn()); @@ -173,7 +173,7 @@ void getBestPpnTest01_WithProviderInNoticeIsPresent() throws IOException, BestPp Mockito.when(noticeService.getNoticeByPpn(Mockito.anyString())).thenReturn(this.noticeElec); // Appel du service - PpnDto result = bestPpnService.getBestPpn(kbart, provider, false, false); + BestPpn result = bestPpnService.getBestPpn(kbart, provider, false, false); // Vérification Assertions.assertEquals("100000001", result.getPpn()); @@ -231,7 +231,7 @@ void getBestPpnTest02() throws IOException, BestPpnException, URISyntaxException Mockito.when(noticeService.getNoticeByPpn(Mockito.anyString())).thenReturn(this.noticeElec); // Appel du service - PpnDto result = bestPpnService.getBestPpn(kbart, provider, false, false); + BestPpn result = bestPpnService.getBestPpn(kbart, provider, false, false); // Vérification Assertions.assertEquals("100000001", result.getPpn()); @@ -289,7 +289,7 @@ void getBestPpnTest03() throws IOException, BestPpnException, URISyntaxException Mockito.when(noticeService.getNoticeByPpn(Mockito.anyString())).thenReturn(this.noticeElec); // Appel du service - PpnDto result = bestPpnService.getBestPpn(kbart, provider, false, false); + BestPpn result = bestPpnService.getBestPpn(kbart, provider, false, false); // Vérification Assertions.assertEquals("100000001", result.getPpn()); @@ -387,7 +387,7 @@ void getBestPpnTest06() throws IOException, BestPpnException, URISyntaxException Mockito.when(service.callDat2Ppn(Mockito.anyString(), Mockito.anyString(), Mockito.anyString())).thenReturn(resultDat2PpnWeb); // Appel de la méthode - PpnDto result = bestPpnService.getBestPpn(kbart, provider, false, false); + BestPpn result = bestPpnService.getBestPpn(kbart, provider, false, false); // Vérification Assertions.assertEquals("300000001", result.getPpn()); @@ -429,7 +429,7 @@ void getBestPpnTest06_NoBestPpnByDat2Ppn() throws IOException, BestPpnException, Mockito.when(noticeService.getNoticeByPpn("300000002")).thenReturn(noticePrint); // Appel de la méthode - PpnDto result = bestPpnService.getBestPpn(kbart, provider, false, false); + BestPpn result = bestPpnService.getBestPpn(kbart, provider, false, false); // Vérification Assertions.assertNull(result.getPpn()); @@ -481,7 +481,7 @@ void getBestPpnTest07() throws IOException, BestPpnException, URISyntaxException Mockito.when(noticeService.getNoticeByPpn(Mockito.anyString())).thenReturn(this.noticeElec); // Appel du service - PpnDto result = bestPpnService.getBestPpn(kbart, provider, false, false); + BestPpn result = bestPpnService.getBestPpn(kbart, provider, false, false); // Vérification Assertions.assertEquals("100000001", result.getPpn()); @@ -532,7 +532,7 @@ void getBestPpnTest08() throws IOException, BestPpnException, URISyntaxException Mockito.when(checkUrlService.checkUrlInNotice(Mockito.anyString(), Mockito.any())).thenReturn(true); // Appel du service - PpnDto result = bestPpnService.getBestPpn(kbart, provider, false, false); + BestPpn result = bestPpnService.getBestPpn(kbart, provider, false, false); // Vérification Assertions.assertEquals("200000001", result.getPpn()); @@ -614,7 +614,7 @@ void getBestPpnTest09() throws IOException, BestPpnException, URISyntaxException ThreadContext.put("package","truc_truc_2000-12-31.tsv"); Mockito.when(checkUrlService.checkUrlInNotice(Mockito.anyString(), Mockito.anyString())).thenReturn(true); // Appel du service - PpnDto result = bestPpnService.getBestPpn(kbart, provider, false, false); + BestPpn result = bestPpnService.getBestPpn(kbart, provider, false, false); // Vérification Assertions.assertEquals("123456789", result.getPpn()); @@ -629,8 +629,8 @@ void bestPpnWithScoreTest1() throws BestPpnException { ppnElecResultList.put("100000001", 10); Set ppnPrintResultList = new HashSet<>(); - bestPpnService.setSendLogs(false); - PpnDto result = bestPpnService.getBestPpnByScore(kbart, ppnElecResultList, ppnPrintResultList, false); + bestPpnService.setIsSendLogs(false); + BestPpn result = bestPpnService.getBestPpnByScore(kbart, ppnElecResultList, ppnPrintResultList, false); Assertions.assertEquals("100000001", result.getPpn()); Assertions.assertEquals(DESTINATION_TOPIC.BEST_PPN_BACON, result.getDestination()); } @@ -644,8 +644,8 @@ void bestPpnWithScoreTest2() throws BestPpnException { ppnElecResultList.put("100000002", 10); Set ppnPrintResultList = new HashSet<>(); - bestPpnService.setSendLogs(false); - PpnDto result = bestPpnService.getBestPpnByScore(kbart, ppnElecResultList, ppnPrintResultList, false); + bestPpnService.setIsSendLogs(false); + BestPpn result = bestPpnService.getBestPpnByScore(kbart, ppnElecResultList, ppnPrintResultList, false); Assertions.assertEquals("100000002", result.getPpn()); Assertions.assertEquals(DESTINATION_TOPIC.BEST_PPN_BACON, result.getDestination()); } @@ -659,8 +659,8 @@ void bestPpnWithScoreTest3() throws BestPpnException { ppnElecResultList.put("100000002", 10); Set ppnPrintResultList = new HashSet<>(); - bestPpnService.setSendLogs(false); - PpnDto result = bestPpnService.getBestPpnByScore(kbart, ppnElecResultList, ppnPrintResultList, true); + bestPpnService.setIsSendLogs(false); + BestPpn result = bestPpnService.getBestPpnByScore(kbart, ppnElecResultList, ppnPrintResultList, true); Assertions.assertEquals("", result.getPpn()); } @@ -675,8 +675,8 @@ void bestPpnWithScoreTest4() throws BestPpnException { ppnPrintResultList.add("100000001"); ppnPrintResultList.add("100000002"); - bestPpnService.setSendLogs(false); - PpnDto result = bestPpnService.getBestPpnByScore(kbart, ppnElecResultList, ppnPrintResultList, true); + bestPpnService.setIsSendLogs(false); + BestPpn result = bestPpnService.getBestPpnByScore(kbart, ppnElecResultList, ppnPrintResultList, true); Assertions.assertEquals("", result.getPpn()); } From d90eadece97fe0e783253a713395938f94492fa9 Mon Sep 17 00:00:00 2001 From: EryneKL <97091460+EryneKL@users.noreply.github.com> Date: Tue, 12 Dec 2023 14:30:08 +0100 Subject: [PATCH 08/12] =?UTF-8?q?FEAT=20:=20CDE-302=20acc=C3=A9der=20aux?= =?UTF-8?q?=20logs=20de=20l'algo=20vest-ppn=20sur=20la=20prod=20:=20=20=20?= =?UTF-8?q?=20=20=20-=20refactor=20algo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/abes/bestppn/BestPpnApplication.java | 2 + .../bestppn/controller/BestPpnController.java | 5 +- .../abes/bestppn/service/BestPpnService.java | 96 +++++++------------ 3 files changed, 40 insertions(+), 63 deletions(-) diff --git a/src/main/java/fr/abes/bestppn/BestPpnApplication.java b/src/main/java/fr/abes/bestppn/BestPpnApplication.java index e5b4031..5df59ea 100644 --- a/src/main/java/fr/abes/bestppn/BestPpnApplication.java +++ b/src/main/java/fr/abes/bestppn/BestPpnApplication.java @@ -2,9 +2,11 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.EnableAspectJAutoProxy; import org.springframework.kafka.annotation.EnableKafka; @EnableKafka +@EnableAspectJAutoProxy @SpringBootApplication public class BestPpnApplication { public static void main(String[] args) { diff --git a/src/main/java/fr/abes/bestppn/controller/BestPpnController.java b/src/main/java/fr/abes/bestppn/controller/BestPpnController.java index 38dfa53..a90fc6d 100644 --- a/src/main/java/fr/abes/bestppn/controller/BestPpnController.java +++ b/src/main/java/fr/abes/bestppn/controller/BestPpnController.java @@ -58,8 +58,9 @@ public BestPpnDto bestPpn(@RequestParam(name = "provider") String provider, @Req ligneKbartDto.setDateMonographPublishedOnline((dateMonographPublishedOnline != null) ? dateMonographPublishedOnline : ""); ligneKbartDto.setFirstAuthor((firstAuthor != null) ? firstAuthor : ""); boolean injectKafka = (force != null) ? force : false; - boolean sendLog = (log != null) ? log : false; - BestPpn bestPpn = service.getBestPpn(ligneKbartDto, provider, injectKafka, sendLog); + boolean isSendLog = (log != null) ? log : false; + BestPpn bestPpn = service.getBestPpn(ligneKbartDto, provider, injectKafka, isSendLog); + if(!isSendLog) bestPpn.setLogs(null); // désactive l'envoi des logs si non demandés. return new BestPpnDto(bestPpn.getPpn(), bestPpn.getTypeSupport(), bestPpn.getLogs()); } catch (URISyntaxException e) { throw new IllegalArgumentException("Une url dans le champ title_url du kbart n'est pas correcte"); diff --git a/src/main/java/fr/abes/bestppn/service/BestPpnService.java b/src/main/java/fr/abes/bestppn/service/BestPpnService.java index 0696491..f6d56e3 100644 --- a/src/main/java/fr/abes/bestppn/service/BestPpnService.java +++ b/src/main/java/fr/abes/bestppn/service/BestPpnService.java @@ -10,6 +10,7 @@ import fr.abes.bestppn.exception.IllegalDoiException; import fr.abes.bestppn.kafka.TopicProducer; import fr.abes.bestppn.utils.*; +import io.netty.handler.logging.LogLevel; import lombok.Getter; import lombok.Setter; import lombok.extern.slf4j.Slf4j; @@ -47,6 +48,7 @@ public class BestPpnService { private final CheckUrlService checkUrlService; + @Setter private List kbartLineLogs; @Setter @@ -59,23 +61,21 @@ public BestPpnService(WsService service, NoticeService noticeService, TopicProdu this.checkUrlService = checkUrlService; } - public BestPpn getBestPpn(LigneKbartDto kbart, String provider, boolean injectKafka, boolean sendLogs) throws IOException, BestPpnException, URISyntaxException, RestClientException, IllegalArgumentException, IllegalDoiException { + public BestPpn getBestPpn(LigneKbartDto kbart, String provider, boolean injectKafka, boolean isSendLogs) throws IOException, BestPpnException, URISyntaxException, RestClientException, IllegalArgumentException, IllegalDoiException { kbartLineLogs = new ArrayList<>(); - this.isSendLogs = sendLogs; + this.isSendLogs = isSendLogs; Map ppnElecScoredList = new HashMap<>(); Set ppnPrintResultList = new HashSet<>(); if (!kbart.getPublicationType().isEmpty()) { provider = kbart.getPublicationType().equals(PUBLICATION_TYPE.serial.toString()) ? "" : provider; if (kbart.getOnlineIdentifier() != null && !kbart.getOnlineIdentifier().isEmpty()) { - if (sendLogs) kbartLineLogs.add("paramètres en entrée : type : " + kbart.getPublicationType() + " / id : " + kbart.getOnlineIdentifier() + " / provider : " + provider); - log.debug("paramètres en entrée : type : " + kbart.getPublicationType() + " / id : " + kbart.getOnlineIdentifier() + " / provider : " + provider); + sendLog(LogLevel.DEBUG, "paramètres en entrée : type : " + kbart.getPublicationType() + " / id : " + kbart.getOnlineIdentifier() + " / provider : " + provider); feedPpnListFromOnline(kbart, provider, ppnElecScoredList, ppnPrintResultList); } if (kbart.getPrintIdentifier() != null && !kbart.getPrintIdentifier().isEmpty()) { - if (sendLogs) kbartLineLogs.add("paramètres en entrée : type : " + kbart.getPublicationType() + " / id : " + kbart.getPrintIdentifier() + " / provider : " + provider); - log.debug("paramètres en entrée : type : " + kbart.getPublicationType() + " / id : " + kbart.getPrintIdentifier() + " / provider : " + provider); + sendLog(LogLevel.DEBUG, "paramètres en entrée : type : " + kbart.getPublicationType() + " / id : " + kbart.getPrintIdentifier() + " / provider : " + provider); feedPpnListFromPrint(kbart, provider, ppnElecScoredList, ppnPrintResultList); } } @@ -92,8 +92,7 @@ public BestPpn getBestPpn(LigneKbartDto kbart, String provider, boolean injectKa } private void feedPpnListFromOnline(LigneKbartDto kbart, String provider, Map ppnElecScoredList, Set ppnPrintResultList) throws IOException, URISyntaxException, IllegalArgumentException, BestPpnException { - if (isSendLogs) kbartLineLogs.add("Entrée dans onlineId2Ppn"); - log.debug("Entrée dans onlineId2Ppn"); + sendLog(LogLevel.DEBUG, "Entrée dans onlineId2Ppn"); try { setScoreToEveryPpnFromResultWS(service.callOnlineId2Ppn(kbart.getPublicationType(), kbart.getOnlineIdentifier(), provider), kbart.getTitleUrl(), this.scoreOnlineId2PpnElect, ppnElecScoredList, ppnPrintResultList); } catch (RestClientException ex) { @@ -102,8 +101,7 @@ private void feedPpnListFromOnline(LigneKbartDto kbart, String provider, Map ppnElecScoredList, Set ppnPrintResultList) throws IOException, URISyntaxException, IllegalArgumentException, BestPpnException { - if (isSendLogs) kbartLineLogs.add("Entrée dans printId2Ppn"); - log.debug("Entrée dans printId2Ppn"); + sendLog(LogLevel.DEBUG, "Entrée dans printId2Ppn"); try { ResultWsSudocDto resultCallWs = service.callPrintId2Ppn(kbart.getPublicationType(), kbart.getPrintIdentifier(), provider); ResultWsSudocDto resultWithTypeElectronique = resultCallWs.getPpnWithTypeElectronique(); @@ -122,18 +120,15 @@ private void feedPpnListFromPrint(LigneKbartDto kbart, String provider, Map ppnElecScoredList, Set ppnPrintResultList) throws IOException { ResultDat2PpnWebDto resultDat2PpnWeb = null; if (!kbart.getAnneeFromDate_monograph_published_online().isEmpty()) { - if (isSendLogs) kbartLineLogs.add("Appel dat2ppn : date_monograph_published_online : " + kbart.getAnneeFromDate_monograph_published_online() + " / publication_title : " + kbart.getPublicationTitle() + " auteur : " + kbart.getAuthor()); - log.debug("Appel dat2ppn : date_monograph_published_online : " + kbart.getAnneeFromDate_monograph_published_online() + " / publication_title : " + kbart.getPublicationTitle() + " auteur : " + kbart.getAuthor()); + sendLog(LogLevel.DEBUG, "Appel dat2ppn : date_monograph_published_online : " + kbart.getAnneeFromDate_monograph_published_online() + " / publication_title : " + kbart.getPublicationTitle() + " auteur : " + kbart.getAuthor()); resultDat2PpnWeb = service.callDat2Ppn(kbart.getAnneeFromDate_monograph_published_online(), kbart.getAuthor(), kbart.getPublicationTitle()); } else if (ppnElecScoredList.isEmpty() && !kbart.getAnneeFromDate_monograph_published_print().isEmpty()) { - if (isSendLogs) kbartLineLogs.add("Appel dat2ppn : date_monograph_published_print : " + kbart.getAnneeFromDate_monograph_published_print() + " / publication_title : " + kbart.getPublicationTitle() + " auteur : " + kbart.getAuthor()); - log.debug("Appel dat2ppn : date_monograph_published_print : " + kbart.getAnneeFromDate_monograph_published_print() + " / publication_title : " + kbart.getPublicationTitle() + " auteur : " + kbart.getAuthor()); + sendLog(LogLevel.DEBUG, "Appel dat2ppn : date_monograph_published_print : " + kbart.getAnneeFromDate_monograph_published_print() + " / publication_title : " + kbart.getPublicationTitle() + " auteur : " + kbart.getAuthor()); resultDat2PpnWeb = service.callDat2Ppn(kbart.getAnneeFromDate_monograph_published_print(), kbart.getAuthor(), kbart.getPublicationTitle()); } if(resultDat2PpnWeb != null && !resultDat2PpnWeb.getPpns().isEmpty()) { for (String ppn : resultDat2PpnWeb.getPpns()) { - if (isSendLogs) kbartLineLogs.add("résultat : ppn " + ppn); - log.debug("résultat : ppn " + ppn); + sendLog(LogLevel.DEBUG, "résultat : ppn " + ppn); NoticeXml notice = noticeService.getNoticeByPpn(ppn); if (notice.isNoticeElectronique()) { ppnElecScoredList.put(ppn, scoreDat2Ppn); @@ -151,8 +146,7 @@ private void feedPpnListFromDoi(String doi, String provider, Map ppnWithTypeDto.getTypeSupport().equals(TYPE_SUPPORT.ELECTRONIQUE)).count(); for (PpnWithTypeDto ppn : resultCallWs.getPpns()) { if(ppn.getTypeSupport().equals(TYPE_SUPPORT.IMPRIME)) { - if (isSendLogs) kbartLineLogs.add("PPN Imprimé : " + ppn); - log.info("PPN Imprimé : " + ppn); + sendLog(LogLevel.DEBUG, "PPN Imprimé : " + ppn); ppnPrintResultList.add(ppn.getPpn()); } else if (ppn.getTypeDocument() != TYPE_DOCUMENT.MONOGRAPHIE || ppn.isProviderPresent() || checkUrlService.checkUrlInNotice(ppn.getPpn(), titleUrl)){ setScoreToPpnElect(score, ppnElecResultList, nbPpnElec, ppn); } else { - if (isSendLogs) kbartLineLogs.add("Le PPN " + ppn + " n'a pas de provider trouvé"); - log.error("Le PPN " + ppn + " n'a pas de provider trouvé"); + sendLog(LogLevel.DEBUG, "Le PPN " + ppn + " n'a pas de provider trouvé"); } } } @@ -183,34 +175,24 @@ private void setScoreToPpnElect(int score, Map ppnElecScoredLis } else { ppnElecScoredList.put(ppn.getPpn(), (score / nbPpnElec)); } - if (isSendLogs) kbartLineLogs.add("PPN Electronique : " + ppn + " / score : " + ppnElecScoredList.get(ppn.getPpn())); - log.info("PPN Electronique : " + ppn + " / score : " + ppnElecScoredList.get(ppn.getPpn())); + sendLog(LogLevel.DEBUG, "PPN Electronique : " + ppn + " / score : " + ppnElecScoredList.get(ppn.getPpn())); } public BestPpn getBestPpnByScore(LigneKbartDto kbart, Map ppnElecResultList, Set ppnPrintResultList, boolean isForced) throws BestPpnException { Map ppnElecScore = Utils.getMaxValuesFromMap(ppnElecResultList); return switch (ppnElecScore.size()) { case 0 -> { - if (isSendLogs) kbartLineLogs.add("Aucun ppn électronique trouvé. " + kbart); - log.info("Aucun ppn électronique trouvé. " + kbart); + sendLog(LogLevel.INFO, "Aucun ppn électronique trouvé. " + kbart); yield switch (ppnPrintResultList.size()) { case 0 -> { kbart.setErrorType("Aucun ppn trouvé"); - if(isSendLogs) { - yield new BestPpn(null, DESTINATION_TOPIC.NO_PPN_FOUND_SUDOC, kbartLineLogs); - } else { - yield new BestPpn(null, DESTINATION_TOPIC.NO_PPN_FOUND_SUDOC); - } + yield new BestPpn(null, DESTINATION_TOPIC.NO_PPN_FOUND_SUDOC, kbartLineLogs); } case 1 -> { kbart.setErrorType("Ppn imprimé trouvé : " + ppnPrintResultList.stream().toList().get(0)); - if(isSendLogs) { - kbartLineLogs.add("Ppn imprimé trouvé : " + ppnPrintResultList.stream().toList().get(0)); - yield new BestPpn(ppnPrintResultList.stream().toList().get(0),DESTINATION_TOPIC.PRINT_PPN_SUDOC, TYPE_SUPPORT.IMPRIME, kbartLineLogs); - } else { - yield new BestPpn(ppnPrintResultList.stream().toList().get(0),DESTINATION_TOPIC.PRINT_PPN_SUDOC, TYPE_SUPPORT.IMPRIME); - } + sendLog(LogLevel.DEBUG, "Ppn imprimé trouvé : " + ppnPrintResultList.stream().toList().get(0)); + yield new BestPpn(ppnPrintResultList.stream().toList().get(0),DESTINATION_TOPIC.PRINT_PPN_SUDOC, TYPE_SUPPORT.IMPRIME, kbartLineLogs); } default -> { @@ -218,26 +200,15 @@ yield switch (ppnPrintResultList.size()) { kbart.setErrorType(errorString); // vérification du forçage if (isForced) { - log.error(errorString); - if (isSendLogs) { - kbartLineLogs.add("Plusieurs ppn imprimés (" + String.join(", ", ppnPrintResultList) + ") ont été trouvés."); - yield new BestPpn("",DESTINATION_TOPIC.BEST_PPN_BACON, kbartLineLogs); - } else { - yield new BestPpn("",DESTINATION_TOPIC.BEST_PPN_BACON); - } + sendLog(LogLevel.ERROR,"Plusieurs ppn imprimés (" + String.join(", ", ppnPrintResultList) + ") ont été trouvés."); + yield new BestPpn("",DESTINATION_TOPIC.BEST_PPN_BACON, kbartLineLogs); } else { throw new BestPpnException(errorString); } } }; } - case 1 -> { - if (isSendLogs) { - yield new BestPpn(ppnElecScore.keySet().stream().findFirst().get(), DESTINATION_TOPIC.BEST_PPN_BACON, TYPE_SUPPORT.ELECTRONIQUE, kbartLineLogs); - } else { - yield new BestPpn(ppnElecScore.keySet().stream().findFirst().get(), DESTINATION_TOPIC.BEST_PPN_BACON, TYPE_SUPPORT.ELECTRONIQUE); - } - } + case 1 -> new BestPpn(ppnElecScore.keySet().stream().findFirst().get(), DESTINATION_TOPIC.BEST_PPN_BACON, TYPE_SUPPORT.ELECTRONIQUE, kbartLineLogs); default -> { String listPpn = String.join(", ", ppnElecScore.keySet()); @@ -245,13 +216,8 @@ yield switch (ppnPrintResultList.size()) { kbart.setErrorType(errorString); // vérification du forçage if (isForced) { - log.error(errorString); - if (isSendLogs) { - kbartLineLogs.add(errorString); - yield new BestPpn("", DESTINATION_TOPIC.BEST_PPN_BACON, kbartLineLogs); - } else { - yield new BestPpn("", DESTINATION_TOPIC.BEST_PPN_BACON); - } + sendLog(LogLevel.ERROR, errorString); + yield new BestPpn("", DESTINATION_TOPIC.BEST_PPN_BACON, kbartLineLogs); } else { throw new BestPpnException(errorString); } @@ -259,8 +225,16 @@ yield switch (ppnPrintResultList.size()) { }; } - public void sendLog(String log, Boolean sendlogs) { - + public void sendLog(LogLevel level, String message) { + if (isSendLogs) { + kbartLineLogs.add(message); + } + switch (level) { + case DEBUG -> log.debug(message); + case TRACE -> log.trace(message); + case WARN -> log.warn(message); + case ERROR -> log.error(message); + default -> log.info(message); + } } - } From 0ceff6a034c981aedcee586bb1daea2cca2af508 Mon Sep 17 00:00:00 2001 From: pierre-maraval Date: Tue, 12 Dec 2023 14:41:34 +0100 Subject: [PATCH 09/12] =?UTF-8?q?CDE-302=20:=20Refactor=20:=20D=C3=A9place?= =?UTF-8?q?ment=20objets=20dans=20package=20model?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/abes/bestppn/controller/BestPpnController.java | 4 ++-- src/main/java/fr/abes/bestppn/kafka/TopicConsumer.java | 4 ++-- src/main/java/fr/abes/bestppn/kafka/TopicProducer.java | 4 ++-- .../fr/abes/bestppn/{ => model}/dto/BestPpnDto.java | 2 +- .../abes/bestppn/{ => model}/dto/PackageKbartDto.java | 4 ++-- .../{ => model}/dto/kafka/KbartProviderDto.java | 2 +- .../bestppn/{ => model}/dto/kafka/LigneKbartDto.java | 2 +- .../{ => model}/dto/kafka/PpnKbartProviderDto.java | 2 +- .../fr/abes/bestppn/{ => model}/dto/mail/MailDto.java | 2 +- .../bestppn/{ => model}/dto/wscall/PpnWithTypeDto.java | 2 +- .../{ => model}/dto/wscall/ResultDat2PpnWebDto.java | 2 +- .../{ => model}/dto/wscall/ResultWsSudocDto.java | 2 +- .../{ => model}/dto/wscall/SearchDatWebDto.java | 2 +- .../bestppn/{ => model}/entity/ExecutionReport.java | 2 +- .../abes/bestppn/{ => model}/entity/PpnResultList.java | 4 ++-- .../bestppn/{ => model}/entity/bacon/LigneKbart.java | 2 +- .../bestppn/{ => model}/entity/bacon/Provider.java | 2 +- .../{ => model}/entity/bacon/ProviderPackage.java | 2 +- .../{ => model}/entity/basexml/NoticesBibio.java | 2 +- .../entity/basexml/notice/Controlfield.java | 2 +- .../{ => model}/entity/basexml/notice/Datafield.java | 2 +- .../{ => model}/entity/basexml/notice/NoticeXml.java | 2 +- .../{ => model}/entity/basexml/notice/SubField.java | 2 +- .../bestppn/repository/bacon/LigneKbartRepository.java | 2 +- .../repository/bacon/ProviderPackageRepository.java | 2 +- .../bestppn/repository/bacon/ProviderRepository.java | 2 +- .../repository/basexml/NoticesBibioRepository.java | 2 +- .../java/fr/abes/bestppn/service/BestPpnService.java | 10 +++++----- .../java/fr/abes/bestppn/service/CheckUrlService.java | 6 +++--- .../java/fr/abes/bestppn/service/EmailService.java | 6 +++--- .../abes/bestppn/service/ExecutionReportService.java | 2 +- .../java/fr/abes/bestppn/service/KbartService.java | 6 +++--- .../java/fr/abes/bestppn/service/LogFileService.java | 2 +- .../java/fr/abes/bestppn/service/NoticeService.java | 4 ++-- .../java/fr/abes/bestppn/service/ProviderService.java | 4 ++-- src/main/java/fr/abes/bestppn/service/WsService.java | 8 +++----- .../java/fr/abes/bestppn/utils/LigneKbartMapper.java | 2 +- src/main/java/fr/abes/bestppn/utils/Utils.java | 5 ++++- .../java/fr/abes/bestppn/dto/LigneKbartDtoTest.java | 2 +- .../java/fr/abes/bestppn/dto/ResultWsSudocDtoTest.java | 4 ++-- .../bestppn/entity/basexml/notice/NoticeXmlTest.java | 3 +++ .../fr/abes/bestppn/service/BestPpnServiceTest.java | 10 +++++----- .../fr/abes/bestppn/service/CheckUrlServiceTest.java | 6 +++--- src/test/java/fr/abes/bestppn/utils/UtilsTest.java | 2 +- 44 files changed, 75 insertions(+), 71 deletions(-) rename src/main/java/fr/abes/bestppn/{ => model}/dto/BestPpnDto.java (95%) rename src/main/java/fr/abes/bestppn/{ => model}/dto/PackageKbartDto.java (88%) rename src/main/java/fr/abes/bestppn/{ => model}/dto/kafka/KbartProviderDto.java (90%) rename src/main/java/fr/abes/bestppn/{ => model}/dto/kafka/LigneKbartDto.java (99%) rename src/main/java/fr/abes/bestppn/{ => model}/dto/kafka/PpnKbartProviderDto.java (94%) rename src/main/java/fr/abes/bestppn/{ => model}/dto/mail/MailDto.java (85%) rename src/main/java/fr/abes/bestppn/{ => model}/dto/wscall/PpnWithTypeDto.java (95%) rename src/main/java/fr/abes/bestppn/{ => model}/dto/wscall/ResultDat2PpnWebDto.java (93%) rename src/main/java/fr/abes/bestppn/{ => model}/dto/wscall/ResultWsSudocDto.java (97%) rename src/main/java/fr/abes/bestppn/{ => model}/dto/wscall/SearchDatWebDto.java (85%) rename src/main/java/fr/abes/bestppn/{ => model}/entity/ExecutionReport.java (97%) rename src/main/java/fr/abes/bestppn/{ => model}/entity/PpnResultList.java (88%) rename src/main/java/fr/abes/bestppn/{ => model}/entity/bacon/LigneKbart.java (91%) rename src/main/java/fr/abes/bestppn/{ => model}/entity/bacon/Provider.java (96%) rename src/main/java/fr/abes/bestppn/{ => model}/entity/bacon/ProviderPackage.java (96%) rename src/main/java/fr/abes/bestppn/{ => model}/entity/basexml/NoticesBibio.java (94%) rename src/main/java/fr/abes/bestppn/{ => model}/entity/basexml/notice/Controlfield.java (87%) rename src/main/java/fr/abes/bestppn/{ => model}/entity/basexml/notice/Datafield.java (91%) rename src/main/java/fr/abes/bestppn/{ => model}/entity/basexml/notice/NoticeXml.java (98%) rename src/main/java/fr/abes/bestppn/{ => model}/entity/basexml/notice/SubField.java (89%) diff --git a/src/main/java/fr/abes/bestppn/controller/BestPpnController.java b/src/main/java/fr/abes/bestppn/controller/BestPpnController.java index a90fc6d..dd23fd8 100644 --- a/src/main/java/fr/abes/bestppn/controller/BestPpnController.java +++ b/src/main/java/fr/abes/bestppn/controller/BestPpnController.java @@ -1,7 +1,7 @@ package fr.abes.bestppn.controller; -import fr.abes.bestppn.dto.BestPpnDto; -import fr.abes.bestppn.dto.kafka.LigneKbartDto; +import fr.abes.bestppn.model.dto.BestPpnDto; +import fr.abes.bestppn.model.dto.kafka.LigneKbartDto; import fr.abes.bestppn.model.BestPpn; import fr.abes.bestppn.exception.BestPpnException; import fr.abes.bestppn.exception.IllegalDoiException; diff --git a/src/main/java/fr/abes/bestppn/kafka/TopicConsumer.java b/src/main/java/fr/abes/bestppn/kafka/TopicConsumer.java index ad01a6c..a62d1b2 100644 --- a/src/main/java/fr/abes/bestppn/kafka/TopicConsumer.java +++ b/src/main/java/fr/abes/bestppn/kafka/TopicConsumer.java @@ -2,8 +2,8 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; -import fr.abes.bestppn.dto.kafka.LigneKbartDto; -import fr.abes.bestppn.entity.bacon.Provider; +import fr.abes.bestppn.model.dto.kafka.LigneKbartDto; +import fr.abes.bestppn.model.entity.bacon.Provider; import fr.abes.bestppn.exception.*; import fr.abes.bestppn.repository.bacon.ProviderRepository; import fr.abes.bestppn.service.EmailService; diff --git a/src/main/java/fr/abes/bestppn/kafka/TopicProducer.java b/src/main/java/fr/abes/bestppn/kafka/TopicProducer.java index 27a7016..8be8204 100644 --- a/src/main/java/fr/abes/bestppn/kafka/TopicProducer.java +++ b/src/main/java/fr/abes/bestppn/kafka/TopicProducer.java @@ -3,8 +3,8 @@ import com.fasterxml.jackson.core.JsonProcessingException; import fr.abes.LigneKbartConnect; import fr.abes.LigneKbartImprime; -import fr.abes.bestppn.dto.kafka.LigneKbartDto; -import fr.abes.bestppn.entity.bacon.ProviderPackage; +import fr.abes.bestppn.model.dto.kafka.LigneKbartDto; +import fr.abes.bestppn.model.entity.bacon.ProviderPackage; import fr.abes.bestppn.exception.BestPpnException; import fr.abes.bestppn.utils.UtilsMapper; import jakarta.annotation.PostConstruct; diff --git a/src/main/java/fr/abes/bestppn/dto/BestPpnDto.java b/src/main/java/fr/abes/bestppn/model/dto/BestPpnDto.java similarity index 95% rename from src/main/java/fr/abes/bestppn/dto/BestPpnDto.java rename to src/main/java/fr/abes/bestppn/model/dto/BestPpnDto.java index 833f544..debb6bb 100644 --- a/src/main/java/fr/abes/bestppn/dto/BestPpnDto.java +++ b/src/main/java/fr/abes/bestppn/model/dto/BestPpnDto.java @@ -1,4 +1,4 @@ -package fr.abes.bestppn.dto; +package fr.abes.bestppn.model.dto; import com.fasterxml.jackson.annotation.JsonInclude; import fr.abes.bestppn.utils.TYPE_SUPPORT; diff --git a/src/main/java/fr/abes/bestppn/dto/PackageKbartDto.java b/src/main/java/fr/abes/bestppn/model/dto/PackageKbartDto.java similarity index 88% rename from src/main/java/fr/abes/bestppn/dto/PackageKbartDto.java rename to src/main/java/fr/abes/bestppn/model/dto/PackageKbartDto.java index 6a7f8e1..fd211ab 100644 --- a/src/main/java/fr/abes/bestppn/dto/PackageKbartDto.java +++ b/src/main/java/fr/abes/bestppn/model/dto/PackageKbartDto.java @@ -1,6 +1,6 @@ -package fr.abes.bestppn.dto; +package fr.abes.bestppn.model.dto; -import fr.abes.bestppn.dto.kafka.LigneKbartDto; +import fr.abes.bestppn.model.dto.kafka.LigneKbartDto; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; diff --git a/src/main/java/fr/abes/bestppn/dto/kafka/KbartProviderDto.java b/src/main/java/fr/abes/bestppn/model/dto/kafka/KbartProviderDto.java similarity index 90% rename from src/main/java/fr/abes/bestppn/dto/kafka/KbartProviderDto.java rename to src/main/java/fr/abes/bestppn/model/dto/kafka/KbartProviderDto.java index 071b466..c7a5d7f 100644 --- a/src/main/java/fr/abes/bestppn/dto/kafka/KbartProviderDto.java +++ b/src/main/java/fr/abes/bestppn/model/dto/kafka/KbartProviderDto.java @@ -1,4 +1,4 @@ -package fr.abes.bestppn.dto.kafka; +package fr.abes.bestppn.model.dto.kafka; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.Getter; diff --git a/src/main/java/fr/abes/bestppn/dto/kafka/LigneKbartDto.java b/src/main/java/fr/abes/bestppn/model/dto/kafka/LigneKbartDto.java similarity index 99% rename from src/main/java/fr/abes/bestppn/dto/kafka/LigneKbartDto.java rename to src/main/java/fr/abes/bestppn/model/dto/kafka/LigneKbartDto.java index fa07864..01bcb5b 100644 --- a/src/main/java/fr/abes/bestppn/dto/kafka/LigneKbartDto.java +++ b/src/main/java/fr/abes/bestppn/model/dto/kafka/LigneKbartDto.java @@ -1,4 +1,4 @@ -package fr.abes.bestppn.dto.kafka; +package fr.abes.bestppn.model.dto.kafka; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/src/main/java/fr/abes/bestppn/dto/kafka/PpnKbartProviderDto.java b/src/main/java/fr/abes/bestppn/model/dto/kafka/PpnKbartProviderDto.java similarity index 94% rename from src/main/java/fr/abes/bestppn/dto/kafka/PpnKbartProviderDto.java rename to src/main/java/fr/abes/bestppn/model/dto/kafka/PpnKbartProviderDto.java index 51f83c3..8c33b6a 100644 --- a/src/main/java/fr/abes/bestppn/dto/kafka/PpnKbartProviderDto.java +++ b/src/main/java/fr/abes/bestppn/model/dto/kafka/PpnKbartProviderDto.java @@ -1,4 +1,4 @@ -package fr.abes.bestppn.dto.kafka; +package fr.abes.bestppn.model.dto.kafka; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/src/main/java/fr/abes/bestppn/dto/mail/MailDto.java b/src/main/java/fr/abes/bestppn/model/dto/mail/MailDto.java similarity index 85% rename from src/main/java/fr/abes/bestppn/dto/mail/MailDto.java rename to src/main/java/fr/abes/bestppn/model/dto/mail/MailDto.java index 0f48efe..df8c40c 100644 --- a/src/main/java/fr/abes/bestppn/dto/mail/MailDto.java +++ b/src/main/java/fr/abes/bestppn/model/dto/mail/MailDto.java @@ -1,4 +1,4 @@ -package fr.abes.bestppn.dto.mail; +package fr.abes.bestppn.model.dto.mail; import lombok.Getter; import lombok.Setter; diff --git a/src/main/java/fr/abes/bestppn/dto/wscall/PpnWithTypeDto.java b/src/main/java/fr/abes/bestppn/model/dto/wscall/PpnWithTypeDto.java similarity index 95% rename from src/main/java/fr/abes/bestppn/dto/wscall/PpnWithTypeDto.java rename to src/main/java/fr/abes/bestppn/model/dto/wscall/PpnWithTypeDto.java index 72812d0..9f45723 100644 --- a/src/main/java/fr/abes/bestppn/dto/wscall/PpnWithTypeDto.java +++ b/src/main/java/fr/abes/bestppn/model/dto/wscall/PpnWithTypeDto.java @@ -1,4 +1,4 @@ -package fr.abes.bestppn.dto.wscall; +package fr.abes.bestppn.model.dto.wscall; import fr.abes.bestppn.utils.TYPE_DOCUMENT; import fr.abes.bestppn.utils.TYPE_SUPPORT; diff --git a/src/main/java/fr/abes/bestppn/dto/wscall/ResultDat2PpnWebDto.java b/src/main/java/fr/abes/bestppn/model/dto/wscall/ResultDat2PpnWebDto.java similarity index 93% rename from src/main/java/fr/abes/bestppn/dto/wscall/ResultDat2PpnWebDto.java rename to src/main/java/fr/abes/bestppn/model/dto/wscall/ResultDat2PpnWebDto.java index 1d236db..20f4b38 100644 --- a/src/main/java/fr/abes/bestppn/dto/wscall/ResultDat2PpnWebDto.java +++ b/src/main/java/fr/abes/bestppn/model/dto/wscall/ResultDat2PpnWebDto.java @@ -1,4 +1,4 @@ -package fr.abes.bestppn.dto.wscall; +package fr.abes.bestppn.model.dto.wscall; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.Getter; diff --git a/src/main/java/fr/abes/bestppn/dto/wscall/ResultWsSudocDto.java b/src/main/java/fr/abes/bestppn/model/dto/wscall/ResultWsSudocDto.java similarity index 97% rename from src/main/java/fr/abes/bestppn/dto/wscall/ResultWsSudocDto.java rename to src/main/java/fr/abes/bestppn/model/dto/wscall/ResultWsSudocDto.java index 4050cb4..bf53ab0 100644 --- a/src/main/java/fr/abes/bestppn/dto/wscall/ResultWsSudocDto.java +++ b/src/main/java/fr/abes/bestppn/model/dto/wscall/ResultWsSudocDto.java @@ -1,4 +1,4 @@ -package fr.abes.bestppn.dto.wscall; +package fr.abes.bestppn.model.dto.wscall; import fr.abes.bestppn.utils.TYPE_SUPPORT; import lombok.Getter; diff --git a/src/main/java/fr/abes/bestppn/dto/wscall/SearchDatWebDto.java b/src/main/java/fr/abes/bestppn/model/dto/wscall/SearchDatWebDto.java similarity index 85% rename from src/main/java/fr/abes/bestppn/dto/wscall/SearchDatWebDto.java rename to src/main/java/fr/abes/bestppn/model/dto/wscall/SearchDatWebDto.java index b571164..b3b3660 100644 --- a/src/main/java/fr/abes/bestppn/dto/wscall/SearchDatWebDto.java +++ b/src/main/java/fr/abes/bestppn/model/dto/wscall/SearchDatWebDto.java @@ -1,4 +1,4 @@ -package fr.abes.bestppn.dto.wscall; +package fr.abes.bestppn.model.dto.wscall; import lombok.Getter; import lombok.Setter; diff --git a/src/main/java/fr/abes/bestppn/entity/ExecutionReport.java b/src/main/java/fr/abes/bestppn/model/entity/ExecutionReport.java similarity index 97% rename from src/main/java/fr/abes/bestppn/entity/ExecutionReport.java rename to src/main/java/fr/abes/bestppn/model/entity/ExecutionReport.java index 768f416..8348edf 100644 --- a/src/main/java/fr/abes/bestppn/entity/ExecutionReport.java +++ b/src/main/java/fr/abes/bestppn/model/entity/ExecutionReport.java @@ -1,4 +1,4 @@ -package fr.abes.bestppn.entity; +package fr.abes.bestppn.model.entity; import lombok.Data; diff --git a/src/main/java/fr/abes/bestppn/entity/PpnResultList.java b/src/main/java/fr/abes/bestppn/model/entity/PpnResultList.java similarity index 88% rename from src/main/java/fr/abes/bestppn/entity/PpnResultList.java rename to src/main/java/fr/abes/bestppn/model/entity/PpnResultList.java index ab221fc..350c933 100644 --- a/src/main/java/fr/abes/bestppn/entity/PpnResultList.java +++ b/src/main/java/fr/abes/bestppn/model/entity/PpnResultList.java @@ -1,6 +1,6 @@ -package fr.abes.bestppn.entity; +package fr.abes.bestppn.model.entity; -import fr.abes.bestppn.dto.wscall.PpnWithTypeDto; +import fr.abes.bestppn.model.dto.wscall.PpnWithTypeDto; import fr.abes.bestppn.utils.TYPE_SUPPORT; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/fr/abes/bestppn/entity/bacon/LigneKbart.java b/src/main/java/fr/abes/bestppn/model/entity/bacon/LigneKbart.java similarity index 91% rename from src/main/java/fr/abes/bestppn/entity/bacon/LigneKbart.java rename to src/main/java/fr/abes/bestppn/model/entity/bacon/LigneKbart.java index e1b407c..4cdb38d 100644 --- a/src/main/java/fr/abes/bestppn/entity/bacon/LigneKbart.java +++ b/src/main/java/fr/abes/bestppn/model/entity/bacon/LigneKbart.java @@ -1,4 +1,4 @@ -package fr.abes.bestppn.entity.bacon; +package fr.abes.bestppn.model.entity.bacon; import jakarta.persistence.Column; import jakarta.persistence.Entity; diff --git a/src/main/java/fr/abes/bestppn/entity/bacon/Provider.java b/src/main/java/fr/abes/bestppn/model/entity/bacon/Provider.java similarity index 96% rename from src/main/java/fr/abes/bestppn/entity/bacon/Provider.java rename to src/main/java/fr/abes/bestppn/model/entity/bacon/Provider.java index 987688b..cbd197c 100644 --- a/src/main/java/fr/abes/bestppn/entity/bacon/Provider.java +++ b/src/main/java/fr/abes/bestppn/model/entity/bacon/Provider.java @@ -1,4 +1,4 @@ -package fr.abes.bestppn.entity.bacon; +package fr.abes.bestppn.model.entity.bacon; import jakarta.persistence.*; import lombok.Getter; diff --git a/src/main/java/fr/abes/bestppn/entity/bacon/ProviderPackage.java b/src/main/java/fr/abes/bestppn/model/entity/bacon/ProviderPackage.java similarity index 96% rename from src/main/java/fr/abes/bestppn/entity/bacon/ProviderPackage.java rename to src/main/java/fr/abes/bestppn/model/entity/bacon/ProviderPackage.java index d08a17c..8dc1192 100644 --- a/src/main/java/fr/abes/bestppn/entity/bacon/ProviderPackage.java +++ b/src/main/java/fr/abes/bestppn/model/entity/bacon/ProviderPackage.java @@ -1,4 +1,4 @@ -package fr.abes.bestppn.entity.bacon; +package fr.abes.bestppn.model.entity.bacon; import jakarta.persistence.*; import lombok.AllArgsConstructor; diff --git a/src/main/java/fr/abes/bestppn/entity/basexml/NoticesBibio.java b/src/main/java/fr/abes/bestppn/model/entity/basexml/NoticesBibio.java similarity index 94% rename from src/main/java/fr/abes/bestppn/entity/basexml/NoticesBibio.java rename to src/main/java/fr/abes/bestppn/model/entity/basexml/NoticesBibio.java index 46cc04a..2ec70e3 100644 --- a/src/main/java/fr/abes/bestppn/entity/basexml/NoticesBibio.java +++ b/src/main/java/fr/abes/bestppn/model/entity/basexml/NoticesBibio.java @@ -1,4 +1,4 @@ -package fr.abes.bestppn.entity.basexml; +package fr.abes.bestppn.model.entity.basexml; import jakarta.persistence.*; import lombok.Getter; diff --git a/src/main/java/fr/abes/bestppn/entity/basexml/notice/Controlfield.java b/src/main/java/fr/abes/bestppn/model/entity/basexml/notice/Controlfield.java similarity index 87% rename from src/main/java/fr/abes/bestppn/entity/basexml/notice/Controlfield.java rename to src/main/java/fr/abes/bestppn/model/entity/basexml/notice/Controlfield.java index bfeac93..715ded3 100644 --- a/src/main/java/fr/abes/bestppn/entity/basexml/notice/Controlfield.java +++ b/src/main/java/fr/abes/bestppn/model/entity/basexml/notice/Controlfield.java @@ -1,4 +1,4 @@ -package fr.abes.bestppn.entity.basexml.notice; +package fr.abes.bestppn.model.entity.basexml.notice; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlText; diff --git a/src/main/java/fr/abes/bestppn/entity/basexml/notice/Datafield.java b/src/main/java/fr/abes/bestppn/model/entity/basexml/notice/Datafield.java similarity index 91% rename from src/main/java/fr/abes/bestppn/entity/basexml/notice/Datafield.java rename to src/main/java/fr/abes/bestppn/model/entity/basexml/notice/Datafield.java index 46e85b5..241c6f1 100644 --- a/src/main/java/fr/abes/bestppn/entity/basexml/notice/Datafield.java +++ b/src/main/java/fr/abes/bestppn/model/entity/basexml/notice/Datafield.java @@ -1,4 +1,4 @@ -package fr.abes.bestppn.entity.basexml.notice; +package fr.abes.bestppn.model.entity.basexml.notice; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; import lombok.Getter; diff --git a/src/main/java/fr/abes/bestppn/entity/basexml/notice/NoticeXml.java b/src/main/java/fr/abes/bestppn/model/entity/basexml/notice/NoticeXml.java similarity index 98% rename from src/main/java/fr/abes/bestppn/entity/basexml/notice/NoticeXml.java rename to src/main/java/fr/abes/bestppn/model/entity/basexml/notice/NoticeXml.java index 6fcb2a0..5bdb060 100644 --- a/src/main/java/fr/abes/bestppn/entity/basexml/notice/NoticeXml.java +++ b/src/main/java/fr/abes/bestppn/model/entity/basexml/notice/NoticeXml.java @@ -1,4 +1,4 @@ -package fr.abes.bestppn.entity.basexml.notice; +package fr.abes.bestppn.model.entity.basexml.notice; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; diff --git a/src/main/java/fr/abes/bestppn/entity/basexml/notice/SubField.java b/src/main/java/fr/abes/bestppn/model/entity/basexml/notice/SubField.java similarity index 89% rename from src/main/java/fr/abes/bestppn/entity/basexml/notice/SubField.java rename to src/main/java/fr/abes/bestppn/model/entity/basexml/notice/SubField.java index 8a8a833..6dea944 100644 --- a/src/main/java/fr/abes/bestppn/entity/basexml/notice/SubField.java +++ b/src/main/java/fr/abes/bestppn/model/entity/basexml/notice/SubField.java @@ -1,4 +1,4 @@ -package fr.abes.bestppn.entity.basexml.notice; +package fr.abes.bestppn.model.entity.basexml.notice; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlText; diff --git a/src/main/java/fr/abes/bestppn/repository/bacon/LigneKbartRepository.java b/src/main/java/fr/abes/bestppn/repository/bacon/LigneKbartRepository.java index 9c44e59..92459cd 100644 --- a/src/main/java/fr/abes/bestppn/repository/bacon/LigneKbartRepository.java +++ b/src/main/java/fr/abes/bestppn/repository/bacon/LigneKbartRepository.java @@ -1,7 +1,7 @@ package fr.abes.bestppn.repository.bacon; import fr.abes.bestppn.configuration.BaconDbConfiguration; -import fr.abes.bestppn.entity.bacon.LigneKbart; +import fr.abes.bestppn.model.entity.bacon.LigneKbart; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; import org.springframework.transaction.annotation.Transactional; diff --git a/src/main/java/fr/abes/bestppn/repository/bacon/ProviderPackageRepository.java b/src/main/java/fr/abes/bestppn/repository/bacon/ProviderPackageRepository.java index aa493e0..0b193c8 100644 --- a/src/main/java/fr/abes/bestppn/repository/bacon/ProviderPackageRepository.java +++ b/src/main/java/fr/abes/bestppn/repository/bacon/ProviderPackageRepository.java @@ -1,7 +1,7 @@ package fr.abes.bestppn.repository.bacon; import fr.abes.bestppn.configuration.BaconDbConfiguration; -import fr.abes.bestppn.entity.bacon.ProviderPackage; +import fr.abes.bestppn.model.entity.bacon.ProviderPackage; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; diff --git a/src/main/java/fr/abes/bestppn/repository/bacon/ProviderRepository.java b/src/main/java/fr/abes/bestppn/repository/bacon/ProviderRepository.java index bbab272..ad3aa26 100644 --- a/src/main/java/fr/abes/bestppn/repository/bacon/ProviderRepository.java +++ b/src/main/java/fr/abes/bestppn/repository/bacon/ProviderRepository.java @@ -1,7 +1,7 @@ package fr.abes.bestppn.repository.bacon; import fr.abes.bestppn.configuration.BaconDbConfiguration; -import fr.abes.bestppn.entity.bacon.Provider; +import fr.abes.bestppn.model.entity.bacon.Provider; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; diff --git a/src/main/java/fr/abes/bestppn/repository/basexml/NoticesBibioRepository.java b/src/main/java/fr/abes/bestppn/repository/basexml/NoticesBibioRepository.java index f15a2ff..f4165b2 100644 --- a/src/main/java/fr/abes/bestppn/repository/basexml/NoticesBibioRepository.java +++ b/src/main/java/fr/abes/bestppn/repository/basexml/NoticesBibioRepository.java @@ -1,6 +1,6 @@ package fr.abes.bestppn.repository.basexml; -import fr.abes.bestppn.entity.basexml.NoticesBibio; +import fr.abes.bestppn.model.entity.basexml.NoticesBibio; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; diff --git a/src/main/java/fr/abes/bestppn/service/BestPpnService.java b/src/main/java/fr/abes/bestppn/service/BestPpnService.java index f6d56e3..164ef89 100644 --- a/src/main/java/fr/abes/bestppn/service/BestPpnService.java +++ b/src/main/java/fr/abes/bestppn/service/BestPpnService.java @@ -1,14 +1,14 @@ package fr.abes.bestppn.service; -import fr.abes.bestppn.dto.kafka.LigneKbartDto; import fr.abes.bestppn.model.BestPpn; -import fr.abes.bestppn.dto.wscall.PpnWithTypeDto; -import fr.abes.bestppn.dto.wscall.ResultDat2PpnWebDto; -import fr.abes.bestppn.dto.wscall.ResultWsSudocDto; -import fr.abes.bestppn.entity.basexml.notice.NoticeXml; import fr.abes.bestppn.exception.BestPpnException; import fr.abes.bestppn.exception.IllegalDoiException; import fr.abes.bestppn.kafka.TopicProducer; +import fr.abes.bestppn.model.dto.kafka.LigneKbartDto; +import fr.abes.bestppn.model.dto.wscall.PpnWithTypeDto; +import fr.abes.bestppn.model.dto.wscall.ResultDat2PpnWebDto; +import fr.abes.bestppn.model.dto.wscall.ResultWsSudocDto; +import fr.abes.bestppn.model.entity.basexml.notice.NoticeXml; import fr.abes.bestppn.utils.*; import io.netty.handler.logging.LogLevel; import lombok.Getter; diff --git a/src/main/java/fr/abes/bestppn/service/CheckUrlService.java b/src/main/java/fr/abes/bestppn/service/CheckUrlService.java index bd5f34d..c1d8bed 100644 --- a/src/main/java/fr/abes/bestppn/service/CheckUrlService.java +++ b/src/main/java/fr/abes/bestppn/service/CheckUrlService.java @@ -1,8 +1,8 @@ package fr.abes.bestppn.service; -import fr.abes.bestppn.entity.basexml.notice.Datafield; -import fr.abes.bestppn.entity.basexml.notice.NoticeXml; -import fr.abes.bestppn.entity.basexml.notice.SubField; +import fr.abes.bestppn.model.entity.basexml.notice.Datafield; +import fr.abes.bestppn.model.entity.basexml.notice.NoticeXml; +import fr.abes.bestppn.model.entity.basexml.notice.SubField; import fr.abes.bestppn.utils.Utils; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; diff --git a/src/main/java/fr/abes/bestppn/service/EmailService.java b/src/main/java/fr/abes/bestppn/service/EmailService.java index 84ed9cf..5601e33 100644 --- a/src/main/java/fr/abes/bestppn/service/EmailService.java +++ b/src/main/java/fr/abes/bestppn/service/EmailService.java @@ -7,9 +7,9 @@ import com.opencsv.bean.StatefulBeanToCsvBuilder; import com.opencsv.exceptions.CsvDataTypeMismatchException; import com.opencsv.exceptions.CsvRequiredFieldEmptyException; -import fr.abes.bestppn.dto.PackageKbartDto; -import fr.abes.bestppn.dto.kafka.LigneKbartDto; -import fr.abes.bestppn.dto.mail.MailDto; +import fr.abes.bestppn.model.dto.PackageKbartDto; +import fr.abes.bestppn.model.dto.kafka.LigneKbartDto; +import fr.abes.bestppn.model.dto.mail.MailDto; import lombok.extern.slf4j.Slf4j; import org.apache.http.HttpEntity; import org.apache.http.client.methods.HttpPost; diff --git a/src/main/java/fr/abes/bestppn/service/ExecutionReportService.java b/src/main/java/fr/abes/bestppn/service/ExecutionReportService.java index ce228e1..2faa4d4 100644 --- a/src/main/java/fr/abes/bestppn/service/ExecutionReportService.java +++ b/src/main/java/fr/abes/bestppn/service/ExecutionReportService.java @@ -1,6 +1,6 @@ package fr.abes.bestppn.service; -import fr.abes.bestppn.entity.ExecutionReport; +import fr.abes.bestppn.model.entity.ExecutionReport; import lombok.Getter; import org.springframework.stereotype.Service; diff --git a/src/main/java/fr/abes/bestppn/service/KbartService.java b/src/main/java/fr/abes/bestppn/service/KbartService.java index b4ab032..fa60729 100644 --- a/src/main/java/fr/abes/bestppn/service/KbartService.java +++ b/src/main/java/fr/abes/bestppn/service/KbartService.java @@ -1,10 +1,10 @@ package fr.abes.bestppn.service; import fr.abes.LigneKbartImprime; -import fr.abes.bestppn.dto.kafka.LigneKbartDto; +import fr.abes.bestppn.model.dto.kafka.LigneKbartDto; import fr.abes.bestppn.model.BestPpn; -import fr.abes.bestppn.entity.bacon.Provider; -import fr.abes.bestppn.entity.bacon.ProviderPackage; +import fr.abes.bestppn.model.entity.bacon.Provider; +import fr.abes.bestppn.model.entity.bacon.ProviderPackage; import fr.abes.bestppn.exception.BestPpnException; import fr.abes.bestppn.exception.IllegalDateException; import fr.abes.bestppn.exception.IllegalDoiException; diff --git a/src/main/java/fr/abes/bestppn/service/LogFileService.java b/src/main/java/fr/abes/bestppn/service/LogFileService.java index 7533dd4..932f995 100644 --- a/src/main/java/fr/abes/bestppn/service/LogFileService.java +++ b/src/main/java/fr/abes/bestppn/service/LogFileService.java @@ -1,6 +1,6 @@ package fr.abes.bestppn.service; -import fr.abes.bestppn.entity.ExecutionReport; +import fr.abes.bestppn.model.entity.ExecutionReport; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; diff --git a/src/main/java/fr/abes/bestppn/service/NoticeService.java b/src/main/java/fr/abes/bestppn/service/NoticeService.java index 9dabf63..8753761 100644 --- a/src/main/java/fr/abes/bestppn/service/NoticeService.java +++ b/src/main/java/fr/abes/bestppn/service/NoticeService.java @@ -1,8 +1,8 @@ package fr.abes.bestppn.service; import com.fasterxml.jackson.dataformat.xml.XmlMapper; -import fr.abes.bestppn.entity.basexml.NoticesBibio; -import fr.abes.bestppn.entity.basexml.notice.NoticeXml; +import fr.abes.bestppn.model.entity.basexml.NoticesBibio; +import fr.abes.bestppn.model.entity.basexml.notice.NoticeXml; import fr.abes.bestppn.repository.basexml.NoticesBibioRepository; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; diff --git a/src/main/java/fr/abes/bestppn/service/ProviderService.java b/src/main/java/fr/abes/bestppn/service/ProviderService.java index 11091da..279459e 100644 --- a/src/main/java/fr/abes/bestppn/service/ProviderService.java +++ b/src/main/java/fr/abes/bestppn/service/ProviderService.java @@ -1,7 +1,7 @@ package fr.abes.bestppn.service; -import fr.abes.bestppn.entity.bacon.Provider; -import fr.abes.bestppn.entity.bacon.ProviderPackage; +import fr.abes.bestppn.model.entity.bacon.Provider; +import fr.abes.bestppn.model.entity.bacon.ProviderPackage; import fr.abes.bestppn.exception.IllegalDateException; import fr.abes.bestppn.exception.IllegalPackageException; import fr.abes.bestppn.repository.bacon.LigneKbartRepository; diff --git a/src/main/java/fr/abes/bestppn/service/WsService.java b/src/main/java/fr/abes/bestppn/service/WsService.java index 9d47398..5bae48c 100644 --- a/src/main/java/fr/abes/bestppn/service/WsService.java +++ b/src/main/java/fr/abes/bestppn/service/WsService.java @@ -2,12 +2,10 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; -import fr.abes.bestppn.dto.wscall.ResultDat2PpnWebDto; -import fr.abes.bestppn.dto.wscall.ResultWsSudocDto; -import fr.abes.bestppn.dto.wscall.SearchDatWebDto; -import fr.abes.bestppn.exception.BestPpnException; +import fr.abes.bestppn.model.dto.wscall.ResultDat2PpnWebDto; +import fr.abes.bestppn.model.dto.wscall.ResultWsSudocDto; +import fr.abes.bestppn.model.dto.wscall.SearchDatWebDto; import fr.abes.bestppn.exception.IllegalDoiException; -import fr.abes.bestppn.utils.ExecutionTime; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpEntity; diff --git a/src/main/java/fr/abes/bestppn/utils/LigneKbartMapper.java b/src/main/java/fr/abes/bestppn/utils/LigneKbartMapper.java index a2107c5..4a1d821 100644 --- a/src/main/java/fr/abes/bestppn/utils/LigneKbartMapper.java +++ b/src/main/java/fr/abes/bestppn/utils/LigneKbartMapper.java @@ -1,7 +1,7 @@ package fr.abes.bestppn.utils; import fr.abes.LigneKbartConnect; -import fr.abes.bestppn.dto.kafka.LigneKbartDto; +import fr.abes.bestppn.model.dto.kafka.LigneKbartDto; import org.modelmapper.Converter; import org.modelmapper.spi.MappingContext; import org.springframework.context.annotation.Bean; diff --git a/src/main/java/fr/abes/bestppn/utils/Utils.java b/src/main/java/fr/abes/bestppn/utils/Utils.java index 2c62793..d7f2cd0 100644 --- a/src/main/java/fr/abes/bestppn/utils/Utils.java +++ b/src/main/java/fr/abes/bestppn/utils/Utils.java @@ -1,9 +1,11 @@ package fr.abes.bestppn.utils; -import fr.abes.bestppn.dto.kafka.LigneKbartDto; +import fr.abes.bestppn.model.dto.kafka.LigneKbartDto; import fr.abes.bestppn.exception.IllegalDateException; import fr.abes.bestppn.exception.IllegalPackageException; import fr.abes.bestppn.exception.IllegalProviderException; +import io.netty.handler.logging.LogLevel; +import lombok.extern.slf4j.Slf4j; import java.net.URI; import java.net.URISyntaxException; @@ -14,6 +16,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; +@Slf4j public class Utils { public static String extractDomainFromUrl(String url) throws URISyntaxException { diff --git a/src/test/java/fr/abes/bestppn/dto/LigneKbartDtoTest.java b/src/test/java/fr/abes/bestppn/dto/LigneKbartDtoTest.java index 0633aab..57076c2 100644 --- a/src/test/java/fr/abes/bestppn/dto/LigneKbartDtoTest.java +++ b/src/test/java/fr/abes/bestppn/dto/LigneKbartDtoTest.java @@ -1,6 +1,6 @@ package fr.abes.bestppn.dto; -import fr.abes.bestppn.dto.kafka.LigneKbartDto; +import fr.abes.bestppn.model.dto.kafka.LigneKbartDto; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; diff --git a/src/test/java/fr/abes/bestppn/dto/ResultWsSudocDtoTest.java b/src/test/java/fr/abes/bestppn/dto/ResultWsSudocDtoTest.java index a3e9b8c..c55c387 100644 --- a/src/test/java/fr/abes/bestppn/dto/ResultWsSudocDtoTest.java +++ b/src/test/java/fr/abes/bestppn/dto/ResultWsSudocDtoTest.java @@ -1,7 +1,7 @@ package fr.abes.bestppn.dto; -import fr.abes.bestppn.dto.wscall.PpnWithTypeDto; -import fr.abes.bestppn.dto.wscall.ResultWsSudocDto; +import fr.abes.bestppn.model.dto.wscall.PpnWithTypeDto; +import fr.abes.bestppn.model.dto.wscall.ResultWsSudocDto; import fr.abes.bestppn.utils.TYPE_SUPPORT; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; diff --git a/src/test/java/fr/abes/bestppn/entity/basexml/notice/NoticeXmlTest.java b/src/test/java/fr/abes/bestppn/entity/basexml/notice/NoticeXmlTest.java index 0360ac8..b0c2c2e 100644 --- a/src/test/java/fr/abes/bestppn/entity/basexml/notice/NoticeXmlTest.java +++ b/src/test/java/fr/abes/bestppn/entity/basexml/notice/NoticeXmlTest.java @@ -1,5 +1,8 @@ package fr.abes.bestppn.entity.basexml.notice; +import fr.abes.bestppn.model.entity.basexml.notice.Datafield; +import fr.abes.bestppn.model.entity.basexml.notice.NoticeXml; +import fr.abes.bestppn.model.entity.basexml.notice.SubField; import org.assertj.core.util.Lists; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; diff --git a/src/test/java/fr/abes/bestppn/service/BestPpnServiceTest.java b/src/test/java/fr/abes/bestppn/service/BestPpnServiceTest.java index 155e963..546ed20 100644 --- a/src/test/java/fr/abes/bestppn/service/BestPpnServiceTest.java +++ b/src/test/java/fr/abes/bestppn/service/BestPpnServiceTest.java @@ -2,12 +2,12 @@ import com.fasterxml.jackson.dataformat.xml.JacksonXmlModule; import com.fasterxml.jackson.dataformat.xml.XmlMapper; -import fr.abes.bestppn.dto.kafka.LigneKbartDto; +import fr.abes.bestppn.model.dto.kafka.LigneKbartDto; import fr.abes.bestppn.model.BestPpn; -import fr.abes.bestppn.dto.wscall.PpnWithTypeDto; -import fr.abes.bestppn.dto.wscall.ResultDat2PpnWebDto; -import fr.abes.bestppn.dto.wscall.ResultWsSudocDto; -import fr.abes.bestppn.entity.basexml.notice.NoticeXml; +import fr.abes.bestppn.model.dto.wscall.PpnWithTypeDto; +import fr.abes.bestppn.model.dto.wscall.ResultDat2PpnWebDto; +import fr.abes.bestppn.model.dto.wscall.ResultWsSudocDto; +import fr.abes.bestppn.model.entity.basexml.notice.NoticeXml; import fr.abes.bestppn.exception.BestPpnException; import fr.abes.bestppn.exception.IllegalDoiException; import fr.abes.bestppn.kafka.TopicProducer; diff --git a/src/test/java/fr/abes/bestppn/service/CheckUrlServiceTest.java b/src/test/java/fr/abes/bestppn/service/CheckUrlServiceTest.java index bb07ade..efc693c 100644 --- a/src/test/java/fr/abes/bestppn/service/CheckUrlServiceTest.java +++ b/src/test/java/fr/abes/bestppn/service/CheckUrlServiceTest.java @@ -1,8 +1,8 @@ package fr.abes.bestppn.service; -import fr.abes.bestppn.entity.basexml.notice.Datafield; -import fr.abes.bestppn.entity.basexml.notice.NoticeXml; -import fr.abes.bestppn.entity.basexml.notice.SubField; +import fr.abes.bestppn.model.entity.basexml.notice.Datafield; +import fr.abes.bestppn.model.entity.basexml.notice.NoticeXml; +import fr.abes.bestppn.model.entity.basexml.notice.SubField; import org.assertj.core.util.Lists; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; diff --git a/src/test/java/fr/abes/bestppn/utils/UtilsTest.java b/src/test/java/fr/abes/bestppn/utils/UtilsTest.java index c083b79..45e5f5e 100644 --- a/src/test/java/fr/abes/bestppn/utils/UtilsTest.java +++ b/src/test/java/fr/abes/bestppn/utils/UtilsTest.java @@ -1,6 +1,6 @@ package fr.abes.bestppn.utils; -import fr.abes.bestppn.dto.kafka.LigneKbartDto; +import fr.abes.bestppn.model.dto.kafka.LigneKbartDto; import fr.abes.bestppn.exception.IllegalDateException; import fr.abes.bestppn.exception.IllegalPackageException; import org.junit.jupiter.api.Assertions; From b49a5d94fc5896d119a4f455c5866def55e11c45 Mon Sep 17 00:00:00 2001 From: EryneKL <97091460+EryneKL@users.noreply.github.com> Date: Wed, 13 Dec 2023 08:48:01 +0100 Subject: [PATCH 10/12] =?UTF-8?q?FEAT=20:=20CDE-302=20acc=C3=A9der=20aux?= =?UTF-8?q?=20logs=20de=20l'algo=20vest-ppn=20sur=20la=20prod=20:=20=20=20?= =?UTF-8?q?=20=20=20-=20fix=20chemin=20d'acc=C3=A8s=20=C3=A0=20l'entity=20?= =?UTF-8?q?dans=20la=20m=C3=A9thode=20baseXmlEntityManager=20de=20BaseXMLO?= =?UTF-8?q?racleConfig.java=20=20=20=20=20=20-=20fix=20chemin=20d'acc?= =?UTF-8?q?=C3=A8s=20=C3=A0=20l'entity=20dans=20la=20m=C3=A9thode=20baconE?= =?UTF-8?q?ntityManager=20de=20BaconDbConfig.java?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/fr/abes/bestppn/configuration/BaconDbConfig.java | 2 +- .../java/fr/abes/bestppn/configuration/BaseXMLOracleConfig.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/fr/abes/bestppn/configuration/BaconDbConfig.java b/src/main/java/fr/abes/bestppn/configuration/BaconDbConfig.java index 45ba0fb..fa6fe6c 100644 --- a/src/main/java/fr/abes/bestppn/configuration/BaconDbConfig.java +++ b/src/main/java/fr/abes/bestppn/configuration/BaconDbConfig.java @@ -41,7 +41,7 @@ public class BaconDbConfig extends AbstractConfig { public LocalContainerEntityManagerFactoryBean baconEntityManager() { LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean(); em.setDataSource(baconDataSource()); - em.setPackagesToScan(new String[]{"fr.abes.bestppn.entity.bacon"}); + em.setPackagesToScan(new String[]{"fr.abes.bestppn.model.entity.bacon"}); configHibernate(em, platform, showsql, dialect, ddlAuto, generateDdl, initMode); return em; } diff --git a/src/main/java/fr/abes/bestppn/configuration/BaseXMLOracleConfig.java b/src/main/java/fr/abes/bestppn/configuration/BaseXMLOracleConfig.java index eaaa9b3..54fe505 100644 --- a/src/main/java/fr/abes/bestppn/configuration/BaseXMLOracleConfig.java +++ b/src/main/java/fr/abes/bestppn/configuration/BaseXMLOracleConfig.java @@ -46,7 +46,7 @@ public LocalContainerEntityManagerFactoryBean baseXmlEntityManager() { = new LocalContainerEntityManagerFactoryBean(); em.setDataSource(baseXmlDataSource()); em.setPackagesToScan( - "fr.abes.bestppn.entity.basexml"); + "fr.abes.bestppn.model.entity.basexml"); configHibernate(em, platform, showsql, dialect, ddlAuto, generateDdl, initMode); return em; } From 985ba6f922e6134c02a9d33603622240f5b770f1 Mon Sep 17 00:00:00 2001 From: EryneKL <97091460+EryneKL@users.noreply.github.com> Date: Wed, 13 Dec 2023 09:14:23 +0100 Subject: [PATCH 11/12] =?UTF-8?q?FEAT=20:=20CDE-302=20acc=C3=A9der=20aux?= =?UTF-8?q?=20logs=20de=20l'algo=20vest-ppn=20sur=20la=20prod=20:=20=20=20?= =?UTF-8?q?=20=20=20-=20fix=20niveau=20de=20log=20dans=20BestPpnService.ja?= =?UTF-8?q?va=20=20=20=20=20=20-=20refactor=20du=20return=20de=20la=20m?= =?UTF-8?q?=C3=A9thode=20bestPpn=20dans=20BestPpnController.java=20=20=20?= =?UTF-8?q?=20=20=20-=20ajout=20d'un=20contructeur=20dans=20BestPpnDto.jav?= =?UTF-8?q?a?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/abes/bestppn/controller/BestPpnController.java | 2 +- src/main/java/fr/abes/bestppn/model/dto/BestPpnDto.java | 7 +++++++ src/main/java/fr/abes/bestppn/service/BestPpnService.java | 8 ++++---- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/main/java/fr/abes/bestppn/controller/BestPpnController.java b/src/main/java/fr/abes/bestppn/controller/BestPpnController.java index dd23fd8..b4ac560 100644 --- a/src/main/java/fr/abes/bestppn/controller/BestPpnController.java +++ b/src/main/java/fr/abes/bestppn/controller/BestPpnController.java @@ -61,7 +61,7 @@ public BestPpnDto bestPpn(@RequestParam(name = "provider") String provider, @Req boolean isSendLog = (log != null) ? log : false; BestPpn bestPpn = service.getBestPpn(ligneKbartDto, provider, injectKafka, isSendLog); if(!isSendLog) bestPpn.setLogs(null); // désactive l'envoi des logs si non demandés. - return new BestPpnDto(bestPpn.getPpn(), bestPpn.getTypeSupport(), bestPpn.getLogs()); + return new BestPpnDto(bestPpn); } catch (URISyntaxException e) { throw new IllegalArgumentException("Une url dans le champ title_url du kbart n'est pas correcte"); } catch (BestPpnException | RestClientException | IllegalArgumentException | IllegalDoiException e) { diff --git a/src/main/java/fr/abes/bestppn/model/dto/BestPpnDto.java b/src/main/java/fr/abes/bestppn/model/dto/BestPpnDto.java index debb6bb..87d6e42 100644 --- a/src/main/java/fr/abes/bestppn/model/dto/BestPpnDto.java +++ b/src/main/java/fr/abes/bestppn/model/dto/BestPpnDto.java @@ -1,6 +1,7 @@ package fr.abes.bestppn.model.dto; import com.fasterxml.jackson.annotation.JsonInclude; +import fr.abes.bestppn.model.BestPpn; import fr.abes.bestppn.utils.TYPE_SUPPORT; import lombok.Getter; import lombok.NoArgsConstructor; @@ -34,4 +35,10 @@ public BestPpnDto(String ppn, TYPE_SUPPORT typeSupport, List logs) { public BestPpnDto(List logs) { this.logs = logs; } + + public BestPpnDto(BestPpn bestPpn) { + this.ppn = bestPpn.getPpn(); + this.typeSupport = bestPpn.getTypeSupport(); + this.logs = bestPpn.getLogs(); + } } diff --git a/src/main/java/fr/abes/bestppn/service/BestPpnService.java b/src/main/java/fr/abes/bestppn/service/BestPpnService.java index 164ef89..0542034 100644 --- a/src/main/java/fr/abes/bestppn/service/BestPpnService.java +++ b/src/main/java/fr/abes/bestppn/service/BestPpnService.java @@ -146,7 +146,7 @@ private void feedPpnListFromDoi(String doi, String provider, Map ppnWithTypeDto.getTypeSupport().equals(TYPE_SUPPORT.ELECTRONIQUE)).count(); for (PpnWithTypeDto ppn : resultCallWs.getPpns()) { if(ppn.getTypeSupport().equals(TYPE_SUPPORT.IMPRIME)) { - sendLog(LogLevel.DEBUG, "PPN Imprimé : " + ppn); + sendLog(LogLevel.INFO, "PPN Imprimé : " + ppn); ppnPrintResultList.add(ppn.getPpn()); } else if (ppn.getTypeDocument() != TYPE_DOCUMENT.MONOGRAPHIE || ppn.isProviderPresent() || checkUrlService.checkUrlInNotice(ppn.getPpn(), titleUrl)){ setScoreToPpnElect(score, ppnElecResultList, nbPpnElec, ppn); } else { - sendLog(LogLevel.DEBUG, "Le PPN " + ppn + " n'a pas de provider trouvé"); + sendLog(LogLevel.ERROR, "Le PPN " + ppn + " n'a pas de provider trouvé"); } } } @@ -175,7 +175,7 @@ private void setScoreToPpnElect(int score, Map ppnElecScoredLis } else { ppnElecScoredList.put(ppn.getPpn(), (score / nbPpnElec)); } - sendLog(LogLevel.DEBUG, "PPN Electronique : " + ppn + " / score : " + ppnElecScoredList.get(ppn.getPpn())); + sendLog(LogLevel.INFO, "PPN Electronique : " + ppn + " / score : " + ppnElecScoredList.get(ppn.getPpn())); } public BestPpn getBestPpnByScore(LigneKbartDto kbart, Map ppnElecResultList, Set ppnPrintResultList, boolean isForced) throws BestPpnException { From 85ab93d6f544e456e4c75203542c9c90ce02ec1d Mon Sep 17 00:00:00 2001 From: EryneKL <97091460+EryneKL@users.noreply.github.com> Date: Wed, 13 Dec 2023 09:49:44 +0100 Subject: [PATCH 12/12] =?UTF-8?q?FEAT=20:=20CDE-302=20acc=C3=A9der=20aux?= =?UTF-8?q?=20logs=20de=20l'algo=20vest-ppn=20sur=20la=20prod=20:=20=20=20?= =?UTF-8?q?=20=20=20-=20refactor=20du=20niveau=20de=20log=20retourn=C3=A9?= =?UTF-8?q?=20=C3=A0=20la=20m=C3=A9thode=20bestPpn=20dans=20BestPpnControl?= =?UTF-8?q?ler.java?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/fr/abes/bestppn/service/BestPpnService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/fr/abes/bestppn/service/BestPpnService.java b/src/main/java/fr/abes/bestppn/service/BestPpnService.java index 0542034..a1669ba 100644 --- a/src/main/java/fr/abes/bestppn/service/BestPpnService.java +++ b/src/main/java/fr/abes/bestppn/service/BestPpnService.java @@ -227,7 +227,7 @@ yield switch (ppnPrintResultList.size()) { public void sendLog(LogLevel level, String message) { if (isSendLogs) { - kbartLineLogs.add(message); + if (level.equals(LogLevel.INFO) || level.equals(LogLevel.ERROR)) kbartLineLogs.add(message); } switch (level) { case DEBUG -> log.debug(message);