Lima-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
October 2013
- 2 participants
- 3 discussions
28 Oct '13
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(a)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
1
0
r3711 - in trunk: lima-callao/src/main/java/org/chorem/lima/entity lima-swing/src/main/java/org/chorem/lima/ui/lettering
by Bavencoff@users.chorem.org 11 Oct '13
by Bavencoff@users.chorem.org 11 Oct '13
11 Oct '13
Author: Bavencoff
Date: 2013-10-11 17:17:27 +0200 (Fri, 11 Oct 2013)
New Revision: 3711
Url: http://chorem.org/projects/lima/repository/revisions/3711
Log:
[lettrage] change lettring/un lettring filter
Modified:
trunk/lima-callao/src/main/java/org/chorem/lima/entity/EntryDAOImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTable.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java
Modified: trunk/lima-callao/src/main/java/org/chorem/lima/entity/EntryDAOImpl.java
===================================================================
--- trunk/lima-callao/src/main/java/org/chorem/lima/entity/EntryDAOImpl.java 2013-10-11 13:56:17 UTC (rev 3710)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/EntryDAOImpl.java 2013-10-11 15:17:27 UTC (rev 3711)
@@ -197,12 +197,11 @@
" where E.financialTransaction = F" +
" and E.account.accountNumber like :account ";
- if (filter.getDisplayLettered() || filter.getDisplayUnlettred()){
- if (filter.getDisplayUnlettred()){
- query += " and E.lettering is null";
- }else {
- query += " and E.lettering is not null";
- }
+
+ if (!filter.getDisplayLettered() && filter.getDisplayUnlettred()){
+ query += " and E.lettering is null";
+ } else if (filter.getDisplayLettered() && !filter.getDisplayUnlettred()){
+ query += " and E.lettering is not null";
}
query += " and E.financialTransaction.transactionDate between :beginDate and :endDate " +
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTable.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTable.java 2013-10-11 13:56:17 UTC (rev 3710)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTable.java 2013-10-11 15:17:27 UTC (rev 3711)
@@ -70,7 +70,7 @@
actionMap.put(binding, new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
- handler.addLetter();
+ handler.addLetter();
}
});
@@ -94,7 +94,18 @@
}
});
+ // refresh
+ binding = "refresh";
+ inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_F5, 0), binding);
+ actionMap.put(binding, new AbstractAction() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ handler.updateAllEntries();
+ }
+ });
+
+
//Get new date editor
setDefaultEditor(Date.class, new DateTableCellEditor());
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringView.jaxx 2013-10-11 13:56:17 UTC (rev 3710)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringView.jaxx 2013-10-11 15:17:27 UTC (rev 3711)
@@ -32,14 +32,11 @@
org.chorem.lima.entity.Account
javax.swing.ListSelectionModel
org.jdesktop.swingx.JXDatePicker
- org.chorem.lima.beans.LetteringFilter
- org.chorem.lima.beans.LetteringFilterImpl
</import>
<LetteringViewHandler id="handler" constructorParams="this"/>
<LetteringTableModel id="tableModel"/>
- <LetteringFilterImpl id='filterModel' initializer='new LetteringFilterImpl()'/>
<LetteringEditModel id='editModel'/>
<LettringSelectionModel id='lettringSelectionModel' constructorParams=' tableModel'
@@ -84,7 +81,7 @@
model="{accountComboBoxModel}"
toolTipText="lima.ui.lettering.account"
renderer="{new org.chorem.lima.ui.common.AccountListRenderer()}"
- onItemStateChanged="filterModel.setAccount((Account)accountComboBoxModel.getSelectedItem())" />
+ onItemStateChanged="handler.setAccount((Account)accountComboBoxModel.getSelectedItem())" />
<JButton id="back" actionIcon="previous"
toolTipText="lima.ui.account.buttonback"
onActionPerformed="handler.back(accountComboBox)"/>
@@ -97,12 +94,12 @@
<JLabel text="lima.ui.lettering.beginFinancialPeriod"
labelFor='{pickerDebut}'/>
<JXDatePicker id="pickerDebut"
- onActionPerformed="filterModel.setDateStart(pickerDebut.getDate())"/>
+ onActionPerformed="handler.setDateStart(pickerDebut.getDate())"/>
<JLabel text="lima.ui.lettering.endFinancialPeriod"
labelFor="{pickerFin}"/>
<JXDatePicker id="pickerFin"
- onActionPerformed="filterModel.setDateEnd(pickerFin.getDate())"/>
+ onActionPerformed="handler.setDateEnd(pickerFin.getDate())"/>
<JToolBar.Separator/>
@@ -112,7 +109,7 @@
genericType='TypeEntry'
constructorParams='TypeEntry.class'
toolTipText="lima.ui.lettering.entry"
- onItemStateChanged="filterModel.setDisplayLettered(lettredEntryComboBox.getSelectedItem().isLettered()) ; filterModel.setDisplayUnlettred(lettredEntryComboBox.getSelectedItem().isNoLettered()) " />
+ onItemStateChanged="handler.setTypeEntry(lettredEntryComboBox.getSelectedItem())" />
<JToolBar.Separator/>
@@ -165,4 +162,4 @@
</JScrollPane>
</cell>
</row>
-</Table>
\ No newline at end of file
+</Table>
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java 2013-10-11 13:56:17 UTC (rev 3710)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java 2013-10-11 15:17:27 UTC (rev 3711)
@@ -40,9 +40,7 @@
import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.service.LimaServiceFactory;
-import javax.swing.JComboBox;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
+import javax.swing.*;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Calendar;
@@ -78,6 +76,7 @@
protected BigDecimal solde = BigDecimal.ZERO;
protected LettringSelectionModel lettringSelectionModel;
protected LetteringEditModel editModel;
+
protected enum ButtonMode {DELETTRED, LETTRED, EQUALIZED, ALL}
private static final Log log = LogFactory.getLog(LetteringViewHandler.class);
@@ -94,18 +93,10 @@
* Init all combo box in view.
*/
public void init() {
- filter = view.getFilterModel();
+ filter = new LetteringFilterImpl();
editModel = view.getEditModel();
lettringSelectionModel = view.getLettringSelectionModel();
loadComboAndRows();
-
- filter.addPropertyChangeListener(new PropertyChangeListener() {
-
- @Override
- public void propertyChange(PropertyChangeEvent evt) {
- updateAllEntries();
- }
- });
}
public void balanceAndActions() {
@@ -302,9 +293,30 @@
return null;
}
+ public void setDateStart(Date date) {
+ filter.setDateStart(date);
+ updateAllEntries();
+ }
+
+ public void setDateEnd(Date date) {
+ filter.setDateEnd(date);
+ updateAllEntries();
+ }
+
+ public void setAccount(Account account) {
+ filter.setAccount(account);
+ updateAllEntries();
+ }
+
+ public void setTypeEntry(TypeEntry typeEntry) {
+ filter.setDisplayLettered(typeEntry.isLettered());
+ filter.setDisplayUnlettred(typeEntry.isNoLettered());
+ updateAllEntries();
+ }
+
public void updateAllEntries() {
- if (isFilterValid()) {
+ if (filter.getAccount() != null && filter.getDateStart() != null && filter.getDateEnd() != null) {
List<Entry> entries = findAllEntries(filter);
List<String> journalEntrees = new ArrayList<String>();
@@ -356,19 +368,6 @@
}
}
- /**To test if the filter contain an account and a period
- * @return true if filter is valid
- * */
- protected boolean isFilterValid() {
- boolean valid = false;
-
- if (filter.getAccount() != null && filter.getDateStart() != null && filter.getDateEnd() != null) {
- valid = true;
- }
-
- return valid;
- }
-
/**
* Select previous value in combo box.
*
1
0
r3710 - in trunk/lima-business/src: main/java/org/chorem/lima/business/ejb main/java/org/chorem/lima/business/utils test/java/org/chorem/lima/business
by Bavencoff@users.chorem.org 11 Oct '13
by Bavencoff@users.chorem.org 11 Oct '13
11 Oct '13
Author: Bavencoff
Date: 2013-10-11 15:56:17 +0200 (Fri, 11 Oct 2013)
New Revision: 3710
Url: http://chorem.org/projects/lima/repository/revisions/3710
Log:
refs #735 : [lettrage]Mauvaise incr?\195?\169mentation des lettres
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/utils/LetteringComparator.java
trunk/lima-business/src/test/java/org/chorem/lima/business/FinancialTransactionServiceImplTest.java
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2013-09-27 14:03:11 UTC (rev 3709)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2013-10-11 13:56:17 UTC (rev 3710)
@@ -25,6 +25,9 @@
package org.chorem.lima.business.ejb;
+import com.google.common.base.Predicate;
+import com.google.common.collect.Collections2;
+import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.Filter.FilterGenerator;
@@ -58,6 +61,7 @@
import javax.ejb.TransactionAttribute;
import java.math.BigDecimal;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.List;
@@ -149,49 +153,37 @@
throw new LimaException("Can't get new letters", ex);
}
- /**Increment letter alphabetically*/
- int indexCharToIncrement = 0;
- int lastActualLettersLength = lastActualLetters.length();
- String findLastLetters;
- String findFirstLetters ="";
- int numberOfA;
+ nextLetters = lettersAfter(lastActualLetters);
- /*Searching which letter is 'Z', and so must be incremented*/
- for (int i = 0; i < lastActualLettersLength; i++) {
- if (lastActualLetters.charAt(i) != 'Z') {
- indexCharToIncrement = i;
- }
- }
+ return nextLetters;
+ }
- /*When no letter, just set 'A'*/
- if (lastActualLettersLength != 0) {
- /*Get first letter(s), only if we have more of one letter (One letter = letter to increment)*/
- String firstPartActualLetters = lastActualLetters.substring(0, indexCharToIncrement);
- if (firstPartActualLetters.length() > 1) {
- findFirstLetters = firstPartActualLetters;
- }
+ public static String lettersAfter(String letters) {
- /*Get the letters after the correct letter to increment and
- *increment it (Using 'indexCharToIncrement')
- * */
- findLastLetters = lastActualLetters.substring(indexCharToIncrement+1, lastActualLettersLength);
- if (lastActualLetters.charAt(indexCharToIncrement) != 'Z') {
- /*Last letters transform to x 'A' (x = Number of 'Z'), if they are 'Z'*/
- if (findLastLetters.length() > 0) {
- if (findLastLetters.charAt(0) == 'Z') {
- numberOfA = findLastLetters.length();
- findLastLetters=getCharsA(numberOfA);
- }
- }
- nextLetters = findFirstLetters + String.valueOf( (char) (lastActualLetters.charAt(indexCharToIncrement) + 1)) + findLastLetters;
- }
+ String letterAfter = null;
+ /* "" -> "A" */
+ if (StringUtils.isEmpty(letters)) {
+
+ letterAfter = "A";
+
} else {
- numberOfA = lastActualLettersLength +1;
- nextLetters = getCharsA(numberOfA);
+ char endChar = letters.charAt(letters.length() - 1);
+
+ if (endChar < 'Z') {
+
+ /* si la lettre n'est pas un 'Z' on ajout a la reste de la chaine le caratère suivant */
+ letterAfter = letters.substring(0, letters.length() -1) + ((char) (endChar + 1));
+ } else {
+ /* si non on réitére sur le reste de la chaine en ajoutant "A" a la nouvelle chaine */
+ letterAfter = lettersAfter(letters.substring(0, letters.length() -1)) + 'A';
+
+ }
+
}
- return nextLetters;
+ return letterAfter;
+
}
@Override
@@ -320,26 +312,24 @@
costOrProductEntry.setAccount(costOrProductAccount);
}
- protected String getCharsA(int numberOfA) {
- String charsA="";
- for (int j = 0; j < numberOfA; j++) {
- charsA = charsA+"A";
- }
- return charsA;
- }
-
public String findLastLetter(List<String> letters) {
String result;
- Collections.sort(letters, new LetteringComparator());
- Collections.reverse(letters);
+ /** filtre sur les valeurs potentiellement généré */
+ Collection<String> generatedLetters = Collections2.filter(letters, new Predicate<String>() {
+ @Override
+ public boolean apply(String input) {
+ return input != null &&
+ input.matches("[A-Z]+");
+ }
+ });
- if (letters.isEmpty()) {
+ if (generatedLetters.isEmpty()) {
result = "";
} else {
- result = letters.get(0);
+ result = Collections.max(generatedLetters, new LetteringComparator());
}
return result;
}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/utils/LetteringComparator.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/utils/LetteringComparator.java 2013-09-27 14:03:11 UTC (rev 3709)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/utils/LetteringComparator.java 2013-10-11 13:56:17 UTC (rev 3710)
@@ -35,16 +35,16 @@
int lengthFirstString = firstString.length();
int lengthSecondString = secondString.length();
+ int result = 0;
+
if (lengthFirstString < lengthSecondString) {
- return -1;
+ result = -1;
} else if (lengthFirstString > lengthSecondString) {
- return 1;
+ result = 1;
} else {
- if (firstString.charAt(0) < secondString.charAt(0)) {
- return -1;
- } else {
- return 1;
- }
+ result = firstString.compareTo(secondString);
}
+
+ return result;
}
}
Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/FinancialTransactionServiceImplTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/FinancialTransactionServiceImplTest.java 2013-09-27 14:03:11 UTC (rev 3709)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/FinancialTransactionServiceImplTest.java 2013-10-11 13:56:17 UTC (rev 3710)
@@ -37,6 +37,7 @@
import java.math.BigDecimal;
import java.text.ParseException;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -146,20 +147,31 @@
}
@Test
+ public void testLettersAfter() {
+
+ Assert.assertEquals("A", FinancialTransactionServiceImpl.lettersAfter(null));
+ Assert.assertEquals("A", FinancialTransactionServiceImpl.lettersAfter(""));
+ Assert.assertEquals("E", FinancialTransactionServiceImpl.lettersAfter("D"));
+ Assert.assertEquals("AA", FinancialTransactionServiceImpl.lettersAfter("Z"));
+ Assert.assertEquals("ASDGUAAAA", FinancialTransactionServiceImpl.lettersAfter("ASDGTZZZZ"));
+
+ }
+
+ @Test
public void testFindLastLetter() {
- List<String> letters = Arrays.asList("A", "BZ", "ZZZ", "C", "Z", "E");
-
FinancialTransactionServiceImpl instance = new FinancialTransactionServiceImpl();
- String nextLetter = instance.findLastLetter(letters);
+ String nextLetter = instance.findLastLetter(Arrays.asList("A", "BZ", "ZZZ", "C", "Z", "E"));
Assert.assertEquals("ZZZ", nextLetter);
- Assert.assertEquals("A", letters.get(5));
- Assert.assertEquals("C", letters.get(4));
- Assert.assertEquals("E", letters.get(3));
- Assert.assertEquals("Z", letters.get(2));
- Assert.assertEquals("BZ", letters.get(1));
- Assert.assertEquals("ZZZ", letters.get(0));
+ nextLetter = instance.findLastLetter(Arrays.asList("sfvq", "sfvr"));
+ Assert.assertEquals("", nextLetter);
+
+ nextLetter = instance.findLastLetter(Arrays.asList("zzz", "ABC", "DEF"));
+ Assert.assertEquals("DEF", nextLetter);
+
+ nextLetter = instance.findLastLetter(new ArrayList<String>());
+ Assert.assertEquals("", nextLetter);
}
}
1
0