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())
return new String[] {STATE_Suspended, STATE_Completed, STATE_Aborted, STATE_Terminated};
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[] {};
} // getNewStateOptions

View File

@ -192,7 +192,7 @@ public class MWFActivity extends X_AD_WF_Activity implements Runnable
setEndWaitTime(new Timestamp(limitMS + System.currentTimeMillis()));
// Responsible
setResponsible(process);
save();
saveEx();
//
m_audit = new MWFEventAudit(this);
m_audit.saveEx();
@ -266,7 +266,7 @@ public class MWFActivity extends X_AD_WF_Activity implements Runnable
log.fine(oldState + "->"+ WFState + ", Msg=" + getTextMsg());
super.setWFState (WFState);
m_state = new StateEngine (getWFState());
save(); // closed in MWFProcess.checkActivities()
saveEx(); // closed in MWFProcess.checkActivities()
updateEventAudit();
// Inform Process
@ -282,7 +282,7 @@ public class MWFActivity extends X_AD_WF_Activity implements Runnable
log.log(Level.SEVERE, msg);
Trace.printStack();
setTextMsg(msg);
save();
saveEx();
// TODO: teo_sarca: throw exception ? please analyze the call hierarchy first
}
} // setWFState
@ -958,10 +958,10 @@ public class MWFActivity extends X_AD_WF_Activity implements Runnable
if (MWFNode.ACTION_WaitSleep.equals(action))
{
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
Calendar cal = Calendar.getInstance();
cal.add(m_node.getDurationCalendarField(), m_node.getWaitTime());
cal.add(Calendar.MINUTE, m_node.getWaitTime());
setEndWaitTime(new Timestamp(cal.getTimeInMillis()));
return false; // not done
}
@ -1434,7 +1434,7 @@ public class MWFActivity extends X_AD_WF_Activity implements Runnable
// Update
setAD_User_ID (user.getAD_User_ID());
setTextMsg(textMsg);
save();
saveEx();
// Close up Old Event
getEventAudit();
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
@ -256,6 +256,7 @@ public class MWFProcess extends X_AD_WF_Process
*/
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()
+ (trxName == null ? "" : "[" + trxName + "]"));
if (m_state.isClosed())
@ -319,7 +320,7 @@ public class MWFProcess extends X_AD_WF_Process
{
setWFState(closedState);
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)
//m_po.unlock(null);
}

View File

@ -55,7 +55,7 @@ public class WorkflowProcessor extends AdempiereServer
*/
public WorkflowProcessor (MWorkflowProcessor model)
{
super (model, 120); // 2 minute dalay
super (model, 120); // 2 minute delay
m_model = model;
m_client = MClient.get(model.getCtx(), model.getAD_Client_ID());
} // WorkflowProcessor
@ -95,7 +95,7 @@ public class WorkflowProcessor extends AdempiereServer
String sql = "SELECT * "
+ "FROM AD_WF_Activity a "
+ "WHERE Processed='N' AND WFState='OS'" // suspended
+ " AND EndWaitTime > SysDate"
+ " AND EndWaitTime <= SysDate"
+ " AND AD_Client_ID=?"
+ " AND EXISTS (SELECT * FROM AD_Workflow wf "
+ " 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=?))";
PreparedStatement pstmt = null;
int count = 0;
int countEMails = 0;
try
{
pstmt = DB.prepareStatement (sql, null);
@ -114,11 +113,11 @@ public class WorkflowProcessor extends AdempiereServer
while (rs.next ())
{
MWFActivity activity = new MWFActivity (getCtx(), rs, null);
activity.setWFState (StateEngine.STATE_Completed);
activity.setWFState (StateEngine.STATE_Completed);
// saves and calls MWFProcess.checkActivities();
count++;
}
rs.close ();
rs.close ();
}
catch (Exception e)
{
@ -146,7 +145,6 @@ public class WorkflowProcessor extends AdempiereServer
+ " AND wfn.DynPriorityUnit IS NOT NULL AND wfn.DynPriorityChange IS NOT NULL)";
PreparedStatement pstmt = null;
int count = 0;
int countEMails = 0;
try
{
pstmt = DB.prepareStatement (sql, null);