Author: sbavencoff Date: 2014-07-04 15:41:12 +0200 (Fri, 04 Jul 2014) New Revision: 3836 Url: http://forge.chorem.org/projects/lima/repository/revisions/3836 Log: refs #557 : fix entry book exception Added: trunk/lima-business-api/src/main/java/org/chorem/lima/business/UsedEntryBookException.java Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/EntryBookException.java trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/EntryBookService.java trunk/lima-business/src/main/java/org/chorem/lima/business/AccountingRules.java trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java trunk/lima-business/src/test/java/org/chorem/lima/business/EntryBookServiceImplTest.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.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/AccountingRules.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/AccountingRules.java 2014-07-02 08:42:53 UTC (rev 3835) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/AccountingRules.java 2014-07-04 13:41:12 UTC (rev 3836) @@ -61,7 +61,7 @@ * @param entryBook * @throws LimaException */ - void removeEntryBookRules(EntryBook entryBook) throws EntryBookException; + void removeEntryBookRules(EntryBook entryBook) throws UsedEntryBookException; /** * Fiscal Period rules Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java 2014-07-02 08:42:53 UTC (rev 3835) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java 2014-07-04 13:41:12 UTC (rev 3836) @@ -29,12 +29,12 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.business.AccountingRules; -import org.chorem.lima.business.EntryBookException; import org.chorem.lima.business.EntryException; import org.chorem.lima.business.FinancialTransactionException; import org.chorem.lima.business.FiscalPeriodException; import org.chorem.lima.business.InvalidAccountNumberException; import org.chorem.lima.business.LimaInterceptor; +import org.chorem.lima.business.UsedEntryBookException; import org.chorem.lima.business.UsedAccountException; import org.chorem.lima.business.utils.ClosedPeriodicEntryBookException; import org.chorem.lima.entity.Account; @@ -138,13 +138,13 @@ /** Check if entrybook have financial transaction */ @Override - public void removeEntryBookRules(EntryBook entryBook) throws EntryBookException { + public void removeEntryBookRules(EntryBook entryBook) throws UsedEntryBookException { FinancialTransactionTopiaDao financialTransactionTopiaDao = getDaoHelper().getFinancialTransactionDao(); // Check if entrybook have entries long nbfinancialtransaction = financialTransactionTopiaDao.getCountByEntryBook(entryBook); if (nbfinancialtransaction != 0) { - throw new EntryBookException(entryBook, "lima-business.defaultaccountingrules.deleteentrybookerror"); + throw new UsedEntryBookException(entryBook); } } Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java 2014-07-02 08:42:53 UTC (rev 3835) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java 2014-07-04 13:41:12 UTC (rev 3836) @@ -26,8 +26,8 @@ package org.chorem.lima.business.ejb; import org.chorem.lima.business.AccountingRules; -import org.chorem.lima.business.EntryBookException; import org.chorem.lima.business.LimaConfig; +import org.chorem.lima.business.UsedEntryBookException; import org.chorem.lima.business.api.EntryBookService; import org.chorem.lima.entity.ClosedPeriodicEntryBook; import org.chorem.lima.entity.ClosedPeriodicEntryBookImpl; @@ -114,7 +114,7 @@ } @Override - public void removeEntryBook(EntryBook entryBook) throws EntryBookException { + public void removeEntryBook(EntryBook entryBook) throws UsedEntryBookException { // check rule AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules(); Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/EntryBookServiceImplTest.java =================================================================== --- trunk/lima-business/src/test/java/org/chorem/lima/business/EntryBookServiceImplTest.java 2014-07-02 08:42:53 UTC (rev 3835) +++ trunk/lima-business/src/test/java/org/chorem/lima/business/EntryBookServiceImplTest.java 2014-07-04 13:41:12 UTC (rev 3836) @@ -79,7 +79,7 @@ * * @throws LimaException */ - @Test(expected=EntryBookException.class) + @Test(expected=UsedEntryBookException.class) public void deleteUsedEntryBook() throws LimaException, ParseException { EntryBook entryBook = entryBookService.getAllEntryBooks().get(0); // VTE Assert.assertNotNull(entryBook); Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/EntryBookException.java =================================================================== --- trunk/lima-business-api/src/main/java/org/chorem/lima/business/EntryBookException.java 2014-07-02 08:42:53 UTC (rev 3835) +++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/EntryBookException.java 2014-07-04 13:41:12 UTC (rev 3836) @@ -9,14 +9,6 @@ protected EntryBook entryBook; - public EntryBookException(String message) { - super(message); - } - - public EntryBookException(String message, Throwable cause) { - super(message, cause); - } - public EntryBookException(EntryBook entryBook, String message) { super(message); this.entryBook = entryBook; Added: trunk/lima-business-api/src/main/java/org/chorem/lima/business/UsedEntryBookException.java =================================================================== --- trunk/lima-business-api/src/main/java/org/chorem/lima/business/UsedEntryBookException.java (rev 0) +++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/UsedEntryBookException.java 2014-07-04 13:41:12 UTC (rev 3836) @@ -0,0 +1,17 @@ +package org.chorem.lima.business; + +import org.chorem.lima.entity.EntryBook; + +/** + * @author Sylvain Bavencoff <bavencoff@codelutin.com> + */ +public class UsedEntryBookException extends EntryBookException { + + public UsedEntryBookException(EntryBook entryBook) { + super(entryBook, ""); + } + + public UsedEntryBookException(EntryBook entryBook, Throwable cause) { + super(entryBook, "", cause); + } +} Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/EntryBookService.java =================================================================== --- trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/EntryBookService.java 2014-07-02 08:42:53 UTC (rev 3835) +++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/EntryBookService.java 2014-07-04 13:41:12 UTC (rev 3836) @@ -25,8 +25,8 @@ package org.chorem.lima.business.api; -import org.chorem.lima.business.EntryBookException; import org.chorem.lima.business.LimaException; +import org.chorem.lima.business.UsedEntryBookException; import org.chorem.lima.entity.EntryBook; import java.util.List; @@ -82,7 +82,7 @@ * impossible de supprimer celui-ci. * * @param entryBook - * @throws EntryBookException + * @throws org.chorem.lima.business.UsedEntryBookException */ - void removeEntryBook(EntryBook entryBook) throws EntryBookException; + void removeEntryBook(EntryBook entryBook) throws UsedEntryBookException; } 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 2014-07-02 08:42:53 UTC (rev 3835) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.java 2014-07-04 13:41:12 UTC (rev 3836) @@ -28,7 +28,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.LimaConfig; -import org.chorem.lima.business.EntryBookException; +import org.chorem.lima.business.UsedEntryBookException; import org.chorem.lima.business.ServiceListener; import org.chorem.lima.business.api.EntryBookService; import org.chorem.lima.business.api.ImportService; @@ -41,7 +41,12 @@ import org.chorem.lima.util.ErrorHelper; import org.jdesktop.swingx.JXTable; -import javax.swing.*; +import javax.swing.AbstractAction; +import javax.swing.ActionMap; +import javax.swing.InputMap; +import javax.swing.JComponent; +import javax.swing.JOptionPane; +import javax.swing.KeyStroke; import java.awt.event.ActionEvent; import java.awt.event.KeyEvent; import java.awt.event.MouseAdapter; @@ -237,8 +242,8 @@ try { entryBookService.removeEntryBook(selectedEntryBook); entryBookTableModel.remove(selectedEntryBook); - } catch (EntryBookException e) { - errorHelper.showErrorMessage(t(e.getMessage())); + } catch (UsedEntryBookException e) { + errorHelper.showErrorMessage(t("lima.ui.entryBook.delete.used.error", e.getEntryBook().getCode(), e.getEntryBook().getLabel())); } } } Modified: trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties =================================================================== --- trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties 2014-07-02 08:42:53 UTC (rev 3835) +++ trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties 2014-07-04 13:41:12 UTC (rev 3836) @@ -359,6 +359,7 @@ lima.ui.common.remove=Remove lima.ui.common.solde= lima.ui.common.update=Update +lima.ui.entryBook.delete.used.error=Can't delete entry book %2$s (%1$s) because exist financcial transactions in this entry book. lima.ui.entrybook.add= lima.ui.entrybook.code= lima.ui.entrybook.default= Modified: trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties =================================================================== --- trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties 2014-07-02 08:42:53 UTC (rev 3835) +++ trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties 2014-07-04 13:41:12 UTC (rev 3836) @@ -341,6 +341,7 @@ lima.ui.common.remove=Supprimer lima.ui.common.solde=Solde lima.ui.common.update=Modifier +lima.ui.entryBook.delete.used.error=Imposible de supprimer le journal %2$s (%1$s) car Il existe des transactioins sur ce journal. lima.ui.entrybook.add=Ajout de journal lima.ui.entrybook.code=Code lima.ui.entrybook.default=Journaux par défault