IDEMPIERE-4523 - Process Audit not mark AD_PInstance.IsProcessing on simple Reports (#1343)

* IDEMPIERE-4523 - Process Audit not mark AD_PInstance.IsProcessing on simple Reports

* IDEMPIERE-4523 - fixed workflow use case
This commit is contained in:
Peter Takács 2022-06-02 10:15:39 +02:00 committed by GitHub
parent 20116c6144
commit bf32da5738
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 166 additions and 120 deletions

View File

@ -15,6 +15,7 @@ import java.util.ArrayList;
import java.util.Properties; import java.util.Properties;
import java.util.logging.Level; import java.util.logging.Level;
import org.compiere.model.MPInstance;
import org.compiere.model.MProcess; import org.compiere.model.MProcess;
import org.compiere.model.MQuery; import org.compiere.model.MQuery;
import org.compiere.model.MTable; import org.compiere.model.MTable;
@ -217,6 +218,11 @@ public class ServerReportCtl {
static public boolean start (ProcessInfo pi) static public boolean start (ProcessInfo pi)
{ {
MPInstance instance = new MPInstance(Env.getCtx(), pi.getAD_PInstance_ID(), null);
instance.setIsProcessing(true);
instance.saveEx();
try {
/** /**
* Order Print * Order Print
*/ */
@ -247,6 +253,11 @@ public class ServerReportCtl {
* Standard Report * Standard Report
*******************/ *******************/
return startStandardReport (pi); return startStandardReport (pi);
}
finally {
instance.setIsProcessing(false);
instance.saveEx();
}
} // create } // create
/************************************************************************** /**************************************************************************

View File

@ -1159,7 +1159,9 @@ public class MWFActivity extends X_AD_WF_Activity implements Runnable
// Process // Process
MProcess process = MProcess.get(getCtx(), m_node.getAD_Process_ID()); MProcess process = MProcess.get(getCtx(), m_node.getAD_Process_ID());
MPInstance pInstance = new MPInstance(getCtx(), process.getAD_Process_ID(), getRecord_ID()); MPInstance pInstance = new MPInstance(getCtx(), process.getAD_Process_ID(), getRecord_ID());
pInstance.setIsProcessing(true);
pInstance.saveEx(); pInstance.saveEx();
try {
fillParameter(pInstance, trx); fillParameter(pInstance, trx);
// //
ProcessInfo pi = new ProcessInfo (m_node.getName(true), m_node.getAD_Process_ID(), ProcessInfo pi = new ProcessInfo (m_node.getName(true), m_node.getAD_Process_ID(),
@ -1194,6 +1196,11 @@ public class MWFActivity extends X_AD_WF_Activity implements Runnable
setTextMsg(pi.getSummary()); setTextMsg(pi.getSummary());
return success; return success;
} }
finally {
pInstance.setIsProcessing(false);
pInstance.saveEx();
}
}
/****** Start Task (Probably redundant; /****** Start Task (Probably redundant;
same can be achieved by attaching a Workflow node sequentially) ******/ same can be achieved by attaching a Workflow node sequentially) ******/

View File

@ -869,8 +869,10 @@ public class DashboardController implements EventListener<Event> {
int AD_Table_ID = 0; int AD_Table_ID = 0;
int Record_ID = 0; int Record_ID = 0;
// //
MPInstance pInstance = new MPInstance(Env.getCtx(), process.getAD_Process_ID(), Record_ID); MPInstance pInstance = new MPInstance(process, Record_ID);
pInstance.setIsProcessing(true);
pInstance.saveEx(); pInstance.saveEx();
try {
fillParameter(pInstance, parameters); fillParameter(pInstance, parameters);
// //
ProcessInfo pi = new ProcessInfo (process.getName(), process.getAD_Process_ID(), ProcessInfo pi = new ProcessInfo (process.getName(), process.getAD_Process_ID(),
@ -886,9 +888,14 @@ public class DashboardController implements EventListener<Event> {
if (re == null) if (re == null)
throw new IllegalStateException("Cannot create Report AD_Process_ID=" + process.getAD_Process_ID() throw new IllegalStateException("Cannot create Report AD_Process_ID=" + process.getAD_Process_ID()
+ " - " + process.getName()); + " - " + process.getName());
return re; return re;
} }
finally {
pInstance.setIsProcessing(false);
pInstance.saveEx();
}
}
public AMedia generateReport(int AD_Process_ID, String parameters) throws Exception { public AMedia generateReport(int AD_Process_ID, String parameters) throws Exception {
ReportEngine re = runReport(AD_Process_ID, parameters); ReportEngine re = runReport(AD_Process_ID, parameters);

View File

@ -167,13 +167,21 @@ public abstract class AbstractProcessCtl implements Runnable
*/ */
if (AD_Workflow_ID > 0) if (AD_Workflow_ID > 0)
{ {
startWorkflow (AD_Workflow_ID);
MPInstance pinstance = new MPInstance(Env.getCtx(), m_pi.getAD_PInstance_ID(), null); MPInstance pinstance = new MPInstance(Env.getCtx(), m_pi.getAD_PInstance_ID(), null);
pinstance.setIsProcessing(true);
pinstance.saveEx();
try {
startWorkflow (AD_Workflow_ID);
String errmsg = m_pi.getSummary(); String errmsg = m_pi.getSummary();
pinstance.setResult(!m_pi.isError()); pinstance.setResult(!m_pi.isError());
pinstance.setErrorMsg(errmsg); pinstance.setErrorMsg(errmsg);
pinstance.saveEx(); pinstance.saveEx();
unlock(); unlock();
}
finally {
pinstance.setIsProcessing(false);
pinstance.saveEx();
}
return; return;
} }

View File

@ -136,8 +136,10 @@ public class ReportCtl
instance.setAD_PrintFormat_ID(((MPrintFormat)pi.getSerializableObject()).getAD_PrintFormat_ID()); instance.setAD_PrintFormat_ID(((MPrintFormat)pi.getSerializableObject()).getAD_PrintFormat_ID());
instance.setIsSummary(pi.isSummary()); instance.setIsSummary(pi.isSummary());
instance.setAD_Language_ID(pi.getLanguageID()); instance.setAD_Language_ID(pi.getLanguageID());
instance.setIsProcessing(true);
instance.saveEx(); instance.saveEx();
try {
/** /**
* Order Print * Order Print
*/ */
@ -178,6 +180,11 @@ public class ReportCtl
* Standard Report * Standard Report
*******************/ *******************/
return startStandardReport (pi, WindowNo); return startStandardReport (pi, WindowNo);
}
finally {
instance.setIsProcessing(false);
instance.saveEx();
}
} // create } // create
/************************************************************************** /**************************************************************************

View File

@ -324,6 +324,8 @@ public class Process {
// Start // Start
if (process.isWorkflow()) if (process.isWorkflow())
{ {
pInstance.setIsProcessing(true);
pInstance.saveEx();
try try
{ {
int AD_Workflow_ID = process.getAD_Workflow_ID(); int AD_Workflow_ID = process.getAD_Workflow_ID();
@ -345,6 +347,10 @@ public class Process {
r.setIsError( true ); r.setIsError( true );
return res; return res;
} }
finally {
pInstance.setIsProcessing(false);
pInstance.saveEx();
}
} }
if (process.isJavaProcess() && !jasperreport) if (process.isJavaProcess() && !jasperreport)