Skip to content

Commit

Permalink
Fix : Remplacement caractères spéciaux dans requête DAT par espace au…
Browse files Browse the repository at this point in the history
… lieu de rien, suppression biblevel quand pas de date, optimisation sur typerecord
  • Loading branch information
pierre-maraval committed Jan 15, 2025
1 parent c48986c commit 0cd849d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,16 @@ public List<String> datToPpn(Integer date, String auteur, String titre) throws U
request.append(" JOIN AUTORITES.bib_100$a b");
request.append(" ON a.ppn=b.ppn");
if (auteur != null) {
request.append(" WHERE a.typerecord != 'd' and a.typecontrol = 'm' and CONTAINS(a.citation1, '(").append(titre).append(") AND (").append(auteur).append(")')>0 and (substr(b.datas,10,4) = '").append(date).append("' or substr(b.datas,14,4)='").append(date).append("')");
request.append(" WHERE a.typerecord in ('c','n') and a.typecontrol = 'm' and CONTAINS(a.citation1, '(").append(titre).append(") AND (").append(auteur).append(")')>0 and (substr(b.datas,10,4) = '").append(date).append("' or substr(b.datas,14,4)='").append(date).append("')");
} else {
request.append(" WHERE a.typerecord != 'd' and a.typecontrol = 'm' and CONTAINS(a.citation1, '(").append(titre).append(")')>0 and (substr(b.datas,10,4) = '").append(date).append("' or substr(b.datas,14,4)='").append(date).append("')");
request.append(" WHERE a.typerecord in ('c','n') and a.typecontrol = 'm' and CONTAINS(a.citation1, '(").append(titre).append(")')>0 and (substr(b.datas,10,4) = '").append(date).append("' or substr(b.datas,14,4)='").append(date).append("')");
}
} else {
request.append(" FROM biblio_table_generale a");
if (auteur != null) {
request.append(" WHERE a.typerecord != 'd' and a.biblevel='l' and a.typecontrol = 'm' and CONTAINS(a.citation1, '(").append(titre).append(") AND (").append(auteur).append(")')>0");
request.append(" WHERE a.typerecord in ('c','n') and a.typecontrol = 'm' and CONTAINS(a.citation1, '(").append(titre).append(") AND (").append(auteur).append(")')>0");
} else {
request.append(" WHERE a.typerecord != 'd' and a.biblevel='l' and a.typecontrol = 'm' and CONTAINS(a.citation1, '(").append(titre).append(")')>0");
request.append(" WHERE a.typerecord in ('c','n') and a.typecontrol = 'm' and CONTAINS(a.citation1, '(").append(titre).append(")')>0");
}
}
return baseXmlJdbcTemplate.queryForList(request.toString(), String.class);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/fr/abes/sudoc/utils/Utilitaire.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ private static String suppCaracters(String chaine) {
String regex = "[" + charsToRemove.stream()
.map(c -> "\\" + c) // Échapper les caractères spéciaux si nécessaire
.reduce("", (acc, c) -> acc + c) + "]";
return chaine.replaceAll(regex, "");
return chaine.replaceAll(regex, " ");
}

private static String banalisationReservedWords(String chaine) {
Expand Down
1 change: 1 addition & 0 deletions src/test/java/fr/abes/sudoc/utils/UtilitaireTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,5 +113,6 @@ void testReformatageChaineDat() {
Assertions.assertEquals("Assez NEAR de NEAR ces NEAR fichus NEAR TU".toUpperCase(), Utilitaire.formatString("Assez ! de _ ces ~fichus *TU"));
Assertions.assertEquals("Je NEAR {AND} NEAR suis NEAR {WITHIN} NEAR content".toUpperCase(), Utilitaire.formatString("Je AND suis! within content"));
Assertions.assertEquals("Je NEAR {AND} NEAR suis NEAR {WITHIN} NEAR content".toUpperCase(), Utilitaire.formatString("Je AND suis! 'WITHIN' content"));
Assertions.assertEquals("J NEAR y NEAR {AND} NEAR suis NEAR {WITHIN} NEAR content".toUpperCase(), Utilitaire.formatString("J'y AND suis! 'WITHIN' content"));
}
}

0 comments on commit 0cd849d

Please sign in to comment.