r3895 - in trunk: lima-business/src/main/java/org/chorem/lima/business/ejb lima-business/src/test/java/org/chorem/lima/business lima-business-api/src/main/java/org/chorem/lima lima-business-api/src/main/java/org/chorem/lima/business lima-business-api/src/main/java/org/chorem/lima/business/api lima-swing/src/main/java/org/chorem/lima/ui lima-swing/src/main/java/org/chorem/lima/ui/importexport lima-swing/src/main/resources/i18n
Author: dcosse Date: 2014-08-05 16:07:42 +0200 (Tue, 05 Aug 2014) New Revision: 3895 Url: http://forge.chorem.org/projects/lima/repository/revisions/3895 Log: refs #1032 gestion des retours d'import export Added: trunk/lima-business-api/src/main/java/org/chorem/lima/ImportBackupException.java trunk/lima-business-api/src/main/java/org/chorem/lima/business/ExportResult.java trunk/lima-business-api/src/main/java/org/chorem/lima/business/ImportExportResults.java Removed: trunk/lima-business-api/src/main/java/org/chorem/lima/business/ImportException.java Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/ImportResult.java trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/ExportService.java trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/ImportService.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ExportServiceImpl.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java trunk/lima-business/src/test/java/org/chorem/lima/business/ImportExportServiceTest.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainView.css trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExport.java trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ExportServiceImpl.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ExportServiceImpl.java 2014-08-04 15:06:04 UTC (rev 3894) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ExportServiceImpl.java 2014-08-05 14:07:42 UTC (rev 3895) @@ -25,11 +25,8 @@ package org.chorem.lima.business.ejb; -import com.google.common.collect.Lists; -import org.apache.commons.codec.binary.Base64; -import org.apache.commons.io.FileUtils; -import org.apache.commons.io.IOUtils; -import org.chorem.lima.LimaTechnicalException; +import org.chorem.lima.business.ExportResult; +import org.chorem.lima.business.ImportExportResults; import org.chorem.lima.business.api.AccountService; import org.chorem.lima.business.api.EntryBookService; import org.chorem.lima.business.api.ExportService; @@ -66,15 +63,11 @@ import javax.ejb.Remote; import javax.ejb.Stateless; import javax.ejb.TransactionAttribute; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileInputStream; import java.nio.charset.Charset; +import java.rmi.server.ExportException; import java.util.ArrayList; import java.util.Collection; import java.util.List; -import java.util.zip.ZipEntry; -import java.util.zip.ZipOutputStream; /** * CSV import export service. @@ -107,146 +100,100 @@ @EJB protected IdentityService identityService; - public static final String JAVA_IO_TMPDIR = System.getProperty("java.io.tmpdir")+"/"; + @Override + public ImportExportResults exportAccountsAsCSV(String charset) { + ImportExportResults results = new ImportExportResults(); + ExportResult exportResult = results.createAddAndGetExportResult(Account.class); - protected File exportAccountsFile(String charset) throws Exception { AccountTopiaDao accountTopiaDao = getDaoHelper().getAccountDao(); List<Account> entities = accountTopiaDao.findAll(); - File result = null; - if (entities != null && entities.size() > 0) { + if (entities != null && !entities.isEmpty()) { AccountModel model = new AccountModel(); - String tmpDir = JAVA_IO_TMPDIR; - - result = new File(tmpDir + "accounts.csv"); - Export.exportToFile(model, entities, result, Charset.forName(charset)); + try { + exportResult.setExportData(Export.exportToString(model, entities, java.nio.charset.Charset.forName(charset), true)); + } catch (Exception e) { + exportResult.addException(new ExportException("TODO", e)); + } } - return result; + return results; } @Override - public String exportAccountsAsCSV(String charset) { - String result = null; - try { - File file = exportAccountsFile(charset); - if (file != null) { - FileInputStream inputStream = new FileInputStream(file); - result = IOUtils.toString(inputStream); - } - } catch (Exception e) { - throw new LimaTechnicalException(e); - } - return result; - } + public ImportExportResults exportEntryBooksAsCSV(String charset){ + ImportExportResults results = new ImportExportResults(); + ExportResult exportResult = results.createAddAndGetExportResult(EntryBook.class); - protected File exportEntryBooksFile(String charset) throws Exception { EntryBookTopiaDao entryBookTopiaDao = getDaoHelper().getEntryBookDao(); List<EntryBook> entities = entryBookTopiaDao.findAll(); - File result = null; if (entities != null && !entities.isEmpty()) { - String tmpDir = JAVA_IO_TMPDIR; - result = new File(tmpDir + "entryBooks.csv"); EntryBookModel model = new EntryBookModel(); - Export.exportToFile(model, entities, result, Charset.forName(charset)); + try { + exportResult.setExportData(Export.exportToString(model, entities, Charset.forName(charset), true)); + } catch (Exception e) { + exportResult.addException(new ExportException("TODO", e)); + } } - - return result; + return results; } - @Override - public String exportEntryBooksAsCSV(String charset) { - String result = null; - try { - File file = exportEntryBooksFile(charset); - if (file != null) { - FileInputStream inputStream = new FileInputStream(file); - result = IOUtils.toString(inputStream); - } - } catch (Exception e) { - throw new LimaTechnicalException(e); - } - return result; - } + public ImportExportResults exportFiscalPeriodsAsCSV(String charset){ + ImportExportResults results = new ImportExportResults(); + ExportResult exportResult = results.createAddAndGetExportResult(FiscalPeriod.class); - protected File exportFiscalPeriodFile(String charset) throws Exception { - FiscalPeriodTopiaDao dao = getDaoHelper().getFiscalPeriodDao(); List<FiscalPeriod> entities = dao.findAll(); - - File result = null; if (entities != null && !entities.isEmpty()) { - String tmpDir = JAVA_IO_TMPDIR; - result = new File(tmpDir + "fiscalPeriod.csv"); FiscalPeriodModel model = new FiscalPeriodModel(); - Export.exportToFile(model, entities, result, Charset.forName(charset)); + try { + exportResult.setExportData(Export.exportToString(model, entities, Charset.forName(charset), true)); + } catch (Exception e) { + exportResult.addException(new ExportException("TODO", e)); + } } - return result; + return results; } - @Override - public String exportFiscalPeriodsAsCSV(String charset) { - String result = null; - try { - File file = exportFiscalPeriodFile(charset); - if (file != null) { - FileInputStream inputStream = new FileInputStream(file); - result = IOUtils.toString(inputStream); - } - } catch (Exception e) { - throw new LimaTechnicalException(e); - } - return result; - } + protected ImportExportResults exportFinancialTransactionsFile(String charset){ + ImportExportResults results = new ImportExportResults(); + ExportResult exportResult = results.createAddAndGetExportResult(FinancialTransaction.class); - protected File exportFinancialTransactionsFile(String charset) throws Exception { - File result = null; - FinancialTransactionTopiaDao financialTransactionTopiaDao = getDaoHelper().getFinancialTransactionDao(); List<FinancialTransaction> entities = financialTransactionTopiaDao.findAll(); - if (entities != null && !entities.isEmpty()) { - String tmpDir = JAVA_IO_TMPDIR; - result = new File(tmpDir + "financialTransactions.csv"); FinancialTransactionModel model = new FinancialTransactionModel(entryBookService); - Export.exportToFile(model, entities, result, Charset.forName(charset)); + try { + exportResult.setExportData(Export.exportToString(model, entities, Charset.forName(charset), true)); + } catch (Exception e) { + exportResult.addException(new ExportException("TODO", e)); + } } - return result; + return results; } - protected File exportEntriesFile(String charset, Boolean humanReadable) throws Exception { + @Override + public ImportExportResults exportEntriesAsCSV(String charset, Boolean humanReadable){ + ImportExportResults results = new ImportExportResults(); + ExportResult exportResult = results.createAddAndGetExportResult(Entry.class); + EntryTopiaDao dao = getDaoHelper().getEntryDao(); List<Entry> entities = dao.findAll(); - - File result = null; if (entities != null && !entities.isEmpty()) { - String tmpDir = JAVA_IO_TMPDIR; - result = new File(tmpDir + "entries.csv"); EntryModel model = new EntryModel(accountService, financialTransactionService , humanReadable); - Export.exportToFile(model, entities, result, Charset.forName(charset)); + try { + exportResult.setExportData(Export.exportToString(model, entities, Charset.forName(charset), true)); + } catch (Exception e) { + exportResult.addException(new ExportException("TODO", e)); + } } - return result; + return results; } - @Override - public String exportEntriesAsCSV(String charset, Boolean humanReadable) { - String result = null; - try { - File file = exportEntriesFile(charset, humanReadable); - if (file != null) { - FileInputStream inputStream = new FileInputStream(file); - result = IOUtils.toString(inputStream); - } - } catch (Exception e) { - throw new LimaTechnicalException(e); - } - return result; - } - protected List<FinancialStatement> getAllSubFinancialStatements(List<FinancialStatement> result, Collection<FinancialStatement> subFinancialStatements) { if (subFinancialStatements != null) { for (FinancialStatement subFinancialStatement : subFinancialStatements) { @@ -258,22 +205,22 @@ } @Override - public String exportFinancialStatements(String charset) throws Exception { - String stResult = null; - String tmpDir = JAVA_IO_TMPDIR; - File fileResult = new File(tmpDir + "financialStatements.csv"); + public ImportExportResults exportFinancialStatements(String charset){ + ImportExportResults results = new ImportExportResults(); + ExportResult exportResult = results.createAddAndGetExportResult(FinancialStatement.class); List<FinancialStatement> rootFinancialStatements = financialStatementService.getRootFinancialStatements(); if (rootFinancialStatements != null) { FinancialStatementModel model = new FinancialStatementModel(); List<FinancialStatement> financialStatements = new ArrayList<>(); getAllSubFinancialStatements(financialStatements, rootFinancialStatements); - Export.exportToFile(model, financialStatements, fileResult, Charset.forName(charset)); - FileInputStream inputStream = new FileInputStream(fileResult); - stResult = IOUtils.toString(inputStream); - + try { + exportResult.setExportData(Export.exportToString(model, financialStatements, Charset.forName(charset), true)); + } catch (Exception e) { + exportResult.addException(new ExportException("TODO", e)); + } } - return stResult; + return results; } protected List<VatStatement> getAllSubVATStatements(List<VatStatement> result, Collection<VatStatement> subVATStatements) { @@ -287,138 +234,110 @@ } @Override - public String exportVatStatements(String charset) throws Exception { - String stResult = null; - String tmpDir = JAVA_IO_TMPDIR; - File fileResult = new File(tmpDir + "vatStatements.csv"); + public ImportExportResults exportVatStatements(String charset) { + ImportExportResults results = new ImportExportResults(); + ExportResult exportResult = results.createAddAndGetExportResult(VatStatement.class); List<VatStatement> rootVatStatements = vatStatementService.getRootVatStatements(); if (rootVatStatements != null) { VatStatementModel model = new VatStatementModel(); List<VatStatement> vatStatements = new ArrayList<>(); getAllSubVATStatements(vatStatements, rootVatStatements); - Export.exportToFile(model, vatStatements, fileResult, Charset.forName(charset)); - FileInputStream inputStream = new FileInputStream(fileResult); - stResult = IOUtils.toString(inputStream); - + try { + exportResult.setExportData(Export.exportToString(model, vatStatements, Charset.forName(charset), true)); + } catch (Exception e) { + exportResult.addException(new ExportException("TODO", e)); + } } - return stResult; + return results; } - protected File exportIdentity(String charset) throws Exception { - File result = null; + protected ImportExportResults exportIdentity(String charset) { + ImportExportResults results = new ImportExportResults(); + ExportResult exportResult = results.createAddAndGetExportResult(Identity.class); Identity identity = identityService.getIdentity(); if (identity != null) { List<Identity> identities = new ArrayList<>(); identities.add(identity); - String tmpDir = JAVA_IO_TMPDIR; - result = new File(tmpDir + "identity.csv"); IdentityModel model = new IdentityModel(); - Export.exportToFile(model, identities, result, Charset.forName(charset)); + try { + exportResult.setExportData(Export.exportToString(model, identities, Charset.forName(charset), true)); + } catch (Exception e) { + exportResult.addException(new ExportException("TODO", e)); + } } - return result; + return results; } @Override - public String exportBackup(String charset) { - ByteArrayOutputStream rstBao = new ByteArrayOutputStream(); - ZipOutputStream export = null; - try { - List<File> files = Lists.newArrayList(); - files.add(exportAccountsFile(charset)); - files.add(exportEntryBooksFile(charset)); - files.add(exportFiscalPeriodFile(charset)); - files.add(exportFinancialTransactionsFile(charset)); - files.add(exportEntriesFile(charset, false)); - files.add(exportIdentity(charset)); + public ImportExportResults exportBackup(String charset) { - export = new ZipOutputStream(rstBao); + ImportExportResults results = exportAccountsAsCSV(charset); - for (File file : files) { - if (file != null) { - ZipEntry ze= new ZipEntry(file.getName()); - export.putNextEntry(ze); - int len; - byte[] buffer = new byte[1024]; - FileInputStream stream = new FileInputStream(file); - while ((len = stream.read(buffer)) > 0) { - export.write(buffer, 0, len); - } - stream.close(); - FileUtils.forceDelete(file); - } - } - export.flush(); - - } catch (Exception e) { - throw new LimaTechnicalException(e); - } finally { - IOUtils.closeQuietly(export); - } - byte[] bytes = rstBao.toByteArray(); - return Base64.encodeBase64String(bytes); + results.pushExportResults(exportEntryBooksAsCSV(charset)); + results.pushExportResults(exportFiscalPeriodsAsCSV(charset)); + results.pushExportResults(exportFinancialTransactionsFile(charset)); + results.pushExportResults(exportEntriesAsCSV(charset, false)); + results.pushExportResults(exportIdentity(charset)); + return results; } //####################################### EBP ############################################## @Override - public String exportAccountAsEbp(String charset) throws Exception { - String stResult = null; - File result; + public ImportExportResults exportAccountAsEbp(String charset) { + ImportExportResults results = new ImportExportResults(); + ExportResult exportResult = results.createAddAndGetExportResult(Account.class); List<Account> accounts = accountService.getAllAccounts(); if (accounts != null && !accounts.isEmpty()) { - - String tmpDir = JAVA_IO_TMPDIR; - result = new File(tmpDir + "accounts.csv"); AccountEBPModel model = new AccountEBPModel(); - Export.exportToFile(model, accounts, result, Charset.forName(charset)); - FileInputStream inputStream = new FileInputStream(result); - stResult = IOUtils.toString(inputStream); - + try { + exportResult.setExportData(Export.exportToString(model, accounts, Charset.forName(charset), true)); + } catch (Exception e) { + exportResult.addException(new ExportException("TODO", e)); + } } - return stResult; + return results; } @Override - public String exportEntriesAsEbp(String charset) throws Exception { - String stResult = null; - File result; + public ImportExportResults exportEntriesAsEbp(String charset){ + ImportExportResults results = new ImportExportResults(); + ExportResult exportResult = results.createAddAndGetExportResult(Entry.class); List<Entry> entries = getDaoHelper().getEntryDao().findAll(); - if (entries != null && !entries.isEmpty()) { - - String tmpDir = JAVA_IO_TMPDIR; - result = new File(tmpDir + "entries.csv"); EntryEBPModel model = new EntryEBPModel(); - Export.exportToFile(model, entries, result, Charset.forName(charset)); - FileInputStream inputStream = new FileInputStream(result); - stResult = IOUtils.toString(inputStream); + try { + exportResult.setExportData(Export.exportToString(model, entries, Charset.forName(charset),true)); + } catch (Exception e) { + exportResult.addException(new ExportException("TODO", e)); + } + } - return stResult; + return results; } @Override - public String exportEntryBookAsEbp(String charset) throws Exception { - String stResult = null; - File result; + public ImportExportResults exportEntryBookAsEbp(String charset){ + ImportExportResults results = new ImportExportResults(); + ExportResult exportResult = results.createAddAndGetExportResult(EntryBook.class); List<EntryBook> entryBooks = entryBookService.getAllEntryBooks(); - if (entryBooks != null && !entryBooks.isEmpty()) { - String tmpDir = JAVA_IO_TMPDIR; - result = new File(tmpDir + "entryBooks.csv"); EntryBookModel model = new EntryBookModel(); - Export.exportToFile(model, entryBooks, result, Charset.forName(charset)); - FileInputStream inputStream = new FileInputStream(result); - stResult = IOUtils.toString(inputStream); + try { + exportResult.setExportData(Export.exportToString(model, entryBooks, Charset.forName(charset))); + } catch (Exception e) { + exportResult.addException(new ExportException("TODO", e)); + } } - return stResult; + return results; } } Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java 2014-08-04 15:06:04 UTC (rev 3894) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java 2014-08-05 14:07:42 UTC (rev 3895) @@ -34,6 +34,7 @@ import org.chorem.lima.business.AlreadyExistVatStatement; import org.chorem.lima.business.FiscalPeriodException; import org.chorem.lima.business.ImportEbpException; +import org.chorem.lima.business.ImportExportResults; import org.chorem.lima.business.ImportResult; import org.chorem.lima.business.InvalidAccountNumberException; import org.chorem.lima.business.LockedEntryBookException; @@ -137,10 +138,12 @@ }; @Override - public ImportResult importAccountAsCSV(String contents) { + public ImportExportResults importAccountAsCSV(String contents) { + + ImportExportResults result = new ImportExportResults(); + ImportResult importResult = result.createAddAndGetImportResult(Account.class); + InputStream contentStream = IOUtils.toInputStream(contents); - - ImportResult result = new ImportResult(); try { ImportModel<Account> model = new AccountModel(); Import<Account> accounts = Import.newImport(model, contentStream); @@ -150,12 +153,12 @@ try { updated = accountService.createOrUbdateAccount(account); if (updated) { - result.increaseUpdated(); + importResult.increaseUpdated(); } else { - result.increaseCreated(); + importResult.increaseCreated(); } } catch (InvalidAccountNumberException e) { - result.addException(e); + importResult.addException(e); } } } finally { @@ -165,9 +168,12 @@ } @Override - public ImportResult importEntryBooksAsCSV(String contents) { + public ImportExportResults importEntryBooksAsCSV(String contents) { + ImportExportResults results = new ImportExportResults(); + ImportResult result = results.createAddAndGetImportResult(Account.class); + InputStream contentStream = IOUtils.toInputStream(contents); - ImportResult result = new ImportResult(); + try { ImportModel<EntryBook> model = new EntryBookModel(); @@ -183,13 +189,15 @@ } finally { IOUtils.closeQuietly(contentStream); } - return result; + return results; } @Override - public ImportResult importFiscalPeriodsAsCSV(String contents) { + public ImportExportResults importFiscalPeriodsAsCSV(String contents) { + ImportExportResults results = new ImportExportResults(); + ImportResult result = results.createAddAndGetImportResult(Account.class); + InputStream contentStream = IOUtils.toInputStream(contents); - ImportResult result = new ImportResult(); try { ImportModel<FiscalPeriod> model = new FiscalPeriodModel(); @@ -208,11 +216,12 @@ } finally { IOUtils.closeQuietly(contentStream); } - return result; + return results; } - protected ImportResult importFinancialTransactionsAsCSV(String contents) { - ImportResult result = new ImportResult(); + protected ImportExportResults importFinancialTransactionsAsCSV(String contents) { + ImportExportResults results = new ImportExportResults(); + ImportResult result = results.createAddAndGetImportResult(Account.class); // import and save FinancialTransactions InputStream contentStream = IOUtils.toInputStream(contents); @@ -233,14 +242,16 @@ } finally { IOUtils.closeQuietly(contentStream); } - return result; + return results; } @Override - public ImportResult importEntriesAsCSV(String contents) { + public ImportExportResults importEntriesAsCSV(String contents) { + ImportExportResults results = new ImportExportResults(); + ImportResult result = results.createAddAndGetImportResult(Account.class); + // import and save entries InputStream contentStream = IOUtils.toInputStream(contents); - ImportResult result = new ImportResult(); try { ImportModel<Entry> model = new EntryModel(accountService, financialTransactionService, false); Import<Entry> entries = Import.newImport(model, contentStream); @@ -251,11 +262,13 @@ } finally { IOUtils.closeQuietly(contentStream); } - return result; + return results; } - public ImportResult importIdentityAsCSV(String contents) { - ImportResult result = new ImportResult(); + public ImportExportResults importIdentityAsCSV(String contents) { + ImportExportResults results = new ImportExportResults(); + ImportResult result = results.createAddAndGetImportResult(Account.class); + // import and save identity if (StringUtils.isNotBlank(contents)){ InputStream contentStream = null; @@ -272,7 +285,7 @@ } } - return result; + return results; } protected FinancialStatement returnFinancialStatement (FinancialStatement rootFinancialStatement, String subFinancialStatementLabel) throws AlreadyExistFinancialStatement, NotAllowedLabel { @@ -314,8 +327,9 @@ } @Override - public ImportResult importFinancialStatementsAsCSV(String contents) { - ImportResult result = new ImportResult(); + public ImportExportResults importFinancialStatementsAsCSV(String contents) { + ImportExportResults results = new ImportExportResults(); + ImportResult result = results.createAddAndGetImportResult(Account.class); // import and save FinancialTransactions InputStream contentStream = IOUtils.toInputStream(contents); @@ -414,7 +428,7 @@ } finally { IOUtils.closeQuietly(contentStream); } - return result; + return results; } protected VatStatement returnVATStatement (VatStatement rootVATStatement, String subVATStatementLabel) throws AlreadyExistVatStatement, NotAllowedLabel { @@ -456,8 +470,9 @@ } @Override - public ImportResult importVATStatementsAsCSV(String contents) { - ImportResult result = new ImportResult(); + public ImportExportResults importVATStatementsAsCSV(String contents) { + ImportExportResults results = new ImportExportResults(); + ImportResult result = results.createAddAndGetImportResult(Account.class); // import and save VATStatements InputStream contentStream = IOUtils.toInputStream(contents); @@ -556,18 +571,18 @@ } finally { IOUtils.closeQuietly(contentStream); } - return result; + return results; } @Override - public List<ImportResult> importBackup(String entryBooks, String financialTransactions, String fiscalPeriods, String accounts, String entries, String identity) throws AlreadyExistAccountException, InvalidAccountNumberException { - List<ImportResult> results = new ArrayList<>(); - results.add(importAccountAsCSV(accounts)); - results.add(importEntryBooksAsCSV(entryBooks)); - results.add(importFiscalPeriodsAsCSV(fiscalPeriods)); - results.add(importFinancialTransactionsAsCSV(financialTransactions)); - results.add(importEntriesAsCSV(entries)); - results.add(importIdentityAsCSV(identity)); + public ImportExportResults importBackup(String entryBooks, String financialTransactions, String fiscalPeriods, String accounts, String entries, String identity) throws AlreadyExistAccountException, InvalidAccountNumberException { + + ImportExportResults results = importAccountAsCSV(accounts); + results.pushImportResults(importEntryBooksAsCSV(entryBooks)); + results.pushImportResults(importFiscalPeriodsAsCSV(fiscalPeriods)); + results.pushImportResults(importFinancialTransactionsAsCSV(financialTransactions)); + results.pushImportResults(importEntriesAsCSV(entries)); + results.pushImportResults(importIdentityAsCSV(identity)); return results; } @@ -575,8 +590,9 @@ @Override - public ImportResult importAccountFromEbp(String datas) { - ImportResult result = new ImportResult(); + public ImportExportResults importAccountFromEbp(String datas) { + ImportExportResults results = new ImportExportResults(); + ImportResult result = results.createAddAndGetImportResult(Account.class); ImportModel<Account> model = new AccountEBPModel(); @@ -596,12 +612,13 @@ result.increaseCreated(); } } - return result; + return results; } @Override - public ImportResult importEntryBookFromEbp(String datas) { - ImportResult result = new ImportResult(); + public ImportExportResults importEntryBookFromEbp(String datas) { + ImportExportResults results = new ImportExportResults(); + ImportResult result = results.createAddAndGetImportResult(Account.class); ImportModel<EntryBook> model = new EntryBookEBPModel(); @@ -616,7 +633,7 @@ result.increaseCreated(); } } - return result; + return results; } protected void basicEntriesFromEBPValidation(String datas, List<FiscalPeriod> fiscalPeriods) throws ImportEbpException { @@ -667,20 +684,20 @@ } @Override - public ImportResult importEntriesFromEbp(String datas) { + public ImportExportResults importEntriesFromEbp(String datas) { + ImportExportResults results = new ImportExportResults(); + ImportResult result = results.createAddAndGetImportResult(Account.class); // use for logs long before = System.currentTimeMillis(); - ImportResult result = new ImportResult(); - // Get all the valid fiscalPeriods Ordered by date. List<FiscalPeriod> fiscalPeriods = fiscalPeriodService.getAllUnblockedFiscalPeriodsByBeginDate(); try { basicEntriesFromEBPValidation(datas, fiscalPeriods); } catch (ImportEbpException e) { result.addException(e); - return result; + return results; } List<Account> accounts = accountService.getAllAccounts(); @@ -734,7 +751,7 @@ log.info("Imported form EBP : " + entryEBPs.size() + " entries in " + (after - before) + " ms"); } - return result; + return results; } protected Entry createEntry(EntryEBP entryEBP, Account account) { Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/ImportExportServiceTest.java =================================================================== --- trunk/lima-business/src/test/java/org/chorem/lima/business/ImportExportServiceTest.java 2014-08-04 15:06:04 UTC (rev 3894) +++ trunk/lima-business/src/test/java/org/chorem/lima/business/ImportExportServiceTest.java 2014-08-05 14:07:42 UTC (rev 3895) @@ -35,8 +35,6 @@ import org.chorem.lima.entity.FinancialTransaction; import org.chorem.lima.entity.FiscalPeriod; import org.chorem.lima.entity.FiscalPeriodImpl; -import org.chorem.lima.entity.Identity; -import org.chorem.lima.entity.IdentityImpl; import org.junit.Assert; import org.junit.Test; @@ -68,8 +66,9 @@ // export accounts String tmpDir = System.getProperty("java.io.tmpdir")+"/"; - String export = exportService.exportAccountsAsCSV(Charset.defaultCharset().name()); - InputStream stream = IOUtils.toInputStream(export); + ImportExportResults export = exportService.exportAccountsAsCSV(Charset.defaultCharset().name()); + + InputStream stream = IOUtils.toInputStream(export.getExportResults().get(0).exportData); FileOutputStream res = new FileOutputStream(tmpDir + "export-accounts.csv"); IOUtils.copy(stream, res); @@ -85,12 +84,12 @@ try { contentStream = new FileInputStream(tmpDir + "export-accounts.csv"); String inportStream = IOUtils.toString(contentStream); - ImportResult result = importService.importAccountAsCSV(inportStream); + ImportExportResults result = importService.importAccountAsCSV(inportStream); // make sure all account have been created Assert.assertEquals(nbEntities, accountService.getAllAccounts().size()); - Assert.assertEquals(nbEntities, result.getNbCreated()); - Assert.assertTrue(result.getAllExceptionsByLine().isEmpty()); + Assert.assertEquals(nbEntities, result.getImportResults().get(0).getNbCreated()); + Assert.assertTrue(result.getImportResults().get(0).getAllExceptionsByLine().isEmpty()); } finally { IOUtils.closeQuietly(contentStream); } @@ -101,8 +100,8 @@ initTestWithEntryBooks(); String tmpDir = System.getProperty("java.io.tmpdir")+"/"; - String export = exportService.exportEntryBooksAsCSV(Charset.defaultCharset().name()); - InputStream stream = IOUtils.toInputStream(export); + ImportExportResults export = exportService.exportEntryBooksAsCSV(Charset.defaultCharset().name()); + InputStream stream = IOUtils.toInputStream(export.getExportResults().get(0).exportData); FileOutputStream res = new FileOutputStream(tmpDir + "export-EntryBooks.csv"); IOUtils.copy(stream, res); @@ -121,7 +120,7 @@ try { contentStream = new FileInputStream(tmpDir + "export-EntryBooks.csv"); String inportStream = IOUtils.toString(contentStream); - result = importService.importEntryBooksAsCSV(inportStream); + result = importService.importEntryBooksAsCSV(inportStream).getImportResults().get(0); } finally { IOUtils.closeQuietly(contentStream); } @@ -146,8 +145,8 @@ //test export String tmpDir = System.getProperty("java.io.tmpdir")+"/"; - String export = exportService.exportEntriesAsCSV(Charset.defaultCharset().name(), false); - InputStream stream = IOUtils.toInputStream(export); + ImportExportResults export = exportService.exportEntriesAsCSV(Charset.defaultCharset().name(), false); + InputStream stream = IOUtils.toInputStream(export.getExportResults().get(0).getExportData()); FileOutputStream res = new FileOutputStream(tmpDir + "export-entries.csv"); IOUtils.copy(stream, res); @@ -172,7 +171,7 @@ try { contentStream = new FileInputStream(tmpDir + "export-entries.csv"); String inputStream = IOUtils.toString(contentStream); - result = importService.importEntriesAsCSV(inputStream); + result = importService.importEntriesAsCSV(inputStream).getImportResults().get(0); } finally { IOUtils.closeQuietly(contentStream); } @@ -194,7 +193,7 @@ initTestWithFiscalPeriod(); String tmpDir = System.getProperty("java.io.tmpdir")+"/"; - String export = exportService.exportFiscalPeriodsAsCSV(Charset.defaultCharset().name()); + String export = exportService.exportFiscalPeriodsAsCSV(Charset.defaultCharset().name()).getExportResults().get(0).getExportData(); InputStream stream = IOUtils.toInputStream(export); FileOutputStream res = new FileOutputStream(tmpDir + "export-fiscal-periods.csv"); IOUtils.copy(stream, res); @@ -212,7 +211,7 @@ try { contentStream = new FileInputStream(tmpDir + "export-fiscal-periods.csv"); String inputStream = IOUtils.toString(contentStream); - result = importService.importFiscalPeriodsAsCSV(inputStream); + result = importService.importFiscalPeriodsAsCSV(inputStream).getImportResults().get(0); } finally { IOUtils.closeQuietly(contentStream); } @@ -222,37 +221,37 @@ Assert.assertTrue(result.getAllExceptionsByLine().isEmpty()); } - @Test - public void exportImportAllAsCSVTest() throws Exception { - initTestWithFinancialTransaction(); - Identity identity = new IdentityImpl(); - identity.setName("Code Lutin"); - identity.setAddress("12 Avenue Jules Verne"); - identity.setZipCode("44230"); - identity.setCity("Saint-Sébastien-sur-Loire"); - identityService.updateIdentity(identity); +// @Test +// public void exportImportAllAsCSVTest() throws Exception { +// initTestWithFinancialTransaction(); +// Identity identity = new IdentityImpl(); +// identity.setName("Code Lutin"); +// identity.setAddress("12 Avenue Jules Verne"); +// identity.setZipCode("44230"); +// identity.setCity("Saint-Sébastien-sur-Loire"); +// identityService.updateIdentity(identity); +// +// String export = exportService.exportBackup("UTF-8"); +// +// String tmpDir = System.getProperty("java.io.tmpdir")+"/TMP_BACKUP.zip"; +// createZipFile(tmpDir, export); +// +// +// initAbstractTest(); +// +// List<ImportResult> importResults; +// importResults = importAllFromZipFile(tmpDir); +// +// String[] imported = {"accounts", "entryBooks", "fiscalPeriod", "financialTransactions", "entries", "identity"}; +// Assert.assertEquals(6, importResults.size()); +// for (int i = 0; i < importResults.size(); i++) { +// ImportResult importResult = importResults.get(i); +// log.info(imported[i] +": created:"+importResult.getNbCreated() + " updated:" + importResult.getNbUpdated() + " ignoded:" + importResult.getNbIgnored()); +// Assert.assertTrue(importResult.getNbCreated()>0); +// Assert.assertTrue(importResult.getAllExceptionsByLine().isEmpty()); +// } +// } - String export = exportService.exportBackup("UTF-8"); - - String tmpDir = System.getProperty("java.io.tmpdir")+"/TMP_BACKUP.zip"; - createZipFile(tmpDir, export); - - - initAbstractTest(); - - List<ImportResult> importResults; - importResults = importAllFromZipFile(tmpDir); - - String[] imported = {"accounts", "entryBooks", "fiscalPeriod", "financialTransactions", "entries", "identity"}; - Assert.assertEquals(6, importResults.size()); - for (int i = 0; i < importResults.size(); i++) { - ImportResult importResult = importResults.get(i); - log.info(imported[i] +": created:"+importResult.getNbCreated() + " updated:" + importResult.getNbUpdated() + " ignoded:" + importResult.getNbIgnored()); - Assert.assertTrue(importResult.getNbCreated()>0); - Assert.assertTrue(importResult.getAllExceptionsByLine().isEmpty()); - } - } - protected void createZipFile(String path, String zippedBase64Str) throws Exception { byte[] bytes = Base64.decodeBase64(zippedBase64Str); ByteArrayInputStream inputStream = new ByteArrayInputStream(bytes); @@ -331,7 +330,7 @@ String identityStreamString = IOUtils.toString(identityStream); IOUtils.closeQuietly(identityStream); - results = importService.importBackup(entryBooksStreamString, transactionsStreamString, fiscalPeriodsStreamString, accountsStreamString, entriesStreamString, identityStreamString); + results = importService.importBackup(entryBooksStreamString, transactionsStreamString, fiscalPeriodsStreamString, accountsStreamString, entriesStreamString, identityStreamString).getImportResults(); } catch (Exception ex) { if(log.isInfoEnabled()) { @@ -350,7 +349,7 @@ ImportResult result; - result = importService.importFinancialStatementsAsCSV(bcr_developed); + result = importService.importFinancialStatementsAsCSV(bcr_developed).getImportResults().get(0); Assert.assertTrue(result.getAllExceptionsByLine().isEmpty()); Assert.assertEquals(162, result.getNbCreated()); @@ -371,7 +370,7 @@ ImportResult result; - result = importService.importVATStatementsAsCSV(bcr_developed); + result = importService.importVATStatementsAsCSV(bcr_developed).getImportResults().get(0); Assert.assertTrue(result.getAllExceptionsByLine().isEmpty()); Assert.assertEquals(55, result.getNbCreated()); @@ -411,7 +410,7 @@ InputStream entriesStream = ImportExportServiceTest.class.getResourceAsStream("/ebp/ecritures.txt"); String entriesData = IOUtils.toString(entriesStream, "ISO-8859-1"); - ImportResult result = importService.importEntriesFromEbp(entriesData); + ImportResult result = importService.importEntriesFromEbp(entriesData).getImportResults().get(0); Assert.assertTrue(result.getAllExceptionsByLine().isEmpty()); Assert.assertEquals(28, result.getNbCreated()); entriesStream.close(); @@ -449,7 +448,7 @@ entryBookService.createEntryBook(entryBook); } - ImportResult result = importService.importEntryBookFromEbp(entryBookData); + ImportResult result = importService.importEntryBookFromEbp(entryBookData).getImportResults().get(0); Assert.assertEquals(7, result.getNbCreated()); Assert.assertEquals(2, result.getNbUpdated()); EntryBook updatedEntryBook = entryBookService.getEntryBookByCode("AC"); @@ -471,7 +470,7 @@ //test export String tmpDir = System.getProperty("java.io.tmpdir")+"/"; - String export = exportService.exportEntriesAsEbp(Charset.defaultCharset().name()); + String export = exportService.exportEntriesAsEbp(Charset.defaultCharset().name()).getExportResults().get(0).getExportData(); InputStream stream = IOUtils.toInputStream(export); FileOutputStream res = new FileOutputStream(tmpDir + "export-entries-EBP.csv"); IOUtils.copy(stream, res); @@ -497,7 +496,7 @@ try { contentStream = new FileInputStream(tmpDir + "export-entries-EBP.csv"); String inputStream = IOUtils.toString(contentStream); - result = importService.importEntriesFromEbp(inputStream); + result = importService.importEntriesFromEbp(inputStream).getImportResults().get(0); } finally { IOUtils.closeQuietly(contentStream); } Copied: trunk/lima-business-api/src/main/java/org/chorem/lima/ImportBackupException.java (from rev 3894, trunk/lima-business-api/src/main/java/org/chorem/lima/business/NotAllowedLabel.java) =================================================================== --- trunk/lima-business-api/src/main/java/org/chorem/lima/ImportBackupException.java (rev 0) +++ trunk/lima-business-api/src/main/java/org/chorem/lima/ImportBackupException.java 2014-08-05 14:07:42 UTC (rev 3895) @@ -0,0 +1,13 @@ +package org.chorem.lima; + +import org.chorem.lima.business.LimaException; + +/** + * Created by davidcosse on 31/07/14. + */ +public class ImportBackupException extends LimaException { + + public ImportBackupException(String message, Throwable cause) { + super(message, cause); + } +} Added: trunk/lima-business-api/src/main/java/org/chorem/lima/business/ExportResult.java =================================================================== --- trunk/lima-business-api/src/main/java/org/chorem/lima/business/ExportResult.java (rev 0) +++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/ExportResult.java 2014-08-05 14:07:42 UTC (rev 3895) @@ -0,0 +1,51 @@ +package org.chorem.lima.business; + +import java.io.Serializable; +import java.rmi.server.ExportException; +import java.util.ArrayList; +import java.util.List; + +/** + * Created by davidcosse on 04/08/14. + */ +public class ExportResult implements Serializable { + + private static final long serialVersionUID = -7708723957001648683L; + + protected Class fromSource; + + public ExportResult(Class fromSource) { + this.fromSource = fromSource; + } + + /** + * all exception catch during export + */ + protected List<ExportException> exportExceptions; + + /** + * export result: data as String + */ + protected String exportData; + + public String getExportData() { + return exportData; + } + + public void setExportData(String exportData) { + this.exportData = exportData; + } + + public List<ExportException> getExportExceptions() { + return exportExceptions; + } + + public void addException(ExportException e) { + exportExceptions = exportExceptions == null ? new ArrayList<ExportException>() : exportExceptions; + exportExceptions.add(e); + } + + public Class getFromSource() { + return fromSource; + } +} Deleted: trunk/lima-business-api/src/main/java/org/chorem/lima/business/ImportException.java =================================================================== --- trunk/lima-business-api/src/main/java/org/chorem/lima/business/ImportException.java 2014-08-04 15:06:04 UTC (rev 3894) +++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/ImportException.java 2014-08-05 14:07:42 UTC (rev 3895) @@ -1,34 +0,0 @@ -package org.chorem.lima.business; - -/* - * #%L - * Lima :: business API - * %% - * Copyright (C) 2008 - 2014 CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -import java.util.HashMap; -import java.util.Map; -/** - * Created by davidcosse on 24/07/14. - */ -public class ImportException extends LimaException { - - protected Map<Integer, LimaException> allExceptions = new HashMap<>(); - -} Added: trunk/lima-business-api/src/main/java/org/chorem/lima/business/ImportExportResults.java =================================================================== --- trunk/lima-business-api/src/main/java/org/chorem/lima/business/ImportExportResults.java (rev 0) +++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/ImportExportResults.java 2014-08-05 14:07:42 UTC (rev 3895) @@ -0,0 +1,73 @@ +package org.chorem.lima.business; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +/** + * Created by davidcosse on 04/08/14. + */ +public class ImportExportResults implements Serializable{ + + private static final long serialVersionUID = -5941835433984457107L; + List<ImportResult> importResults; + + List<ExportResult> exportResults; + + public List<ImportResult> getImportResults() { + return importResults; + } + + public List<ExportResult> getExportResults() { + return exportResults; + } + + public void addImportResult(ImportResult result) { + importResults = importResults == null ? new ArrayList<ImportResult>() : importResults; + importResults.add(result); + } + + public void addAllImportResult(Collection<ImportResult> results) { + importResults = importResults == null ? new ArrayList<ImportResult>() : importResults; + importResults.addAll(results); + } + + protected void addExportResult(ExportResult result) { + exportResults = exportResults == null ? new ArrayList<ExportResult>() : exportResults; + exportResults.add(result); + } + + protected void addAllExportResult(Collection<ExportResult> results) { + exportResults = exportResults == null ? new ArrayList<ExportResult>() : exportResults; + exportResults.addAll(results); + } + + public ImportResult createAddAndGetImportResult(Class fromSource) { + ImportResult result = new ImportResult(fromSource); + addImportResult(result); + return result; + } + + public ExportResult createAddAndGetExportResult(Class fromSource) { + ExportResult result = new ExportResult(fromSource); + addExportResult(result); + return result; + } + + /** + * add all ExportResults from the given ImportExportResults to the current ImportExportResults + * @param results + */ + public void pushExportResults(ImportExportResults results) { + addAllExportResult(results.getExportResults()); + } + + /** + * add all ExportResults from the given ImportExportResults to the current ImportExportResults + * @param results + */ + public void pushImportResults(ImportExportResults results) { + addAllImportResult(results.getImportResults()); + } +} Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/ImportResult.java =================================================================== --- trunk/lima-business-api/src/main/java/org/chorem/lima/business/ImportResult.java 2014-08-04 15:06:04 UTC (rev 3894) +++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/ImportResult.java 2014-08-05 14:07:42 UTC (rev 3895) @@ -39,13 +39,16 @@ protected int lineIndex; + protected Class fromSource; + protected Map<Integer, LimaException> allExceptions = new HashMap<>(); - public ImportResult() { + public ImportResult(Class fromSource) { nbCreated = 0; nbUpdated = 0; nbIgnored = 0; lineIndex = 0; + this.fromSource = fromSource; } public int getNbCreated() { @@ -83,4 +86,8 @@ public Map<Integer, LimaException> getAllExceptionsByLine() { return allExceptions; } + + public Class getFromSource() { + return fromSource; + } } Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/ExportService.java =================================================================== --- trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/ExportService.java 2014-08-04 15:06:04 UTC (rev 3894) +++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/ExportService.java 2014-08-05 14:07:42 UTC (rev 3895) @@ -25,6 +25,8 @@ package org.chorem.lima.business.api; +import org.chorem.lima.business.ImportExportResults; + /** * Import export service. * <p/> @@ -40,25 +42,25 @@ //####################################### CSV ############################################## - String exportAccountsAsCSV(String charset); + ImportExportResults exportAccountsAsCSV(String charset); - String exportEntryBooksAsCSV(String charset); + ImportExportResults exportEntryBooksAsCSV(String charset); - String exportFiscalPeriodsAsCSV(String charset); + ImportExportResults exportFiscalPeriodsAsCSV(String charset); - String exportEntriesAsCSV(String charset, Boolean humanReadable); + ImportExportResults exportEntriesAsCSV(String charset, Boolean humanReadable); - String exportFinancialStatements(String charset) throws Exception; + ImportExportResults exportFinancialStatements(String charset); - String exportVatStatements(String charset) throws Exception; + ImportExportResults exportVatStatements(String charset); - String exportBackup(String charset); + ImportExportResults exportBackup(String charset); //####################################### EBP ############################################## - String exportAccountAsEbp(String charset) throws Exception; + ImportExportResults exportAccountAsEbp(String charset); - String exportEntriesAsEbp(String charset) throws Exception; + ImportExportResults exportEntriesAsEbp(String charset); - String exportEntryBookAsEbp(String charset) throws Exception; + ImportExportResults exportEntryBookAsEbp(String charset); } Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/ImportService.java =================================================================== --- trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/ImportService.java 2014-08-04 15:06:04 UTC (rev 3894) +++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/ImportService.java 2014-08-05 14:07:42 UTC (rev 3895) @@ -23,11 +23,9 @@ */ import org.chorem.lima.business.AlreadyExistAccountException; -import org.chorem.lima.business.ImportResult; +import org.chorem.lima.business.ImportExportResults; import org.chorem.lima.business.InvalidAccountNumberException; -import java.util.List; - /** * Created by davidcosse on 03/06/14. */ @@ -35,27 +33,27 @@ //####################################### CSV ############################################## - ImportResult importAccountAsCSV(String contents); + ImportExportResults importAccountAsCSV(String contents); - ImportResult importEntryBooksAsCSV(String contents); + ImportExportResults importEntryBooksAsCSV(String contents); - ImportResult importFiscalPeriodsAsCSV(String contents); + ImportExportResults importFiscalPeriodsAsCSV(String contents); - ImportResult importEntriesAsCSV(String contents); + ImportExportResults importEntriesAsCSV(String contents); - ImportResult importFinancialStatementsAsCSV(String contents); + ImportExportResults importFinancialStatementsAsCSV(String contents); - ImportResult importVATStatementsAsCSV(String contents); + ImportExportResults importVATStatementsAsCSV(String contents); - List<ImportResult> importBackup(String entryBooks, String transactions, String fiscalPeriods, String accounts, String entries, String identity) throws AlreadyExistAccountException, InvalidAccountNumberException; + ImportExportResults importBackup(String entryBooks, String transactions, String fiscalPeriods, String accounts, String entries, String identity) throws AlreadyExistAccountException, InvalidAccountNumberException; //####################################### EBP ############################################## - ImportResult importAccountFromEbp(String datas); + ImportExportResults importAccountFromEbp(String datas); - ImportResult importEntryBookFromEbp(String datas); + ImportExportResults importEntryBookFromEbp(String datas); - ImportResult importEntriesFromEbp(String datas); + ImportExportResults importEntriesFromEbp(String datas); // String importAsPDF(String data, // ImportExportEntityEnum importExportEntityEnum, Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainView.css =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainView.css 2014-08-04 15:06:04 UTC (rev 3894) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainView.css 2014-08-05 14:07:42 UTC (rev 3895) @@ -31,18 +31,18 @@ #file{ text : "lima.file"; mnemonic : "F"; } -#csv { text : "lima.importExport.csv"; } +#csv { text : "lima.importexport.csv"; } -#csvImport { text : "lima.importExport.import"; actionIcon : "import"; } -#csvImportAll { text : "lima.importExport.all"; } +#csvImport { text : "lima.importexport.import"; actionIcon : "import"; } +#csvImportAll { text : "lima.importexport.all"; } #csvImportAccounts { text : "lima.accounts.plan"; actionIcon : "accounts"; } #csvImportEntryBooks { text : "lima.entryBooks"; actionIcon : "entryBooks"; } #csvImportFinancialStatements { text : "lima.financialStatements"; actionIcon : "financialStatements"; } #csvImportVatStatements { text : "lima.vatStatements"; actionIcon : "vatStatements"; } #csvImportEntries { text : "lima.entries"; actionIcon : "entries" } -#csvExport { text : "lima.importExport.export"; actionIcon : "export"; } -#csvExportAll { text : "lima.importExport.all"; } +#csvExport { text : "lima.importexport.export"; actionIcon : "export"; } +#csvExportAll { text : "lima.importexport.all"; } #csvExportAccounts { text : "lima.accounts.plan"; actionIcon : "accounts"; } #csvExportEntryBooks { text : "lima.entryBooks"; actionIcon : "entryBooks"; } #csvExportFinancialStatements { text : "lima.financialStatements"; actionIcon : "financialStatements"; } @@ -50,14 +50,14 @@ #csvExportEntries { text : "lima.entries"; actionIcon : "entries" } -#ebp { text : "lima.importExport.ebp"; } +#ebp { text : "lima.importexport.ebp"; } -#ebpImport { text : "lima.importExport.import"; actionIcon : "import"; } +#ebpImport { text : "lima.importexport.import"; actionIcon : "import"; } #ebpImportAccounts { text : "lima.accounts.plan"; actionIcon : "accounts"; } #ebpImportEntryBooks { text : "lima.entryBooks"; actionIcon : "entryBooks"; } #ebpImportEntries { text : "lima.entries"; actionIcon : "entries" } -#ebpExport { text : "lima.importExport.export"; actionIcon : "export"; } +#ebpExport { text : "lima.importexport.export"; actionIcon : "export"; } #ebpExportAccounts { text : "lima.accounts.plan"; actionIcon : "accounts"; } #ebpExportEntryBooks { text : "lima.entryBooks"; actionIcon : "entryBooks"; } #ebpExportEntries { text : "lima.entries"; actionIcon : "entries" } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExport.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExport.java 2014-08-04 15:06:04 UTC (rev 3894) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExport.java 2014-08-05 14:07:42 UTC (rev 3895) @@ -27,16 +27,26 @@ import com.google.common.base.Charsets; import com.google.common.base.Strings; -import org.apache.commons.codec.binary.Base64; +import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; -import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.chorem.lima.ImportBackupException; import org.chorem.lima.LimaTechnicalException; -import org.chorem.lima.business.ImportEbpException; +import org.chorem.lima.business.ExportResult; +import org.chorem.lima.business.ImportExportResults; import org.chorem.lima.business.ImportResult; +import org.chorem.lima.business.LimaException; import org.chorem.lima.business.api.ExportService; import org.chorem.lima.business.api.ImportService; +import org.chorem.lima.entity.Account; +import org.chorem.lima.entity.Entry; +import org.chorem.lima.entity.EntryBook; +import org.chorem.lima.entity.FinancialStatement; +import org.chorem.lima.entity.FinancialTransaction; +import org.chorem.lima.entity.FiscalPeriod; +import org.chorem.lima.entity.Identity; +import org.chorem.lima.entity.VatStatement; import org.chorem.lima.enums.EncodingEnum; import org.chorem.lima.enums.ImportExportEnum; import org.chorem.lima.service.LimaServiceFactory; @@ -46,7 +56,6 @@ import javax.swing.*; import java.awt.*; import java.io.BufferedWriter; -import java.io.ByteArrayInputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; @@ -54,12 +63,16 @@ import java.io.InputStream; import java.io.OutputStreamWriter; import java.nio.charset.Charset; +import java.rmi.server.ExportException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.List; +import java.util.Map; +import java.util.Set; import java.util.concurrent.ExecutionException; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; +import java.util.zip.ZipOutputStream; import static org.nuiton.i18n.I18n.t; @@ -90,6 +103,8 @@ protected ErrorHelper errorHelper; + public static final String JAVA_IO_TMPDIR = System.getProperty("java.io.tmpdir")+"/"; + public ImportExport(Component view) { viewComponent = view; @@ -115,7 +130,7 @@ */ public void importExport(ImportExportEnum importExportMethode, String file, boolean verbose) { final ImportExportEnum importExportMethodeF = importExportMethode; - final Charset charset = Charsets.UTF_8; + final Charset defaultCharset = Charsets.UTF_8; if (Strings.isNullOrEmpty(file)) { file = chooseFile(importExportMethode.getImportMode(), importExportMethode); } @@ -124,128 +139,101 @@ final String filePath = file; final Boolean verboseMode = verbose; final Boolean importMode = importExportMethode.getImportMode(); - new SwingWorker<String, Void>() { + + new SwingWorker<ImportExportResults, Void>() { + @Override - protected String doInBackground() { - String datas; - // TODO DCossé 24/07/14 remove it - String result = ""; - ImportResult importResult; + protected ImportExportResults doInBackground() { + ImportExportResults results = new ImportExportResults(); try { switch (importExportMethodeF) { //####################################### CSV ############################################## case CSV_ACCOUNTCHARTS_EXPORT: - datas = exportService.exportAccountsAsCSV(charset.name()); - createFile(filePath, charset.name(), datas); + results.pushExportResults(exportService.exportAccountsAsCSV(defaultCharset.name())); + createFile(filePath, defaultCharset.name(), results.getExportResults().get(0).getExportData()); break; case CSV_ACCOUNTCHARTS_IMPORT: - datas = extractFile(filePath, charset.name()); - importResult = importService.importAccountAsCSV(datas); - // TODO DCossé 24/07/14 change result - result = "SUCCESS"; + String content = loadFile(filePath, defaultCharset.name()); + results.pushImportResults(importService.importAccountAsCSV(content)); break; - case CSV_ENTRYBOOKS_EXPORT: - datas = exportService.exportEntryBooksAsCSV(charset.name()); - createFile(filePath, charset.name(), datas); + results.pushExportResults(exportService.exportEntryBooksAsCSV(defaultCharset.name())); + createFile(filePath, defaultCharset.name(), results.getExportResults().get(0).getExportData()); break; case CSV_ENTRYBOOKS_IMPORT: - datas = extractFile(filePath, charset.name()); - importResult = importService.importEntryBooksAsCSV(datas); - // TODO DCossé 24/07/14 change result - result = "SUCCESS"; + content = loadFile(filePath, defaultCharset.name()); + results.pushImportResults(importService.importEntryBooksAsCSV(content)); break; case CSV_ENTRIES_EXPORT: - datas = exportService.exportEntriesAsCSV(charset.name(), true); - createFile(filePath, charset.name(), datas); + results.pushExportResults(exportService.exportEntriesAsCSV(defaultCharset.name(), true)); + createFile(filePath, defaultCharset.name(), results.getExportResults().get(0).getExportData()); break; case CSV_ENTRIES_IMPORT: - datas = extractFile(filePath, charset.name()); - importResult = importService.importEntriesAsCSV(datas); - // TODO DCossé 24/07/14 change result - result = "SUCCESS"; + content = loadFile(filePath, defaultCharset.name()); + results.pushImportResults(importService.importEntriesAsCSV(content)); break; case CSV_ALL_EXPORT: - datas = exportService.exportBackup(charset.name()); - createZipFile(filePath, datas); + exportBackup(filePath, defaultCharset.name()); break; case CSV_ALL_IMPORT: - List<ImportResult> allResults = importAllFromZipFile(filePath); - // TODO DCossé 24/07/14 change result - result = "SUCCESS"; + results = importAllFromZipFile(filePath); break; case CSV_VAT_EXPORT: - datas = exportService.exportVatStatements(charset.name()); - createFile(filePath, charset.name(), datas); + results.pushExportResults(exportService.exportVatStatements(defaultCharset.name())); + createFile(filePath, defaultCharset.name(), results.getExportResults().get(0).getExportData()); break; case CSV_VAT_IMPORT: - datas = extractFile(filePath, charset.name()); - importResult = importService.importVATStatementsAsCSV(datas); - // TODO DCossé 24/07/14 change result - result = "SUCCESS"; + content = loadFile(filePath, defaultCharset.name()); + results.pushImportResults(importService.importVATStatementsAsCSV(content)); break; case CSV_FINANCIALSTATEMENTS_EXPORT: - datas = exportService.exportFinancialStatements(charset.name()); - createFile(filePath, charset.name(), datas); + results.pushExportResults(exportService.exportFinancialStatements(defaultCharset.name())); + createFile(filePath, defaultCharset.name(), results.getExportResults().get(0).getExportData()); break; case CSV_FINANCIALSTATEMENTS_IMPORT: - datas = extractFile(filePath, charset.name()); - importResult = importService.importFinancialStatementsAsCSV(datas); - // TODO DCossé 24/07/14 change result - result = "SUCCESS"; + content = loadFile(filePath, defaultCharset.name()); + results.pushImportResults(importService.importFinancialStatementsAsCSV(content)); break; //####################################### EBP ############################################## + //For windows ebp so using encoding ISOLATIN1 case EBP_ACCOUNTCHARTS_EXPORT: - //For windows ebp - datas = exportService.exportAccountAsEbp(charset.name()); - createFile(filePath, EncodingEnum.ISOLATIN1.getEncoding(), datas); + results.pushExportResults(exportService.exportAccountAsEbp(defaultCharset.name())); + createFile(filePath, EncodingEnum.ISOLATIN1.getEncoding(), results.getExportResults().get(0).getExportData()); break; case EBP_ACCOUNTCHARTS_IMPORT: - //For windows ebp - datas = extractFile(filePath, EncodingEnum.ISOLATIN1.getEncoding()); - importResult = importService.importAccountFromEbp(datas); - // TODO DCossé 24/07/14 change result - result = "SUCCESS"; + content = loadFile(filePath, EncodingEnum.ISOLATIN1.getEncoding()); + results.pushImportResults(importService.importAccountFromEbp(content)); break; case EBP_ENTRYBOOKS_EXPORT: - datas = exportService.exportEntryBookAsEbp(charset.name()); - createFile(filePath, EncodingEnum.ISOLATIN1.getEncoding(), datas); + results.pushExportResults(exportService.exportEntryBookAsEbp(defaultCharset.name())); + createFile(filePath, EncodingEnum.ISOLATIN1.getEncoding(), results.getExportResults().get(0).getExportData()); break; case EBP_ENTRYBOOKS_IMPORT: - datas = extractFile(filePath, EncodingEnum.ISOLATIN1.getEncoding()); - importResult = importService.importEntryBookFromEbp(datas); - // TODO DCossé 24/07/14 change result - result = "SUCCESS"; + content = loadFile(filePath, EncodingEnum.ISOLATIN1.getEncoding()); + results.pushImportResults(importService.importEntryBookFromEbp(content)); break; case EBP_ENTRIES_EXPORT: - //For windows ebp - datas = exportService.exportEntriesAsEbp(charset.name()); - createFile(filePath, EncodingEnum.ISOLATIN1.getEncoding(), datas); + results.pushExportResults(exportService.exportEntriesAsEbp(defaultCharset.name())); + createFile(filePath, EncodingEnum.ISOLATIN1.getEncoding(), results.getExportResults().get(0).getExportData()); break; case EBP_ENTRIES_IMPORT: - //For windows ebp - datas = extractFile(filePath, EncodingEnum.ISOLATIN1.getEncoding()); - importResult = importService.importEntriesFromEbp(datas); - // TODO DCossé 24/07/14 change result - result = "SUCCESS"; + content = loadFile(filePath, EncodingEnum.ISOLATIN1.getEncoding()); + results.pushImportResults(importService.importEntriesFromEbp(content)); break; } - } catch (ImportEbpException e) { - errorHelper.showErrorMessage(t(e.getMessage())); - } catch (Exception e) { - // TODO DCossé 01/08/14 it should be an other exception + } catch (ExportException e) { e.printStackTrace(); } - return result; + return results; } @Override @@ -261,46 +249,89 @@ // display result dialog if (verboseMode) { - String result = get(); - if (importMode && StringUtils.isBlank(result)) { + ImportExportResults results = get(); + if (importMode && results == null) { JOptionPane.showMessageDialog(viewComponent, t("lima.ui.importexport.importerror"), t("lima.ui.importexport.importtitle"), JOptionPane.ERROR_MESSAGE); } else { if (importMode) { - if (log.isDebugEnabled()) { - log.debug("importMode"); - log.debug("importExportMethodeF : " + importExportMethodeF); - } - //special message when importing a VAT PDF - if (importExportMethodeF.equals(ImportExportEnum.PDF_VAT_IMPORT)) { + List<ImportResult> resultList = results.getImportResults(); + if (resultList != null) { if (log.isDebugEnabled()) { - log.debug("PDF_VAT_IMPORT"); + log.debug("importMode"); + log.debug("importExportMethodeF : " + importExportMethodeF); + for (ImportResult result : resultList) { + String importedEntity = result.getFromSource().getSimpleName(); + log.debug(importedEntity + " nbCreated: " + result.getNbCreated()); + log.debug(importedEntity + " nbUpdated: " + result.getNbUpdated()); + log.debug(importedEntity + " nbIgnored: " + result.getNbIgnored()); + } } + if (log.isDebugEnabled()) { + log.debug("import.terminated"); + } + + String message = "Import"; + for (ImportResult result : resultList) { + Class fromSource = result.getFromSource(); + message += getFromSourceMessage(fromSource)+"\n"; + message += t("lima.ui.importexport.import.nbCreated", result.getNbCreated())+"\n"; + message += t("lima.ui.importexport.import.nbUpdated", result.getNbUpdated())+"\n"; + message += t("lima.ui.importexport.import.nbIgnored", result.getNbIgnored())+"\n"; + Map<Integer, LimaException> exceptionsByLine = result.getAllExceptionsByLine(); + if (exceptionsByLine != null) { + Set<Integer> lines = exceptionsByLine.keySet(); + for (Integer line : lines) { + message += t("lima.ui.importexport.import.exceptions", line)+"\n"; + if (log.isErrorEnabled()) { + LimaException importException = exceptionsByLine.get(line); + log.error(importException.getMessage()); + } + } + } + } + JOptionPane.showMessageDialog( waitView, - t("lima.ui.importexport.import.vatpdfimport"), + message, t("lima.ui.importexport.import"), JOptionPane.INFORMATION_MESSAGE); - } else { + } + } else { + List<ExportResult> exportResults = results.getExportResults(); + if (exportResults != null) { if (log.isDebugEnabled()) { - log.debug("import.terminated"); + log.debug("export.terminated"); + } + String message = "Export"; + for (ExportResult result : exportResults) { + Class fromSource = result.getFromSource(); + message += getFromSourceMessage(fromSource); + List<ExportException> exportExceptions = result.getExportExceptions(); + if (exportExceptions != null && !exportExceptions.isEmpty()) { + message += t("lima.ui.importexport.export.exception")+"\n"; + if (log.isErrorEnabled()) { + for (ExportException exportException : exportExceptions) { + log.error(exportException.getMessage()); + } + } + } + } + JOptionPane.showMessageDialog( waitView, - t("lima.ui.importexport.import.terminated"), - t("lima.ui.importexport.import"), + t("lima.ui.importexport.export.terminated"), + message, JOptionPane.INFORMATION_MESSAGE); + } else { + if (log.isDebugEnabled()) { + log.debug("export.terminated"); + log.debug(t("lima.ui.importexport.no.result")); + } } - } else { - if (log.isDebugEnabled()) { - log.debug("export.terminated"); - } - JOptionPane.showMessageDialog( - waitView, - t("lima.ui.importexport.export.terminated"), - t("lima.ui.importexport.export"), - JOptionPane.INFORMATION_MESSAGE); + } } } @@ -315,7 +346,29 @@ } } + private String getFromSourceMessage(Class fromSource) { + String message; + if (fromSource.equals(Account.class)){ + message = t("lima.ui.importexport.account")+"\n"; + } else if (fromSource.equals(Entry.class)) { + message = t("lima.ui.importexport.entry")+"\n"; + }else if (fromSource.equals(FinancialStatement.class)) { + message = t("lima.ui.importexport.financialStatement")+"\n"; + } else if (fromSource.equals(FinancialTransaction.class)) { + message = t("lima.ui.importexport.financialTransaction")+"\n"; + } else if (fromSource.equals(FiscalPeriod.class)) { + message = t("lima.ui.importexport.fiscalPeriod")+"\n"; + } else if (fromSource.equals(Identity.class)) { + message = t("lima.ui.importexport.identity")+"\n"; + } else if (fromSource.equals(VatStatement.class)) { + message = t("lima.ui.importexport.vatStatement")+"\n"; + } else { + throw new LimaTechnicalException("Source not know"); + } + return message; + } + /** * open choose file dialog with appropriate file mode view * folders for export or folders+files for import @@ -364,8 +417,6 @@ } } - - return filePath; } @@ -377,7 +428,7 @@ * @param charset * @param datas */ - public void createFile(String filePath, String charset, String datas) { + protected File createFile(String filePath, String charset, String datas) { File file = new File(filePath); BufferedWriter out = null; try { @@ -392,7 +443,7 @@ } finally { IOUtils.closeQuietly(out); } - + return file; } /** @@ -402,7 +453,7 @@ * @param charset * @return */ - public String extractFile(String filePath, String charset) { + protected String loadFile(String filePath, String charset) { String result = null; InputStream is = null; try { @@ -420,18 +471,38 @@ return result; } - protected void createZipFile(String path, String zippedBase64Str) { + protected void exportBackup(String path, String charset) throws ExportException { + ImportExportResults results = exportService.exportBackup(charset); + + ZipOutputStream export = null; try { - byte[] bytes = Base64.decodeBase64(zippedBase64Str); - ByteArrayInputStream inputStream = new ByteArrayInputStream(bytes); SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss"); - IOUtils.copy(inputStream, new FileOutputStream(path+"/LIMA-BACKUP-"+ dateFormat.format(new Date()))); + FileOutputStream fos = new FileOutputStream(path + "/LIMA-BACKUP-"+ dateFormat.format(new Date())); + export = new ZipOutputStream(fos); + for (ExportResult result : results.getExportResults()) { + File file = createFile(JAVA_IO_TMPDIR + result.getFromSource().getSimpleName(), charset, result.getExportData()); + if (file != null) { + ZipEntry ze= new ZipEntry(file.getName()); + export.putNextEntry(ze); + int len; + byte[] buffer = new byte[1024]; + FileInputStream stream = new FileInputStream(file); + while ((len = stream.read(buffer)) > 0) { + export.write(buffer, 0, len); + } + stream.close(); + FileUtils.forceDelete(file); + } + } + export.flush(); } catch (IOException e) { - throw new LimaTechnicalException("could not zip file", e); + e.printStackTrace(); + } finally { + IOUtils.closeQuietly(export); } } - protected List<ImportResult> importAllFromZipFile(String filePath) { + protected ImportExportResults importAllFromZipFile(String filePath) { ZipInputStream zipInputStream = null; String tmpDir = System.getProperty("java.io.tmpdir")+"/"; FileInputStream inputStream = null; @@ -441,31 +512,16 @@ zipInputStream = new ZipInputStream(inputStream); ZipEntry entry; + while ((entry = zipInputStream.getNextEntry()) != null) { byte[] buffer = new byte[2048]; - FileOutputStream fileoutputstream = null; + FileOutputStream fileoutputstream = new FileOutputStream(tmpDir + entry.getName() + ".csv"); - if (entry.getName().equalsIgnoreCase("accounts.csv")) { - fileoutputstream = new FileOutputStream(tmpDir + "accounts.csv"); - } else if (entry.getName().equalsIgnoreCase("entryBooks.csv")) { - fileoutputstream = new FileOutputStream(tmpDir + "entryBooks.csv"); - } else if (entry.getName().equalsIgnoreCase("fiscalPeriod.csv")) { - fileoutputstream = new FileOutputStream(tmpDir + "fiscalPeriods.csv"); - } else if (entry.getName().equalsIgnoreCase("financialTransactions.csv")) { - fileoutputstream = new FileOutputStream(tmpDir + "financialTransactions.csv"); - } else if (entry.getName().equalsIgnoreCase("entries.csv")) { - fileoutputstream = new FileOutputStream(tmpDir + "entries.csv"); - } else if (entry.getName().equalsIgnoreCase("identity.csv")) { - fileoutputstream = new FileOutputStream(tmpDir + "identity.csv"); - } int n; - - if (fileoutputstream != null) { - while ((n = zipInputStream.read(buffer, 0, 2048)) > -1) { - fileoutputstream.write(buffer, 0, n); - } - fileoutputstream.close(); + while ((n = zipInputStream.read(buffer, 0, 2048)) > -1) { + fileoutputstream.write(buffer, 0, n); } + fileoutputstream.close(); zipInputStream.closeEntry(); } @@ -476,30 +532,30 @@ IOUtils.closeQuietly(inputStream); } InputStream transactionsStream, entryBooksStream, fiscalPeriodsStream, entriesStream, accountsStream, identityStream; - List<ImportResult> results; + ImportExportResults results = null; try { - entryBooksStream = new FileInputStream(tmpDir + "entryBooks.csv"); + entryBooksStream = new FileInputStream(tmpDir + EntryBook.class.getSimpleName() +".csv"); String entryBooksStreamString = IOUtils.toString(entryBooksStream); IOUtils.closeQuietly(entryBooksStream); // import - transactionsStream = new FileInputStream(tmpDir + "financialTransactions.csv"); + transactionsStream = new FileInputStream(tmpDir + FinancialTransaction.class.getSimpleName() +".csv"); String transactionsStreamString = IOUtils.toString(transactionsStream); IOUtils.closeQuietly(transactionsStream); - fiscalPeriodsStream = new FileInputStream(tmpDir + "fiscalPeriods.csv"); + fiscalPeriodsStream = new FileInputStream(tmpDir + FiscalPeriod.class.getSimpleName() +".csv"); String fiscalPeriodsStreamString = IOUtils.toString(fiscalPeriodsStream); IOUtils.closeQuietly(fiscalPeriodsStream); - accountsStream = new FileInputStream(tmpDir + "accounts.csv"); + accountsStream = new FileInputStream(tmpDir + Account.class.getSimpleName() +".csv"); String accountsStreamString = IOUtils.toString(accountsStream); IOUtils.closeQuietly(accountsStream); - entriesStream = new FileInputStream(tmpDir + "entries.csv"); + entriesStream = new FileInputStream(tmpDir + Entry.class.getSimpleName() +".csv"); String entriesStreamString = IOUtils.toString(entriesStream); IOUtils.closeQuietly(entriesStream); - identityStream = new FileInputStream(tmpDir + "identity.csv"); + identityStream = new FileInputStream(tmpDir + Identity.class.getSimpleName() + ".csv"); String identityStreamString = IOUtils.toString(identityStream); IOUtils.closeQuietly(identityStream); @@ -509,7 +565,9 @@ if(log.isInfoEnabled()) { log.info(ex); } - throw new LimaTechnicalException("could not import files", ex); + results = new ImportExportResults(); + ImportResult result = results.createAddAndGetImportResult(Account.class); + result.addException(new ImportBackupException("could not import files", ex)); } return results; } Modified: trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties =================================================================== --- trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties 2014-08-04 15:06:04 UTC (rev 3894) +++ trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties 2014-08-05 14:07:42 UTC (rev 3895) @@ -343,14 +343,13 @@ lima.identity.phoneNumber=Phone number lima.identity.vatNumber=VAT number lima.identity.zipCode=Zip code -lima.importExport.all= -lima.importExport.csv= -lima.importExport.ebp= -lima.importExport.export= -lima.importExport.import= +lima.importexport.all= lima.importexport.choiceencoding= +lima.importexport.csv= +lima.importexport.ebp= lima.importexport.export= lima.importexport.export.terminated= +lima.importexport.import= lima.importexport.import.alreadyExistFinancialStatement=Category with name %s exists for parent %s. lima.importexport.usevatpdf= lima.init.closed=Lima closed at %1$s @@ -572,29 +571,40 @@ lima.ui.fullscreen= lima.ui.home.entryBooks.info= lima.ui.home.entryBooks.info.one= -lima.ui.importExport.all= -lima.ui.importExport.csv= -lima.ui.importExport.ebp= -lima.ui.importExport.export= -lima.ui.importExport.import= +lima.ui.importexport.account=Accounts import completed. lima.ui.importexport.accountcharts=Accounts chart lima.ui.importexport.all=All lima.ui.importexport.csv=Import/Export CSV lima.ui.importexport.defaultentrybooks=Defaults entrybooks lima.ui.importexport.ebp=Import/Export EBP lima.ui.importexport.entries=Entries +lima.ui.importexport.entry=Entries import completed. lima.ui.importexport.entrybooks=Entry books lima.ui.importexport.export=Export +lima.ui.importexport.export.exception= +lima.ui.importexport.export.exceptions=Export failed. +lima.ui.importexport.export.import.exceptions=Export has failed. lima.ui.importexport.export.terminated=Export terminated +lima.ui.importexport.financialStatement=Financial transactions import completed. +lima.ui.importexport.financialTransaction= lima.ui.importexport.financialstatements=FinancialStatements chart lima.ui.importexport.financialtransactions=Moves +lima.ui.importexport.fiscalPeriod=Fiscal periods import completed. +lima.ui.importexport.identity=Identity import completed. lima.ui.importexport.import= +lima.ui.importexport.import.exception= +lima.ui.importexport.import.exceptions=The line %d could not be imported. +lima.ui.importexport.import.nbCreated=%d created +lima.ui.importexport.import.nbIgnored=%d ignored +lima.ui.importexport.import.nbUpdated=%d updated lima.ui.importexport.import.terminated=Import terminated lima.ui.importexport.import.vatpdfimport=The PDF has been imported. It can be found inside the Lima resources directory lima.ui.importexport.importcsv= lima.ui.importexport.importebp= lima.ui.importexport.importerror=An error has occured during import lima.ui.importexport.importtitle= +lima.ui.importexport.no.result=No result found. +lima.ui.importexport.vatStatement=VTA transactions import completed. lima.ui.importexport.vatstatements=VAT chart lima.ui.importexport.wait=Job in progress… lima.ui.importexport.waittitle= Modified: trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties =================================================================== --- trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties 2014-08-04 15:06:04 UTC (rev 3894) +++ trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties 2014-08-05 14:07:42 UTC (rev 3895) @@ -301,15 +301,14 @@ lima.identity.phoneNumber=n° Tel lima.identity.vatNumber=n° TVA lima.identity.zipCode=Code Postal -lima.importExport.all=Tout -lima.importExport.csv=Import/Export CSV -lima.importExport.ebp=Import/Export EBP -lima.importExport.export=Exporter -lima.importExport.import=Importer +lima.importexport.all=Tout lima.importexport.choiceencoding=Choix de l'encodage -lima.importexport.export= -lima.importexport.export.terminated= -lima.importexport.import.alreadyExistFinancialStatement= +lima.importexport.csv=Import/Export CSV +lima.importexport.ebp=Import/Export EBP +lima.importexport.export=Exporter +lima.importexport.export.terminated=Export terminé +lima.importexport.import=Importer +lima.importexport.import.alreadyExistFinancialStatement=La transaction financière %s existe déjà sur le parent %s. lima.importexport.import.alreadyExistVatStatement= lima.importexport.usevatpdf=Êtes-vous sûr de vouloir utiliser ce pdf pour la déclaration de TVA ? lima.init.closed=Lima fermé à %1$s @@ -376,7 +375,7 @@ lima.ui.account.removeaccountconfirm=Voulez-vous supprimer le compte %s ? lima.ui.account.removeaccounttitle=Suppression d'un compte lima.ui.account.shortened=Plan comptable abrégé -lima.ui.account.update.error.invalidAccountNumber=Le numéro du compt %1$s n'est pas valide +lima.ui.account.update.error.invalidAccountNumber=Le numéro du compte %1$s n'est pas valide lima.ui.account.updateaccounttitle=Modification d'un compte lima.ui.common.amountcredit=Total Crédit lima.ui.common.amountdebit=Total Débit @@ -473,8 +472,8 @@ lima.ui.fiscalPeriod.add.error.notBeginNextDayOfLastFiscalPeriod=La date de début de l'exercice doit suivre la date de fin de l'exercice précédent le %1$te/%1$tm/%1$tY lima.ui.fiscalPeriod.block.error.AlreadyLockedFiscalPeriod=L'exercice est déjà clôturés lima.ui.fiscalPeriod.block.error.lastUnlockedFiscalPeriod=L'exercice prédent doit être clôturé -lima.ui.fiscalPeriod.buttonback= -lima.ui.fiscalPeriod.buttonnext= +lima.ui.fiscalPeriod.buttonback=← +lima.ui.fiscalPeriod.buttonnext=→ lima.ui.fiscalPeriod.delete.error.noEmptyFiscalPeriod=Impossible de supprimer un exercice avec des transactions (%1$s). lima.ui.fiscalperiod.addfiscalperiod.morethan12=La période sélectionnée n'est pas de 12 mois, voulez-vous continuer ? lima.ui.fiscalperiod.addfiscalperiodtitle=Nouvel exercice @@ -499,17 +498,33 @@ lima.ui.fiscalperiod.modifyfiscalperiodtitle=Modification de l'exercice lima.ui.fiscalperiod.open=Ouvert lima.ui.fiscalperiod.status=Statut +lima.ui.importexport.account=des comptes terminé. lima.ui.importexport.defaultentrybooks=Journaux par défaut +lima.ui.importexport.entry=des entrées terminé. lima.ui.importexport.entrybooks=Journaux lima.ui.importexport.export=Exporter +lima.ui.importexport.export.action=Export +lima.ui.importexport.export.exception= +lima.ui.importexport.export.exceptions=Echec de l'export. lima.ui.importexport.export.terminated=Export terminé +lima.ui.importexport.financialStatement=des transaction financière terminé. +lima.ui.importexport.financialTransaction= +lima.ui.importexport.fiscalPeriod=des periodes fiscales terminé. +lima.ui.importexport.identity=de l'identité terminé. lima.ui.importexport.import=Importer +lima.ui.importexport.import.action=Import +lima.ui.importexport.import.exceptions=La ligne %d n'a pu être impotée. +lima.ui.importexport.import.nbCreated=%d créés +lima.ui.importexport.import.nbIgnored=%d ignorés +lima.ui.importexport.import.nbUpdated=%d mis à jours lima.ui.importexport.import.terminated=Import terminé lima.ui.importexport.import.vatpdfimport=Le PDF a bien été importé dans le répertoire des ressources de Lima lima.ui.importexport.importcsv=Import/Export CSV lima.ui.importexport.importebp=Import/Export EBP lima.ui.importexport.importerror=Une erreur est survenue lors de l'import lima.ui.importexport.importtitle=Erreur d'import +lima.ui.importexport.no.result=Aucun résultat trouvé. +lima.ui.importexport.vatStatement=des transactions de tva terminé. lima.ui.importexport.wait=Traitement en cours… lima.ui.importexport.waittitle=Traitement en cours lima.ui.lettering.account=Comptes
participants (1)
-
dcosse@users.chorem.org