KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > shark > expressionbuilders > AssignmentIteratorExpressionBuilderDODS


1 /* AssignmentIteratorExpressionBuilderDODS.java */
2
3 package org.enhydra.shark.expressionbuilders;
4
5 import java.util.Properties JavaDoc;
6
7 import org.enhydra.shark.api.common.AssignmentIteratorExpressionBuilder;
8 import org.enhydra.shark.api.common.SharkConstants;
9
10 /**
11  * AssignmentIteratorExpressionBuilderDODS
12  *
13  * @author V.Puskas
14  * @version 0.21
15  */

16 public class AssignmentIteratorExpressionBuilderDODS extends BasicExpressionBuilder implements
17       AssignmentIteratorExpressionBuilder {
18    private static final String JavaDoc sqlUsername = " ResourceId ";
19    private static final String JavaDoc sqlProcessId = " ActivityProcessId ";
20
21    public AssignmentIteratorExpressionBuilderDODS(Properties JavaDoc p) {
22       super(p);
23    }
24
25    public AssignmentIteratorExpressionBuilder and() {
26       this.operator = AND_OPERATOR;
27       return this;
28    }
29
30    public AssignmentIteratorExpressionBuilder or() {
31       this.operator = OR_OPERATOR;
32       return this;
33    }
34
35    public AssignmentIteratorExpressionBuilder not() {
36       this.operator |= NOT_OPERATOR;
37       return this;
38    }
39
40    public AssignmentIteratorExpressionBuilder addUsernameEquals(String JavaDoc un) {
41       addEqualsWithSubQuery(SharkConstants.ASS_RESOURCE_USERNAME, " TheResource ", "IN (select "
42             + objectid_column_name + " from ResourcesTable where Username = ", un, ") ");
43       return this;
44    }
45
46    public AssignmentIteratorExpressionBuilder addProcessIdEquals(String JavaDoc pid) {
47       addEqualsWithSubQuery(SharkConstants.ASS_PROCESS_ID, " Activity ", "IN (select "
48             + objectid_column_name + " from Activities where " + "ProcessId = ", pid, ")) ");
49       return this;
50    }
51
52    public AssignmentIteratorExpressionBuilder addIsAccepted() {
53       String JavaDoc javaName = SharkConstants.ASS_ACCEPTED;
54       String JavaDoc sqlName = " Activity ";
55       String JavaDoc sqlInPart = "IN (select "
56          + objectid_column_name
57          + " from Activities where "
58          + "TheResource IS NOT NULL";
59       String JavaDoc sqlEndPart = ") ";
60
61       char _notPrecedes = appendOperator(true);
62       this.bshExpression.add(_notPrecedes + javaName + ".booleanValue()");
63       this.sqlExpression.add(sqlName
64             + (' ' == _notPrecedes ? "" : "NOT ")
65             + sqlInPart
66             + sqlEndPart);
67       if (!this.propertiesUsed.contains(javaName)) {
68          this.propertiesUsed.add(javaName);
69       }
70
71       return this;
72    }
73
74    public AssignmentIteratorExpressionBuilder addPackageIdEquals(String JavaDoc un) {
75       addEqualsWithSubQuery(SharkConstants.ASS_PACKAGE_ID, " Activity ", "IN (select "
76             + objectid_column_name + " from Activities where " + "Process IN (select "
77             + objectid_column_name + " from Processes where " + "ProcessDefinition IN (select "
78             + objectid_column_name + " from ProcessDefinitions where PackageId = ", un, "))) ");
79       return this;
80    }
81
82    public AssignmentIteratorExpressionBuilder addPackageVersionEquals(String JavaDoc un) {
83       addEqualsWithSubQuery(SharkConstants.ASS_PACKAGE_VERSION, " Activity ", "IN (select "
84             + objectid_column_name + " from Activities where " + "Process IN (select "
85             + objectid_column_name + " from Processes where " + "ProcessDefinition IN (select "
86             + objectid_column_name + " from ProcessDefinitions where ProcessDefinitionVersion = ",
87             un, "))) ");
88       return this;
89    }
90
91    public AssignmentIteratorExpressionBuilder addProcessDefIdEquals(String JavaDoc un) {
92       addEqualsWithSubQuery(SharkConstants.ASS_PROCESS_DEFINITION_ID, " Activity ", "IN (select "
93             + objectid_column_name + " from Activities where " + "Process IN (select "
94             + objectid_column_name + " from Processes where " + "ProcessDefinition IN (select "
95             + objectid_column_name + " from ProcessDefinitions where ProcessDefinitionId = ", un,
96             "))) ");
97       return this;
98    }
99
100    public AssignmentIteratorExpressionBuilder addActivitySetDefIdEquals(String JavaDoc un) {
101       addEqualsWithSubQuery(SharkConstants.ASS_ACTIVITY_SET_DEFINITION_ID, " Activity ",
102             "IN (select " + objectid_column_name
103                   + " from Activities where ActivitySetDefinitionId = ", un, ") ");
104       return this;
105    }
106
107    public AssignmentIteratorExpressionBuilder addActivityDefIdEquals(String JavaDoc un) {
108       addEqualsWithSubQuery(SharkConstants.ASS_ACTIVITY_DEFINITION_ID, " Activity ", "IN (select "
109             + objectid_column_name + " from Activities where ActivityDefinitionId = ", un, ") ");
110       return this;
111    }
112
113    public AssignmentIteratorExpressionBuilder addActivityIdEquals(String JavaDoc un) {
114       addEqualsWithSubQuery(SharkConstants.ASS_ACTIVITY_DEFINITION_ID,
115                             " Activity ",
116                             "IN (select "
117                             + objectid_column_name
118                             + " from Activities where Id = ",
119                             un,
120                            ") ");
121       return this;
122    }
123
124    public AssignmentIteratorExpressionBuilder addExpression(String JavaDoc exp) {
125       sqlComplete = false;
126       appendOperator(false);
127       this.bshExpression.add(exp);
128       return this;
129    }
130
131    public AssignmentIteratorExpressionBuilder addExpression(AssignmentIteratorExpressionBuilder eb) {
132       appendOperator(eb.isComplete());
133       this.bshExpression.add(eb);
134       this.sqlExpression.add(eb);
135       sqlComplete |= eb.isComplete();
136       return this;
137    }
138
139    public AssignmentIteratorExpressionBuilder setOrderByUsername(boolean ascending) {
140       super.setOrderBy(sqlUsername, ascending);
141       return null;
142    }
143
144    public AssignmentIteratorExpressionBuilder setOrderByProcessId(boolean ascending) {
145       super.setOrderBy(sqlProcessId, ascending);
146       return null;
147    }
148
149    public AssignmentIteratorExpressionBuilder setOrderByCreatedTime(boolean ascending) {
150       super.setOrderBy(super.objectid_column_name, ascending);
151       return null;
152    }
153
154    public AssignmentIteratorExpressionBuilder setOrderByAccepted(boolean ascending) {
155       super.setOrderBy(" IsAccepted ", ascending);
156       return null;
157    }
158 }
Popular Tags