r2793 - trunk/lima-service-callao/src/main/java/org/chorem/lima/service/callao
Author: echatellier Date: 2010-03-01 10:32:36 +0100 (Mon, 01 Mar 2010) New Revision: 2793 Modified: trunk/lima-service-callao/src/main/java/org/chorem/lima/service/callao/CallaoTransactionService.java Log: Fix a potential / by 0 durring progression update Modified: trunk/lima-service-callao/src/main/java/org/chorem/lima/service/callao/CallaoTransactionService.java =================================================================== --- trunk/lima-service-callao/src/main/java/org/chorem/lima/service/callao/CallaoTransactionService.java 2010-02-26 16:39:12 UTC (rev 2792) +++ trunk/lima-service-callao/src/main/java/org/chorem/lima/service/callao/CallaoTransactionService.java 2010-03-01 09:32:36 UTC (rev 2793) @@ -36,7 +36,6 @@ import org.chorem.lima.service.callao.convertObject.ConvertTransaction; import org.chorem.lima.service.util.ProgressListener; import org.chorem.lima.service.util.ServiceHelper; -import javax.swing.JProgressBar; import static org.nuiton.i18n.I18n._; import org.chorem.callao.service.TransactionServiceImpl; @@ -127,25 +126,29 @@ List<org.chorem.callao.service.dto.TransactionDTO> listTransactionCallao = transactionServiceImpl.getAllTransactionDTO(); // Récupère le nombre de transactions + // TODO le depart a 70 est tres bizar ici + // cela suppose que l'on connait l'ordre de chargement par l'UI double nbTransactions = listTransactionCallao.size(); - double incremente = 30 / nbTransactions; - double value = 70; - for (org.chorem.callao.service.dto.TransactionDTO transactionCallao : listTransactionCallao) { - // Converti la transaction Callao en transaction Lima - TransactionDTO transactionLima = convertTransaction.transactionCallaoToTransactionLima(transactionCallao,journals,periods,status); - // Recherche de toutes les entrées comptables pour cette transaction - List<EntryDTO> listEntryLima = entryServ.getEntryByTransaction(transactionLima, accounts); - // Pour toutes les entrées comptables Lima - for (EntryDTO entryLima : listEntryLima) { - transactionLima.addChild(entryLima); + if (nbTransactions > 0) { + double incremente = 30 / nbTransactions; + double value = 70; + for (org.chorem.callao.service.dto.TransactionDTO transactionCallao : listTransactionCallao) { + // Converti la transaction Callao en transaction Lima + TransactionDTO transactionLima = convertTransaction.transactionCallaoToTransactionLima(transactionCallao,journals,periods,status); + // Recherche de toutes les entrées comptables pour cette transaction + List<EntryDTO> listEntryLima = entryServ.getEntryByTransaction(transactionLima, accounts); + // Pour toutes les entrées comptables Lima + for (EntryDTO entryLima : listEntryLima) { + transactionLima.addChild(entryLima); + } + listTransactionLima.add(transactionLima); + // Incrémente la barre de chargement + value = value + incremente; + + if (progress != null) { + progress.updateProgression(value, _("lima.progressBar.load.etape5")); + } } - listTransactionLima.add(transactionLima); - // Incrémente la barre de chargement - value = value + incremente; - - if (progress != null) { - progress.updateProgression(value, _("lima.progressBar.load.etape5")); - } } return listTransactionLima; }
participants (1)
-
echatellier@users.chorem.org