r2971 - in trunk: lima-business/src/main/java/org/chorem/lima/business lima-business/src/main/java/org/chorem/lima/business/accountingrules lima-business/src/main/java/org/chorem/lima/business/ejb lima-business/src/test/java/org/chorem/lima/business lima-callao/src/main/xmi lima-swing/src/main/java/org/chorem/lima/ui lima-swing/src/main/java/org/chorem/lima/ui/account lima-swing/src/main/java/org/chorem/lima/ui/entrybook lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart lima
Author: jpepin Date: 2010-07-16 18:05:21 +0200 (Fri, 16 Jul 2010) New Revision: 2971 Url: http://chorem.org/repositories/revision/lima/2971 Log: Am?\195?\169lioration UI : plan comptable, journaux, et BCR par d?\195?\169faut. Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/DefaultAccountsChartEnum.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/DefaultAccountsChartForm.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/DefaultEntryBooksEnum.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/DefaultEntryBooksForm.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/DefaultFinancialStatementChartForm.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/DefaultFinancialStatementsEnum.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExportWaitView.jaxx Removed: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FilesServiceImpl.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/csv/ trunk/lima-business/src/test/java/org/chorem/lima/business/FilesServiceImplTest.java trunk/lima-swing/src/main/resources/import/default_pcg.xml trunk/lima-swing/src/main/resources/import/ebp_code-lutin-test.csv Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/FinancialStatementService.java trunk/lima-business/src/main/java/org/chorem/lima/business/FiscalPeriodServiceLocal.java trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialStatementServiceImpl.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java trunk/lima-callao/src/main/xmi/accounting.zargo trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountView.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookView.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartView.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/HomeViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExport.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExportEnum.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/FinancialStatementService.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/FinancialStatementService.java 2010-07-15 10:27:28 UTC (rev 2970) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/FinancialStatementService.java 2010-07-16 16:05:21 UTC (rev 2971) @@ -35,6 +35,7 @@ public void updateFinancialStatement(FinancialStatement financialStatement) throws LimaException, LimaBusinessException; public void removeFinancialStatement(FinancialStatement financialStatement) throws LimaException, LimaBusinessException; + public List<FinancialStatement> getAllFinancialStatements() throws LimaException; public List<FinancialStatement> getChildrenFinancialStatement(FinancialStatement financialStatement) throws LimaException; public List<FinancialStatement> getAllChildrenFinancialStatement(FinancialStatement financialStatement, List<FinancialStatement> financialStatements) throws LimaException, LimaBusinessException; Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/FiscalPeriodServiceLocal.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/FiscalPeriodServiceLocal.java 2010-07-15 10:27:28 UTC (rev 2970) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/FiscalPeriodServiceLocal.java 2010-07-16 16:05:21 UTC (rev 2971) @@ -20,7 +20,6 @@ package org.chorem.lima.business; import javax.ejb.Local; -import org.chorem.lima.entity.FiscalPeriod; /** * Fiscal period service. Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java 2010-07-15 10:27:28 UTC (rev 2970) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java 2010-07-16 16:05:21 UTC (rev 2971) @@ -61,9 +61,8 @@ } public void updateAccountRules(Account masterAccount, Account account) throws LimaException { - log.debug("masterAccount"+masterAccount); - log.debug("acccount"+account); super.updateAccountRules(masterAccount, account); + // Check if the number account is type numeric if (!StringUtils.isNumeric(account.getAccountNumber())){ throw new LimaBusinessException("AccountNumber is not numeric : " @@ -195,7 +194,7 @@ TopiaQuery query = fiscalPeriodDAO.createQuery(); fiscalPeriodDAO.findAllByQuery(query); - query.add(FiscalPeriod.LOCKED, Op.EQ, false); + query.addEquals(FiscalPeriod.LOCKED, Op.EQ, false); query.addOrder(FiscalPeriod.END_DATE); FiscalPeriod oldestUnBlockedFiscalPeriod = @@ -232,8 +231,6 @@ new ArrayList<ClosedPeriodicEntryBook>(); try { - - log.debug("france check"); // Get all closedperiod between for the period and entrybook Date endDate = closedPeriodicEntryBook. Deleted: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FilesServiceImpl.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FilesServiceImpl.java 2010-07-15 10:27:28 UTC (rev 2970) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FilesServiceImpl.java 2010-07-16 16:05:21 UTC (rev 2971) @@ -1,644 +0,0 @@ -/* *##% Lima Business - * Copyright (C) 2008 - 2010 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 2 - * 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, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * ##%* - */ - -package org.chorem.lima.business.ejb; - -import java.util.List; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.chorem.lima.entity.Account; -import org.jdom.Document; -import org.jdom.Element; - -/** - * Cette classe permet d'importer et exporter des données comptables. Ces données - * sont au format xml. - * - * @author Rémi Chapelet - */ -public class FilesServiceImpl { // implements FilesService { - - /** - * log - */ - private static final Log log = LogFactory.getLog(FilesServiceImpl.class); - - static Element racine = new Element("Callao"); - - static org.jdom.Document document = new Document(racine); - - private AccountServiceImpl accountServiceImpl = new AccountServiceImpl(); - - private EntryBookServiceImpl journalServiceImpl = new EntryBookServiceImpl(); - - private FiscalPeriodServiceImpl periodServiceImpl = new FiscalPeriodServiceImpl(); - - private FinancialPeriodServiceImpl timeSpanServiceImpl = new FinancialPeriodServiceImpl(); - - private FinancialTransactionServiceImpl transactionServiceImpl = new FinancialTransactionServiceImpl(); - - /** - * Cete méthode permet d'exporter des données de Callao vers un fichier au - * format xml. - * - * @param nameFile - */ - public void exportDatas(String nameFile) { - /*if (log.isDebugEnabled()) { - log.debug("Save file XML : "); - } - - // Partie Informations - Element info = new Element("informations"); - racine.addContent(info); - Attribute date = new Attribute("date", new Date().toString()); - info.setAttribute(date); - Attribute user = new Attribute("user", "Name user"); - info.setAttribute(user); - Attribute company = new Attribute("company", "Name company"); - info.setAttribute(company); - - // Partie Save - - // Création Element save - Element save = new Element("save"); - racine.addContent(save); - - // Period - - // Création élément liste de périods - Element periods = new Element("periods"); - // Création élément liste de timespans - Element timeSpans = new Element("timespans"); - save.addContent(periods); - save.addContent(timeSpans); - // Recherche de la liste de toutes les périodes et leurs timeSpans en DTO - List<PeriodDTO> listPeriodDTO = periodServiceImpl.getAllPeriod(); - // Pour chaque période - for (PeriodDTO periodDTO : listPeriodDTO) { - // Création élément périod - Element period = new Element("period"); - periods.addContent(period); - // Identifiant période - Attribute id = new Attribute("id", periodDTO.getId()); - period.setAttribute(id); - // BeginPeriod - // Découpage date - String dateTab[] = dateUtil.arrayDate(periodDTO.getBeginPeriod()); - Attribute beginYear = new Attribute("beginYear", dateTab[0]); - period.setAttribute(beginYear); - Attribute beginMonth = new Attribute("beginMonth", dateTab[1]); - period.setAttribute(beginMonth); - Attribute beginDay = new Attribute("beginDay", dateTab[2]); - period.setAttribute(beginDay); - // EndPeriod - dateTab = dateUtil.arrayDate(periodDTO.getEndPeriod()); - Attribute endYear = new Attribute("endYear", dateTab[0]); - period.setAttribute(endYear); - Attribute endMonth = new Attribute("endMonth", dateTab[1]); - period.setAttribute(endMonth); - Attribute endDay = new Attribute("endDay", dateTab[2]); - period.setAttribute(endDay); - // Locked Period - if (periodDTO.isLocked()) { - Attribute locked = new Attribute("locked", "true"); - period.setAttribute(locked); - } else { - Attribute locked = new Attribute("locked", "false"); - period.setAttribute(locked); - } - - // TimeSpan - - // Recherche des timeSpans de la période - List<TimeSpanDTO> listTimeSpanDTO = periodDTO.getListTimeSpan(); - // Pour chaque timeSpan - for (TimeSpanDTO timeSpanDTO : listTimeSpanDTO) { - Element timeSpan = new Element("timespan"); - timeSpans.addContent(timeSpan); - // Identifiant timeSpan - Attribute idTimeSpan = new Attribute("id", timeSpanDTO.getId()); - timeSpan.setAttribute(idTimeSpan); - Attribute idPeriod = new Attribute("idPeriod", periodDTO - .getId()); - timeSpan.setAttribute(idPeriod); - // Begin TimeSpan - // Découpage date - dateTab = dateUtil.arrayDate(timeSpanDTO.getBeginTimeSpan()); - Attribute beginYearTimeSpan = new Attribute("beginYear", - dateTab[0]); - timeSpan.setAttribute(beginYearTimeSpan); - Attribute beginMonthTimeSpan = new Attribute("beginMonth", - dateTab[1]); - timeSpan.setAttribute(beginMonthTimeSpan); - Attribute beginDayTimeSpan = new Attribute("beginDay", - dateTab[2]); - timeSpan.setAttribute(beginDayTimeSpan); - // End TimeSpan - dateTab = dateUtil.arrayDate(timeSpanDTO.getEndTimeSpan()); - Attribute endYearTimeSpan = new Attribute("endYear", dateTab[0]); - timeSpan.setAttribute(endYearTimeSpan); - Attribute endMonthTimeSpan = new Attribute("endMonth", - dateTab[1]); - timeSpan.setAttribute(endMonthTimeSpan); - Attribute endDayTimeSpan = new Attribute("endDay", dateTab[2]); - timeSpan.setAttribute(endDayTimeSpan); - // Lock timeSpan - if (timeSpanDTO.isLocked()) { - Attribute locked = new Attribute("locked", "true"); - timeSpan.setAttribute(locked); - } else { - Attribute locked = new Attribute("locked", "false"); - timeSpan.setAttribute(locked); - } - } - } - - // Journal - - Element journals = new Element("journals"); - save.addContent(journals); - List<JournalDTO> listJournalDTO = journalServiceImpl.getAllJournal(); - for (JournalDTO journalDTO : listJournalDTO) { - Element journal = new Element("journal"); - journals.addContent(journal); - // Identification du journal - Attribute idJournal = new Attribute("id", journalDTO.getId()); - journal.setAttribute(idJournal); - // Label - Attribute label = new Attribute("label", journalDTO.getLabel()); - journal.setAttribute(label); - // Prefix - Attribute prefix = new Attribute("prefix", journalDTO.getPrefix()); - journal.setAttribute(prefix); - // Description - Attribute description = new Attribute("description", journalDTO - .getDescription()); - journal.setAttribute(description); - } - - // Account - - Element accounts = new Element("accounts"); - save.addContent(accounts); - List<AccountDTO> listAccountDTO = accountServiceImpl.getAllAccount(); - // Appel une fonction récursive pour parcourir l'arborescence des comptes - accountXML(listAccountDTO, accounts); - - // Transaction - Element transactions = new Element("transactions"); - save.addContent(transactions); - Element entries = new Element("entries"); - save.addContent(entries); - // Recherche de toutes les transactions - List<TransactionDTO> listTransactionDTO = transactionServiceImpl - .getAllTransactionDTO(); - // Pour chaque transaction - for (TransactionDTO transactionDTO : listTransactionDTO) { - Element transaction = new Element("transaction"); - transactions.addContent(transaction); - // Identification de la transaction - Attribute idTransaction = new Attribute("id", transactionDTO - .getId()); - transaction.setAttribute(idTransaction); - // EntryDate - String dateTab[] = dateUtil - .arrayDate(transactionDTO.getEntryDate()); - Attribute entryDateYear = new Attribute("entryDateYear", dateTab[0]); - transaction.setAttribute(entryDateYear); - Attribute entryDateMonth = new Attribute("entryDateMonth", - dateTab[1]); - transaction.setAttribute(entryDateMonth); - Attribute entryDateDay = new Attribute("entryDateDay", dateTab[2]); - transaction.setAttribute(entryDateDay); - // VoucherRef - Attribute voucherRef = new Attribute("voucherRef", transactionDTO - .getVoucherRef()); - transaction.setAttribute(voucherRef); - // Description - Attribute description = new Attribute("description", transactionDTO - .getDescription()); - transaction.setAttribute(description); - // Id journal - Attribute IdJournal = new Attribute("idJournal", transactionDTO - .getJournalDTO().getId()); - transaction.setAttribute(IdJournal); - // Id timeSpan - Attribute IdTimeSpan = new Attribute("idTimeSpan", transactionDTO - .getTimeSpanDTO().getId()); - transaction.setAttribute(IdTimeSpan); - - // Entry - List<EntryDTO> listEntryDTO = entryServiceImpl - .searchEntryDTOWithTransaction(transactionDTO); - for (EntryDTO entryDTO : listEntryDTO) { - Element entry = new Element("entry"); - entries.addContent(entry); - // Identification du entry - Attribute idEntry = new Attribute("id", entryDTO.getId()); - entry.setAttribute(idEntry); - // Description - Attribute descriptionEntry = new Attribute("description", - entryDTO.getDescription()); - entry.setAttribute(descriptionEntry); - // Amount - Attribute amount = new Attribute("amount", entryDTO.getAmount()); - entry.setAttribute(amount); - // Lettering - Attribute lettering = new Attribute("lettering", entryDTO - .getLettering()); - entry.setAttribute(lettering); - // Detail - Attribute detail = new Attribute("detail", entryDTO.getDetail()); - entry.setAttribute(detail); - // Debit / crédit - if (entryDTO.isDebit()) { - Attribute debit = new Attribute("debit", "true"); - entry.setAttribute(debit); - } else { - Attribute debit = new Attribute("debit", "false"); - entry.setAttribute(debit); - } - // Transaction - Attribute idrefTransaction = new Attribute("idTransaction", - transactionDTO.getId()); - entry.setAttribute(idrefTransaction); - // Account - Attribute idAccount = new Attribute("idAccount", entryDTO - .getAccountDTO().getId()); - entry.setAttribute(idAccount); - } - } - //affiche(); - enregistre(nameFile); - return ServiceHelper.RESPOND_SUCCESS;*/ - } - - /** - * Converti la liste des comptes pour être ajouté au document xml. - * @param listAccountDTO - * @param accounts - */ - protected void accountXML(List<Account> listAccount, Element accounts) { - /*for (AccountDTO accountDTO : listAccountDTO) { - Element account = new Element("account"); - accounts.addContent(account); - // Identification du account - Attribute idAccount = new Attribute("id", accountDTO.getId()); - account.setAttribute(idAccount); - // Label - Attribute label = new Attribute("label", accountDTO.getLabel()); - account.setAttribute(label); - // Type - Attribute type = new Attribute("type", accountDTO.getType()); - account.setAttribute(type); - // AccountNumber - Attribute accountNumber = new Attribute("accountNumber", accountDTO - .getAccountNumber()); - account.setAttribute(accountNumber); - // MasterAccountNumber - Attribute masterAccountNumber = new Attribute("masterAccount", - accountDTO.getMasterAccount()); - account.setAttribute(masterAccountNumber); - // Ajoute les comptes enfants à la liste - accountXML(accountDTO.getAccountChildDTO(), accounts); - }*/ - } - - // Affiche le fichier xml - /*static void affiche() { - try { - XMLOutputter sortie = new XMLOutputter(Format.getPrettyFormat()); - sortie.output(document, System.out); - } catch (java.io.IOException e) { - } - }*/ - - /** - * Permet d'enregistrer le fichier xml. - * @param fichier - */ - /*static void enregistre(String fichier) { - try { - XMLOutputter sortie = new XMLOutputter(Format.getPrettyFormat()); - sortie.output(document, new FileOutputStream(fichier)); - } catch (java.io.IOException e) { - } - }*/ - - /** - * Permet d'importer un fichier de données au format xml dans Callao. Si le - * fichier n'est pas disponible, il est alors renvoyé un message d'erreur. - * @param file - * @return - */ - public void importDatas(String file) { - /*if (log.isDebugEnabled()) { - log.debug("Load file XML : "); - } - String result = ServiceHelper.RESPOND_ERROR; - boolean existError = false; - - - // Chargement du fichier et construction du Dom - try { - // On crée une instance de SAXBuilder - SAXBuilder sxb = new SAXBuilder(); - document = sxb.build(file); - } catch (IOException e) { - log.error("Erreur lors de la lecture du fichier " + e.getMessage()); - e.printStackTrace(); - } catch (JDOMException e) { - log.error("Erreur lors de la construction du fichier JDOM " - + e.getMessage()); - e.printStackTrace(); - } - - - // Ecriture dans la base de données - try { - // Recherche de la racine - Element racine = document.getRootElement(); - - // Journal - XPath requeteXpath = XPath.newInstance("//journal"); - List results = requeteXpath.selectNodes(racine); - - Iterator iter = results.iterator(); - // Pour tous les journaux - while (iter.hasNext()) { - Element noeudCourant = (Element) iter.next(); - // Recherche attributs - String label = noeudCourant.getAttribute("label").getValue(); - String prefix = noeudCourant.getAttribute("prefix").getValue(); - String description = noeudCourant.getAttribute("description") - .getValue(); - // Création bdd - result = journalServiceImpl.createJournal(label, prefix, - description); - // Control erreur - if (result.equals(ServiceHelper.RESPOND_ERROR)) { - existError = true; - } - } - - // Account - requeteXpath = XPath.newInstance("//account"); - results = requeteXpath.selectNodes(racine); - - iter = results.iterator(); - // Pour tous les accounts - while (iter.hasNext()) { - Element noeudCourant = (Element) iter.next(); - // Recherche attributs - String label = noeudCourant.getAttribute("label").getValue(); - String accountNumber = noeudCourant.getAttribute( - "accountNumber").getValue(); - String masterAccount = noeudCourant.getAttribute( - "masterAccount").getValue(); - String typeAccount = noeudCourant.getAttribute("type") - .getValue(); - // Création bdd - result = accountServiceImpl.createAccount(accountNumber, label, - masterAccount, typeAccount); - // Control erreur - if (result.equals(ServiceHelper.RESPOND_ERROR)) { - existError = true; - } - } - - // Period - requeteXpath = XPath.newInstance("//period"); - results = requeteXpath.selectNodes(racine); - - iter = results.iterator(); - // Pour tous les periods - while (iter.hasNext()) { - Element noeudCourant = (Element) iter.next(); - // Recherche attributs - String idPeriod = noeudCourant.getAttribute("id").getValue(); - int year = Integer.parseInt(noeudCourant.getAttribute( - "beginYear").getValue()); - int month = Integer.parseInt(noeudCourant.getAttribute( - "beginMonth").getValue()); - int day = Integer.parseInt(noeudCourant - .getAttribute("beginDay").getValue()); - Date beginPeriod = new Date(year - 1900, month, day); - year = Integer.parseInt(noeudCourant.getAttribute("endYear") - .getValue()); - month = Integer.parseInt(noeudCourant.getAttribute("endMonth") - .getValue()); - day = Integer.parseInt(noeudCourant.getAttribute("endDay") - .getValue()); - Date endPeriod = new Date(year - 1900, month, day); - // Création bdd - result = periodServiceImpl.createPeriod(beginPeriod, endPeriod, - false); - // Control erreur - if (result.equals(ServiceHelper.RESPOND_ERROR)) { - existError = true; - } - - // Transaction - requeteXpath = XPath - .newInstance("//transaction[@idTimeSpan=//timespan[@idPeriod='" - + idPeriod + "']/@id]"); - List resultsTransaction = requeteXpath.selectNodes(racine); - Iterator iterTrans = resultsTransaction.iterator(); - // Pour tous les transactions - while (iterTrans.hasNext()) { - Element noeudCourantTrans = (Element) iterTrans.next(); - - // Recherche attributs - - // Id transaction XMl - String idTransactionXML = noeudCourantTrans.getAttribute( - "id").getValue(); - // Recherche du journal en DTO - String idJournal = noeudCourantTrans.getAttribute( - "idJournal").getValue(); - requeteXpath = XPath.newInstance("//journal[@id='" - + idJournal + "']/@label"); - String label = requeteXpath.valueOf(racine); - JournalDTO journalDTO = journalServiceImpl - .searchJournalDTOWithLabel(label); - // Recherche du timeSpan en DTO - String idtimeSpan = noeudCourantTrans.getAttribute( - "idTimeSpan").getValue(); - requeteXpath = XPath.newInstance("//timespan[@id='" - + idtimeSpan + "']/@beginYear"); - year = Integer.parseInt(requeteXpath.valueOf(racine)); - requeteXpath = XPath.newInstance("//timespan[@id='" - + idtimeSpan + "']/@beginMonth"); - month = Integer.parseInt(requeteXpath.valueOf(racine)); - requeteXpath = XPath.newInstance("//timespan[@id='" - + idtimeSpan + "']/@beginDay"); - day = Integer.parseInt(requeteXpath.valueOf(racine)); - Date beginTimeSpan = new Date(year - 1900, month, day); - TimeSpanDTO timeSpanDTO = timeSpanServiceImpl - .searchTimeSpanDTOByDate(beginTimeSpan); - - // Création de transaction DTO - TransactionDTO transactionDTO = new TransactionDTO(); - transactionDTO.setJournalDTO(journalDTO); - transactionDTO.setTimeSpanDTO(timeSpanDTO); - // entryDate - year = Integer.parseInt(noeudCourantTrans.getAttribute( - "entryDateYear").getValue()); - month = Integer.parseInt(noeudCourantTrans.getAttribute( - "entryDateMonth").getValue()); - day = Integer.parseInt(noeudCourantTrans.getAttribute( - "entryDateDay").getValue()); - Date entryDate = new Date(year - 1900, month, day); - transactionDTO.setEntryDate(entryDate); - // voucherRef - String voucherRef = noeudCourantTrans.getAttribute( - "voucherRef").getValue(); - transactionDTO.setVoucherRef(voucherRef); - // description - String description = noeudCourantTrans.getAttribute( - "description").getValue(); - transactionDTO.setDescription(description); - - // Création bdd - String idTransactionCallao = transactionServiceImpl - .createTransaction(transactionDTO); - - // Entry - requeteXpath = XPath.newInstance("//entry[@idTransaction='" - + idTransactionXML + "']"); - List resultsEntry = requeteXpath.selectNodes(racine); - - Iterator iterEntry = resultsEntry.iterator(); - // Pour tous les entries - while (iterEntry.hasNext()) { - Element noeudEntry = (Element) iterEntry.next(); - - // Recherche attributs - - // Transaction DTO - transactionDTO = transactionServiceImpl - .searchTransactionDTO(idTransactionCallao); - // Account DTO - String idAccount = noeudEntry.getAttribute("idAccount") - .getValue(); - requeteXpath = XPath.newInstance("//account[@id='" - + idAccount + "']/@accountNumber"); - String accountNumber = requeteXpath.valueOf(racine); - AccountDTO accountDTO = accountServiceImpl - .searchAccountDTO(accountNumber); - // Entry DTO - EntryDTO entryDTO = new EntryDTO(); - entryDTO.setAccountDTO(accountDTO); - entryDTO.setTransactionDTO(transactionDTO); - // Description - description = noeudEntry.getAttribute("description") - .getValue(); - entryDTO.setDescription(description); - // Amount - String amount = noeudEntry.getAttribute("amount") - .getValue(); - entryDTO.setAmount(amount); - // Debit - boolean debit = noeudEntry.getAttribute("debit") - .getValue().equals("true"); - entryDTO.setDebit(debit); - // Lettering - String lettering = noeudEntry.getAttribute("lettering") - .getValue(); - entryDTO.setLettering(lettering); - // Detail - String detail = noeudEntry.getAttribute("detail") - .getValue(); - entryDTO.setDetail(detail); - // Création bdd - result = transactionServiceImpl.addEntry(entryDTO); - // Control erreur - if (result.equals(ServiceHelper.RESPOND_ERROR)) { - existError = true; - } - } - } - - - // Bloquer Period - boolean lock = noeudCourant.getAttribute("locked").getValue() - .equals("true"); - // Si la période est bloquée - if (lock) { - // Bloque tous ses timeSpans - result = periodServiceImpl - .blockAllTimeSpanOfPeriod(periodServiceImpl - .searchPeriodWithDate(beginPeriod)); - // Control erreur - if (result.equals(ServiceHelper.RESPOND_ERROR)) { - existError = true; - } - // bloque la période - result = periodServiceImpl.blockPeriod(periodServiceImpl - .searchPeriodWithDate(beginPeriod)); - - } else { - // On regarde si il y a besoin de bloquer les timeSpans - requeteXpath = XPath.newInstance("//timespan[@idPeriod = '" - + idPeriod + "']"); - List resultsTimeSpan = requeteXpath.selectNodes(racine); - Iterator iterTimeSpan = resultsTimeSpan.iterator(); - // Pour tous les timeSpans - while (iterTimeSpan.hasNext()) { - Element noeudCourantTimeSpan = (Element) iterTimeSpan - .next(); - // Recherche attributs - year = Integer.parseInt(noeudCourantTimeSpan - .getAttribute("beginYear").getValue()); - month = Integer.parseInt(noeudCourantTimeSpan - .getAttribute("beginMonth").getValue()); - day = Integer.parseInt(noeudCourantTimeSpan - .getAttribute("beginDay").getValue()); - Date beginTimeSpan = new Date(year - 1900, month, day); - lock = noeudCourantTimeSpan.getAttribute("locked") - .getValue().equals("true"); - // Bloque le timeSpan - if (lock) { - timeSpanServiceImpl - .blockTimeSpan(timeSpanServiceImpl - .searchTimeSpanByDate(beginTimeSpan)); - } - // Control erreur - if (result.equals(ServiceHelper.RESPOND_ERROR)) { - existError = true; - } - } - } - - } - - } catch (JDOMException e) { - log.error("Erreur JDOM " + e.getMessage()); - e.printStackTrace(); - } - - // Détection des erreurs - if (!existError) { - result = ServiceHelper.RESPOND_SUCCESS; - } - return result;*/ - } - -} Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialStatementServiceImpl.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialStatementServiceImpl.java 2010-07-15 10:27:28 UTC (rev 2970) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialStatementServiceImpl.java 2010-07-16 16:05:21 UTC (rev 2971) @@ -22,13 +22,10 @@ import static org.nuiton.i18n.I18n._; import java.util.ArrayList; import java.util.Date; -import java.util.HashSet; import java.util.List; import java.util.StringTokenizer; - import javax.ejb.EJB; import javax.ejb.Stateless; - import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -169,9 +166,22 @@ finally { doFinally(transaction, log); } - } + @Override + public List<FinancialStatement> getAllFinancialStatements() throws LimaException { + TopiaContext transaction = null; + List<FinancialStatement> financialStatements = null; + try { + transaction = beginTransaction(); + FinancialStatementDAO financialStatementDAO = + LimaCallaoDAOHelper.getFinancialStatementDAO(transaction); + financialStatements = financialStatementDAO.findAll(); + } catch (TopiaException ex) { + doCatch(transaction, ex, log); + } + return financialStatements; + } @Override public List<FinancialStatement> getAllChildrenFinancialStatement(FinancialStatement financialStatement, List<FinancialStatement> result) throws LimaException, LimaBusinessException { 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 2010-07-15 10:27:28 UTC (rev 2970) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java 2010-07-16 16:05:21 UTC (rev 2971) @@ -24,6 +24,7 @@ import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; import java.util.Date; import java.util.HashMap; @@ -33,8 +34,6 @@ import java.util.TreeMap; import javax.ejb.EJB; import javax.ejb.Stateless; - -import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.beans.AccountEBP; @@ -163,6 +162,21 @@ strat.setType(EntryEBPImpl.class); //read header to set strategy mapping strat.setColumnMapping(csvReader.readNext()); + + //check if file have a good header + List<String> headAccount = new ArrayList<String>(); + headAccount.add("Journal"); + headAccount.add("Compte"); + headAccount.add("DatEcr"); + headAccount.add("Piece"); + headAccount.add("Libelle"); + headAccount.add("Debit"); + headAccount.add("Credit"); + headAccount.add("Lettre"); + if (!Arrays.asList(strat.getColumnMapping()).containsAll(headAccount)){ + throw new LimaBusinessException("ERROR : This file contains no entries"); + } + CsvToBean<EntryEBPImpl> csv = new CsvToBean<EntryEBPImpl>(); List<EntryEBPImpl> list = csv.parse(strat, csvReader); @@ -277,9 +291,18 @@ strat.setType(AccountEBPImpl.class); //read header to set strategy mapping strat.setColumnMapping(csvReader.readNext()); + + //check if file have a good header + List<String> headAccount = new ArrayList<String>(); + headAccount.add("Numero"); + headAccount.add("Intitule"); + if (!Arrays.asList(strat.getColumnMapping()).containsAll(headAccount)){ + throw new LimaBusinessException("ERROR : This file contains no account"); + } + CsvToBean<AccountEBPImpl> csv = new CsvToBean<AccountEBPImpl>(); List<AccountEBPImpl> list = csv.parse(strat, csvReader); - Collections.sort(list, new AccountEBPComparator()); + Collections.sort(list, new AccountEBPComparator()); AccountDAO accountDAO = LimaCallaoDAOHelper.getAccountDAO(topiaContext); for (AccountEBP accountEBP : list) { @@ -371,33 +394,33 @@ String[] nextLine = new String[1]; CSVReader csvReader = new CSVReader(new StringReader(datas), ';'); - while ((nextLine = csvReader.readNext()) != null) { ImportExportEntityEnum importExportEntityEnum = ImportExportEntityEnum.valueOfLabel(nextLine[0]); - - switch (importExportEntityEnum) { - case ACCOUNT: - result += importAccountsChartsCSV(nextLine, accounts, topiaContext); - break; - case ENTRYBOOK: - result += importEntryBooksChartCSV(nextLine, topiaContext); - break; - case FINANCIALSTATEMENT: - result += importFinancialsStatementChartCSV(nextLine, financialStatements, topiaContext); - break; - case FISCALPERIOD: - result += importFiscalPeriodCSV(nextLine, fiscalPeriods, topiaContext); - break; - case CLOSEDPERIODICENTRYBOOK: - importClosedPeriodicEntryBookCSV(nextLine, closedPeriodicEntryBooks, topiaContext); - break; - case FINANCIALTRANSACTION: - importFinancialTransactionsCSV(nextLine, financialTransactions, topiaContext); - break; - case ENTRY: - importEntriesCSV(nextLine, entries, topiaContext); - break; - } + if (importExportEntityEnum != null){ + switch (importExportEntityEnum) { + case ACCOUNT: + result += importAccountsChartsCSV(nextLine, accounts, topiaContext); + break; + case ENTRYBOOK: + result += importEntryBooksChartCSV(nextLine, topiaContext); + break; + case FINANCIALSTATEMENT: + result += importFinancialsStatementChartCSV(nextLine, financialStatements, topiaContext); + break; + case FISCALPERIOD: + result += importFiscalPeriodCSV(nextLine, fiscalPeriods, topiaContext); + break; + case CLOSEDPERIODICENTRYBOOK: + importClosedPeriodicEntryBookCSV(nextLine, closedPeriodicEntryBooks, topiaContext); + break; + case FINANCIALTRANSACTION: + importFinancialTransactionsCSV(nextLine, financialTransactions, topiaContext); + break; + case ENTRY: + importEntriesCSV(nextLine, entries, topiaContext); + break; + } + } } //create accounts Deleted: trunk/lima-business/src/test/java/org/chorem/lima/business/FilesServiceImplTest.java =================================================================== --- trunk/lima-business/src/test/java/org/chorem/lima/business/FilesServiceImplTest.java 2010-07-15 10:27:28 UTC (rev 2970) +++ trunk/lima-business/src/test/java/org/chorem/lima/business/FilesServiceImplTest.java 2010-07-16 16:05:21 UTC (rev 2971) @@ -1,63 +0,0 @@ -package org.chorem.lima.business; - -import org.apache.commons.logging.LogFactory; -import org.chorem.lima.business.ejb.FilesServiceImpl; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -/** - * Tests pour la gestion des comptes dans le plan comptable - * - * Vérification sur l'ajout, la modification et suppression d'un compte. - * Il existe également des tests sur des actions à partir de DTO. La classe - * AccountServiceImplTest possède une méthode upload qui, à partir d'un DTO, - * va mettre à jour automatiquement dans la base de données. - * - * @author Rémi Chapelet - */ -public class FilesServiceImplTest { - - /** log. */ - private static final org.apache.commons.logging.Log log = LogFactory - .getLog(FilesServiceImplTest.class); - - private static FilesServiceImpl instance; - - @BeforeClass - public static void setUpClass() throws Exception { - LimaConfig.getInstance(); - } - - /** - * On nettoie la base de données - * @throws java.lang.Exception - */ - @AfterClass - public static void tearDownClass() throws Exception { - - } - - @Before - public void setUp() { - //instance = new FilesServiceImpl(); - } - - public FilesServiceImplTest() { - } - - /** - * Permet de tester la sauvegarde en document xml. - * Il existe un fichier dtd externe : - * 'callao-service/src/main/resources/save-callao.dtd' - */ - @Test - public void fileTest() { - /* Création sauvegarde - String result = instance.exportDatas("/tmp/callao_save.xml"); - Assert.assertEquals(ServiceHelper.RESPOND_SUCCESS,result); - Chargement sauvegarde - instance.importDatas("/home/bombjack/save_big_lima");*/ - } - -} \ No newline at end of file Modified: trunk/lima-callao/src/main/xmi/accounting.zargo =================================================================== (Binary files differ) Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java 2010-07-15 10:27:28 UTC (rev 2970) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java 2010-07-16 16:05:21 UTC (rev 2971) @@ -291,6 +291,7 @@ MainView mainView = getUI(rootContext); AccountView accountView = new AccountView(mainView); mainView.showTab(_("lima.charts.account"), accountView); + accountView.getHandler().defaultAccountsChart(mainView); } /** * Show account tree table view to create or modify accounts @@ -303,6 +304,7 @@ MainView mainView = getUI(rootContext); EntryBookView entryBookView= new EntryBookView(mainView); mainView.showTab(_("lima.charts.entrybook"), entryBookView); + entryBookView.getHandler().defaultEntryBooks(mainView); } /** @@ -321,7 +323,8 @@ */ public void showFinancialPeriodView(JAXXContext rootContext) { MainView mainView = getUI(rootContext); - FinancialPeriodView financialPeriodView = new FinancialPeriodView(mainView); + FinancialPeriodView financialPeriodView = + new FinancialPeriodView(mainView); mainView.showTab(_("lima.charts.financialperiod"), financialPeriodView); } @@ -331,8 +334,10 @@ */ public void showFinancialStatementView(JAXXContext rootContext) { MainView mainView = getUI(rootContext); - FinancialStatementChartView financialStatementView = new FinancialStatementChartView(mainView); + FinancialStatementChartView financialStatementView = + new FinancialStatementChartView(mainView); mainView.showTab(_("lima.charts.financialstatement"), financialStatementView); + financialStatementView.getHandler().defaultFinancialStatementChart(mainView); } /** @@ -341,7 +346,8 @@ */ public void showAccountReports(JAXXContext rootContext) { MainView mainView = getUI(rootContext); - AccountsReportsView accountsReportsView = new AccountsReportsView(mainView); + AccountsReportsView accountsReportsView = + new AccountsReportsView(mainView); mainView.showTab(_("lima.reports.accounts"), accountsReportsView); } @@ -393,7 +399,7 @@ public void showImportExportView(JAXXContext rootContext, ImportExportEnum type) { MainView mainView = getUI(rootContext); ImportExport importExport = ImportExport.getInstance(mainView); - importExport.importExport(type); + importExport.importExport(type, ""); } public void showExportView(String type) { Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountView.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountView.jaxx 2010-07-15 10:27:28 UTC (rev 2970) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountView.jaxx 2010-07-16 16:05:21 UTC (rev 2971) @@ -22,7 +22,7 @@ <script> <![CDATA[ - //getHandler().init(); + ]]> </script> @@ -64,10 +64,4 @@ enabled="{isSelectedRow()}"/> </cell> </row> - <row> - <cell fill="horizontal"> - <JButton id="importexportButton" text="lima.common.importexport" - onActionPerformed="getHandler().importexportAccount()"/> - </cell> - </row> </Table> \ No newline at end of file Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java 2010-07-15 10:27:28 UTC (rev 2970) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java 2010-07-16 16:05:21 UTC (rev 2971) @@ -29,12 +29,12 @@ import org.chorem.lima.entity.Account; import org.chorem.lima.entity.AccountImpl; import org.chorem.lima.service.LimaServiceFactory; +import org.chorem.lima.ui.MainView; import org.chorem.lima.ui.account.AccountForm; import org.chorem.lima.ui.account.AccountView; import org.chorem.lima.ui.account.SubLedgerForm; import org.chorem.lima.ui.importexport.ImportExport; import org.chorem.lima.ui.importexport.ImportExportEnum; -import org.chorem.lima.ui.importexport.ImportExportForm; import org.chorem.lima.util.DialogHelper; import org.chorem.lima.util.ErrorHelper; import org.jdesktop.swingx.JXTreeTable; @@ -244,38 +244,32 @@ } } } - }; + } - public void importexportAccount(){ + public void defaultAccountsChart(MainView mainView){ - JXTreeTable accountsTreeTable = view.getAccountsTreeTable(); - AccountTreeTableModel accountsTreeTableModel = - (AccountTreeTableModel)accountsTreeTable.getTreeTableModel(); - - ImportExportForm importExportForm = new ImportExportForm(view); - importExportForm.setLocationRelativeTo(view); - importExportForm.setVisible(true); + try { + if (accountService.getAllAccounts().size() == 0){ + DefaultAccountsChartForm form = new DefaultAccountsChartForm(); + // + form.setLocationRelativeTo(mainView); + form.setVisible(true); - Object value = importExportForm.getRadioButtons().getSelectedValue(); - // if action confirmed - if (value != null){ - String mode = (String) value; - ImportExport importExport = ImportExport.getInstance(view); - - try { - if (mode.equals("import")){ - importExport.importExport(ImportExportEnum.LIMA_ACCOUNTCHARTS_IMPORT); - accountsTreeTableModel.refreshTree(); - } - else { - importExport.importExport(ImportExportEnum.LIMA_ACCOUNTCHARTS_EXPORT); - } - } catch (LimaException eee) { - if (log.isErrorEnabled()){ - log.error("Can't refresh tree", eee); + Object value = form.getRadioButtons().getSelectedValue(); + // if action confirmed + if (value != null){ + + DefaultAccountsChartEnum defaultAccountsChartEnum = + (DefaultAccountsChartEnum) value; + ImportExport importExport = ImportExport.getInstance(view); + importExport.importExport(ImportExportEnum.LIMA_ACCOUNTCHARTS_IMPORT, + defaultAccountsChartEnum.getFilePath()); } - DialogHelper.showMessageDialog(eee.getMessage()); } - } + } catch (LimaException eee) { + if (log.isErrorEnabled()) { + log.error("Can't get default accounts chart", eee); + } + } } } Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/DefaultAccountsChartEnum.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/DefaultAccountsChartEnum.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/DefaultAccountsChartEnum.java 2010-07-16 16:05:21 UTC (rev 2971) @@ -0,0 +1,16 @@ +package org.chorem.lima.ui.account; + +public enum DefaultAccountsChartEnum { + + IMPORT(""), SHORTENED(""), BASE(""), DEVELOPED(""); + + private final String filePath; + + private DefaultAccountsChartEnum(String filePath) { + this.filePath = filePath; + } + + public String getFilePath() { + return this.filePath; + } +} Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/DefaultAccountsChartForm.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/DefaultAccountsChartForm.jaxx (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/DefaultAccountsChartForm.jaxx 2010-07-16 16:05:21 UTC (rev 2971) @@ -0,0 +1,72 @@ +<!-- ##% Lima Swing + Copyright (C) 2008 - 2010 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 2 + 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, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + ##% --> + +<JDialog modal="true"> + + <jaxx.runtime.swing.JAXXButtonGroup id="radioButtons" javaBean='new JAXXButtonGroup()'/> + <Boolean id="addState" javaBean='true'/> + + <script> + <![CDATA[ + import org.chorem.lima.ui.account.DefaultAccountsChartEnum; + protected void performCancel() { + getRadioButtons().setSelectedValue(null); + dispose(); + } + ]]> + </script> + + <Table> + <row> + <cell><JLabel text='lima.charts.account.nothing' /></cell> + </row> + <row> + <cell> + <JRadioButton text='lima.charts.account.shortened' value='{DefaultAccountsChartEnum.SHORTENED}' buttonGroup="{getRadioButtons()}" + selected='true'/> + </cell> + </row> + <row> + <cell> + <JRadioButton text='lima.charts.account.base' value='{DefaultAccountsChartEnum.BASE}' buttonGroup="{getRadioButtons()}" + selected='true'/> + </cell> + </row> + <row> + <cell> + <JRadioButton text='lima.charts.account.developed' value='{DefaultAccountsChartEnum.DEVELOPED}' buttonGroup="{getRadioButtons()}" + selected='true'/> + </cell> + </row> + <row> + <cell> + <JRadioButton text='lima.importexport.import' value='{DefaultAccountsChartEnum.IMPORT}' buttonGroup="{getRadioButtons()}" + selected='true'/> + </cell> + </row> + <row> + <cell fill="none"> + <JButton text="lima.common.ok" onActionPerformed="dispose()"/> + </cell> + </row> + <row> + <cell fill="none"> + <JButton text="lima.common.cancel" onActionPerformed="performCancel()"/> + </cell> + </row> + </Table> +</JDialog> \ No newline at end of file Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/DefaultAccountsChartForm.jaxx ___________________________________________________________________ Added: svn:executable + * Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/DefaultEntryBooksEnum.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/DefaultEntryBooksEnum.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/DefaultEntryBooksEnum.java 2010-07-16 16:05:21 UTC (rev 2971) @@ -0,0 +1,16 @@ +package org.chorem.lima.ui.entrybook; + +public enum DefaultEntryBooksEnum { + + IMPORT(""), DEFAULT(""); + + private final String filePath; + + private DefaultEntryBooksEnum(String filePath) { + this.filePath = filePath; + } + + public String getFilePath() { + return this.filePath; + } +} Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/DefaultEntryBooksForm.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/DefaultEntryBooksForm.jaxx (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/DefaultEntryBooksForm.jaxx 2010-07-16 16:05:21 UTC (rev 2971) @@ -0,0 +1,51 @@ +<!-- ##% Lima Swing + Copyright (C) 2008 - 2010 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 2 + 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, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + ##% --> + +<JDialog modal="true"> + + <jaxx.runtime.swing.JAXXButtonGroup id="radioButtons" javaBean='new JAXXButtonGroup()'/> + <Boolean id="addState" javaBean='true'/> + + <script> + <![CDATA[ + import org.chorem.lima.ui.entrybook.DefaultEntryBooksEnum; + protected void performCancel() { + getRadioButtons().setSelectedValue(null); + dispose(); + } + ]]> + </script> + + <Table> + <row> + <cell> + <JRadioButton text='lima.charts.entrybook.default' value='{DefaultEntryBooksEnum.DEFAULT}' buttonGroup="{getRadioButtons()}" + selected='true'/> + </cell> + <cell> + <JRadioButton text='lima.charts.entrybook.import' value='{DefaultEntryBooksEnum.IMPORT}' buttonGroup="{getRadioButtons()}" + selected='true'/> + </cell> + <cell fill="none"> + <JButton text="lima.common.ok" onActionPerformed="dispose()"/> + </cell> + <cell fill="none"> + <JButton text="lima.common.cancel" onActionPerformed="performCancel()"/> + </cell> + </row> + </Table> +</JDialog> \ No newline at end of file Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/DefaultEntryBooksForm.jaxx ___________________________________________________________________ Added: svn:executable + * Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookView.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookView.jaxx 2010-07-15 10:27:28 UTC (rev 2970) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookView.jaxx 2010-07-16 16:05:21 UTC (rev 2971) @@ -23,6 +23,7 @@ <script> <![CDATA[ + import java.awt.Dimension; ]]> </script> @@ -57,10 +58,4 @@ onActionPerformed="getHandler().deleteEntryBook()"/> </cell> </row> - <row> - <cell fill="horizontal"> - <JButton id="importexportButton" text="lima.common.importexport" - onActionPerformed="getHandler().importexportEntryBook()"/> - </cell> - </row> </Table> \ No newline at end of file Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.java 2010-07-15 10:27:28 UTC (rev 2970) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.java 2010-07-16 16:05:21 UTC (rev 2971) @@ -22,12 +22,14 @@ import javax.swing.JOptionPane; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.chorem.lima.business.EntryBookService; import org.chorem.lima.business.LimaException; import org.chorem.lima.entity.EntryBook; import org.chorem.lima.entity.EntryBookImpl; +import org.chorem.lima.service.LimaServiceFactory; +import org.chorem.lima.ui.MainView; import org.chorem.lima.ui.importexport.ImportExport; import org.chorem.lima.ui.importexport.ImportExportEnum; -import org.chorem.lima.ui.importexport.ImportExportForm; import org.chorem.lima.util.DialogHelper; import org.jdesktop.swingx.JXTable; @@ -45,9 +47,12 @@ private static final Log log = LogFactory.getLog(EntryBookViewHandler.class); protected EntryBookView view; + + protected EntryBookService entryBookService; public EntryBookViewHandler(EntryBookView view) { this.view = view; + entryBookService = LimaServiceFactory.getInstance().getEntryBookService(); } public void addEntryBook() { @@ -139,29 +144,32 @@ } -public void importexportEntryBook(){ - - JXTable entryBookTable = view.getEntryBooksTable(); - EntryBookTableModel entryBookTableModel = - (EntryBookTableModel)entryBookTable.getModel(); - - ImportExportForm importExportForm = new ImportExportForm(view); - importExportForm.setLocationRelativeTo(view); - importExportForm.setVisible(true); + public void defaultEntryBooks(MainView mainView){ + + try { + if (entryBookService.getAllEntryBooks().size() == 0){ + + DefaultEntryBooksForm form = + new DefaultEntryBooksForm(); + form.setLocationRelativeTo(mainView); + form.setVisible(true); - Object value = importExportForm.getRadioButtons().getSelectedValue(); - // if action confirmed - if (value != null){ - String mode = (String) value; - ImportExport importExport = ImportExport.getInstance(view); - - if (mode.equals("import")){ - importExport.importExport(ImportExportEnum.LIMA_ENTRYBOOKS_IMPORT); - entryBookTableModel.refreshTable(); - } - else { - importExport.importExport(ImportExportEnum.LIMA_ENTRYBOOKS_EXPORT); + Object value = form.getRadioButtons().getSelectedValue(); + // if action confirmed + if (value != null){ + DefaultEntryBooksEnum defaultEntryBooksEnum = + (DefaultEntryBooksEnum) value; + ImportExport importExport = ImportExport.getInstance(view); + importExport.importExport(ImportExportEnum.LIMA_ENTRYBOOKS_IMPORT, + defaultEntryBooksEnum.getFilePath()); + } + } + } catch (LimaException eee) { + if (log.isErrorEnabled()) { + log.error("Can't get default accounts chart", eee); } } - } + } + } + Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/DefaultFinancialStatementChartForm.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/DefaultFinancialStatementChartForm.jaxx (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/DefaultFinancialStatementChartForm.jaxx 2010-07-16 16:05:21 UTC (rev 2971) @@ -0,0 +1,72 @@ +<!-- ##% Lima Swing + Copyright (C) 2008 - 2010 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 2 + 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, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + ##% --> + +<JDialog modal="true"> + + <jaxx.runtime.swing.JAXXButtonGroup id="radioButtons" javaBean='new JAXXButtonGroup()'/> + <Boolean id="addState" javaBean='true'/> + + <script> + <![CDATA[ + import org.chorem.lima.ui.financialstatementchart.DefaultFinancialStatementsEnum; + protected void performCancel() { + getRadioButtons().setSelectedValue(null); + dispose(); + } + ]]> + </script> + + <Table> + <row> + <cell><JLabel text='lima.charts.financialstatement.nothing' /></cell> + </row> + <row> + <cell> + <JRadioButton text='lima.charts.financialstatement.shortened' value='{DefaultFinancialStatementsEnum.SHORTENED}' buttonGroup="{getRadioButtons()}" + selected='true'/> + </cell> + </row> + <row> + <cell> + <JRadioButton text='lima.charts.financialstatement.base' value='{DefaultFinancialStatementsEnum.BASE}' buttonGroup="{getRadioButtons()}" + selected='true'/> + </cell> + </row> + <row> + <cell> + <JRadioButton text='lima.charts.financialstatement.developed' value='{DefaultFinancialStatementsEnum.DEVELOPED}' buttonGroup="{getRadioButtons()}" + selected='true'/> + </cell> + </row> + <row> + <cell> + <JRadioButton text='lima.importexport.import' value='{DefaultFinancialStatementsEnum.IMPORT}' buttonGroup="{getRadioButtons()}" + selected='true'/> + </cell> + </row> + <row> + <cell fill="none"> + <JButton text="lima.common.ok" onActionPerformed="dispose()"/> + </cell> + </row> + <row> + <cell fill="none"> + <JButton text="lima.common.cancel" onActionPerformed="performCancel()"/> + </cell> + </row> + </Table> +</JDialog> \ No newline at end of file Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/DefaultFinancialStatementChartForm.jaxx ___________________________________________________________________ Added: svn:executable + * Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/DefaultFinancialStatementsEnum.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/DefaultFinancialStatementsEnum.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/DefaultFinancialStatementsEnum.java 2010-07-16 16:05:21 UTC (rev 2971) @@ -0,0 +1,16 @@ +package org.chorem.lima.ui.financialstatementchart; + +public enum DefaultFinancialStatementsEnum { + + IMPORT(""), SHORTENED(""), BASE(""), DEVELOPED(""); + + private final String filePath; + + private DefaultFinancialStatementsEnum(String filePath) { + this.filePath = filePath; + } + + public String getFilePath() { + return this.filePath; + } +} Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartView.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartView.jaxx 2010-07-15 10:27:28 UTC (rev 2970) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartView.jaxx 2010-07-16 16:05:21 UTC (rev 2971) @@ -64,10 +64,4 @@ enabled="{isSelectedRow()}"/> </cell> </row> - <row> - <cell fill="horizontal"> - <JButton id="importexportButton" text="lima.common.importexport" - onActionPerformed="getHandler().importexportFinancialStatement()"/> - </cell> - </row> </Table> \ No newline at end of file Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartViewHandler.java 2010-07-15 10:27:28 UTC (rev 2970) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartViewHandler.java 2010-07-16 16:05:21 UTC (rev 2971) @@ -23,15 +23,17 @@ import javax.swing.tree.TreePath; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.chorem.lima.business.FinancialStatementService; import org.chorem.lima.business.LimaBusinessException; import org.chorem.lima.business.LimaException; import org.chorem.lima.entity.FinancialStatement; import org.chorem.lima.entity.FinancialStatementImpl; +import org.chorem.lima.service.LimaServiceFactory; +import org.chorem.lima.ui.MainView; import org.chorem.lima.ui.financialstatementchart.FinancialStatementHeaderForm; import org.chorem.lima.ui.financialstatementchart.FinancialStatementMovementForm; import org.chorem.lima.ui.importexport.ImportExport; import org.chorem.lima.ui.importexport.ImportExportEnum; -import org.chorem.lima.ui.importexport.ImportExportForm; import org.chorem.lima.util.DialogHelper; import org.chorem.lima.util.ErrorHelper; import org.jdesktop.swingx.JXTreeTable; @@ -50,10 +52,13 @@ /** log. */ private static final Log log = LogFactory.getLog(FinancialStatementChartViewHandler.class); + protected FinancialStatementService financialStatementService; + protected FinancialStatementChartView view; protected FinancialStatementChartViewHandler(FinancialStatementChartView view) { this.view = view; + financialStatementService = LimaServiceFactory.getInstance().getFinancialStatementService(); } /** @@ -247,24 +252,31 @@ } } - public void importexportFinancialStatement(){ - - ImportExportForm importExportForm = new ImportExportForm(view); - importExportForm.setLocationRelativeTo(view); - importExportForm.setVisible(true); + + public void defaultFinancialStatementChart(MainView mainView){ + + try { + if (financialStatementService.getAllFinancialStatements().size() == 0){ + DefaultFinancialStatementChartForm form = + new DefaultFinancialStatementChartForm(); + form.setLocationRelativeTo(mainView); + form.setVisible(true); - Object value = importExportForm.getRadioButtons().getSelectedValue(); - // if action confirmed - if (value != null){ - String mode = (String) value; - ImportExport importExport = ImportExport.getInstance(view); - if (mode.equals("import")){ - importExport.importExport(ImportExportEnum.LIMA_FINANCIALSTATEMENTS_IMPORT); - } - else { - importExport.importExport(ImportExportEnum.LIMA_FINANCIALSTATEMENTS_EXPORT); - } - } + Object value = form.getRadioButtons().getSelectedValue(); + // if action confirmed + if (value != null){ + DefaultFinancialStatementsEnum defaultFinancialStatementsEnum = + (DefaultFinancialStatementsEnum) value; + ImportExport importExport = ImportExport.getInstance(view); + importExport.importExport(ImportExportEnum.LIMA_FINANCIALSTATEMENTS_IMPORT, + defaultFinancialStatementsEnum.getFilePath()); + } + } + } catch (LimaException eee) { + if (log.isErrorEnabled()) { + log.error("Can't get default accounts chart", eee); + } + } } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/HomeViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/HomeViewHandler.java 2010-07-15 10:27:28 UTC (rev 2970) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/HomeViewHandler.java 2010-07-16 16:05:21 UTC (rev 2971) @@ -6,6 +6,7 @@ import javax.swing.JEditorPane; import javax.swing.event.HyperlinkEvent; import javax.swing.event.HyperlinkListener; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.LimaContext; @@ -21,32 +22,30 @@ import org.chorem.lima.service.LimaServiceFactory; import org.chorem.lima.ui.MainView; + public class HomeViewHandler implements HyperlinkListener { private static final Log log = LogFactory.getLog(HomeViewHandler.class); - private HomeView view; - + protected HomeView view; + + /* Services */ protected AccountService accountService; - protected EntryBookService entryBookService; - protected FinancialTransactionService financialTransactionService; - protected FiscalPeriodService fiscalPeriodService; - protected HyperlinkListener accountsListener; + /* Editorpane*/ + protected JEditorPane accountPane; + protected JEditorPane entryBookPane; + protected JEditorPane fiscalYearPane; + protected JEditorPane dailyPane; - protected HyperlinkListener entrybookListener; - private static Color redBackground = new Color(0xff, 0xee, 0xee); - protected HomeViewHandler(HomeView view) { - - + protected HomeViewHandler(HomeView view) { this.view=view; - accountService = LimaServiceFactory.getInstance().getAccountService(); entryBookService = @@ -59,11 +58,25 @@ } + public void setEditorPanes() { + //Get all editorpanes + accountPane = view.getTextHomeAccount(); + entryBookPane = view.getTextHomeEntryBook(); + fiscalYearPane = view.getTextHomeFiscalYear(); + dailyPane = view.getTextHomeDaily(); + + //add hyperlink listener + accountPane.addHyperlinkListener(this); + entryBookPane.addHyperlinkListener(this); + fiscalYearPane.addHyperlinkListener(this); + dailyPane.addHyperlinkListener(this); + } + + + @Override public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { - - log.debug(e.getDescription()); if (e.getDescription().equals("#accountschart")) { MainView ui = LimaContext.MAIN_UI_ENTRY_DEF.getContextValue(view); @@ -90,19 +103,12 @@ } - public void refresh(){ - //Get all editorpanes - JEditorPane accountPane = view.getTextHomeAccount(); - JEditorPane entryBookPane = view.getTextHomeEntryBook(); - JEditorPane fiscalYearPane = view.getTextHomeFiscalYear(); - JEditorPane dailyPane = view.getTextHomeDaily(); - - //add hyperlink listener - accountPane.addHyperlinkListener(this); - entryBookPane.addHyperlinkListener(this); - fiscalYearPane.addHyperlinkListener(this); - dailyPane.addHyperlinkListener(this); + + if (accountPane ==null){ + setEditorPanes(); + } + String htmlBegin = "<font face='sans-serif' size=3>" + "<p style=vertical-align:'bottom', horizontal-align:'center'>"; String htmlEnd = "</p></font>"; @@ -128,7 +134,6 @@ accountPane.setText(htmlBegin + accountsString + htmlEnd); } - //ENTRYBOOKS List<EntryBook> entryBooks = entryBookService.getAllEntryBooks(); int ebSize = entryBooks.size(); 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 2010-07-15 10:27:28 UTC (rev 2970) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExport.java 2010-07-16 16:05:21 UTC (rev 2971) @@ -20,8 +20,8 @@ package org.chorem.lima.ui.importexport; import static org.nuiton.i18n.I18n._; +import java.awt.Color; import java.awt.Component; -import java.io.BufferedInputStream; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; @@ -30,7 +30,9 @@ import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; +import java.util.concurrent.ExecutionException; import javax.swing.JFileChooser; +import javax.swing.SwingWorker; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.business.ExportService; @@ -40,6 +42,7 @@ import org.chorem.lima.ui.account.AccountViewHandler; import org.chorem.lima.util.DialogHelper; import org.chorem.lima.util.FileChooseView; +import org.jdesktop.swingx.painter.BusyPainter; public class ImportExport { @@ -52,109 +55,131 @@ protected ImportService importService; protected ExportService exportService; + + private ImportExportWaitView waitView; public ImportExport(Component view) { viewComponent=view; importService = LimaServiceFactory.getInstance().getImportService(); exportService = LimaServiceFactory.getInstance().getExportService(); + //create the wait dialog panel + waitView = new ImportExportWaitView(); + waitView.waitDialog.setSize(400, 200); + waitView.setLocationRelativeTo(view); + BusyPainter busyPainter = waitView.getBusylabel().getBusyPainter(); + busyPainter.setHighlightColor(new Color(44, 61, 146).darker()); + busyPainter.setBaseColor(new Color(168, 204, 241).brighter()); } - - - public void importExport(ImportExportEnum importExportMethode){ - String result = ""; - String datas = ""; - String filePath = ""; - String charset = "UTF-8"; - try { - switch (importExportMethode) { - case LIMA_ALL_EXPORT: - filePath = chooseFile(false); - datas = exportService.exportAsCSV(); - createFile(filePath, charset, datas); - break; - case LIMA_ACCOUNTCHARTS_EXPORT: - filePath = chooseFile(false); - datas = exportService.exportAccountsChartAsCSV(); - createFile(filePath, charset, datas); - break; - case LIMA_ENTRYBOOKS_EXPORT: - filePath = chooseFile(false); - datas = exportService.exportEntryBookChartAsCSV(); - createFile(filePath, charset, datas); - break; - case LIMA_FINANCIALSTATEMENTS_EXPORT: - filePath = chooseFile(false); - datas = exportService.exportFinancialStatementChartAsCSV(); - createFile(filePath, charset, datas); - break; - case EBP_ACCOUNTCHARTS_EXPORT: - //For windows ebp - filePath = chooseFile(false); - charset = "ISO-8859-1"; - datas = exportService.exportAccountsAsEBP(); - createFile(filePath, charset, datas); - break; - case EBP_ENTRIES_EXPORT: - //For windows ebp - charset = "ISO-8859-1"; - filePath = chooseFile(false); - datas = exportService.exportEntriesAsEBP(); - createFile(filePath, charset, datas); - break; - case LIMA_ALL_IMPORT: - filePath = chooseFile(true); - datas = extractFile(filePath, charset); - result = importService.importCSV(datas); - break; - case LIMA_ACCOUNTCHARTS_IMPORT: - filePath = chooseFile(true); - datas = extractFile(filePath, charset); - result = importService.importAccountsChartAsCSV(datas); - break; - case LIMA_ENTRYBOOKS_IMPORT: - filePath = chooseFile(true); - datas = extractFile(filePath, charset); - result = importService.importEntryBooksChartAsCSV(datas); - break; - case LIMA_FINANCIALSTATEMENTS_IMPORT: - filePath = chooseFile(true); - datas = extractFile(filePath, charset); - result = importService.importFinancialStatementsChartAsCSV(datas); - break; - case EBP_ACCOUNTCHARTS_IMPORT: - //For windows ebp - charset = "ISO-8859-1"; - filePath = chooseFile(true); - datas = extractFile(filePath, charset); - result = importService.importAccountsChartFromEbp(datas); - break; - case EBP_ENTRIES_IMPORT: - //For windows ebp - charset = "ISO-8859-1"; - filePath = chooseFile(true); - datas = extractFile(filePath, charset); - result = importService.importEntriesFromEbp(datas); - break; - } - if (!result.equals("")){ - DialogHelper.showReportDialog(result, _("lima.importexport.import"), viewComponent); - } - else { - DialogHelper.showMessageDialog(_("lima.importexport.import.terminated")); - } - } - catch (LimaException eee) { - if (log.isDebugEnabled()){ - log.debug("Can't call export import service ", eee); - DialogHelper.showMessageDialog(eee.getMessage()); - } - } - - + + /** + * Call the appropriate methode in business service + * @param importExportMethode + */ + public void importExport(ImportExportEnum importExportMethode, String file){ + final ImportExportEnum importExportMethodeF = importExportMethode; + if (file.equals("")){ + file = chooseFile(importExportMethode.getImportMode()); + } + final String filePath = file; + new SwingWorker<String,Void>() { + @Override protected String doInBackground() throws LimaException { + String charset = "UTF-8"; + String datas = ""; + String result = ""; + switch (importExportMethodeF) { + case LIMA_ALL_EXPORT: + datas = exportService.exportAsCSV(); + createFile(filePath, charset, datas); + break; + case LIMA_ACCOUNTCHARTS_EXPORT: + datas = exportService.exportAccountsChartAsCSV(); + createFile(filePath, charset, datas); + break; + case LIMA_ENTRYBOOKS_EXPORT: + datas = exportService.exportEntryBookChartAsCSV(); + createFile(filePath, charset, datas); + break; + case LIMA_FINANCIALSTATEMENTS_EXPORT: + datas = exportService.exportFinancialStatementChartAsCSV(); + createFile(filePath, charset, datas); + break; + case EBP_ACCOUNTCHARTS_EXPORT: + //For windows ebp + charset = "ISO-8859-1"; + datas = exportService.exportAccountsAsEBP(); + createFile(filePath, charset, datas); + break; + case EBP_ENTRIES_EXPORT: + //For windows ebp + charset = "ISO-8859-1"; + datas = exportService.exportEntriesAsEBP(); + createFile(filePath, charset, datas); + break; + case LIMA_ALL_IMPORT: + datas = extractFile(filePath, charset); + result = importService.importCSV(datas); + break; + case LIMA_ACCOUNTCHARTS_IMPORT: + datas = extractFile(filePath, charset); + result = importService.importAccountsChartAsCSV(datas); + break; + case LIMA_ENTRYBOOKS_IMPORT: + datas = extractFile(filePath, charset); + result = importService.importEntryBooksChartAsCSV(datas); + break; + case LIMA_FINANCIALSTATEMENTS_IMPORT: + datas = extractFile(filePath, charset); + result = importService.importFinancialStatementsChartAsCSV(datas); + break; + case EBP_ACCOUNTCHARTS_IMPORT: + //For windows ebp + charset = "ISO-8859-1"; + datas = extractFile(filePath, charset); + result = importService.importAccountsChartFromEbp(datas); + break; + case EBP_ENTRIES_IMPORT: + //For windows ebp + charset = "ISO-8859-1"; + datas = extractFile(filePath, charset); + result = importService.importEntriesFromEbp(datas); + break; + } + return result; + } + @Override protected void done() { + try { + //hidde wait dialog panel + waitView.setVisible(false); + // display result dialog + String result = get(); + if (!result.equals("")){ + DialogHelper.showReportDialog(result, _("lima.importexport.import"), viewComponent); + } + else { + DialogHelper.showMessageDialog(_("lima.importexport.import.terminated")); + } + } catch (InterruptedException eeeIE) { + if (log.isDebugEnabled()){ + log.debug("Can't get result message", eeeIE); + } + } catch (ExecutionException eeeEE) { + if (log.isDebugEnabled()){ + log.debug("Can't get result message", eeeEE); + } + } + } + }.execute(); + waitView.setVisible(true); + //TODO refresh the view } - + /** + * open choose file dialog with appropriate file mode view + * folders for export or folders+files for import + * @param importMode + * @return + */ public String chooseFile(Boolean importMode){ String filePath = ""; FileChooseView fileChooseView = new FileChooseView(); @@ -176,7 +201,6 @@ } - /** * Get csv datas in string and write file * @@ -197,7 +221,6 @@ } - /** * Open csv file and get his datas on a string * @@ -218,7 +241,6 @@ } - public static ImportExport getInstance(Component view) { if (exchanger == null) { exchanger = new ImportExport(view); Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExportEnum.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExportEnum.java 2010-07-15 10:27:28 UTC (rev 2970) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExportEnum.java 2010-07-16 16:05:21 UTC (rev 2971) @@ -1,9 +1,24 @@ package org.chorem.lima.ui.importexport; + +/** + * Boolean importMode define if it's a import (true) or an export (false) + * + */ public enum ImportExportEnum { - LIMA_ALL_EXPORT, LIMA_ALL_IMPORT, - LIMA_ACCOUNTCHARTS_EXPORT, LIMA_ENTRYBOOKS_EXPORT, LIMA_FINANCIALSTATEMENTS_EXPORT, - LIMA_ACCOUNTCHARTS_IMPORT, LIMA_ENTRYBOOKS_IMPORT, LIMA_FINANCIALSTATEMENTS_IMPORT, - EBP_ACCOUNTCHARTS_EXPORT, EBP_ENTRIES_EXPORT, - EBP_ACCOUNTCHARTS_IMPORT, EBP_ENTRIES_IMPORT; + LIMA_ALL_EXPORT(false), LIMA_ALL_IMPORT(true), + LIMA_ACCOUNTCHARTS_EXPORT(false), LIMA_ENTRYBOOKS_EXPORT(false), LIMA_FINANCIALSTATEMENTS_EXPORT(false), + LIMA_ACCOUNTCHARTS_IMPORT(true), LIMA_ENTRYBOOKS_IMPORT(true), LIMA_FINANCIALSTATEMENTS_IMPORT(true), + EBP_ACCOUNTCHARTS_EXPORT(false), EBP_ENTRIES_EXPORT(false), + EBP_ACCOUNTCHARTS_IMPORT(true), EBP_ENTRIES_IMPORT(true); + + private final Boolean importMode; + + private ImportExportEnum(Boolean importMode) { + this.importMode = importMode; + } + + public Boolean getImportMode() { + return this.importMode; + } } Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExportWaitView.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExportWaitView.jaxx (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExportWaitView.jaxx 2010-07-16 16:05:21 UTC (rev 2971) @@ -0,0 +1,36 @@ +<!-- ##% Lima Swing + Copyright (C) 2008 - 2010 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 2 + 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, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + ##% --> + +<JDialog id="waitDialog"> + + <script> + <![CDATA[ + + ]]> + </script> + + <Table> + <row> + <cell> + <org.jdesktop.swingx.JXBusyLabel id='busylabel' busy='true'/> + </cell> + <cell> + <JLabel text='lima.importexport.wait'/> + </cell> + </row> + </Table> +</JDialog> \ No newline at end of file Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExportWaitView.jaxx ___________________________________________________________________ Added: svn:executable + * 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 2010-07-15 10:27:28 UTC (rev 2970) +++ trunk/lima-swing/src/main/resources/i18n/lima-swing-en_GB.properties 2010-07-16 16:05:21 UTC (rev 2971) @@ -25,9 +25,19 @@ lima.amountcredit= lima.amountdebit= lima.charts.account=Accounts chart +lima.charts.account.base= +lima.charts.account.developed= +lima.charts.account.nothing= +lima.charts.account.shortened= lima.charts.entrybook=EntryBooks chart +lima.charts.entrybook.default= +lima.charts.entrybook.import= lima.charts.financialperiod=Financial Periods lima.charts.financialstatement= +lima.charts.financialstatement.base= +lima.charts.financialstatement.developed= +lima.charts.financialstatement.nothing= +lima.charts.financialstatement.shortened= lima.charts.fiscalyear=Fiscal Years lima.close=Closed lima.common.add= @@ -104,6 +114,7 @@ lima.importexport.import=Import lima.importexport.import.terminated= lima.importexport.lima= +lima.importexport.wait= lima.init.closed=Lima closed at %1$s lima.init.errorclosing= lima.lettering.add= 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 2010-07-15 10:27:28 UTC (rev 2970) +++ trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties 2010-07-16 16:05:21 UTC (rev 2971) @@ -25,9 +25,19 @@ lima.amountcredit=Total Cr\u00E9dit lima.amountdebit=Total D\u00E9bit lima.charts.account=Plan comptable +lima.charts.account.base=Plan comptable de base +lima.charts.account.developed=Plan comptable d\u00E9velopp\u00E9 +lima.charts.account.nothing=<html><center>Aucun plan comptable charg\u00E9<br/>Veuillez s\u00E9lectionner un plan par d\u00E9fault, <br/>importer un plan personnalis\u00E9<br/> ou annuler pour cr\u00E9er votre propre plan.</center></html> +lima.charts.account.shortened=Plan comptable abr\u00E9g\u00E9 lima.charts.entrybook=Journaux +lima.charts.entrybook.default=Journaux par d\u00E9fault +lima.charts.entrybook.import=Importer des journaux lima.charts.financialperiod=P\u00E9riodes comptables lima.charts.financialstatement=Plan BCR +lima.charts.financialstatement.base=Plan BCR de base +lima.charts.financialstatement.developed=Plan BCR d\u00E9velopp\u00E9 +lima.charts.financialstatement.nothing=<html><center>Aucun plan BCR charg\u00E9<br/>Veuillez s\u00E9lectionner un plan par d\u00E9fault, <br/>importer un plan personnalis\u00E9<br/> ou annuler pour cr\u00E9er votre propre plan.</center></html> +lima.charts.financialstatement.shortened=Plan BCR abr\u00E9g\u00E9 lima.charts.fiscalyear=Exercices lima.close=Ferm\u00E9 lima.common.add=Ajout Compte G\u00E9n\u00E9ral @@ -104,6 +114,7 @@ lima.importexport.import=Import lima.importexport.import.terminated=Import termin\u00E9 lima.importexport.lima=Import/Export Lima +lima.importexport.wait=Traitement en cours \u2026 lima.init.closed=Lima ferm\u00E9 \u00E0 %1$s lima.init.errorclosing= lima.lettering.add=Ajouter une lettre Deleted: trunk/lima-swing/src/main/resources/import/default_pcg.xml =================================================================== --- trunk/lima-swing/src/main/resources/import/default_pcg.xml 2010-07-15 10:27:28 UTC (rev 2970) +++ trunk/lima-swing/src/main/resources/import/default_pcg.xml 2010-07-16 16:05:21 UTC (rev 2971) @@ -1,45 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<Callao> - <informations date="Fri Aug 07 11:35:27 CEST 2009" user="Name user" company="Name company" /> - <save> - <accounts> - <account id="org.chorem.callao.entity.Account#1249555347959#0.9019304796412684" label="COMPTES D'IMMOBILISATIONS" type="actif" accountNumber="2" masterAccount="0" /> - <account id="org.chorem.callao.entity.Account#1249555348338#0.04260276658110562" label="Frais d'établissement" type="Actif" accountNumber="201" masterAccount="2" /> - <account id="org.chorem.callao.entity.Account#1249555348347#0.18726180615226806" label="Droit au bail" type="Actif" accountNumber="206" masterAccount="2" /> - <account id="org.chorem.callao.entity.Account#1249555497020#0.6505535213374983" label="Immobilisations corporelles" type="Actif" accountNumber="21" masterAccount="2" /> - <account id="org.chorem.callao.entity.Account#1249555618637#0.47602527280737383" label="Autres immobilisations corporelles" type="Actif" accountNumber="218" masterAccount="21" /> - <account id="org.chorem.callao.entity.Account#1249555347984#0.4908833205081513" label="COMPTES DE STOCKS ET EN-COURS" type="actif" accountNumber="3" masterAccount="0" /> - <account id="org.chorem.callao.entity.Account#1249555347993#0.01567348299581306" label="COMPTES DE TIERS" type="actif" accountNumber="4" masterAccount="0" /> - <account id="org.chorem.callao.entity.Account#1249555822435#0.06041671027235429" label="Fournisseurs" type="Passif" accountNumber="401" masterAccount="4" /> - <account id="org.chorem.callao.entity.Account#1249555583700#0.6265947943023162" label="Clients" type="Actif" accountNumber="411" masterAccount="4" /> - <account id="org.chorem.callao.entity.Account#1249555348000#0.6004750737819512" label="COMPTES FINANCIERS" type="actif" accountNumber="5" masterAccount="0" /> - <account id="org.chorem.callao.entity.Account#1249555511423#0.011319837765867757" label="Caisse" type="Actif" accountNumber="53" masterAccount="5" /> - <account id="org.chorem.callao.entity.Account#1249555348022#0.930622399756405" label="COMPTES DE CHARGES" type="actif" accountNumber="6" masterAccount="0" /> - <account id="org.chorem.callao.entity.Account#1249555348378#0.8374727763221947" label="ACHATS" type="Charge" accountNumber="60" masterAccount="6" /> - <account id="org.chorem.callao.entity.Account#1249555548999#0.018490025064101023" label="Achas de marchandises" type="Charge" accountNumber="607" masterAccount="60" /> - <account id="org.chorem.callao.entity.Account#1249555636400#0.5473094310405552" label="Impôts, taxes et versements assimilés" type="Charge" accountNumber="63" masterAccount="6" /> - <account id="org.chorem.callao.entity.Account#1249555657935#0.35366073929481334" label="Charges de personnel" type="Charge" accountNumber="64" masterAccount="6" /> - <account id="org.chorem.callao.entity.Account#1249555348027#0.6782322672056709" label="COMPTES DE PRODUITS" type="actif" accountNumber="7" masterAccount="0" /> - <account id="org.chorem.callao.entity.Account#1249555599917#0.5953808167367928" label="Ventes de marchandises" type="Produit" accountNumber="707" masterAccount="7" /> - <account id="org.chorem.callao.entity.Account#1249555348076#0.6190508684748437" label="COMPTES SPECIAUX" type="actif" accountNumber="8" masterAccount="0" /> - <account id="org.chorem.callao.entity.Account#1249555347952#0.9924023380704713" label="COMPTES DE CAPITAUX" type="Passif" accountNumber="1" masterAccount="0" /> - <account id="org.chorem.callao.entity.Account#1249555348157#0.3681372547493901" label="Ecarts de réévaluation" type="Passif" accountNumber="105" masterAccount="1" /> - <account id="org.chorem.callao.entity.Account#1249555348211#0.8970560365362152" label="Ecarts de réévaluation" type="actif" accountNumber="10500000" masterAccount="105" /> - <account id="org.chorem.callao.entity.Account#1249555348169#0.21975217717147555" label="Réserves" type="Passif" accountNumber="106" masterAccount="1" /> - <account id="org.chorem.callao.entity.Account#1249555348221#0.20073728197870266" label="Réserve légale" type="actif" accountNumber="1061" masterAccount="106" /> - <account id="org.chorem.callao.entity.Account#1249555348269#0.3388466646762297" label="Réserve légale" type="actif" accountNumber="10610000" masterAccount="1061" /> - <account id="org.chorem.callao.entity.Account#1249555348301#0.09087057997481063" label="réserve légale" type="actif" accountNumber="10611000" masterAccount="1061" /> - <account id="org.chorem.callao.entity.Account#1249555348230#0.6918799658776698" label="Réserves indisponibles" type="actif" accountNumber="1062" masterAccount="106" /> - <account id="org.chorem.callao.entity.Account#1249555348308#0.6217734109884933" label="Réserves indisponibles" type="actif" accountNumber="10620000" masterAccount="1062" /> - <account id="org.chorem.callao.entity.Account#1249555348244#0.009767392197928992" label="Réserves statutaires ou contractuelles" type="actif" accountNumber="1063" masterAccount="106" /> - <account id="org.chorem.callao.entity.Account#1249555348315#0.8177617600611057" label="Réserves statutaires ou contractuelles" type="actif" accountNumber="10630000" masterAccount="1063" /> - <account id="org.chorem.callao.entity.Account#1249555348253#0.7582011362212686" label="Réserves réglementes" type="actif" accountNumber="1064" masterAccount="106" /> - <account id="org.chorem.callao.entity.Account#1249555348329#0.8489995807518893" label="Réserves réglementes" type="acif" accountNumber="10640000" masterAccount="1064" /> - <account id="org.chorem.callao.entity.Account#1249555348262#0.4019019740691401" label="Autres réserves" type="actif" accountNumber="1068" masterAccount="106" /> - <account id="org.chorem.callao.entity.Account#1249555348140#0.7846696113518526" label="Capital" type="Passif" accountNumber="101" masterAccount="1" /> - <account id="org.chorem.callao.entity.Account#1249555348184#0.7230203499285881" label="Capital" type="actif" accountNumber="10100000" masterAccount="101" /> - <account id="org.chorem.callao.entity.Account#1249555348200#0.3427497656667253" label="Capital non amorti" type="actif" accountNumber="10131000" masterAccount="101" /> - </accounts> - </save> -</Callao> - Deleted: trunk/lima-swing/src/main/resources/import/ebp_code-lutin-test.csv =================================================================== --- trunk/lima-swing/src/main/resources/import/ebp_code-lutin-test.csv 2010-07-15 10:27:28 UTC (rev 2970) +++ trunk/lima-swing/src/main/resources/import/ebp_code-lutin-test.csv 2010-07-16 16:05:21 UTC (rev 2971) @@ -1,8 +0,0 @@ -Journal;Compte;Debit;Libelle;Credit;DatSai;Piece -AC;44566210;1.82;ch 270 720 libelle 1;0;29/08/2003;24 -AC;44566210;2.13;ch 28 909 libelle 2;0;29/08/2003;52 -AC;44566210;10.17;ch 28 915 libelle 3;0;29/08/2003;59 -AC;44566130;0.31;ch 220 974 libelle 4;0;01/09/2003;107 -AC;44566210;0.68;ch 123 813 libelle 5;0;01/09/2003;15 -AC;44566210;5.4;ch 123 824 libelle 6;0;01/09/2003;30 -AC;44566130;1.23;ch 187 456 libelle 7;0;01/09/2003;44 \ No newline at end of file
participants (1)
-
jpepin@users.chorem.org