Skip to content

Commit

Permalink
FEAT ITEM-304-back-corriger-les-lignes-vides-en-fin-de-fichier
Browse files Browse the repository at this point in the history
  • Loading branch information
EryneKL committed Oct 21, 2024
1 parent e7d4a64 commit f925664
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ protected void checkRcr(String rcrFichier, String rcr, int ligneCourante) throws
* @throws FileCheckingException : erreur de format de fichier
*/
protected void checkPpn(String ppn, int ligneCourante) throws FileCheckingException {
if (!ppn.matches("^\\d{8}[0-9X]$")){
if (!ppn.matches("^(\\d{8}[0-9X])?$")){
throw new FileCheckingException(Constant.ERR_FILE_ERRLINE + ligneCourante + Constant.ERR_FILE_WRONGPPN);
}
}
Expand All @@ -110,7 +110,7 @@ protected void checkPpn(String ppn, int ligneCourante) throws FileCheckingExcept
* @throws FileCheckingException: erreur de format de l'epn
*/
protected void checkEpn(String epn, int ligneCourante) throws FileCheckingException {
if (!epn.matches("^\\d{8}[0-9X]$")) {
if (!epn.matches("^(\\d{8}[0-9X])?$")) {
throw new FileCheckingException(Constant.ERR_FILE_ERRLINE + ligneCourante + Constant.ERR_FILE_WRONGEPN);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,9 @@
import fr.abes.item.core.constant.Constant;
import fr.abes.item.core.constant.TYPE_DEMANDE;
import fr.abes.item.core.entities.item.Demande;
import fr.abes.item.core.exception.FileCheckingException;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

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

@Component
public class FichierPrepareSupp extends FichierPrepare implements Fichier {

Expand All @@ -25,21 +20,4 @@ public FichierPrepareSupp(@Value("") final String filename) {
public void generateFileName(Demande demande) {
this.filename = Constant.FIC_CORRESPONDANCE_NAME + demande.getId() + Constant.EXTENSIONCSV;
}

public void controleIntegriteDesCorrespondances() throws IOException, FileCheckingException {
List<String> epnSansCorrespondance = new ArrayList<>();
try (FileReader fileReader = new FileReader(path.resolve(filename).toString());
BufferedReader reader = new BufferedReader(fileReader);) {
reader.readLine();//cette ligne enleve le header
reader.lines().forEach(line -> {
if(line.split(";")[0].isEmpty()){
epnSansCorrespondance.add(line.split(";")[2]);
}
});
}
if (!epnSansCorrespondance.isEmpty()) {
throw new FileCheckingException("EPN sans correspondance : " + String.join(", ", epnSansCorrespondance));
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,6 @@ private void preparerFichierEnPrep(DemandeSupp demande) throws IOException, Dema
fichierPrepare.ecrireEnTete();
//Alimentation du fichier par appel à la procédure Oracle ppntoepn
appelProcStockee(demande.getRcr(), demande.getTypeSuppression());
if(demande.getTypeSuppression().equals(TYPE_SUPPRESSION.EPN))
fichierPrepare.controleIntegriteDesCorrespondances();
fichierPrepare.trierLignesDeCorrespondances();
demande.setEtatDemande(new EtatDemande(Constant.ETATDEM_PREPAREE));
save(demande);
Expand Down

0 comments on commit f925664

Please sign in to comment.