r2869 - in trunk: lima-business/src/main/java/org/chorem/lima/business 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/account lima-swing/src/main/java/org/chorem/lima/ui/account/model lima-swing/src/main/java/org/chorem/lima/ui/transaction
Author: jpepin Date: 2010-04-20 18:33:17 +0200 (Tue, 20 Apr 2010) New Revision: 2869 Log: Modification compte et compte tiers (fiche d'identit?\195?\169) Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/AccountService.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java trunk/lima-business/src/test/java/org/chorem/lima/business/EntryServiceImplTest.java trunk/lima-business/src/test/java/org/chorem/lima/business/FilesServiceImplTest.java trunk/lima-callao/src/main/xmi/accounting.properties trunk/lima-callao/src/main/xmi/accounting.zargo 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/account/SubLedgerForm.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/model/AccountTreeTableModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/FinancialTransactionViewHandler.java Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/AccountService.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/AccountService.java 2010-04-20 14:05:38 UTC (rev 2868) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/AccountService.java 2010-04-20 16:33:17 UTC (rev 2869) @@ -22,6 +22,7 @@ import java.util.List; import org.chorem.lima.entity.Account; +import org.chorem.lima.entity.Identity; /** * Account service. @@ -46,15 +47,15 @@ */ void createAccount(Account masterAccount, Account account) throws LimaException; - void createSubLedger(Account masterAccount, Account account) throws LimaException; + void createSubLedger(Account masterAccount, Account account, Identity identity) throws LimaException; void updateAccount(Account account) throws LimaException; - int removeAccount(Account account) throws LimaException; + void updateIdentity(Identity identity) throws LimaException; + void removeAccount(Account account) throws LimaException; + void removeAccountwithSubAccounts(Account account) throws LimaException; - - Account getAccountNumber(String numAccount) throws LimaException; - + List<Account> getChildrenAccounts(Account masterAccount) throws LimaException; } Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java 2010-04-20 14:05:38 UTC (rev 2868) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java 2010-04-20 16:33:17 UTC (rev 2869) @@ -39,6 +39,8 @@ import org.chorem.lima.entity.AccountDAO; import org.chorem.lima.entity.Entry; import org.chorem.lima.entity.EntryDAO; +import org.chorem.lima.entity.Identity; +import org.chorem.lima.entity.IdentityDAO; import org.chorem.lima.entity.LimaCallaoDAOHelper; import org.nuiton.topia.TopiaContext; import org.nuiton.topia.TopiaContextFactory; @@ -89,20 +91,20 @@ @Override public void createAccount(Account masterAccount, Account account) throws LimaException { - // test la validite du numero de compte + // Check if the numberaccount is not blank if (StringUtils.isBlank(account.getAccountNumber())) { throw new LimaBusinessException("Invalid AccountNumber : " + account.getAccountNumber()); } - // test que le numero de compte est de type numeric + // Check if the number account is type numeric if (!StringUtils.isNumeric(account.getAccountNumber())){ throw new LimaBusinessException("AccountNumber is not numeric : " + account.getAccountNumber()); } - // test que le numero de compte du fils commence par celui du pere - // (peut etre trop specific à la compta francaise) + // Check if the number account start with the number of the master account + // (specific to the french accountancy) if (masterAccount!=null && !account.getAccountNumber().startsWith( masterAccount.getAccountNumber())){ @@ -111,7 +113,7 @@ + account.getAccountNumber()); } - // Test que le compte master crée a un numéro entre 1 a 8 + // Check if master account have a number between 1 to 8 if (masterAccount==null && !account.getAccountNumber().matches("[1-8]")){ throw new LimaBusinessException( "Master account is not a digit between 1 to 8 :" @@ -124,11 +126,12 @@ // TODO move it into JTA transaction = rootContext.beginTransaction(); - // test si le numero de compte existe deja + // check if account number already exist AccountDAO accountDAO = LimaCallaoDAOHelper.getAccountDAO(transaction); - Account existAccount = accountDAO.findByAccountNumber(account.getAccountNumber()); + Account existAccount = + accountDAO.findByAccountNumber(account.getAccountNumber()); if (existAccount != null) { throw new LimaBusinessException(_( "An account already exists with this number : %s", @@ -137,7 +140,7 @@ accountDAO.create(account); - // test si le compte parent existe; + // check if parent account exist; if (masterAccount != null) { masterAccount.addSubAccounts(account); accountDAO.update(masterAccount); @@ -156,10 +159,9 @@ @Override - public void createSubLedger(Account masterAccount, Account account) + public void createSubLedger(Account masterAccount, Account account, Identity identity) throws LimaException { - // TODO Auto-generated method stub - // test la validite du numero de compte + // check the number account is not empty if (StringUtils.isBlank(account.getAccountNumber())) { throw new LimaBusinessException("Invalid AccountNumber : " + account.getAccountNumber()); @@ -171,29 +173,34 @@ // TODO move it into JTA transaction = rootContext.beginTransaction(); - // test si le numero de compte existe deja + // check if the accountnumber already exist AccountDAO accountDAO = LimaCallaoDAOHelper.getAccountDAO(transaction); - Account existAccount = accountDAO.findByAccountNumber(account.getAccountNumber()); + Account existAccount = + accountDAO.findByAccountNumber(account.getAccountNumber()); if (existAccount != null) { throw new LimaBusinessException(_( "An account already exists with this number : %s", account.getAccountNumber())); } - //test si le parent ne contient pas de subaccount - if (masterAccount.getSubAccounts().size() > 0) - /*List<Account> existingSubAccounts = masterAccount.getSubAccounts(); - if (CollectionUtils.isNotEmpty(existingSubAccounts))*/{ + //check if parentaccount have no subaccount + if (masterAccount.getSubAccounts().size() > 0){ throw new LimaBusinessException( - "Subledger must create on a account whithout subaccount : "); - + "Subledger must create on a account whithout subaccount : "); } accountDAO.create(account); - // test si le compte parent existe; + + IdentityDAO identityDAO = LimaCallaoDAOHelper.getIdentityDAO(transaction); + identityDAO.create(identity); + account.setIdentity(identity); + + // check if the masteraccount exist; if (masterAccount != null) { masterAccount.addSubLedgers(account); + //account.setIdentity(identity); + System.out.println(identity.getName()+" "+identity.getAddress()); accountDAO.update(masterAccount); } @@ -543,7 +550,6 @@ LimaCallaoDAOHelper.getAccountDAO(transaction); TopiaQuery query = accountDAO.createQuery(); - if (masterAccount == null){ query.add("masterAccount", masterAccount); query.add("generalLedger", TopiaQuery.Op.EQ, null); @@ -569,23 +575,6 @@ return accountsList; } - /* - * Renvoie vrai si le compte avec son numéro existe déjà dans la base de - * données. - * @param accountNumber numéro du compte recherché - * @return - * - public boolean existAccount(String accountNumber) { - // Recherche du compte - Account accountSearch = searchAccount(accountNumber); - boolean result = false; - // Si le compte est trouvé - if (accountSearch != null) { - result = true; - } - return result; - }*/ - /** * Permet d'effacer un compte dans la base de données. * @@ -598,7 +587,7 @@ * @throws LimaException */ @Override - public int removeAccount(Account account) throws LimaException { + public void removeAccount(Account account) throws LimaException { /*String result = ServiceHelper.RESPOND_ERROR; Account deleteAccount = searchAccount(accountNumber); // Si le compte n'existe pas @@ -680,7 +669,6 @@ transaction = rootContext.beginTransaction(); //Check if an account has not his number - // FIXME !IMPORTANT! check that subaccounts have no entries too EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(transaction); Entry firstEntry = entryDAO.findByAccount(account); @@ -688,10 +676,9 @@ throw new LimaBusinessException("Can't delete account with entries"); } - //Check if the account is not empty, return -1 - List<Account> existingSubAccounts = getChildrenAccounts(account); - if (CollectionUtils.isNotEmpty(existingSubAccounts)){ - result =-1; + //Check if the account is not empty + if (account.getSubAccounts().size() > 0){ + throw new LimaBusinessException("Account not empty"); } else { // remove account @@ -708,7 +695,6 @@ finally { doFinally(transaction, log); } - return result; } /** @@ -741,19 +727,6 @@ } } - /* - * Permet d'effacer un compte à partir d'un compte DTO. Il appelle la - * méthode removeAccount, qui effacera également les enfants (et ainsi de - * suite dans la hiérarchie du compte). - * @param accountDTO Compte au format DTO qu'on souhaite supprimer. - * @return - * - public String removeAccount(AccountDTO accountDTO) { - String result; - result = removeAccount(accountDTO.getAccountNumber()); - return result; - }*/ - /** * Permet de modifier un compte sur son label et son compte père. * @@ -827,24 +800,25 @@ } @Override - public Account getAccountNumber(String numAccount) throws LimaException { - Account account = null; + public void updateIdentity(Identity identity) throws LimaException { + // TODO Auto-generated method stub TopiaContext transaction = null; try { transaction = rootContext.beginTransaction(); - // get account from his number - AccountDAO accountDAO = - LimaCallaoDAOHelper.getAccountDAO(transaction); - account = accountDAO.findByAccountNumber(numAccount); + // update account + IdentityDAO identityDAO = + LimaCallaoDAOHelper.getIdentityDAO(transaction); + identityDAO.update(identity); + // commit + transaction.commitTransaction(); } catch (TopiaException ex) { if (log.isErrorEnabled()) { - log.error("Error during get account from his number", ex); + log.error("Error during update identity", ex); } - throw new LimaException("Can't get account from his number", ex); + throw new LimaException("Can't update identity", ex); } - return account; } /* Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/EntryServiceImplTest.java =================================================================== --- trunk/lima-business/src/test/java/org/chorem/lima/business/EntryServiceImplTest.java 2010-04-20 14:05:38 UTC (rev 2868) +++ trunk/lima-business/src/test/java/org/chorem/lima/business/EntryServiceImplTest.java 2010-04-20 16:33:17 UTC (rev 2869) @@ -26,7 +26,7 @@ @BeforeClass public static void setUpClass() throws Exception { - LimaConfigTest.getInstance(); + LimaConfig.getInstance(); } /** Modified: 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-04-20 14:05:38 UTC (rev 2868) +++ trunk/lima-business/src/test/java/org/chorem/lima/business/FilesServiceImplTest.java 2010-04-20 16:33:17 UTC (rev 2869) @@ -26,7 +26,7 @@ @BeforeClass public static void setUpClass() throws Exception { - LimaConfigTest.getInstance(); + LimaConfig.getInstance(); } /** Modified: trunk/lima-callao/src/main/xmi/accounting.properties =================================================================== --- trunk/lima-callao/src/main/xmi/accounting.properties 2010-04-20 14:05:38 UTC (rev 2868) +++ trunk/lima-callao/src/main/xmi/accounting.properties 2010-04-20 16:33:17 UTC (rev 2869) @@ -3,5 +3,6 @@ org.chorem.lima.entity.Account.attribute.subAccounts.tagvalue.lazy=false org.chorem.lima.entity.Account.attribute.subLedgers.tagvalue.lazy=false org.chorem.lima.entity.FinancialTransaction.attribute.entry.tagvalue.lazy=false +org.chorem.lima.entity.Account.attribute.identity.tagvalue.lazy=false #model.tagvalue.dbSchema=Callao model.tagvalue.String=text \ 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/account/AccountView.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountView.jaxx 2010-04-20 14:05:38 UTC (rev 2868) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountView.jaxx 2010-04-20 16:33:17 UTC (rev 2869) @@ -29,32 +29,38 @@ <row> <cell fill="both" weightx="1" weighty="1" rows='4'> <JScrollPane> - <org.jdesktop.swingx.JXTreeTable id="accountsTreeTable" selectionMode="{ListSelectionModel.SINGLE_SELECTION}" + <org.jdesktop.swingx.JXTreeTable id="accountsTreeTable" + selectionMode="{ListSelectionModel.SINGLE_SELECTION}" treeTableModel="{new org.chorem.lima.ui.account.model.AccountTreeTableModel()}" highlighters='{org.jdesktop.swingx.decorator.HighlighterFactory.createAlternateStriping()}' /> - <javax.swing.ListSelectionModel javaBean="getAccountsTreeTable().getSelectionModel()" - onValueChanged="setSelectedRow(accountsTreeTable.getSelectedRow() != -1)"/> + <javax.swing.ListSelectionModel + javaBean="getAccountsTreeTable().getSelectionModel()" + onValueChanged="setSelectedRow(accountsTreeTable.getSelectedRow() != -1)"/> </JScrollPane> </cell> <cell fill="horizontal"> - <JButton id="addButton" text="lima.common.add" onActionPerformed="getHandler().addAccount()"/> + <JButton id="addButton" text="lima.common.add" + onActionPerformed="getHandler().addAccount()"/> </cell> </row> <row> <cell fill="horizontal"> - <JButton id="addSubLedger" text="lima.common.addSubLedger" onActionPerformed="getHandler().addSubLedger()" + <JButton id="addSubLedger" text="lima.common.addSubLedger" + onActionPerformed="getHandler().addSubLedger()" enabled="{isSelectedRow()}"/> </cell> </row> <row> <cell fill="horizontal"> - <JButton id="updateButton" text="lima.common.update" onActionPerformed="getHandler().updateAccount()" + <JButton id="updateButton" text="lima.common.update" + onActionPerformed="getHandler().updateAccount()" enabled="{isSelectedRow()}"/> </cell> </row> <row> <cell fill="horizontal"> - <JButton id="removeButton" text="lima.common.remove" onActionPerformed="getHandler().removeAccount()" + <JButton id="removeButton" text="lima.common.remove" + onActionPerformed="getHandler().removeAccount()" enabled="{isSelectedRow()}"/> </cell> </row> 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-04-20 14:05:38 UTC (rev 2868) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java 2010-04-20 16:33:17 UTC (rev 2869) @@ -26,15 +26,24 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.business.LimaBusinessException; +import org.chorem.lima.business.LimaConfig; import org.chorem.lima.business.LimaException; import org.chorem.lima.entity.Account; import org.chorem.lima.entity.AccountImpl; +import org.chorem.lima.entity.Identity; +import org.chorem.lima.entity.IdentityDAO; +import org.chorem.lima.entity.IdentityImpl; +import org.chorem.lima.entity.LimaCallaoDAOHelper; import org.chorem.lima.ui.account.model.AccountTreeTableModel; 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.util.ErrorHelper; import org.jdesktop.swingx.JXTreeTable; +import org.nuiton.topia.TopiaContext; +import org.nuiton.topia.TopiaContextFactory; +import org.nuiton.topia.TopiaException; +import org.nuiton.topia.TopiaNotFoundException; /** * Handler associated with account view. @@ -51,9 +60,19 @@ private static final Log log = LogFactory.getLog(AccountViewHandler.class); protected AccountView view; + + private TopiaContext rootContext; protected AccountViewHandler(AccountView view) { this.view = view; + LimaConfig config = LimaConfig.getInstance(); + try { + rootContext = TopiaContextFactory.getContext(config.getOptions()); + } catch (TopiaNotFoundException ex) { + if (log.isErrorEnabled()) { + log.error("Can't init topia context", ex); + } + } } /** @@ -62,7 +81,8 @@ public void addAccount() { JXTreeTable accountsTreeTable = view.getAccountsTreeTable(); - AccountTreeTableModel accountsTreeTableModel = (AccountTreeTableModel)accountsTreeTable.getTreeTableModel(); + AccountTreeTableModel accountsTreeTableModel = + (AccountTreeTableModel)accountsTreeTable.getTreeTableModel(); Account newAccount = new AccountImpl(); AccountForm accountForm = new AccountForm(view); @@ -104,15 +124,19 @@ public void addSubLedger(){ JXTreeTable accountsTreeTable = view.getAccountsTreeTable(); - AccountTreeTableModel accountsTreeTableModel = (AccountTreeTableModel)accountsTreeTable.getTreeTableModel(); + AccountTreeTableModel accountsTreeTableModel = + (AccountTreeTableModel)accountsTreeTable.getTreeTableModel(); Account newAccount = new AccountImpl(); SubLedgerForm subledgerForm = new SubLedgerForm(view); subledgerForm.setAccount(newAccount); + Identity newIdentity = new IdentityImpl(); + subledgerForm.setIdentity(newIdentity); // jaxx constructor don't call super() ? subledgerForm.setLocationRelativeTo(view); subledgerForm.setVisible(true); newAccount=subledgerForm.getAccount(); + newIdentity=subledgerForm.getIdentity(); // null == cancel action if (newAccount != null) { @@ -122,7 +146,7 @@ treePath = view.getAccountsTreeTable().getPathForRow(selectedRow); // add it try { - accountsTreeTableModel.addSubLedger(treePath, newAccount); + accountsTreeTableModel.addSubLedger(treePath, newAccount, newIdentity); } catch (LimaBusinessException ex) { if (log.isErrorEnabled()) { log.error("Can't add subledger", ex); @@ -141,44 +165,82 @@ /** * Open account form with selected account. + * Verifiy if it's an account or a subledger */ public void updateAccount() { JXTreeTable accountsTreeTable = view.getAccountsTreeTable(); - AccountTreeTableModel accountsTreeTableModel = (AccountTreeTableModel)accountsTreeTable.getTreeTableModel(); + AccountTreeTableModel accountsTreeTableModel = + (AccountTreeTableModel)accountsTreeTable.getTreeTableModel(); // get selected account int selectedRow = view.getAccountsTreeTable().getSelectedRow(); TreePath treePath = view.getAccountsTreeTable().getPathForRow(selectedRow); // not null - Account selectedAccount = (Account)treePath.getLastPathComponent(); + Account selectedObject = (Account)treePath.getLastPathComponent(); + //TODO update Account or update SubLedger + if (selectedObject != null) { + // get current selection path + if ( selectedRow != -1) { + treePath = view.getAccountsTreeTable().getPathForRow(selectedRow); + } else { + treePath = new TreePath(accountsTreeTableModel.getRoot()); + } + //test if selectedrow is account or ledger + Identity existIdentity = selectedObject.getIdentity(); + // if is an account or subaccount + if (existIdentity == null) { + AccountForm accountForm = new AccountForm(view); + accountForm.setAccount(selectedObject); + // jaxx constructor don't call super() ? + accountForm.setLocationRelativeTo(view); + accountForm.setVisible(true); + // null == cancel action + selectedObject = accountForm.getAccount(); + if (selectedObject != null){ + // update it + try { + + accountsTreeTableModel. + updateAccount(treePath, selectedObject); + } catch (LimaException ex) { + if (log.isErrorEnabled()) { + log.error("Can't add update", ex); + } + ErrorHelper.showErrorDialog("Can't add update", ex); + } + } + } + // else is a subledger + else{ + SubLedgerForm subLedgerForm = new SubLedgerForm(view); + subLedgerForm.setAccount(selectedObject); + //log.debug("nom :"+selectedObject.getIdentity().getName()); + Identity identity=selectedObject.getIdentity(); + subLedgerForm.setIdentity(identity); + // jaxx constructor don't call super() ? + subLedgerForm.setLocationRelativeTo(view); + subLedgerForm.setVisible(true); + // null == cancel action + selectedObject = subLedgerForm.getAccount(); + if (selectedObject != null){ + // update it + try { + accountsTreeTableModel. + updateIdentity(identity); + accountsTreeTableModel. + updateAccount(treePath, selectedObject); + + } catch (LimaException ex) { + if (log.isErrorEnabled()) { + log.error("Can't add update", ex); + } + ErrorHelper.showErrorDialog("Can't add update", ex); + } + } + } + } + + } - AccountForm accountForm = new AccountForm(view); - accountForm.setAccount(selectedAccount); - // jaxx constructor don't call super() ? - accountForm.setLocationRelativeTo(view); - accountForm.setVisible(true); - - // null == cancel action - selectedAccount = accountForm.getAccount(); - if (selectedAccount != null) { - // get current selection path - if ( selectedRow != -1) { - treePath = view.getAccountsTreeTable().getPathForRow(selectedRow); - } else { - treePath = new TreePath(accountsTreeTableModel.getRoot()); - } - - // update it - try { - accountsTreeTableModel.updateAccount(treePath, selectedAccount); - } catch (LimaException ex) { - if (log.isErrorEnabled()) { - log.error("Can't add account", ex); - } - ErrorHelper.showErrorDialog("Can't add account", ex); - } - } - }; - /** * Ask for user to remove for selected account, and remove it if confirmed. */ @@ -186,7 +248,8 @@ // maybe this code can be factorised JXTreeTable accountsTreeTable = view.getAccountsTreeTable(); - AccountTreeTableModel accountsTreeTableModel = (AccountTreeTableModel)accountsTreeTable.getTreeTableModel(); + AccountTreeTableModel accountsTreeTableModel = + (AccountTreeTableModel)accountsTreeTable.getTreeTableModel(); // Any row selected int selectedRow = view.getAccountsTreeTable().getSelectedRow(); @@ -198,28 +261,25 @@ JOptionPane.QUESTION_MESSAGE); if (n == JOptionPane.YES_OPTION) { // update view of treetable - TreePath treePath = view.getAccountsTreeTable().getPathForRow(selectedRow); + TreePath treePath = view.getAccountsTreeTable(). + getPathForRow(selectedRow); Account account = (Account) treePath.getLastPathComponent(); - try { - int result = accountsTreeTableModel.removeAccount(treePath, account); - if (result ==-1){ - int n2 = JOptionPane.showConfirmDialog(view, - _("lima.question.confirmremove.account"), - _("lima.question"), - JOptionPane.YES_NO_OPTION, - JOptionPane.QUESTION_MESSAGE); - if (n2 == JOptionPane.YES_OPTION) { - // update view of treetable - try { - accountsTreeTableModel.removeAccountwithSubAccounts(treePath, account); - } catch (LimaException ex) { - if (log.isErrorEnabled()) { - log.error("Can't delete account", ex); - } - ErrorHelper.showErrorDialog("Can't delete account", ex); - } - } - } + try{ + try { + accountsTreeTableModel.removeAccount(treePath, account); + } + catch(LimaBusinessException ex){ + int n2 = JOptionPane.showConfirmDialog(view, + _("lima.question.confirmremove.account"), + _("lima.question"), + JOptionPane.YES_NO_OPTION, + JOptionPane.QUESTION_MESSAGE); + if (n2 == JOptionPane.YES_OPTION) { + // update view of treetable + accountsTreeTableModel. + removeAccountwithSubAccounts(treePath, account); + } + } } catch (LimaException ex) { if (log.isErrorEnabled()) { log.error("Can't delete account", ex); Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/SubLedgerForm.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/SubLedgerForm.jaxx 2010-04-20 14:05:38 UTC (rev 2868) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/SubLedgerForm.jaxx 2010-04-20 16:33:17 UTC (rev 2869) @@ -17,8 +17,8 @@ <JDialog defaultCloseOperation="dispose_on_close" modal="true"> + <org.chorem.lima.entity.Account id="account" javaBean='null'/> <org.chorem.lima.entity.Identity id="identity" javaBean='null'/> - <org.chorem.lima.entity.Account id="account" javaBean='null'/> <Boolean id="addState" javaBean='true'/> @@ -26,7 +26,6 @@ <![CDATA[ protected void performCancel() { setAccount(null); - setIdentity(null); dispose(); } ]]> @@ -38,7 +37,8 @@ <JLabel text="lima.subledger.code"/> </cell> <cell fill="horizontal"> - <JTextField id="numberTextField" editable='{isAddState()}' text="{getAccount().getAccountNumber()}"/> + <JTextField id="numberTextField" editable='{isAddState()}' + text="{getAccount().getAccountNumber()}"/> <javax.swing.text.Document javaBean="getNumberTextField().getDocument()" onInsertUpdate='getAccount().setAccountNumber(getNumberTextField().getText())' onRemoveUpdate='getAccount().setAccountNumber(getNumberTextField().getText())' /> @@ -51,8 +51,8 @@ <cell fill="horizontal"> <JTextField id="descriptionTextField" text="{getAccount().getLabel()}"/> <javax.swing.text.Document javaBean="getDescriptionTextField().getDocument()" - onInsertUpdate='getAccount().setLabel(getDescriptionTextField().getText())' - onRemoveUpdate='getAccount().setLabel(getDescriptionTextField().getText())' /> + onInsertUpdate='getAccount().setLabel(getDescriptionTextField().getText())' + onRemoveUpdate='getAccount().setLabel(getDescriptionTextField().getText())' /> </cell> </row> <row> @@ -60,9 +60,10 @@ <JLabel text="lima.account.type"/> </cell> <cell fill="horizontal"> - <JComboBox id="typeComboBox" model='{new org.chorem.lima.ui.account.model.AccountTypeListModel()}' - selectedItem="{getAccount().getType()}" - onActionPerformed="getAccount().setType((String)getTypeComboBox().getSelectedItem())"/> + <JComboBox id="typeComboBox" + model='{new org.chorem.lima.ui.account.model.AccountTypeListModel()}' + selectedItem="{getAccount().getType()}" + onActionPerformed="getAccount().setType((String)getTypeComboBox().getSelectedItem())"/> </cell> </row> <!-- NAME CONTACT--> @@ -73,8 +74,8 @@ <cell fill="horizontal"> <JTextField id="nameIdentityTextField" text="{getIdentity().getName()}"/> <javax.swing.text.Document javaBean="getNameIdentityTextField().getDocument()" - onInsertUpdate='getIdentity().setName(getNameIdentityTextField().getText())' - onRemoveUpdate='getIdentity().setName(getNameIdentityTextField().getText())' /> + onInsertUpdate='getIdentity().setName(getNameIdentityTextField().getText())' + onRemoveUpdate='getIdentity().setName(getNameIdentityTextField().getText())' /> </cell> <cell fill="horizontal"> <JLabel text="lima.identity.contact"/> @@ -82,8 +83,8 @@ <cell fill="horizontal"> <JTextField id="contactIdentityTextField" text="{getIdentity().getContact()}"/> <javax.swing.text.Document javaBean="getContactIdentityTextField().getDocument()" - onInsertUpdate='getIdentity().setContact(getContactIdentityTextField().getText())' - onRemoveUpdate='getIdentity().setContact(getContactIdentityTextField().getText())' /> + onInsertUpdate='getIdentity().setContact(getContactIdentityTextField().getText())' + onRemoveUpdate='getIdentity().setContact(getContactIdentityTextField().getText())' /> </cell> </row> <!-- SIRET--> @@ -94,8 +95,8 @@ <cell fill="horizontal"> <JTextField id="SiretIdentityTextField" text="{getIdentity().getSiret()}"/> <javax.swing.text.Document javaBean="getSiretIdentityTextField().getDocument()" - onInsertUpdate='getIdentity().setSiret(getZIPCodeIdentityTextField().getText())' - onRemoveUpdate='getIdentity().setSiret(getZIPCodeIdentityTextField().getText())' /> + onInsertUpdate='getIdentity().setSiret(getSiretIdentityTextField().getText())' + onRemoveUpdate='getIdentity().setSiret(getSiretIdentityTextField().getText())' /> </cell> </row> <!-- ADDRESS --> @@ -106,8 +107,8 @@ <cell fill="horizontal"> <JTextField id="addressIdentityTextField" text="{getIdentity().getAddress()}"/> <javax.swing.text.Document javaBean="getAddressIdentityTextField().getDocument()" - onInsertUpdate='getIdentity().setAddress(getAddressIdentityTextField().getText())' - onRemoveUpdate='getIdentity().setAddress(getAddressIdentityTextField().getText())' /> + onInsertUpdate='getIdentity().setAddress(getAddressIdentityTextField().getText())' + onRemoveUpdate='getIdentity().setAddress(getAddressIdentityTextField().getText())' /> </cell> </row> <!-- ZIPCODE CITY--> @@ -116,10 +117,10 @@ <JLabel text="lima.identity.zipcode"/> </cell> <cell fill="horizontal"> - <JTextField id="ZIPCodeIdentityTextField" text="{getIdentity().getZIPCode()}"/> - <javax.swing.text.Document javaBean="getZIPCodeIdentityTextField().getDocument()" - onInsertUpdate='getIdentity().setZIPCode(getZIPCodeIdentityTextField().getText())' - onRemoveUpdate='getIdentity().setZIPCode(getZIPCodeIdentityTextField().getText())' /> + <JTextField id="ZipCodeIdentityTextField" text="{getIdentity().getZipCode()}"/> + <javax.swing.text.Document javaBean="getZipCodeIdentityTextField().getDocument()" + onInsertUpdate='getIdentity().setZipCode(getZipCodeIdentityTextField().getText())' + onRemoveUpdate='getIdentity().setZipCode(getZipCodeIdentityTextField().getText())' /> </cell> <cell fill="horizontal"> <JLabel text="lima.identity.city"/> @@ -127,8 +128,8 @@ <cell fill="horizontal"> <JTextField id="cityIdentityTextField" text="{getIdentity().getCity()}"/> <javax.swing.text.Document javaBean="getCityIdentityTextField().getDocument()" - onInsertUpdate='getIdentity().setCity(getCityIdentityTextField().getText())' - onRemoveUpdate='getIdentity().setCity(getCityIdentityTextField().getText())' /> + onInsertUpdate='getIdentity().setCity(getCityIdentityTextField().getText())' + onRemoveUpdate='getIdentity().setCity(getCityIdentityTextField().getText())' /> </cell> </row> <!-- COUNTRY--> @@ -139,8 +140,8 @@ <cell fill="horizontal"> <JTextField id="CountryIdentityTextField" text="{getIdentity().getCountry()}"/> <javax.swing.text.Document javaBean="getCountryIdentityTextField().getDocument()" - onInsertUpdate='getIdentity().setCountry(getZIPCodeIdentityTextField().getText())' - onRemoveUpdate='getIdentity().setCountry(getZIPCodeIdentityTextField().getText())' /> + onInsertUpdate='getIdentity().setCountry(getCountryIdentityTextField().getText())' + onRemoveUpdate='getIdentity().setCountry(getCountryIdentityTextField().getText())' /> </cell> </row> <!-- PHONE FAX--> @@ -151,8 +152,8 @@ <cell fill="horizontal"> <JTextField id="phoneIdentityTextField" text="{getIdentity().getPhone()}"/> <javax.swing.text.Document javaBean="getPhoneIdentityTextField().getDocument()" - onInsertUpdate='getIdentity().setPhone(getPhoneIdentityTextField().getText())' - onRemoveUpdate='getIdentity().setPhone(getPhoneIdentityTextField().getText())' /> + onInsertUpdate='getIdentity().setPhone(getPhoneIdentityTextField().getText())' + onRemoveUpdate='getIdentity().setPhone(getPhoneIdentityTextField().getText())' /> </cell> <cell fill="horizontal"> <JLabel text="lima.identity.fax"/> @@ -160,8 +161,8 @@ <cell fill="horizontal"> <JTextField id="faxIdentityTextField" text="{getIdentity().getFax()}"/> <javax.swing.text.Document javaBean="getFaxIdentityTextField().getDocument()" - onInsertUpdate='getIdentity().setFax(getFaxIdentityTextField().getText())' - onRemoveUpdate='getIdentity().setFax(getFaxIdentityTextField().getText())' /> + onInsertUpdate='getIdentity().setFax(getFaxIdentityTextField().getText())' + onRemoveUpdate='getIdentity().setFax(getFaxIdentityTextField().getText())' /> </cell> </row> <!-- fin fiche identite EMAIL WEBSITE--> @@ -172,8 +173,8 @@ <cell fill="horizontal"> <JTextField id="emailIdentityTextField" text="{getIdentity().getEmail()}"/> <javax.swing.text.Document javaBean="getEmailIdentityTextField().getDocument()" - onInsertUpdate='getIdentity().setEmail(getEmailIdentityTextField().getText())' - onRemoveUpdate='getIdentity().setEmail(getEmailIdentityTextField().getText())' /> + onInsertUpdate='getIdentity().setEmail(getEmailIdentityTextField().getText())' + onRemoveUpdate='getIdentity().setEmail(getEmailIdentityTextField().getText())' /> </cell> <cell fill="horizontal"> <JLabel text="lima.identity.website"/> @@ -181,8 +182,8 @@ <cell fill="horizontal"> <JTextField id="websiteIdentityTextField" text="{getIdentity().getWebsite()}"/> <javax.swing.text.Document javaBean="getWebsiteIdentityTextField().getDocument()" - onInsertUpdate='getIdentity().setWebsite(getWebsiteIdentityTextField().getText())' - onRemoveUpdate='getIdentity().setWebsite(getWebsiteIdentityTextField().getText())' /> + onInsertUpdate='getIdentity().setWebsite(getWebsiteIdentityTextField().getText())' + onRemoveUpdate='getIdentity().setWebsite(getWebsiteIdentityTextField().getText())' /> </cell> </row> <!-- fin fiche identite --> Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/model/AccountTreeTableModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/model/AccountTreeTableModel.java 2010-04-20 14:05:38 UTC (rev 2868) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/model/AccountTreeTableModel.java 2010-04-20 16:33:17 UTC (rev 2869) @@ -24,11 +24,16 @@ import javax.swing.tree.TreePath; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.chorem.lima.business.AccountService; +import org.chorem.lima.business.LimaBusinessException; import org.chorem.lima.business.LimaException; import org.chorem.lima.entity.Account; import org.chorem.lima.entity.AccountImpl; +import org.chorem.lima.entity.Identity; import org.chorem.lima.service.LimaServiceFactory; +import org.chorem.lima.ui.account.AccountViewHandler; import org.jdesktop.swingx.treetable.AbstractTreeTableModel; /** @@ -42,7 +47,10 @@ * By : $Author$ */ public class AccountTreeTableModel extends AbstractTreeTableModel { - + + /** log. */ + private static final Log log = LogFactory.getLog(AccountViewHandler.class); + /** Account service. */ protected final AccountService accountService; @@ -111,6 +119,7 @@ @Override public Object getChild(Object parent, int index) { + log.debug("GETCHILD_BEGIN"); Object result = null; if (parent == getRoot()) { try { @@ -135,6 +144,7 @@ e.printStackTrace(); } } + log.debug("GETCHILD_END"); return result; } @@ -221,13 +231,13 @@ * @param account * @throws LimaException */ - public void addSubLedger(TreePath path, Account account) throws LimaException { + public void addSubLedger(TreePath path, Account account, Identity identity) throws LimaException { // Calling account service Account parentAccount = (Account)path.getLastPathComponent(); if (parentAccount == getRoot()) { parentAccount = null; } - accountService.createSubLedger(parentAccount, account); + accountService.createSubLedger(parentAccount, account, identity); int index = getIndexOfChild(path.getLastPathComponent(), account); modelSupport.fireChildAdded(path, index, account); } @@ -247,21 +257,30 @@ } /** + * Update identity. + * + * @param path + * @param account + * @throws LimaException + */ + public void updateIdentity(Identity identity) throws LimaException { + // Calling account service + accountService.updateIdentity(identity); + } + + /** * Remove account. * * @param path * @param account * @throws LimaException */ - public int removeAccount(TreePath path, Account account) throws LimaException { + public void removeAccount(TreePath path, Account account) throws LimaException { // Calling account service int index = getIndexOfChild( path.getParentPath().getLastPathComponent(), account); - int result = accountService.removeAccount(account); - if (result==0){ + accountService.removeAccount(account); modelSupport.fireChildRemoved(path.getParentPath(), index, account); - } - return result; } public void removeAccountwithSubAccounts(TreePath path, Account account) throws LimaException { Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/FinancialTransactionViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/FinancialTransactionViewHandler.java 2010-04-20 14:05:38 UTC (rev 2868) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/FinancialTransactionViewHandler.java 2010-04-20 16:33:17 UTC (rev 2869) @@ -62,7 +62,7 @@ //add a new transaction protected void addFinancialTransaction() { - FinancialTransactionTable table = (FinancialTransactionTable)view.getTransactionTable(); + FinancialTransactionTable table = (FinancialTransactionTable)view.getFinancialTransactionTable(); FinancialTransactionTableModel model = (FinancialTransactionTableModel)table.getModel(); try { @@ -79,7 +79,7 @@ //add a new entry to the selected transaction public void addEmptyEntry(){ - FinancialTransactionTable table = (FinancialTransactionTable)view.getTransactionTable(); + FinancialTransactionTable table = (FinancialTransactionTable)view.getFinancialTransactionTable(); FinancialTransactionTableModel model = (FinancialTransactionTableModel)table.getModel(); int indexSelectedRow = table.getSelectedRow(); @@ -102,7 +102,7 @@ */ public void deleteSelectedRow(){ - FinancialTransactionTable table = (FinancialTransactionTable)view.getTransactionTable(); + FinancialTransactionTable table = (FinancialTransactionTable)view.getFinancialTransactionTable(); FinancialTransactionTableModel model = (FinancialTransactionTableModel)table.getModel(); int indexSelectedRow = table.getSelectedRow();
participants (1)
-
jpepin@users.chorem.org