use of org.compiere.process.ProcessInfoParameter in project adempiere by adempiere.
the class CreateProductPlanning method prepare.
/**
* Prepare - e.g., get Parameters.
*/
protected void prepare() {
for (ProcessInfoParameter para : getParameter()) {
String name = para.getParameterName();
if (para.getParameter() == null)
;
else if (MProduct.COLUMNNAME_M_Product_Category_ID.equals(name))
productCategoryId = para.getParameterAsInt();
else if (MPPProductPlanning.COLUMNNAME_M_Warehouse_ID.equals(name))
warehouseId = para.getParameterAsInt();
else if (MPPProductPlanning.COLUMNNAME_S_Resource_ID.equals(name))
resourceId = para.getParameterAsInt();
else if (MPPProductPlanning.COLUMNNAME_IsCreatePlan.equals(name))
createPlan = para.getParameterAsBoolean();
else if (MPPProductPlanning.COLUMNNAME_IsMPS.equals(name))
isMPS = para.getParameterAsBoolean();
else if (MPPProductPlanning.COLUMNNAME_DD_NetworkDistribution_ID.equals(name))
networkDistributionId = para.getParameterAsInt();
else if (MPPProductPlanning.COLUMNNAME_AD_Workflow_ID.equals(name))
workflowId = para.getParameterAsInt();
else if (MPPProductPlanning.COLUMNNAME_TimeFence.equals(name))
timeFence = para.getParameterAsBigDecimal();
else if (MPPProductPlanning.COLUMNNAME_TransferTime.equals(name))
transferTime = para.getParameterAsBigDecimal();
else if (MPPProductPlanning.COLUMNNAME_SafetyStock.equals(name))
safetyStock = para.getParameterAsBigDecimal();
else if (MPPProductPlanning.COLUMNNAME_Order_Min.equals(name))
orderMin = para.getParameterAsBigDecimal();
else if (MPPProductPlanning.COLUMNNAME_Order_Max.equals(name))
orderMax = para.getParameterAsBigDecimal();
else if (MPPProductPlanning.COLUMNNAME_Order_Pack.equals(name))
orderPack = para.getParameterAsBigDecimal();
else if (MPPProductPlanning.COLUMNNAME_Order_Qty.equals(name))
orderQty = para.getParameterAsBigDecimal();
else if (MPPProductPlanning.COLUMNNAME_WorkingTime.equals(name))
workingTime = para.getParameterAsBigDecimal();
else if (MPPProductPlanning.COLUMNNAME_Yield.equals(name))
yield = para.getParameterAsInt();
else if (MPPProductPlanning.COLUMNNAME_DeliveryTime_Promised.equals(name))
deliveryTimePromised = para.getParameterAsBigDecimal();
else if (MPPProductPlanning.COLUMNNAME_Order_Period.equals(name))
orderPeriod = para.getParameterAsBigDecimal();
else if (MPPProductPlanning.COLUMNNAME_Order_Policy.equals(name))
orderPolicy = para.getParameterAsString();
else if (MPPProductPlanning.COLUMNNAME_Planner_ID.equals(name))
plannerId = para.getParameterAsInt();
else
log.log(Level.SEVERE, "prepare - Unknown Parameter: " + name);
}
clientId = Env.getAD_Client_ID(getCtx());
if (warehouseId > 0) {
MWarehouse warehouse = MWarehouse.get(getCtx(), warehouseId);
orgId = warehouse.getAD_Org_ID();
}
}
use of org.compiere.process.ProcessInfoParameter in project adempiere by adempiere.
the class InvoicePrint method prepare.
/**
* Prepare - e.g., get Parameters.
*/
protected void prepare() {
ProcessInfoParameter[] para = getParameter();
for (int i = 0; i < para.length; i++) {
String name = para[i].getParameterName();
if (para[i].getParameter() == null)
;
else if (name.equals("DateInvoiced")) {
m_dateInvoiced_From = ((Timestamp) para[i].getParameter());
m_dateInvoiced_To = ((Timestamp) para[i].getParameter_To());
} else if (name.equals("EMailPDF"))
p_EMailPDF = "Y".equals(para[i].getParameter());
else if (name.equals("R_MailText_ID"))
p_R_MailText_ID = para[i].getParameterAsInt();
else if (name.equals("C_BPartner_ID"))
m_C_BPartner_ID = para[i].getParameterAsInt();
else if (name.equals("C_Invoice_ID"))
m_C_Invoice_ID = para[i].getParameterAsInt();
else if (name.equals("DocumentNo")) {
m_DocumentNo_From = (String) para[i].getParameter();
m_DocumentNo_To = (String) para[i].getParameter_To();
} else
log.log(Level.SEVERE, "prepare - Unknown Parameter: " + name);
}
if (m_DocumentNo_From != null && m_DocumentNo_From.length() == 0)
m_DocumentNo_From = null;
if (m_DocumentNo_To != null && m_DocumentNo_To.length() == 0)
m_DocumentNo_To = null;
}
use of org.compiere.process.ProcessInfoParameter in project adempiere by adempiere.
the class ProcessUtil method startScriptProcess.
public static boolean startScriptProcess(Properties ctx, ProcessInfo pi, Trx trx) {
String msg = null;
boolean success = true;
try {
String cmd = pi.getClassName();
MRule rule = MRule.get(ctx, cmd.substring(MRule.SCRIPT_PREFIX.length()));
if (rule == null) {
log.log(Level.WARNING, cmd + " not found");
pi.setSummary("ScriptNotFound", true);
return false;
}
if (!(rule.getEventType().equals(MRule.EVENTTYPE_Process) && rule.getRuleType().equals(MRule.RULETYPE_JSR223ScriptingAPIs))) {
log.log(Level.WARNING, cmd + " must be of type JSR 223 and event Process");
pi.setSummary("ScriptNotFound", true);
return false;
}
ScriptEngine engine = rule.getScriptEngine();
// Window context are W_
// Login context are G_
// Method arguments context are A_
// Parameter context are P_
// no window
MRule.setContext(engine, ctx, 0);
// now add the method arguments to the engine
engine.put(MRule.ARGUMENTS_PREFIX + "Ctx", ctx);
if (trx == null)
trx = Trx.get(pi.getTitle() + "_" + pi.getAD_PInstance_ID(), true);
engine.put(MRule.ARGUMENTS_PREFIX + "Trx", trx);
engine.put(MRule.ARGUMENTS_PREFIX + "TrxName", trx.getTrxName());
engine.put(MRule.ARGUMENTS_PREFIX + "Record_ID", pi.getRecord_ID());
engine.put(MRule.ARGUMENTS_PREFIX + "AD_Client_ID", pi.getAD_Client_ID());
engine.put(MRule.ARGUMENTS_PREFIX + "AD_User_ID", pi.getAD_User_ID());
engine.put(MRule.ARGUMENTS_PREFIX + "AD_PInstance_ID", pi.getAD_PInstance_ID());
engine.put(MRule.ARGUMENTS_PREFIX + "Table_ID", pi.getTable_ID());
// Add process parameters
ProcessInfoParameter[] para = pi.getParameter();
if (para == null) {
ProcessInfoUtil.setParameterFromDB(pi);
para = pi.getParameter();
}
if (para != null) {
engine.put(MRule.ARGUMENTS_PREFIX + "Parameter", pi.getParameter());
for (int i = 0; i < para.length; i++) {
String name = para[i].getParameterName();
if (para[i].getParameter_To() == null) {
Object value = para[i].getParameter();
if (name.endsWith("_ID") && (value instanceof BigDecimal))
engine.put(MRule.PARAMETERS_PREFIX + name, ((BigDecimal) value).intValue());
else
engine.put(MRule.PARAMETERS_PREFIX + name, value);
} else {
Object value1 = para[i].getParameter();
Object value2 = para[i].getParameter_To();
if (name.endsWith("_ID") && (value1 instanceof BigDecimal))
engine.put(MRule.PARAMETERS_PREFIX + name + "1", ((BigDecimal) value1).intValue());
else
engine.put(MRule.PARAMETERS_PREFIX + name + "1", value1);
if (name.endsWith("_ID") && (value2 instanceof BigDecimal))
engine.put(MRule.PARAMETERS_PREFIX + name + "2", ((BigDecimal) value2).intValue());
else
engine.put(MRule.PARAMETERS_PREFIX + name + "2", value2);
}
}
}
engine.put(MRule.ARGUMENTS_PREFIX + "ProcessInfo", pi);
msg = engine.eval(rule.getScript()).toString();
//transaction should rollback if there are error in process
if ("@Error@".equals(msg))
success = false;
// Parse Variables
msg = Msg.parseTranslation(ctx, msg);
pi.setSummary(msg, !success);
} catch (Exception e) {
pi.setSummary("ScriptError", true);
log.log(Level.SEVERE, pi.getClassName(), e);
success = false;
}
if (success) {
if (trx != null) {
try {
trx.commit(true);
} catch (Exception e) {
log.log(Level.SEVERE, "Commit failed.", e);
pi.addSummary("Commit Failed.");
pi.setError(true);
success = false;
}
trx.close();
}
} else {
if (trx != null) {
trx.rollback();
trx.close();
}
}
return success;
}
use of org.compiere.process.ProcessInfoParameter in project adempiere by adempiere.
the class ASPGenerateLevel method prepare.
/**
* Prepare
*/
protected void prepare() {
for (ProcessInfoParameter para : getParameter()) {
String name = para.getParameterName();
if (para.getParameter() == null)
;
else if (name.equals("ASP_Status"))
p_ASP_Status = (String) para.getParameter();
else if (name.equals("AD_Menu_ID"))
p_AD_Menu_ID = para.getParameterAsInt();
else if (name.equals("IsGenerateFields"))
p_IsGenerateFields = para.getParameter().equals("Y");
else
log.log(Level.SEVERE, "Unknown Parameter: " + name);
}
p_ASP_Level_ID = getRecord_ID();
}
use of org.compiere.process.ProcessInfoParameter in project adempiere by adempiere.
the class ModelExporter method prepare.
/**
* Get Parameters
*/
protected void prepare() {
p_Record_ID = getRecord_ID();
if (p_AD_Client_ID == 0)
p_AD_Client_ID = Env.getAD_Client_ID(getCtx());
AD_Table_ID = getTable_ID();
StringBuffer sb = new StringBuffer("AD_Table_ID=").append(AD_Table_ID);
sb.append("; Record_ID=").append(getRecord_ID());
// Parameter
ProcessInfoParameter[] paras = getParameter();
for (ProcessInfoParameter para : paras) {
String name = para.getParameterName();
if (para.getParameter() == null)
;
else if (name.equals("EXP_Format_ID"))
p_EXP_Format_ID = para.getParameterAsInt();
else if (name.equals("FileName"))
p_FileName = (String) para.getParameter();
else
log.log(Level.SEVERE, "Unknown Parameter: " + name);
}
if (p_EXP_Format_ID == 0)
p_EXP_Format_ID = p_Record_ID;
if (p_FileName == null) {
// Load XML file and parse it
String fileNameOr = org.compiere.util.Ini.findAdempiereHome() + System.getProperty("file.separator") + "data" + System.getProperty("file.separator") + "ExportFile.xml";
p_FileName = fileNameOr;
}
log.info(sb.toString());
}
Aggregations