use of org.compiere.model.MPInstance in project adempiere by adempiere.
the class ProcessInfoHandler method getProcessInstance.
protected MPInstance getProcessInstance(ProcessInfo info) {
MPInstance instance = new MPInstance(Env.getCtx(), info.getAD_Process_ID(), info.getRecord_ID());
if (!instance.save()) {
info.setSummary(Msg.getMsg(Env.getCtx(), "ProcessNoInstance"));
info.setError(true);
return null;
}
return instance;
}
use of org.compiere.model.MPInstance in project adempiere by adempiere.
the class WProcess method fillParameter.
/**
* Fill Parameter
* @param request request
* @param process process
* @return process instance
*/
private MPInstance fillParameter(HttpServletRequest request, MProcess process) {
MPInstance pInstance = new MPInstance(process, 0);
//
MPInstancePara[] iParams = pInstance.getParameters();
for (int pi = 0; pi < iParams.length; pi++) {
MPInstancePara iPara = iParams[pi];
String key = iPara.getParameterName();
MProcessPara pPara = process.getParameter(key);
if (pPara == null) {
log.log(Level.SEVERE, "Parameter not found: " + key);
continue;
}
String valueString = WebUtil.getParameter(request, key);
log.fine("fillParameter - " + key + " = " + valueString);
Object value = valueString;
if (valueString != null && valueString.length() == 0)
value = null;
// No Value
if (value == null) {
// if (pPara.isMandatory())
// log.log(Level.WARNING,"fillParameter - " + key
// + " - empty - mandatory!");
} else {
// Convert to Type
try {
if (DisplayType.isNumeric(pPara.getAD_Reference_ID()) || DisplayType.isID(pPara.getAD_Reference_ID())) {
BigDecimal bd = null;
if (value instanceof BigDecimal)
bd = (BigDecimal) value;
else if (value instanceof Integer)
bd = new BigDecimal(((Integer) value).intValue());
else
bd = new BigDecimal(value.toString());
iPara.setP_Number(bd);
log.fine("fillParameter - " + key + " = " + valueString + " (=" + bd + "=)");
} else if (DisplayType.isDate(pPara.getAD_Reference_ID())) {
Timestamp ts = null;
if (value instanceof Timestamp)
ts = (Timestamp) value;
else
ts = Timestamp.valueOf(value.toString());
iPara.setP_Date(ts);
log.fine("fillParameter - " + key + " = " + valueString + " (=" + ts + "=)");
} else {
iPara.setP_String(value.toString());
}
//
iPara.saveEx();
} catch (Exception e) {
log.warning("fillParameter - " + key + " = " + valueString + " (" + value + ") " + value.getClass().getName() + " - " + e.getLocalizedMessage());
}
}
// not null
}
return pInstance;
}
use of org.compiere.model.MPInstance in project adempiere by adempiere.
the class ProcessPanel method loadQuerySaved.
/**
* Load Combo
*/
private void loadQuerySaved() {
//user query
List<MPInstance> savedParams = getSavedInstances(true);
fSavedName.removeAllItems();
for (MPInstance instance : savedParams) {
String queries = instance.getName();
fSavedName.appendItem(queries);
}
//
fSavedName.setValue("");
}
use of org.compiere.model.MPInstance in project adempiere by adempiere.
the class WProcessCtl method process.
/**
* Process Control
* <code>
* - Get Instance ID
* - Get Parameters
* - execute (lock - start process - unlock)
* </code>
* Creates a ProcessCtl instance, which calls
* lockUI and unlockUI if parent is a ASyncProcess
* <br>
*
* @param aProcess ASyncProcess & Container
* @param WindowNo window no
* @param pi ProcessInfo process info
* @param trx Transaction
* @author Yamel Senih, ysenih@erpcya.com, ERPCyA http://www.erpcya.com
* <li>FR [ 265 ] ProcessParameterPanel is not MVC
* @see https://github.com/adempiere/adempiere/issues/265
*/
public static void process(ASyncProcess aProcess, int WindowNo, ProcessInfo pi, Trx trx) {
log.fine("WindowNo=" + WindowNo + " - " + pi);
MPInstance instance = null;
try {
instance = new MPInstance(Env.getCtx(), pi.getAD_Process_ID(), pi.getRecord_ID());
} catch (Exception e) {
pi.setSummary(e.getLocalizedMessage());
pi.setError(true);
log.warning(pi.toString());
} catch (Error e) {
pi.setSummary(e.getLocalizedMessage());
pi.setError(true);
log.warning(pi.toString());
}
// Valid null
if (instance == null)
return;
//
if (!instance.save()) {
pi.setSummary(Msg.getMsg(Env.getCtx(), "ProcessNoInstance"));
pi.setError(true);
}
pi.setAD_PInstance_ID(instance.getAD_PInstance_ID());
// Get Parameters (Dialog)
ProcessModalDialog para = new ProcessModalDialog(aProcess, WindowNo, pi);
if (para.isValid()) {
para.setWidth("500px");
para.setVisible(true);
para.setPosition("center");
para.setAttribute(Window.MODE_KEY, Window.MODE_MODAL);
AEnv.showWindow(para);
}
}
use of org.compiere.model.MPInstance in project adempiere by adempiere.
the class ProcessCtl method process.
// execute
/**
* Async Process - Do it all.
* <code>
* - Get Instance ID
* - Get Parameters
* - execute (lock - start process - unlock)
* </code>
* Creates a ProcessCtl instance, which calls
* lockUI and unlockUI if parent is a ASyncProcess
* <br>
* Called from ProcessDialog.actionPerformed
*
* @param parent ASyncProcess & Container
* @param WindowNo window no
* @param paraPanel Process Parameter Panel
* @param pi ProcessInfo process info
* @param trx Transaction
* @return worker started ProcessCtl instance or null for workflow
*/
public static ProcessCtl process(ASyncProcess parent, int WindowNo, ProcessController parameter, ProcessInfo pi, Trx trx) {
log.fine("WindowNo=" + WindowNo + " - " + pi);
MPInstance instance = null;
try {
instance = new MPInstance(Env.getCtx(), pi.getAD_Process_ID(), pi.getRecord_ID());
} catch (Exception e) {
pi.setSummary(e.getLocalizedMessage());
pi.setError(true);
log.warning(pi.toString());
return null;
} catch (Error e) {
pi.setSummary(e.getLocalizedMessage());
pi.setError(true);
log.warning(pi.toString());
return null;
}
if (!instance.save()) {
pi.setSummary(Msg.getMsg(Env.getCtx(), "ProcessNoInstance"));
pi.setError(true);
return null;
}
pi.setAD_PInstance_ID(instance.getAD_PInstance_ID());
// BR [ 265 ]
if (parameter != null) {
if (parameter.saveParameters() != null) {
return null;
}
}
// execute
ProcessCtl worker = new ProcessCtl(parent, WindowNo, pi, trx);
if (parent != null) {
worker.start();
} else {
//synchrous
worker.run();
}
return worker;
}
Aggregations