Skip to content

Commit

Permalink
feat: rename chargement bo for readability
Browse files Browse the repository at this point in the history
  • Loading branch information
Nolife999 committed Oct 8, 2023
1 parent 0cf606a commit 49d857a
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,19 @@ public class FileIdCard {
private String periodicite;
private final String integrationDate = DateConversion.queryDateConversion(new Date());

private FileIdCardChargement regleChargement;
public FileIdCardChargement getRegleChargement() {
return regleChargement;
private IdCardChargement idCardChargement;
public IdCardChargement getIdCardChargement() {
return idCardChargement;
}
public void setRegleChargement(FileIdCardChargement regleChargement) {
this.regleChargement = regleChargement;
public void setIdCardChargement(IdCardChargement regleChargement) {
this.idCardChargement = regleChargement;
}


public FileIdCard(String idSource) {
this.fileName = idSource;
}

public void setFileAttributes(String idNorme, String validite, String periodicite) {
public void setFileIdCard(String idNorme, String validite, String periodicite) {
this.idNorme = idNorme;
this.validite = validite;
this.periodicite = periodicite;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
* @author S4LWO8
*
*/
public class FileIdCardChargement {
public class IdCardChargement {

private TypeChargement typeChargement;
private String format;
private String delimiter;


public FileIdCardChargement(TypeChargement typeChargement, String delimiter, String format) {
public IdCardChargement(TypeChargement typeChargement, String delimiter, String format) {
super();
this.typeChargement = typeChargement;
this.format = format;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public void execQueryCopyCsv(InputStream streamContent) throws ArcException {

boolean ignoreFirstLine = (parser.getValue(FormatRulesCsv.HEADERS) == null);

String separateur = fileIdCard.getRegleChargement().getDelimiter();
String separateur = fileIdCard.getIdCardChargement().getDelimiter();

String quote = parser.getValue(FormatRulesCsv.QUOTE);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ private void calculerNormeAndValidite(FileIdCard normeOk, String requeteFichier)

NormeRules normFound = listeNorme.get(Integer.parseInt(result.get(0).get(0)));

normeOk.setFileAttributes(normFound.getIdNorme(), result.get(0).get(2), normFound.getPeriodicite());
normeOk.setFileIdCard(normFound.getIdNorme(), result.get(0).get(2), normFound.getPeriodicite());

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,14 @@ private void copyCsvFileToDatabase() throws ArcException {
StaticLoggerDispatcher.info(LOGGER, "** CSVtoBase begin **");

StaticLoggerDispatcher.debug(LOGGER,
String.format("contenu delimiter %s", fileIdCard.getRegleChargement().getDelimiter()));
String.format("contenu delimiter %s", fileIdCard.getIdCardChargement().getDelimiter()));
StaticLoggerDispatcher.debug(LOGGER,
String.format("contenu format %s", fileIdCard.getRegleChargement().getFormat()));
String.format("contenu format %s", fileIdCard.getIdCardChargement().getFormat()));

// update delimiter
fileIdCard.getRegleChargement()
fileIdCard.getIdCardChargement()
.setDelimiter(ObjectUtils.firstNonNull(
dao.execQueryEvaluateCharExpression(fileIdCard.getRegleChargement().getDelimiter().trim()),
dao.execQueryEvaluateCharExpression(fileIdCard.getIdCardChargement().getDelimiter().trim()),
Delimiters.DEFAULT_CSV_DELIMITER));

// update quote
Expand Down Expand Up @@ -122,7 +122,7 @@ private void copyCsvFileToDatabase() throws ArcException {
*/
private void computeHeaders() throws ArcException {
String userDefinedHeaders = parser.getValue(FormatRulesCsv.HEADERS);
String csvDelimiter = fileIdCard.getRegleChargement().getDelimiter();
String csvDelimiter = fileIdCard.getIdCardChargement().getDelimiter();

// si le headers n'est pas spécifié, alors on le cherche dans le fichier en
// premier ligne
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@ private List<String> initialisationOutputStream(Map<String, String> arbreFormat,

ecrireXML("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");

String rubrique = ManipString.substringBeforeFirst(ligne, fileIdCard.getRegleChargement().getDelimiter());
String donnee = ManipString.substringAfterFirst(ligne, fileIdCard.getRegleChargement().getDelimiter());
String rubrique = ManipString.substringBeforeFirst(ligne, fileIdCard.getIdCardChargement().getDelimiter());
String donnee = ManipString.substringAfterFirst(ligne, fileIdCard.getIdCardChargement().getDelimiter());

// On retire les quotes de début et fin de manière violente
donnee = donnee.substring(1, donnee.length() - 1);
Expand Down Expand Up @@ -234,8 +234,8 @@ private List<String> lectureLigne(Map<String, String> arbreFormat,
String pere;
String rubriqueCourante;

rubrique = ManipString.substringBeforeFirst(ligne, fileIdCard.getRegleChargement().getDelimiter());
donnee = ManipString.substringAfterFirst(ligne, fileIdCard.getRegleChargement().getDelimiter());
rubrique = ManipString.substringBeforeFirst(ligne, fileIdCard.getIdCardChargement().getDelimiter());
donnee = ManipString.substringAfterFirst(ligne, fileIdCard.getIdCardChargement().getDelimiter());

// On retire les quotes de début et fin de manière violente
donnee = donnee.substring(1, donnee.length() - 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ public void initialisation() throws ArcException {
java.util.Date beginDate = new java.util.Date();

this.format = new ArrayList<>();
if (this.fileIdCard.getRegleChargement().getFormat() != null) {
for (String rule : this.fileIdCard.getRegleChargement().getFormat().split("\n")) {
if (this.fileIdCard.getIdCardChargement().getFormat() != null) {
for (String rule : this.fileIdCard.getIdCardChargement().getFormat().split("\n")) {
this.format.add(new Pair<>(rule.split(",")[0].trim(), rule.split(",")[1].trim()));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public void setValue(T t, String value) {


public void parseFormatRules() {
String formatRules = this.fileIdCard.getRegleChargement().getFormat();
String formatRules = this.fileIdCard.getIdCardChargement().getFormat();
if (formatRules == null || formatRules.isBlank()) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import fr.insee.arc.core.service.p2chargement.archiveloader.IArchiveFileLoader;
import fr.insee.arc.core.service.p2chargement.bo.FileIdCard;
import fr.insee.arc.core.service.p2chargement.bo.NormeRules;
import fr.insee.arc.core.service.p2chargement.bo.FileIdCardChargement;
import fr.insee.arc.core.service.p2chargement.bo.IdCardChargement;
import fr.insee.arc.core.service.p2chargement.engine.ChargementBrut;
import fr.insee.arc.core.service.p2chargement.engine.IChargeur;
import fr.insee.arc.core.service.p2chargement.factory.ChargeurFactory;
Expand Down Expand Up @@ -274,7 +274,7 @@ private IChargeur chooseLoader() throws ArcException {

ChargeurFactory chargeurFactory = new ChargeurFactory(this);

return chargeurFactory.getChargeur(this.fileIdCard.getRegleChargement().getTypeChargement());
return chargeurFactory.getChargeur(this.fileIdCard.getIdCardChargement().getTypeChargement());
}

/**
Expand All @@ -301,7 +301,7 @@ private void calculerTypeFichier() throws ArcException {
throw new ArcException(ArcExceptionMessage.LOAD_RULES_NOT_FOUND, fileIdCard.getIdNorme());
}

fileIdCard.setRegleChargement(new FileIdCardChargement(
fileIdCard.setIdCardChargement(new IdCardChargement(
TypeChargement.getEnum(regle.get(ColumnEnum.TYPE_FICHIER.getColumnName()).get(0)),
regle.get(ColumnEnum.DELIMITER.getColumnName()).get(0)
, regle.get(ColumnEnum.FORMAT.getColumnName()).get(0)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public ArbreFormat(FileIdCard fileIdCard) throws ArcException {
SAXParser saxParser = SecuredSaxParser.buildSecuredSaxParser();
FormatFichierHandler formatHandler = new FormatFichierHandler();

saxParser.parse(new InputSource(new StringReader(fileIdCard.getRegleChargement().getFormat())), formatHandler);
saxParser.parse(new InputSource(new StringReader(fileIdCard.getIdCardChargement().getFormat())), formatHandler);

this.arbreHierachieDuFichier = formatHandler.getArbre();
calculerFeuilles();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public ResponseEntity<ReturnView> executeEngineClient(
bodyPojo.fileContent.getBytes(StandardCharsets.UTF_8));) {

FileIdCard fileIdCard = new FileIdCard(bodyPojo.fileName);
fileIdCard.setFileAttributes(bodyPojo.norme, bodyPojo.validite, bodyPojo.periodicite);
fileIdCard.setFileIdCard(bodyPojo.norme, bodyPojo.validite, bodyPojo.periodicite);

ChargeurXmlComplexe chargeur = new ChargeurXmlComplexe(connection, fileIdCard, inputStream, currentTemporaryTable(i));
chargeur.executeEngine();
Expand Down

0 comments on commit 49d857a

Please sign in to comment.