1 package org.enhydra.shark.corbaclient.workflowadmin.monitoring; 2 3 import java.awt.*; 4 import java.awt.event.*; 5 import javax.swing.*; 6 import javax.swing.border.*; 7 import javax.swing.event.*; 8 import javax.swing.table.*; 9 import java.util.*; 10 11 import org.omg.WorkflowModel.*; 12 import org.enhydra.jawe.xml.elements.*; 13 import org.enhydra.shark.corbaclient.*; 14 import org.enhydra.shark.corbaclient.workflowadmin.monitoring.actions.*; 15 import org.enhydra.jawe.xml.elements.*; 16 import org.enhydra.shark.corba.WorkflowService.*; 17 18 24 public class HistoryTable extends ActionPanel { 25 26 private TablePanel historyTablePanel; 27 28 private WfProcess myProcess; 29 private WorkflowProcess myProcessDefinition; 30 31 private ProcessMonitor processMonitor; 32 33 34 public HistoryTable (ProcessMonitor pm,WfProcess proc,WorkflowProcess wp) { 35 super(); 36 this.myProcess=proc; 37 this.myProcessDefinition=wp; 38 super.init(); 39 this.setPreferredSize(new Dimension(1000,600)); 40 super.initDialog(pm.getWorkflowAdmin().getFrame(), 41 ResourceManager.getLanguageDependentString("DialogEventHistory"), 42 true,false); 43 } 44 45 protected void createActions () {} 46 47 50 protected Component createCenterComponent() { 51 Vector columnNames=new Vector(); 52 columnNames.add(ResourceManager.getLanguageDependentString("TimeKey")); 53 columnNames.add(ResourceManager.getLanguageDependentString("DescriptionKey")); 54 historyTablePanel=new TablePanel(columnNames,true); 55 fillTable(); 56 JTable t=historyTablePanel.getTable(); 57 TableColumnModel tcm=t.getColumnModel(); 58 TableColumn column=t.getColumnModel().getColumn(0); 59 column.setPreferredWidth(125); 60 column=t.getColumnModel().getColumn(1); 61 column.setPreferredWidth(825); 62 return historyTablePanel; 63 } 64 65 protected void applyChanges () { 66 myDialog.dispose(); 67 } 68 69 protected void cancelChanges () { 70 myDialog.dispose(); 71 } 72 73 public void fillTable () { 74 java.util.List l=new ArrayList(); 75 try { 76 WfCreateProcessEventAudit cpea=SharkClient.getExecAmin().getCreateProcessHistory(myProcess.key()); 79 if (cpea!=null) { 80 l.add(new HistoryData(cpea)); 81 } 82 WfEventAudit[] procEvents; 83 try { 84 procEvents=SharkClient.getExecAmin().getProcessSequenceStateHistory(myProcess.key(),0); 85 } catch (Exception ex){ 86 procEvents=null; 87 } 88 if (procEvents!=null) { 89 for (int i=0; i<procEvents.length; i++) { 90 l.add(new HistoryData(procEvents[i])); 91 } 92 } 93 try { 94 procEvents=SharkClient.getExecAmin().getProcessSequenceDataHistory(myProcess.key(),0); 95 } catch (Exception ex) { 96 procEvents=null; 97 } 98 if (procEvents!=null) { 99 for (int i=0; i<procEvents.length; i++) { 100 l.add(new HistoryData(procEvents[i])); 101 } 102 } 103 104 WfActivity[] acts=myProcess.get_sequence_step(0); 106 if (acts!=null) { 107 for (int i=0; i<acts.length; i++) { 108 WfEventAudit[] actEvents; 110 try { 111 actEvents=SharkClient.getExecAmin().getActivitySequenceStateHistory(myProcess.key(),acts[i].key(),0); 112 } catch (Exception ex) { 113 actEvents=null; 114 } 115 if (actEvents!=null) { 116 for (int j=0; j<actEvents.length; j++) { 117 l.add(new HistoryData(actEvents[j])); 118 } 119 } 120 try { 121 actEvents=SharkClient.getExecAmin().getActivitySequenceDataHistory(myProcess.key(),acts[i].key(),0); 122 } catch (Exception ex) { 123 actEvents=null; 124 } 125 if (actEvents!=null) { 126 for (int j=0; j<actEvents.length; j++) { 127 l.add(new HistoryData(actEvents[j])); 128 } 129 } 130 try { 131 actEvents=SharkClient.getExecAmin().getSequenceAssignmentHistory(myProcess.key(),acts[i].key(),0); 132 } catch (Exception ex) { 133 actEvents=null; 134 } 135 if (actEvents!=null) { 136 for (int j=0; j<actEvents.length; j++) { 137 l.add(new HistoryData(actEvents[j])); 138 } 139 } 140 } 141 } 142 } catch (Exception ex) {ex.printStackTrace();} 143 144 Collections.sort(l,new HistoryDataComparator()); 147 148 Iterator it=l.iterator(); 150 while (it.hasNext()) { 151 HistoryData hd=(HistoryData)it.next(); 152 try { 153 Vector v=new Vector(); 154 v.add(hd.time); 155 v.add(hd.description); 156 try { 157 historyTablePanel.addElement(v); 158 } catch (Exception ex) { 159 System.out.println("Incorrect vector size"); 160 } 161 } catch (Exception ex) {ex.printStackTrace();} 162 } 163 } 164 165 class HistoryData { 166 long utcTime; 167 String time; 168 String description; 169 170 HistoryData (WfEventAudit ev) { 171 init(ev); 172 } 173 174 private void init (WfEventAudit ev) { 175 AdminMisc s=SharkClient.getAdminMiscUtilities(); 176 try { 177 utcTime=ev.time_stamp().time; 178 time=WorkflowUtilities.getDateFromUTC(ev.time_stamp()); 179 if (ev instanceof WfCreateProcessEventAudit) { 180 WfCreateProcessEventAudit ea=(WfCreateProcessEventAudit)ev; 181 description="Process instantiated"; 182 try { 186 description+=" by activity [packageId="+s.getProcessMgrPkgId(ea.p_process_mgr_name())+ 187 ", procDefId="+s.getProcessDefinitionId(ea.p_process_key())+ 188 ", actDefId="+s.getActivityDefinitionId(ea.p_process_key(),ea.p_activity_key())+ 189 ", procId="+ea.p_process_key()+ 190 ", actId="+ea.p_activity_key()+"]"; 191 192 } catch (Exception ex) {} 193 } else if (ev instanceof WfStateEventAudit) { 195 WfStateEventAudit ea=(WfStateEventAudit)ev; 196 try { 199 description="Activity [actDefId="+s.getActivityDefinitionId(ea.process_key(),ea.activity_key())+ 200 ", actId="+ea.activity_key()+"] changed state"; 201 } catch (Exception ex) { 202 description="Process changed state"; 203 } 204 try { 208 description+=" from "+ea.old_state(); 209 } catch (Exception ex) {} 210 description+=" to "+ea.new_state(); 211 } else if (ev instanceof WfDataEventAudit) { 213 WfDataEventAudit ea=(WfDataEventAudit)ev; 214 try { 217 s.getActivityDefinitionId(ea.process_key(),ea.activity_key()); if (ea.event_type().equals("activityResultChanged")) { 220 description="Activity context changed as a result of an activity setResult() method"; 221 } else { 222 description="Activity [actDefId="+s.getActivityDefinitionId(ea.process_key(),ea.activity_key())+ 223 ", actId="+ea.activity_key()+"] context changed "; 224 } 225 } catch (Exception ex) { 226 description="Process context changed "; 227 } 228 } else if (ev instanceof WfAssignmentEventAudit) { 230 WfAssignmentEventAudit ea=(WfAssignmentEventAudit)ev; 231 description="Activity [actDefId="+s.getActivityDefinitionId(ea.process_key(),ea.activity_key())+ 232 ", actId="+ea.activity_key()+"]"; 233 try { 237 if (ea.old_resource_key().equals(ea.new_resource_key())) { 238 if (ea.is_accepted()) { 239 description+=" is accepted by "+ea.new_resource_key(); 240 } else { 241 description+=" is rejected by "+ea.new_resource_key(); 242 } 243 } else { 244 description+=" is reassigned from "+ea.old_resource_key()+ 245 " to "+ea.new_resource_key(); 246 } 247 } catch (Exception ex) { 248 description+=" is assigned to "+ea.new_resource_key(); 249 } 250 252 } else { 253 } 255 } catch (Exception ex) {ex.printStackTrace();} 256 } 257 258 259 } 260 261 class HistoryDataComparator implements Comparator { 262 public int compare(Object o1,Object o2) { 263 HistoryData hd1=(HistoryData)o1; 264 HistoryData hd2=(HistoryData)o2; 265 long t1=hd1.utcTime; 266 long t2=hd2.utcTime; 267 268 return (t1<t2 ? -1 : (t1==t2 ? 0 : 1)); 269 } 270 } 271 272 } 273 274 275 | Popular Tags |