IDEMPIERE-4186 allow workflow to be suspended until after commit of actual transaction
This commit is contained in:
parent
7fc71f8e9e
commit
f1e9b23029
|
|
@ -66,6 +66,7 @@ import org.compiere.util.Env;
|
||||||
import org.compiere.util.Msg;
|
import org.compiere.util.Msg;
|
||||||
import org.compiere.util.Trace;
|
import org.compiere.util.Trace;
|
||||||
import org.compiere.util.Trx;
|
import org.compiere.util.Trx;
|
||||||
|
import org.compiere.util.TrxEventListener;
|
||||||
import org.compiere.util.Util;
|
import org.compiere.util.Util;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -1007,6 +1008,8 @@ public class MWFActivity extends X_AD_WF_Activity implements Runnable
|
||||||
Calendar cal = Calendar.getInstance();
|
Calendar cal = Calendar.getInstance();
|
||||||
cal.add(Calendar.MINUTE, m_node.getWaitTime());
|
cal.add(Calendar.MINUTE, m_node.getWaitTime());
|
||||||
setEndWaitTime(new Timestamp(cal.getTimeInMillis()));
|
setEndWaitTime(new Timestamp(cal.getTimeInMillis()));
|
||||||
|
if (m_node.getWaitTime() == -1)
|
||||||
|
prepareCommitEvent();
|
||||||
return false; // not done
|
return false; // not done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1980,4 +1983,43 @@ public class MWFActivity extends X_AD_WF_Activity implements Runnable
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
} // getSummary
|
} // getSummary
|
||||||
|
|
||||||
|
private void prepareCommitEvent()
|
||||||
|
{
|
||||||
|
Trx trx = null;
|
||||||
|
if (get_TrxName() == null)
|
||||||
|
{
|
||||||
|
return; // no transaction, nothing to commit
|
||||||
|
}
|
||||||
|
MWFActivity activity = new MWFActivity (getCtx(), get_ID(), get_TrxName());
|
||||||
|
trx = Trx.get(get_TrxName(), true);
|
||||||
|
trx.addTrxEventListener(new TrxListener(activity));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static class TrxListener implements TrxEventListener {
|
||||||
|
|
||||||
|
private MWFActivity activity;
|
||||||
|
|
||||||
|
protected TrxListener(MWFActivity activity) {
|
||||||
|
this.activity = activity;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void afterRollback(Trx trx, boolean success) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void afterCommit(Trx trx, boolean success) {
|
||||||
|
if (success) {
|
||||||
|
trx.removeTrxEventListener(this);
|
||||||
|
activity.setWFState (StateEngine.STATE_Completed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void afterClose(Trx trx) {
|
||||||
|
trx.removeTrxEventListener(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
} // MWFActivity
|
} // MWFActivity
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue