Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Cde 302 acceder aux logs de lalgo best ppn sur la prod #43

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/main/java/fr/abes/bestppn/BestPpnApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
26 changes: 18 additions & 8 deletions src/main/java/fr/abes/bestppn/controller/BestPpnController.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package fr.abes.bestppn.controller;

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;
import fr.abes.bestppn.service.BestPpnService;
Expand All @@ -15,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 = "*")
Expand All @@ -37,11 +41,12 @@ public BestPpnController(BestPpnService service) {
}
)
@GetMapping(value = "/bestPpn")
public String 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) 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);
Expand All @@ -53,11 +58,16 @@ 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 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);
} 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();
List<String> logs = new ArrayList<>();
logs.add(e.getMessage());
return new BestPpnDto(logs);
}
}
}
12 changes: 0 additions & 12 deletions src/main/java/fr/abes/bestppn/dto/kafka/PpnWithDestinationDto.java

This file was deleted.

4 changes: 2 additions & 2 deletions src/main/java/fr/abes/bestppn/kafka/TopicConsumer.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/fr/abes/bestppn/kafka/TopicProducer.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
52 changes: 52 additions & 0 deletions src/main/java/fr/abes/bestppn/model/BestPpn.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package fr.abes.bestppn.model;

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.List;

@Getter
@Setter
@NoArgsConstructor
public class BestPpn {

@Nullable
private String ppn;

@Nullable
private TYPE_SUPPORT typeSupport;

@Nullable
private DESTINATION_TOPIC destination;

@Nullable
private List<String> logs;

public BestPpn(String ppn, DESTINATION_TOPIC destination) {
this.ppn = ppn;
this.destination = destination;
}

public BestPpn(String ppn, DESTINATION_TOPIC destination, TYPE_SUPPORT typeSupport) {
this.ppn = ppn;
this.destination = destination;
this.typeSupport = typeSupport;
}

public BestPpn(String ppn, DESTINATION_TOPIC destination, List<String> logs) {
this.ppn = ppn;
this.destination = destination;
this.logs = logs;
}

public BestPpn(String ppn, DESTINATION_TOPIC destination, TYPE_SUPPORT typeSupport, List<String> logs) {
this.ppn = ppn;
this.destination = destination;
this.typeSupport = typeSupport;
this.logs = logs;
}
}
44 changes: 44 additions & 0 deletions src/main/java/fr/abes/bestppn/model/dto/BestPpnDto.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
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;
import lombok.Setter;
import org.springframework.lang.Nullable;

import java.util.List;

@Getter
@Setter
@NoArgsConstructor
public class BestPpnDto {
@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 List<String> logs;

public BestPpnDto(String ppn, TYPE_SUPPORT typeSupport, List<String> logs) {
this.ppn = ppn;
this.typeSupport = typeSupport;
this.logs = logs;
}

public BestPpnDto(List<String> logs) {
this.logs = logs;
}

public BestPpnDto(BestPpn bestPpn) {
this.ppn = bestPpn.getPpn();
this.typeSupport = bestPpn.getTypeSupport();
this.logs = bestPpn.getLogs();
}
}
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package fr.abes.bestppn.dto.kafka;
package fr.abes.bestppn.model.dto.kafka;

import lombok.AllArgsConstructor;
import lombok.Getter;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package fr.abes.bestppn.dto.mail;
package fr.abes.bestppn.model.dto.mail;

import lombok.Getter;
import lombok.Setter;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package fr.abes.bestppn.dto.wscall;
package fr.abes.bestppn.model.dto.wscall;

import lombok.Getter;
import lombok.Setter;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package fr.abes.bestppn.entity;
package fr.abes.bestppn.model.entity;

import lombok.Data;

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package fr.abes.bestppn.entity.bacon;
package fr.abes.bestppn.model.entity.bacon;

import jakarta.persistence.*;
import lombok.Getter;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package fr.abes.bestppn.entity.bacon;
package fr.abes.bestppn.model.entity.bacon;

import jakarta.persistence.*;
import lombok.AllArgsConstructor;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package fr.abes.bestppn.entity.basexml;
package fr.abes.bestppn.model.entity.basexml;

import jakarta.persistence.*;
import lombok.Getter;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
Loading
Loading