1 package org.enhydra.shark.swingclient.workflowadmin.instantiation; 2 3 import java.util.ArrayList ; 4 import java.util.List ; 5 6 import org.enhydra.shark.api.SharkTransaction; 7 import org.enhydra.shark.api.client.wfbase.BaseException; 8 import org.enhydra.shark.api.client.wfmodel.InvalidPerformer; 9 import org.enhydra.shark.api.client.wfmodel.WfDataEventAudit; 10 import org.enhydra.shark.api.client.wfmodel.WfEventAudit; 11 import org.enhydra.shark.api.client.wfmodel.WfProcess; 12 import org.enhydra.shark.api.client.wfmodel.WfProcessIterator; 13 import org.enhydra.shark.api.client.wfmodel.WfRequester; 14 import org.enhydra.shark.api.client.wfmodel.WfStateEventAudit; 15 import org.enhydra.shark.swingclient.SharkClient; 16 17 20 public class ProcessInstantiator implements WfRequester { 21 22 private List performers=new ArrayList (); 23 24 25 public ProcessInstantiator() { 26 } 27 28 public void addPerformer (WfProcess pr) { 29 try { 30 performers.add(pr.key()); 31 } catch (Exception ex) {} 32 } 33 36 public int how_many_performer () throws BaseException { 37 return performers.size(); 38 } 39 40 public int how_many_performer (SharkTransaction t) throws BaseException { 41 return performers.size(); 42 } 43 44 46 public WfProcessIterator get_iterator_performer () throws BaseException { 47 throw new BaseException("Not implemented"); 48 } 49 50 public WfProcessIterator get_iterator_performer (SharkTransaction t) throws BaseException { 51 throw new BaseException("Not implemented"); 52 } 53 54 58 public WfProcess[] get_sequence_performer (int max_number) throws BaseException { 59 return get_sequence_performer(null,max_number); 60 } 61 62 public WfProcess[] get_sequence_performer (SharkTransaction t,int max_number) throws BaseException { 63 WfProcess[] processes=new WfProcess[performers.size()]; 64 for (int i=0; i<processes.length; i++) { 65 try { 66 processes[i]=SharkClient.getExecAmin().getProcess(performers.get(i).toString()); 67 } catch (Exception ex) {} 68 } 69 return processes; 70 } 71 72 77 public boolean is_member_of_performer (WfProcess member) throws BaseException { 78 return performers.contains(member); 79 } 80 81 public boolean is_member_of_performer (SharkTransaction t,WfProcess member) throws BaseException { 82 return performers.contains(member); 83 } 84 85 88 public void receive_event (WfEventAudit event) throws BaseException, InvalidPerformer { 89 throw new BaseException("Not implemented"); 90 } 91 92 public void receive_event (SharkTransaction t,WfEventAudit event) throws BaseException, InvalidPerformer { 93 try { 94 String msg="ProcessInstantiator -> Event received:"+ 95 " \n\tevent time --> "+event.time_stamp().getTimestamp()+ 96 " \n\tprocess id --> "+event.process_key()+ 97 " \n\tevent type --> "+event.event_type(); 98 if (event instanceof WfStateEventAudit) { 99 msg+=" \n\told state --> "+((WfStateEventAudit)event).old_state(); 100 msg+=" \n\tnew state --> "+((WfStateEventAudit)event).new_state(); 101 } 102 if (event instanceof WfDataEventAudit) { 103 msg+=" \n\told data --> "+((WfDataEventAudit)event).old_data(); 104 msg+=" \n\tnew data --> "+((WfDataEventAudit)event).new_data(); 105 } 106 System.out.println(msg); 107 } catch (Exception ex) { 108 ex.printStackTrace(); 109 } 110 } 111 112 } 113 | Popular Tags |