Skip to content

Commit

Permalink
Merge pull request #86 from abes-esr/CDE-408_printId2ppn_cas_où_un_se…
Browse files Browse the repository at this point in the history
…ul_ppn_trouvé_au_lieu_de_deux

ajout rechercher dans tout les cas des ppn liés
  • Loading branch information
pierre-maraval authored May 15, 2024
2 parents eb33779 + 4c8ab6a commit d9ca80b
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions src/main/java/fr/abes/sudoc/service/NoticeService.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@

import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.*;

@Service
@Slf4j
Expand Down Expand Up @@ -49,29 +47,22 @@ public NoticeXml getNoticeByPpn(String ppn) throws IllegalPpnException, IOExcept

public List<String> getEquivalentElectronique(NoticeXml notice) throws IOException, IllegalPpnException {
log.debug("entrée dans getEquivalentElectronique");
List<String> ppnlies;

//on cherche une 452$0 dans la notice
List<String> ppn452 = notice.get4XXDollar0("452");
ppnlies = getNoticeElectroniqueLiee(ppn452);
if (ppnlies.size() > 0) return ppnlies;
Set<String> ppnlies = new HashSet<>(getNoticeElectroniqueLiee(ppn452));

//on cherche une 456$0 dans la notice
List<String> ppn456 = notice.get4XXDollar0("456");
ppnlies = getNoticeElectroniqueLiee(ppn456);
if (ppnlies.size() > 0) return ppnlies;
ppnlies.addAll(getNoticeElectroniqueLiee(ppn456));

//Si pas de résultat trouvé, on interroge la table biblio_table_frbr_4XX
ppnlies.addAll(this.biblioTableFrbr4XXRepository.findAllByTagAndDatas("452$0", notice.getPpn()).stream().map(BiblioTableFrbr4XX::getPpn).toList());
//on renvoie les ppn trouvés via la requête
if (ppnlies.size() > 0) return ppnlies;

ppnlies.addAll(this.biblioTableFrbr4XXRepository.findAllByTagAndDatas("455$0", notice.getPpn()).stream().map(BiblioTableFrbr4XX::getPpn).toList());
//on renvoie les ppn trouvés via la requête
if (ppnlies.size() > 0) return ppnlies;

//aucune des conditions n'a été respectée, on renvoie une liste vide
return new ArrayList<>();
return ppnlies.stream().toList();
}

public List<String> getNoticeElectroniqueLiee(List<String> ppn4XX) throws IllegalPpnException, IOException {
Expand Down

0 comments on commit d9ca80b

Please sign in to comment.