IDEMPIERE-3294 - check empty String parameter (#1336)
* IDEMPIERE-3294 - check empty String parameter
This commit is contained in:
parent
9f1eeb07f3
commit
b2b31fb087
|
@ -151,6 +151,25 @@ public class MPInstance extends X_AD_PInstance
|
||||||
return m_parameters;
|
return m_parameters;
|
||||||
} // getParameters
|
} // getParameters
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Process Parameters
|
||||||
|
* @return processParameters array
|
||||||
|
*/
|
||||||
|
public MProcessPara[] getProcessParameters()
|
||||||
|
{
|
||||||
|
final String whereClause = "AD_Process_ID=?";
|
||||||
|
List <MProcessPara> list = new Query(getCtx(), MProcessPara.Table_Name, whereClause, get_TrxName())
|
||||||
|
.setParameters(getAD_Process_ID())
|
||||||
|
.setOnlyActiveRecords(true)
|
||||||
|
.setOrderBy("SeqNo")
|
||||||
|
.list();
|
||||||
|
|
||||||
|
//
|
||||||
|
MProcessPara[] processParameters = new MProcessPara[list.size()];
|
||||||
|
list.toArray(processParameters);
|
||||||
|
return processParameters;
|
||||||
|
} // getParameters
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate that a set of process instance parameters are equal or not
|
* Validate that a set of process instance parameters are equal or not
|
||||||
* to the current instance parameter
|
* to the current instance parameter
|
||||||
|
|
|
@ -297,7 +297,7 @@ public class MProcess extends X_AD_Process implements ImmutablePOSupport
|
||||||
*/
|
*/
|
||||||
public MPInstance processIt (int Record_ID, Trx trx, boolean managedTrx)
|
public MPInstance processIt (int Record_ID, Trx trx, boolean managedTrx)
|
||||||
{
|
{
|
||||||
MPInstance pInstance = new MPInstance (this, Record_ID);
|
MPInstance pInstance = new MPInstance (getCtx(), this.getAD_Process_ID(), Record_ID);
|
||||||
// Lock
|
// Lock
|
||||||
pInstance.setIsProcessing(true);
|
pInstance.setIsProcessing(true);
|
||||||
pInstance.saveEx();
|
pInstance.saveEx();
|
||||||
|
@ -340,7 +340,7 @@ public class MProcess extends X_AD_Process implements ImmutablePOSupport
|
||||||
{
|
{
|
||||||
if (pi.getAD_PInstance_ID() == 0)
|
if (pi.getAD_PInstance_ID() == 0)
|
||||||
{
|
{
|
||||||
MPInstance pInstance = new MPInstance (this, pi.getRecord_ID());
|
MPInstance pInstance = new MPInstance (getCtx(), this.getAD_Process_ID(), pi.getRecord_ID());
|
||||||
// Lock
|
// Lock
|
||||||
pInstance.setIsProcessing(true);
|
pInstance.setIsProcessing(true);
|
||||||
pInstance.saveEx();
|
pInstance.saveEx();
|
||||||
|
|
|
@ -70,7 +70,7 @@ public class FinReportJasper extends FinReport
|
||||||
m_report = new MReport (getCtx(), getRecord_ID(), get_TrxName());
|
m_report = new MReport (getCtx(), getRecord_ID(), get_TrxName());
|
||||||
|
|
||||||
MProcess proc = new MProcess(getCtx(), m_report.getJasperProcess_ID(), get_TrxName());
|
MProcess proc = new MProcess(getCtx(), m_report.getJasperProcess_ID(), get_TrxName());
|
||||||
MPInstance instance = new MPInstance(proc, getRecord_ID());
|
MPInstance instance = new MPInstance(getCtx(), proc.getAD_Process_ID(), getRecord_ID());
|
||||||
instance.saveEx();
|
instance.saveEx();
|
||||||
ProcessInfo poInfo = new ProcessInfo(proc.getName(), proc.getAD_Process_ID());
|
ProcessInfo poInfo = new ProcessInfo(proc.getName(), proc.getAD_Process_ID());
|
||||||
poInfo.setParameter(pars);
|
poInfo.setParameter(pars);
|
||||||
|
|
|
@ -46,6 +46,7 @@ import org.compiere.model.MOrgInfo;
|
||||||
import org.compiere.model.MPInstance;
|
import org.compiere.model.MPInstance;
|
||||||
import org.compiere.model.MPInstancePara;
|
import org.compiere.model.MPInstancePara;
|
||||||
import org.compiere.model.MProcess;
|
import org.compiere.model.MProcess;
|
||||||
|
import org.compiere.model.MProcessPara;
|
||||||
import org.compiere.model.MRefList;
|
import org.compiere.model.MRefList;
|
||||||
import org.compiere.model.MRole;
|
import org.compiere.model.MRole;
|
||||||
import org.compiere.model.MTable;
|
import org.compiere.model.MTable;
|
||||||
|
@ -1127,8 +1128,9 @@ public class MWFActivity extends X_AD_WF_Activity implements Runnable
|
||||||
getAD_Table_ID(), getRecord_ID());
|
getAD_Table_ID(), getRecord_ID());
|
||||||
pi.setAD_User_ID(getAD_User_ID());
|
pi.setAD_User_ID(getAD_User_ID());
|
||||||
pi.setAD_Client_ID(getAD_Client_ID());
|
pi.setAD_Client_ID(getAD_Client_ID());
|
||||||
MPInstance pInstance = new MPInstance(process, getRecord_ID());
|
MPInstance pInstance = new MPInstance(getCtx(), process.getAD_Process_ID(), getRecord_ID());
|
||||||
pInstance.set_TrxName(trx != null ? trx.getTrxName() : null);
|
pInstance.set_TrxName(trx != null ? trx.getTrxName() : null);
|
||||||
|
pInstance.saveEx();
|
||||||
fillParameter(pInstance, trx);
|
fillParameter(pInstance, trx);
|
||||||
pi.setAD_PInstance_ID(pInstance.getAD_PInstance_ID());
|
pi.setAD_PInstance_ID(pInstance.getAD_PInstance_ID());
|
||||||
// Report
|
// Report
|
||||||
|
@ -1157,7 +1159,8 @@ public class MWFActivity extends X_AD_WF_Activity implements Runnable
|
||||||
if (log.isLoggable(Level.FINE)) log.fine("Process:AD_Process_ID=" + m_node.getAD_Process_ID());
|
if (log.isLoggable(Level.FINE)) log.fine("Process:AD_Process_ID=" + m_node.getAD_Process_ID());
|
||||||
// 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(process, getRecord_ID());
|
MPInstance pInstance = new MPInstance(getCtx(), process.getAD_Process_ID(), getRecord_ID());
|
||||||
|
pInstance.saveEx();
|
||||||
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(),
|
||||||
|
@ -1649,10 +1652,14 @@ public class MWFActivity extends X_AD_WF_Activity implements Runnable
|
||||||
getPO(trx);
|
getPO(trx);
|
||||||
//
|
//
|
||||||
MWFNodePara[] nParams = m_node.getParameters();
|
MWFNodePara[] nParams = m_node.getParameters();
|
||||||
MPInstancePara[] iParams = pInstance.getParameters();
|
MProcessPara[] processParams = pInstance.getProcessParameters();
|
||||||
for (int pi = 0; pi < iParams.length; pi++)
|
for (int pi = 0; pi < processParams.length; pi++)
|
||||||
{
|
{
|
||||||
MPInstancePara iPara = iParams[pi];
|
MPInstancePara iPara = new MPInstancePara (pInstance, processParams[pi].getSeqNo());
|
||||||
|
iPara.setParameterName(processParams[pi].getColumnName());
|
||||||
|
iPara.setInfo(processParams[pi].getName());
|
||||||
|
iPara.setParameterName(processParams[pi].getColumnName());
|
||||||
|
iPara.setInfo(processParams[pi].getName());
|
||||||
for (int np = 0; np < nParams.length; np++)
|
for (int np = 0; np < nParams.length; np++)
|
||||||
{
|
{
|
||||||
MWFNodePara nPara = nParams[np];
|
MWFNodePara nPara = nParams[np];
|
||||||
|
@ -1674,6 +1681,11 @@ public class MWFActivity extends X_AD_WF_Activity implements Runnable
|
||||||
+ " - empty");
|
+ " - empty");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if( DisplayType.isText(nPara.getDisplayType())
|
||||||
|
&& Util.isEmpty(String.valueOf(value))) {
|
||||||
|
if (log.isLoggable(Level.FINE)) log.fine(nPara.getAttributeName() + " - empty string");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
// Convert to Type
|
// Convert to Type
|
||||||
try
|
try
|
||||||
|
|
|
@ -45,6 +45,7 @@ import org.compiere.model.MOrgInfo;
|
||||||
import org.compiere.model.MPInstance;
|
import org.compiere.model.MPInstance;
|
||||||
import org.compiere.model.MPInstancePara;
|
import org.compiere.model.MPInstancePara;
|
||||||
import org.compiere.model.MProcess;
|
import org.compiere.model.MProcess;
|
||||||
|
import org.compiere.model.MProcessPara;
|
||||||
import org.compiere.model.MRole;
|
import org.compiere.model.MRole;
|
||||||
import org.compiere.model.MScheduler;
|
import org.compiere.model.MScheduler;
|
||||||
import org.compiere.model.MSchedulerLog;
|
import org.compiere.model.MSchedulerLog;
|
||||||
|
@ -192,7 +193,8 @@ public class Scheduler extends AdempiereServer
|
||||||
int AD_Table_ID = scheduler.getAD_Table_ID();
|
int AD_Table_ID = scheduler.getAD_Table_ID();
|
||||||
int Record_ID = scheduler.getRecord_ID();
|
int Record_ID = scheduler.getRecord_ID();
|
||||||
//
|
//
|
||||||
MPInstance pInstance = new MPInstance(process, Record_ID);
|
MPInstance pInstance = new MPInstance(getCtx(), process.getAD_Process_ID(), Record_ID);
|
||||||
|
pInstance.saveEx();
|
||||||
fillParameter(pInstance);
|
fillParameter(pInstance);
|
||||||
//
|
//
|
||||||
pi = new ProcessInfo (process.getName(), process.getAD_Process_ID(), AD_Table_ID, Record_ID);
|
pi = new ProcessInfo (process.getName(), process.getAD_Process_ID(), AD_Table_ID, Record_ID);
|
||||||
|
@ -512,10 +514,12 @@ public class Scheduler extends AdempiereServer
|
||||||
protected void fillParameter(MPInstance pInstance)
|
protected void fillParameter(MPInstance pInstance)
|
||||||
{
|
{
|
||||||
MSchedulerPara[] sParams = get(getCtx(), AD_Scheduler_ID).getParameters (false);
|
MSchedulerPara[] sParams = get(getCtx(), AD_Scheduler_ID).getParameters (false);
|
||||||
MPInstancePara[] iParams = pInstance.getParameters();
|
MProcessPara[] processParams = pInstance.getProcessParameters();
|
||||||
for (int pi = 0; pi < iParams.length; pi++)
|
for (int pi = 0; pi < processParams.length; pi++)
|
||||||
{
|
{
|
||||||
MPInstancePara iPara = iParams[pi];
|
MPInstancePara iPara = new MPInstancePara (pInstance, processParams[pi].getSeqNo());
|
||||||
|
iPara.setParameterName(processParams[pi].getColumnName());
|
||||||
|
iPara.setInfo(processParams[pi].getName());
|
||||||
for (int np = 0; np < sParams.length; np++)
|
for (int np = 0; np < sParams.length; np++)
|
||||||
{
|
{
|
||||||
MSchedulerPara sPara = sParams[np];
|
MSchedulerPara sPara = sParams[np];
|
||||||
|
@ -537,6 +541,12 @@ public class Scheduler extends AdempiereServer
|
||||||
if (log.isLoggable(Level.FINE)) log.fine(sPara.getColumnName() + " - empty");
|
if (log.isLoggable(Level.FINE)) log.fine(sPara.getColumnName() + " - empty");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if( DisplayType.isText(sPara.getDisplayType())
|
||||||
|
&& Util.isEmpty(String.valueOf(value))
|
||||||
|
&& Util.isEmpty(String.valueOf(toValue))) {
|
||||||
|
if (log.isLoggable(Level.FINE)) log.fine(sPara.getColumnName() + " - empty string");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
// Convert to Type
|
// Convert to Type
|
||||||
try
|
try
|
||||||
|
|
|
@ -655,6 +655,10 @@ public class ProcessParameterPanel extends Panel implements
|
||||||
//Save only parameters which are set
|
//Save only parameters which are set
|
||||||
if((result == null) && (result2 == null))
|
if((result == null) && (result2 == null))
|
||||||
continue;
|
continue;
|
||||||
|
if(result instanceof String) {
|
||||||
|
if (Util.isEmpty((String)result) && (result2 == null || Util.isEmpty((String)result2)))
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// Create Parameter
|
// Create Parameter
|
||||||
MPInstancePara para = MPInstancePara.getOrCreate(Env.getCtx(),
|
MPInstancePara para = MPInstancePara.getOrCreate(Env.getCtx(),
|
||||||
|
|
|
@ -104,6 +104,9 @@ import org.zkoss.zul.Vlayout;
|
||||||
*/
|
*/
|
||||||
public class DashboardController implements EventListener<Event> {
|
public class DashboardController implements EventListener<Event> {
|
||||||
|
|
||||||
|
/** Logger */
|
||||||
|
protected transient CLogger log = CLogger.getCLogger (getClass());
|
||||||
|
|
||||||
private static final String PANEL_EMPTY_ATTR = "panel.empty";
|
private static final String PANEL_EMPTY_ATTR = "panel.empty";
|
||||||
private final static CLogger logger = CLogger.getCLogger(DashboardController.class);
|
private final static CLogger logger = CLogger.getCLogger(DashboardController.class);
|
||||||
private Component prevParent;
|
private Component prevParent;
|
||||||
|
@ -866,7 +869,8 @@ 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(process, Record_ID);
|
MPInstance pInstance = new MPInstance(Env.getCtx(), process.getAD_Process_ID(), Record_ID);
|
||||||
|
pInstance.saveEx();
|
||||||
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(),
|
||||||
|
@ -911,9 +915,13 @@ public class DashboardController implements EventListener<Event> {
|
||||||
String value = s.substring(pos + 1);
|
String value = s.substring(pos + 1);
|
||||||
paramMap.put(key, value);
|
paramMap.put(key, value);
|
||||||
}
|
}
|
||||||
MPInstancePara[] iParams = pInstance.getParameters();
|
MProcessPara[] processParams = pInstance.getProcessParameters();
|
||||||
for (MPInstancePara iPara : iParams)
|
for (int pi = 0; pi < processParams.length; pi++)
|
||||||
{
|
{
|
||||||
|
MPInstancePara iPara = new MPInstancePara (pInstance, processParams[pi].getSeqNo());
|
||||||
|
iPara.setParameterName(processParams[pi].getColumnName());
|
||||||
|
iPara.setInfo(processParams[pi].getName());
|
||||||
|
|
||||||
String variable = paramMap.get(iPara.getParameterName());
|
String variable = paramMap.get(iPara.getParameterName());
|
||||||
|
|
||||||
if (Util.isEmpty(variable))
|
if (Util.isEmpty(variable))
|
||||||
|
@ -970,6 +978,11 @@ public class DashboardController implements EventListener<Event> {
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if( DisplayType.isText(iPara.getDisplayType())
|
||||||
|
&& Util.isEmpty(String.valueOf(value))) {
|
||||||
|
if (log.isLoggable(Level.FINE)) log.fine(iPara.getParameterName() + " - empty string");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
// Convert to Type
|
// Convert to Type
|
||||||
if (DisplayType.isNumeric(iPara.getDisplayType()))
|
if (DisplayType.isNumeric(iPara.getDisplayType()))
|
||||||
|
|
|
@ -482,17 +482,20 @@ public class Process {
|
||||||
|
|
||||||
private static MPInstance fillParameter(CompiereService m_cs, DataRow dr, MProcess process, Map<String, Object> requestCtx) throws Exception
|
private static MPInstance fillParameter(CompiereService m_cs, DataRow dr, MProcess process, Map<String, Object> requestCtx) throws Exception
|
||||||
{
|
{
|
||||||
MPInstance pInstance = new MPInstance (process, 0);
|
MPInstance pInstance = new MPInstance(Env.getCtx(), process.getAD_Process_ID(), 0);
|
||||||
|
pInstance.saveEx();
|
||||||
|
|
||||||
DataField f[] = dr.getFieldArray();
|
DataField f[] = dr.getFieldArray();
|
||||||
HashMap<String,DataField> fmap = new HashMap<String,DataField>();
|
HashMap<String,DataField> fmap = new HashMap<String,DataField>();
|
||||||
for (int i=0; i<f.length; i++)
|
for (int i=0; i<f.length; i++)
|
||||||
fmap.put(f[i].getColumn(), f[i]);
|
fmap.put(f[i].getColumn(), f[i]);
|
||||||
//
|
//
|
||||||
MPInstancePara[] iParams = pInstance.getParameters();
|
MProcessPara[] processParams = pInstance.getProcessParameters();
|
||||||
for (int pi = 0; pi < iParams.length; pi++)
|
for (int pi = 0; pi < processParams.length; pi++)
|
||||||
{
|
{
|
||||||
MPInstancePara iPara = iParams[pi];
|
MPInstancePara iPara = new MPInstancePara (pInstance, processParams[pi].getSeqNo());
|
||||||
|
iPara.setParameterName(processParams[pi].getColumnName());
|
||||||
|
iPara.setInfo(processParams[pi].getName());
|
||||||
String key = iPara.getParameterName();
|
String key = iPara.getParameterName();
|
||||||
MProcessPara pPara = process.getParameter(key);
|
MProcessPara pPara = process.getParameter(key);
|
||||||
if (pPara == null)
|
if (pPara == null)
|
||||||
|
@ -541,6 +544,7 @@ public class Process {
|
||||||
if (log.isLoggable(Level.FINE)) log.fine("fillParameter - " + key + " = " + valueString);
|
if (log.isLoggable(Level.FINE)) log.fine("fillParameter - " + key + " = " + valueString);
|
||||||
|
|
||||||
Object value = valueString;
|
Object value = valueString;
|
||||||
|
Object toValue = valueString2;
|
||||||
if (valueString != null && valueString.length() == 0)
|
if (valueString != null && valueString.length() == 0)
|
||||||
value = null;
|
value = null;
|
||||||
if (value != null && (DisplayType.isList(displayType) ||
|
if (value != null && (DisplayType.isList(displayType) ||
|
||||||
|
@ -555,6 +559,12 @@ public class Process {
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if( DisplayType.isText(displayType)
|
||||||
|
&& Util.isEmpty(String.valueOf(value))
|
||||||
|
&& Util.isEmpty(String.valueOf(toValue))) {
|
||||||
|
if (log.isLoggable(Level.FINE)) log.fine(pPara.getColumnName() + " - empty string");
|
||||||
|
break;
|
||||||
|
}
|
||||||
// Convert to Type
|
// Convert to Type
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue