Skip to content

Commit

Permalink
REFACTOR : Correction sur recherche dans zone 210 / 214
Browse files Browse the repository at this point in the history
  • Loading branch information
pierre-maraval committed Oct 8, 2024
1 parent 5a92b53 commit 1bd4620
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
11 changes: 5 additions & 6 deletions src/main/java/fr/abes/sudoc/entity/notice/NoticeXml.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import java.util.List;
import java.util.Locale;
import java.util.Optional;
import java.util.stream.Collectors;

/**
* Représente une notice au format d'export UnimarcXML
Expand Down Expand Up @@ -107,10 +106,10 @@ public String getPpn() {

public List<String> get4XXDollar0(String zone) {
List<String> ppns = new ArrayList<>();
List<Datafield> listeZone = this.datafields.stream().filter(datafield -> datafield.getTag().equals(zone)).collect(Collectors.toList());
List<Datafield> listeZone = this.datafields.stream().filter(datafield -> datafield.getTag().equals(zone)).toList();
if (!listeZone.isEmpty()) {
for (Datafield datafield : listeZone) {
List<SubField> subFields = datafield.getSubFields().stream().filter(subField -> subField.getCode().equals("0")).collect(Collectors.toList());
List<SubField> subFields = datafield.getSubFields().stream().filter(subField -> subField.getCode().equals("0")).toList();
subFields.forEach(subField -> {
ppns.add(subField.getValue());
});
Expand All @@ -125,10 +124,10 @@ public List<String> get4XXDollar0(String zone) {
* @return true si le provider est présent en début d'une 035$a, false sinon
*/
public boolean checkProviderIn035a(String provider) {
List<Datafield> listeZone = this.datafields.stream().filter(datafield -> datafield.getTag().equals("035")).collect(Collectors.toList());
List<Datafield> listeZone = this.datafields.stream().filter(datafield -> datafield.getTag().equals("035")).toList();
if (!listeZone.isEmpty()) {
for (Datafield datafield : listeZone) {
List<SubField> subFields = datafield.getSubFields().stream().filter(subField -> subField.getCode().equals("a")).collect(Collectors.toList());
List<SubField> subFields = datafield.getSubFields().stream().filter(subField -> subField.getCode().equals("a")).toList();
if (subFields.stream().anyMatch(sf -> sf.getValue().toLowerCase().startsWith(provider.toLowerCase()))) return true;
}
}
Expand All @@ -147,7 +146,7 @@ public boolean checkProviderInZone(String provider, String zone, String sousZone
if (!listeZone.isEmpty()) {
for (Datafield datafield : listeZone) {
List<SubField> subFields = datafield.getSubFields().stream().filter(subField -> subField.getCode().equals(sousZone)).toList();
if (subFields.stream().anyMatch(sf -> Utilitaire.replaceDiacritics(sf.getValue()).toLowerCase().contains(provider.toLowerCase(Locale.ROOT))))
if (subFields.stream().anyMatch(sf -> Utilitaire.replaceDiacritics(sf.getValue().toLowerCase()).contains(Utilitaire.replaceDiacritics(provider.toLowerCase(Locale.ROOT)))))
return true;
}
}
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/fr/abes/sudoc/service/ProviderService.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,8 @@ public boolean checkProviderDansNoticeGeneral(Optional<ElementDto> providerDispl
}

private boolean checkProviderDansNotice(String provider, NoticeXml notice) {
String providerWithoutDiacritics = Utilitaire.replaceDiacritics(provider);
return notice.checkProviderInZone(providerWithoutDiacritics, "210", "c")
|| notice.checkProviderInZone(providerWithoutDiacritics, "214", "c");
return notice.checkProviderInZone(provider, "210", "c")
|| notice.checkProviderInZone(provider, "214", "c");
}

private boolean checkProviderIn035(Integer providerIdt, NoticeXml notice) throws IOException {
Expand Down

0 comments on commit 1bd4620

Please sign in to comment.