Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEAT : Ajout RCR et EPN dans fichier sauvegarde csv #95

Merged
merged 2 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,11 @@ public void writePpnInFile(String ppn, Exemplaire exemplaire, String typeDoc) th
PrintWriter out = new PrintWriter(bw)) {
// création de la liste de référence pour trouver l'emplacement de chaque zone et sous-zone
List<String> listDeReference = referenceService.constructHeaderCsv();
listDeReference.remove(0);
listDeReference.remove(0);
listDeReference.subList(0, 4).clear();
// ajout de la ligne
out.println(typeDoc + ";" + ppn + ";" + gererZones(listDeReference, exemplaire));
String rcr = exemplaire.findZone("930", 0).findSubLabel("$b");
String epn = exemplaire.findZone("A99", 0).getValeur();
out.println(typeDoc + ";" + ppn + ";" + rcr + ";" + epn + ";" + gererZones(listDeReference, exemplaire));
} catch (IOException ex) {
throw new StorageException("Impossible d'écrire dans le fichier de sauvegarde csv");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ public List<String> constructHeaderCsv() {
List<String> headerCsv = new ArrayList<>();
headerCsv.add("TYPE (008)");
headerCsv.add("PPN");
headerCsv.add("RCR");
headerCsv.add("EPN");
for (ZonesAutorisees zonesAutorisees: listZonesAutorisees) {
if(!zonesAutorisees.getLabelZone().startsWith("L")){
headerCsv.add(zonesAutorisees.getLabelZone()+zonesAutorisees.getSousZonesAutorisees().remove(0).getLibelle());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ public String[] getNoticeExemplaireAvantApres(Demande demande, LigneFichier lign
DemandeSupp demandeSupp = (DemandeSupp) demande;
try {
traitementService.authenticate("M" + demandeSupp.getRcr());
List<Exemplaire> exemplairesExistants = getExemplairesExistants(ligneFichierSupp);
List<Exemplaire> exemplairesExistants = getExemplairesExistants(ligneFichierSupp.getPpn());
//On ne conserve que les EPN de son RCR
exemplairesExistants = exemplairesExistants.stream().filter(exemplaire -> exemplaire.findZone("930", 0).findSubLabel("$b").equals(demandeSupp.getRcr())).toList();
if (exemplairesExistants.isEmpty()) {
Expand Down Expand Up @@ -393,15 +393,7 @@ public String getTypeDocumentFromPpn(String ppn) throws CBSException, IOExceptio
};
}

public List<Exemplaire> getExemplairesExistants(LigneFichierSupp ligneFichierSupp) throws IOException, QueryToSudocException, CBSException, ZoneException {
return getExemplairesExistants(ligneFichierSupp.getPpn());
}

public List<Exemplaire> getExemplairesExistants(String ppn) throws IOException, QueryToSudocException, CBSException, ZoneException {
return getExemplairesExistantsInternal(ppn);
}

private List<Exemplaire> getExemplairesExistantsInternal(String ppn) throws IOException, QueryToSudocException, CBSException, ZoneException {
String query = "che ppn " + ppn;
traitementService.getCbs().search(query);
int nbReponses = traitementService.getCbs().getNbNotices();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package fr.abes.item.core.service;

import fr.abes.cbs.exception.CBSException;
import fr.abes.cbs.exception.ZoneException;
import fr.abes.item.core.entities.item.SousZonesAutorisees;
import fr.abes.item.core.entities.item.ZonesAutorisees;
import fr.abes.item.core.exception.QueryToSudocException;
import fr.abes.item.core.repository.item.IEtatDemandeDao;
import fr.abes.item.core.repository.item.ITraitementDao;
import fr.abes.item.core.repository.item.ITypeExempDao;
Expand All @@ -15,7 +12,6 @@
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

Expand Down Expand Up @@ -65,7 +61,7 @@ void constructHeaderCsv() {
Mockito.when(iZonesAutoriseesDao.findAll()).thenReturn(zonesAutoriseesList);

List<String> test = referenceService.constructHeaderCsv();
List<String> reference = List.of("TYPE (008);PPN;917$a;930$c;$d;".split(";"));
List<String> reference = List.of("TYPE (008);PPN;RCR;EPN;917$a;930$c;$d;".split(";"));

assertEquals(reference,test);

Expand Down
Loading