1003376 Form to captured process parameter for scheduler. IDEMPIERE-1486
This commit is contained in:
parent
11041a4a4d
commit
2d7e991095
|
@ -0,0 +1,56 @@
|
|||
SET SQLBLANKLINES ON
|
||||
SET DEFINE OFF
|
||||
|
||||
-- Oct 23, 2013 3:21:49 PM MYT
|
||||
-- 1003376 Form to captured process parameter for scheduler
|
||||
INSERT INTO AD_Element (ColumnName,AD_Element_ID,Help,Name,Description,PrintName,AD_Element_UU,Created,Updated,AD_Org_ID,CreatedBy,UpdatedBy,IsActive,AD_Client_ID,EntityType) VALUES ('ParameterToDefault',202621,'The default value can be a variable like @#Date@ ','Default To Parameter','Default value of the to parameter','Default To Parameter','51de5831-4534-45e3-865b-d3ae57c7770d',TO_DATE('2013-10-23 15:21:48','YYYY-MM-DD HH24:MI:SS'),TO_DATE('2013-10-23 15:21:48','YYYY-MM-DD HH24:MI:SS'),0,100,100,'Y',0,'D')
|
||||
;
|
||||
|
||||
-- Oct 23, 2013 3:22:53 PM MYT
|
||||
-- 1003376 Form to captured process parameter for scheduler
|
||||
INSERT INTO AD_Column (IsSyncDatabase,Version,AD_Table_ID,AD_Column_ID,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsParent,FieldLength,IsSelectionColumn,AD_Reference_ID,IsKey,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsUpdateable,ColumnName,Description,Help,Name,IsAllowCopy,Updated,CreatedBy,AD_Org_ID,IsActive,Created,UpdatedBy,IsToolbarButton,IsAlwaysUpdateable,AD_Client_ID,EntityType,IsEncrypted,AD_Element_ID,IsSecure) VALUES ('N',1,698,210881,'N','N','N',0,'N',255,'N',10,'N','N','N','c3d45397-19b4-4cd9-9dda-1cde8d35ef8b','Y','ParameterToDefault','Default value of the to parameter','The default value can be a variable like @#Date@ ','Default To Parameter','Y',TO_DATE('2013-10-23 15:22:52','YYYY-MM-DD HH24:MI:SS'),100,0,'Y',TO_DATE('2013-10-23 15:22:52','YYYY-MM-DD HH24:MI:SS'),100,'N','N',0,'U','N',202621,'N')
|
||||
;
|
||||
|
||||
-- Oct 23, 2013 3:23:22 PM MYT
|
||||
-- 1003376 Form to captured process parameter for scheduler
|
||||
UPDATE AD_Column SET EntityType='D',Updated=TO_DATE('2013-10-23 15:23:22','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=210881
|
||||
;
|
||||
|
||||
-- Oct 23, 2013 3:23:39 PM MYT
|
||||
-- 1003376 Form to captured process parameter for scheduler
|
||||
ALTER TABLE AD_Scheduler_Para ADD ParameterToDefault NVARCHAR2(255) DEFAULT NULL
|
||||
;
|
||||
|
||||
-- Oct 23, 2013 3:25:14 PM MYT
|
||||
-- 1003376 Form to captured process parameter for scheduler
|
||||
INSERT INTO AD_Field (SortNo,IsEncrypted,AD_Tab_ID,DisplayLength,IsSameLine,IsHeading,AD_Column_ID,SeqNo,IsCentrallyMaintained,AD_Field_ID,IsReadOnly,Help,Description,Name,AD_Field_UU,IsDisplayed,IsFieldOnly,UpdatedBy,AD_Org_ID,Created,CreatedBy,Updated,IsActive,IsDisplayedGrid,SeqNoGrid,XPosition,IsQuickEntry,AD_Client_ID,ColumnSpan,NumLines,EntityType,IsAdvancedField,IsDefaultFocus) VALUES (0,'N',590,0,'N','N',210881,80,'Y',202528,'N','The default value can be a variable like @#Date@ ','Default value of the to parameter','Default To Parameter','f9902ce8-90b2-4192-ab23-a1f218e34535','Y','N',100,0,TO_DATE('2013-10-23 15:25:12','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2013-10-23 15:25:12','YYYY-MM-DD HH24:MI:SS'),'Y','Y',80,1,'N',0,2,1,'D','N','N')
|
||||
;
|
||||
|
||||
-- Oct 23, 2013 3:25:45 PM MYT
|
||||
-- 1003376 Form to captured process parameter for scheduler
|
||||
UPDATE AD_Field SET SeqNo=70, IsDisplayed='Y', XPosition=1, ColumnSpan=5,Updated=TO_DATE('2013-10-23 15:25:45','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=202528
|
||||
;
|
||||
|
||||
-- Oct 23, 2013 3:25:45 PM MYT
|
||||
-- 1003376 Form to captured process parameter for scheduler
|
||||
UPDATE AD_Field SET SeqNo=80,Updated=TO_DATE('2013-10-23 15:25:45','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=9447
|
||||
;
|
||||
|
||||
-- Oct 23, 2013 3:27:43 PM MYT
|
||||
-- 1003376 Form to captured process parameter for scheduler
|
||||
INSERT INTO AD_Form (AccessLevel,Classname,AD_Form_ID,IsBetaFunctionality,AD_Form_UU,Name,AD_Org_ID,UpdatedBy,CreatedBy,Updated,Created,IsActive,AD_Client_ID,EntityType) VALUES ('4','org.adempiere.webui.apps.form.WProcessParameter',200008,'N','0a47e803-4917-4e7f-af33-39135b8b2415','Captured Process Parameter',0,100,100,TO_DATE('2013-10-23 15:27:42','YYYY-MM-DD HH24:MI:SS'),TO_DATE('2013-10-23 15:27:42','YYYY-MM-DD HH24:MI:SS'),'Y',0,'D')
|
||||
;
|
||||
|
||||
-- Oct 23, 2013 3:28:05 PM MYT
|
||||
-- 1003376 Form to captured process parameter for scheduler
|
||||
INSERT INTO AD_Process (CopyFromProcess,AD_Process_ID,IsDirectPrint,IsReport,AD_Process_UU,AccessLevel,IsBetaFunctionality,IsServerProcess,Statistic_Seconds,Statistic_Count,ShowHelp,AD_Form_ID,AD_Org_ID,Updated,UpdatedBy,Created,IsActive,CreatedBy,Name,Value,AD_Client_ID,EntityType) VALUES ('N',200064,'N','N','cef75223-9f82-4eb3-a2e9-9702eb2f7d69','4','N','N',0,0,'Y',200008,0,TO_DATE('2013-10-23 15:28:05','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2013-10-23 15:28:05','YYYY-MM-DD HH24:MI:SS'),'Y',100,'Captured Process Parameter','CapturedProcessParameter',0,'D')
|
||||
;
|
||||
|
||||
-- Oct 23, 2013 3:29:32 PM MYT
|
||||
-- 1003376 Form to captured process parameter for scheduler
|
||||
INSERT INTO AD_ToolBarButton (Action,AD_Tab_ID,AD_Process_ID,SeqNo,Created,AD_Org_ID,IsCustomization,Name,ComponentName,CreatedBy,AD_ToolBarButton_ID,Updated,UpdatedBy,IsActive,AD_Client_ID,AD_ToolBarButton_UU) VALUES ('W',589,200064,10,TO_DATE('2013-10-23 15:29:31','YYYY-MM-DD HH24:MI:SS'),0,'N','Captured Process Parameter','CapturedProcessParameter',100,200077,TO_DATE('2013-10-23 15:29:31','YYYY-MM-DD HH24:MI:SS'),100,'Y',0,'45728640-5c48-41be-b2b6-5970199b05db')
|
||||
;
|
||||
|
||||
SELECT register_migration_script('201310230810_1003376.sql') FROM dual
|
||||
;
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
-- Oct 23, 2013 3:21:49 PM MYT
|
||||
-- 1003376 Form to captured process parameter for scheduler
|
||||
INSERT INTO AD_Element (ColumnName,AD_Element_ID,Help,Name,Description,PrintName,AD_Element_UU,Created,Updated,AD_Org_ID,CreatedBy,UpdatedBy,IsActive,AD_Client_ID,EntityType) VALUES ('ParameterToDefault',202621,'The default value can be a variable like @#Date@ ','Default To Parameter','Default value of the to parameter','Default To Parameter','51de5831-4534-45e3-865b-d3ae57c7770d',TO_TIMESTAMP('2013-10-23 15:21:48','YYYY-MM-DD HH24:MI:SS'),TO_TIMESTAMP('2013-10-23 15:21:48','YYYY-MM-DD HH24:MI:SS'),0,100,100,'Y',0,'D')
|
||||
;
|
||||
|
||||
-- Oct 23, 2013 3:22:53 PM MYT
|
||||
-- 1003376 Form to captured process parameter for scheduler
|
||||
INSERT INTO AD_Column (IsSyncDatabase,Version,AD_Table_ID,AD_Column_ID,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsParent,FieldLength,IsSelectionColumn,AD_Reference_ID,IsKey,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsUpdateable,ColumnName,Description,Help,Name,IsAllowCopy,Updated,CreatedBy,AD_Org_ID,IsActive,Created,UpdatedBy,IsToolbarButton,IsAlwaysUpdateable,AD_Client_ID,EntityType,IsEncrypted,AD_Element_ID,IsSecure) VALUES ('N',1,698,210881,'N','N','N',0,'N',255,'N',10,'N','N','N','c3d45397-19b4-4cd9-9dda-1cde8d35ef8b','Y','ParameterToDefault','Default value of the to parameter','The default value can be a variable like @#Date@ ','Default To Parameter','Y',TO_TIMESTAMP('2013-10-23 15:22:52','YYYY-MM-DD HH24:MI:SS'),100,0,'Y',TO_TIMESTAMP('2013-10-23 15:22:52','YYYY-MM-DD HH24:MI:SS'),100,'N','N',0,'U','N',202621,'N')
|
||||
;
|
||||
|
||||
-- Oct 23, 2013 3:23:22 PM MYT
|
||||
-- 1003376 Form to captured process parameter for scheduler
|
||||
UPDATE AD_Column SET EntityType='D',Updated=TO_TIMESTAMP('2013-10-23 15:23:22','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=210881
|
||||
;
|
||||
|
||||
-- Oct 23, 2013 3:23:39 PM MYT
|
||||
-- 1003376 Form to captured process parameter for scheduler
|
||||
ALTER TABLE AD_Scheduler_Para ADD COLUMN ParameterToDefault VARCHAR(255) DEFAULT NULL
|
||||
;
|
||||
|
||||
-- Oct 23, 2013 3:25:14 PM MYT
|
||||
-- 1003376 Form to captured process parameter for scheduler
|
||||
INSERT INTO AD_Field (SortNo,IsEncrypted,AD_Tab_ID,DisplayLength,IsSameLine,IsHeading,AD_Column_ID,SeqNo,IsCentrallyMaintained,AD_Field_ID,IsReadOnly,Help,Description,Name,AD_Field_UU,IsDisplayed,IsFieldOnly,UpdatedBy,AD_Org_ID,Created,CreatedBy,Updated,IsActive,IsDisplayedGrid,SeqNoGrid,XPosition,IsQuickEntry,AD_Client_ID,ColumnSpan,NumLines,EntityType,IsAdvancedField,IsDefaultFocus) VALUES (0,'N',590,0,'N','N',210881,80,'Y',202528,'N','The default value can be a variable like @#Date@ ','Default value of the to parameter','Default To Parameter','f9902ce8-90b2-4192-ab23-a1f218e34535','Y','N',100,0,TO_TIMESTAMP('2013-10-23 15:25:12','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2013-10-23 15:25:12','YYYY-MM-DD HH24:MI:SS'),'Y','Y',80,1,'N',0,2,1,'D','N','N')
|
||||
;
|
||||
|
||||
-- Oct 23, 2013 3:25:45 PM MYT
|
||||
-- 1003376 Form to captured process parameter for scheduler
|
||||
UPDATE AD_Field SET SeqNo=70, IsDisplayed='Y', XPosition=1, ColumnSpan=5,Updated=TO_TIMESTAMP('2013-10-23 15:25:45','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=202528
|
||||
;
|
||||
|
||||
-- Oct 23, 2013 3:25:45 PM MYT
|
||||
-- 1003376 Form to captured process parameter for scheduler
|
||||
UPDATE AD_Field SET SeqNo=80,Updated=TO_TIMESTAMP('2013-10-23 15:25:45','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=9447
|
||||
;
|
||||
|
||||
-- Oct 23, 2013 3:27:43 PM MYT
|
||||
-- 1003376 Form to captured process parameter for scheduler
|
||||
INSERT INTO AD_Form (AccessLevel,Classname,AD_Form_ID,IsBetaFunctionality,AD_Form_UU,Name,AD_Org_ID,UpdatedBy,CreatedBy,Updated,Created,IsActive,AD_Client_ID,EntityType) VALUES ('4','org.adempiere.webui.apps.form.WProcessParameter',200008,'N','0a47e803-4917-4e7f-af33-39135b8b2415','Captured Process Parameter',0,100,100,TO_TIMESTAMP('2013-10-23 15:27:42','YYYY-MM-DD HH24:MI:SS'),TO_TIMESTAMP('2013-10-23 15:27:42','YYYY-MM-DD HH24:MI:SS'),'Y',0,'D')
|
||||
;
|
||||
|
||||
-- Oct 23, 2013 3:28:05 PM MYT
|
||||
-- 1003376 Form to captured process parameter for scheduler
|
||||
INSERT INTO AD_Process (CopyFromProcess,AD_Process_ID,IsDirectPrint,IsReport,AD_Process_UU,AccessLevel,IsBetaFunctionality,IsServerProcess,Statistic_Seconds,Statistic_Count,ShowHelp,AD_Form_ID,AD_Org_ID,Updated,UpdatedBy,Created,IsActive,CreatedBy,Name,Value,AD_Client_ID,EntityType) VALUES ('N',200064,'N','N','cef75223-9f82-4eb3-a2e9-9702eb2f7d69','4','N','N',0,0,'Y',200008,0,TO_TIMESTAMP('2013-10-23 15:28:05','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2013-10-23 15:28:05','YYYY-MM-DD HH24:MI:SS'),'Y',100,'Captured Process Parameter','CapturedProcessParameter',0,'D')
|
||||
;
|
||||
|
||||
-- Oct 23, 2013 3:29:32 PM MYT
|
||||
-- 1003376 Form to captured process parameter for scheduler
|
||||
INSERT INTO AD_ToolBarButton ("action",AD_Tab_ID,AD_Process_ID,SeqNo,Created,AD_Org_ID,IsCustomization,Name,ComponentName,CreatedBy,AD_ToolBarButton_ID,Updated,UpdatedBy,IsActive,AD_Client_ID,AD_ToolBarButton_UU) VALUES ('W',589,200064,10,TO_TIMESTAMP('2013-10-23 15:29:31','YYYY-MM-DD HH24:MI:SS'),0,'N','Captured Process Parameter','CapturedProcessParameter',100,200077,TO_TIMESTAMP('2013-10-23 15:29:31','YYYY-MM-DD HH24:MI:SS'),100,'Y',0,'45728640-5c48-41be-b2b6-5970199b05db')
|
||||
;
|
||||
|
||||
SELECT register_migration_script('201310230810_1003376.sql') FROM dual
|
||||
;
|
||||
|
|
@ -152,6 +152,19 @@ public interface I_AD_Scheduler_Para
|
|||
*/
|
||||
public String getParameterDefault();
|
||||
|
||||
/** Column name ParameterToDefault */
|
||||
public static final String COLUMNNAME_ParameterToDefault = "ParameterToDefault";
|
||||
|
||||
/** Set Default To Parameter.
|
||||
* Default value of the to parameter
|
||||
*/
|
||||
public void setParameterToDefault (String ParameterToDefault);
|
||||
|
||||
/** Get Default To Parameter.
|
||||
* Default value of the to parameter
|
||||
*/
|
||||
public String getParameterToDefault();
|
||||
|
||||
/** Column name Updated */
|
||||
public static final String COLUMNNAME_Updated = "Updated";
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ public class X_AD_Scheduler_Para extends PO implements I_AD_Scheduler_Para, I_Pe
|
|||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 20130626L;
|
||||
private static final long serialVersionUID = 20131023L;
|
||||
|
||||
/** Standard Constructor */
|
||||
public X_AD_Scheduler_Para (Properties ctx, int AD_Scheduler_Para_ID, String trxName)
|
||||
|
@ -170,4 +170,21 @@ public class X_AD_Scheduler_Para extends PO implements I_AD_Scheduler_Para, I_Pe
|
|||
{
|
||||
return (String)get_Value(COLUMNNAME_ParameterDefault);
|
||||
}
|
||||
|
||||
/** Set Default To Parameter.
|
||||
@param ParameterToDefault
|
||||
Default value of the to parameter
|
||||
*/
|
||||
public void setParameterToDefault (String ParameterToDefault)
|
||||
{
|
||||
set_Value (COLUMNNAME_ParameterToDefault, ParameterToDefault);
|
||||
}
|
||||
|
||||
/** Get Default To Parameter.
|
||||
@return Default value of the to parameter
|
||||
*/
|
||||
public String getParameterToDefault ()
|
||||
{
|
||||
return (String)get_Value(COLUMNNAME_ParameterToDefault);
|
||||
}
|
||||
}
|
|
@ -310,43 +310,14 @@ public class Scheduler extends AdempiereServer
|
|||
if (paraDesc != null && paraDesc.trim().length() > 0)
|
||||
iPara.setInfo(sPara.getDescription());
|
||||
String variable = sPara.getParameterDefault();
|
||||
String toVariable = sPara.getParameterToDefault();
|
||||
if (log.isLoggable(Level.FINE)) log.fine(sPara.getColumnName() + " = " + variable);
|
||||
// Value - Constant/Variable
|
||||
Object value = variable;
|
||||
if (variable == null
|
||||
|| (variable != null && variable.length() == 0))
|
||||
value = null;
|
||||
else if ( variable.indexOf('@') != -1
|
||||
&& variable.indexOf('@') != variable.lastIndexOf('@')) // we have a variable / BF [1926032]
|
||||
{
|
||||
// Strip
|
||||
int index = variable.indexOf('@');
|
||||
String columnName = variable.substring(index+1);
|
||||
index = columnName.indexOf('@');
|
||||
if (index == -1)
|
||||
{
|
||||
log.warning(sPara.getColumnName()
|
||||
+ " - cannot evaluate=" + variable);
|
||||
break;
|
||||
}
|
||||
columnName = columnName.substring(0, index);
|
||||
// try Env
|
||||
String env = Env.getContext(m_schedulerctx, columnName);
|
||||
if (env == null || env.length() == 0)
|
||||
env = Env.getContext(getCtx(), columnName);
|
||||
if (env.length() == 0)
|
||||
{
|
||||
log.warning(sPara.getColumnName()
|
||||
+ " - not in environment =" + columnName
|
||||
+ "(" + variable + ")");
|
||||
break;
|
||||
}
|
||||
else
|
||||
value = env;
|
||||
} // @variable@
|
||||
Object value = parseVariable(sPara, variable);
|
||||
Object toValue = toVariable != null ? parseVariable(sPara, toVariable) : null;
|
||||
|
||||
// No Value
|
||||
if (value == null)
|
||||
if (value == null && toValue == null)
|
||||
{
|
||||
if (log.isLoggable(Level.FINE)) log.fine(sPara.getColumnName() + " - empty");
|
||||
break;
|
||||
|
@ -358,31 +329,34 @@ public class Scheduler extends AdempiereServer
|
|||
if (DisplayType.isNumeric(sPara.getDisplayType())
|
||||
|| DisplayType.isID(sPara.getDisplayType()))
|
||||
{
|
||||
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());
|
||||
BigDecimal bd = toBigDecimal(value);
|
||||
iPara.setP_Number(bd);
|
||||
if (toValue != null)
|
||||
{
|
||||
bd = toBigDecimal(toValue);
|
||||
iPara.setP_Number_To(bd);
|
||||
}
|
||||
if (log.isLoggable(Level.FINE)) log.fine(sPara.getColumnName()
|
||||
+ " = " + variable + " (=" + bd + "=)");
|
||||
}
|
||||
else if (DisplayType.isDate(sPara.getDisplayType()))
|
||||
{
|
||||
Timestamp ts = null;
|
||||
if (value instanceof Timestamp)
|
||||
ts = (Timestamp)value;
|
||||
else
|
||||
ts = Timestamp.valueOf(value.toString());
|
||||
Timestamp ts = toTimestamp(value);
|
||||
iPara.setP_Date(ts);
|
||||
if (toValue != null) {
|
||||
ts = toTimestamp(toValue);
|
||||
iPara.setP_Date_To(ts);
|
||||
}
|
||||
if (log.isLoggable(Level.FINE)) log.fine(sPara.getColumnName()
|
||||
+ " = " + variable + " (=" + ts + "=)");
|
||||
}
|
||||
else
|
||||
{
|
||||
iPara.setP_String(value.toString());
|
||||
if (toValue != null)
|
||||
{
|
||||
iPara.setP_String_To(toValue.toString());
|
||||
}
|
||||
if (log.isLoggable(Level.FINE)) log.fine(sPara.getColumnName()
|
||||
+ " = " + variable
|
||||
+ " (=" + value + "=) " + value.getClass().getName());
|
||||
|
@ -403,6 +377,62 @@ public class Scheduler extends AdempiereServer
|
|||
} // instance parameter loop
|
||||
} // fillParameter
|
||||
|
||||
private Timestamp toTimestamp(Object value) {
|
||||
Timestamp ts = null;
|
||||
if (value instanceof Timestamp)
|
||||
ts = (Timestamp)value;
|
||||
else
|
||||
ts = Timestamp.valueOf(value.toString());
|
||||
return ts;
|
||||
}
|
||||
|
||||
private BigDecimal toBigDecimal(Object value) {
|
||||
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());
|
||||
return bd;
|
||||
}
|
||||
|
||||
private Object parseVariable(MSchedulerPara sPara, String variable) {
|
||||
Object value = variable;
|
||||
if (variable == null
|
||||
|| (variable != null && variable.length() == 0))
|
||||
value = null;
|
||||
else if ( variable.indexOf('@') != -1
|
||||
&& variable.indexOf('@') != variable.lastIndexOf('@')) // we have a variable / BF [1926032]
|
||||
{
|
||||
// Strip
|
||||
int index = variable.indexOf('@');
|
||||
String columnName = variable.substring(index+1);
|
||||
index = columnName.indexOf('@');
|
||||
if (index == -1)
|
||||
{
|
||||
log.warning(sPara.getColumnName()
|
||||
+ " - cannot evaluate=" + variable);
|
||||
return null;
|
||||
}
|
||||
columnName = columnName.substring(0, index);
|
||||
// try Env
|
||||
String env = Env.getContext(m_schedulerctx, columnName);
|
||||
if (env == null || env.length() == 0)
|
||||
env = Env.getContext(getCtx(), columnName);
|
||||
if (env.length() == 0)
|
||||
{
|
||||
log.warning(sPara.getColumnName()
|
||||
+ " - not in environment =" + columnName
|
||||
+ "(" + variable + ")");
|
||||
return null;
|
||||
}
|
||||
else
|
||||
value = env;
|
||||
} // @variable@
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get Server Info
|
||||
|
|
|
@ -20,6 +20,7 @@ import java.sql.ResultSet;
|
|||
import java.sql.SQLException;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.adempiere.webui.component.Column;
|
||||
|
@ -454,7 +455,7 @@ public class ProcessParameterPanel extends Panel implements
|
|||
MPInstancePara para = new MPInstancePara(Env.getCtx(),
|
||||
m_processInfo.getAD_PInstance_ID(), i);
|
||||
GridField mField = (GridField) m_mFields.get(i);
|
||||
para.setParameterName(mField.getColumnName());
|
||||
para.setParameterName(mField.getColumnName());
|
||||
|
||||
// Date
|
||||
if (result instanceof Timestamp || result2 instanceof Timestamp) {
|
||||
|
@ -509,6 +510,95 @@ public class ProcessParameterPanel extends Panel implements
|
|||
return true;
|
||||
} // saveParameters
|
||||
|
||||
/**
|
||||
* Get Parameter values without saving
|
||||
*
|
||||
* @return list of parameter values
|
||||
*/
|
||||
public MPInstancePara[] getParameters() {
|
||||
log.config("");
|
||||
|
||||
if (!validateParameters())
|
||||
return new MPInstancePara[0];
|
||||
|
||||
List<MPInstancePara> paras = new ArrayList<MPInstancePara>();
|
||||
|
||||
/**********************************************************************
|
||||
* Save Now
|
||||
*/
|
||||
for (int i = 0; i < m_mFields.size(); i++) {
|
||||
// Get Values
|
||||
WEditor editor = (WEditor) m_wEditors.get(i);
|
||||
WEditor editor2 = (WEditor) m_wEditors2.get(i);
|
||||
Object result = editor.getValue();
|
||||
Object result2 = null;
|
||||
if (editor2 != null)
|
||||
result2 = editor2.getValue();
|
||||
|
||||
// Create Parameter
|
||||
MPInstancePara para = new MPInstancePara(Env.getCtx(), 0, i);
|
||||
GridField mField = (GridField) m_mFields.get(i);
|
||||
para.setParameterName(mField.getColumnName());
|
||||
para.setP_Date(null);
|
||||
para.setP_Date_To(null);
|
||||
para.setP_Number((BigDecimal)null);
|
||||
para.setP_Number_To((BigDecimal)null);
|
||||
para.setP_String(null);
|
||||
para.setP_String_To(null);
|
||||
|
||||
// Date
|
||||
if (result instanceof Timestamp || result2 instanceof Timestamp) {
|
||||
if (result instanceof Timestamp)
|
||||
para.setP_Date((Timestamp) result);
|
||||
if (editor2 != null && result2 != null && result2 instanceof Timestamp)
|
||||
para.setP_Date_To((Timestamp) result2);
|
||||
}
|
||||
// Integer
|
||||
else if (result instanceof Integer || result2 instanceof Integer) {
|
||||
if (result != null && result instanceof Integer) {
|
||||
Integer ii = (Integer) result;
|
||||
para.setP_Number(ii.intValue());
|
||||
}
|
||||
if (editor2 != null && result2 != null && result2 instanceof Integer) {
|
||||
Integer ii = (Integer) result2;
|
||||
para.setP_Number_To(ii.intValue());
|
||||
}
|
||||
}
|
||||
// BigDecimal
|
||||
else if (result instanceof BigDecimal
|
||||
|| result2 instanceof BigDecimal) {
|
||||
if (result instanceof BigDecimal)
|
||||
para.setP_Number((BigDecimal) result);
|
||||
if (editor2 != null && result2 != null && result2 instanceof BigDecimal)
|
||||
para.setP_Number_To((BigDecimal) result2);
|
||||
}
|
||||
// Boolean
|
||||
else if (result instanceof Boolean) {
|
||||
Boolean bb = (Boolean) result;
|
||||
String value = bb.booleanValue() ? "Y" : "N";
|
||||
para.setP_String(value);
|
||||
// to does not make sense
|
||||
}
|
||||
// String
|
||||
else {
|
||||
if (result != null)
|
||||
para.setP_String(result.toString());
|
||||
if (editor2 != null && result2 != null)
|
||||
para.setP_String_To(result2.toString());
|
||||
}
|
||||
|
||||
// Info
|
||||
para.setInfo(editor.getDisplay());
|
||||
if (editor2 != null)
|
||||
para.setInfo_To(editor2.getDisplay());
|
||||
//
|
||||
paras.add(para);
|
||||
} // for every parameter
|
||||
|
||||
return paras.toArray(new MPInstancePara[0]);
|
||||
} // saveParameters
|
||||
|
||||
|
||||
/**
|
||||
* Editor Listener
|
||||
*
|
||||
|
|
|
@ -0,0 +1,100 @@
|
|||
/******************************************************************************
|
||||
* Copyright (C) 2013 Trek Global *
|
||||
* Product: iDempiere ERP & CRM Smart Business Solution *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
*****************************************************************************/
|
||||
|
||||
package org.adempiere.webui.apps.form;
|
||||
|
||||
import org.adempiere.webui.panel.ADForm;
|
||||
import org.adempiere.webui.panel.IFormController;
|
||||
import org.adempiere.webui.panel.WProcessParameterForm;
|
||||
import org.compiere.model.MPInstancePara;
|
||||
import org.compiere.model.MProcess;
|
||||
import org.compiere.model.MProcessPara;
|
||||
import org.compiere.model.MScheduler;
|
||||
import org.compiere.model.MSchedulerPara;
|
||||
import org.compiere.util.DisplayType;
|
||||
import org.compiere.util.Env;
|
||||
|
||||
/**
|
||||
* @author hengsin
|
||||
*
|
||||
*/
|
||||
public class WProcessParameter implements IFormController {
|
||||
|
||||
private WProcessParameterForm parameterForm = null;
|
||||
|
||||
/**
|
||||
* default constructor
|
||||
*/
|
||||
public WProcessParameter() {
|
||||
parameterForm = new WProcessParameterForm(this);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.adempiere.webui.panel.IFormController#getForm()
|
||||
*/
|
||||
@Override
|
||||
public ADForm getForm() {
|
||||
return parameterForm;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save parameters to AD_Scheduler_Para
|
||||
* @param paras
|
||||
*/
|
||||
public void saveParameters(MPInstancePara[] paras) {
|
||||
MScheduler scheduler = new MScheduler(Env.getCtx(), parameterForm.getProcessInfo().getRecord_ID(), null);
|
||||
int AD_Process_ID = scheduler.getAD_Process_ID();
|
||||
if (AD_Process_ID > 0 && paras.length > 0) {
|
||||
MProcess process = MProcess.get(Env.getCtx(), AD_Process_ID);
|
||||
MProcessPara[] processParameters = process.getParameters();
|
||||
MSchedulerPara[] schedulerParas = scheduler.getParameters(true);
|
||||
for(MSchedulerPara para : schedulerParas) {
|
||||
para.deleteEx(true);
|
||||
}
|
||||
|
||||
for(MPInstancePara para : paras) {
|
||||
MSchedulerPara schedulerPara = new MSchedulerPara(Env.getCtx(), 0, null);
|
||||
schedulerPara.setAD_Scheduler_ID(scheduler.getAD_Scheduler_ID());
|
||||
for(MProcessPara processPara : processParameters) {
|
||||
if (processPara.getColumnName().equals(para.getParameterName())) {
|
||||
schedulerPara.setAD_Process_Para_ID(processPara.getAD_Process_Para_ID());
|
||||
if (DisplayType.isNumeric(processPara.getAD_Reference_ID())) {
|
||||
if (para.getP_Number() != null)
|
||||
schedulerPara.setParameterDefault(para.getP_Number().toString());
|
||||
if (para.getP_Number_To() != null)
|
||||
schedulerPara.setParameterToDefault(para.getP_Number_To().toString());
|
||||
} else if (DisplayType.isID(processPara.getAD_Reference_ID())) {
|
||||
if (para.getP_Number() != null)
|
||||
schedulerPara.setParameterDefault(Integer.toString(para.getP_Number().intValue()));
|
||||
if (para.getP_Number_To() != null)
|
||||
schedulerPara.setParameterToDefault(Integer.toString(para.getP_Number_To().intValue()));
|
||||
} else if (DisplayType.isDate(processPara.getAD_Reference_ID())) {
|
||||
if (para.getP_Date() != null)
|
||||
schedulerPara.setParameterDefault(para.getP_Date().toString());
|
||||
if (para.getP_Date_To() != null)
|
||||
schedulerPara.setParameterToDefault(para.getP_Date_To().toString());
|
||||
} else {
|
||||
schedulerPara.setParameterDefault(para.getP_String());
|
||||
if (para.getP_String_To() != null)
|
||||
schedulerPara.setParameterToDefault(para.getP_String_To());
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
schedulerPara.saveEx();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,236 @@
|
|||
/******************************************************************************
|
||||
* Copyright (C) 2013 Trek Global *
|
||||
* Product: iDempiere ERP & CRM Smart Business Solution *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
*****************************************************************************/
|
||||
|
||||
package org.adempiere.webui.panel;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.adempiere.webui.apps.ProcessParameterPanel;
|
||||
import org.adempiere.webui.apps.form.WProcessParameter;
|
||||
import org.adempiere.webui.component.Button;
|
||||
import org.adempiere.webui.component.ConfirmPanel;
|
||||
import org.adempiere.webui.component.Panel;
|
||||
import org.adempiere.webui.component.VerticalBox;
|
||||
import org.adempiere.webui.factory.ButtonFactory;
|
||||
import org.compiere.model.MPInstancePara;
|
||||
import org.compiere.model.MScheduler;
|
||||
import org.compiere.process.ProcessInfo;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.Env;
|
||||
import org.zkoss.zk.ui.Component;
|
||||
import org.zkoss.zk.ui.event.Event;
|
||||
import org.zkoss.zk.ui.event.Events;
|
||||
import org.zkoss.zul.Div;
|
||||
import org.zkoss.zul.Hbox;
|
||||
import org.zkoss.zul.Html;
|
||||
import org.zkoss.zul.Vlayout;
|
||||
|
||||
public class WProcessParameterForm extends ADForm
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -2533099650671242190L;
|
||||
|
||||
private WProcessParameter pp;
|
||||
|
||||
private VerticalBox dialogBody;
|
||||
|
||||
private Html message;
|
||||
|
||||
private Panel centerPanel;
|
||||
|
||||
private ProcessInfo processInfo;
|
||||
|
||||
private String m_Name;
|
||||
|
||||
private StringBuffer m_messageText = new StringBuffer();
|
||||
|
||||
private ProcessParameterPanel parameterPanel;
|
||||
|
||||
private final static CLogger log = CLogger.getCLogger(WProcessParameterForm.class);
|
||||
|
||||
public WProcessParameterForm(WProcessParameter wpp) {
|
||||
pp = wpp;
|
||||
initComponents();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mode getWindowMode() {
|
||||
return Mode.HIGHLIGHTED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setVisible(boolean visible) {
|
||||
boolean ok = super.setVisible(visible);
|
||||
if (visible && getProcessInfo() != null && parameterPanel == null)
|
||||
initForm();
|
||||
return ok;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEvent(Event event) throws Exception {
|
||||
Component component = event.getTarget();
|
||||
if (component instanceof Button) {
|
||||
Button element = (Button)component;
|
||||
if ("Ok".equalsIgnoreCase(element.getId())) {
|
||||
onOK();
|
||||
} else if ("Cancel".equalsIgnoreCase(element.getId())) {
|
||||
onCancel();
|
||||
}
|
||||
} else {
|
||||
super.onEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
private void onCancel() {
|
||||
this.dispose();
|
||||
}
|
||||
|
||||
private void onOK() {
|
||||
MPInstancePara[] paras = parameterPanel.getParameters();
|
||||
pp.saveParameters(paras);
|
||||
this.dispose();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initForm() {
|
||||
if (getProcessInfo() != null) {
|
||||
MScheduler scheduler = new MScheduler(Env.getCtx(), getProcessInfo().getRecord_ID(), null);
|
||||
int AD_Process_ID = scheduler.getAD_Process_ID();
|
||||
if (AD_Process_ID > 0) {
|
||||
processInfo = new ProcessInfo("", AD_Process_ID);
|
||||
init();
|
||||
}
|
||||
}
|
||||
this.setSizable(true);
|
||||
this.setClosable(true);
|
||||
this.setWidth("500px");
|
||||
this.setVflex("min");
|
||||
}
|
||||
|
||||
private void initComponents() {
|
||||
this.setBorder("normal");
|
||||
dialogBody = new VerticalBox();
|
||||
dialogBody.setHflex("1");
|
||||
Vlayout dialogContent = new Vlayout();
|
||||
dialogContent.setHflex("1");
|
||||
dialogContent.setVflex("1");
|
||||
dialogContent.setSclass("dialog-content");
|
||||
dialogBody.appendChild(dialogContent);
|
||||
Div div = new Div();
|
||||
div.setId("message");
|
||||
message = new Html();
|
||||
div.appendChild(message);
|
||||
div.setStyle("max-height: 150pt; overflow: auto;");
|
||||
dialogContent.appendChild(div);
|
||||
centerPanel = new Panel();
|
||||
dialogContent.appendChild(centerPanel);
|
||||
Hbox hbox = new Hbox();
|
||||
hbox.setWidth("100%");
|
||||
hbox.setSclass("dialog-footer");
|
||||
Button btn = ButtonFactory.createNamedButton(ConfirmPanel.A_OK);
|
||||
btn.setId("Ok");
|
||||
btn.addEventListener(Events.ON_CLICK, this);
|
||||
hbox.appendChild(btn);
|
||||
|
||||
btn = ButtonFactory.createNamedButton(ConfirmPanel.A_CANCEL);
|
||||
btn.setId("Cancel");
|
||||
btn.addEventListener(Events.ON_CLICK, this);
|
||||
|
||||
hbox.appendChild(btn);
|
||||
hbox.setPack("end");
|
||||
dialogBody.appendChild(hbox);
|
||||
this.appendChild(dialogBody);
|
||||
this.setSclass("popup-dialog");
|
||||
}
|
||||
|
||||
/**
|
||||
* Dynamic Init
|
||||
* @return true, if there is something to process (start from menu)
|
||||
*/
|
||||
private boolean init()
|
||||
{
|
||||
//
|
||||
boolean trl = !Env.isBaseLanguage(Env.getCtx(), "AD_Process");
|
||||
String sql = "SELECT Name, Description, Help, IsReport, ShowHelp "
|
||||
+ "FROM AD_Process "
|
||||
+ "WHERE AD_Process_ID=?";
|
||||
if (trl)
|
||||
sql = "SELECT t.Name, t.Description, t.Help, p.IsReport, p.ShowHelp "
|
||||
+ "FROM AD_Process p, AD_Process_Trl t "
|
||||
+ "WHERE p.AD_Process_ID=t.AD_Process_ID"
|
||||
+ " AND p.AD_Process_ID=? AND t.AD_Language=?";
|
||||
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
try
|
||||
{
|
||||
pstmt = DB.prepareStatement(sql, null);
|
||||
pstmt.setInt(1, processInfo.getAD_Process_ID());
|
||||
if (trl)
|
||||
pstmt.setString(2, Env.getAD_Language(Env.getCtx()));
|
||||
rs = pstmt.executeQuery();
|
||||
if (rs.next())
|
||||
{
|
||||
m_Name = rs.getString(1);
|
||||
//
|
||||
m_messageText.append("<b>");
|
||||
String s = rs.getString(2); // Description
|
||||
if (rs.wasNull())
|
||||
;
|
||||
else
|
||||
m_messageText.append(s);
|
||||
m_messageText.append("</b>");
|
||||
|
||||
s = rs.getString(3); // Help
|
||||
if (!rs.wasNull())
|
||||
m_messageText.append("<p>").append(s).append("</p>");
|
||||
}
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
log.log(Level.SEVERE, sql, e);
|
||||
return false;
|
||||
}
|
||||
finally
|
||||
{
|
||||
DB.close(rs, pstmt);
|
||||
}
|
||||
|
||||
if (m_Name == null)
|
||||
return false;
|
||||
//
|
||||
this.setTitle(m_Name);
|
||||
message.setContent(m_messageText.toString());
|
||||
|
||||
// Move from APanel.actionButton
|
||||
processInfo.setAD_User_ID (Env.getAD_User_ID(Env.getCtx()));
|
||||
processInfo.setAD_Client_ID(Env.getAD_Client_ID(Env.getCtx()));
|
||||
processInfo.setTitle(m_Name);
|
||||
parameterPanel = new ProcessParameterPanel(m_WindowNo, processInfo);
|
||||
centerPanel.getChildren().clear();
|
||||
if ( parameterPanel.init() ) {
|
||||
centerPanel.appendChild(parameterPanel);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
} // init
|
||||
}
|
Loading…
Reference in New Issue