Modified: ofbiz/trunk/framework/shark/src/org/ofbiz/shark/instance/Deadline.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/shark/src/org/ofbiz/shark/instance/Deadline.java?view=diff&rev=498425&r1=498424&r2=498425 ============================================================================== --- ofbiz/trunk/framework/shark/src/org/ofbiz/shark/instance/Deadline.java (original) +++ ofbiz/trunk/framework/shark/src/org/ofbiz/shark/instance/Deadline.java Sun Jan 21 10:48:58 2007 @@ -18,15 +18,20 @@ *******************************************************************************/ package org.ofbiz.shark.instance; +import java.util.Date; + +import org.enhydra.shark.api.internal.instancepersistence.DeadlinePersistenceInterface; +import org.enhydra.shark.api.internal.instancepersistence.PersistenceException; +import org.ofbiz.base.util.Debug; +import org.ofbiz.base.util.UtilDateTime; +import org.ofbiz.base.util.UtilMisc; import org.ofbiz.entity.GenericDelegator; -import org.ofbiz.entity.GenericValue; + import org.ofbiz.entity.GenericEntityException; -import org.ofbiz.base.util.UtilMisc; -import org.ofbiz.base.util.Debug; +import org.ofbiz.entity.GenericValue; + import org.ofbiz.shark.container.SharkContainer; -import org.enhydra.shark.api.internal.instancepersistence.DeadlinePersistenceInterface; -import org.enhydra.shark.api.internal.instancepersistence.PersistenceException; public class Deadline extends InstanceEntityObject implements DeadlinePersistenceInterface { @@ -39,7 +44,7 @@ super(mgr, delegator); if (this.delegator != null) { try { - this.deadline = delegator.findByPrimaryKey("WfDeadline", UtilMisc.toMap("deadlineId", deadlineId)); + this.deadline = delegator.findByPrimaryKey(org.ofbiz.shark.SharkConstants.WfDeadline, UtilMisc.toMap(org.ofbiz.shark.SharkConstants.deadlineId, deadlineId)); } catch (GenericEntityException e) { throw new PersistenceException(e); } @@ -56,7 +61,7 @@ public Deadline(EntityPersistentMgr mgr, GenericDelegator delegator) { super(mgr, delegator); this.newValue = true; - this.deadline = delegator.makeValue("WfDeadline", UtilMisc.toMap("deadlineId", delegator.getNextSeqId("WfDeadline"))); + this.deadline = delegator.makeValue(org.ofbiz.shark.SharkConstants.WfDeadline, UtilMisc.toMap(org.ofbiz.shark.SharkConstants.deadlineId, delegator.getNextSeqId(org.ofbiz.shark.SharkConstants.WfDeadline))); } public static Deadline getInstance(EntityPersistentMgr mgr, GenericValue deadlineV) { @@ -83,63 +88,63 @@ } public void setProcessId(String procId) { - this.deadline.set("processId", procId); + this.deadline.set(org.ofbiz.shark.SharkConstants.processId, procId); } public String getProcessId() { - return this.deadline.getString("processId"); + return this.deadline.getString(org.ofbiz.shark.SharkConstants.processId); } public void setActivityId(String actId) { - this.deadline.set("activityId", actId); + this.deadline.set(org.ofbiz.shark.SharkConstants.activityId, actId); } public String getActivityId() { - return this.deadline.getString("activityId"); + return this.deadline.getString(org.ofbiz.shark.SharkConstants.activityId); } public void setTimeLimit(long timeLimit) { - this.deadline.set("timeLimit", new Long(timeLimit)); + deadline.set(org.ofbiz.shark.SharkConstants.timeLimit, new Long(timeLimit)); } public long getTimeLimit() { - if (this.deadline.get("timeLimit") != null) { - return this.deadline.getLong("timeLimit").longValue(); + if (this.deadline.get(org.ofbiz.shark.SharkConstants.timeLimit) != null) { + return this.deadline.getLong(org.ofbiz.shark.SharkConstants.timeLimit).longValue(); } else { return -1; } } public void setExceptionName(String exceptionName) { - this.deadline.set("exceptionName", exceptionName); + this.deadline.set(org.ofbiz.shark.SharkConstants.exceptionName, exceptionName); } public String getExceptionName() { - return this.deadline.getString("exceptionName"); + return this.deadline.getString(org.ofbiz.shark.SharkConstants.exceptionName); } public void setSynchronous(boolean sync) { - this.deadline.set("isSync", sync ? "Y" : "N"); + this.deadline.set(org.ofbiz.shark.SharkConstants.isSync, sync ? "Y" : "N"); } public boolean isSynchronous() { - return (this.deadline.get("isSync") == null ? false : "Y".equalsIgnoreCase(this.deadline.getString("isSync"))); + return (this.deadline.get(org.ofbiz.shark.SharkConstants.isSync) == null ? false : "Y".equalsIgnoreCase(this.deadline.getString(org.ofbiz.shark.SharkConstants.isSync))); } public void setExecuted(boolean ex) { - this.deadline.set("isExecuted", ex ? "Y" : "N"); + this.deadline.set(org.ofbiz.shark.SharkConstants.isExecuted, ex ? "Y" : "N"); } public boolean isExecuted() { - return (this.deadline.get("isExecuted") == null ? false : "Y".equalsIgnoreCase(this.deadline.getString("isExecuted"))); + return (this.deadline.get(org.ofbiz.shark.SharkConstants.isExecuted) == null ? false : "Y".equalsIgnoreCase(this.deadline.getString(org.ofbiz.shark.SharkConstants.isExecuted))); } public void setUniqueId(String s) { - this.deadline.set("deadlineId", s); + this.deadline.set(org.ofbiz.shark.SharkConstants.deadlineId, s); } public String getUniqueId() { - return this.deadline.getString("deadlineId"); + return this.deadline.getString(org.ofbiz.shark.SharkConstants.deadlineId); } public void store() throws GenericEntityException { Modified: ofbiz/trunk/framework/shark/src/org/ofbiz/shark/instance/EntityPersistentMgr.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/shark/src/org/ofbiz/shark/instance/EntityPersistentMgr.java?view=diff&rev=498425&r1=498424&r2=498425 ============================================================================== --- ofbiz/trunk/framework/shark/src/org/ofbiz/shark/instance/EntityPersistentMgr.java (original) +++ ofbiz/trunk/framework/shark/src/org/ofbiz/shark/instance/EntityPersistentMgr.java Sun Jan 21 10:48:58 2007 @@ -16,138 +16,145 @@ * specific language governing permissions and limitations * under the License. *******************************************************************************/ + package org.ofbiz.shark.instance; import java.util.ArrayList; +import java.util.Date; import java.util.Iterator; import java.util.LinkedList; import java.util.List; -import java.util.Date; + import java.util.Map; +import java.util.StringTokenizer; +import org.enhydra.shark.api.RootException; +import org.enhydra.shark.api.SharkTransaction; +import org.enhydra.shark.api.internal.instancepersistence.ActivityPersistenceInterface; +import org.enhydra.shark.api.internal.instancepersistence.ActivityVariablePersistenceInterface; +import org.enhydra.shark.api.internal.instancepersistence.AndJoinEntryInterface; +import org.enhydra.shark.api.internal.instancepersistence.AssignmentPersistenceInterface; +import org.enhydra.shark.api.internal.instancepersistence.DeadlinePersistenceInterface; +import org.enhydra.shark.api.internal.instancepersistence.PersistenceException; +import org.enhydra.shark.api.internal.instancepersistence.PersistentManagerInterface; +import org.enhydra.shark.api.internal.instancepersistence.ProcessMgrPersistenceInterface; +import org.enhydra.shark.api.internal.instancepersistence.ProcessPersistenceInterface; +import org.enhydra.shark.api.internal.instancepersistence.ProcessVariablePersistenceInterface; +import org.enhydra.shark.api.internal.instancepersistence.ResourcePersistenceInterface; +import org.enhydra.shark.api.internal.working.CallbackUtilities; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.UtilMisc; import org.ofbiz.base.util.UtilValidate; import org.ofbiz.entity.GenericDelegator; import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.GenericValue; -import org.ofbiz.entity.util.EntityListIterator; -import org.ofbiz.entity.model.DynamicViewEntity; -import org.ofbiz.entity.model.ModelKeyMap; +import org.ofbiz.entity.condition.EntityComparisonOperator; + + import org.ofbiz.entity.condition.EntityCondition; import org.ofbiz.entity.condition.EntityConditionList; import org.ofbiz.entity.condition.EntityExpr; import org.ofbiz.entity.condition.EntityJoinOperator; import org.ofbiz.entity.condition.EntityOperator; -import org.ofbiz.entity.condition.EntityComparisonOperator; +import org.ofbiz.entity.model.DynamicViewEntity; +import org.ofbiz.entity.model.ModelKeyMap; +import org.ofbiz.entity.util.EntityListIterator; import org.ofbiz.shark.container.SharkContainer; -import org.enhydra.shark.api.RootException; -import org.enhydra.shark.api.SharkTransaction; -import org.enhydra.shark.api.internal.instancepersistence.*; -import org.enhydra.shark.api.internal.working.CallbackUtilities; - /** * Shark Persistance Manager Implementation */ + public class EntityPersistentMgr implements PersistentManagerInterface { public static final String module = EntityPersistentMgr.class.getName(); protected CallbackUtilities callBackUtil = null; - - public void configure(CallbackUtilities callBackUtil) throws RootException { - this.callBackUtil = callBackUtil; + + public void configure(CallbackUtilities callbackutilities) throws RootException { + this.callBackUtil = callbackutilities; } public void shutdownDatabase() throws PersistenceException { } - // store methods - public void persist(ProcessMgrPersistenceInterface processMgr, SharkTransaction trans) throws PersistenceException { + public void persist(ProcessMgrPersistenceInterface processmgrpersistenceinterface, boolean flag, SharkTransaction sharktransaction) throws PersistenceException { try { - ((ProcessMgr) processMgr).store(); + + ((ProcessMgr) processmgrpersistenceinterface).store(); } catch (GenericEntityException e) { throw new PersistenceException(e); } } - public void persist(ProcessPersistenceInterface process, SharkTransaction trans) throws PersistenceException { + public void persist(ProcessPersistenceInterface processpersistenceinterface, boolean flag, SharkTransaction sharktransaction) throws PersistenceException { try { - ((Process) process).store(); + ((Process) processpersistenceinterface).store(); } catch (GenericEntityException e) { throw new PersistenceException(e); } } - public void persistExternalRequester(String processId, Object req, SharkTransaction trans) throws PersistenceException { - ProcessPersistenceInterface proc = this.restoreProcess(processId, trans); - proc.setExternalRequester(req); - this.persist(proc, trans); - } - - public void persist(ActivityPersistenceInterface activity, SharkTransaction trans) throws PersistenceException { + public void persist(ActivityPersistenceInterface activitypersistenceinterface, boolean flag, SharkTransaction sharktransaction) throws PersistenceException { try { - ((Activity) activity).store(); + ((Activity) activitypersistenceinterface).store(); } catch (GenericEntityException e) { throw new PersistenceException(e); } } - public void persist(ResourcePersistenceInterface resource, SharkTransaction trans) throws PersistenceException { - try { - ((Resource) resource).store(); - } catch (GenericEntityException e) { - throw new PersistenceException(e); - } + public void persist(ResourcePersistenceInterface resourcepersistenceinterface, boolean flag, SharkTransaction sharktransaction) throws PersistenceException { + try { + ((Resource) resourcepersistenceinterface).store(); + } catch (GenericEntityException e) { + throw new PersistenceException(e); + } } - public void persist(AssignmentPersistenceInterface assignment, SharkTransaction trans) throws PersistenceException { + public void persist(AssignmentPersistenceInterface assignmentpersistenceinterface, boolean flag, SharkTransaction sharktransaction) throws PersistenceException { try { - ((Assignment) assignment).store(); + ((Assignment) assignmentpersistenceinterface).store(); } catch (GenericEntityException e) { throw new PersistenceException(e); } } - public void persist(AssignmentPersistenceInterface assignment, String oldResUname, SharkTransaction trans) throws PersistenceException { - // TODO: look into this, if it is used only for re-assigning then have it expire/create new assignment - persist(assignment, trans); + public void persist(AssignmentPersistenceInterface assignmentpersistenceinterface, String s, SharkTransaction sharktransaction) throws PersistenceException { + persist(assignmentpersistenceinterface, true ,sharktransaction); + } - public void persist(ProcessVariablePersistenceInterface processVariable, SharkTransaction trans) throws PersistenceException { + public void persist(ProcessVariablePersistenceInterface processvariablepersistenceinterface, boolean flag, SharkTransaction sharktransaction) throws PersistenceException { try { - ((ProcessVariable) processVariable).store(); + ((ProcessVariable) processvariablepersistenceinterface).store(); } catch (GenericEntityException e) { throw new PersistenceException(e); } } - public void persist(ActivityVariablePersistenceInterface activityVariable, SharkTransaction trans) throws PersistenceException { + public void persist(ActivityVariablePersistenceInterface activityvariablepersistenceinterface, boolean flag, SharkTransaction sharktransaction) throws PersistenceException { try { - ((ActivityVariable) activityVariable).store(); + ((ActivityVariable) activityvariablepersistenceinterface).store(); } catch (GenericEntityException e) { throw new PersistenceException(e); } } - public void persist(AndJoinEntryInterface andJoin, SharkTransaction trans) throws PersistenceException { + public void persist(AndJoinEntryInterface andjoinentryinterface, SharkTransaction sharktransaction) throws PersistenceException { try { - ((AndJoinEntry) andJoin).store(); + ((AndJoinEntry) andjoinentryinterface).store(); } catch (GenericEntityException e) { throw new PersistenceException(e); } } - public void persist(DeadlinePersistenceInterface dpe, SharkTransaction ti) throws PersistenceException { + public void persist(DeadlinePersistenceInterface deadlinepersistenceinterface, boolean flag, SharkTransaction sharktransaction) throws PersistenceException { try { - ((Deadline) dpe).store(); + ((Deadline) deadlinepersistenceinterface).store(); } catch (GenericEntityException e) { throw new PersistenceException(e); } } - - // restore methods public ProcessMgrPersistenceInterface restoreProcessMgr(String mgrName, SharkTransaction trans) throws PersistenceException { return ProcessMgr.getInstance(this, mgrName); } @@ -196,7 +203,7 @@ return true; } - // remove/delete methods + public void deleteProcessMgr(String mgrName, SharkTransaction trans) throws PersistenceException { if (Debug.infoOn()) Debug.log(":: deleteProcessMgr ::", module); try { @@ -207,6 +214,7 @@ } public void deleteProcess(String processId, boolean admin, SharkTransaction trans) throws PersistenceException { + GenericDelegator delegator = SharkContainer.getDelegator(); if (admin) { if (Debug.infoOn()) Debug.log(":: deleteProcess ::", module); Process process = (Process) this.restoreProcess(processId, trans); @@ -216,16 +224,18 @@ while (i.hasNext()) { Activity activity = (Activity) i.next(); try { + this.deleteDeadlines(processId, activity.getId(), trans); activity.remove(); } catch (GenericEntityException e) { throw new PersistenceException(e); } } } - try { + delegator.removeByAnd(org.ofbiz.shark.SharkConstants.WfActivity, UtilMisc.toMap(org.ofbiz.shark.SharkConstants.subFlowId, processId)); + process.remove(); - } catch (GenericEntityException e) { + } catch (Exception e) { throw new PersistenceException(e); } } @@ -276,8 +286,8 @@ if (Debug.infoOn()) Debug.log(":: deleteAndJoinEntries ::", module); GenericDelegator delegator = SharkContainer.getDelegator(); try { - delegator.removeByAnd("WfAndJoin", UtilMisc.toMap("processId", procId, - "activitySetDefId", asDefId, "activityDefId", aDefId)); + delegator.removeByAnd(org.ofbiz.shark.SharkConstants.WfAndJoin, UtilMisc.toMap(org.ofbiz.shark.SharkConstants.processId, procId, + org.ofbiz.shark.SharkConstants.activitySetDefId, asDefId, org.ofbiz.shark.SharkConstants.activityDefId, aDefId)); } catch (GenericEntityException e) { throw new PersistenceException(e); } @@ -286,7 +296,7 @@ public void deleteDeadlines(String procId, SharkTransaction trans) throws PersistenceException { GenericDelegator delegator = SharkContainer.getDelegator(); try { - delegator.removeByAnd("WfDeadline", UtilMisc.toMap("processId", procId)); + delegator.removeByAnd(org.ofbiz.shark.SharkConstants.WfDeadline, UtilMisc.toMap(org.ofbiz.shark.SharkConstants.processId, procId)); } catch (GenericEntityException e) { throw new PersistenceException(e); } @@ -295,26 +305,50 @@ public void deleteDeadlines(String procId, String actId, SharkTransaction trans) throws PersistenceException { GenericDelegator delegator = SharkContainer.getDelegator(); try { - delegator.removeByAnd("WfDeadline", UtilMisc.toMap("processId", procId, "activityId", actId)); + delegator.removeByAnd(org.ofbiz.shark.SharkConstants.WfDeadline, UtilMisc.toMap(org.ofbiz.shark.SharkConstants.processId, procId, org.ofbiz.shark.SharkConstants.activityId, actId)); } catch (GenericEntityException e) { throw new PersistenceException(e); } } public void delete(ProcessVariablePersistenceInterface processVariable, SharkTransaction trans) throws PersistenceException { - // don't delete variables + Debug.logInfo("Call : delete(ProcessVariablePersistenceInterface processVariable, SharkTransaction trans)",module); } public void delete(ActivityVariablePersistenceInterface activityVariable, SharkTransaction trans) throws PersistenceException { - // don't delete variables + Debug.logInfo("Call : delete(ActivityVariablePersistenceInterface activityVariable, SharkTransaction trans)",module); } + public List getProcessMgrsWhere(SharkTransaction trans, String sqlWhere) throws PersistenceException { - if (sqlWhere != null) { - Debug.log("Attempt to call getProcessMgrsWhere() - " + sqlWhere, module); - throw new PersistenceException("Method not available to this implementation! (" + sqlWhere + ")"); + StringTokenizer st = null; + StringTokenizer strtoc = null; + String pkgId = new String(); + String Elem = new String(); + List l = getAllProcessMgrs(trans); + List returnList = new ArrayList(); + if (sqlWhere != null) + { + st = new StringTokenizer(sqlWhere); + while(st.hasMoreElements()) + { + Elem = (String)st.nextElement(); + if(Elem.equalsIgnoreCase(org.ofbiz.shark.SharkConstants.packageId)){ + st.nextElement(); + strtoc = new StringTokenizer((String)st.nextElement(), "\'"); + pkgId = strtoc.nextToken(); + for(int i = 0; i < l.size(); i++){ + if(((ProcessMgr)l.get(i)).getPackageId().equalsIgnoreCase(pkgId)){ + returnList.add((ProcessMgr)l.get(i)); + } + } + return returnList; + } + } + }else{ + return getAllProcessMgrs(trans); } - return this.getAllProcessMgrs(trans); + return returnList; } public List getAllProcessMgrs(SharkTransaction trans) throws PersistenceException { @@ -323,7 +357,7 @@ List createdList = new ArrayList(); List lookupList = null; try { - lookupList = delegator.findAll("WfProcessMgr"); + lookupList = delegator.findAll(org.ofbiz.shark.SharkConstants.WfProcessMgr); } catch (GenericEntityException e) { Debug.logError(e, module); throw new PersistenceException(e); @@ -335,16 +369,16 @@ createdList.add(ProcessMgr.getInstance(this, v)); } } - if (Debug.verboseOn()) Debug.log("ProcessMgr : " + createdList.size(), module); return createdList; } public List getResourcesWhere(SharkTransaction trans, String sqlWhere) throws PersistenceException { + Debug.logInfo(">>>>>>>>>>>>>>>>>>>>>>> Call : getResourcesWhere(SharkTransaction trans, String sqlWhere)",module); + Debug.logInfo(">>>>>>>>>>>>>>>>>>>>>>> sqlWhere = " + sqlWhere, module); if (sqlWhere != null) { - Debug.log("Attempt to call getResourcesWhere() - " + sqlWhere, module); - throw new PersistenceException("Method not available to this implementation! (" + sqlWhere + ")"); + throw new PersistenceException("Call : Method not available to this implementation! (" + sqlWhere + ")"); } - return this.getAllResources(trans); + return getAllResources(trans); } public List getAllResources(SharkTransaction trans) throws PersistenceException { @@ -353,7 +387,7 @@ List createdList = new ArrayList(); List lookupList = null; try { - lookupList = delegator.findAll("WfResource"); + lookupList = delegator.findAll(org.ofbiz.shark.SharkConstants.WfResource); } catch (GenericEntityException e) { throw new PersistenceException(e); } @@ -373,7 +407,7 @@ List createdList = new ArrayList(); List lookupList = null; try { - lookupList = delegator.findAll("WfAssignment"); + lookupList = delegator.findAll(org.ofbiz.shark.SharkConstants.WfAssignment); } catch (GenericEntityException e) { throw new PersistenceException(e); } @@ -386,34 +420,13 @@ } return createdList; } - - public List getAllProcesses(SharkTransaction trans) throws PersistenceException { - if (Debug.verboseOn()) Debug.log(":: getAllProcesses ::", module); - GenericDelegator delegator = SharkContainer.getDelegator(); - List createdList = new ArrayList(); - List lookupList = null; - try { - lookupList = delegator.findAll("WfProcess"); - } catch (GenericEntityException e) { - throw new PersistenceException(e); - } - if (lookupList != null && lookupList.size() > 0) { - Iterator i = lookupList.iterator(); - while (i.hasNext()) { - GenericValue v = (GenericValue) i.next(); - createdList.add(Process.getInstance(this, v)); - } - } - return createdList; - } - public List getAllActivities(SharkTransaction trans) throws PersistenceException { if (Debug.verboseOn()) Debug.log(":: getAllActivities ::", module); GenericDelegator delegator = SharkContainer.getDelegator(); List createdList = new ArrayList(); List lookupList = null; try { - lookupList = delegator.findAll("WfActivity"); + lookupList = delegator.findAll(org.ofbiz.shark.SharkConstants.WfActivity); } catch (GenericEntityException e) { throw new PersistenceException(e); } @@ -438,13 +451,13 @@ List createdList = new ArrayList(); List lookupList = null; - Map findBy = UtilMisc.toMap("mgrName", mgrName); + Map findBy = UtilMisc.toMap(org.ofbiz.shark.SharkConstants.mgrName, mgrName); if (state != null) { - findBy.put("currentState", state); + findBy.put(org.ofbiz.shark.SharkConstants.currentState, state); } try { - lookupList = delegator.findByAnd("WfProcess", findBy); + lookupList = delegator.findByAnd(org.ofbiz.shark.SharkConstants.WfProcess, findBy); } catch (GenericEntityException e) { throw new PersistenceException(e); } @@ -461,12 +474,12 @@ public List getAllRunningProcesses(SharkTransaction trans) throws PersistenceException { GenericDelegator delegator = SharkContainer.getDelegator(); List runningStates = UtilMisc.toList("open.running"); - List order = UtilMisc.toList("startedTime"); + List order = UtilMisc.toList(org.ofbiz.shark.SharkConstants.startedTime); List createdList = new ArrayList(); List lookupList = null; try { - lookupList = delegator.findByCondition("WfProcess", - makeStateListCondition("currentState", runningStates, EntityOperator.EQUALS, EntityOperator.OR), null, order); + lookupList = delegator.findByCondition(org.ofbiz.shark.SharkConstants.WfProcess, + makeStateListCondition(org.ofbiz.shark.SharkConstants.currentState, runningStates, EntityOperator.EQUALS, EntityOperator.OR), null, order); } catch (GenericEntityException e) { throw new PersistenceException(e); } @@ -481,16 +494,17 @@ } protected List findFinishedProcesses(SharkTransaction trans, String packageId, String processDefId, String packageVer, Date finishedBefore) throws PersistenceException { + GenericDelegator delegator = SharkContainer.getDelegator(); List finsihedStates = UtilMisc.toList("closed.completed", "closed.terminated", "closed.aborted"); - List order = UtilMisc.toList("lastStateTime"); + List order = UtilMisc.toList(org.ofbiz.shark.SharkConstants.lastStateTime); List createdList = new ArrayList(); List lookupList = null; try { - EntityCondition stateCond = this.makeStateListCondition("currentState", finsihedStates, EntityOperator.EQUALS, EntityOperator.OR); + EntityCondition stateCond = this.makeStateListCondition(org.ofbiz.shark.SharkConstants.currentState, finsihedStates, EntityOperator.EQUALS, EntityOperator.OR); EntityCondition cond = this.makeProcessFilterCondition(stateCond, packageId, processDefId, packageVer, finishedBefore); - lookupList = delegator.findByCondition("WfProcess", cond, null, order); + lookupList = delegator.findByCondition(org.ofbiz.shark.SharkConstants.WfProcess, cond, null, order); } catch (GenericEntityException e) { throw new PersistenceException(e); } @@ -523,84 +537,6 @@ public List getAllFinishedProcesses(SharkTransaction trans, String packageId, String processDefId, String packageVer) throws PersistenceException { return this.findFinishedProcesses(trans, packageId, processDefId, packageVer, null); } - - private EntityCondition makeStateListCondition(String field, List states, EntityComparisonOperator operator, EntityJoinOperator jop) throws GenericEntityException { - if (states != null) { - if (states.size() > 1) { - List exprs = new LinkedList(); - Iterator i = states.iterator(); - while (i.hasNext()) { - exprs.add(new EntityExpr(field, operator, i.next())); - } - return new EntityConditionList(exprs, jop); - } else { - return new EntityExpr(field, operator, states.get(0)); - } - } else { - throw new GenericEntityException("Cannot create entity condition from list :" + states); - } - } - - private EntityCondition makeProcessFilterCondition(EntityCondition cond, String packageId, String processDefId, String packageVer, Date finishBefore) { - EntityCondition newCond = null; - List exprs = new LinkedList(); - if (packageId != null) { - exprs.add(new EntityExpr("packageId", EntityOperator.EQUALS, packageId)); - } - if (processDefId != null) { - exprs.add(new EntityExpr("definitionId", EntityOperator.EQUALS, processDefId)); - } - if (packageVer != null) { - exprs.add(new EntityExpr("packageVer", EntityOperator.EQUALS, packageVer)); - } - if (finishBefore != null) { - exprs.add(new EntityExpr("lastStateTime", EntityOperator.LESS_THAN, finishBefore)); - } - - if (exprs.size() > 0) { - newCond = new EntityConditionList(exprs, EntityJoinOperator.AND); - } - - if (newCond != null) { - if (cond != null) { - return new EntityConditionList(UtilMisc.toList(cond, newCond), EntityJoinOperator.AND); - } else { - return newCond; - } - } else { - return cond; - } - } - - protected List findProcessActivities(String processId, List states, EntityComparisonOperator operator, SharkTransaction trans) throws PersistenceException { - GenericDelegator delegator = SharkContainer.getDelegator(); - List createdList = new ArrayList(); - List order = UtilMisc.toList("lastStateTime"); - List lookupList = null; - try { - EntityCondition cond = null; - EntityCondition proc = new EntityExpr("processId", EntityOperator.EQUALS, processId); - - if (states != null) { - EntityCondition stateCond = this.makeStateListCondition("currentState", states, operator, EntityOperator.OR); - cond = new EntityConditionList(UtilMisc.toList(proc, stateCond), EntityOperator.AND); - } else { - cond = proc; - } - lookupList = delegator.findByCondition("WfActivity", cond, null, order); - } catch (GenericEntityException e) { - throw new PersistenceException(e); - } - if (lookupList != null && lookupList.size() > 0) { - Iterator i = lookupList.iterator(); - while (i.hasNext()) { - GenericValue v = (GenericValue) i.next(); - createdList.add(Activity.getInstance(this, v)); - } - } - return createdList; - } - public List getAllActivitiesForProcess(String processId, SharkTransaction trans) throws PersistenceException { return this.findProcessActivities(processId, null, null, trans); } @@ -615,20 +551,15 @@ } public List getAllActiveActivitiesForProcess(String processId, SharkTransaction trans) throws PersistenceException { - List finishedStates = UtilMisc.toList("closed.completed", "closed.terminated", "closed.aborted"); - return this.findProcessActivities(processId, finishedStates, EntityOperator.NOT_EQUAL, trans); + List finishedStates = UtilMisc.toList("open.running");//, "open.not_running.not_started" , "open.not_running.suspended"); + return this.findProcessActivities(processId, finishedStates, EntityOperator.NOT_EQUAL, trans); } - - /** - * Returns all assignments for the resource, no matter if its activity - * is in "closed" state (or some of its sub-states). - */ public List getAllAssignmentsForResource(String user, SharkTransaction trans) throws PersistenceException { GenericDelegator delegator = SharkContainer.getDelegator(); List createdList = new ArrayList(); List lookupList = null; try { - lookupList = delegator.findByAnd("WfAssignment", UtilMisc.toMap("userName", user)); + lookupList = delegator.findByAnd(org.ofbiz.shark.SharkConstants.WfAssignment, UtilMisc.toMap(org.ofbiz.shark.SharkConstants.userName, user)); } catch (GenericEntityException e) { throw new PersistenceException(e); } @@ -692,7 +623,7 @@ List createdList = new ArrayList(); List lookupList = null; try { - lookupList = delegator.findByAnd("WfAssignment", UtilMisc.toMap("activityId", activityId)); + lookupList = delegator.findByAnd(org.ofbiz.shark.SharkConstants.WfAssignment, UtilMisc.toMap(org.ofbiz.shark.SharkConstants.activityId, activityId)); } catch (GenericEntityException e) { throw new PersistenceException(e); } @@ -716,7 +647,9 @@ if (at.getState().startsWith("closed")) { return new ArrayList(); } else { - return getAllAssignmentsForActivity(activityId, trans); + + List createdList = getAllAssignmentsForActivity(activityId, trans); + return createdList; } } @@ -731,12 +664,10 @@ if (at.getState().startsWith("closed")) { return new ArrayList(); } - List assignments = getAllAssignmentsForActivity(activityId, trans); if (at.getResourceUsername() == null) { return assignments; } - List valid = new ArrayList(); Iterator i = assignments.iterator(); while (i.hasNext()) { @@ -745,6 +676,7 @@ valid.add(as); } } + return valid; } @@ -754,7 +686,7 @@ List createdList = new ArrayList(); List lookupList = null; try { - lookupList = delegator.findByAnd("WfProcessVariable", UtilMisc.toMap("processId", processId)); + lookupList = delegator.findByAnd(org.ofbiz.shark.SharkConstants.WfProcessVariable, UtilMisc.toMap(org.ofbiz.shark.SharkConstants.processId, processId)); } catch (GenericEntityException e) { Debug.logError(e, module); throw new PersistenceException(e); @@ -769,19 +701,18 @@ } else { Debug.log("Lookup list empty", module); } - if (Debug.verboseOn()) Debug.log("Returning list : " + createdList.size(), module); - //Debug.log(new Exception(), "Stack Trace", module); return createdList; } public List getAllVariablesForActivity(String activityId, SharkTransaction trans) throws PersistenceException { + if (Debug.verboseOn()) Debug.log(":: getAllVariablesForActivity ::", module); GenericDelegator delegator = SharkContainer.getDelegator(); List createdList = new ArrayList(); List lookupList = null; try { - lookupList = delegator.findByAnd("WfActivityVariable", UtilMisc.toMap("activityId", activityId)); + lookupList = delegator.findByAnd(org.ofbiz.shark.SharkConstants.WfActivityVariable, UtilMisc.toMap(org.ofbiz.shark.SharkConstants.activityId, activityId)); } catch (GenericEntityException e) { throw new PersistenceException(e); } @@ -792,15 +723,17 @@ createdList.add(ActivityVariable.getInstance(this, v)); } } + return createdList; } public List getResourceRequestersProcessIds(String userName, SharkTransaction trans) throws PersistenceException { + GenericDelegator delegator = SharkContainer.getDelegator(); List idList = new ArrayList(); List lookupList = null; try { - lookupList = delegator.findByAnd("WfProcess", UtilMisc.toMap("resourceReqId", userName)); + lookupList = delegator.findByAnd(org.ofbiz.shark.SharkConstants.WfProcess, UtilMisc.toMap(org.ofbiz.shark.SharkConstants.resourceReqId, userName)); } catch (GenericEntityException e) { throw new PersistenceException(e); } @@ -808,13 +741,14 @@ Iterator i = lookupList.iterator(); while (i.hasNext()) { GenericValue v = (GenericValue) i.next(); - idList.add(v.getString("processId")); + idList.add(v.getString(org.ofbiz.shark.SharkConstants.processId)); } } return idList; } public List getAndJoinEntries(String procId, String asDefId, String aDefId, SharkTransaction trans) throws PersistenceException { + List createdList = new ArrayList(); List lookupList = getAndJoinValues(procId, asDefId, aDefId); @@ -834,14 +768,16 @@ } public List getAllDeadlinesForProcess(String procId, SharkTransaction trans) throws PersistenceException { - List lookupList = getDeadlineValues(UtilMisc.toList(new EntityExpr("processId", EntityOperator.EQUALS, procId))); - return getDealineObjects(lookupList); + List lookupList = getDeadlineValues(UtilMisc.toList(new EntityExpr(org.ofbiz.shark.SharkConstants.processId, EntityOperator.EQUALS, procId))); + List dl = getDealineObjects(lookupList); + return dl; } public List getAllDeadlinesForProcess(String procId, long timeLimit, SharkTransaction trans) throws PersistenceException { - List lookupList = getDeadlineValues(UtilMisc.toList(new EntityExpr("processId", EntityOperator.EQUALS, procId), - new EntityExpr("timeLimit", EntityOperator.LESS_THAN, new Long(timeLimit)))); - return getDealineObjects(lookupList); + List lookupList = getDeadlineValues(UtilMisc.toList(new EntityExpr(org.ofbiz.shark.SharkConstants.processId, EntityOperator.EQUALS, procId), + new EntityExpr(org.ofbiz.shark.SharkConstants.timeLimit, EntityOperator.LESS_THAN, new Long(timeLimit)))); + List dl = getDealineObjects(lookupList); + return dl; } public List getAllIdsForProcessesWithExpiriedDeadlines(long l, SharkTransaction trans) throws PersistenceException { @@ -850,13 +786,13 @@ List processIds = new ArrayList(); DynamicViewEntity view = new DynamicViewEntity(); - view.addMemberEntity("WFDL", "WfDeadline"); - view.addMemberEntity("WFPR", "WfProcess"); - view.addMemberEntity("WFAC", "WfActivity"); - view.addAlias("WFPR", "currentState", "processState", null, null, null, null); - view.addAlias("WFAC", "currentState", "activityState", null, null, null, null); - view.addViewLink("WFDL", "WFPR", Boolean.FALSE, ModelKeyMap.makeKeyMapList("processId")); - view.addViewLink("WFDL", "WFAC", Boolean.FALSE, ModelKeyMap.makeKeyMapList("activityId")); + view.addMemberEntity("WFDL", org.ofbiz.shark.SharkConstants.WfDeadline); + view.addMemberEntity("WFPR", org.ofbiz.shark.SharkConstants.WfProcess); + view.addMemberEntity("WFAC", org.ofbiz.shark.SharkConstants.WfActivity); + view.addAlias("WFPR", org.ofbiz.shark.SharkConstants.currentState, "processState", null, null, null, null); + view.addAlias("WFAC", org.ofbiz.shark.SharkConstants.currentState, "activityState", null, null, null, null); + view.addViewLink("WFDL", "WFPR", Boolean.FALSE, ModelKeyMap.makeKeyMapList(org.ofbiz.shark.SharkConstants.processId)); + view.addViewLink("WFDL", "WFAC", Boolean.FALSE, ModelKeyMap.makeKeyMapList(org.ofbiz.shark.SharkConstants.activityId)); EntityListIterator eli = null; try { @@ -865,13 +801,13 @@ EntityCondition actState2 = new EntityExpr("activityState", EntityOperator.EQUALS, "open.running"); EntityCondition actState = new EntityConditionList(UtilMisc.toList(actState1, actState2), EntityOperator.OR); - EntityCondition timeCond = new EntityExpr("timeLimit", EntityOperator.LESS_THAN, new Long(l)); + EntityCondition timeCond = new EntityExpr(org.ofbiz.shark.SharkConstants.timeLimit, EntityOperator.LESS_THAN, new Long(l)); EntityCondition cond = new EntityConditionList(UtilMisc.toList(timeCond, procState, actState), EntityOperator.AND); eli = delegator.findListIteratorByCondition(view, cond, null, null, null, null); GenericValue v = null; while ((v = (GenericValue) eli.next()) != null) { - processIds.add(v.getString("processId")); + processIds.add(v.getString(org.ofbiz.shark.SharkConstants.processId)); } } catch (GenericEntityException e) { throw new PersistenceException(e); @@ -888,23 +824,29 @@ } public List getAllDeadlinesForActivity(String procId, String actId, SharkTransaction trans) throws PersistenceException { - List lookupList = getDeadlineValues(UtilMisc.toList(new EntityExpr("processId", EntityOperator.EQUALS, procId), - new EntityExpr("activityId", EntityOperator.EQUALS, actId))); - return getDealineObjects(lookupList); + + List lookupList = getDeadlineValues(UtilMisc.toList(new EntityExpr(org.ofbiz.shark.SharkConstants.processId, EntityOperator.EQUALS, procId), + new EntityExpr(org.ofbiz.shark.SharkConstants.activityId, EntityOperator.EQUALS, actId))); + List dl = getDealineObjects(lookupList); + + return dl; } public List getAllDeadlinesForActivity(String procId, String actId, long timeLimit, SharkTransaction trans) throws PersistenceException { - List lookupList = getDeadlineValues(UtilMisc.toList(new EntityExpr("processId", EntityOperator.EQUALS, procId), - new EntityExpr("activityId", EntityOperator.EQUALS, actId), - new EntityExpr("timeLimit", EntityOperator.LESS_THAN, new Long(timeLimit)))); - return getDealineObjects(lookupList); + + List lookupList = getDeadlineValues(UtilMisc.toList(new EntityExpr(org.ofbiz.shark.SharkConstants.processId, EntityOperator.EQUALS, procId), + new EntityExpr(org.ofbiz.shark.SharkConstants.activityId, EntityOperator.EQUALS, actId), + new EntityExpr(org.ofbiz.shark.SharkConstants.timeLimit, EntityOperator.LESS_THAN, new Long(timeLimit)))); + List dl = getDealineObjects(lookupList); + return dl; } public int getExecuteCount(String procId, String asDefId, String aDefId, SharkTransaction trans) throws PersistenceException { + GenericDelegator delegator = SharkContainer.getDelegator(); long count = 0; try { - count = delegator.findCountByAnd("WfActivity", UtilMisc.toMap("processId", procId, "setDefinitionId", asDefId, "definitionId", aDefId)); + count = delegator.findCountByAnd(org.ofbiz.shark.SharkConstants.WfActivity, UtilMisc.toMap(org.ofbiz.shark.SharkConstants.processId, procId, org.ofbiz.shark.SharkConstants.setDefinitionId, asDefId, org.ofbiz.shark.SharkConstants.definitionId, aDefId)); } catch (GenericEntityException e) { throw new PersistenceException(e); } @@ -916,8 +858,8 @@ GenericDelegator delegator = SharkContainer.getDelegator(); List lookupList = null; try { - lookupList = delegator.findByAnd("WfAndJoin", UtilMisc.toMap("processId", processId, - "activitySetDefId", activitySetDefId, "activityDefId", activityDefId)); + lookupList = delegator.findByAnd(org.ofbiz.shark.SharkConstants.WfAndJoin, UtilMisc.toMap(org.ofbiz.shark.SharkConstants.processId, processId, + org.ofbiz.shark.SharkConstants.activitySetDefId, activitySetDefId, org.ofbiz.shark.SharkConstants.activityDefId, activityDefId)); } catch (GenericEntityException e) { throw new PersistenceException(e); } @@ -934,7 +876,7 @@ lookupList = new ArrayList(); } else { try { - lookupList = delegator.findByAnd("WfDeadline", exprList); + lookupList = delegator.findByAnd(org.ofbiz.shark.SharkConstants.WfDeadline, exprList); } catch (GenericEntityException e) { throw new PersistenceException(e); } @@ -957,7 +899,9 @@ return deadlines; } - // create methods + + + public ActivityPersistenceInterface createActivity() { return new Activity(this, SharkContainer.getDelegator()); } @@ -1000,26 +944,254 @@ } public List getAssignmentsWhere(SharkTransaction trans, String sqlWhere) throws PersistenceException { + Debug.logInfo(">>>>>>>>>>>>>>>>>>>>>>> getAssignmentsWhere(SharkTransaction trans, String sqlWhere)",module); + Debug.logInfo(">>>>>>>>>>>>>>>>>>>>>>> sqlWhere = " + sqlWhere ,module); if (sqlWhere != null) { - Debug.log("Attempt to call getAssignmentsWhere() - " + sqlWhere, module); + Debug.log("Call : Attempt to call getAssignmentsWhere() - " + sqlWhere, module); throw new PersistenceException("Method not available to this implementation! (" + sqlWhere + ")"); } return this.getAllAssignments(trans); } public List getProcessesWhere(SharkTransaction trans, String sqlWhere) throws PersistenceException { - if (sqlWhere != null) { - Debug.log("Attempt to call getProcessesWhere() - " + sqlWhere, module); - throw new PersistenceException("Method not available to this implementation! (" + sqlWhere + ")"); + Debug.logInfo(">!!!!!!!!!!!!!!!!!!!!!! getProcessesWhere(SharkTransaction trans, String sqlWhere)",module); + Debug.logInfo(">!!!!!!!!!!!!!!!!!!!!!! sqlWhere = " +sqlWhere,module); + StringTokenizer st = null; + StringTokenizer strtoc = null; + List returnList = new ArrayList(); + List l = new ArrayList(); + String prcsMngrName = new String(); + String procState = new String(); + String element = null; + if(sqlWhere != null) + { + st = new StringTokenizer(sqlWhere); + while(st.hasMoreElements()) + { + element = (String)st.nextElement(); + if(element.equalsIgnoreCase("ProcessDefinitions")) + { + st.nextElement(); + st.nextElement(); + st.nextElement(); + prcsMngrName = (String)st.nextElement(); + strtoc = new StringTokenizer(prcsMngrName, "\'"); + prcsMngrName = strtoc.nextToken(); + } + if(element.equalsIgnoreCase("ProcessStates")) + { + st.nextElement(); + st.nextElement(); + st.nextElement(); + procState = (String)st.nextElement(); + strtoc = new StringTokenizer(procState, "\'"); + procState = strtoc.nextToken(); + break; + } + } + l = getAllProcessesForMgr(prcsMngrName, trans); + for(int i = 0; i < l.size(); i ++) + { + if(((Process)l.get(i)).getState().startsWith(new String(procState.substring(0, procState.length()-1)))) + returnList.add(l.get(i)); + } + }else{ + returnList = getAllProcesses(trans); + return returnList; } - return this.getAllProcesses(trans); + return returnList; + } + public List getAllProcesses(SharkTransaction trans) throws PersistenceException { + if (Debug.verboseOn()) Debug.log(":: getAllProcesses ::", module); + GenericDelegator delegator = SharkContainer.getDelegator(); + List createdList = new ArrayList(); + List lookupList = null; + try { + lookupList = delegator.findAll(org.ofbiz.shark.SharkConstants.WfProcess); + } catch (GenericEntityException e) { + throw new PersistenceException(e); + } + if (lookupList != null && lookupList.size() > 0) { + Iterator i = lookupList.iterator(); + while (i.hasNext()) { + GenericValue v = (GenericValue) i.next(); + createdList.add(Process.getInstance(this, v)); + } + } + + return createdList; } - public List getActivitiesWhere(SharkTransaction trans, String sqlWhere) throws PersistenceException { - if (sqlWhere != null) { - Debug.log("Attempt to call getActivitiesWhere() - " + sqlWhere, module); - throw new PersistenceException("Method not available to this implementation! (" + sqlWhere + ")"); + Debug.logInfo(">>>>>>>>>>>>>>>>>>>>>>> getActivitiesWhere(SharkTransaction trans, String sqlWhere)",module); + Debug.logInfo(">>>>>>>>>>>>>>>>>>>>>>> sqlWhere = " + sqlWhere,module); + String ProcessId = new String(); + List act_list = new ArrayList(); + StringTokenizer st = null; + StringTokenizer strtoc = null; + List returnList = new ArrayList(); + String element = new String(); + String state = null; + String defId = null; + if (sqlWhere != null) + { + st = new StringTokenizer(sqlWhere); + while(st.hasMoreElements()) + { + element = (String)st.nextElement(); + if(element.equals("Id")) + { + st.nextElement(); + ProcessId = (String)st.nextElement(); + strtoc = new StringTokenizer(ProcessId, "\'"); + ProcessId = strtoc.nextToken(); + } else if( element.equals("ActivityStates")) + { + st.nextElement(); + st.nextElement(); + st.nextElement(); + String e = (String)st.nextElement(); + strtoc = new StringTokenizer(e, "\'"); + state = strtoc.nextToken(); + } else if(element.equals("ActivityDefinitionId")){ + st.nextElement(); + String e = (String)st.nextElement(); + strtoc = new StringTokenizer(e, "\'"); + defId = strtoc.nextToken(); + } + continue; + } + act_list = getAllActivitiesForProcess(ProcessId, trans); + + for(int i = 0; i < act_list.size(); i ++) + { + if((state == null) && (defId != null)){ + if(((Activity)act_list.get(i)).getActivityDefinitionId().equalsIgnoreCase(defId)) + returnList.add(act_list.get(i)); + } else if((state != null) && (defId == null)){ + if(((Activity)act_list.get(i)).getState().startsWith(new String(state.substring(0, state.length()-1)))) + returnList.add(act_list.get(i)); + } else if ((state != null) && (defId != null)) { + if((((Activity)act_list.get(i)).getState().startsWith(new String(state.substring(0, state.length()-1))))&& + (((Activity)act_list.get(i)).getActivityDefinitionId().equalsIgnoreCase(defId))) + returnList.add(act_list.get(i)); + } + } + } + else{ + returnList = getAllActivities(trans); + return returnList; + } + return returnList; + } + + private EntityCondition makeStateListCondition(String field, List states, EntityComparisonOperator operator, EntityJoinOperator jop) throws GenericEntityException { + if (states != null) { + if (states.size() > 1) { + List exprs = new LinkedList(); + Iterator i = states.iterator(); + while (i.hasNext()) { + exprs.add(new EntityExpr(field, operator, i.next())); + } + return new EntityConditionList(exprs, jop); + } else { + return new EntityExpr(field, operator, states.get(0)); + } + } else { + throw new GenericEntityException("Cannot create entity condition from list :" + states); } - return this.getAllActivities(trans); + } + private EntityCondition makeProcessFilterCondition(EntityCondition cond, String packageId, String processDefId, String packageVer, Date finishBefore) { + EntityCondition newCond = null; + List exprs = new LinkedList(); + if (packageId != null) { + exprs.add(new EntityExpr(org.ofbiz.shark.SharkConstants.packageId, EntityOperator.EQUALS, packageId)); + } + if (processDefId != null) { + exprs.add(new EntityExpr(org.ofbiz.shark.SharkConstants.definitionId, EntityOperator.EQUALS, processDefId)); + } + if (packageVer != null) { + exprs.add(new EntityExpr(org.ofbiz.shark.SharkConstants.packageVer, EntityOperator.EQUALS, packageVer)); + } + if (finishBefore != null) { + exprs.add(new EntityExpr(org.ofbiz.shark.SharkConstants.lastStateTime, EntityOperator.LESS_THAN, finishBefore)); + } + + if (exprs.size() > 0) { + newCond = new EntityConditionList(exprs, EntityJoinOperator.AND); + } + + if (newCond != null) { + if (cond != null) { + return new EntityConditionList(UtilMisc.toList(cond, newCond), EntityJoinOperator.AND); + } else { + return newCond; + } + } else { + return cond; + } + } + protected List findProcessActivities(String processId, List states, EntityComparisonOperator operator, SharkTransaction trans) throws PersistenceException { + GenericDelegator delegator = SharkContainer.getDelegator(); + List createdList = new ArrayList(); + List order = UtilMisc.toList(org.ofbiz.shark.SharkConstants.lastStateTime); + List lookupList = null; + try { + EntityCondition cond = null; + EntityCondition proc = new EntityExpr(org.ofbiz.shark.SharkConstants.processId, EntityOperator.EQUALS, processId); + + if (states != null) { + EntityCondition stateCond = this.makeStateListCondition(org.ofbiz.shark.SharkConstants.currentState, states, operator, EntityOperator.OR); + cond = new EntityConditionList(UtilMisc.toList(proc, stateCond), EntityOperator.AND); + } else { + cond = proc; + } + lookupList = delegator.findByCondition(org.ofbiz.shark.SharkConstants.WfActivity, cond, null, order); + } catch (GenericEntityException e) { + throw new PersistenceException(e); + } + if (lookupList != null && lookupList.size() > 0) { + Iterator i = lookupList.iterator(); + while (i.hasNext()) { + GenericValue v = (GenericValue) i.next(); + createdList.add(Activity.getInstance(this, v)); + } + } + return createdList; + } + + public List getProcessVariables(String processId,List varList, SharkTransaction trans) throws PersistenceException { + List createdList = new ArrayList(); + List tmpList = null; + tmpList = getAllVariablesForProcess(processId, trans); + if(tmpList != null){ + for(int i =0; i < tmpList.size(); i++){ + for(int j =0; j < varList.size(); j++){ + if(((String)varList.get(j)).equalsIgnoreCase(((ProcessVariable)tmpList.get(i)).getDefinitionId())){ + createdList.add(tmpList.get(i)); + } + } + } + } + return createdList; + } + + public List getActivityVariables(String activityId, List varList, SharkTransaction trans) throws PersistenceException { + if(varList == null) + { + return new ArrayList(); + } + List createdList = new ArrayList(); + List tmpList = null; + tmpList = getAllVariablesForActivity(activityId, trans); + if(tmpList != null){ + for(int i =0; i < tmpList.size(); i++){ + for(int j =0; j < varList.size(); j++){ + if(((String)varList.get(j)).equalsIgnoreCase(((ActivityVariable)tmpList.get(i)).getDefinitionId())){ + createdList.add(tmpList.get(i)); + } + } + } + } + return createdList; } } Modified: ofbiz/trunk/framework/shark/src/org/ofbiz/shark/instance/Process.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/shark/src/org/ofbiz/shark/instance/Process.java?view=diff&rev=498425&r1=498424&r2=498425 ============================================================================== --- ofbiz/trunk/framework/shark/src/org/ofbiz/shark/instance/Process.java (original) +++ ofbiz/trunk/framework/shark/src/org/ofbiz/shark/instance/Process.java Sun Jan 21 10:48:58 2007 @@ -18,20 +18,24 @@ *******************************************************************************/ package org.ofbiz.shark.instance; -import org.ofbiz.entity.GenericDelegator; -import org.ofbiz.entity.GenericValue; -import org.ofbiz.entity.GenericEntityException; -import org.ofbiz.base.util.UtilMisc; +import org.enhydra.shark.api.internal.instancepersistence.PersistenceException; +import org.enhydra.shark.api.internal.instancepersistence.ProcessMgrPersistenceInterface; +import org.enhydra.shark.api.internal.instancepersistence.ProcessPersistenceInterface; + import org.ofbiz.base.util.Debug; -import org.ofbiz.base.util.UtilDateTime; +import org.ofbiz.base.util.UtilMisc; import org.ofbiz.base.util.UtilObject; +import org.ofbiz.entity.GenericDelegator; +import org.ofbiz.entity.GenericEntityException; +import org.ofbiz.entity.GenericValue; import org.ofbiz.shark.container.SharkContainer; -import org.enhydra.shark.api.internal.instancepersistence.*; + /** * Persistance Object */ + public class Process extends InstanceEntityObject implements ProcessPersistenceInterface { public static final String module = Process.class.getName(); @@ -43,8 +47,10 @@ super(mgr, delegator); if (this.delegator != null) { try { - this.process = delegator.findByPrimaryKey("WfProcess", UtilMisc.toMap("processId", processId)); + this.process = delegator.findByPrimaryKey(org.ofbiz.shark.SharkConstants.WfProcess, UtilMisc.toMap(org.ofbiz.shark.SharkConstants.processId, processId)); } catch (GenericEntityException e) { + Debug.logError("Invalid delegator object passed", module); + e.printStackTrace(); throw new PersistenceException(e); } } else { @@ -60,7 +66,7 @@ public Process(EntityPersistentMgr mgr, GenericDelegator delegator) { super(mgr, delegator); this.newValue = true; - this.process = delegator.makeValue("WfProcess", null); + this.process = delegator.makeValue(org.ofbiz.shark.SharkConstants.WfProcess, null); } public static Process getInstance(EntityPersistentMgr mgr, GenericValue process) { @@ -79,7 +85,7 @@ } Debug.log("Returning null Process ID : " + processId, module); if (processId == null) Debug.log(new Exception(), module); - return null; + return null; } public boolean isLoaded() { @@ -90,123 +96,128 @@ } public void setId(String s) { - process.set("processId", s); + process.set(org.ofbiz.shark.SharkConstants.processId, s); } public String getId() { - return process.getString("processId"); + return process.getString(org.ofbiz.shark.SharkConstants.processId); } public void setProcessMgrName(String s) { - process.set("mgrName", s); + process.set(org.ofbiz.shark.SharkConstants.mgrName, s); try { ProcessMgrPersistenceInterface pm = mgr.restoreProcessMgr(s, null); - process.set("packageId", pm.getPackageId()); - process.set("packageVer", pm.getVersion()); + process.set(org.ofbiz.shark.SharkConstants.packageId, pm.getPackageId()); + process.set(org.ofbiz.shark.SharkConstants.packageVer, pm.getVersion()); } catch (PersistenceException e) { Debug.logError(e, "Unable to set package information", module); } } public String getProcessMgrName() { - return process.getString("mgrName"); + return process.getString(org.ofbiz.shark.SharkConstants.mgrName); } public void setExternalRequester(Object o) { byte[] value = UtilObject.getBytes(o); - process.setBytes("externalReq", (value != null ? value : null)); + process.setBytes(org |
Free forum by Nabble | Edit this page |