IDEMPIERE-1208 Add API for execution of document action workflow.
This commit is contained in:
parent
d70244f8bc
commit
87dba26de2
|
@ -23,6 +23,7 @@ import java.sql.Timestamp;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import org.compiere.model.PO;
|
||||||
import org.compiere.util.DisplayType;
|
import org.compiere.util.DisplayType;
|
||||||
import org.compiere.util.Env;
|
import org.compiere.util.Env;
|
||||||
import org.compiere.util.Ini;
|
import org.compiere.util.Ini;
|
||||||
|
@ -140,6 +141,8 @@ public class ProcessInfo implements Serializable
|
||||||
/** Row count */
|
/** Row count */
|
||||||
private int m_rowCount;
|
private int m_rowCount;
|
||||||
|
|
||||||
|
private transient PO m_po = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* String representation
|
* String representation
|
||||||
* @return String representation
|
* @return String representation
|
||||||
|
@ -773,4 +776,11 @@ public class ProcessInfo implements Serializable
|
||||||
return m_rowCount;
|
return m_rowCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setPO(PO po) {
|
||||||
|
m_po = po;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PO getPO() {
|
||||||
|
return m_po;
|
||||||
|
}
|
||||||
} // ProcessInfo
|
} // ProcessInfo
|
||||||
|
|
|
@ -108,6 +108,8 @@ public class MWFProcess extends X_AD_WF_Process
|
||||||
// Document
|
// Document
|
||||||
setAD_Table_ID(wf.getAD_Table_ID());
|
setAD_Table_ID(wf.getAD_Table_ID());
|
||||||
setRecord_ID(pi.getRecord_ID());
|
setRecord_ID(pi.getRecord_ID());
|
||||||
|
if (pi.getPO() != null)
|
||||||
|
m_po = pi.getPO();
|
||||||
if (getPO() == null)
|
if (getPO() == null)
|
||||||
{
|
{
|
||||||
setTextMsg("No PO with ID=" + pi.getRecord_ID());
|
setTextMsg("No PO with ID=" + pi.getRecord_ID());
|
||||||
|
|
|
@ -27,11 +27,16 @@ import java.util.Properties;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
import org.adempiere.exceptions.DBException;
|
import org.adempiere.exceptions.DBException;
|
||||||
|
import org.compiere.model.MColumn;
|
||||||
import org.compiere.model.MMenu;
|
import org.compiere.model.MMenu;
|
||||||
import org.compiere.model.MProduct;
|
import org.compiere.model.MProduct;
|
||||||
|
import org.compiere.model.MTable;
|
||||||
|
import org.compiere.model.PO;
|
||||||
import org.compiere.model.Query;
|
import org.compiere.model.Query;
|
||||||
import org.compiere.model.X_AD_Workflow;
|
import org.compiere.model.X_AD_Workflow;
|
||||||
|
import org.compiere.process.DocAction;
|
||||||
import org.compiere.process.ProcessInfo;
|
import org.compiere.process.ProcessInfo;
|
||||||
|
import org.compiere.process.ServerProcessCtl;
|
||||||
import org.compiere.process.StateEngine;
|
import org.compiere.process.StateEngine;
|
||||||
import org.compiere.util.CCache;
|
import org.compiere.util.CCache;
|
||||||
import org.compiere.util.CLogger;
|
import org.compiere.util.CLogger;
|
||||||
|
@ -951,4 +956,27 @@ public class MWorkflow extends X_AD_Workflow
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param po
|
||||||
|
* @param docAction
|
||||||
|
* @return ProcessInfo
|
||||||
|
*/
|
||||||
|
public static ProcessInfo runDocumentActionWorkflow(PO po, String docAction)
|
||||||
|
{
|
||||||
|
int AD_Table_ID = po.get_Table_ID();
|
||||||
|
MTable table = MTable.get(Env.getCtx(), AD_Table_ID);
|
||||||
|
MColumn column = table.getColumn("DocAction");
|
||||||
|
if (column == null)
|
||||||
|
return null;
|
||||||
|
if (!docAction.equals(po.get_Value(column.getColumnName())))
|
||||||
|
{
|
||||||
|
po.set_ValueOfColumn(column.getColumnName(), docAction);
|
||||||
|
}
|
||||||
|
ProcessInfo processInfo = new ProcessInfo (((DocAction)po).getDocumentInfo(),column.getAD_Process_ID(),po.get_Table_ID(),po.get_ID());
|
||||||
|
processInfo.setTransactionName(po.get_TrxName());
|
||||||
|
processInfo.setPO(po);
|
||||||
|
ServerProcessCtl.process(processInfo, Trx.get(processInfo.getTransactionName(), false));
|
||||||
|
return processInfo;
|
||||||
|
}
|
||||||
} // MWorkflow_ID
|
} // MWorkflow_ID
|
||||||
|
|
Loading…
Reference in New Issue