KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > shark > corba > WfProcessMgrCORBA


1 package org.enhydra.shark.corba;
2
3 import org.omg.WfBase.BaseException;
4 import org.omg.WfBase.NameValueInfo;
5 import org.omg.WorkflowModel.*;
6
7 /**
8  * WfProcessMgrImpl - Workflow Process Manager implementation
9  */

10
11 public class WfProcessMgrCORBA extends _WfProcessMgrImplBase {
12
13    org.enhydra.shark.api.client.wfmodel.WfProcessMgr sharkProcMgr;
14
15    private Collective __collective;
16
17    /**
18     * Creates new WfProcessMgrImpl
19     *
20     * @param sharkProcMgr a WfProcessMgr
21     */

22    protected WfProcessMgrCORBA(Collective toJoin,
23                                org.enhydra.shark.api.client.wfmodel.WfProcessMgr sharkProcMgr) {
24       __collective = toJoin;
25       toJoin.__recruit(this);
26       this.sharkProcMgr = sharkProcMgr;
27    }
28
29    public int how_many_process() throws BaseException {
30       try {
31          return sharkProcMgr.how_many_process();
32       } catch (Exception JavaDoc ex) {
33          throw new BaseException();
34       }
35    }
36
37    public WfProcessIterator get_iterator_process() throws BaseException {
38       try {
39          return new WfProcessIteratorCORBA(__collective,
40                                            sharkProcMgr.get_iterator_process());
41       } catch (Exception JavaDoc ex) {
42          throw new BaseException();
43       }
44    }
45
46    public WfProcess[] get_sequence_process(int max_number) throws BaseException {
47       try {
48          return SharkCORBAUtilities.makeCORBAProcesses(__collective,
49                                                        sharkProcMgr.get_sequence_process(max_number));
50       } catch (Exception JavaDoc ex) {
51          throw new BaseException();
52       }
53    }
54
55    public boolean is_member_of_process(WfProcess member) throws BaseException {
56       try {
57          WfProcess[] procs = get_sequence_process(0);
58          boolean ret = false;
59          if (procs != null) {
60             for (int i = 0; i < procs.length; i++) {
61                if (procs[i].key().equals(member.key())) {
62                   ret = true;
63                   break;
64                }
65             }
66          }
67          return ret;
68       } catch (Exception JavaDoc ex) {
69          throw new BaseException();
70       }
71    }
72
73    public process_mgr_stateType process_mgr_state() throws BaseException {
74       try {
75          return process_mgr_stateType.from_int(sharkProcMgr.process_mgr_state()
76             .value());
77       } catch (Exception JavaDoc ex) {
78          throw new BaseException();
79       }
80    }
81
82    public void set_process_mgr_state(process_mgr_stateType new_state) throws BaseException,
83                                                                      TransitionNotAllowed {
84       try {
85          sharkProcMgr.set_process_mgr_state(org.enhydra.shark.api.client.wfmodel.process_mgr_stateType.from_int(new_state.value()));
86       } catch (org.enhydra.shark.api.client.wfmodel.TransitionNotAllowed tna) {
87          throw new TransitionNotAllowed();
88       } catch (Exception JavaDoc ex) {
89          throw new BaseException();
90       }
91    }
92
93    public String JavaDoc name() throws BaseException {
94       try {
95          return sharkProcMgr.name();
96       } catch (Exception JavaDoc ex) {
97          throw new BaseException();
98       }
99    }
100
101    public String JavaDoc description() throws BaseException {
102       try {
103          return sharkProcMgr.description();
104       } catch (Exception JavaDoc ex) {
105          throw new BaseException();
106       }
107    }
108
109    public String JavaDoc category() throws BaseException {
110       try {
111          return sharkProcMgr.category();
112       } catch (Exception JavaDoc ex) {
113          throw new BaseException();
114       }
115    }
116
117    public String JavaDoc version() throws BaseException {
118       try {
119          return sharkProcMgr.version();
120       } catch (Exception JavaDoc ex) {
121          throw new BaseException();
122       }
123    }
124
125    public NameValueInfo[] context_signature() throws BaseException {
126       try {
127          return SharkCORBAUtilities.makeCORBANameValueInfoArray(sharkProcMgr.context_signature());
128       } catch (Exception JavaDoc ex) {
129          throw new BaseException();
130       }
131    }
132
133    public NameValueInfo[] result_signature() throws BaseException {
134       try {
135          return SharkCORBAUtilities.makeCORBANameValueInfoArray(sharkProcMgr.result_signature());
136       } catch (Exception JavaDoc ex) {
137          throw new BaseException();
138       }
139    }
140
141    /**
142     * Create a WfProcess object
143     */

144    public WfProcess create_process(WfRequester requester) throws BaseException,
145                                                          NotEnabled,
146                                                          InvalidRequester,
147                                                          RequesterRequired {
148
149       if (requester == null) throw new RequesterRequired();
150
151       if (requester instanceof WfActivity) { throw new BaseException(); }
152
153       try {
154          WfLinkingRequesterForCORBA lr = new WfLinkingRequesterForCORBA();
155          org.enhydra.shark.api.client.wfmodel.WfProcess procInternal=
156             sharkProcMgr.create_process(lr);
157          WfLinkingRequesterForCORBA.setCORBARequester(procInternal.key(), requester);
158          WfProcess pr = new WfProcessCORBA(__collective,procInternal);
159          return pr;
160       } catch (org.enhydra.shark.api.client.wfmodel.NotEnabled ne) {
161          throw new NotEnabled();
162       } catch (org.enhydra.shark.api.client.wfmodel.InvalidRequester ir) {
163          throw new InvalidRequester();
164       } catch (org.enhydra.shark.api.client.wfmodel.RequesterRequired rr) {
165          throw new RequesterRequired();
166       } catch (Exception JavaDoc ex) {
167          throw new BaseException();
168       }
169    }
170
171    /**
172     * It is assumed that there can't be two or more processes mgrs
173     * having the same name.
174     */

175    public boolean equals(Object JavaDoc obj) {
176       if (!(obj instanceof WfProcessMgr)) return false;
177       WfProcessMgr mgr = (WfProcessMgr) obj;
178       try {
179          return mgr.name().equals(name());
180       } catch (Exception JavaDoc ex) {
181          return false;
182       }
183    }
184
185    public String JavaDoc toString() {
186       return sharkProcMgr.toString();
187    }
188
189 }
190
191
Popular Tags