Skip to content

Commit

Permalink
Merge pull request #97 from abes-esr/develop
Browse files Browse the repository at this point in the history
Merge develop dans main
  • Loading branch information
SamuelQuetin authored Oct 8, 2024
2 parents 1b2fd57 + b53de26 commit 7cd95d3
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.11.0</version>
<version>2.14.0</version>
</dependency>

<!--Validation-->
Expand Down
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
6 changes: 5 additions & 1 deletion src/main/java/fr/abes/sudoc/service/IsbnService.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ public IsbnService(BaseXmlFunctionsCaller caller) {

@Override
public boolean checkFormat(String isbn) {
return isbn != null && isbn.matches("^[0-9]((?:-?[0-9]){9}|(?:-?[0-9]){8}X|(?:-?[0-9]){12})$");
//regexp permettant de vérifier
//ISBN 10 et 13
//avec ou sans tiret
//avec prise en compte du caractère de controle X en fin
return isbn != null && isbn.matches("^(?:ISBN(?:-1[03])?:?\\\\s*)?(?=[-0-9X\\\\s]{10,17}$)(?:97[89][- ]?)?([0-9]{1,5})[- ]?([0-9]+)[- ]?([0-9]+)[- ]?([0-9X])$");
}

@Override
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 7cd95d3

Please sign in to comment.