Author: tchemit Date: 2011-09-17 14:55:16 +0200 (Sat, 17 Sep 2011) New Revision: 3289 Url: http://chorem.org/repositories/revision/lima/3289 Log: utilisation du prefixe sur les constantes g?\195?\169n?\195?\169r?\195?\169es + reformat du code Modified: trunk/lima-callao/src/main/java/org/chorem/lima/FinancialStatementWayEnum.java trunk/lima-callao/src/main/java/org/chorem/lima/entity/AccountDAOImpl.java trunk/lima-callao/src/main/java/org/chorem/lima/entity/ClosedPeriodicEntryBookDAOImpl.java trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialPeriodDAOImpl.java trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialStatementImpl.java trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialTransactionImpl.java trunk/lima-callao/src/main/java/org/chorem/lima/entity/VatStatementImpl.java trunk/lima-callao/src/main/xmi/accounting.properties Modified: trunk/lima-callao/src/main/java/org/chorem/lima/FinancialStatementWayEnum.java =================================================================== --- trunk/lima-callao/src/main/java/org/chorem/lima/FinancialStatementWayEnum.java 2011-09-09 16:14:41 UTC (rev 3288) +++ trunk/lima-callao/src/main/java/org/chorem/lima/FinancialStatementWayEnum.java 2011-09-17 12:55:16 UTC (rev 3289) @@ -35,12 +35,12 @@ private final String description; - private FinancialStatementWayEnum(String description) { + FinancialStatementWayEnum(String description) { this.description = description; } public String getDescription() { - return this.description; + return description; } public static String[] descriptions(){ Modified: trunk/lima-callao/src/main/java/org/chorem/lima/entity/AccountDAOImpl.java =================================================================== --- trunk/lima-callao/src/main/java/org/chorem/lima/entity/AccountDAOImpl.java 2011-09-09 16:14:41 UTC (rev 3288) +++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/AccountDAOImpl.java 2011-09-17 12:55:16 UTC (rev 3289) @@ -25,10 +25,6 @@ package org.chorem.lima.entity; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.StringTokenizer; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -36,10 +32,15 @@ import org.nuiton.topia.framework.TopiaQuery; import org.nuiton.topia.framework.TopiaQuery.Op; -public class AccountDAOImpl <E extends Account> extends AccountDAOAbstract<E> { +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.StringTokenizer; +public class AccountDAOImpl<E extends Account> extends AccountDAOAbstract<E> { + private static final Log log = LogFactory.getLog(AccountDAOImpl.class); - + /** * List all subaccounts (no folderaccounts, exclude accounts contains thirdpart accounts) * Sort by accout number in lexicographical order @@ -47,102 +48,100 @@ @Override public List<Account> findAllSubAccounts() throws TopiaException { TopiaQuery query = createQuery(); - String subAccountsProperty = TopiaQuery.getProperty(Account.SUB_ACCOUNTS); - query.addWhere("not exists elements ("+subAccountsProperty+")") - .addOrder(Account.ACCOUNT_NUMBER); + String subAccountsProperty = TopiaQuery.getProperty(Account.PROPERTY_SUB_ACCOUNTS); + query.addWhere("not exists elements (" + subAccountsProperty + ")") + .addOrder(Account.PROPERTY_ACCOUNT_NUMBER); return (List<Account>) findAllByQuery(query); } - + @Override public Account findSubAccountByNumber(String number) throws TopiaException { TopiaQuery query = createQuery(); - String subAccountsProperty = TopiaQuery.getProperty(Account.SUB_ACCOUNTS); - String subLedgersProperty = TopiaQuery.getProperty(Account.SUB_LEDGERS); - query.addWhere("not exists elements ("+subAccountsProperty+")") - .addWhere("not exists elements ("+subLedgersProperty+")") - .addEquals(Account.ACCOUNT_NUMBER, number); + String subAccountsProperty = TopiaQuery.getProperty(Account.PROPERTY_SUB_ACCOUNTS); + String subLedgersProperty = TopiaQuery.getProperty(Account.PROPERTY_SUB_LEDGERS); + query.addWhere("not exists elements (" + subAccountsProperty + ")") + .addWhere("not exists elements (" + subLedgersProperty + ")") + .addEquals(Account.PROPERTY_ACCOUNT_NUMBER, number); return findByQuery(query); } - - public List<Account> findIntervalAccountByNumber(String accountNumberLow, String accountNumberHigh) throws TopiaException { + + public List<Account> findIntervalAccountByNumber(String accountNumberLow, + String accountNumberHigh) throws TopiaException { TopiaQuery query = createQuery(); - query.addBetween(Account.ACCOUNT_NUMBER, accountNumberLow, accountNumberHigh); + query.addBetween(Account.PROPERTY_ACCOUNT_NUMBER, + accountNumberLow, accountNumberHigh); return (List<Account>) findAllByQuery(query); } - + @Override public List<Account> stringToListAccounts(String selectedAccounts, - Boolean subAccountsMode) throws TopiaException { + Boolean subAccountsMode) throws TopiaException { HashSet<Account> accounts = new HashSet<Account>(); - if (selectedAccounts != null){ - //Remove Spaces - String result = StringUtils.deleteWhitespace(selectedAccounts); + if (selectedAccounts != null) { + //Remove Spaces + String result = StringUtils.deleteWhitespace(selectedAccounts); - Boolean first = true; - StringTokenizer stStar = new StringTokenizer(result, "-"); - while (stStar.hasMoreTokens()) { - String subString = stStar.nextToken(); - - //Split comma - StringTokenizer stComma = new StringTokenizer(subString, ","); - while (stComma.hasMoreTokens()) { - String s = stComma.nextToken(); - //if intervall account - if (s.contains("..") && !s.endsWith("..")){ - //Split .. - String stringDoubleDot[] = s.split("\\.\\."); - - List<Account> resultIntervall = + Boolean first = true; + StringTokenizer stStar = new StringTokenizer(result, "-"); + while (stStar.hasMoreTokens()) { + String subString = stStar.nextToken(); + + //Split comma + StringTokenizer stComma = new StringTokenizer(subString, ","); + while (stComma.hasMoreTokens()) { + String s = stComma.nextToken(); + //if intervall account + if (s.contains("..") && !s.endsWith("..")) { + //Split .. + String stringDoubleDot[] = s.split("\\.\\."); + + List<Account> resultIntervall = findIntervalAccountByNumber(stringDoubleDot[0], stringDoubleDot[1]); - - //if first add accounts, else remove - if (first){ - accounts.addAll(resultIntervall); - } - else { - accounts.removeAll(resultIntervall); - } + + //if first add accounts, else remove + if (first) { + accounts.addAll(resultIntervall); + } else { + accounts.removeAll(resultIntervall); } - //else one account - else{ - Account account = null; - if (subAccountsMode){ - account = findSubAccountByNumber(s); + } + //else one account + else { + Account account = null; + if (subAccountsMode) { + account = findSubAccountByNumber(s); + } else { + account = findByAccountNumber(s); + } + //if exist + if (account != null) { + //if first + if (first) { + accounts.add(account); + } else { + accounts.remove(account); } - else { - account = findByAccountNumber(s); - } - //if exist - if (account != null){ + } + //search all account start with accountnumber + else { + TopiaQuery query = createQuery(); + String subAccountsProperty = TopiaQuery.getProperty(Account.PROPERTY_SUB_ACCOUNTS); + query.addWhere("not exists elements (" + subAccountsProperty + ")") + .addWhere(Account.PROPERTY_ACCOUNT_NUMBER, Op.LIKE, s + "%"); + List<Account> accountsResult = (List<Account>) findAllByQuery(query); + if (accountsResult != null) { //if first - if (first){ - accounts.add(account); + if (first) { + accounts.addAll(accountsResult); + } else { + accounts.removeAll(accountsResult); } - else { - accounts.remove(account); - } } - //search all account start with accountnumber - else { - TopiaQuery query = createQuery(); - String subAccountsProperty = TopiaQuery.getProperty(Account.SUB_ACCOUNTS); - query.addWhere("not exists elements ("+subAccountsProperty+")") - .addWhere(Account.ACCOUNT_NUMBER, Op.LIKE, s+"%"); - List<Account> accountsResult = (List<Account>) findAllByQuery(query); - if (accountsResult != null){ - //if first - if (first){ - accounts.addAll(accountsResult); - } - else { - accounts.removeAll(accountsResult); - } - } - } } } - first=false; } + first = false; + } } return new ArrayList(accounts); } Modified: trunk/lima-callao/src/main/java/org/chorem/lima/entity/ClosedPeriodicEntryBookDAOImpl.java =================================================================== --- trunk/lima-callao/src/main/java/org/chorem/lima/entity/ClosedPeriodicEntryBookDAOImpl.java 2011-09-09 16:14:41 UTC (rev 3288) +++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/ClosedPeriodicEntryBookDAOImpl.java 2011-09-17 12:55:16 UTC (rev 3289) @@ -25,53 +25,47 @@ package org.chorem.lima.entity; -import java.util.Date; -import java.util.List; - import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.chorem.lima.entity.ClosedPeriodicEntryBook; -import org.chorem.lima.entity.ClosedPeriodicEntryBookDAOAbstract; -import org.chorem.lima.entity.EntryBook; -import org.chorem.lima.entity.FinancialPeriod; import org.nuiton.topia.TopiaException; import org.nuiton.topia.framework.TopiaQuery; import org.nuiton.topia.framework.TopiaQuery.Op; -public class ClosedPeriodicEntryBookDAOImpl <E extends ClosedPeriodicEntryBook> extends ClosedPeriodicEntryBookDAOAbstract<E>{ +import java.util.Date; +import java.util.List; +public class ClosedPeriodicEntryBookDAOImpl<E extends ClosedPeriodicEntryBook> extends ClosedPeriodicEntryBookDAOAbstract<E> { + private static final Log log = LogFactory.getLog(ClosedPeriodicEntryBookDAOImpl.class); - - /** - * Return ClosedPeriodicEntryBook by EntryBook and FinancialPeriod - */ + + /** Return ClosedPeriodicEntryBook by EntryBook and FinancialPeriod */ @Override public ClosedPeriodicEntryBook findByEntryBookAndFinancialPeriod( EntryBook entryBook, FinancialPeriod financialPeriod) throws TopiaException { TopiaQuery query = createQuery(); - if (entryBook != null){ - query.addEquals(ClosedPeriodicEntryBook.ENTRY_BOOK, entryBook); + if (entryBook != null) { + query.addEquals(ClosedPeriodicEntryBook.PROPERTY_ENTRY_BOOK, entryBook); } - if (financialPeriod != null){ - query.addEquals(ClosedPeriodicEntryBook.FINANCIAL_PERIOD, financialPeriod); + if (financialPeriod != null) { + query.addEquals(ClosedPeriodicEntryBook.PROPERTY_FINANCIAL_PERIOD, financialPeriod); } return findByQuery(query); } @Override public List<ClosedPeriodicEntryBook> findAllByDates(Date beginDate, - Date endDate) throws TopiaException { + Date endDate) throws TopiaException { TopiaQuery query = createQuery(); - if (beginDate != null && endDate != null){ - String beginDateProperty = TopiaQuery.getProperty(ClosedPeriodicEntryBook.FINANCIAL_PERIOD, FinancialPeriod.BEGIN_DATE); - String endDateProperty = TopiaQuery.getProperty(ClosedPeriodicEntryBook.FINANCIAL_PERIOD, FinancialPeriod.BEGIN_DATE); - String entrybookProperty = TopiaQuery.getProperty(ClosedPeriodicEntryBook.ENTRY_BOOK, EntryBook.CODE); + if (beginDate != null && endDate != null) { + String beginDateProperty = TopiaQuery.getProperty(ClosedPeriodicEntryBook.PROPERTY_FINANCIAL_PERIOD, FinancialPeriod.PROPERTY_BEGIN_DATE); + String endDateProperty = TopiaQuery.getProperty(ClosedPeriodicEntryBook.PROPERTY_FINANCIAL_PERIOD, FinancialPeriod.PROPERTY_BEGIN_DATE); + String entrybookProperty = TopiaQuery.getProperty(ClosedPeriodicEntryBook.PROPERTY_ENTRY_BOOK, EntryBook.PROPERTY_CODE); query.addWhere(beginDateProperty, Op.GE, beginDate) - .addWhere(endDateProperty, Op.LE, endDate) - .addOrder(beginDateProperty, entrybookProperty); + .addWhere(endDateProperty, Op.LE, endDate) + .addOrder(beginDateProperty, entrybookProperty); } return (List<ClosedPeriodicEntryBook>) findAllByQuery(query); } Modified: trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialPeriodDAOImpl.java =================================================================== --- trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialPeriodDAOImpl.java 2011-09-09 16:14:41 UTC (rev 3288) +++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialPeriodDAOImpl.java 2011-09-17 12:55:16 UTC (rev 3289) @@ -25,13 +25,13 @@ package org.chorem.lima.entity; -import java.util.Date; - import org.nuiton.topia.TopiaException; import org.nuiton.topia.framework.TopiaQuery; -public class FinancialPeriodDAOImpl <E extends FinancialPeriod> extends FinancialPeriodDAOAbstract<E>{ +import java.util.Date; +public class FinancialPeriodDAOImpl<E extends FinancialPeriod> extends FinancialPeriodDAOAbstract<E> { + /** * Return FinancialPeriod by Date * Date is include between financialperiod begin and end date @@ -40,10 +40,10 @@ public FinancialPeriod findByDate(Date date) throws TopiaException { TopiaQuery query = createQuery(); - if (date != null){ - query.addWhere("beginDate <= :value") - .addWhere("endDate >= :value") - .addParam("value", date); + if (date != null) { + query.addWhere(FinancialPeriod.PROPERTY_BEGIN_DATE + " <= :value") + .addWhere(FinancialPeriod.PROPERTY_END_DATE + " >= :value") + .addParam("value", date); } return findByQuery(query); } Modified: trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialStatementImpl.java =================================================================== --- trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialStatementImpl.java 2011-09-09 16:14:41 UTC (rev 3288) +++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialStatementImpl.java 2011-09-17 12:55:16 UTC (rev 3289) @@ -25,14 +25,16 @@ package org.chorem.lima.entity; -public class FinancialStatementImpl extends FinancialStatementAbstract{ +public class FinancialStatementImpl extends FinancialStatementAbstract { + private static final long serialVersionUID = 1L; + protected Integer level; - + @Override public int getLevel() { if (level == null) { - if (masterFinancialStatement != null){ + if (masterFinancialStatement != null) { level = masterFinancialStatement.getLevel() + 1; } else { level = 1; Modified: trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialTransactionImpl.java =================================================================== --- trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialTransactionImpl.java 2011-09-09 16:14:41 UTC (rev 3288) +++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialTransactionImpl.java 2011-09-17 12:55:16 UTC (rev 3289) @@ -35,17 +35,16 @@ @Override public void setAmounts() { - if (amountDebit == null){ + if (amountDebit == null) { amountDebit = new BigDecimal(0); } - if (amountCredit == null){ - amountCredit = new BigDecimal(0); + if (amountCredit == null) { + amountCredit = new BigDecimal(0); } for (Entry entryFT : entry) { - if (entryFT.getDebit()){ + if (entryFT.getDebit()) { amountDebit = amountDebit.add(entryFT.getAmount()); - } - else { + } else { amountCredit = amountCredit.add(entryFT.getAmount()); } } Modified: trunk/lima-callao/src/main/java/org/chorem/lima/entity/VatStatementImpl.java =================================================================== --- trunk/lima-callao/src/main/java/org/chorem/lima/entity/VatStatementImpl.java 2011-09-09 16:14:41 UTC (rev 3288) +++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/VatStatementImpl.java 2011-09-17 12:55:16 UTC (rev 3289) @@ -26,12 +26,14 @@ public class VatStatementImpl extends VatStatementAbstract { + private static final long serialVersionUID = 1L; + protected Integer level; - + @Override public int getLevel() { if (level == null) { - if (masterVatStatement != null){ + if (masterVatStatement != null) { level = masterVatStatement.getLevel() + 1; } else { level = 1; Modified: trunk/lima-callao/src/main/xmi/accounting.properties =================================================================== --- trunk/lima-callao/src/main/xmi/accounting.properties 2011-09-09 16:14:41 UTC (rev 3288) +++ trunk/lima-callao/src/main/xmi/accounting.properties 2011-09-17 12:55:16 UTC (rev 3289) @@ -24,6 +24,7 @@ ### # Precise l'entete de l'ensemble des fichiers generes model.tagvalue.copyright=/*\n Copyright (C) 2009-2010 Lima Callao\n */ +model.tagvalue.constantPrefix=PROPERTY_ # natural id org.chorem.lima.entity.Account.class.tagvalue.naturalIdMutable=false