r3887 - in trunk: lima-business/src/main/java/org/chorem/lima/business/ejb lima-business/src/main/java/org/chorem/lima/business/ejb/csv lima-business/src/test/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/importexport
Author: dcosse Date: 2014-07-31 21:50:37 +0200 (Thu, 31 Jul 2014) New Revision: 3887 Url: http://forge.chorem.org/projects/lima/repository/revisions/3887 Log: refs #1032 import export de l'identit?\195?\169 Added: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/csv/IdentityModel.java Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/NewImportService.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/NewExportServiceImpl.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/NewImportServiceImpl.java trunk/lima-business/src/test/java/org/chorem/lima/business/AbstractLimaTest.java trunk/lima-business/src/test/java/org/chorem/lima/business/NewImportExportServiceTest.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExport.java Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/NewExportServiceImpl.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/NewExportServiceImpl.java 2014-07-31 16:45:29 UTC (rev 3886) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/NewExportServiceImpl.java 2014-07-31 19:50:37 UTC (rev 3887) @@ -34,6 +34,7 @@ import org.chorem.lima.business.api.EntryBookService; import org.chorem.lima.business.api.FinancialStatementService; import org.chorem.lima.business.api.FinancialTransactionService; +import org.chorem.lima.business.api.IdentityService; import org.chorem.lima.business.api.NewExportService; import org.chorem.lima.business.api.VatStatementService; import org.chorem.lima.business.ejb.csv.AccountModel; @@ -42,6 +43,7 @@ import org.chorem.lima.business.ejb.csv.FinancialStatementModel; import org.chorem.lima.business.ejb.csv.FinancialTransactionModel; import org.chorem.lima.business.ejb.csv.FiscalPeriodModel; +import org.chorem.lima.business.ejb.csv.IdentityModel; import org.chorem.lima.business.ejb.csv.VatStatementModel; import org.chorem.lima.entity.Account; import org.chorem.lima.entity.AccountTopiaDao; @@ -54,6 +56,7 @@ import org.chorem.lima.entity.FinancialTransactionTopiaDao; import org.chorem.lima.entity.FiscalPeriod; import org.chorem.lima.entity.FiscalPeriodTopiaDao; +import org.chorem.lima.entity.Identity; import org.chorem.lima.entity.VatStatement; import org.nuiton.csv.Export; @@ -99,6 +102,9 @@ @EJB protected VatStatementService vatStatementService; + @EJB + protected IdentityService identityService; + public static final String JAVA_IO_TMPDIR = "java.io.tmpdir"; @Override @@ -112,20 +118,23 @@ files.add(exportFiscalPeriodFile(charset)); files.add(exportFinancialTransactionsFile(charset)); files.add(exportEntriesFile(charset, false)); + files.add(exportIdentity(charset)); export = new ZipOutputStream(rstBao); for (File file : files) { - 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); + 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); } - stream.close(); - FileUtils.forceDelete(file); } export.flush(); @@ -141,22 +150,26 @@ 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) { + AccountModel model = new AccountModel(); + String tmpDir = System.getProperty(JAVA_IO_TMPDIR)+"/"; - AccountModel model = new AccountModel(); - String tmpDir = System.getProperty(JAVA_IO_TMPDIR)+"/"; - - File result = new File(tmpDir + "accounts.csv"); - Export.exportToFile(model, entities, result, Charset.forName(charset)); + result = new File(tmpDir + "accounts.csv"); + Export.exportToFile(model, entities, result, Charset.forName(charset)); + } return result; } @Override public String exportAccountsAsCSV(String charset) { - String result; + String result = null; try { File file = exportAccountsFile(charset); - FileInputStream inputStream = new FileInputStream(file); - result = IOUtils.toString(inputStream); + if (file != null) { + FileInputStream inputStream = new FileInputStream(file); + result = IOUtils.toString(inputStream); + } } catch (Exception e) { throw new LimaTechnicalException(e); } @@ -166,23 +179,27 @@ 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 = System.getProperty(JAVA_IO_TMPDIR)+"/"; + result = new File(tmpDir + "entryBooks.csv"); + EntryBookModel model = new EntryBookModel(); + Export.exportToFile(model, entities, result, Charset.forName(charset)); + } - String tmpDir = System.getProperty(JAVA_IO_TMPDIR)+"/"; - File result = new File(tmpDir + "entryBooks.csv"); - EntryBookModel model = new EntryBookModel(); - Export.exportToFile(model, entities, result, Charset.forName(charset)); - return result; } @Override public String exportEntryBooksAsCSV(String charset) { - String result; + String result = null; try { File file = exportEntryBooksFile(charset); - FileInputStream inputStream = new FileInputStream(file); - result = IOUtils.toString(inputStream); + if (file != null) { + FileInputStream inputStream = new FileInputStream(file); + result = IOUtils.toString(inputStream); + } } catch (Exception e) { throw new LimaTechnicalException(e); } @@ -194,21 +211,27 @@ FiscalPeriodTopiaDao dao = getDaoHelper().getFiscalPeriodDao(); List<FiscalPeriod> entities = dao.findAll(); - String tmpDir = System.getProperty(JAVA_IO_TMPDIR)+"/"; - File result = new File(tmpDir + "fiscalPeriod.csv"); - FiscalPeriodModel model = new FiscalPeriodModel(); - Export.exportToFile(model, entities, result, Charset.forName(charset)); + File result = null; + if (entities != null && !entities.isEmpty()) { + String tmpDir = System.getProperty(JAVA_IO_TMPDIR)+"/"; + result = new File(tmpDir + "fiscalPeriod.csv"); + FiscalPeriodModel model = new FiscalPeriodModel(); + Export.exportToFile(model, entities, result, Charset.forName(charset)); + } + return result; } @Override public String exportFiscalPeriodsAsCSV(String charset) { - String result; + String result = null; try { File file = exportFiscalPeriodFile(charset); - FileInputStream inputStream = new FileInputStream(file); - result = IOUtils.toString(inputStream); + if (file != null) { + FileInputStream inputStream = new FileInputStream(file); + result = IOUtils.toString(inputStream); + } } catch (Exception e) { throw new LimaTechnicalException(e); } @@ -216,17 +239,19 @@ } protected File exportFinancialTransactionsFile(String charset) throws Exception { - File result; + File result = null; FinancialTransactionTopiaDao financialTransactionTopiaDao = getDaoHelper().getFinancialTransactionDao(); List<FinancialTransaction> entities = financialTransactionTopiaDao.findAll(); - String tmpDir = System.getProperty(JAVA_IO_TMPDIR)+"/"; - result = new File(tmpDir + "financialTransactions.csv"); - FinancialTransactionModel model = new FinancialTransactionModel(entryBookService); - Export.exportToFile(model, entities, result, Charset.forName(charset)); - Export.exportToFile(model, entities, result, Charset.forName(charset)); + if (entities != null && !entities.isEmpty()) { + String tmpDir = System.getProperty(JAVA_IO_TMPDIR)+"/"; + result = new File(tmpDir + "financialTransactions.csv"); + FinancialTransactionModel model = new FinancialTransactionModel(entryBookService); + Export.exportToFile(model, entities, result, Charset.forName(charset)); + } + return result; } @@ -234,20 +259,42 @@ EntryTopiaDao dao = getDaoHelper().getEntryDao(); List<Entry> entities = dao.findAll(); - String tmpDir = System.getProperty(JAVA_IO_TMPDIR)+"/"; - File result = new File(tmpDir + "entries.csv"); - EntryModel model = new EntryModel(accountService, financialTransactionService , humanReadable); - Export.exportToFile(model, entities, result, Charset.forName(charset)); + File result = null; + if (entities != null && !entities.isEmpty()) { + String tmpDir = System.getProperty(JAVA_IO_TMPDIR)+"/"; + result = new File(tmpDir + "entries.csv"); + EntryModel model = new EntryModel(accountService, financialTransactionService , humanReadable); + Export.exportToFile(model, entities, result, Charset.forName(charset)); + } + return result; } + protected File exportIdentity(String charset) throws Exception { + File result = null; + + Identity identity = identityService.getIdentity(); + if (identity != null) { + List<Identity> identities = new ArrayList<>(); + identities.add(identity); + + String tmpDir = System.getProperty(JAVA_IO_TMPDIR)+"/"; + result = new File(tmpDir + "identity.csv"); + IdentityModel model = new IdentityModel(); + Export.exportToFile(model, identities, result, Charset.forName(charset)); + } + return result; + } + @Override public String exportEntriesAsCSV(String charset, Boolean humanReadable) { - String result; + String result = null; try { File file = exportEntriesFile(charset, humanReadable); - FileInputStream inputStream = new FileInputStream(file); - result = IOUtils.toString(inputStream); + if (file != null) { + FileInputStream inputStream = new FileInputStream(file); + result = IOUtils.toString(inputStream); + } } catch (Exception e) { throw new LimaTechnicalException(e); } Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/NewImportServiceImpl.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/NewImportServiceImpl.java 2014-07-31 16:45:29 UTC (rev 3886) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/NewImportServiceImpl.java 2014-07-31 19:50:37 UTC (rev 3887) @@ -47,6 +47,7 @@ import org.chorem.lima.business.api.FinancialStatementService; import org.chorem.lima.business.api.FinancialTransactionService; import org.chorem.lima.business.api.FiscalPeriodService; +import org.chorem.lima.business.api.IdentityService; import org.chorem.lima.business.api.NewImportService; import org.chorem.lima.business.api.VatStatementService; import org.chorem.lima.business.ejb.csv.AccountModel; @@ -55,6 +56,7 @@ import org.chorem.lima.business.ejb.csv.FinancialStatementModel; import org.chorem.lima.business.ejb.csv.FinancialTransactionModel; import org.chorem.lima.business.ejb.csv.FiscalPeriodModel; +import org.chorem.lima.business.ejb.csv.IdentityModel; import org.chorem.lima.business.ejb.csv.VatStatementModel; import org.chorem.lima.business.ejb.ebp.EntryBookEBPModel; import org.chorem.lima.business.ejb.ebp.EntryEBPModel; @@ -69,6 +71,7 @@ import org.chorem.lima.entity.FinancialTransaction; import org.chorem.lima.entity.FinancialTransactionImpl; import org.chorem.lima.entity.FiscalPeriod; +import org.chorem.lima.entity.Identity; import org.chorem.lima.entity.VatStatement; import org.nuiton.csv.Import; import org.nuiton.csv.ImportModel; @@ -120,6 +123,9 @@ @EJB protected VatStatementService vatStatementService; + @EJB + protected IdentityService identityService; + protected static final Function<Account, String> GET_ACCOUNT_NUMBER = new Function<Account, String>() { @Override public String apply(Account input) { @@ -260,6 +266,27 @@ return result; } + public ImportResult importIdentityAsCSV(String contents) { + ImportResult result = new ImportResult(); + // import and save identity + if (StringUtils.isNotBlank(contents)){ + InputStream contentStream = null; + try { + contentStream = IOUtils.toInputStream(contents); + ImportModel<Identity> model = new IdentityModel(); + Import<Identity> identities = Import.newImport(model, contentStream); + for (Identity identity : identities) { + identityService.updateIdentity(identity); + result.increaseCreated(); + } + } finally { + IOUtils.closeQuietly(contentStream); + } + } + + return result; + } + protected FinancialStatement returnFinancialStatement (FinancialStatement rootFinancialStatement, String subFinancialStatementLabel) throws AlreadyExistFinancialStatement, NotAllowedLabel { Collection<FinancialStatement> subFinancialStatements = rootFinancialStatement.getSubFinancialStatements(); FinancialStatement targetedFinancialStatement = null; @@ -553,13 +580,14 @@ } @Override - public List<ImportResult> importBackup(String entryBooks, String financialTransactions, String fiscalPeriods, String accounts, String entries) throws AlreadyExistAccountException, InvalidAccountNumberException { + public List<ImportResult> importBackup(String entryBooks, String financialTransactions, String fiscalPeriods, String accounts, String entries, String identity) throws AlreadyExistAccountException, InvalidAccountNumberException { List<ImportResult> results = new ArrayList<>(); - importAccountAsCSV(accounts); - importEntryBooksAsCSV(entryBooks); - importFiscalPeriodsAsCSV(fiscalPeriods); - importFinancialTransactionsAsCSV(financialTransactions); - importEntriesAsCSV(entries); + results.add(importAccountAsCSV(accounts)); + results.add(importEntryBooksAsCSV(entryBooks)); + results.add(importFiscalPeriodsAsCSV(fiscalPeriods)); + results.add(importFinancialTransactionsAsCSV(financialTransactions)); + results.add(importEntriesAsCSV(entries)); + results.add(importIdentityAsCSV(identity)); return results; } @@ -607,8 +635,7 @@ Collections.sort(fiscalPeriods, new FiscalPeriodComparator()); // There are no valid fiscalPeriods -> exception - int nbFiscalPeriods = fiscalPeriods.size(); - if (nbFiscalPeriods == 0) { + if (fiscalPeriods.isEmpty()) { result.getException().addException(0, new ImportEbpException( t("lima-business.import.nofiscalperiodopen"))); // whe don't want to go further. @@ -638,7 +665,7 @@ // if entry date have fiscalperiod open if (dateEcr.compareTo(fiscalPeriods.get(0).getBeginDate()) < 0 - || dateEcr.compareTo(fiscalPeriods.get(nbFiscalPeriods - 1).getEndDate()) > 0) { + || dateEcr.compareTo(fiscalPeriods.get(fiscalPeriods.size() - 1).getEndDate()) > 0) { result.getException().addException(lineIndex, new ImportEbpException(t("lima-business.import.entriesoutofdatesrange", dateEcr))); lineIndex++; continue; Copied: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/csv/IdentityModel.java (from rev 3884, trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/csv/AccountModel.java) =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/csv/IdentityModel.java (rev 0) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/csv/IdentityModel.java 2014-07-31 19:50:37 UTC (rev 3887) @@ -0,0 +1,72 @@ +package org.chorem.lima.business.ejb.csv; + +/* + * #%L + * Lima :: business + * %% + * 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 org.chorem.lima.entity.Identity; +import org.chorem.lima.entity.IdentityImpl; +import org.nuiton.csv.ExportModel; +import org.nuiton.csv.ExportableColumn; +import org.nuiton.csv.ModelBuilder; + +/** + * Created by davidcosse on 03/06/14. + */ +public class IdentityModel extends AbstractLimaModel<Identity> implements ExportModel<Identity> { + + public IdentityModel() { + super(';'); + newOptionalColumn("name", Identity.PROPERTY_NAME); + newOptionalColumn("description", Identity.PROPERTY_DESCRIPTION); + newOptionalColumn("address", Identity.PROPERTY_ADDRESS); + newOptionalColumn("address2", Identity.PROPERTY_ADDRESS2); + newOptionalColumn("city", Identity.PROPERTY_CITY); + newOptionalColumn("phoneNumber", Identity.PROPERTY_PHONE_NUMBER); + newOptionalColumn("email", Identity.PROPERTY_EMAIL); + newOptionalColumn("zipCode", Identity.PROPERTY_ZIP_CODE); + newOptionalColumn("vatNumber", Identity.PROPERTY_VAT_NUMBER); + newOptionalColumn("classificationCode", Identity.PROPERTY_CLASSIFICATION_CODE); + newOptionalColumn("buisinessNumber", Identity.PROPERTY_BUSINESS_NUMBER); + } + + @Override + public Iterable<ExportableColumn<Identity, Object>> getColumnsForExport() { + ModelBuilder<Identity> modelBuilder = new ModelBuilder<>(); + modelBuilder.newColumnForExport("name", Identity.PROPERTY_NAME); + modelBuilder.newColumnForExport("description", Identity.PROPERTY_DESCRIPTION); + modelBuilder.newColumnForExport("address", Identity.PROPERTY_ADDRESS); + modelBuilder.newColumnForExport("address2", Identity.PROPERTY_ADDRESS2); + modelBuilder.newColumnForExport("city", Identity.PROPERTY_CITY); + modelBuilder.newColumnForExport("phoneNumber", Identity.PROPERTY_PHONE_NUMBER); + modelBuilder.newColumnForExport("email", Identity.PROPERTY_EMAIL); + modelBuilder.newColumnForExport("zipCode", Identity.PROPERTY_ZIP_CODE); + modelBuilder.newColumnForExport("vatNumber", Identity.PROPERTY_VAT_NUMBER); + modelBuilder.newColumnForExport("classificationCode", Identity.PROPERTY_CLASSIFICATION_CODE); + modelBuilder.newColumnForExport("buisinessNumber", Identity.PROPERTY_BUSINESS_NUMBER); + return (Iterable) modelBuilder.getColumnsForExport(); + } + + @Override + public Identity newEmptyInstance() { + return new IdentityImpl(); + } +} Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/AbstractLimaTest.java =================================================================== --- trunk/lima-business/src/test/java/org/chorem/lima/business/AbstractLimaTest.java 2014-07-31 16:45:29 UTC (rev 3886) +++ trunk/lima-business/src/test/java/org/chorem/lima/business/AbstractLimaTest.java 2014-07-31 19:50:37 UTC (rev 3887) @@ -35,6 +35,7 @@ import org.chorem.lima.business.api.FinancialStatementService; import org.chorem.lima.business.api.FinancialTransactionService; import org.chorem.lima.business.api.FiscalPeriodService; +import org.chorem.lima.business.api.IdentityService; import org.chorem.lima.business.api.ImportService; import org.chorem.lima.business.api.NewExportService; import org.chorem.lima.business.api.NewImportService; @@ -101,6 +102,7 @@ protected NewExportService newExportService; protected FinancialStatementService financialStatementService; protected VatStatementService vatStatementService; + protected IdentityService identityService; protected LimaCallaoTopiaApplicationContext context; @@ -143,6 +145,7 @@ newImportService = LimaServiceFactory.getService(NewImportService.class); newExportService = LimaServiceFactory.getService(NewExportService.class); + identityService = LimaServiceFactory.getService(IdentityService.class); } } Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/NewImportExportServiceTest.java =================================================================== --- trunk/lima-business/src/test/java/org/chorem/lima/business/NewImportExportServiceTest.java 2014-07-31 16:45:29 UTC (rev 3886) +++ trunk/lima-business/src/test/java/org/chorem/lima/business/NewImportExportServiceTest.java 2014-07-31 19:50:37 UTC (rev 3887) @@ -35,6 +35,8 @@ 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; @@ -221,21 +223,30 @@ @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 = newExportService.exportBackup("UTF-8"); - initAbstractTest(); + String tmpDir = System.getProperty("java.io.tmpdir")+"/TMP_BACKUP.zip"; createZipFile(tmpDir, export); + initAbstractTest(); - FileInputStream contentStream = null; List<ImportResult> importResults; - try { - importResults = importAllFromZipFile(tmpDir); - } finally { - IOUtils.closeQuietly(contentStream); - } - for (ImportResult 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.getException().getAllExceptionsByLine().isEmpty()); } } @@ -270,6 +281,8 @@ 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; @@ -288,7 +301,7 @@ IOUtils.closeQuietly(zipInputStream); IOUtils.closeQuietly(inputStream); } - InputStream transactionsStream, entryBooksStream, fiscalPeriodsStream, entriesStream, accountsStream; + InputStream transactionsStream, entryBooksStream, fiscalPeriodsStream, entriesStream, accountsStream, identityStream; List<ImportResult> results; try { entryBooksStream = new FileInputStream(tmpDir + "entryBooks.csv"); @@ -312,8 +325,12 @@ String accountsStreamString = IOUtils.toString(accountsStream); IOUtils.closeQuietly(accountsStream); - results = newImportService.importBackup(entryBooksStreamString, transactionsStreamString, fiscalPeriodsStreamString, accountsStreamString, entriesStreamString); + identityStream = new FileInputStream(tmpDir + "identity.csv"); + String identityStreamString = IOUtils.toString(identityStream); + IOUtils.closeQuietly(identityStream); + results = newImportService.importBackup(entryBooksStreamString, transactionsStreamString, fiscalPeriodsStreamString, accountsStreamString, entriesStreamString, identityStreamString); + } catch (Exception ex) { if(log.isInfoEnabled()) { log.info(ex); Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/NewImportService.java =================================================================== --- trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/NewImportService.java 2014-07-31 16:45:29 UTC (rev 3886) +++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/NewImportService.java 2014-07-31 19:50:37 UTC (rev 3887) @@ -45,7 +45,7 @@ ImportResult importVATStatementsAsCSV(String contents); - List<ImportResult> importBackup(String entryBooks, String transactions, String fiscalPeriods, String accounts, String entries) throws AlreadyExistAccountException, InvalidAccountNumberException; + List<ImportResult> importBackup(String entryBooks, String transactions, String fiscalPeriods, String accounts, String entries, String identity) throws AlreadyExistAccountException, InvalidAccountNumberException; ImportResult importEntriesFromEbp(String datas); 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-07-31 16:45:29 UTC (rev 3886) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExport.java 2014-07-31 19:50:37 UTC (rev 3887) @@ -186,7 +186,8 @@ createFile(filePath, EncodingEnum.ISOLATIN1.getEncoding(), datas); break; case CSV_ALL_IMPORT: - List<ImportResult> results = importAllFromZipFile(filePath); + List<ImportResult> allResults = importAllFromZipFile(filePath); + // TODO DCossé 24/07/14 change result result = "SUCCESS"; break; case CSV_ACCOUNTCHARTS_IMPORT: @@ -462,6 +463,8 @@ 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; @@ -480,7 +483,7 @@ IOUtils.closeQuietly(zipInputStream); IOUtils.closeQuietly(inputStream); } - InputStream transactionsStream, entryBooksStream, fiscalPeriodsStream, entriesStream, accountsStream; + InputStream transactionsStream, entryBooksStream, fiscalPeriodsStream, entriesStream, accountsStream, identityStream; List<ImportResult> results; try { entryBooksStream = new FileInputStream(tmpDir + "entryBooks.csv"); @@ -504,8 +507,12 @@ String entriesStreamString = IOUtils.toString(entriesStream); IOUtils.closeQuietly(entriesStream); - results = newImportService.importBackup(entryBooksStreamString, transactionsStreamString, fiscalPeriodsStreamString, accountsStreamString, entriesStreamString); + identityStream = new FileInputStream(tmpDir + "identity.csv"); + String identityStreamString = IOUtils.toString(identityStream); + IOUtils.closeQuietly(identityStream); + results = newImportService.importBackup(entryBooksStreamString, transactionsStreamString, fiscalPeriodsStreamString, accountsStreamString, entriesStreamString, identityStreamString); + } catch (Exception ex) { if(log.isInfoEnabled()) { log.info(ex);
participants (1)
-
dcosse@users.chorem.org