1 package org.enhydra.shark.corba.poa; 2 3 import org.omg.TimeBase.UtcT; 4 import org.omg.WfBase.BaseException; 5 import org.omg.WfBase.NameValue; 6 import org.omg.WorkflowModel.*; 7 import org.omg.CORBA.ORB ; 8 import org.omg.PortableServer.POA ; 9 import org.omg.PortableServer.POAHelper ; 10 import org.omg.PortableServer.POAPackage.ServantAlreadyActive ; 11 import org.omg.PortableServer.POAPackage.WrongPolicy ; 12 import org.omg.PortableServer.POAPackage.ServantNotActive ; 13 import org.enhydra.shark.corba.poa.*; 14 15 21 public class WfProcessCORBA extends WfProcessPOA { 22 23 org.enhydra.shark.api.client.wfmodel.WfProcess sharkProc; 24 25 private Collective __collective; 26 private ORB orb; 27 28 33 protected WfProcessCORBA(ORB orb, Collective toJoin, 34 org.enhydra.shark.api.client.wfmodel.WfProcess sharkProc) { 35 36 __collective = toJoin; 37 this.orb = orb; 38 this.sharkProc = sharkProc; 40 } 41 42 45 public WfRequester requester() throws BaseException { 46 try { 47 WfRequester req; 48 org.enhydra.shark.api.client.wfmodel.WfRequester requester = sharkProc.requester(); 49 if (requester instanceof org.enhydra.shark.api.client.wfmodel.WfActivity) { 50 req = SharkCORBAUtilities.makeWfActivity(new WfActivityCORBA(orb, __collective, 51 (org.enhydra.shark.api.client.wfmodel.WfActivity) requester)); 52 } else if (requester instanceof WfLinkingRequesterForCORBA) { 53 req = WfLinkingRequesterForCORBA.getCORBARequester(sharkProc.key()); 54 } else { 55 req = SharkCORBAUtilities.makeWfRequester(new WfRequesterCORBA(orb , __collective, requester)); 56 } 57 __collective.__recruit(req); 58 return req; 59 } catch (Exception ex) { 60 throw new BaseException(); 61 } 62 } 63 64 67 public void set_requester(WfRequester new_value) throws BaseException, 68 CannotChangeRequester { 69 if (new_value == null) throw new CannotChangeRequester("Trying to set external requester which is null!"); 70 71 if (new_value instanceof WfActivity) { 72 throw new CannotChangeRequester("Can't change requester to activity requester"); 73 } 74 75 try { 76 77 WfLinkingRequesterForCORBA lr = new WfLinkingRequesterForCORBA(); 78 lr.setOrb(orb); 79 WfLinkingRequesterForCORBA.setCORBARequester(sharkProc.key(), new_value); 80 sharkProc.set_requester(lr); 81 82 } catch (org.enhydra.shark.api.client.wfmodel.CannotChangeRequester ccr) { 83 throw new CannotChangeRequester(); 84 } catch (Exception ex) { 85 throw new BaseException(); 86 } 87 } 88 89 92 public int how_many_step() throws BaseException { 93 try { 94 return sharkProc.how_many_step(); 95 } catch (Exception ex) { 96 throw new BaseException(); 97 } 98 } 99 100 103 public WfActivityIterator get_iterator_step() throws BaseException { 104 try { 105 WfActivityIterator iter = SharkCORBAUtilities.makeWfActivityIterator(new WfActivityIteratorCORBA(orb, __collective, 106 sharkProc.get_iterator_step())); 107 __collective.__recruit(iter); 108 return iter; 109 110 } catch (Exception ex) { 111 throw new BaseException(); 112 } 113 114 } 115 116 122 public WfActivity[] get_sequence_step(int max_number) throws BaseException { 123 try { 124 return SharkCORBAUtilities.makeCORBAActivities(__collective, 125 sharkProc.get_sequence_step(max_number)); 126 } catch (Exception ex) { 127 throw new BaseException(); 128 } 129 } 130 131 137 public boolean is_member_of_step(WfActivity member) throws BaseException { 138 try { 139 WfActivity[] acts = get_sequence_step(0); 140 boolean ret = false; 141 if (acts != null) { 142 for (int i = 0; i < acts.length; i++) { 143 WfActivity act = acts[i]; 144 if (act.key().equals(member.key())) { 145 ret = true; 146 break; 147 } 148 } 149 } 150 return ret; 151 } catch (Exception ex) { 152 throw new BaseException(); 153 } 154 } 155 156 159 public WfProcessMgr manager() throws BaseException { 160 WfProcessMgr ret = null ; 161 try { 162 ret = SharkCORBAUtilities.makeWfProcessMgr(new WfProcessMgrCORBA(orb, __collective, sharkProc.manager()) ); 163 } catch (org.enhydra.shark.api.client.wfbase.BaseException e) { 164 e.printStackTrace(); 165 throw new BaseException(); 166 } 167 __collective.__recruit(ret); 168 return ret; 169 } 170 171 174 public NameValue[] result() throws BaseException, ResultNotAvailable { 175 try { 176 return SharkCORBAUtilities.makeCORBANameValueArray(orb, 177 sharkProc.result()); 178 } catch (org.enhydra.shark.api.client.wfmodel.ResultNotAvailable rna) { 179 throw new ResultNotAvailable(); 180 } catch (Exception ex) { 181 throw new BaseException(); 182 } 183 } 184 185 188 public void start() throws BaseException, CannotStart, AlreadyRunning { 189 try { 190 sharkProc.start(); 191 } catch (org.enhydra.shark.api.client.wfmodel.CannotStart cns) { 192 throw new CannotStart(); 193 } catch (org.enhydra.shark.api.client.wfmodel.AlreadyRunning ar) { 194 throw new AlreadyRunning(); 195 } catch (Exception ex) { 196 throw new BaseException(); 197 } 198 } 199 200 203 public WfActivityIterator get_activities_in_state(String state) throws BaseException, 204 InvalidState { 205 try { 206 WfActivityIterator iter = SharkCORBAUtilities.makeWfActivityIterator(new WfActivityIteratorCORBA(orb, __collective, 207 sharkProc.get_activities_in_state(state))); 208 __collective.__recruit(iter); 209 return iter; 210 } catch (org.enhydra.shark.api.client.wfmodel.InvalidState is) { 211 throw new InvalidState(); 212 } catch (Exception ex) { 213 throw new BaseException(); 214 } 215 } 216 217 public workflow_stateType workflow_state() throws BaseException { 218 try { 219 return workflow_stateType.from_int(sharkProc.workflow_state() 220 .value()); 221 } catch (Exception ex) { 222 throw new BaseException(); 223 } 224 } 225 226 public while_openType while_open() throws BaseException { 227 try { 228 return while_openType.from_int(sharkProc.while_open().value()); 229 } catch (Exception ex) { 230 throw new BaseException(); 231 } 232 } 233 234 public why_not_runningType why_not_running() throws BaseException { 235 try { 236 return why_not_runningType.from_int(sharkProc.why_not_running() 237 .value()); 238 } catch (Exception ex) { 239 throw new BaseException(); 240 } 241 } 242 243 public how_closedType how_closed() throws BaseException { 244 try { 245 return how_closedType.from_int(sharkProc.how_closed().value()); 246 } catch (Exception ex) { 247 throw new BaseException(); 248 } 249 } 250 251 public String [] valid_states() throws BaseException { 252 try { 253 return sharkProc.valid_states(); 254 } catch (Exception ex) { 255 throw new BaseException(); 256 } 257 } 258 259 public String state() throws BaseException { 260 try { 261 return sharkProc.state(); 262 } catch (Exception ex) { 263 throw new BaseException(); 264 } 265 } 266 267 public void change_state(String new_state) throws BaseException, 268 InvalidState, 269 TransitionNotAllowed { 270 try { 271 sharkProc.change_state(new_state); 272 } catch (org.enhydra.shark.api.client.wfmodel.InvalidState is) { 273 throw new InvalidState(); 274 } catch (org.enhydra.shark.api.client.wfmodel.TransitionNotAllowed tna) { 275 throw new TransitionNotAllowed(); 276 } catch (Exception ex) { 277 throw new BaseException(); 278 } 279 } 280 281 public String name() throws BaseException { 282 try { 283 return sharkProc.name(); 284 } catch (Exception ex) { 285 throw new BaseException(); 286 } 287 } 288 289 public void set_name(String new_value) throws BaseException { 290 try { 291 sharkProc.set_name(new_value); 292 } catch (Exception ex) { 293 throw new BaseException(); 294 } 295 } 296 297 public String key() throws BaseException { 298 try { 299 return sharkProc.key(); 300 } catch (Exception ex) { 301 throw new BaseException(); 302 } 303 } 304 305 public String description() throws BaseException { 306 try { 307 return sharkProc.description(); 308 } catch (Exception ex) { 309 throw new BaseException(); 310 } 311 } 312 313 public void set_description(String new_value) throws BaseException { 314 try { 315 sharkProc.set_description(new_value); 316 } catch (Exception ex) { 317 throw new BaseException(); 318 } 319 } 320 321 public NameValue[] process_context() throws BaseException { 322 try { 323 return SharkCORBAUtilities.makeCORBANameValueArray(orb, 324 sharkProc.process_context()); 325 } catch (Exception ex) { 326 throw new BaseException(); 327 } 328 } 329 330 public void set_process_context(NameValue[] new_value) throws BaseException, 331 InvalidData, 332 UpdateNotAllowed { 333 try { 334 sharkProc.set_process_context(SharkCORBAUtilities.makeMap(new_value)); 335 } catch (org.enhydra.shark.api.client.wfmodel.InvalidData id) { 336 throw new InvalidData(); 337 } catch (org.enhydra.shark.api.client.wfmodel.UpdateNotAllowed una) { 338 throw new UpdateNotAllowed(); 339 } catch (Exception ex) { 340 throw new BaseException(); 341 } 342 } 343 344 public short priority() throws BaseException { 345 try { 346 return sharkProc.priority(); 347 } catch (Exception ex) { 348 throw new BaseException(); 349 } 350 } 351 352 public void set_priority(short new_value) throws BaseException { 353 try { 354 sharkProc.set_priority(new_value); 355 } catch (Exception ex) { 356 throw new BaseException(); 357 } 358 } 359 360 363 public void resume() throws BaseException, CannotResume, NotSuspended { 364 try { 365 sharkProc.resume(); 366 } catch (org.enhydra.shark.api.client.wfmodel.CannotResume cnr) { 367 throw new CannotResume(); 368 } catch (org.enhydra.shark.api.client.wfmodel.NotSuspended ns) { 369 throw new NotSuspended(); 370 } catch (Exception ex) { 371 throw new BaseException(); 372 } 373 } 374 375 378 public void suspend() throws BaseException, 379 CannotSuspend, 380 NotRunning, 381 AlreadySuspended { 382 try { 383 sharkProc.suspend(); 384 } catch (org.enhydra.shark.api.client.wfmodel.CannotSuspend cns) { 385 throw new CannotSuspend(); 386 } catch (org.enhydra.shark.api.client.wfmodel.NotRunning nr) { 387 throw new NotRunning(); 388 } catch (org.enhydra.shark.api.client.wfmodel.AlreadySuspended as) { 389 throw new AlreadySuspended(); 390 } catch (Exception ex) { 391 throw new BaseException(); 392 } 393 } 394 395 398 public synchronized void terminate() throws BaseException, 399 CannotStop, 400 NotRunning { 401 try { 402 sharkProc.terminate(); 403 } catch (org.enhydra.shark.api.client.wfmodel.CannotStop cns) { 404 throw new CannotStop(); 405 } catch (org.enhydra.shark.api.client.wfmodel.NotRunning nr) { 406 throw new NotRunning(); 407 } catch (Exception ex) { 408 throw new BaseException(); 409 } 410 } 411 412 415 public synchronized void abort() throws BaseException, 416 CannotStop, 417 NotRunning { 418 try { 419 sharkProc.abort(); 420 } catch (org.enhydra.shark.api.client.wfmodel.CannotStop cns) { 421 throw new CannotStop(); 422 } catch (org.enhydra.shark.api.client.wfmodel.NotRunning nr) { 423 throw new NotRunning(); 424 } catch (Exception ex) { 425 throw new BaseException(); 426 } 427 } 428 429 public int how_many_history() throws BaseException, HistoryNotAvailable { 430 try { 431 return sharkProc.how_many_history(); 432 } catch (org.enhydra.shark.api.client.wfmodel.HistoryNotAvailable hna) { 433 throw new HistoryNotAvailable(); 434 } catch (Exception ex) { 435 throw new BaseException(); 436 } 437 } 438 439 444 public WfEventAuditIterator get_iterator_history(String query, 445 NameValue[] names_in_query) throws BaseException, 446 HistoryNotAvailable { 447 WfEventAuditIterator ret = null; 448 try { 449 ret = SharkCORBAUtilities.makeWfEventAuditIterator(new WfEventAuditIteratorCORBA(orb, __collective, sharkProc.get_iterator_history(query, 450 SharkCORBAUtilities.makeMap(names_in_query)))); 451 __collective.__recruit(ret); 452 } catch (org.enhydra.shark.api.client.wfmodel.HistoryNotAvailable hna) { 453 throw new HistoryNotAvailable(); 454 } catch (Exception ex) { 455 throw new BaseException(); 456 } 457 return ret; 458 } 459 460 465 public WfEventAudit[] get_sequence_history(int max_number) throws BaseException, 466 HistoryNotAvailable { 467 try { 468 return SharkCORBAUtilities.makeCORBAEventAudits(__collective, sharkProc.get_sequence_history(max_number)); 469 } catch (org.enhydra.shark.api.client.wfmodel.HistoryNotAvailable hna) { 470 throw new HistoryNotAvailable(); 471 } catch (Exception ex) { 472 throw new BaseException(); 473 } 474 } 475 476 481 public boolean is_member_of_history(WfExecutionObject member) throws BaseException { 482 try { 483 boolean ret = false; 484 WfEventAudit[] evs = SharkCORBAUtilities.makeCORBAEventAudits(__collective, sharkProc.get_sequence_history(0)); 485 if (evs != null) { 486 for (int i = 0; i < evs.length; i++) { 487 WfEventAudit ea = evs[i]; 488 if (member instanceof WfActivity) { 489 WfActivity act = (WfActivity) member; 490 if (act.container().key().equals(ea.process_key()) 491 && act.key().equals(ea.activity_key())) { 492 ret = true; 493 break; 494 } 495 } else { 496 if (member.key().equals(ea.process_key())) { 497 ret = true; 498 break; 499 } 500 } 501 } 502 } 503 return ret; 504 } catch (Exception ex) { 505 throw new BaseException(); 506 } 507 } 508 509 public UtcT last_state_time() throws BaseException { 510 try { 511 org.enhydra.shark.api.client.timebase.UtcT t = sharkProc.last_state_time(); 512 return new UtcT(t.time, t.inacclo, t.inacchi, t.tdf); 513 } catch (Exception ex) { 514 throw new BaseException(); 515 } 516 } 517 518 522 public boolean equals(java.lang.Object obj) { 523 if (!(obj instanceof WfProcess)) return false; 524 WfProcess proc = (WfProcess) obj; 525 try { 526 return proc.key().equals(key()); 527 } catch (Exception ex) { 528 return false; 529 } 530 } 531 532 public String toString() { 533 return sharkProc.toString(); 534 } 535 } | Popular Tags |