r3712 - in trunk: lima-callao/src/main/java/org/chorem/lima/Filter lima-callao/src/main/java/org/chorem/lima/beans lima-callao/src/main/java/org/chorem/lima/entity lima-swing/src/main/java/org/chorem/lima/ui/Filter/StringCondition lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch lima-swing/src/main/java/org/chorem/lima/ui/lettering lima-swing/src/main/resources/icons
Author: dcosse Date: 2013-10-28 09:11:44 +0100 (Mon, 28 Oct 2013) New Revision: 3712 Url: http://chorem.org/projects/lima/repository/revisions/3712 Log: fixes #955 correction d un bug sur l'application de filtres sur les ?\195?\169critures Modified: trunk/lima-callao/src/main/java/org/chorem/lima/Filter/FilterGenerator.java trunk/lima-callao/src/main/java/org/chorem/lima/beans/AccountCondition.java trunk/lima-callao/src/main/java/org/chorem/lima/beans/Condition.java trunk/lima-callao/src/main/java/org/chorem/lima/beans/CreditCondition.java trunk/lima-callao/src/main/java/org/chorem/lima/beans/DateCondition.java trunk/lima-callao/src/main/java/org/chorem/lima/beans/DateIntervalCondition.java trunk/lima-callao/src/main/java/org/chorem/lima/beans/DebitCondition.java trunk/lima-callao/src/main/java/org/chorem/lima/beans/DescriptionCondition.java trunk/lima-callao/src/main/java/org/chorem/lima/beans/EntryBookCondition.java trunk/lima-callao/src/main/java/org/chorem/lima/beans/FinancialPeriodCondition.java trunk/lima-callao/src/main/java/org/chorem/lima/beans/FinancialTransactionCondition.java trunk/lima-callao/src/main/java/org/chorem/lima/beans/FiscalPeriodCondition.java trunk/lima-callao/src/main/java/org/chorem/lima/beans/LetteringCondition.java trunk/lima-callao/src/main/java/org/chorem/lima/beans/VoucherCondition.java trunk/lima-callao/src/main/java/org/chorem/lima/entity/GeneratorHQuery.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/Filter/StringCondition/StringConditionHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/Filter/StringCondition/StringConditionView.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/TypeEntry.java trunk/lima-swing/src/main/resources/icons/action-choose-entry.png trunk/lima-swing/src/main/resources/icons/action-un-lettering.png Modified: trunk/lima-callao/src/main/java/org/chorem/lima/Filter/FilterGenerator.java =================================================================== --- trunk/lima-callao/src/main/java/org/chorem/lima/Filter/FilterGenerator.java 2013-10-11 15:17:27 UTC (rev 3711) +++ trunk/lima-callao/src/main/java/org/chorem/lima/Filter/FilterGenerator.java 2013-10-28 08:11:44 UTC (rev 3712) @@ -24,6 +24,7 @@ * #L% */ +import org.apache.commons.lang3.StringUtils; import org.chorem.lima.Clause.AndClause; import org.chorem.lima.Clause.BooleanClause; import org.chorem.lima.Clause.Clause; @@ -75,134 +76,146 @@ @Override public void visitFinancialTransactionCondition(FinancialTransactionCondition condition) { - - filter = new FinancialTransactionFilter(); - for (Condition subCondition : condition.getConditions()) { - subCondition.accept(this); - } - if (clauses.size() == 1 ) { - filter.setClause(clauses.get(0)); - } else if (clauses.size() > 1) { - if (condition.isAllConditions()) { - AndClause clause = new AndClause(); - clause.addAll(clauses); - filter.setClause(clause); - } else { - OrClause clause = new OrClause(); - clause.addAll(clauses); - filter.setClause(clause); + if (condition != null && condition.getConditions() != null) { + filter = new FinancialTransactionFilter(); + for (Condition subCondition : condition.getConditions()) { + if (subCondition.validCondition()) { + subCondition.accept(this); + } } - } + if (clauses.size() == 1 ) { + filter.setClause(clauses.get(0)); + } else if (clauses.size() > 1) { + if (condition.isAllConditions()) { + AndClause clause = new AndClause(); + clause.addAll(clauses); + filter.setClause(clause); + } else { + OrClause clause = new OrClause(); + clause.addAll(clauses); + filter.setClause(clause); + } + } - if (entryClauses.size() == 1 ) { - entryFilter.setClause(entryClauses.get(0)); - } else if (entryClauses.size() > 1) { - if (condition.isAllConditions()) { - AndClause clause = new AndClause(); - clause.addAll(entryClauses); - entryFilter.setClause(clause); - } else { - OrClause clause = new OrClause(); - clause.addAll(entryClauses); - entryFilter.setClause(clause); + if (entryClauses.size() == 1 ) { + entryFilter.setClause(entryClauses.get(0)); + } else if (entryClauses.size() > 1) { + if (condition.isAllConditions()) { + AndClause clause = new AndClause(); + clause.addAll(entryClauses); + entryFilter.setClause(clause); + } else { + OrClause clause = new OrClause(); + clause.addAll(entryClauses); + entryFilter.setClause(clause); + } } } } @Override public void visitDateCondition(DateCondition condition) { - DateClause dateClause = getFilter().newTransactionDateClause(); - switch (condition.getOperand()) { - case SAME: - dateClause.setOperand(DateClause.Operand.SAME); - break; - case AFTER: - dateClause.setOperand(DateClause.Operand.AFTER); - break; - case PREVIOUS: - dateClause.setOperand(DateClause.Operand.PREVIOUS); - break; - case DIFFERENT: - dateClause.setOperand(DateClause.Operand.DIFFERENT); - break; + if (condition != null && condition.getOperand() != null) { + DateClause dateClause = getFilter().newTransactionDateClause(); + switch (condition.getOperand()) { + case SAME: + dateClause.setOperand(DateClause.Operand.SAME); + break; + case AFTER: + dateClause.setOperand(DateClause.Operand.AFTER); + break; + case PREVIOUS: + dateClause.setOperand(DateClause.Operand.PREVIOUS); + break; + case DIFFERENT: + dateClause.setOperand(DateClause.Operand.DIFFERENT); + break; + } + dateClause.setValue(condition.getDate()); + clauses.add(dateClause); } - dateClause.setValue(condition.getDate()); - clauses.add(dateClause); } @Override public void visitDateIntervalCondition(DateIntervalCondition condition) { - AndClause andClause = new AndClause(); + if (condition != null && condition.getBeginDate() != null && condition.getEndDate() != null) { + AndClause andClause = new AndClause(); - DateClause beginDateClause = getFilter().newTransactionDateClause(); - beginDateClause.setOperand(DateClause.Operand.AFTER); - beginDateClause.setValue(condition.getBeginDate()); - andClause.add(beginDateClause); + DateClause beginDateClause = getFilter().newTransactionDateClause(); + beginDateClause.setOperand(DateClause.Operand.AFTER); + beginDateClause.setValue(condition.getBeginDate()); + andClause.add(beginDateClause); - DateClause endDateClause = getFilter().newTransactionDateClause(); - endDateClause.setOperand(DateClause.Operand.PREVIOUS); - endDateClause.setValue(condition.getEndDate()); - andClause.add(endDateClause); + DateClause endDateClause = getFilter().newTransactionDateClause(); + endDateClause.setOperand(DateClause.Operand.PREVIOUS); + endDateClause.setValue(condition.getEndDate()); + andClause.add(endDateClause); - clauses.add(andClause); + clauses.add(andClause); + } } @Override public void visitEntryBookCondition(EntryBookCondition condition) { - - SetClause setClause = getFilter().newEntryBookSetClause(); - setClause.addAll(condition.getEntryBooks()); - clauses.add(setClause); + if (condition != null && condition.getEntryBooks() != null) { + SetClause setClause = getFilter().newEntryBookSetClause(); + setClause.addAll(condition.getEntryBooks()); + clauses.add(setClause); + } } @Override public void visitFinancialPeriodCondition(FinancialPeriodCondition condition) { - OrClause orClause = new OrClause(); - for (FinancialPeriod period : condition.getFinancialPeriods()) { - AndClause andClause = new AndClause(); + if (condition != null && condition.getFinancialPeriods() != null) { + OrClause orClause = new OrClause(); + for (FinancialPeriod period : condition.getFinancialPeriods()) { + AndClause andClause = new AndClause(); - DateClause beginDateClause = getFilter().newTransactionDateClause(); - beginDateClause.setOperand(DateClause.Operand.AFTER); - beginDateClause.setValue(period.getBeginDate()); - andClause.add(beginDateClause); + DateClause beginDateClause = getFilter().newTransactionDateClause(); + beginDateClause.setOperand(DateClause.Operand.AFTER); + beginDateClause.setValue(period.getBeginDate()); + andClause.add(beginDateClause); - DateClause endDateClause = getFilter().newTransactionDateClause(); - endDateClause.setOperand(DateClause.Operand.PREVIOUS); - endDateClause.setValue(period.getEndDate()); - andClause.add(endDateClause); + DateClause endDateClause = getFilter().newTransactionDateClause(); + endDateClause.setOperand(DateClause.Operand.PREVIOUS); + endDateClause.setValue(period.getEndDate()); + andClause.add(endDateClause); - orClause.add(andClause); + orClause.add(andClause); + } + if (orClause.size() == 1) { + clauses.add(orClause.get(0)); + } else { + clauses.add(orClause); + } } - if (orClause.size() == 1) { - clauses.add(orClause.get(0)); - } else { - clauses.add(orClause); - } } @Override public void visitFiscalPeriodCondition(FiscalPeriodCondition condition) { - OrClause orClause = new OrClause(); - for (FiscalPeriod period : condition.getFiscalPeriods()) { - AndClause andClause = new AndClause(); + if (condition != null && condition.getFiscalPeriods()!=null) { + OrClause orClause = new OrClause(); + for (FiscalPeriod period : condition.getFiscalPeriods()) { + AndClause andClause = new AndClause(); - DateClause beginDateClause = getFilter().newTransactionDateClause(); - beginDateClause.setOperand(DateClause.Operand.AFTER); - beginDateClause.setValue(period.getBeginDate()); - andClause.add(beginDateClause); + DateClause beginDateClause = getFilter().newTransactionDateClause(); + beginDateClause.setOperand(DateClause.Operand.AFTER); + beginDateClause.setValue(period.getBeginDate()); + andClause.add(beginDateClause); - DateClause endDateClause = getFilter().newTransactionDateClause(); - endDateClause.setOperand(DateClause.Operand.PREVIOUS); - endDateClause.setValue(period.getEndDate()); - andClause.add(endDateClause); + DateClause endDateClause = getFilter().newTransactionDateClause(); + endDateClause.setOperand(DateClause.Operand.PREVIOUS); + endDateClause.setValue(period.getEndDate()); + andClause.add(endDateClause); - orClause.add(andClause); + orClause.add(andClause); + } + if (orClause.size() == 1) { + clauses.add(orClause.get(0)); + } else { + clauses.add(orClause); + } } - if (orClause.size() == 1) { - clauses.add(orClause.get(0)); - } else { - clauses.add(orClause); - } } protected EntryFilter getEntryFilter() { @@ -239,18 +252,22 @@ @Override public void visitDescriptionCondition(DescriptionCondition descriptionCondition) { - getEntryFilter(); - StringClause stringClause = entryFilter.newDescriptionClause(); + if (descriptionCondition != null + && descriptionCondition.getOperand() != null + && StringUtils.isNotBlank(descriptionCondition.getValue())) { + getEntryFilter(); + StringClause stringClause = entryFilter.newDescriptionClause(); - AbstractStringCondition.Operand operand = descriptionCondition.getOperand(); - StringClause.Operand stringClauseOperand = getStringClauseOperand(operand); - stringClause.setOperand(stringClauseOperand); + AbstractStringCondition.Operand operand = descriptionCondition.getOperand(); + StringClause.Operand stringClauseOperand = getStringClauseOperand(operand); + stringClause.setOperand(stringClauseOperand); - stringClause.setValue(descriptionCondition.getValue()); + stringClause.setValue(descriptionCondition.getValue()); - stringClause.setSensitiveCase(descriptionCondition.isSensitiveCase()); + stringClause.setSensitiveCase(descriptionCondition.isSensitiveCase()); - entryClauses.add(stringClause); + entryClauses.add(stringClause); + } } @Override @@ -262,7 +279,8 @@ StringClause.Operand stringClauseOperand = getStringClauseOperand(operand); stringClause.setOperand(stringClauseOperand); - stringClause.setValue(voucherCondition.getValue()); + String value = voucherCondition.getValue() == null ? "*" : voucherCondition.getValue(); + stringClause.setValue(value); stringClause.setSensitiveCase(voucherCondition.isSensitiveCase()); @@ -271,102 +289,120 @@ @Override public void visitLetteringCondition(LetteringCondition letteringCondition) { - getEntryFilter(); - StringClause stringClause = entryFilter.newLetteringClause(); + if (letteringCondition != null + && letteringCondition.getOperand() != null + && StringUtils.isNotBlank(letteringCondition.getValue())){ + getEntryFilter(); + StringClause stringClause = entryFilter.newLetteringClause(); - AbstractStringCondition.Operand operand = letteringCondition.getOperand(); - StringClause.Operand stringClauseOperand = getStringClauseOperand(operand); - stringClause.setOperand(stringClauseOperand); + AbstractStringCondition.Operand operand = letteringCondition.getOperand(); + StringClause.Operand stringClauseOperand = getStringClauseOperand(operand); + stringClause.setOperand(stringClauseOperand); - stringClause.setValue(letteringCondition.getValue()); + stringClause.setValue(letteringCondition.getValue()); - stringClause.setSensitiveCase(letteringCondition.isSensitiveCase()); + stringClause.setSensitiveCase(letteringCondition.isSensitiveCase()); - entryClauses.add(stringClause); + entryClauses.add(stringClause); + } + } @Override public void visitAccountCondition(AccountCondition accountCondition) { - getEntryFilter(); - SubFilterClause subFilterClause = entryFilter.newAccountFilterClause(); - AccountFilter accountFilter = (AccountFilter) subFilterClause.getSubFilter(); - StringClause stringClause = accountFilter.newAccountNumberClause(); - stringClause.setOperand(StringClause.Operand.BEGIN); - Account account = accountCondition.getAccount(); - stringClause.setValue(account.getAccountNumber()); + if (accountCondition != null + && accountCondition.getAccount() != null + && accountCondition.getAccount().getAccountNumber() != null){ + getEntryFilter(); + SubFilterClause subFilterClause = entryFilter.newAccountFilterClause(); + AccountFilter accountFilter = (AccountFilter) subFilterClause.getSubFilter(); + StringClause stringClause = accountFilter.newAccountNumberClause(); + stringClause.setOperand(StringClause.Operand.BEGIN); + Account account = accountCondition.getAccount(); + stringClause.setValue(account.getAccountNumber()); - accountFilter.setClause(stringClause); - entryClauses.add(subFilterClause); + accountFilter.setClause(stringClause); + entryClauses.add(subFilterClause); + } } protected NumberClause.Operand getNumberClauseOperand(AbstractBigDecimalCondition.Operand operand) { - NumberClause.Operand result; - switch (operand) { - case NOT_EQUAL: - result = NumberClause.Operand.NOT_EQUAL; - break; - case LOWER: - result = NumberClause.Operand.LOWER; - break; - case LOWER_OR_EQUAL: - result = NumberClause.Operand.LOWER_OR_EQUAL; - break; - case UPPER: - result = NumberClause.Operand.UPPER; - break; - case UPPER_OR_EQUAL: - result = NumberClause.Operand.UPPER_OR_EQUAL; - break; - case EQUAL: - default: - result = NumberClause.Operand.EQUAL; - break; + NumberClause.Operand result = NumberClause.Operand.EQUAL; + if (operand != null) { + switch (operand) { + case NOT_EQUAL: + result = NumberClause.Operand.NOT_EQUAL; + break; + case LOWER: + result = NumberClause.Operand.LOWER; + break; + case LOWER_OR_EQUAL: + result = NumberClause.Operand.LOWER_OR_EQUAL; + break; + case UPPER: + result = NumberClause.Operand.UPPER; + break; + case UPPER_OR_EQUAL: + result = NumberClause.Operand.UPPER_OR_EQUAL; + break; + case EQUAL: + default: + result = NumberClause.Operand.EQUAL; + break; + } } return result; } @Override public void visitDebitCondition(DebitCondition debitCondition) { - getEntryFilter(); + if (debitCondition != null + && debitCondition.getOperand() != null + && debitCondition.getValue() != null){ + getEntryFilter(); - BooleanClause debitClause = entryFilter.newDebitClause(); + BooleanClause debitClause = entryFilter.newDebitClause(); - NumberClause amountClause = entryFilter.newAmountClause(); + NumberClause amountClause = entryFilter.newAmountClause(); - AbstractBigDecimalCondition.Operand operand = debitCondition.getOperand(); - NumberClause.Operand clauseOperand = getNumberClauseOperand(operand); - amountClause.setOperand(clauseOperand); + AbstractBigDecimalCondition.Operand operand = debitCondition.getOperand(); + NumberClause.Operand clauseOperand = getNumberClauseOperand(operand); + amountClause.setOperand(clauseOperand); - amountClause.setValue(debitCondition.getValue()); + amountClause.setValue(debitCondition.getValue()); - AndClause andClause = new AndClause(); - andClause.add(debitClause); - andClause.add(amountClause); + AndClause andClause = new AndClause(); + andClause.add(debitClause); + andClause.add(amountClause); - entryClauses.add(andClause); + entryClauses.add(andClause); + } } @Override public void visitCreditCondition(CreditCondition creditCondition) { - getEntryFilter(); + if (creditCondition != null && creditCondition.getOperand() != null && creditCondition.getValue() != null) { + getEntryFilter(); - BooleanClause debitClause = entryFilter.newDebitClause(); - NotClause creditClause = new NotClause(); - creditClause.setClause(debitClause); + BooleanClause debitClause = entryFilter.newDebitClause(); + NotClause creditClause = new NotClause(); + creditClause.setClause(debitClause); - NumberClause amountClause = entryFilter.newAmountClause(); + NumberClause amountClause = entryFilter.newAmountClause(); - AbstractBigDecimalCondition.Operand operand = creditCondition.getOperand(); - NumberClause.Operand clauseOperand = getNumberClauseOperand(operand); - amountClause.setOperand(clauseOperand); + AbstractBigDecimalCondition.Operand operand = creditCondition.getOperand(); + NumberClause.Operand clauseOperand = getNumberClauseOperand(operand); + amountClause.setOperand(clauseOperand); - amountClause.setValue(creditCondition.getValue()); + amountClause.setValue(creditCondition.getValue()); - AndClause andClause = new AndClause(); - andClause.add(creditClause); - andClause.add(amountClause); + AndClause andClause = new AndClause(); + andClause.add(creditClause); + andClause.add(amountClause); - entryClauses.add(andClause); + entryClauses.add(andClause); + } + } public FinancialTransactionFilter getFilter() { Modified: trunk/lima-callao/src/main/java/org/chorem/lima/beans/AccountCondition.java =================================================================== --- trunk/lima-callao/src/main/java/org/chorem/lima/beans/AccountCondition.java 2013-10-11 15:17:27 UTC (rev 3711) +++ trunk/lima-callao/src/main/java/org/chorem/lima/beans/AccountCondition.java 2013-10-28 08:11:44 UTC (rev 3712) @@ -44,6 +44,11 @@ } @Override + public boolean validCondition() { + return account != null; + } + + @Override public void accept(VisitorCondition v) { v.visitAccountCondition(this); } Modified: trunk/lima-callao/src/main/java/org/chorem/lima/beans/Condition.java =================================================================== --- trunk/lima-callao/src/main/java/org/chorem/lima/beans/Condition.java 2013-10-11 15:17:27 UTC (rev 3711) +++ trunk/lima-callao/src/main/java/org/chorem/lima/beans/Condition.java 2013-10-28 08:11:44 UTC (rev 3712) @@ -29,5 +29,12 @@ */ public interface Condition { + /** + * Accept the condition if there is benefice to execute it + * @return true if the condition is valid + */ + public boolean validCondition(); + public void accept(VisitorCondition v); + } Modified: trunk/lima-callao/src/main/java/org/chorem/lima/beans/CreditCondition.java =================================================================== --- trunk/lima-callao/src/main/java/org/chorem/lima/beans/CreditCondition.java 2013-10-11 15:17:27 UTC (rev 3711) +++ trunk/lima-callao/src/main/java/org/chorem/lima/beans/CreditCondition.java 2013-10-28 08:11:44 UTC (rev 3712) @@ -30,6 +30,11 @@ public class CreditCondition extends AbstractBigDecimalCondition { @Override + public boolean validCondition() { + return value != null; + } + + @Override public void accept(VisitorCondition v) { v.visitCreditCondition(this); } Modified: trunk/lima-callao/src/main/java/org/chorem/lima/beans/DateCondition.java =================================================================== --- trunk/lima-callao/src/main/java/org/chorem/lima/beans/DateCondition.java 2013-10-11 15:17:27 UTC (rev 3711) +++ trunk/lima-callao/src/main/java/org/chorem/lima/beans/DateCondition.java 2013-10-28 08:11:44 UTC (rev 3712) @@ -59,6 +59,11 @@ } @Override + public boolean validCondition() { + return date != null; + } + + @Override public void accept(VisitorCondition v) { v.visitDateCondition(this); } Modified: trunk/lima-callao/src/main/java/org/chorem/lima/beans/DateIntervalCondition.java =================================================================== --- trunk/lima-callao/src/main/java/org/chorem/lima/beans/DateIntervalCondition.java 2013-10-11 15:17:27 UTC (rev 3711) +++ trunk/lima-callao/src/main/java/org/chorem/lima/beans/DateIntervalCondition.java 2013-10-28 08:11:44 UTC (rev 3712) @@ -53,6 +53,11 @@ } @Override + public boolean validCondition() { + return beginDate != null && endDate != null; + } + + @Override public void accept(VisitorCondition v) { v.visitDateIntervalCondition(this); } Modified: trunk/lima-callao/src/main/java/org/chorem/lima/beans/DebitCondition.java =================================================================== --- trunk/lima-callao/src/main/java/org/chorem/lima/beans/DebitCondition.java 2013-10-11 15:17:27 UTC (rev 3711) +++ trunk/lima-callao/src/main/java/org/chorem/lima/beans/DebitCondition.java 2013-10-28 08:11:44 UTC (rev 3712) @@ -30,6 +30,11 @@ public class DebitCondition extends AbstractBigDecimalCondition { @Override + public boolean validCondition() { + return value != null; + } + + @Override public void accept(VisitorCondition v) { v.visitDebitCondition(this); } Modified: trunk/lima-callao/src/main/java/org/chorem/lima/beans/DescriptionCondition.java =================================================================== --- trunk/lima-callao/src/main/java/org/chorem/lima/beans/DescriptionCondition.java 2013-10-11 15:17:27 UTC (rev 3711) +++ trunk/lima-callao/src/main/java/org/chorem/lima/beans/DescriptionCondition.java 2013-10-28 08:11:44 UTC (rev 3712) @@ -24,6 +24,8 @@ * #L% */ +import org.apache.commons.lang3.StringUtils; + import java.io.Serializable; /** @@ -32,6 +34,11 @@ public class DescriptionCondition extends AbstractStringCondition implements Serializable { @Override + public boolean validCondition() { + return StringUtils.isNotBlank(value); + } + + @Override public void accept(VisitorCondition v) { v.visitDescriptionCondition(this); } Modified: trunk/lima-callao/src/main/java/org/chorem/lima/beans/EntryBookCondition.java =================================================================== --- trunk/lima-callao/src/main/java/org/chorem/lima/beans/EntryBookCondition.java 2013-10-11 15:17:27 UTC (rev 3711) +++ trunk/lima-callao/src/main/java/org/chorem/lima/beans/EntryBookCondition.java 2013-10-28 08:11:44 UTC (rev 3712) @@ -45,6 +45,11 @@ } @Override + public boolean validCondition() { + return entryBooks != null; + } + + @Override public void accept(VisitorCondition v) { v.visitEntryBookCondition(this); } Modified: trunk/lima-callao/src/main/java/org/chorem/lima/beans/FinancialPeriodCondition.java =================================================================== --- trunk/lima-callao/src/main/java/org/chorem/lima/beans/FinancialPeriodCondition.java 2013-10-11 15:17:27 UTC (rev 3711) +++ trunk/lima-callao/src/main/java/org/chorem/lima/beans/FinancialPeriodCondition.java 2013-10-28 08:11:44 UTC (rev 3712) @@ -45,6 +45,11 @@ } @Override + public boolean validCondition() { + return financialPeriods != null; + } + + @Override public void accept(VisitorCondition v) { v.visitFinancialPeriodCondition(this); } Modified: trunk/lima-callao/src/main/java/org/chorem/lima/beans/FinancialTransactionCondition.java =================================================================== --- trunk/lima-callao/src/main/java/org/chorem/lima/beans/FinancialTransactionCondition.java 2013-10-11 15:17:27 UTC (rev 3711) +++ trunk/lima-callao/src/main/java/org/chorem/lima/beans/FinancialTransactionCondition.java 2013-10-28 08:11:44 UTC (rev 3712) @@ -58,6 +58,11 @@ } @Override + public boolean validCondition() { + return true; + } + + @Override public void accept(VisitorCondition v) { v.visitFinancialTransactionCondition(this); } Modified: trunk/lima-callao/src/main/java/org/chorem/lima/beans/FiscalPeriodCondition.java =================================================================== --- trunk/lima-callao/src/main/java/org/chorem/lima/beans/FiscalPeriodCondition.java 2013-10-11 15:17:27 UTC (rev 3711) +++ trunk/lima-callao/src/main/java/org/chorem/lima/beans/FiscalPeriodCondition.java 2013-10-28 08:11:44 UTC (rev 3712) @@ -48,6 +48,11 @@ } @Override + public boolean validCondition() { + return fiscalPeriods != null; + } + + @Override public void accept(VisitorCondition v) { v.visitFiscalPeriodCondition(this); } Modified: trunk/lima-callao/src/main/java/org/chorem/lima/beans/LetteringCondition.java =================================================================== --- trunk/lima-callao/src/main/java/org/chorem/lima/beans/LetteringCondition.java 2013-10-11 15:17:27 UTC (rev 3711) +++ trunk/lima-callao/src/main/java/org/chorem/lima/beans/LetteringCondition.java 2013-10-28 08:11:44 UTC (rev 3712) @@ -24,6 +24,8 @@ * #L% */ +import org.apache.commons.lang3.StringUtils; + import java.io.Serializable; /** @@ -31,6 +33,11 @@ */ public class LetteringCondition extends AbstractStringCondition implements Serializable { @Override + public boolean validCondition() { + return StringUtils.isNotBlank(value); + } + + @Override public void accept(VisitorCondition v) { v.visitLetteringCondition(this); } Modified: trunk/lima-callao/src/main/java/org/chorem/lima/beans/VoucherCondition.java =================================================================== --- trunk/lima-callao/src/main/java/org/chorem/lima/beans/VoucherCondition.java 2013-10-11 15:17:27 UTC (rev 3711) +++ trunk/lima-callao/src/main/java/org/chorem/lima/beans/VoucherCondition.java 2013-10-28 08:11:44 UTC (rev 3712) @@ -24,6 +24,8 @@ * #L% */ +import org.apache.commons.lang3.StringUtils; + import java.io.Serializable; /** @@ -32,6 +34,11 @@ public class VoucherCondition extends AbstractStringCondition implements Serializable { @Override + public boolean validCondition() { + return StringUtils.isNotBlank(value); + } + + @Override public void accept(VisitorCondition v) { v.visitVoucherCondition(this); } Modified: trunk/lima-callao/src/main/java/org/chorem/lima/entity/GeneratorHQuery.java =================================================================== --- trunk/lima-callao/src/main/java/org/chorem/lima/entity/GeneratorHQuery.java 2013-10-11 15:17:27 UTC (rev 3711) +++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/GeneratorHQuery.java 2013-10-28 08:11:44 UTC (rev 3712) @@ -24,6 +24,7 @@ * #L% */ +import org.apache.commons.lang3.StringUtils; import org.chorem.lima.Clause.AndClause; import org.chorem.lima.Clause.BooleanClause; import org.chorem.lima.Clause.Clause; @@ -166,25 +167,30 @@ @Override public void visitDateClause(DateClause dateClause) { - String parameter = addParameter(dateClause.getValue()); - Filter filter = filterStack.peek(); - String alias = aliasMap.get(filter); - String operand = " = " ; - switch (dateClause.getOperand()) { - case SAME: - operand = " = "; - break; - case PREVIOUS: - operand = " <= "; - break; - case AFTER: - operand = " >= "; - break; - case DIFFERENT: - operand = " != "; - break; + if (dateClause != null + && dateClause.getValue() != null) { + String parameter = addParameter(dateClause.getValue()); + Filter filter = filterStack.peek(); + String alias = aliasMap.get(filter); + String operand = " = " ; + switch (dateClause.getOperand()) { + case SAME: + operand = " = "; + break; + case PREVIOUS: + operand = " <= "; + break; + case AFTER: + operand = " >= "; + break; + case DIFFERENT: + operand = " != "; + break; + } + whereClause += alias + "." + dateClause.getProperty() + operand + ":" + parameter; + } else { + whereClause += "1 = 1"; } - whereClause += alias + "." + dateClause.getProperty() + operand + ":" + parameter; } @Override @@ -212,31 +218,35 @@ @Override public void visitNumberClause(NumberClause numberClause) { - String parameter = addParameter(numberClause.getValue()); - Filter filter = filterStack.peek(); - String alias = aliasMap.get(filter); - String operand = " = " ; - switch (numberClause.getOperand()) { - case EQUAL: - operand = " = "; - break; - case NOT_EQUAL: - operand = " != "; - break; - case LOWER: - operand = " < "; - break; - case LOWER_OR_EQUAL: - operand = " <= "; - break; - case UPPER: - operand = " > "; - break; - case UPPER_OR_EQUAL: - operand = " >= "; - break; + if (numberClause != null && numberClause.getValue() != null) { + String parameter = addParameter(numberClause.getValue()); + String operand = " = " ; + Filter filter = filterStack.peek(); + String alias = aliasMap.get(filter); + switch (numberClause.getOperand()) { + case EQUAL: + operand = " = "; + break; + case NOT_EQUAL: + operand = " != "; + break; + case LOWER: + operand = " < "; + break; + case LOWER_OR_EQUAL: + operand = " <= "; + break; + case UPPER: + operand = " > "; + break; + case UPPER_OR_EQUAL: + operand = " >= "; + break; + } + whereClause += alias + "." + numberClause.getProperty() + operand + ":" + parameter; + } else { + whereClause += "1 = 1"; } - whereClause += alias + "." + numberClause.getProperty() + operand + ":" + parameter; } @Override @@ -291,37 +301,39 @@ @Override public void visitStringClause(StringClause stringClause) { - Filter filter = filterStack.peek(); - String alias = aliasMap.get(filter); - String operand = " = " ; String value = stringClause.getValue(); - switch (stringClause.getOperand()) { - case EQUAL: - operand = " = "; - value = stringClause.getValue(); - break; - case NOT_EQUAL: - operand = " != "; - value = stringClause.getValue(); - break; - case BEGIN: - operand = " LIKE "; - value = stringClause.getValue() + "%"; - break; - case ENDING: - operand = " LIKE "; - value = "%" + stringClause.getValue(); - break; - case CONTAIN: - operand = " LIKE "; - value = "%" + stringClause.getValue()+ "%"; - break; + if (StringUtils.isNotBlank(value)) { + Filter filter = filterStack.peek(); + String alias = aliasMap.get(filter); + String operand = " = " ; + switch (stringClause.getOperand()) { + case EQUAL: + operand = " = "; + value = stringClause.getValue(); + break; + case NOT_EQUAL: + operand = " != "; + value = stringClause.getValue(); + break; + case BEGIN: + operand = " LIKE "; + value = stringClause.getValue() + "%"; + break; + case ENDING: + operand = " LIKE "; + value = "%" + stringClause.getValue(); + break; + case CONTAIN: + operand = " LIKE "; + value = "%" + stringClause.getValue()+ "%"; + break; + } + if (stringClause.isSensitiveCase()) { + whereClause += alias + "." + stringClause.getProperty() + operand + "'" + value + "'"; + } else { + whereClause += "lower(" + alias + "." + stringClause.getProperty() + ")" + operand + "'" + value.toLowerCase() + "'"; + } } - if (stringClause.isSensitiveCase()) { - whereClause += alias + "." + stringClause.getProperty() + operand + "'" + value + "'"; - } else { - whereClause += "lower(" + alias + "." + stringClause.getProperty() + ")" + operand + "'" + value.toLowerCase() + "'"; - } } @Override Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/Filter/StringCondition/StringConditionHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/Filter/StringCondition/StringConditionHandler.java 2013-10-11 15:17:27 UTC (rev 3711) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/Filter/StringCondition/StringConditionHandler.java 2013-10-28 08:11:44 UTC (rev 3712) @@ -35,6 +35,7 @@ import java.awt.event.ActionEvent; import java.awt.event.ItemEvent; +import java.awt.event.KeyEvent; /** * @author Sylvain Bavencoff <bavencoff@codelutin.com> @@ -64,7 +65,7 @@ condition.setValue(text); } - public void setText(ActionEvent event) { + public void setText(KeyEvent event) { String text = view.getTextField().getText(); setText(text); } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/Filter/StringCondition/StringConditionView.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/Filter/StringCondition/StringConditionView.jaxx 2013-10-11 15:17:27 UTC (rev 3711) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/Filter/StringCondition/StringConditionView.jaxx 2013-10-28 08:11:44 UTC (rev 3712) @@ -55,7 +55,7 @@ <cell> <JTextField id="textField" text="{handler.getText()}" - onActionPerformed="handler.setText(event)" /> + onKeyReleased="handler.setText(event)" /> </cell> <cell weightx="1" anchor="west"> <JCheckBox id="sensitiveCaseCheckBox" Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchViewHandler.java 2013-10-11 15:17:27 UTC (rev 3711) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchViewHandler.java 2013-10-28 08:11:44 UTC (rev 3712) @@ -157,8 +157,8 @@ public void refresh() { FinancialTransactionDefaultTable table = view.getFinancialTransactionSearchTable(); table.exit(); - FinancialTransactionConditionView ConditionView = view.getFinancialTransactionConditionView(); - FinancialTransactionConditionHandler conditionHandler = ConditionView.getHandler(); + FinancialTransactionConditionView conditionView = view.getFinancialTransactionConditionView(); + FinancialTransactionConditionHandler conditionHandler = conditionView.getHandler(); FinancialTransactionCondition condition= conditionHandler.getFilter(); tableModel = view.getFinancialTransactionSearchTableModel(); if (tableModel != null) { Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/TypeEntry.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/TypeEntry.java 2013-10-11 15:17:27 UTC (rev 3711) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/TypeEntry.java 2013-10-28 08:11:44 UTC (rev 3712) @@ -1,5 +1,29 @@ package org.chorem.lima.ui.lettering; +/* + * #%L + * Lima :: Swing + * $Id:$ + * $HeadURL:$ + * %% + * Copyright (C) 2008 - 2013 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 3 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, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + import static org.nuiton.i18n.I18n._; /** Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/TypeEntry.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Property changes on: trunk/lima-swing/src/main/resources/icons/action-choose-entry.png ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Property changes on: trunk/lima-swing/src/main/resources/icons/action-un-lettering.png ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL
participants (1)
-
dcosse@users.chorem.org