Skip to content

Commit

Permalink
Merge pull request #43 from abes-esr/CDE-277-performances-fichiers-aj…
Browse files Browse the repository at this point in the history
…out-donnees-log

Ajout des ExecutionTime sur la couche service
  • Loading branch information
EryneKL authored Nov 13, 2023
2 parents 2a8c9a9 + a63b038 commit bb1dfcc
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.fasterxml.jackson.core.JsonProcessingException;
import fr.abes.convergence.kbartws.component.BaseXmlFunctionsCaller;
import fr.abes.convergence.kbartws.exception.IllegalPpnException;
import fr.abes.convergence.kbartws.utils.ExecutionTime;
import fr.abes.convergence.kbartws.utils.Utilitaire;
import org.springframework.jdbc.UncategorizedSQLException;
import org.springframework.stereotype.Service;
Expand All @@ -24,6 +25,7 @@ public boolean checkFormat(String doi) {
return doi != null;
}

@ExecutionTime
public List<String> getPpnFromIdentifiant(String doi) throws IllegalPpnException, IOException {
try{
return Utilitaire.parseJson(caller.doiToPpn(doi));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.fasterxml.jackson.core.JsonProcessingException;
import fr.abes.convergence.kbartws.component.BaseXmlFunctionsCaller;
import fr.abes.convergence.kbartws.exception.IllegalPpnException;
import fr.abes.convergence.kbartws.utils.ExecutionTime;
import fr.abes.convergence.kbartws.utils.TYPE_ID;
import fr.abes.convergence.kbartws.utils.Utilitaire;
import oracle.jdbc.OracleDatabaseException;
Expand All @@ -27,6 +28,7 @@ public boolean checkFormat(String isbn) {
return isbn != null && isbn.matches("^[0-9]((?:-?[0-9]){9}|(?:-?[0-9]){12})$");
}

@ExecutionTime
@Override
public List<String> getPpnFromIdentifiant(String isbn) throws IllegalPpnException, IOException {
try{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.fasterxml.jackson.core.JsonProcessingException;
import fr.abes.convergence.kbartws.component.BaseXmlFunctionsCaller;
import fr.abes.convergence.kbartws.exception.IllegalPpnException;
import fr.abes.convergence.kbartws.utils.ExecutionTime;
import fr.abes.convergence.kbartws.utils.Utilitaire;
import org.springframework.jdbc.UncategorizedSQLException;
import org.springframework.stereotype.Service;
Expand All @@ -24,6 +25,7 @@ public boolean checkFormat(String issn) {
return issn != null && issn.matches("^[0-9]{4}-?[0-9]{3}[0-9xX]$");
}

@ExecutionTime
@Override
public List<String> getPpnFromIdentifiant(String issn) throws IllegalPpnException, IOException {
try{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public NoticeService(NoticesBibioRepository noticesBibioRepository, BiblioTableF
this.xmlMapper = xmlMapper;
}

@ExecutionTime
public NoticeXml getNoticeByPpn(String ppn) throws IllegalPpnException, IOException {
if (ppn == null)
throw new IllegalPpnException("Le PPN ne peut pas être null");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import fr.abes.convergence.kbartws.dto.provider035.BaconDto;
import fr.abes.convergence.kbartws.dto.provider035.ResultProvider035Dto;
import fr.abes.convergence.kbartws.exception.IllegalPpnException;
import fr.abes.convergence.kbartws.utils.ExecutionTime;
import fr.abes.convergence.kbartws.utils.Utilitaire;
import lombok.RequiredArgsConstructor;
import org.springframework.jdbc.UncategorizedSQLException;
Expand All @@ -31,11 +32,13 @@ public class ProviderService {

private final ObjectMapper objectMapper;

@ExecutionTime
public Optional<ElementDto> getProviderDisplayName(String shortName) throws IOException {
ResultProviderDto result = wsService.callProviderList();
return Arrays.stream(result.getBacon().getQuery().getResults()).toList().stream().filter(el -> el.getElements().getProvider().equalsIgnoreCase(shortName)).map(ResultDto::getElements).findFirst();
}

@ExecutionTime
public List<String> getProviderFor035(Integer provider) throws IOException {
List<String> listValeurs = new ArrayList<>();
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import fr.abes.convergence.kbartws.dto.provider.ResultDto;
import fr.abes.convergence.kbartws.dto.provider.ResultProviderDto;
import fr.abes.convergence.kbartws.utils.ExecutionTime;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpEntity;
Expand Down Expand Up @@ -34,7 +35,6 @@ public WsService(ObjectMapper mapper, RestTemplate restTemplate) {
this.mapper = mapper;
}


public String postCall(String url, String requestJson) {
HttpEntity<String> entity = new HttpEntity<>(requestJson, headers);

Expand All @@ -53,6 +53,7 @@ public String getCall(String url, String... params) {
return restTemplate.getForObject(formedUrl.toString(), String.class);
}

@ExecutionTime
public ResultProviderDto callProviderList() throws RestClientResponseException, JsonProcessingException {
String result = getCall(providerList);
return mapper.readValue(result, ResultProviderDto.class);
Expand Down

0 comments on commit bb1dfcc

Please sign in to comment.