IDEMPIERE-6032 MPInstanceLog ResultSet constructor not getting all value from result set (#2233)

This commit is contained in:
hengsin 2024-02-08 17:34:13 +08:00 committed by Carlos Ruiz
parent c2111b9ccd
commit 7224009efc
3 changed files with 42 additions and 6 deletions

View File

@ -119,12 +119,16 @@ public class MPInstanceLog
*/
public MPInstanceLog (ResultSet rs) throws SQLException
{
setAD_PInstance_ID(rs.getInt("AD_PInstance_ID"));
setLog_ID(rs.getInt("Log_ID"));
setP_Date(rs.getTimestamp("P_Date"));
setP_ID(rs.getInt("P_ID"));
setP_Number(rs.getBigDecimal("P_Number"));
setP_Msg(rs.getString("P_Msg"));
setAD_PInstance_ID(rs.getInt(X_AD_PInstance_Log.COLUMNNAME_AD_PInstance_ID));
setLog_ID(rs.getInt(X_AD_PInstance_Log.COLUMNNAME_Log_ID));
setP_Date(rs.getTimestamp(X_AD_PInstance_Log.COLUMNNAME_P_Date));
setP_ID(rs.getInt(X_AD_PInstance_Log.COLUMNNAME_P_ID));
setP_Number(rs.getBigDecimal(X_AD_PInstance_Log.COLUMNNAME_P_Number));
setP_Msg(rs.getString(X_AD_PInstance_Log.COLUMNNAME_P_Msg));
setAD_Table_ID(rs.getInt(X_AD_PInstance_Log.COLUMNNAME_AD_Table_ID));
setRecord_ID(rs.getInt(X_AD_PInstance_Log.COLUMNNAME_Record_ID));
setPInstanceLogType(rs.getString(X_AD_PInstance_Log.COLUMNNAME_PInstanceLogType));
setAD_PInstance_Log_UU(rs.getString(X_AD_PInstance_Log.COLUMNNAME_AD_PInstance_Log_UU));
} // MPInstance_Log
private int m_AD_PInstance_ID;

View File

@ -93,6 +93,7 @@ public class SystemIDs
public final static int PROCESS_AD_CHANGELOG_REDO = 307;
public final static int PROCESS_AD_NATIVE_SEQUENCE_ENABLE = 53156;
public final static int PROCESS_AD_TAB_CREATEFIELDS = 174;
public final static int PROCESS_C_BPARTNER_VALIDATE = 314;
public final static int PROCESS_C_INVOICE_GENERATE = 119;
public final static int PROCESS_C_INVOICE_GENERATE_MANUAL = 134;
public final static int PROCESS_C_INVOICE_GENERATERMA_MANUAL = 52002;

View File

@ -40,10 +40,14 @@ import org.compiere.model.MInOutConfirm;
import org.compiere.model.MInOutLine;
import org.compiere.model.MOrder;
import org.compiere.model.MOrderLine;
import org.compiere.model.MPInstance;
import org.compiere.model.MPInstanceLog;
import org.compiere.model.MPInstancePara;
import org.compiere.model.MProcess;
import org.compiere.model.MProduct;
import org.compiere.model.Query;
import org.compiere.model.SystemIDs;
import org.compiere.model.X_AD_PInstance_Log;
import org.compiere.process.DocAction;
import org.compiere.process.ProcessCall;
import org.compiere.process.ProcessInfo;
@ -291,4 +295,31 @@ public class ProcessTest extends AbstractTestCase {
assertNotNull(pc, "Failed to load ProcessCall instance for " + process.toString() + ", " + process.getClassname());
}
}
@Test
public void testGetInstanceLog() {
// Run the validate business partner process
MProcess process = MProcess.get(SystemIDs.PROCESS_C_BPARTNER_VALIDATE);
MPInstance pinstance = new MPInstance(process, 0, 0, null);
MPInstancePara[] paras = pinstance.getParameters();
for (MPInstancePara para : paras) {
if (para.getParameterName().equals("C_BPartner_ID")) {
para.setP_Number(DictionaryIDs.C_BPartner.JOE_BLOCK.id);
para.saveEx();
break;
}
}
ProcessInfo pi = new ProcessInfo(process.getName(), SystemIDs.PROCESS_C_BPARTNER_VALIDATE);
pi.setAD_PInstance_ID(pinstance.getAD_PInstance_ID());
//use local process trx to create pinstance log immediately
process.processIt(pi, null, true);
assertTrue(!pi.isError(), pi.getSummary());
MPInstanceLog[] logs = pinstance.getLog();
assertTrue(logs != null && logs.length > 0, "Failed to retrieve process instance logs");
assertEquals(pinstance.getAD_PInstance_ID(), logs[0].getAD_PInstance_ID(), "Invalid MPInstanceLog.AD_PInstance_ID value");
assertTrue(logs[0].getAD_PInstance_Log_UU() != null && logs[0].getAD_PInstance_Log_UU().length() == 36, "Invalid MPInstanceLog.AD_PInstance_Log_UU value");
assertEquals(X_AD_PInstance_Log.PINSTANCELOGTYPE_Result, logs[0].getPInstanceLogType(), "Invalid MPInstanceLog.PInstanceLogType value");
}
}