Skip to content

Commit

Permalink
Merge pull request #101 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 31, 2024
2 parents 0b60d69 + 9ba8db7 commit 288a58f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 30 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</parent>
<groupId>fr.abes</groupId>
<artifactId>sudoc</artifactId>
<version>0.0.12</version>
<version>0.0.13-SNAPSHOT</version>
<packaging>jar</packaging>
<name>sudoc</name>
<description>webservices de récupération de ppns dans le sudoc</description>
Expand Down
8 changes: 0 additions & 8 deletions src/main/java/fr/abes/sudoc/SudocWebservicesApplication.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package fr.abes.sudoc;

import fr.abes.cbs.process.ProcessCBS;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;

import java.util.TimeZone;

Expand All @@ -21,10 +19,4 @@ public static void main(String[] args) {
@Override
public void run(String... args) {
}

@Bean
public ProcessCBS initCbs() {
return new ProcessCBS();
}

}
44 changes: 23 additions & 21 deletions src/main/java/fr/abes/sudoc/service/SudocService.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,33 +25,35 @@ public class SudocService {
@Value("${sudoc.passwd}")
private String passCbs;

@Autowired
private ProcessCBS cbs;

@Getter
private String query;

public List<String> getPpnFromDat(Integer annee, String auteur, String titre) throws CBSException {
log.debug("serveur : " + this.serveurCbs + " / port : " + this.port);
this.cbs.authenticate(this.serveurCbs, this.port, this.loginCbs, this.passCbs);
if (annee != null && auteur != null) {
this.query = "tno t ; apu " + annee + " ; che aut " + auteur + " et mti " + titre;
} else if (annee != null) {
this.query = "tno t ; apu " + annee + " ; che mti " + titre;
} else {
if (auteur != null) {
this.query = "tno t ; che aut " + auteur + " et mti " + titre;
ProcessCBS cbs = new ProcessCBS();
try {
log.debug("serveur : " + this.serveurCbs + " / port : " + this.port);
cbs.authenticate(this.serveurCbs, this.port, this.loginCbs, this.passCbs);
if (annee != null && auteur != null) {
this.query = "tno t ; apu " + annee + " ; che aut " + auteur + " et mti " + titre;
} else if (annee != null) {
this.query = "tno t ; apu " + annee + " ; che mti " + titre;
} else {
this.query = "tno t ; che mti " + titre;
if (auteur != null) {
this.query = "tno t ; che aut " + auteur + " et mti " + titre;
} else {
this.query = "tno t ; che mti " + titre;
}
}
}

log.debug("requête : " + this.query);
this.cbs.search(this.query);
return switch (this.cbs.getNbNotices()) {
case 0 -> new ArrayList<>();
case 1 -> Collections.singletonList(this.cbs.getPpnEncours());
default -> Arrays.asList(this.cbs.getListePpn().toString().split(";"));
};
log.debug("requête : " + this.query);
cbs.search(this.query);
return switch (cbs.getNbNotices()) {
case 0 -> new ArrayList<>();
case 1 -> Collections.singletonList(cbs.getPpnEncours());
default -> Arrays.asList(cbs.getListePpn().toString().split(";"));
};
} finally {
cbs.disconnect();
}
}
}

0 comments on commit 288a58f

Please sign in to comment.