Author: jpepin Date: 2010-04-12 17:46:09 +0200 (Mon, 12 Apr 2010) New Revision: 2859 Log: tests metier de creation de compte ajouter Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java 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-12 13:53:23 UTC (rev 2858) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java 2010-04-12 15:46:09 UTC (rev 2859) @@ -88,14 +88,31 @@ @Override public void createAccount(Account masterAccount, Account account) throws LimaException { + + + // test la validite du numero de compte if (StringUtils.isBlank(account.getAccountNumber())) { throw new LimaBusinessException("Invalid AccountNumber : " + account.getAccountNumber()); } + // test que le numero de compte est de type numeric + if (!StringUtils.isNumeric(account.getAccountNumber())){ + throw new LimaBusinessException("AccountNumber is not numeric : " + account.getAccountNumber()); + } + // TODO verifier que le numero de compte du fils commence par celui du pere // (peut etre trop specific à la compta francaise) - + if (masterAccount!=null && !account.getAccountNumber().startsWith(masterAccount.getAccountNumber())){ + + throw new LimaBusinessException("Account Number not begin with the number account master :" + account.getAccountNumber()); + } + + // Test que le compte master crée a un numéro entre 1 a 8 + if (masterAccount==null && !account.getAccountNumber().matches("[1-8]")){ + throw new LimaBusinessException("Master account is not a digit between 1 to 8 :" + account.getAccountNumber()); + } + TopiaContext transaction = null; try { // basic check done, make check in database 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-12 13:53:23 UTC (rev 2858) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java 2010-04-12 15:46:09 UTC (rev 2859) @@ -25,6 +25,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.chorem.lima.business.LimaBusinessException; import org.chorem.lima.business.LimaException; import org.chorem.lima.entity.Account; import org.chorem.lima.entity.AccountImpl; @@ -84,10 +85,17 @@ // add it try { accountsTreeTableModel.addAccount(treePath, newAccount); - } catch (LimaException ex) { + } catch (LimaBusinessException ex) { if (log.isErrorEnabled()) { log.error("Can't add account", ex); } + ErrorHelper.showErrorDialog(ex.getMessage(), ex); + } + + catch (LimaException ex) { + if (log.isErrorEnabled()) { + log.error("Can't add account", ex); + } ErrorHelper.showErrorDialog("Can't add account", ex); } }