r2789 - in trunk: lima-service/src/main/java/org/chorem/lima/service lima-service/src/main/java/org/chorem/lima/service/util lima-service-callao/src/main/java/org/chorem/lima/service/callao lima-service-mock/src/main/java/org/chorem/lima/service/mock lima-service-neogia/src/main/java/org/chorem/lima/service/neogia
Author: echatellier Date: 2010-02-26 17:36:36 +0100 (Fri, 26 Feb 2010) New Revision: 2789 Added: trunk/lima-service/src/main/java/org/chorem/lima/service/util/ProgressListener.java Modified: trunk/lima-service-callao/src/main/java/org/chorem/lima/service/callao/CallaoTransactionService.java trunk/lima-service-mock/src/main/java/org/chorem/lima/service/mock/MockTransactionService.java trunk/lima-service-neogia/src/main/java/org/chorem/lima/service/neogia/NeogiaTransactionService.java trunk/lima-service/src/main/java/org/chorem/lima/service/TransactionService.java Log: Add a progressListener interface into service to remove dependency on JProgressBar in business code Modified: trunk/lima-service/src/main/java/org/chorem/lima/service/TransactionService.java =================================================================== --- trunk/lima-service/src/main/java/org/chorem/lima/service/TransactionService.java 2010-02-26 14:27:49 UTC (rev 2788) +++ trunk/lima-service/src/main/java/org/chorem/lima/service/TransactionService.java 2010-02-26 16:36:36 UTC (rev 2789) @@ -19,12 +19,13 @@ package org.chorem.lima.service; import java.util.List; + import org.chorem.lima.dto.AccountDTO; import org.chorem.lima.dto.JournalDTO; import org.chorem.lima.dto.PeriodDTO; import org.chorem.lima.dto.StatusDTO; import org.chorem.lima.dto.TransactionDTO; -import javax.swing.JProgressBar; +import org.chorem.lima.service.util.ProgressListener; /** * @@ -37,22 +38,16 @@ * @param periods * @param journals * @param accounts - * @param status + * @param status + * @param progressListener to notify loading progress (can be null) * @return */ public List<TransactionDTO> getAllTransaction( - List<PeriodDTO> periods, - List<JournalDTO> journals, - List<AccountDTO> accounts, - List<StatusDTO> status); - - - public List<TransactionDTO> getAllTransaction( List<PeriodDTO> periods, List<JournalDTO> journals, List<AccountDTO> accounts, List<StatusDTO> status, - JProgressBar barre); + ProgressListener progressListener); /** * @@ -71,7 +66,7 @@ List<StatusDTO> status, TransactionDTO oldTrans, TransactionDTO newTrans); - + /** * * @param trans Added: trunk/lima-service/src/main/java/org/chorem/lima/service/util/ProgressListener.java =================================================================== --- trunk/lima-service/src/main/java/org/chorem/lima/service/util/ProgressListener.java (rev 0) +++ trunk/lima-service/src/main/java/org/chorem/lima/service/util/ProgressListener.java 2010-02-26 16:36:36 UTC (rev 2789) @@ -0,0 +1,40 @@ +/** + * *##% Lima service + * Copyright (C) 2010 CodeLutin + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%* + */ + +package org.chorem.lima.service.util; + +/** + * Progression listener interface to notify for loading update. + * + * @author chatellier + * @version $Revision$ + * + * Last update : $Date$ + * By : $Author$ + */ +public interface ProgressListener { + + /** + * Update progression. + * + * @param progression progression (between 0.0 and 1.0) + * @param message message (can be null) + */ + void updateProgression(double progression, String message); +} Property changes on: trunk/lima-service/src/main/java/org/chorem/lima/service/util/ProgressListener.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL 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 14:27:49 UTC (rev 2788) +++ trunk/lima-service-callao/src/main/java/org/chorem/lima/service/callao/CallaoTransactionService.java 2010-02-26 16:36:36 UTC (rev 2789) @@ -34,6 +34,7 @@ import org.chorem.lima.service.TransactionService; import org.chorem.lima.service.ServiceFactory; 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._; @@ -56,15 +57,16 @@ private ConvertTransaction convertTransaction = new ConvertTransaction(); - - /** + /* + * Duplicated code (merged will null allowed progress). + * * Recherche toutes les transactions dans la bdd. * @param periods * @param journals * @param accounts * @param status * @return - */ + * @Override public List<TransactionDTO> getAllTransaction(List<PeriodDTO> periods, List<JournalDTO> journals, List<AccountDTO> accounts, List<StatusDTO> status) { if (log.isDebugEnabled()) { @@ -95,21 +97,21 @@ listTransactionLima.add(transactionLima); } return listTransactionLima; - } + }*/ /** - * Récupère toutes les transactions avec la possibilité d'augmenter la - * barre de chargement. + * Récupère toutes les transactions avec la possibilité d'augmenter la barre de chargement. + * * @param periods * @param journals * @param accounts * @param status - * @param barre + * @param progress progress (can be null) * @return */ @Override public List<TransactionDTO> getAllTransaction(List<PeriodDTO> periods, List<JournalDTO> journals, - List<AccountDTO> accounts, List<StatusDTO> status,JProgressBar barre) { + List<AccountDTO> accounts, List<StatusDTO> status, ProgressListener progress) { if (log.isDebugEnabled()) { log.debug("getAllTransaction : "); } @@ -125,25 +127,25 @@ List<org.chorem.callao.service.dto.TransactionDTO> listTransactionCallao = transactionServiceImpl.getAllTransactionDTO(); // Récupère le nombre de transactions - float nbTransactions = listTransactionCallao.size(); - float incremente = 30 / nbTransactions; - float value = 70; - for (org.chorem.callao.service.dto.TransactionDTO transactionCallao : listTransactionCallao) - { + 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) - { + for (EntryDTO entryLima : listEntryLima) { transactionLima.addChild(entryLima); } listTransactionLima.add(transactionLima); // Incrémente la barre de chargement - value = value + incremente; - barre.setValue((int)value); - barre.setString((int)value+"% : "+_("lima.progressBar.load.etape5")); + value = value + incremente; + + if (progress != null) { + progress.updateProgression(value, _("lima.progressBar.load.etape5")); + } } return listTransactionLima; } Modified: trunk/lima-service-mock/src/main/java/org/chorem/lima/service/mock/MockTransactionService.java =================================================================== --- trunk/lima-service-mock/src/main/java/org/chorem/lima/service/mock/MockTransactionService.java 2010-02-26 14:27:49 UTC (rev 2788) +++ trunk/lima-service-mock/src/main/java/org/chorem/lima/service/mock/MockTransactionService.java 2010-02-26 16:36:36 UTC (rev 2789) @@ -18,19 +18,24 @@ */ package org.chorem.lima.service.mock; +import java.util.Calendar; +import java.util.LinkedList; +import java.util.List; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.chorem.lima.dto.*; +import org.chorem.lima.dto.AccountDTO; +import org.chorem.lima.dto.EntryDTO; +import org.chorem.lima.dto.JournalDTO; +import org.chorem.lima.dto.PeriodDTO; +import org.chorem.lima.dto.StatusDTO; +import org.chorem.lima.dto.TransactionDTO; import org.chorem.lima.service.EntryService; import org.chorem.lima.service.ServiceFactory; import org.chorem.lima.service.TransactionService; +import org.chorem.lima.service.util.ProgressListener; import org.chorem.lima.service.util.ServiceHelper; -import java.util.Calendar; -import java.util.LinkedList; -import java.util.List; -import javax.swing.JProgressBar; - /** * @author ore */ @@ -42,7 +47,8 @@ protected static final Log log = LogFactory.getLog(MockTransactionService.class); @Override - public List<TransactionDTO> getAllTransaction(List<PeriodDTO> periods, List<JournalDTO> journals, List<AccountDTO> accounts, List<StatusDTO> status) { + public List<TransactionDTO> getAllTransaction(List<PeriodDTO> periods, List<JournalDTO> journals, + List<AccountDTO> accounts, List<StatusDTO> status, ProgressListener progress) { if (log.isDebugEnabled()) { log.debug("getAllTransaction : "); } @@ -87,14 +93,6 @@ } @Override - public List<TransactionDTO> getAllTransaction(List<PeriodDTO> periods, - List<JournalDTO> journals, List<AccountDTO> accounts, - List<StatusDTO> status,JProgressBar barre) { - return getAllTransaction(periods,journals,accounts,status); - } - - - @Override public String removeTransaction(TransactionDTO trans,List<StatusDTO> status) { if (log.isDebugEnabled()) { log.debug("removeTransaction : "); Modified: trunk/lima-service-neogia/src/main/java/org/chorem/lima/service/neogia/NeogiaTransactionService.java =================================================================== --- trunk/lima-service-neogia/src/main/java/org/chorem/lima/service/neogia/NeogiaTransactionService.java 2010-02-26 14:27:49 UTC (rev 2788) +++ trunk/lima-service-neogia/src/main/java/org/chorem/lima/service/neogia/NeogiaTransactionService.java 2010-02-26 16:36:36 UTC (rev 2789) @@ -32,27 +32,39 @@ */ package org.chorem.lima.service.neogia; +import java.rmi.RemoteException; +import java.util.Calendar; +import java.util.LinkedList; +import java.util.List; + +import javax.swing.JProgressBar; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.chorem.lima.dto.*; +import org.chorem.lima.dto.AccountDTO; +import org.chorem.lima.dto.EntryDTO; +import org.chorem.lima.dto.JournalDTO; +import org.chorem.lima.dto.PeriodDTO; +import org.chorem.lima.dto.StatusDTO; +import org.chorem.lima.dto.TransactionDTO; import org.chorem.lima.service.EntryService; import org.chorem.lima.service.ServiceFactory; import org.chorem.lima.service.TransactionService; import org.chorem.lima.service.neogia.util.NeogiaUtil; +import org.chorem.lima.service.util.ProgressListener; import org.chorem.lima.service.util.ServiceHelper; -import org.ofbiz.webservice.proxies.*; +import org.ofbiz.webservice.proxies.AddTransactionDocument; +import org.ofbiz.webservice.proxies.AddTransactionResponseDocument; +import org.ofbiz.webservice.proxies.GetAllTransactionResponseDocument; +import org.ofbiz.webservice.proxies.RemoveTransactionDocument; +import org.ofbiz.webservice.proxies.UpdateTransactionDocument; +import org.ofbiz.webservice.proxies.UpdateTransactionResponseDocument; import org.ofbiz.webservice.proxies.AddTransactionDocument.AddTransaction; import org.ofbiz.webservice.proxies.RemoveTransactionDocument.RemoveTransaction; import org.ofbiz.webservice.proxies.UpdateTransactionDocument.UpdateTransaction; import org.ofbiz.webservice.wrappers.xsd.GenericValueAcctgTransactionItem; import org.ofbiz.webservice.wrappers.xsd.GenericValueAcctgTransactionItemAndGlPeriod; -import java.rmi.RemoteException; -import java.util.Calendar; -import java.util.LinkedList; -import java.util.List; -import javax.swing.JProgressBar; - /** * @author chemit */ @@ -64,7 +76,8 @@ protected static final Log log = LogFactory.getLog(NeogiaPeriodService.class); @Override - public List<TransactionDTO> getAllTransaction(List<PeriodDTO> periods, List<JournalDTO> journals, List<AccountDTO> accounts, List<StatusDTO> status) { + public List<TransactionDTO> getAllTransaction(List<PeriodDTO> periods, List<JournalDTO> journals, + List<AccountDTO> accounts, List<StatusDTO> status, ProgressListener progress) { if (log.isDebugEnabled()) { log.debug("getAllTransaction : "); } @@ -94,14 +107,6 @@ } @Override - public List<TransactionDTO> getAllTransaction(List<PeriodDTO> periods, - List<JournalDTO> journals, List<AccountDTO> accounts, - List<StatusDTO> status,JProgressBar barre) { - return getAllTransaction(periods,journals,accounts,status); - } - - - @Override public String removeTransaction(TransactionDTO trans,List<StatusDTO> status) { if (log.isDebugEnabled()) { log.debug("removeTransaction : ");
participants (1)
-
echatellier@users.chorem.org