Program: 59008
Project: 59008
Buggy source:
/** 
 * Méthode réalisant l'export SI - Agresso des en-têtes pour les journaux de type achat
 * @param mlr
 * @param replay
 * @throws AxelorException
 * @throws IOException 
 */
@SuppressWarnings("String_Node_Str") @Transactional(rollbackOn={AxelorException.class,Exception.class}) public void exportMoveLineTypeSelect9FILE1(MoveLineReport moveLineReport,boolean replay) throws AxelorException, IOException {
  LOG.info("String_Node_Str");
  Company company=moveLineReport.getCompany();
  String dateQueryStr=String.format("String_Node_Str",company.getId());
  JournalType journalType=moveLineReportService.getJournalType(moveLineReport);
  if (moveLineReport.getJournal() != null) {
    dateQueryStr+=String.format("String_Node_Str",moveLineReport.getJournal().getId());
  }
 else {
    dateQueryStr+=String.format("String_Node_Str",journalType.getId());
  }
  if (moveLineReport.getPeriod() != null) {
    dateQueryStr+=String.format("String_Node_Str",moveLineReport.getPeriod().getId());
  }
  if (replay) {
    dateQueryStr+=String.format("String_Node_Str",moveLineReport.getId());
  }
 else {
    dateQueryStr+="String_Node_Str";
  }
  dateQueryStr+="String_Node_Str";
  Query dateQuery=JPA.em().createQuery("String_Node_Str" + dateQueryStr + "String_Node_Str");
  List<LocalDate> allDates=new ArrayList<LocalDate>();
  allDates=dateQuery.getResultList();
  LOG.debug("String_Node_Str",allDates);
  List<String[]> allMoveData=new ArrayList<String[]>();
  String companyCode="String_Node_Str";
  String reference="String_Node_Str";
  String moveQueryStr="String_Node_Str";
  String moveLineQueryStr="String_Node_Str";
  if (moveLineReport.getRef() != null) {
    reference=moveLineReport.getRef();
  }
  if (company != null) {
    companyCode=company.getCode();
    moveQueryStr+=String.format("String_Node_Str",company.getId());
  }
  if (moveLineReport.getPeriod() != null) {
    moveQueryStr+=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 (replay) {
    moveQueryStr+=String.format("String_Node_Str",moveLineReport.getId());
  }
 else {
    moveQueryStr+="String_Node_Str";
  }
  LocalDate interfaceDate=moveLineReport.getDate();
  for (  LocalDate dt : allDates) {
    List<Journal> journalList=Journal.filter("String_Node_Str",journalType).fetch();
    if (moveLineReport.getJournal() != null) {
      journalList=new ArrayList<Journal>();
      journalList.add(moveLineReport.getJournal());
    }
    for (    Journal journal : journalList) {
      List<Move> moveList=Move.filter("String_Node_Str" + moveQueryStr,dt,journal).fetch();
      String journalCode=journal.getExportCode();
      int moveListSize=moveList.size();
      if (moveListSize > 0) {
        int i=0;
        for (        Move move : moveList) {
          List<MoveLine> moveLineList=MoveLine.filter("String_Node_Str" + moveLineQueryStr,moveList).fetch();
          if (moveLineList.size() > 0) {
            String exportNumber=this.getPurchaseExportNumber(company);
            String periodCode=move.getPeriod().getFromDate().toString("String_Node_Str");
            BigDecimal totalCredit=this.getSumCredit(moveLineList);
            String invoiceId="String_Node_Str";
            String dueDate="String_Node_Str";
            if (move.getInvoice() != null) {
              invoiceId=move.getInvoice().getInvoiceId();
              dueDate=move.getInvoice().getDueDate().toString();
            }
            MoveLine firstMoveLine=moveLineList.get(0);
            String items[]=new String[12];
            items[0]=companyCode;
            items[1]=journalCode;
            items[2]=exportNumber;
            items[3]=interfaceDate.toString("String_Node_Str");
            items[4]="String_Node_Str";
            items[5]=invoiceId;
            items[6]=dueDate;
            items[7]=firstMoveLine.getAccount().getCode();
            items[8]=totalCredit.toString();
            items[9]=reference;
            items[10]=dt.toString("String_Node_Str");
            items[11]=periodCode;
            allMoveData.add(items);
            this.updateMove(move,moveLineReport,interfaceDate,exportNumber);
            if (i % 10 == 0) {
              JPA.clear();
            }
            if (i++ % 100 == 0) {
              LOG.debug("String_Node_Str",i,moveListSize);
            }
          }
        }
      }
    }
  }
  String fileName="String_Node_Str" + todayTime.toString("String_Node_Str") + "String_Node_Str";
  String filePath=accountConfigService.getExportPath(accountConfigService.getAccountConfig(company));
  new File(filePath).mkdirs();
  LOG.debug("String_Node_Str",filePath,fileName);
  CsvTool.csvWriter(filePath,fileName,'|',null,allMoveData);
}

Fixed version (ground truth):
/** 
 * Méthode réalisant l'export SI - Agresso des en-têtes pour les journaux de type achat
 * @param mlr
 * @param replay
 * @throws AxelorException
 * @throws IOException 
 */
@SuppressWarnings("String_Node_Str") @Transactional(rollbackOn={AxelorException.class,Exception.class}) public void exportMoveLineTypeSelect9FILE1(MoveLineReport moveLineReport,boolean replay) throws AxelorException, IOException {
  LOG.info("String_Node_Str");
  Company company=moveLineReport.getCompany();
  String dateQueryStr=String.format("String_Node_Str",company.getId());
  JournalType journalType=moveLineReportService.getJournalType(moveLineReport);
  if (moveLineReport.getJournal() != null) {
    dateQueryStr+=String.format("String_Node_Str",moveLineReport.getJournal().getId());
  }
 else {
    dateQueryStr+=String.format("String_Node_Str",journalType.getId());
  }
  if (moveLineReport.getPeriod() != null) {
    dateQueryStr+=String.format("String_Node_Str",moveLineReport.getPeriod().getId());
  }
  if (replay) {
    dateQueryStr+=String.format("String_Node_Str",moveLineReport.getId());
  }
 else {
    dateQueryStr+="String_Node_Str";
  }
  dateQueryStr+="String_Node_Str";
  Query dateQuery=JPA.em().createQuery("String_Node_Str" + dateQueryStr + "String_Node_Str");
  List<LocalDate> allDates=new ArrayList<LocalDate>();
  allDates=dateQuery.getResultList();
  LOG.debug("String_Node_Str",allDates);
  List<String[]> allMoveData=new ArrayList<String[]>();
  String companyCode="String_Node_Str";
  String reference="String_Node_Str";
  String moveQueryStr="String_Node_Str";
  String moveLineQueryStr="String_Node_Str";
  if (moveLineReport.getRef() != null) {
    reference=moveLineReport.getRef();
  }
  if (company != null) {
    companyCode=company.getCode();
    moveQueryStr+=String.format("String_Node_Str",company.getId());
  }
  if (moveLineReport.getPeriod() != null) {
    moveQueryStr+=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 (replay) {
    moveQueryStr+=String.format("String_Node_Str",moveLineReport.getId());
  }
 else {
    moveQueryStr+="String_Node_Str";
  }
  LocalDate interfaceDate=moveLineReport.getDate();
  for (  LocalDate dt : allDates) {
    List<Journal> journalList=(List<Journal>)Journal.filter("String_Node_Str",journalType).fetch();
    if (moveLineReport.getJournal() != null) {
      journalList=new ArrayList<Journal>();
      journalList.add(moveLineReport.getJournal());
    }
    for (    Journal journal : journalList) {
      List<Move> moveList=(List<Move>)Move.filter("String_Node_Str" + moveQueryStr,dt,journal).fetch();
      String journalCode=journal.getExportCode();
      int moveListSize=moveList.size();
      if (moveListSize > 0) {
        int i=0;
        for (        Move move : moveList) {
          List<MoveLine> moveLineList=(List<MoveLine>)MoveLine.filter("String_Node_Str" + moveLineQueryStr,moveList).fetch();
          if (moveLineList.size() > 0) {
            String exportNumber=this.getPurchaseExportNumber(company);
            String periodCode=move.getPeriod().getFromDate().toString("String_Node_Str");
            BigDecimal totalCredit=this.getSumCredit(moveLineList);
            String invoiceId="String_Node_Str";
            String dueDate="String_Node_Str";
            if (move.getInvoice() != null) {
              invoiceId=move.getInvoice().getInvoiceId();
              dueDate=move.getInvoice().getDueDate().toString();
            }
            MoveLine firstMoveLine=moveLineList.get(0);
            String items[]=new String[12];
            items[0]=companyCode;
            items[1]=journalCode;
            items[2]=exportNumber;
            items[3]=interfaceDate.toString("String_Node_Str");
            items[4]="String_Node_Str";
            items[5]=invoiceId;
            items[6]=dueDate;
            items[7]=firstMoveLine.getAccount().getCode();
            items[8]=totalCredit.toString();
            items[9]=reference;
            items[10]=dt.toString("String_Node_Str");
            items[11]=periodCode;
            allMoveData.add(items);
            this.updateMove(move,moveLineReport,interfaceDate,exportNumber);
            if (i % 10 == 0) {
              JPA.clear();
            }
            if (i++ % 100 == 0) {
              LOG.debug("String_Node_Str",i,moveListSize);
            }
          }
        }
      }
    }
  }
  String fileName="String_Node_Str" + todayTime.toString("String_Node_Str") + "String_Node_Str";
  String filePath=accountConfigService.getExportPath(accountConfigService.getAccountConfig(company));
  new File(filePath).mkdirs();
  LOG.debug("String_Node_Str",filePath,fileName);
  CsvTool.csvWriter(filePath,fileName,'|',null,allMoveData);
}