Program: 59007
Project: 59007
Buggy source:
/** 
 * Méthode réalisant l'export SI - Agresso des fichiers détails
 * @param mlr
 * @param fileName
 * @throws AxelorException
 * @throws IOException 
 */
@SuppressWarnings("String_Node_Str") public void exportMoveLineAllTypeSelectFILE2(MoveLineReport moveLineReport,String fileName) throws AxelorException, IOException {
  LOG.info("String_Node_Str");
  Company company=moveLineReport.getCompany();
  String companyCode="String_Node_Str";
  String moveLineQueryStr="String_Node_Str";
  int typeSelect=moveLineReport.getTypeSelect();
  if (company != null) {
    companyCode=company.getCode();
    moveLineQueryStr+=String.format("String_Node_Str",company.getId());
  }
  if (moveLineReport.getJournal() != null) {
    moveLineQueryStr+=String.format("String_Node_Str",moveLineReport.getJournal().getId());
  }
 else {
    moveLineQueryStr+=String.format("String_Node_Str",moveLineReportService.getJournalType(moveLineReport).getId());
  }
  if (moveLineReport.getPeriod() != null) {
    moveLineQueryStr+=String.format("String_Node_Str",moveLineReport.getPeriod().getId());
  }
  if (moveLineReport.getDateFrom() != null) {
    moveLineQueryStr+=String.format("String_Node_Str",moveLineReport.getDateFrom().toString());
  }
  if (moveLineReport.getDateTo() != null) {
    moveLineQueryStr+=String.format("String_Node_Str",moveLineReport.getDateTo().toString());
  }
  if (moveLineReport.getDate() != null) {
    moveLineQueryStr+=String.format("String_Node_Str",moveLineReport.getDate().toString());
  }
  if (typeSelect != 8) {
    moveLineQueryStr+=String.format("String_Node_Str");
  }
  moveLineQueryStr+=String.format("String_Node_Str",moveLineReport.getId());
  Query queryDate=JPA.em().createQuery("String_Node_Str" + moveLineQueryStr + "String_Node_Str");
  List<LocalDate> dates=new ArrayList<LocalDate>();
  dates=queryDate.getResultList();
  LOG.debug("String_Node_Str",dates);
  List<String[]> allMoveLineData=new ArrayList<String[]>();
  for (  LocalDate localDate : dates) {
    Query queryExportAgressoRef=JPA.em().createQuery("String_Node_Str" + "String_Node_Str" + localDate.toString() + "String_Node_Str"+ moveLineQueryStr);
    List<String> exportAgressoRefs=new ArrayList<String>();
    exportAgressoRefs=queryExportAgressoRef.getResultList();
    for (    String exportAgressoRef : exportAgressoRefs) {
      if (exportAgressoRef != null && !exportAgressoRef.isEmpty()) {
        int sequence=1;
        Query query=JPA.em().createQuery("String_Node_Str" + "String_Node_Str" + localDate.toString() + "String_Node_Str"+ exportAgressoRef+ "String_Node_Str"+ moveLineQueryStr+ "String_Node_Str");
        List<Long> accountIds=new ArrayList<Long>();
        accountIds=query.getResultList();
        LOG.debug("String_Node_Str",accountIds);
        for (        Long accountId : accountIds) {
          if (accountId != null) {
            String accountCode=Account.find(accountId).getCode();
            List<MoveLine> moveLines=MoveLine.filter("String_Node_Str" + localDate.toString() + "String_Node_Str"+ exportAgressoRef+ "String_Node_Str"+ moveLineQueryStr,accountId).fetch();
            LOG.debug("String_Node_Str",moveLines);
            if (moveLines.size() > 0) {
              List<MoveLine> moveLineList=this.consolidateMoveLineByAnalyticAxis(moveLines);
              List<MoveLine> sortMoveLineList=this.sortMoveLineByDebitCredit(moveLineList);
              for (              MoveLine moveLine3 : sortMoveLineList) {
                Journal journal=moveLine3.getMove().getJournal();
                LocalDate date=moveLine3.getDate();
                String items[]=null;
                if (typeSelect == 9) {
                  items=new String[13];
                }
 else {
                  items=new String[12];
                }
                items[0]=companyCode;
                items[1]=journal.getExportCode();
                items[2]=moveLine3.getMove().getExportNumber();
                items[3]=String.format("String_Node_Str",sequence);
                sequence++;
                items[4]=accountCode;
                BigDecimal totAmt=moveLine3.getCredit().subtract(moveLine3.getDebit());
                String moveLineSign="String_Node_Str";
                if (totAmt.compareTo(BigDecimal.ZERO) == -1) {
                  moveLineSign="String_Node_Str";
                  totAmt=totAmt.negate();
                }
                items[5]=moveLineSign;
                items[6]=totAmt.toString();
                String activeStr="String_Node_Str";
                String crbStr="String_Node_Str";
                String metiertr="String_Node_Str";
                String siteStr="String_Node_Str";
                for (                AnalyticAccount analyticAccount : moveLine3.getAnalyticAccountSet()) {
                  if (analyticAccount.getAnalyticAxis() != null && analyticAccount.getAnalyticAxis().getCode().equals("String_Node_Str")) {
                    activeStr=analyticAccount.getCode();
                  }
                  if (analyticAccount.getAnalyticAxis() != null && analyticAccount.getAnalyticAxis().getCode().equals("String_Node_Str")) {
                    crbStr=analyticAccount.getCode();
                  }
                  if (analyticAccount.getAnalyticAxis() != null && analyticAccount.getAnalyticAxis().getCode().equals("String_Node_Str")) {
                    metiertr=analyticAccount.getCode();
                  }
                  if (analyticAccount.getAnalyticAxis() != null && analyticAccount.getAnalyticAxis().getCode().equals("String_Node_Str")) {
                    siteStr=analyticAccount.getCode();
                  }
                }
                if (typeSelect == 9) {
                  items[7]="String_Node_Str";
                  items[8]=crbStr;
                  items[9]=siteStr;
                  items[10]=metiertr;
                  items[11]=activeStr;
                  items[12]=String.format("String_Node_Str",journal.getCode(),date.toString("String_Node_Str"));
                }
 else {
                  items[7]=crbStr;
                  items[8]=siteStr;
                  items[9]=metiertr;
                  items[10]=activeStr;
                  items[11]=String.format("String_Node_Str",journal.getCode(),date.toString("String_Node_Str"));
                }
                allMoveLineData.add(items);
              }
            }
          }
        }
      }
    }
  }
  String filePath=accountConfigService.getExportPath(accountConfigService.getAccountConfig(company));
  new File(filePath).mkdirs();
  LOG.debug("String_Node_Str",filePath,fileName);
  CsvTool.csvWriter(filePath,fileName,'|',null,allMoveLineData);
}

Fixed version (ground truth):
/** 
 * Méthode réalisant l'export SI - Agresso des fichiers détails
 * @param mlr
 * @param fileName
 * @throws AxelorException
 * @throws IOException 
 */
@SuppressWarnings("String_Node_Str") public void exportMoveLineAllTypeSelectFILE2(MoveLineReport moveLineReport,String fileName) throws AxelorException, IOException {
  LOG.info("String_Node_Str");
  Company company=moveLineReport.getCompany();
  String companyCode="String_Node_Str";
  String moveLineQueryStr="String_Node_Str";
  int typeSelect=moveLineReport.getTypeSelect();
  if (company != null) {
    companyCode=company.getCode();
    moveLineQueryStr+=String.format("String_Node_Str",company.getId());
  }
  if (moveLineReport.getJournal() != null) {
    moveLineQueryStr+=String.format("String_Node_Str",moveLineReport.getJournal().getId());
  }
 else {
    moveLineQueryStr+=String.format("String_Node_Str",moveLineReportService.getJournalType(moveLineReport).getId());
  }
  if (moveLineReport.getPeriod() != null) {
    moveLineQueryStr+=String.format("String_Node_Str",moveLineReport.getPeriod().getId());
  }
  if (moveLineReport.getDateFrom() != null) {
    moveLineQueryStr+=String.format("String_Node_Str",moveLineReport.getDateFrom().toString());
  }
  if (moveLineReport.getDateTo() != null) {
    moveLineQueryStr+=String.format("String_Node_Str",moveLineReport.getDateTo().toString());
  }
  if (moveLineReport.getDate() != null) {
    moveLineQueryStr+=String.format("String_Node_Str",moveLineReport.getDate().toString());
  }
  if (typeSelect != 8) {
    moveLineQueryStr+=String.format("String_Node_Str");
  }
  moveLineQueryStr+=String.format("String_Node_Str",moveLineReport.getId());
  Query queryDate=JPA.em().createQuery("String_Node_Str" + moveLineQueryStr + "String_Node_Str");
  List<LocalDate> dates=new ArrayList<LocalDate>();
  dates=queryDate.getResultList();
  LOG.debug("String_Node_Str",dates);
  List<String[]> allMoveLineData=new ArrayList<String[]>();
  for (  LocalDate localDate : dates) {
    Query queryExportAgressoRef=JPA.em().createQuery("String_Node_Str" + "String_Node_Str" + localDate.toString() + "String_Node_Str"+ moveLineQueryStr);
    List<String> exportAgressoRefs=new ArrayList<String>();
    exportAgressoRefs=queryExportAgressoRef.getResultList();
    for (    String exportAgressoRef : exportAgressoRefs) {
      if (exportAgressoRef != null && !exportAgressoRef.isEmpty()) {
        int sequence=1;
        Query query=JPA.em().createQuery("String_Node_Str" + "String_Node_Str" + localDate.toString() + "String_Node_Str"+ exportAgressoRef+ "String_Node_Str"+ moveLineQueryStr+ "String_Node_Str");
        List<Long> accountIds=new ArrayList<Long>();
        accountIds=query.getResultList();
        LOG.debug("String_Node_Str",accountIds);
        for (        Long accountId : accountIds) {
          if (accountId != null) {
            String accountCode=Account.find(accountId).getCode();
            List<MoveLine> moveLines=(List<MoveLine>)MoveLine.filter("String_Node_Str" + localDate.toString() + "String_Node_Str"+ exportAgressoRef+ "String_Node_Str"+ moveLineQueryStr,accountId).fetch();
            LOG.debug("String_Node_Str",moveLines);
            if (moveLines.size() > 0) {
              List<MoveLine> moveLineList=this.consolidateMoveLineByAnalyticAxis(moveLines);
              List<MoveLine> sortMoveLineList=this.sortMoveLineByDebitCredit(moveLineList);
              for (              MoveLine moveLine3 : sortMoveLineList) {
                Journal journal=moveLine3.getMove().getJournal();
                LocalDate date=moveLine3.getDate();
                String items[]=null;
                if (typeSelect == 9) {
                  items=new String[13];
                }
 else {
                  items=new String[12];
                }
                items[0]=companyCode;
                items[1]=journal.getExportCode();
                items[2]=moveLine3.getMove().getExportNumber();
                items[3]=String.format("String_Node_Str",sequence);
                sequence++;
                items[4]=accountCode;
                BigDecimal totAmt=moveLine3.getCredit().subtract(moveLine3.getDebit());
                String moveLineSign="String_Node_Str";
                if (totAmt.compareTo(BigDecimal.ZERO) == -1) {
                  moveLineSign="String_Node_Str";
                  totAmt=totAmt.negate();
                }
                items[5]=moveLineSign;
                items[6]=totAmt.toString();
                String activeStr="String_Node_Str";
                String crbStr="String_Node_Str";
                String metiertr="String_Node_Str";
                String siteStr="String_Node_Str";
                for (                AnalyticAccount analyticAccount : moveLine3.getAnalyticAccountSet()) {
                  if (analyticAccount.getAnalyticAxis() != null && analyticAccount.getAnalyticAxis().getCode().equals("String_Node_Str")) {
                    activeStr=analyticAccount.getCode();
                  }
                  if (analyticAccount.getAnalyticAxis() != null && analyticAccount.getAnalyticAxis().getCode().equals("String_Node_Str")) {
                    crbStr=analyticAccount.getCode();
                  }
                  if (analyticAccount.getAnalyticAxis() != null && analyticAccount.getAnalyticAxis().getCode().equals("String_Node_Str")) {
                    metiertr=analyticAccount.getCode();
                  }
                  if (analyticAccount.getAnalyticAxis() != null && analyticAccount.getAnalyticAxis().getCode().equals("String_Node_Str")) {
                    siteStr=analyticAccount.getCode();
                  }
                }
                if (typeSelect == 9) {
                  items[7]="String_Node_Str";
                  items[8]=crbStr;
                  items[9]=siteStr;
                  items[10]=metiertr;
                  items[11]=activeStr;
                  items[12]=String.format("String_Node_Str",journal.getCode(),date.toString("String_Node_Str"));
                }
 else {
                  items[7]=crbStr;
                  items[8]=siteStr;
                  items[9]=metiertr;
                  items[10]=activeStr;
                  items[11]=String.format("String_Node_Str",journal.getCode(),date.toString("String_Node_Str"));
                }
                allMoveLineData.add(items);
              }
            }
          }
        }
      }
    }
  }
  String filePath=accountConfigService.getExportPath(accountConfigService.getAccountConfig(company));
  new File(filePath).mkdirs();
  LOG.debug("String_Node_Str",filePath,fileName);
  CsvTool.csvWriter(filePath,fileName,'|',null,allMoveLineData);
}