package org.enhydra.shark.corba;
import javax.transaction.UserTransaction;
import org.omg.WfBase.BaseException;
import org.omg.WfBase.NameValueInfo;
import org.omg.WorkflowModel.*;
/**
* WfProcessMgrImpl - Workflow Process Manager implementation
*/
public class WfProcessMgrCORBA extends _WfProcessMgrImplBase {
org.enhydra.shark.api.client.wfmodel.WfProcessMgr sharkProcMgr;
private Collective __collective;
/**
* Creates new WfProcessMgrImpl
*
* @param sharkProcMgr a WfProcessMgr
*/
protected WfProcessMgrCORBA(Collective toJoin,
org.enhydra.shark.api.client.wfmodel.WfProcessMgr sharkProcMgr) {
__collective = toJoin;
toJoin.__recruit(this);
this.sharkProcMgr = sharkProcMgr;
}
public int how_many_process() throws BaseException {
UserTransaction ut = null;
boolean e = SharkCORBAServer.doesTransactionExist();
try {
ut = SharkCORBAUtilities.beginTransaction(e);
int ret = sharkProcMgr.how_many_process();
SharkCORBAUtilities.commitTransaction(ut, e);
return ret;
} catch (Exception ex) {
SharkCORBAUtilities.rollbackTransaction(ut, e);
throw new BaseException();
}
}
public WfProcessIterator get_iterator_process() throws BaseException {
UserTransaction ut = null;
boolean e = SharkCORBAServer.doesTransactionExist();
try {
ut = SharkCORBAUtilities.beginTransaction(e);
WfProcessIterator ret = new WfProcessIteratorCORBA(__collective,
sharkProcMgr.get_iterator_process());
SharkCORBAUtilities.commitTransaction(ut, e);
return ret;
} catch (Exception ex) {
SharkCORBAUtilities.rollbackTransaction(ut, e);
throw new BaseException();
}
}
public WfProcess[] get_sequence_process(int max_number) throws BaseException {
UserTransaction ut = null;
boolean e = SharkCORBAServer.doesTransactionExist();
try {
ut = SharkCORBAUtilities.beginTransaction(e);
WfProcess[] ret = SharkCORBAUtilities.makeCORBAProcesses(__collective,
sharkProcMgr.get_sequence_process(max_number));
SharkCORBAUtilities.commitTransaction(ut, e);
return ret;
} catch (Exception ex) {
SharkCORBAUtilities.rollbackTransaction(ut, e);
throw new BaseException();
}
}
public boolean is_member_of_process(WfProcess member) throws BaseException {
UserTransaction ut = null;
boolean e = SharkCORBAServer.doesTransactionExist();
try {
ut = SharkCORBAUtilities.beginTransaction(e);
WfProcess[] procs = get_sequence_process(0);
boolean ret = false;
if (procs != null) {
for (int i = 0; i < procs.length; i++) {
if (procs[i].key().equals(member.key())) {
ret = true;
break;
}
}
}
SharkCORBAUtilities.commitTransaction(ut, e);
return ret;
} catch (Exception ex) {
SharkCORBAUtilities.rollbackTransaction(ut, e);
throw new BaseException();
}
}
public process_mgr_stateType process_mgr_state() throws BaseException {
UserTransaction ut = null;
boolean e = SharkCORBAServer.doesTransactionExist();
try {
ut = SharkCORBAUtilities.beginTransaction(e);
process_mgr_stateType ret = process_mgr_stateType.from_int(sharkProcMgr.process_mgr_state()
.value());
SharkCORBAUtilities.commitTransaction(ut, e);
return ret;
} catch (Exception ex) {
SharkCORBAUtilities.rollbackTransaction(ut, e);
throw new BaseException();
}
}
public void set_process_mgr_state(process_mgr_stateType new_state)
throws BaseException,
TransitionNotAllowed {
UserTransaction ut = null;
boolean e = SharkCORBAServer.doesTransactionExist();
try {
ut = SharkCORBAUtilities.beginTransaction(e);
sharkProcMgr.set_process_mgr_state(org.enhydra.shark.api.client.wfmodel.process_mgr_stateType.from_int(new_state.value()));
SharkCORBAUtilities.commitTransaction(ut, e);
} catch (org.enhydra.shark.api.client.wfmodel.TransitionNotAllowed tna) {
SharkCORBAUtilities.rollbackTransaction(ut, e);
throw new TransitionNotAllowed();
} catch (Exception ex) {
SharkCORBAUtilities.rollbackTransaction(ut, e);
throw new BaseException();
}
}
public String name() throws BaseException {
UserTransaction ut = null;
boolean e = SharkCORBAServer.doesTransactionExist();
try {
ut = SharkCORBAUtilities.beginTransaction(e);
String ret = sharkProcMgr.name();
SharkCORBAUtilities.commitTransaction(ut, e);
return ret;
} catch (Exception ex) {
SharkCORBAUtilities.rollbackTransaction(ut, e);
throw new BaseException();
}
}
public String description() throws BaseException {
UserTransaction ut = null;
boolean e = SharkCORBAServer.doesTransactionExist();
try {
ut = SharkCORBAUtilities.beginTransaction(e);
String ret = sharkProcMgr.description();
SharkCORBAUtilities.commitTransaction(ut, e);
return ret;
} catch (Exception ex) {
SharkCORBAUtilities.rollbackTransaction(ut, e);
throw new BaseException();
}
}
public String category() throws BaseException {
UserTransaction ut = null;
boolean e = SharkCORBAServer.doesTransactionExist();
try {
ut = SharkCORBAUtilities.beginTransaction(e);
String ret = sharkProcMgr.category();
SharkCORBAUtilities.commitTransaction(ut, e);
return ret;
} catch (Exception ex) {
SharkCORBAUtilities.rollbackTransaction(ut, e);
throw new BaseException();
}
}
public String version() throws BaseException {
UserTransaction ut = null;
boolean e = SharkCORBAServer.doesTransactionExist();
try {
ut = SharkCORBAUtilities.beginTransaction(e);
String ret = sharkProcMgr.version();
SharkCORBAUtilities.commitTransaction(ut, e);
return ret;
} catch (Exception ex) {
SharkCORBAUtilities.rollbackTransaction(ut, e);
throw new BaseException();
}
}
public NameValueInfo[] context_signature() throws BaseException {
UserTransaction ut = null;
boolean e = SharkCORBAServer.doesTransactionExist();
try {
ut = SharkCORBAUtilities.beginTransaction(e);
NameValueInfo[] ret = SharkCORBAUtilities.makeCORBANameValueInfoArray(sharkProcMgr.context_signature());
SharkCORBAUtilities.commitTransaction(ut, e);
return ret;
} catch (Exception ex) {
SharkCORBAUtilities.rollbackTransaction(ut, e);
throw new BaseException();
}
}
public NameValueInfo[] result_signature() throws BaseException {
UserTransaction ut = null;
boolean e = SharkCORBAServer.doesTransactionExist();
try {
ut = SharkCORBAUtilities.beginTransaction(e);
NameValueInfo[] ret = SharkCORBAUtilities.makeCORBANameValueInfoArray(sharkProcMgr.result_signature());
SharkCORBAUtilities.commitTransaction(ut, e);
return ret;
} catch (Exception ex) {
SharkCORBAUtilities.rollbackTransaction(ut, e);
throw new BaseException();
}
}
/**
* Create a WfProcess object
*/
public WfProcess create_process(WfRequester requester)
throws BaseException,
NotEnabled,
InvalidRequester,
RequesterRequired {
if (requester == null)
throw new RequesterRequired();
if (requester instanceof WfActivity) {
throw new BaseException();
}
UserTransaction ut = null;
boolean e = SharkCORBAServer.doesTransactionExist();
try {
ut = SharkCORBAUtilities.beginTransaction(e);
WfLinkingRequesterForCORBA lr = new WfLinkingRequesterForCORBA();
org.enhydra.shark.api.client.wfmodel.WfProcess procInternal = sharkProcMgr.create_process(lr);
WfLinkingRequesterForCORBA.setCORBARequester(procInternal.key(), requester);
WfProcess ret = new WfProcessCORBA(__collective, procInternal);
SharkCORBAUtilities.commitTransaction(ut, e);
return ret;
} catch (org.enhydra.shark.api.client.wfmodel.NotEnabled ne) {
SharkCORBAUtilities.rollbackTransaction(ut, e);
throw new NotEnabled();
} catch (org.enhydra.shark.api.client.wfmodel.InvalidRequester ir) {
SharkCORBAUtilities.rollbackTransaction(ut, e);
throw new InvalidRequester();
} catch (org.enhydra.shark.api.client.wfmodel.RequesterRequired rr) {
SharkCORBAUtilities.rollbackTransaction(ut, e);
throw new RequesterRequired();
} catch (Exception ex) {
SharkCORBAUtilities.rollbackTransaction(ut, e);
throw new BaseException();
}
}
/**
* It is assumed that there can't be two or more processes mgrs having the same name.
*/
public boolean equals(Object obj) {
if (!(obj instanceof WfProcessMgr))
return false;
WfProcessMgr mgr = (WfProcessMgr) obj;
UserTransaction ut = null;
boolean e = SharkCORBAServer.doesTransactionExist();
try {
ut = SharkCORBAUtilities.beginTransaction(e);
boolean ret = mgr.name().equals(name());
SharkCORBAUtilities.commitTransaction(ut, e);
return ret;
} catch (Exception ex) {
SharkCORBAUtilities.rollbackTransaction(ut, e);
return false;
}
}
public String toString() {
return sharkProcMgr.toString();
}
}
|