001: /*
002: * Copyright 2002-2005 the original author or authors.
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016:
017: package info.jtrac.domain;
018:
019: import java.io.Serializable;
020: import java.util.List;
021:
022: /**
023: * can possibly be merged into ColumnHeading, but at the moment
024: * hold filter criteria entered by user for search
025: * value = for single values
026: * value2 = second value for "between" kind of queries
027: * values = list of values for multi-select filter criteria
028: */
029: public class FilterCriteria implements Serializable {
030:
031: public enum Expression {
032: IN("in"), NOT_IN("notIn"), CONTAINS("like"), EQ("equal"), NOT_EQ(
033: "notEqual"), GT("greaterThan"), LT("lessThan"), BETWEEN(
034: "between");
035:
036: private String key;
037:
038: Expression(String key) {
039: this .key = key;
040: }
041:
042: public String getKey() {
043: return key;
044: }
045: }
046:
047: private Expression expression;
048: private List values;
049: private Object value;
050: private Object value2;
051:
052: private Expression previousExpression;
053:
054: public Expression getExpression() {
055: return expression;
056: }
057:
058: public void setExpression(Expression expression) {
059: previousExpression = this .expression;
060: this .expression = expression;
061: if (expression == null) {
062: values = null;
063: value = null;
064: value2 = null;
065: }
066: }
067:
068: public boolean requiresUiFragmentUpdate() {
069: if (expression != null && previousExpression != null) {
070: if (expression == Expression.BETWEEN
071: || previousExpression == Expression.BETWEEN) {
072: return true;
073: } else {
074: return false;
075: }
076: }
077: return true;
078: }
079:
080: public Object getValue() {
081: return value;
082: }
083:
084: public void setValue(Object value) {
085: this .value = value;
086: }
087:
088: public Object getValue2() {
089: return value2;
090: }
091:
092: public void setValue2(Object value2) {
093: this .value2 = value2;
094: }
095:
096: public List getValues() {
097: return values;
098: }
099:
100: public void setValues(List values) {
101: this .values = values;
102: }
103:
104: @Override
105: public String toString() {
106: StringBuilder sb = new StringBuilder();
107: sb.append("expression [").append(expression);
108: sb.append("]; value [").append(value);
109: sb.append("]; value2 [").append(value2);
110: sb.append("]; values [").append(values);
111: sb.append("]");
112: return sb.toString();
113: }
114:
115: }
|