use of org.compiere.model.MProcessPara in project adempiere by adempiere.
the class WProcess method createParameterPage.
// doPost
//Modified by Rob Klein 4/29/07
/**************************************************************************
* Create Parameter Page
* @param wsc web session context
* @param AD_Menu_ID Menu
* @return Page
*/
private WebDoc createParameterPage(WebSessionCtx wsc, int processId, int windowID, int tableID, int recordID, int Type, String columnName, GridTab mTab) {
MProcess process = null;
if (Type == 0)
process = MProcess.getFromMenu(wsc.ctx, processId);
else
process = MProcess.get(wsc.ctx, processId);
// need to check if Role can access
if (process == null) {
WebDoc doc = WebDoc.createWindow("Process Not Found");
return doc;
}
//Modified by Rob Klein 4/29/07
WebDoc doc = WebDoc.createWindow(process.getName());
if (process.isWorkflow()) {
//Modified by Rob Klein 7/01/07
if (mTab == null) {
doc = WebDoc.createWindow("No Tab found");
return doc;
}
// Pop up Document Action (Workflow)
if (columnName.toString().equals("DocAction")) {
readReference();
option[] Options = dynInit(windowID, tableID, recordID, columnName, mTab);
td center = doc.addWindowCenter(false);
WebField wField = new WebField(wsc, columnName, columnName, columnName, // no display length
17, 22, 22, false, // not r/o, ., not error, not dependent
false, false, false, false, false, processId, 0, 0, 0, 0, null, null, null, null, null);
if (process.getDescription() != null)
center.addElement(new p(new i(process.getDescription())));
if (process.getHelp() != null)
center.addElement(new p(process.getHelp(), AlignType.LEFT));
form myForm = new form("WProcess").setName("process" + process.getAD_Process_ID());
myForm.setTarget("WPopup");
//myForm.setOnSubmit("this.Submit.disabled=true;return true;");
myForm.addElement(new input(input.TYPE_HIDDEN, "AD_Process_ID", process.getAD_Process_ID()));
myForm.addElement(new input(input.TYPE_HIDDEN, "AD_Window_ID", windowID));
myForm.addElement(new input(input.TYPE_HIDDEN, "AD_Table_ID", tableID));
myForm.addElement(new input(input.TYPE_HIDDEN, "AD_Record_ID", recordID));
table myTable = new table("0", "0", "5", "100%", null);
myTable.setID("WProcessParameter");
myTable.addElement(new tr().addElement(wField.getLabel()).addElement(createSelectField(columnName, Options)));
// Reset
String text = "Reset";
if (wsc.ctx != null)
text = Msg.getMsg(wsc.ctx, "Reset");
input restbtn = new input(input.TYPE_RESET, text, " " + text);
restbtn.setID(text);
restbtn.setClass("resetbtn");
// Submit
text = "Submit";
if (wsc.ctx != null)
text = Msg.getMsg(wsc.ctx, "Submit");
input submitbtn = new input(input.TYPE_SUBMIT, text, " " + text);
submitbtn.setID(text);
submitbtn.setClass("submitbtn");
myTable.addElement(new tr().addElement(new td(null, AlignType.RIGHT, AlignType.MIDDLE, false, restbtn)).addElement(new td(null, AlignType.LEFT, AlignType.MIDDLE, false, submitbtn)).addElement(new td(null, AlignType.RIGHT, AlignType.MIDDLE, false, null)));
myForm.addElement(myTable);
center.addElement(myForm);
}
// DocAction
} else {
td center = doc.addWindowCenter(false);
if (process.getDescription() != null)
center.addElement(new p(new i(process.getDescription())));
if (process.getHelp() != null)
center.addElement(new p(process.getHelp(), AlignType.LEFT));
//
form myForm = new form("WProcess").setName("process" + process.getAD_Process_ID());
myForm.setTarget("WPopup");
//myForm.setOnSubmit("this.Submit.disabled=true;return true;");
myForm.addElement(new input(input.TYPE_HIDDEN, "AD_Process_ID", process.getAD_Process_ID()));
myForm.addElement(new input(input.TYPE_HIDDEN, "AD_Window_ID", windowID));
myForm.addElement(new input(input.TYPE_HIDDEN, "AD_Table_ID", tableID));
myForm.addElement(new input(input.TYPE_HIDDEN, "AD_Record_ID", recordID));
table myTable = new table("0", "0", "5", "100%", null);
myTable.setID("WProcessParameter");
MProcessPara[] parameter = process.getParameters();
for (int i = 0; i < parameter.length; i++) {
MProcessPara para = parameter[i];
WebField wField = new WebField(wsc, para.getColumnName(), para.getName(), para.getDescription(), // no display length
para.getAD_Reference_ID(), para.getFieldLength(), para.getFieldLength(), false, // not r/o, ., not error, not dependent
false, para.isMandatory(), false, false, false, para.getAD_Process_ID(), 0, 0, 0, i, null, null, null, null, null);
WebField wFieldforRange = null;
if (para.isRange())
wFieldforRange = new WebField(wsc, para.getColumnName(), para.getName(), para.getDescription(), // no display length
para.getAD_Reference_ID(), para.getFieldLength(), para.getFieldLength(), false, // not r/o, ., not error, not dependent
false, para.isMandatory(), false, false, false, para.getAD_Process_ID(), 0, 0, 0, i + 1, null, null, null, null, null);
td toField = para.isRange() ? wFieldforRange.getField(para.getLookup(), para.getDefaultValue2()) : new td(WebEnv.NBSP);
// Add to Table
myTable.addElement(new tr().addElement(wField.getLabel()).addElement(wField.getField(para.getLookup(), para.getDefaultValue())).addElement(toField));
}
// Reset
String text = "Reset";
if (wsc.ctx != null)
text = Msg.getMsg(wsc.ctx, "Reset");
input restbtn = new input(input.TYPE_RESET, text, " " + text);
restbtn.setID(text);
restbtn.setClass("resetbtn");
// Submit
text = "Submit";
if (wsc.ctx != null)
text = Msg.getMsg(wsc.ctx, "Submit");
input submitbtn = new input(input.TYPE_SUBMIT, text, " " + text);
submitbtn.setID(text);
submitbtn.setClass("submitbtn");
submitbtn.setOnClick("popUp('WProcess','WPopup')");
myTable.addElement(new tr().addElement(new td(null, AlignType.RIGHT, AlignType.MIDDLE, false, restbtn)).addElement(new td(null, AlignType.LEFT, AlignType.MIDDLE, false, submitbtn)).addElement(new td(null, AlignType.RIGHT, AlignType.MIDDLE, false, null)));
myForm.addElement(myTable);
center.addElement(myForm);
}
return doc;
}
use of org.compiere.model.MProcessPara 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.MProcessPara in project adempiere by adempiere.
the class ProcessAbstractClassGenerator method createParameters.
/**
* Create Parameters for header
* @return
*/
private void createParameters() {
// Create Name and Values
for (MProcessPara parameter : getParameters()) {
// The information only don't are parameters
if (parameter.isInfoOnly())
continue;
createParameterName(parameter);
createParameterValue(parameter, false);
createParameterFill(parameter, false);
// For Range
if (parameter.isRange()) {
createParameterValue(parameter, true);
createParameterFill(parameter, true);
}
}
}
use of org.compiere.model.MProcessPara in project adempiere by adempiere.
the class ASPGenerateLevel method generateProcess.
private void generateProcess(int p_AD_Process_ID) {
// Add Process and Parameters
MProcess process = new MProcess(getCtx(), p_AD_Process_ID, get_TrxName());
int asp_process_id = DB.getSQLValueEx(get_TrxName(), "SELECT ASP_Process_ID FROM ASP_Process WHERE ASP_Level_ID = ? AND AD_Process_ID = ?", p_ASP_Level_ID, process.getAD_Process_ID());
X_ASP_Process aspProcess = null;
if (asp_process_id < 1) {
aspProcess = new X_ASP_Process(getCtx(), 0, get_TrxName());
aspProcess.setASP_Level_ID(p_ASP_Level_ID);
aspProcess.setAD_Process_ID(process.getAD_Process_ID());
aspProcess.setASP_Status(p_ASP_Status);
if (aspProcess.save()) {
noProcesses++;
asp_process_id = aspProcess.getASP_Process_ID();
}
} else {
aspProcess = new X_ASP_Process(getCtx(), asp_process_id, get_TrxName());
}
// parameters
for (MProcessPara processpara : process.getParameters()) {
if (DB.getSQLValueEx(get_TrxName(), "SELECT COUNT(*) FROM ASP_Process_Para WHERE ASP_Process_ID = ? AND AD_Process_Para_ID = ?", asp_process_id, processpara.getAD_Process_Para_ID()) < 1) {
X_ASP_Process_Para aspProcess_Para = new X_ASP_Process_Para(getCtx(), 0, get_TrxName());
aspProcess_Para.setASP_Process_ID(asp_process_id);
aspProcess_Para.setAD_Process_Para_ID(processpara.getAD_Process_Para_ID());
aspProcess_Para.setASP_Status(p_ASP_Status);
if (aspProcess_Para.save())
noParameters++;
}
}
if (process.getAD_Workflow_ID() > 0) {
generateWorkflow(process.getAD_Workflow_ID());
}
}
use of org.compiere.model.MProcessPara in project adempiere by adempiere.
the class CopyReportProcess method copyFrom.
/**
* Copy parameters to process
* @param process
* @param record
* @throws SQLException
*/
private void copyFrom(MProcess process, int key) throws SQLException {
// Get Values
int m_AD_Column_ID = getSelectionAsInt(key, "PARAMETER_AD_Column_ID");
int m_AD_ReportView_ID = getSelectionAsInt(key, "PARAMETER_AD_ReportView_ID");
int m_AD_Process_Para_ID = getSelectionAsInt(key, "PARAMETER_AD_Process_Para_ID");
boolean m_IsMandatory = getSelectionAsBoolean(key, "PARAMETER_IsMandatory");
boolean m_IsRange = getSelectionAsBoolean(key, "PARAMETER_IsRange");
String m_DefaultValue = getSelectionAsString(key, "PARAMETER_DefaultValue");
String m_DefaultValue2 = getSelectionAsString(key, "PARAMETER_DefaultValue2");
// Do it
MProcessPara newParameter = new MProcessPara(process);
if (m_AD_ReportView_ID != 0) {
// For Create from View
MColumn column = MColumn.get(getCtx(), m_AD_Column_ID);
//
if (column.getAD_Reference_ID() == DisplayType.ID) {
return;
}
// For Process
if (process.getAD_ReportView_ID() != m_AD_ReportView_ID) {
process.setAD_ReportView_ID(m_AD_ReportView_ID);
process.saveEx();
}
// Set Values
newParameter.setEntityType(process.getEntityType());
newParameter.setAD_Element_ID(column.getAD_Element_ID());
newParameter.setAD_Reference_ID(column.getAD_Reference_ID());
newParameter.setAD_Reference_Value_ID(column.getAD_Reference_Value_ID());
newParameter.setAD_Val_Rule_ID(column.getAD_Val_Rule_ID());
newParameter.setName(column.getName());
newParameter.setColumnName(column.getColumnName());
newParameter.setDescription(column.getDescription());
newParameter.setFieldLength(column.getFieldLength());
newParameter.setHelp(column.getHelp());
newParameter.setIsCentrallyMaintained(true);
} else if (m_AD_Process_Para_ID != 0) {
// For Copy from Process
MProcessPara fromParameter = new MProcessPara(getCtx(), m_AD_Process_Para_ID, get_TrxName());
PO.copyValues(fromParameter, newParameter);
} else {
return;
}
// Fill values
newParameter.setIsMandatory(m_IsMandatory);
newParameter.setIsRange(m_IsRange);
newParameter.setDefaultValue(m_DefaultValue);
newParameter.setDefaultValue2(m_DefaultValue2);
newParameter.setSeqNo(m_SeqNo);
// Save
newParameter.saveEx();
// Add new Sequence
m_SeqNo += 10;
addLog("@AD_Process_Para_ID@ @" + newParameter.getColumnName() + "@ @Added@");
}
Aggregations