Skip to content

Commit

Permalink
fix cas ou plusieurs DOI en sortie de la base xml pour un ppn donné
Browse files Browse the repository at this point in the history
  • Loading branch information
pierre-maraval committed Sep 5, 2024
1 parent 6eb6fff commit bca1a09
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ public String baconProvider035(Integer provider) throws SQLRecoverableException,
}


public String doiToPpn(String doi) throws UncategorizedSQLException, EmptyResultDataAccessException {
public List<String> doiToPpn(String doi) throws UncategorizedSQLException {
StringBuilder request = new StringBuilder("select a.ppn from autorites.biblio_table_FRBR_0xx a where ");
request.append("upper(SUBSTR(a.datas,1,50)) = '");
request.append(doi.toUpperCase());
request.append("' and a.tag='017$a' ");
request.append("and a.id in (select /*+ no_index(b BIBLIO_TABLE_FRBR_0XX_IDX_DATA) */ id from autorites.biblio_table_FRBR_0xx b where ");
request.append("a.id=b.id and ");
request.append("b.tag='017$2' and SUBSTR(b.datas,1,50)='DOI' and a.POSFIELD=b.POSFIELD and b.POSSUBFIELD='2')");
return baseXmlJdbcTemplate.queryForObject(request.toString(), String.class);
return baseXmlJdbcTemplate.queryForList(request.toString(), String.class);
}
}
13 changes: 9 additions & 4 deletions src/main/java/fr/abes/sudoc/service/DoiService.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,17 @@ public boolean checkFormat(String doi) {
@Override
public List<String> getPpnFromIdentifiant(String doi) throws IOException, IllegalPpnException {
try {
return Collections.singletonList(caller.doiToPpn(doi));
List<String> result = caller.doiToPpn(doi);
if (result.isEmpty())
throw new IllegalPpnException("Aucune notice ne correspond à la recherche sur le doi " + doi);
else
if (result.size() != 1) {
throw new IllegalPpnException("Plusieurs résultats à la recherche sur doi " + doi);
} else {
return Collections.singletonList(result.get(0));
}
} catch (UncategorizedSQLException ex) {
throw new IOException("Incident technique lors de l'accès à la base de données");
} catch (EmptyResultDataAccessException ex) {
throw new IllegalPpnException("Aucune notice ne correspond à la recherche");
}
}

}

0 comments on commit bca1a09

Please sign in to comment.