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