001: package org.enhydra.shark.corba;
002:
003: import javax.transaction.UserTransaction;
004:
005: import org.omg.WfBase.*;
006: import org.omg.WorkflowModel.WfProcess;
007: import org.omg.WorkflowModel._WfProcessIteratorImplBase;
008:
009: /**
010: * Iterator for process managers processes.
011: *
012: * @author Sasa Bojanic
013: * @version 1.0
014: */
015: public class WfProcessIteratorCORBA extends _WfProcessIteratorImplBase {
016:
017: org.enhydra.shark.api.client.wfmodel.WfProcessIterator myIterator;
018:
019: private Collective __collective;
020:
021: protected WfProcessIteratorCORBA(Collective toJoin,
022: org.enhydra.shark.api.client.wfmodel.WfProcessIterator iter)
023: throws BaseException {
024: __collective = toJoin;
025: toJoin.__recruit(this );
026: this .myIterator = iter;
027: }
028:
029: public String query_expression() throws BaseException {
030: UserTransaction ut = null;
031: boolean e = SharkCORBAServer.doesTransactionExist();
032: try {
033: ut = SharkCORBAUtilities.beginTransaction(e);
034: String ret = myIterator.query_expression();
035: SharkCORBAUtilities.commitTransaction(ut, e);
036: return ret;
037: } catch (Exception ex) {
038: SharkCORBAUtilities.rollbackTransaction(ut, e);
039: throw new BaseException();
040: }
041: }
042:
043: /**
044: * The following names may be used in queries: processDefinitionId, key, name,
045: * priority, description, state. Also the names of process context variables can be
046: * used, but the "context_" prefix should be placed before variable Id, i.e.
047: * "context_myvariable".
048: */
049: public void set_query_expression(String query)
050: throws BaseException, InvalidQuery {
051: UserTransaction ut = null;
052: boolean e = SharkCORBAServer.doesTransactionExist();
053: try {
054: ut = SharkCORBAUtilities.beginTransaction(e);
055: myIterator.set_query_expression(query);
056: SharkCORBAUtilities.commitTransaction(ut, e);
057: } catch (org.enhydra.shark.api.client.wfbase.InvalidQuery iq) {
058: SharkCORBAUtilities.rollbackTransaction(ut, e);
059: throw new InvalidQuery();
060: } catch (Exception ex) {
061: SharkCORBAUtilities.rollbackTransaction(ut, e);
062: throw new BaseException();
063: }
064: }
065:
066: public NameValue[] names_in_expression() throws BaseException {
067: UserTransaction ut = null;
068: boolean e = SharkCORBAServer.doesTransactionExist();
069: try {
070: ut = SharkCORBAUtilities.beginTransaction(e);
071: NameValue[] ret = SharkCORBAUtilities
072: .makeCORBANameValueArray(this ._orb(), myIterator
073: .names_in_expression());
074: SharkCORBAUtilities.commitTransaction(ut, e);
075: return ret;
076: } catch (Exception ex) {
077: SharkCORBAUtilities.rollbackTransaction(ut, e);
078: throw new BaseException();
079: }
080: }
081:
082: public void set_names_in_expression(NameValue[] query)
083: throws BaseException, NameMismatch {
084: UserTransaction ut = null;
085: boolean e = SharkCORBAServer.doesTransactionExist();
086: try {
087: ut = SharkCORBAUtilities.beginTransaction(e);
088: myIterator.set_names_in_expression(SharkCORBAUtilities
089: .makeMap(query));
090: SharkCORBAUtilities.commitTransaction(ut, e);
091: } catch (org.enhydra.shark.api.client.wfbase.NameMismatch nm) {
092: SharkCORBAUtilities.rollbackTransaction(ut, e);
093: throw new NameMismatch();
094: } catch (Exception ex) {
095: SharkCORBAUtilities.rollbackTransaction(ut, e);
096: throw new BaseException();
097: }
098: }
099:
100: public String query_grammar() throws BaseException {
101: UserTransaction ut = null;
102: boolean e = SharkCORBAServer.doesTransactionExist();
103: try {
104: ut = SharkCORBAUtilities.beginTransaction(e);
105: String ret = myIterator.query_grammar();
106: SharkCORBAUtilities.commitTransaction(ut, e);
107: return ret;
108: } catch (Exception ex) {
109: SharkCORBAUtilities.rollbackTransaction(ut, e);
110: throw new BaseException();
111: }
112: }
113:
114: public void set_query_grammar(String query_grammmar)
115: throws BaseException, GrammarNotSupported {
116: UserTransaction ut = null;
117: boolean e = SharkCORBAServer.doesTransactionExist();
118: try {
119: ut = SharkCORBAUtilities.beginTransaction(e);
120: myIterator.set_query_grammar(query_grammmar);
121: SharkCORBAUtilities.commitTransaction(ut, e);
122: } catch (org.enhydra.shark.api.client.wfbase.GrammarNotSupported gns) {
123: SharkCORBAUtilities.rollbackTransaction(ut, e);
124: throw new GrammarNotSupported();
125: } catch (Exception ex) {
126: SharkCORBAUtilities.rollbackTransaction(ut, e);
127: throw new BaseException();
128: }
129: }
130:
131: public int how_many() throws BaseException {
132: UserTransaction ut = null;
133: boolean e = SharkCORBAServer.doesTransactionExist();
134: try {
135: ut = SharkCORBAUtilities.beginTransaction(e);
136: int ret = myIterator.how_many();
137: SharkCORBAUtilities.commitTransaction(ut, e);
138: return ret;
139: } catch (Exception ex) {
140: SharkCORBAUtilities.rollbackTransaction(ut, e);
141: throw new BaseException();
142: }
143: }
144:
145: public void goto_start() throws BaseException {
146: UserTransaction ut = null;
147: boolean e = SharkCORBAServer.doesTransactionExist();
148: try {
149: ut = SharkCORBAUtilities.beginTransaction(e);
150: myIterator.goto_start();
151: SharkCORBAUtilities.commitTransaction(ut, e);
152: } catch (Exception ex) {
153: SharkCORBAUtilities.rollbackTransaction(ut, e);
154: throw new BaseException();
155: }
156: }
157:
158: public void goto_end() throws BaseException {
159: UserTransaction ut = null;
160: boolean e = SharkCORBAServer.doesTransactionExist();
161: try {
162: ut = SharkCORBAUtilities.beginTransaction(e);
163: myIterator.goto_end();
164: SharkCORBAUtilities.commitTransaction(ut, e);
165: } catch (Exception ex) {
166: SharkCORBAUtilities.rollbackTransaction(ut, e);
167: throw new BaseException();
168: }
169: }
170:
171: public WfProcess get_next_object() throws BaseException {
172: UserTransaction ut = null;
173: boolean e = SharkCORBAServer.doesTransactionExist();
174: try {
175: ut = SharkCORBAUtilities.beginTransaction(e);
176: WfProcess ret = new WfProcessCORBA(__collective, myIterator
177: .get_next_object());
178: SharkCORBAUtilities.commitTransaction(ut, e);
179: return ret;
180: } catch (Exception ex) {
181: SharkCORBAUtilities.rollbackTransaction(ut, e);
182: throw new BaseException();
183: }
184: }
185:
186: public WfProcess get_previous_object() throws BaseException {
187: UserTransaction ut = null;
188: boolean e = SharkCORBAServer.doesTransactionExist();
189: try {
190: ut = SharkCORBAUtilities.beginTransaction(e);
191: WfProcess ret = new WfProcessCORBA(__collective, myIterator
192: .get_previous_object());
193: SharkCORBAUtilities.commitTransaction(ut, e);
194: return ret;
195: } catch (Exception ex) {
196: SharkCORBAUtilities.rollbackTransaction(ut, e);
197: throw new BaseException();
198: }
199: }
200:
201: public WfProcess[] get_next_n_sequence(int max_number)
202: throws BaseException {
203: UserTransaction ut = null;
204: boolean e = SharkCORBAServer.doesTransactionExist();
205: try {
206: ut = SharkCORBAUtilities.beginTransaction(e);
207: WfProcess[] ret = SharkCORBAUtilities.makeCORBAProcesses(
208: __collective, myIterator
209: .get_next_n_sequence(max_number));
210: SharkCORBAUtilities.commitTransaction(ut, e);
211: return ret;
212: } catch (Exception ex) {
213: SharkCORBAUtilities.rollbackTransaction(ut, e);
214: throw new BaseException();
215: }
216: }
217:
218: public WfProcess[] get_previous_n_sequence(int max_number)
219: throws BaseException {
220: UserTransaction ut = null;
221: boolean e = SharkCORBAServer.doesTransactionExist();
222: try {
223: ut = SharkCORBAUtilities.beginTransaction(e);
224: WfProcess[] ret = SharkCORBAUtilities.makeCORBAProcesses(
225: __collective, myIterator
226: .get_previous_n_sequence(max_number));
227: SharkCORBAUtilities.commitTransaction(ut, e);
228: return ret;
229: } catch (Exception ex) {
230: SharkCORBAUtilities.rollbackTransaction(ut, e);
231: throw new BaseException();
232: }
233: }
234:
235: }
|