1 5 package org.ofbiz.shark.instance; 6 7 import org.ofbiz.entity.GenericDelegator; 8 import org.ofbiz.entity.GenericValue; 9 import org.ofbiz.entity.GenericEntityException; 10 import org.ofbiz.base.util.UtilMisc; 11 import org.ofbiz.base.util.Debug; 12 import org.ofbiz.shark.container.SharkContainer; 13 14 import org.enhydra.shark.api.internal.instancepersistence.DeadlinePersistenceInterface; 15 import org.enhydra.shark.api.internal.instancepersistence.PersistenceException; 16 17 23 public class Deadline extends InstanceEntityObject implements DeadlinePersistenceInterface { 24 25 public static final String module = Deadline.class.getName(); 26 27 protected GenericValue deadline = null; 28 protected boolean newValue = false; 29 30 protected Deadline(EntityPersistentMgr mgr, GenericDelegator delegator, String deadlineId) throws PersistenceException { 31 super(mgr, delegator); 32 if (this.delegator != null) { 33 try { 34 this.deadline = delegator.findByPrimaryKey("WfDeadline", UtilMisc.toMap("deadlineId", deadlineId)); 35 } catch (GenericEntityException e) { 36 throw new PersistenceException(e); 37 } 38 } else { 39 Debug.logError("Invalid delegator object passed", module); 40 } 41 } 42 43 protected Deadline(EntityPersistentMgr mgr, GenericValue deadline) { 44 super(mgr, deadline.getDelegator()); 45 this.deadline = deadline; 46 } 47 48 public Deadline(EntityPersistentMgr mgr, GenericDelegator delegator) { 49 super(mgr, delegator); 50 this.newValue = true; 51 this.deadline = delegator.makeValue("WfDeadline", UtilMisc.toMap("deadlineId", delegator.getNextSeqId("WfDeadline"))); 52 } 53 54 public static Deadline getInstance(EntityPersistentMgr mgr, GenericValue deadlineV) { 55 Deadline deadline = new Deadline(mgr, deadlineV); 56 if (deadline.isLoaded()) { 57 return deadline; 58 } 59 return null; 60 } 61 62 public static Deadline getInstance(EntityPersistentMgr mgr, String deadlineId) throws PersistenceException { 63 Deadline deadline = new Deadline(mgr, SharkContainer.getDelegator(), deadlineId); 64 if (deadline.isLoaded()) { 65 return deadline; 66 } 67 return null; 68 } 69 70 public boolean isLoaded() { 71 if (deadline == null) { 72 return false; 73 } 74 return true; 75 } 76 77 public void setProcessId(String procId) { 78 this.deadline.set("processId", procId); 79 } 80 81 public String getProcessId() { 82 return this.deadline.getString("processId"); 83 } 84 85 public void setActivityId(String actId) { 86 this.deadline.set("activityId", actId); 87 } 88 89 public String getActivityId() { 90 return this.deadline.getString("activityId"); 91 } 92 93 public void setTimeLimit(long timeLimit) { 94 this.deadline.set("timeLimit", new Long (timeLimit)); 95 } 96 97 public long getTimeLimit() { 98 if (this.deadline.get("timeLimit") != null) { 99 return this.deadline.getLong("timeLimit").longValue(); 100 } else { 101 return -1; 102 } 103 } 104 105 public void setExceptionName(String exceptionName) { 106 this.deadline.set("exceptionName", exceptionName); 107 } 108 109 public String getExceptionName() { 110 return this.deadline.getString("exceptionName"); 111 } 112 113 public void setSynchronous(boolean sync) { 114 this.deadline.set("isSync", sync ? "Y" : "N"); 115 } 116 117 public boolean isSynchronous() { 118 return (this.deadline.get("isSync") == null ? false : "Y".equalsIgnoreCase(this.deadline.getString("isSync"))); 119 } 120 121 public void setExecuted(boolean ex) { 122 this.deadline.set("isExecuted", ex ? "Y" : "N"); 123 } 124 125 public boolean isExecuted() { 126 return (this.deadline.get("isExecuted") == null ? false : "Y".equalsIgnoreCase(this.deadline.getString("isExecuted"))); 127 } 128 129 public void setUniqueId(String s) { 130 this.deadline.set("deadlineId", s); 131 } 132 133 public String getUniqueId() { 134 return this.deadline.getString("deadlineId"); 135 } 136 137 public void store() throws GenericEntityException { 138 if (newValue) { 139 newValue = false; 140 delegator.createOrStore(deadline); 141 } else { 142 delegator.store(deadline); 143 } 144 } 145 146 public void reload() throws GenericEntityException { 147 if (!newValue) { 148 deadline.refresh(); 149 } 150 } 151 152 public void remove() throws GenericEntityException { 153 if (!newValue) { 154 delegator.removeValue(deadline); 155 } 156 } 157 } 158 | Popular Tags |