001: package org.enhydra.shark.corba;
002:
003: import javax.transaction.UserTransaction;
004:
005: import org.omg.WfBase.BaseException;
006: import org.omg.WorkflowModel.*;
007:
008: /**
009: * WfRequesterImpl - Workflow Requester implementation
010: */
011: public class WfRequesterCORBA extends _WfRequesterImplBase {
012:
013: org.enhydra.shark.api.client.wfmodel.WfRequester reqInternal;
014:
015: private Collective __collective;
016:
017: public WfRequesterCORBA(Collective toJoin,
018: org.enhydra.shark.api.client.wfmodel.WfRequester reqInternal) {
019: __collective = toJoin;
020: toJoin.__recruit(this );
021: this .reqInternal = reqInternal;
022: }
023:
024: /**
025: * Gets the number of processes.
026: */
027: public int how_many_performer() throws BaseException {
028: UserTransaction ut = null;
029: boolean e = SharkCORBAServer.doesTransactionExist();
030: try {
031: ut = SharkCORBAUtilities.beginTransaction(e);
032: int ret = reqInternal.how_many_performer();
033: SharkCORBAUtilities.commitTransaction(ut, e);
034: return ret;
035: } catch (Exception ex) {
036: SharkCORBAUtilities.rollbackTransaction(ut, e);
037: throw new BaseException();
038: }
039: }
040:
041: /**
042: * Gets an iterator of processes.
043: */
044: public WfProcessIterator get_iterator_performer()
045: throws BaseException {
046: UserTransaction ut = null;
047: boolean e = SharkCORBAServer.doesTransactionExist();
048: try {
049: ut = SharkCORBAUtilities.beginTransaction(e);
050: WfProcessIterator ret = new WfProcessIteratorCORBA(
051: __collective, reqInternal.get_iterator_performer());
052: SharkCORBAUtilities.commitTransaction(ut, e);
053: return ret;
054: } catch (Exception ex) {
055: SharkCORBAUtilities.rollbackTransaction(ut, e);
056: throw new BaseException();
057: }
058: }
059:
060: /**
061: * A list of processes
062: *
063: * @return List of WfProcess objects.
064: */
065: public WfProcess[] get_sequence_performer(int max_number)
066: throws BaseException {
067: UserTransaction ut = null;
068: boolean e = SharkCORBAServer.doesTransactionExist();
069: try {
070: ut = SharkCORBAUtilities.beginTransaction(e);
071: WfProcess[] ret = SharkCORBAUtilities.makeCORBAProcesses(
072: __collective, reqInternal
073: .get_sequence_performer(max_number));
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: /**
083: * Checks if a WfProcess is associated with this requester object
084: *
085: * @return true if the process is found.
086: */
087: public boolean is_member_of_performer(WfProcess member)
088: throws BaseException {
089: UserTransaction ut = null;
090: boolean e = SharkCORBAServer.doesTransactionExist();
091: try {
092: ut = SharkCORBAUtilities.beginTransaction(e);
093: boolean ret = false;
094: WfProcess[] perfs = SharkCORBAUtilities
095: .makeCORBAProcesses(__collective, reqInternal
096: .get_sequence_performer(0));
097: if (perfs != null) {
098: for (int i = 0; i < perfs.length; i++) {
099: WfProcess perf = perfs[i];
100: if (perf.key().equals(member.key())) {
101: ret = true;
102: break;
103: }
104: }
105: }
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 receive_event(WfEventAudit event) throws BaseException,
115: InvalidPerformer {
116: throw new BaseException();
117: }
118:
119: }
|