001: /*
002: * Copyright (c) 2002-2003 by OpenSymphony
003: * All rights reserved.
004: */
005: package com.opensymphony.workflow.query;
006:
007: /**
008: * Field expressions are used when constructing a workflow query on the fields
009: * of persistent workflow instances like (START_DATE, OWNER,....).
010: * Field expressions have three attributes. These are:
011: * <li>operator: This is the operator to apply on the expression.
012: * <li>field: The workflow field to test agains
013: * <li>Context: The context to search in, which can be one history, current steps, or a workflow instance.
014: *
015: * @author Christine Zimmermann
016: */
017: public class FieldExpression extends Expression {
018: //~ Static fields/initializers /////////////////////////////////////////////
019:
020: // field operators
021:
022: /**
023: * Constant for the equality operator.
024: */
025: public final static int EQUALS = 1;
026:
027: /**
028: * Constant for the less than operator.
029: */
030: public final static int LT = 2;
031:
032: /**
033: * Constant for the greater than operator.
034: */
035: public final static int GT = 3;
036:
037: /**
038: * Constant for the not equals operator.
039: */
040: public final static int NOT_EQUALS = 5;
041:
042: // fields
043:
044: /**
045: * Constant for the workflow owner field.
046: */
047: public final static int OWNER = 1;
048:
049: /**
050: * Constant for the workflow start date field.
051: */
052: public final static int START_DATE = 2;
053:
054: /**
055: * Constant for the workflow finish date field.
056: */
057: public final static int FINISH_DATE = 3;
058:
059: /**
060: * Constant for the workflow action field.
061: */
062: public final static int ACTION = 4;
063:
064: /**
065: * Constant for the workflow step field.
066: */
067: public final static int STEP = 5;
068:
069: /**
070: * Constant for the workflow caller field.
071: */
072: public final static int CALLER = 6;
073:
074: /**
075: * Constant for the workflow status field.
076: */
077: public final static int STATUS = 7;
078:
079: /**
080: * Constant for the workflow name field.
081: */
082: public final static int NAME = 8;
083:
084: /**
085: * Constant for the state field.
086: */
087: public final static int STATE = 9;
088:
089: /**
090: * Constant for the workflow due date field.
091: */
092: public final static int DUE_DATE = 10;
093:
094: // field context
095:
096: /**
097: * Constant for the history steps context.
098: * Specifying this context means that the search
099: * should be performed against the workflow steps.
100: */
101: public final static int HISTORY_STEPS = 1;
102:
103: /**
104: * Constant for the history steps context.
105: * Specifying this context means that the search
106: * should be performed against the workflow current steps.
107: */
108: public final static int CURRENT_STEPS = 2;
109:
110: /**
111: * Constant for the workflow entry context.
112: * Specifying this context means that the search
113: * should be performed against the workflow entries.
114: */
115: public final static int ENTRY = 3;
116:
117: //~ Instance fields ////////////////////////////////////////////////////////
118:
119: private Object value;
120: private int context;
121: private int field;
122: private int operator;
123:
124: //~ Constructors ///////////////////////////////////////////////////////////
125:
126: public FieldExpression() {
127: }
128:
129: public FieldExpression(int field, int context, int operator,
130: Object value) {
131: this .context = context;
132: this .operator = operator;
133: this .field = field;
134: this .value = value;
135: }
136:
137: public FieldExpression(int field, int context, int operator,
138: Object value, boolean negate) {
139: this (field, context, operator, value);
140: super .negate = negate;
141: }
142:
143: //~ Methods ////////////////////////////////////////////////////////////////
144:
145: public void setContext(int context) {
146: this .context = context;
147: }
148:
149: public int getContext() {
150: return context;
151: }
152:
153: public void setField(int field) {
154: this .field = field;
155: }
156:
157: public int getField() {
158: return field;
159: }
160:
161: public boolean isNested() {
162: return false;
163: }
164:
165: public void setOperator(int operator) {
166: this .operator = operator;
167: }
168:
169: public int getOperator() {
170: return operator;
171: }
172:
173: public void setValue(Object value) {
174: this .value = value;
175: }
176:
177: public Object getValue() {
178: return value;
179: }
180: }
|