1 25 package org.ofbiz.workflow.impl; 26 27 import java.sql.Timestamp ; 28 import java.util.Date ; 29 30 import org.ofbiz.base.util.ObjectType; 31 import org.ofbiz.workflow.SourceNotAvailable; 32 import org.ofbiz.workflow.WfActivity; 33 import org.ofbiz.workflow.WfEventAudit; 34 import org.ofbiz.workflow.WfException; 35 import org.ofbiz.workflow.WfExecutionObject; 36 import org.ofbiz.workflow.WfProcess; 37 38 45 public class WfEventAuditImpl implements WfEventAudit { 46 47 private WfExecutionObject object = null; 48 private String eventType = null; 49 private Timestamp timeStamp = null; 50 51 public WfEventAuditImpl(WfExecutionObject object, String eventType) { 52 this.object = object; 53 this.eventType = eventType; 54 this.timeStamp = new Timestamp (new Date ().getTime()); 55 } 56 57 60 public WfExecutionObject source() throws WfException, SourceNotAvailable { 61 return object; 62 } 63 64 67 public Timestamp timeStamp() throws WfException { 68 return timeStamp; 69 } 70 71 74 public String eventType() throws WfException { 75 return eventType; 76 } 77 78 81 public String activityKey() throws WfException { 82 try { 83 if (ObjectType.instanceOf(object, "org.ofbiz.workflow.WfActivity")) 84 return object.key(); 85 } catch (Exception e) { 86 throw new WfException("Source is not a WfActivity object"); 87 } 88 throw new WfException("Source is not a WfActivity object"); 89 } 90 91 94 public String activityName() throws WfException { 95 try { 96 if (ObjectType.instanceOf(object, "org.ofbiz.workflow.WfActivity")) 97 return object.name(); 98 } catch (Exception e) {} 99 throw new WfException("Source is not a WfActivity object"); 100 101 } 102 103 106 public String processKey() throws WfException { 107 try { 108 if (ObjectType.instanceOf(object, "org.ofbiz.workflow.WfProcess")) 109 return object.key(); 110 } catch (Exception e) {} 111 throw new WfException("Source is not a WfProcess object"); 112 113 } 114 115 118 public String processName() throws WfException { 119 try { 120 if (ObjectType.instanceOf(object, "org.ofbiz.workflow.WfProcess")) 121 return object.name(); 122 } catch (Exception e) {} 123 throw new WfException("Source is not a WfProcess object"); 124 125 } 126 127 130 public String processMgrName() throws WfException { 131 try { 132 if (ObjectType.instanceOf(object, "org.ofbiz.workflow.WfProcess")) 133 return ((WfProcess) object).manager().name(); 134 else if (ObjectType.instanceOf(object, "org.ofbiz.workflow.WfActivity")) 135 return ((WfActivity) object).container().manager().name(); 136 } catch (Exception e) {} 137 throw new WfException("Illegal source object"); 138 } 139 140 143 public String processMgrVersion() throws WfException { 144 try { 145 if (ObjectType.instanceOf(object, "org.ofbiz.workflow.WfProcess")) 146 return ((WfProcess) object).manager().version(); 147 else if (ObjectType.instanceOf(object, "org.ofbiz.workflow.WfActivity")) 148 return ((WfActivity) object).container().manager().version(); 149 } catch (Exception e) {} 150 throw new WfException("Illegal source object"); 151 } 152 } 153 154 | Popular Tags |