001: /* WfActivitySSBean.java */
002: package org.enhydra.shark.ejb;
003:
004: import java.rmi.RemoteException;
005: import java.util.Map;
006:
007: import javax.ejb.EJBException;
008: import javax.ejb.EJBObject;
009: import javax.ejb.SessionBean;
010: import javax.ejb.SessionContext;
011: import javax.naming.Context;
012: import javax.naming.InitialContext;
013: import javax.rmi.PortableRemoteObject;
014:
015: import org.enhydra.shark.api.client.timebase.UtcT;
016: import org.enhydra.shark.api.client.wfmodel.AlreadySuspended;
017: import org.enhydra.shark.api.client.wfmodel.CannotComplete;
018: import org.enhydra.shark.api.client.wfmodel.CannotResume;
019: import org.enhydra.shark.api.client.wfmodel.CannotStop;
020: import org.enhydra.shark.api.client.wfmodel.CannotSuspend;
021: import org.enhydra.shark.api.client.wfmodel.HistoryNotAvailable;
022: import org.enhydra.shark.api.client.wfmodel.InvalidData;
023: import org.enhydra.shark.api.client.wfmodel.InvalidPerformer;
024: import org.enhydra.shark.api.client.wfmodel.InvalidState;
025: import org.enhydra.shark.api.client.wfmodel.NotRunning;
026: import org.enhydra.shark.api.client.wfmodel.NotSuspended;
027: import org.enhydra.shark.api.client.wfmodel.ResultNotAvailable;
028: import org.enhydra.shark.api.client.wfmodel.TransitionNotAllowed;
029: import org.enhydra.shark.api.client.wfmodel.UpdateNotAllowed;
030: import org.enhydra.shark.api.client.wfmodel.WfAssignment;
031: import org.enhydra.shark.api.client.wfmodel.WfAssignmentIterator;
032: import org.enhydra.shark.api.client.wfmodel.WfActivity;
033: import org.enhydra.shark.api.client.wfmodel.WfEventAudit;
034: import org.enhydra.shark.api.client.wfmodel.WfEventAuditIterator;
035: import org.enhydra.shark.api.client.wfmodel.WfExecutionObject;
036: import org.enhydra.shark.api.client.wfmodel.WfProcess;
037: import org.enhydra.shark.api.client.wfmodel.WfProcessIterator;
038: import org.enhydra.shark.api.client.wfmodel.how_closedType;
039: import org.enhydra.shark.api.client.wfmodel.while_openType;
040: import org.enhydra.shark.api.client.wfmodel.why_not_runningType;
041: import org.enhydra.shark.api.client.wfmodel.workflow_stateType;
042:
043: /**
044: * @ejb.bean
045: * name="WfActivitySS"
046: * type="Stateful"
047: * display-name="WfActivity"
048: * jndi-name="org/enhydra/shark/ejb/WfActivitySS"
049: * local-jndi-name="org/enhydra/shark/ejb/WfActivitySSLocal"
050: * transaction-type="Container"
051: * view-type="both"
052: * local-business-interface="org.enhydra.shark.api.client.wfmodel.WfActivity"
053: *
054: * @ejb.ejb-ref ejb-name="WfProcessIteratorSS"
055: * view-type="both"
056: * ref-name="org/enhydra/shark/ejb/WfProcessIteratorSS"
057: * @ejb.ejb-ref ejb-name="WfProcessSS"
058: * view-type="both"
059: * ref-name="org/enhydra/shark/ejb/WfProcessSS"
060: * @ejb.ejb-ref ejb-name="WfAssignmentEventAuditSS"
061: * view-type="both"
062: * ref-name="org/enhydra/shark/ejb/WfAssignmentEventAuditSS"
063: * @ejb.ejb-ref ejb-name="WfCreateProcessEventAuditSS"
064: * view-type="both"
065: * ref-name="org/enhydra/shark/ejb/WfCreateProcessEventAuditSS"
066: * @ejb.ejb-ref ejb-name="WfDataEventAuditSS"
067: * view-type="both"
068: * ref-name="org/enhydra/shark/ejb/WfDataEventAuditSS"
069: * @ejb.ejb-ref ejb-name="WfPackageEventAuditSS"
070: * view-type="both"
071: * ref-name="org/enhydra/shark/ejb/WfPackageEventAuditSS"
072: * @ejb.ejb-ref ejb-name="WfStateEventAuditSS"
073: * view-type="both"
074: * ref-name="org/enhydra/shark/ejb/WfStateEventAuditSS"
075: * @ejb.ejb-ref ejb-name="WfEventAuditIteratorSS"
076: * view-type="both"
077: * ref-name="org/enhydra/shark/ejb/WfEventAuditIteratorSS"
078: * @ejb.ejb-ref ejb-name="WfActivitySS"
079: * view-type="both"
080: * ref-name="org/enhydra/shark/ejb/WfActivitySS"
081: * @ejb.ejb-ref ejb-name="WfAssignmentSS"
082: * view-type="both"
083: * ref-name="org/enhydra/shark/ejb/WfAssignmentSS"
084: * @ejb.ejb-ref ejb-name="WfAssignmentIteratorSS"
085: * view-type="both"
086: * ref-name="org/enhydra/shark/ejb/WfAssignmentIteratorSS"
087: *
088: *
089: * @ejb:interface
090: * extends="org.enhydra.shark.api.client.wfmodel.WfActivity,javax.ejb.EJBObject"
091: *
092: * @ejb:transaction
093: * type="Required"
094: *
095: * @jonas:bean
096: * ejb-name="WfActivitySS"
097: * jndi-name="org/enhydra/shark/ejb/WfActivitySS"
098: *
099: * OMG definition:WfActivity is a step in a process that is associated, as part of an
100: * aggregation, with a single WfProcess. It represents a request for work in the context
101: * of the containing WfProcess. There can be many active WfActivity objects within a
102: * WfProcess at a given point in time. The WfActivity interface specializes
103: * WfExecutionObject with an explicit complete operation to signal completion of the step,
104: * and with an operation to set the result of the WfActivity. It also adds relationships
105: * with WfProcess and WfAssignment.
106: * <p>
107: * We extended OMG's interface by duplicating methods, and adding additional parameter
108: * that represents transaction. If you use methods without SharkTransaction parameter, the
109: * transaction will be implicitly created, and if you use it with SharkTransaction
110: * parameter you must obey to some rules explained in HowTo documentation.
111: *
112: * @author V.Puskas
113: * @author S.Bojanic
114: * @author T.Jovanovic
115: * @version 0.1
116: */
117: public abstract class WfActivitySSBean implements WfActivity,
118: SessionBean {
119:
120: private SessionContext context;
121: private org.enhydra.shark.api.client.wfmodel.WfActivity sharkObj;
122:
123: /**
124: * @ejb:interface-method
125: * view-type="both"
126: * Zero or more WfProcesses can be associated with a WfRequester. A requester is
127: * associated with a WfProcess when the process is created.
128: * <p>
129: * The following operation provide the information about the number of WfProcess items
130: * currently associated with a WfRequester.
131: */
132: public int how_many_performer() throws Exception {
133: return sharkObj.how_many_performer();
134: }
135:
136: /**
137: * @ejb:interface-method
138: * view-type="both"
139: * Zero or more WfProcesses can be associated with a WfRequester. A requester is
140: * associated with a WfProcess when the process is created.
141: * <p>
142: * The following operation returns iterator for qurying associated processes based on
143: * some criteria.
144: */
145: public WfProcessIterator get_iterator_performer() throws Exception {
146: WfProcessIterator wfshark = sharkObj.get_iterator_performer();
147: WfProcessIteratorSS wf = null;
148: try {
149: Context initialContext = EJBJNDIContext.getInstance()
150: .getInitialContext();
151: wf = ((org.enhydra.shark.ejb.WfProcessIteratorSSHome) PortableRemoteObject
152: .narrow(
153: initialContext
154: .lookup("org/enhydra/shark/ejb/WfProcessIteratorSS"),
155: org.enhydra.shark.ejb.WfProcessIteratorSSHome.class))
156: .create(wfshark);
157: return (WfProcessIteratorSS) wf.getPassedEJBObject();
158: } catch (Exception ex) {
159: throw new EJBException(ex);
160: }
161: }
162:
163: /**
164: * @ejb:interface-method
165: * view-type="both"
166: * Zero or more WfProcesses can be associated with a WfRequester. A requester is
167: * associated with a WfProcess when the process is created.
168: * <p>
169: * The following operation returns max_number of WfProcess objects associated with an
170: * WfRequester. If max_number is less or eaqual to zero, or it is greater than the
171: * number of existing processes, all associated WfProcess objects will be returned.
172: */
173: public WfProcess[] get_sequence_performer(int max_number)
174: throws Exception {
175: WfProcess[] wfsshark = sharkObj
176: .get_sequence_performer(max_number);
177: WfProcessSSHome home = null;
178: InitialContext initialContext = EJBJNDIContext.getInstance()
179: .getInitialContext();
180: home = (WfProcessSSHome) PortableRemoteObject.narrow(
181: initialContext
182: .lookup("org/enhydra/shark/ejb/WfProcessSS"),
183: org.enhydra.shark.ejb.WfProcessSSHome.class);
184: int len = wfsshark.length;
185: WfProcessSS[] remotes = new WfProcessSS[len];
186: for (int i = 0; i < len; i++) {
187: remotes[i] = (WfProcessSS) (home.create(wfsshark[i]))
188: .getPassedEJBObject();
189: }
190: return remotes;
191: }
192:
193: /**
194: * @ejb:interface-method
195: * view-type="both"
196: * Zero or more WfProcesses can be associated with a WfRequester. A requester is
197: * associated with a WfProcess when the process is created.
198: * <p>
199: * The following operation returns true if given process is associated with
200: * WfRequester.
201: */
202: public boolean is_member_of_performer(WfProcess member)
203: throws Exception {
204: try {
205: boolean ret = false;
206: WfProcess[] perfs = sharkObj.get_sequence_performer(0);
207: if (perfs != null) {
208: for (int i = 0; i < perfs.length; i++) {
209: WfProcess perf = perfs[i];
210: if (perf.key().equals(member.key())) {
211: ret = true;
212: break;
213: }
214: }
215: }
216: return ret;
217: } catch (Exception ex) {
218: throw new EJBException(ex);
219: }
220: }
221:
222: /**
223: * @ejb:interface-method
224: * view-type="both"
225: * The following operation is used by WfProcess to notify its requester of workflow
226: * events. In particular the WfProcess must notify the requester of complete,
227: * terminate, or abort events or the transition to a closed state.
228: * <p>
229: * The workflow event contains the source of the event; an InvalidPerformer exception
230: * is raised if the source of the event is not a performer associated with the
231: * WfRequester.
232: */
233: public void receive_event(WfEventAudit event) throws Exception,
234: InvalidPerformer {
235: /*try {
236: WfEventAudit eaudit = event.getWfEventAudit();
237: reqInternal.receive_event(eaudit);
238: } catch (InvalidPerformer ex) {
239: throw new InvalidPerformer();
240: } catch (Exception ex) {
241: throw new EJBException(ex);
242: }
243: */
244: }
245:
246: /**
247: * @ejb:interface-method
248: * view-type="both"
249: * Returns the basic state of execution object: open or closed.
250: */
251: public workflow_stateType workflow_state() throws Exception {
252: return sharkObj.workflow_state();
253: }
254:
255: /**
256: * @ejb:interface-method
257: * view-type="both"
258: * Returns the sub-state of execution object that is in open state: running or not
259: * running.
260: */
261: public while_openType while_open() throws Exception {
262: return sharkObj.while_open();
263: }
264:
265: /**
266: * @ejb:interface-method
267: * view-type="both"
268: * Returns the sub-state of execution object that is in open.not_running state: not
269: * started or suspended.
270: */
271: public why_not_runningType why_not_running() throws Exception {
272: return sharkObj.why_not_running();
273: }
274:
275: /**
276: * @ejb:interface-method
277: * view-type="both"
278: * Returns the sub-state of execution object that is in closed state: completed,
279: * aborted or terminated.
280: */
281: public how_closedType how_closed() throws Exception {
282: return sharkObj.how_closed();
283: }
284:
285: /**
286: * @ejb:interface-method
287: * view-type="both"
288: * The following operations support access to a potentially extended set of states; a
289: * state is represented by a dot-notation representing hierarchical states (e.g.,
290: * open.running).
291: * <p>
292: * Returns a list of all the valid states that can be reached from the current state.
293: * For example, open.running and closed.terminated would be in the list of valid states
294: * if the current state was open.not_running.not_started - open.not_running.suspended
295: * probably would not be in that list.
296: */
297: public String[] valid_states() throws Exception {
298: return sharkObj.valid_states();
299: }
300:
301: /**
302: * @ejb:interface-method
303: * view-type="both"
304: * Gets the current state of the object.
305: */
306: public String state() throws Exception {
307: return sharkObj.state();
308: }
309:
310: /**
311: * @ejb:interface-method
312: * view-type="both"
313: * Updates the current state of the execution object. As a result the state of
314: * execution objects associated with this execution object might be updated, too.
315: *
316: * @throws InvalidState raised when the new_state is not a valid state for the
317: * execution object
318: * @throws TransitionNotAllowed raised when the transition from the current state to
319: * new_state is not allowed.
320: * @throws Exception
321: */
322: public void change_state(String new_state) throws Exception,
323: InvalidState, TransitionNotAllowed {
324: sharkObj.change_state(new_state);
325: }
326:
327: /**
328: * @ejb:interface-method
329: * view-type="both"
330: * Returns human readable, descriptive identifier of the execution object.
331: */
332: public String name() throws Exception {
333: return sharkObj.name();
334: }
335:
336: /**
337: * @ejb:interface-method
338: * view-type="both"
339: * Sets the human readable, descriptive identifier of the execution object.
340: */
341: public void set_name(String new_value) throws Exception {
342: sharkObj.set_name(new_value);
343: }
344:
345: /**
346: * @ejb:interface-method
347: * view-type="both"
348: * Gets the identifier of the execution object. The key of a WfProcess is unique among
349: * the set of all WfProcesses created by a particular WfProcessMgr; the key of a
350: * WfActivity is unique within the set of all WfActivities contained in a particular
351: * WfProcess. A key is assigned to the execution object by its WfProcessMgr when it is
352: * created.
353: * <p>
354: * The key of a workflow object should not be confused with an object identifier. It is
355: * used for reference to the process or activity independently of the lifetime of the
356: * execution object.
357: */
358: public String key() throws Exception {
359: return sharkObj.key();
360: }
361:
362: /**
363: * @ejb:interface-method
364: * view-type="both"
365: * Returns description of the execution object.
366: */
367: public String description() throws Exception {
368: return sharkObj.description();
369: }
370:
371: /**
372: * @ejb:interface-method
373: * view-type="both"
374: * Sets description of the execution object.
375: */
376: public void set_description(String new_value) throws Exception {
377: sharkObj.set_description(new_value);
378: }
379:
380: /**
381: * @ejb:interface-method
382: * view-type="both"
383: * The process context is described by a set of named properties; the following
384: * operation support access to the context of an execution object. The Map structure
385: * identifies a set of property names and values matching the signature of the
386: * execution object. The signature of a WfProcess can be obtained using the
387: * get_context_signature operation provided by the WfProcessMgr of the process.
388: */
389: public Map process_context() throws Exception {
390: return sharkObj.process_context();
391: }
392:
393: /**
394: * @ejb:interface-method
395: * view-type="both"
396: * Sets the process relevant data that define the context of the execution object. The
397: * process context is described by a set of named properties. The Map structure
398: * identifies a set of property names and values matching the signature of the
399: * execution object. The signature of a WfProcess can be obtained using the
400: * get_context_signature operation provided by the WfProcessMgr of the process.
401: * <p>
402: * When this method has been called, only those name-value pairs in the parameter will
403: * be set. Several set_process_context() calls could be used to set the entire context.
404: *
405: * @param new_value a Map
406: * @throws Exception
407: * @throws InvalidData raised when an update request does not match this signature.
408: * @throws UpdateNotAllowed raised when the implementation of the WfM Facility or the
409: * specific workflow process does not allow an update of the context.
410: */
411: public void set_process_context(Map new_value) throws Exception,
412: InvalidData, UpdateNotAllowed {
413: sharkObj.set_process_context(new_value);
414: }
415:
416: /**
417: * @ejb:interface-method
418: * view-type="both"
419: * Returns relative priority of the execution element in the set of all execution
420: * objects of a given type.
421: * <p>
422: * Valid values are numbers between one and five, with three being 'normal' and one as
423: * the 'highest' priority.
424: */
425: public short priority() throws Exception {
426: return sharkObj.priority();
427: }
428:
429: /**
430: * @ejb:interface-method
431: * view-type="both"
432: * Sets the relative priority of the execution element in the set of all execution
433: * objects of a given type.
434: * <p>
435: * Valid values are numbers between one and five, with three being 'normal' and one as
436: * the 'highest' priority.
437: * <p>
438: * A request for update of the priority will raise an exception when the specified
439: * priority is out of range, or when the priority cannot be updated.
440: */
441: public void set_priority(short new_value) throws Exception {
442: sharkObj.set_priority(new_value);
443: }
444:
445: /**
446: * @ejb:interface-method
447: * view-type="both"
448: * Requests enactment of a suspended execution object to be resumed. The state is set
449: * to open.running (or a substate) from open.not_running.suspended.
450: *
451: * @throws CannotResume raised when the execution object cannot be resumed. For
452: * example, resuming a WfActivity might not be allowed when the containing
453: * WfProcess is suspended.
454: * @throws NotSuspended raised when the object is not suspended.
455: * @throws Exception
456: */
457: public void resume() throws Exception, CannotResume, NotSuspended {
458: sharkObj.resume();
459: }
460:
461: /**
462: * @ejb:interface-method
463: * view-type="both"
464: * Requests enactment of an execution object to be suspended. The state is set to
465: * open.not_running.suspended (or one of its substates).
466: *
467: * @throws CannotSuspend exception is raised when the execution object cannot be
468: * suspended. For example, an implementation of the WfM Facility might not
469: * support suspension of a WfActivity.
470: * @throws NotRunning raised when the object is not running.
471: * @throws AlreadySuspended raised when the object is already suspended.
472: * @throws Exception
473: */
474: public void suspend() throws Exception, CannotSuspend, NotRunning,
475: AlreadySuspended {
476: sharkObj.suspend();
477: }
478:
479: /**
480: * @ejb:interface-method
481: * view-type="both"
482: * Requests enactment of an execution object to be terminated before its normal
483: * completion. A terminate request is different from an abort request in its effect of
484: * execution object associated with the current execution object. The state is set to
485: * closed.terminated (or one of its substates) from open.running (or one of its
486: * substates).
487: *
488: * @throws CannotStop raised when the execution object cannot be terminated; for
489: * example, termination of a WfActivity might not be allowed when its
490: * implementation is still active and cannot be terminated.
491: * @throws NotRunning raised when the object is not running.
492: * @throws Exception
493: */
494: public void terminate() throws Exception, CannotStop, NotRunning {
495: sharkObj.terminate();
496: }
497:
498: /**
499: * @ejb:interface-method
500: * view-type="both"
501: * Requests enactment of a suspended execution object to be aborted before its normal
502: * completion. The state is set to closed.aborted.
503: *
504: * @throws CannotStop raised when the execution object cannot be aborted.
505: * @throws NotRunning raised when the object is not running.
506: * @throws Exception
507: */
508: public void abort() throws Exception, CannotStop, NotRunning {
509: sharkObj.abort();
510: }
511:
512: /**
513: * @ejb:interface-method
514: * view-type="both"
515: * Zero or more WfEventAudit items can be associated with an execution object. An event
516: * audit item is generated (and associated with the source object) for each workflow
517: * relevant status change (change of state, context or result and change of resource
518: * assignment) of a WfExecutionObject. Status changes can be explicitly triggered by
519: * operations that request a change of the objects status or implicitly by the workflow
520: * process logic. We will indicate which operations trigger generation of WfEventAudit
521: * items.
522: * <p>
523: * The following operation provide the information about the number of WfEventAudit
524: * items currently associated with a WfExecutionObject.
525: */
526: public int how_many_history() throws Exception, HistoryNotAvailable {
527: return sharkObj.how_many_history();
528: }
529:
530: /**
531: * @ejb:interface-method
532: * view-type="both"
533: * Zero or more WfEventAudit items can be associated with an execution object. An event
534: * audit item is generated (and associated with the source object) for each workflow
535: * relevant status change (change of state, context or result and change of resource
536: * assignment) of a WfExecutionObject. Status changes can be explicitly triggered by
537: * operations that request a change of the objects status or implicitly by the workflow
538: * process logic. We will indicate which operations trigger generation of WfEventAudit
539: * items.
540: * <p>
541: * The following operation returns iterator for qurying associated event audits based
542: * on some criteria.
543: */
544: public WfEventAuditIterator get_iterator_history(String query,
545: Map names_in_query) throws Exception, HistoryNotAvailable {
546: WfEventAuditIterator wfshark = sharkObj.get_iterator_history(
547: query, names_in_query);
548: WfEventAuditIteratorSS wf = null;
549: try {
550: Context initialContext = EJBJNDIContext.getInstance()
551: .getInitialContext();
552: wf = ((org.enhydra.shark.ejb.WfEventAuditIteratorSSHome) PortableRemoteObject
553: .narrow(
554: initialContext
555: .lookup("org/enhydra/shark/ejb/WfEventAuditIteratorSS"),
556: org.enhydra.shark.ejb.WfEventAuditIteratorSSHome.class))
557: .create(wfshark);
558: return (WfEventAuditIteratorSS) wf.getPassedEJBObject();
559: } catch (Exception ex) {
560: throw new EJBException(ex);
561: }
562: }
563:
564: /**
565: * @ejb:interface-method
566: * view-type="both"
567: * Zero or more WfEventAudit items can be associated with an execution object. An event
568: * audit item is generated (and associated with the source object) for each workflow
569: * relevant status change (change of state, context or result and change of resource
570: * assignment) of a WfExecutionObject. Status changes can be explicitly triggered by
571: * operations that request a change of the objects status or implicitly by the workflow
572: * process logic. We will indicate which operations trigger generation of WfEventAudit
573: * items.
574: * <p>
575: * The following operation returns max_number of WfEventAudit objects associated with
576: * an WfExecutionObject. If max_number is less or eaqual to zero, or it is greater than
577: * the number of existing event audits, all associated WfEventAudit objects will be
578: * returned.
579: */
580: public WfEventAudit[] get_sequence_history(int max_number)
581: throws Exception, HistoryNotAvailable {
582: try {
583: return SharkEJBUtilities.makeSSEventAudits(sharkObj
584: .get_sequence_history(max_number));
585: } catch (Exception ex) {
586: throw new EJBException(ex);
587: }
588: }
589:
590: /**
591: * @ejb:interface-method
592: * view-type="both"
593: * Zero or more WfEventAudit items can be associated with an execution object. An event
594: * audit item is generated (and associated with the source object) for each workflow
595: * relevant status change (change of state, context or result and change of resource
596: * assignment) of a WfExecutionObject. Status changes can be explicitly triggered by
597: * operations that request a change of the objects status or implicitly by the workflow
598: * process logic. We will indicate which operations trigger generation of WfEventAudit
599: * items.
600: * <p>
601: * The following operation returns true if given event audit is associated with
602: * WfExecutionObject.
603: */
604: public boolean is_member_of_history(WfExecutionObject member)
605: throws Exception {
606: try {
607: boolean ret = false;
608: WfEventAudit[] evs = SharkEJBUtilities
609: .makeSSEventAudits(sharkObj.get_sequence_history(0));
610: if (evs != null) {
611: for (int i = 0; i < evs.length; i++) {
612: WfEventAudit ea = evs[i];
613: if (member.key().equals(ea.process_key())) {
614: ret = true;
615: break;
616: }
617: }
618: }
619: return ret;
620: } catch (Exception ex) {
621: throw new EJBException(ex);
622: }
623: }
624:
625: /**
626: * @ejb:interface-method
627: * view-type="both"
628: * Returns the time when WfExecutionObject changed its state to the current one.
629: */
630: public UtcT last_state_time() throws Exception {
631: return sharkObj.last_state_time();
632: }
633:
634: /**
635: * @ejb:interface-method
636: * view-type="both"
637: * Zero or more WfAssignments can be associated with a WfActivity. The association is
638: * established when the assignment is created as part of the resource selection process
639: * for the activity.
640: * <p>
641: * The following operation returns the number of WfAssignments associated with an
642: * activity.
643: */
644: public int how_many_assignment() throws Exception {
645: return sharkObj.how_many_assignment();
646: }
647:
648: /**
649: * @ejb:interface-method
650: * view-type="both"
651: * Zero or more WfAssignments can be associated with a WfActivity. The association is
652: * established when the assignment is created as part of the resource selection process
653: * for the activity.
654: * <p>
655: * The following operation returns iterator for qurying associated assignments based on
656: * some criteria.
657: */
658: public WfAssignmentIterator get_iterator_assignment()
659: throws Exception {
660: WfAssignmentIterator wfshark = sharkObj
661: .get_iterator_assignment();
662: WfAssignmentIteratorSS wf = null;
663: try {
664: Context initialContext = EJBJNDIContext.getInstance()
665: .getInitialContext();
666: wf = ((org.enhydra.shark.ejb.WfAssignmentIteratorSSHome) PortableRemoteObject
667: .narrow(
668: initialContext
669: .lookup("org/enhydra/shark/ejb/WfAssignmentIteratorSS"),
670: org.enhydra.shark.ejb.WfAssignmentIteratorSSHome.class))
671: .create(wfshark);
672: return (WfAssignmentIteratorSS) wf.getPassedEJBObject();
673: } catch (Exception ex) {
674: throw new EJBException(ex);
675: }
676: }
677:
678: /**
679: * @ejb:interface-method
680: * view-type="both"
681: * Zero or more WfAssignments can be associated with a WfActivity. The association is
682: * established when the assignment is created as part of the resource selection process
683: * for the activity.
684: * <p>
685: * The following operation returns max_number of WfAssignment objects associated with
686: * an activity. If max_number is less or eaqual to zero, or it is greater than the
687: * number of existing assignments, all associated WfAssignments objects will be
688: * returned.
689: */
690: public WfAssignment[] get_sequence_assignment(int max_number)
691: throws Exception {
692: WfAssignment[] wfsshark = sharkObj
693: .get_sequence_assignment(max_number);
694: WfAssignmentSSHome home = null;
695: InitialContext initialContext = EJBJNDIContext.getInstance()
696: .getInitialContext();
697: home = (WfAssignmentSSHome) PortableRemoteObject
698: .narrow(
699: initialContext
700: .lookup("org/enhydra/shark/ejb/WfAssignmentSS"),
701: org.enhydra.shark.ejb.WfAssignmentSSHome.class);
702: int len = wfsshark.length;
703: WfAssignmentSS[] remotes = new WfAssignmentSS[len];
704: for (int i = 0; i < len; i++) {
705: remotes[i] = (WfAssignmentSS) (home.create(wfsshark[i]))
706: .getPassedEJBObject();
707: }
708: return remotes;
709: }
710:
711: /**
712: * @ejb:interface-method
713: * view-type="both"
714: * Zero or more WfAssignments can be associated with a WfActivity. The association is
715: * established when the assignment is created as part of the resource selection process
716: * for the activity.
717: * <p>
718: * The following operation returns true if given assignment is associated with
719: * activity.
720: */
721: public boolean is_member_of_assignment(WfAssignment member)
722: throws Exception {
723: try {
724: String actId = member.activity().key();
725: return actId.equals(sharkObj.key());
726: } catch (Exception ex) {
727: throw new EJBException(ex);
728: }
729: }
730:
731: /**
732: * @ejb:interface-method
733: * view-type="both"
734: * This operation returns the WfProcess that this activity is a part of.
735: */
736: public WfProcess container() throws Exception {
737: WfProcess wfshark = sharkObj.container();
738: WfProcessSS wf = null;
739: try {
740: Context initialContext = EJBJNDIContext.getInstance()
741: .getInitialContext();
742: wf = ((org.enhydra.shark.ejb.WfProcessSSHome) PortableRemoteObject
743: .narrow(
744: initialContext
745: .lookup("org/enhydra/shark/ejb/WfProcessSS"),
746: org.enhydra.shark.ejb.WfProcessSSHome.class))
747: .create(wfshark);
748: return (WfProcessSS) wf.getPassedEJBObject();
749: } catch (Exception ex) {
750: throw new EJBException(ex);
751: }
752: }
753:
754: /**
755: * @ejb:interface-method
756: * view-type="both"
757: * Represents the result produced by the realization of the work request represented by
758: * an activity. An implementation of the WfM Facility may or may not provide access to
759: * the result of an activity. If it does not, or if the result data are not available
760: * yet, a ResultNotAvailable exception is raised by the result access operation.
761: */
762: public Map result() throws Exception, ResultNotAvailable {
763: return sharkObj.result();
764: }
765:
766: /**
767: * @ejb:interface-method
768: * view-type="both"
769: * The set_result operation is used to pass process data back to the workflow process.
770: * An InvalidData exception is raised when the data do not match the signature of the
771: * activity or when an invalid attempt is made to update the results of an activity;
772: * lack of access rights might be one of those reasons.
773: */
774: public void set_result(Map result) throws Exception, InvalidData {
775: sharkObj.set_result(result);
776: }
777:
778: /**
779: * @ejb:interface-method
780: * view-type="both"
781: * This operation is used by an application to signal completion of the WfActivity. It
782: * will be used together with the set_result operation to pass results of the activity
783: * back to the workflow process. A CannotComplete exception is raised when the activity
784: * cannot be completed yet.
785: */
786: public void complete() throws Exception, CannotComplete {
787: sharkObj.complete();
788: }
789:
790: /**
791: * @ejb.interface-method
792: * view-type="both"
793: **/
794: public EJBObject getPassedEJBObject() throws EJBException {
795: try {
796: return context.getEJBObject();
797: } catch (Exception ex) {
798: throw new EJBException(ex);
799: }
800: }
801:
802: public void setSessionContext(SessionContext ctx)
803: throws EJBException, RemoteException {
804: context = ctx;
805: }
806:
807: /**
808: * @ejb:create-method
809: */
810: public void ejbCreate(
811: org.enhydra.shark.api.client.wfmodel.WfActivity act) {
812: sharkObj = act;
813: }
814:
815: /* (non-Javadoc)
816: * @see javax.ejb.SessionBean#ejbActivate()
817: */
818: public void ejbActivate() throws EJBException, RemoteException {
819: }
820:
821: /* (non-Javadoc)
822: * @see javax.ejb.SessionBean#ejbPassivate()
823: */
824: public void ejbPassivate() throws EJBException, RemoteException {
825: }
826:
827: /* (non-Javadoc)
828: * @see javax.ejb.SessionBean#ejbRemove()
829: */
830: public void ejbRemove() throws EJBException, RemoteException {
831: }
832: }
|