Fix IDEMPIERE-73 Workflow Node with Action = Wait/Sleep does not wait for entered Wait Time

This commit is contained in:
Carlos Ruiz 2011-09-26 10:41:31 -05:00
parent f961ec5eb0
commit 20b1cb08fa
6 changed files with 32 additions and 15 deletions

View File

@ -0,0 +1,9 @@
-- Sep 25, 2011 10:42:55 AM COT
-- IDEMPIERE-73 Enable Workflow Process window for Client
UPDATE AD_Table SET AccessLevel='6',Updated=TO_DATE('2011-09-25 10:42:55','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Table_ID=697
;
-- Sep 25, 2011 10:43:00 AM COT
UPDATE AD_Table SET AccessLevel='6',Updated=TO_DATE('2011-09-25 10:43:00','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Table_ID=696
;

View File

@ -0,0 +1,9 @@
-- Sep 25, 2011 10:42:55 AM COT
-- IDEMPIERE-73 Enable Workflow Process window for Client
UPDATE AD_Table SET AccessLevel='6',Updated=TO_TIMESTAMP('2011-09-25 10:42:55','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Table_ID=697
;
-- Sep 25, 2011 10:43:00 AM COT
UPDATE AD_Table SET AccessLevel='6',Updated=TO_TIMESTAMP('2011-09-25 10:43:00','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Table_ID=696
;

View File

@ -365,7 +365,7 @@ public class StateEngine
if (isRunning()) if (isRunning())
return new String[] {STATE_Suspended, STATE_Completed, STATE_Aborted, STATE_Terminated}; return new String[] {STATE_Suspended, STATE_Completed, STATE_Aborted, STATE_Terminated};
if (isSuspended()) if (isSuspended())
return new String[] {STATE_Running, STATE_Aborted, STATE_Terminated}; return new String[] {STATE_Running, STATE_Aborted, STATE_Terminated, STATE_Completed};
// //
return new String[] {}; return new String[] {};
} // getNewStateOptions } // getNewStateOptions

View File

@ -192,7 +192,7 @@ public class MWFActivity extends X_AD_WF_Activity implements Runnable
setEndWaitTime(new Timestamp(limitMS + System.currentTimeMillis())); setEndWaitTime(new Timestamp(limitMS + System.currentTimeMillis()));
// Responsible // Responsible
setResponsible(process); setResponsible(process);
save(); saveEx();
// //
m_audit = new MWFEventAudit(this); m_audit = new MWFEventAudit(this);
m_audit.saveEx(); m_audit.saveEx();
@ -266,7 +266,7 @@ public class MWFActivity extends X_AD_WF_Activity implements Runnable
log.fine(oldState + "->"+ WFState + ", Msg=" + getTextMsg()); log.fine(oldState + "->"+ WFState + ", Msg=" + getTextMsg());
super.setWFState (WFState); super.setWFState (WFState);
m_state = new StateEngine (getWFState()); m_state = new StateEngine (getWFState());
save(); // closed in MWFProcess.checkActivities() saveEx(); // closed in MWFProcess.checkActivities()
updateEventAudit(); updateEventAudit();
// Inform Process // Inform Process
@ -282,7 +282,7 @@ public class MWFActivity extends X_AD_WF_Activity implements Runnable
log.log(Level.SEVERE, msg); log.log(Level.SEVERE, msg);
Trace.printStack(); Trace.printStack();
setTextMsg(msg); setTextMsg(msg);
save(); saveEx();
// TODO: teo_sarca: throw exception ? please analyze the call hierarchy first // TODO: teo_sarca: throw exception ? please analyze the call hierarchy first
} }
} // setWFState } // setWFState
@ -958,10 +958,10 @@ public class MWFActivity extends X_AD_WF_Activity implements Runnable
if (MWFNode.ACTION_WaitSleep.equals(action)) if (MWFNode.ACTION_WaitSleep.equals(action))
{ {
log.fine("Sleep:WaitTime=" + m_node.getWaitTime()); log.fine("Sleep:WaitTime=" + m_node.getWaitTime());
if (m_node.getWaitingTime() == 0) if (m_node.getWaitTime() == 0) // IDEMPIERE-73 Carlos Ruiz - globalqss
return true; // done return true; // done
Calendar cal = Calendar.getInstance(); Calendar cal = Calendar.getInstance();
cal.add(m_node.getDurationCalendarField(), m_node.getWaitTime()); cal.add(Calendar.MINUTE, m_node.getWaitTime());
setEndWaitTime(new Timestamp(cal.getTimeInMillis())); setEndWaitTime(new Timestamp(cal.getTimeInMillis()));
return false; // not done return false; // not done
} }
@ -1434,7 +1434,7 @@ public class MWFActivity extends X_AD_WF_Activity implements Runnable
// Update // Update
setAD_User_ID (user.getAD_User_ID()); setAD_User_ID (user.getAD_User_ID());
setTextMsg(textMsg); setTextMsg(textMsg);
save(); saveEx();
// Close up Old Event // Close up Old Event
getEventAudit(); getEventAudit();
m_audit.setAD_User_ID(oldUser.getAD_User_ID()); m_audit.setAD_User_ID(oldUser.getAD_User_ID());

View File

@ -47,7 +47,7 @@ public class MWFProcess extends X_AD_WF_Process
/** /**
* *
*/ */
private static final long serialVersionUID = -8992222567597358696L; private static final long serialVersionUID = -4447369291008183913L;
/** /**
* Standard Constructor * Standard Constructor
@ -256,6 +256,7 @@ public class MWFProcess extends X_AD_WF_Process
*/ */
public void checkActivities(String trxName, PO lastPO) public void checkActivities(String trxName, PO lastPO)
{ {
this.set_TrxName(trxName); // ensure process is working on the same transaction
log.info("(" + getAD_Workflow_ID() + ") - " + getWFState() log.info("(" + getAD_Workflow_ID() + ") - " + getWFState()
+ (trxName == null ? "" : "[" + trxName + "]")); + (trxName == null ? "" : "[" + trxName + "]"));
if (m_state.isClosed()) if (m_state.isClosed())
@ -319,7 +320,7 @@ public class MWFProcess extends X_AD_WF_Process
{ {
setWFState(closedState); setWFState(closedState);
getPO(); getPO();
//hengsin: remmove lock/unlock in workflow which is causing deadlock in many place //hengsin: remove lock/unlock in workflow which is causing deadlock in many place
//if (m_po != null) //if (m_po != null)
//m_po.unlock(null); //m_po.unlock(null);
} }

View File

@ -55,7 +55,7 @@ public class WorkflowProcessor extends AdempiereServer
*/ */
public WorkflowProcessor (MWorkflowProcessor model) public WorkflowProcessor (MWorkflowProcessor model)
{ {
super (model, 120); // 2 minute dalay super (model, 120); // 2 minute delay
m_model = model; m_model = model;
m_client = MClient.get(model.getCtx(), model.getAD_Client_ID()); m_client = MClient.get(model.getCtx(), model.getAD_Client_ID());
} // WorkflowProcessor } // WorkflowProcessor
@ -95,7 +95,7 @@ public class WorkflowProcessor extends AdempiereServer
String sql = "SELECT * " String sql = "SELECT * "
+ "FROM AD_WF_Activity a " + "FROM AD_WF_Activity a "
+ "WHERE Processed='N' AND WFState='OS'" // suspended + "WHERE Processed='N' AND WFState='OS'" // suspended
+ " AND EndWaitTime > SysDate" + " AND EndWaitTime <= SysDate"
+ " AND AD_Client_ID=?" + " AND AD_Client_ID=?"
+ " AND EXISTS (SELECT * FROM AD_Workflow wf " + " AND EXISTS (SELECT * FROM AD_Workflow wf "
+ " INNER JOIN AD_WF_Node wfn ON (wf.AD_Workflow_ID=wfn.AD_Workflow_ID) " + " INNER JOIN AD_WF_Node wfn ON (wf.AD_Workflow_ID=wfn.AD_Workflow_ID) "
@ -104,7 +104,6 @@ public class WorkflowProcessor extends AdempiereServer
+ " AND (wf.AD_WorkflowProcessor_ID IS NULL OR wf.AD_WorkflowProcessor_ID=?))"; + " AND (wf.AD_WorkflowProcessor_ID IS NULL OR wf.AD_WorkflowProcessor_ID=?))";
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
int count = 0; int count = 0;
int countEMails = 0;
try try
{ {
pstmt = DB.prepareStatement (sql, null); pstmt = DB.prepareStatement (sql, null);
@ -146,7 +145,6 @@ public class WorkflowProcessor extends AdempiereServer
+ " AND wfn.DynPriorityUnit IS NOT NULL AND wfn.DynPriorityChange IS NOT NULL)"; + " AND wfn.DynPriorityUnit IS NOT NULL AND wfn.DynPriorityChange IS NOT NULL)";
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
int count = 0; int count = 0;
int countEMails = 0;
try try
{ {
pstmt = DB.prepareStatement (sql, null); pstmt = DB.prepareStatement (sql, null);