IDEMPIERE-1845 Allow Scheduler to use default logic based on SQL
This commit is contained in:
parent
991a199423
commit
5aa1701d01
|
@ -0,0 +1,14 @@
|
||||||
|
SET SQLBLANKLINES ON
|
||||||
|
SET DEFINE OFF
|
||||||
|
|
||||||
|
-- Mar 21, 2014 10:20:57 PM CET
|
||||||
|
-- IDEMPIERE-1845
|
||||||
|
UPDATE AD_Field SET IsAdvancedField='Y',Updated=TO_DATE('2014-03-21 22:20:57','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=9448
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Mar 21, 2014 10:20:59 PM CET
|
||||||
|
UPDATE AD_Field SET IsAdvancedField='Y',Updated=TO_DATE('2014-03-21 22:20:59','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=202528
|
||||||
|
;
|
||||||
|
|
||||||
|
SELECT register_migration_script('201303212222_IDEMPIERE-1845.sql') FROM dual
|
||||||
|
;
|
|
@ -0,0 +1,11 @@
|
||||||
|
-- Mar 21, 2014 10:20:57 PM CET
|
||||||
|
-- IDEMPIERE-1845
|
||||||
|
UPDATE AD_Field SET IsAdvancedField='Y',Updated=TO_TIMESTAMP('2014-03-21 22:20:57','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=9448
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Mar 21, 2014 10:20:59 PM CET
|
||||||
|
UPDATE AD_Field SET IsAdvancedField='Y',Updated=TO_TIMESTAMP('2014-03-21 22:20:59','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=202528
|
||||||
|
;
|
||||||
|
|
||||||
|
SELECT register_migration_script('201303212222_IDEMPIERE-1845.sql') FROM dual
|
||||||
|
;
|
|
@ -18,6 +18,9 @@ package org.compiere.server;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.sql.PreparedStatement;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
@ -40,10 +43,12 @@ import org.compiere.print.ReportEngine;
|
||||||
import org.compiere.process.ProcessInfo;
|
import org.compiere.process.ProcessInfo;
|
||||||
import org.compiere.process.ProcessInfoUtil;
|
import org.compiere.process.ProcessInfoUtil;
|
||||||
import org.compiere.process.ServerProcessCtl;
|
import org.compiere.process.ServerProcessCtl;
|
||||||
|
import org.compiere.util.DB;
|
||||||
import org.compiere.util.DisplayType;
|
import org.compiere.util.DisplayType;
|
||||||
import org.compiere.util.Env;
|
import org.compiere.util.Env;
|
||||||
import org.compiere.util.TimeUtil;
|
import org.compiere.util.TimeUtil;
|
||||||
import org.compiere.util.Trx;
|
import org.compiere.util.Trx;
|
||||||
|
import org.compiere.util.Util;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -402,6 +407,39 @@ public class Scheduler extends AdempiereServer
|
||||||
if (variable == null
|
if (variable == null
|
||||||
|| (variable != null && variable.length() == 0))
|
|| (variable != null && variable.length() == 0))
|
||||||
value = null;
|
value = null;
|
||||||
|
else if (variable.startsWith("@SQL=")) {
|
||||||
|
String defStr = "";
|
||||||
|
String sql = variable.substring(5); // w/o tag
|
||||||
|
//sql = Env.parseContext(m_vo.ctx, m_vo.WindowNo, sql, false, true); // replace variables
|
||||||
|
//hengsin, capture unparseable error to avoid subsequent sql exception
|
||||||
|
sql = Env.parseContext(m_schedulerctx, 0, sql, false, false); // replace variables
|
||||||
|
if (sql.equals(""))
|
||||||
|
log.log(Level.WARNING, "(" + sPara.getColumnName() + ") - Default SQL variable parse failed: " + variable);
|
||||||
|
else {
|
||||||
|
PreparedStatement stmt = null;
|
||||||
|
ResultSet rs = null;
|
||||||
|
try {
|
||||||
|
stmt = DB.prepareStatement(sql, null);
|
||||||
|
rs = stmt.executeQuery();
|
||||||
|
if (rs.next())
|
||||||
|
defStr = rs.getString(1);
|
||||||
|
else {
|
||||||
|
if (log.isLoggable(Level.INFO))
|
||||||
|
log.log(Level.INFO, "(" + sPara.getColumnName() + ") - no Result: " + sql);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (SQLException e) {
|
||||||
|
log.log(Level.WARNING, "(" + sPara.getColumnName() + ") " + sql, e);
|
||||||
|
}
|
||||||
|
finally{
|
||||||
|
DB.close(rs, stmt);
|
||||||
|
rs = null;
|
||||||
|
stmt = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!Util.isEmpty(defStr))
|
||||||
|
value = defStr;
|
||||||
|
} // SQL Statement
|
||||||
else if ( variable.indexOf('@') != -1
|
else if ( variable.indexOf('@') != -1
|
||||||
&& variable.indexOf('@') != variable.lastIndexOf('@')) // we have a variable / BF [1926032]
|
&& variable.indexOf('@') != variable.lastIndexOf('@')) // we have a variable / BF [1926032]
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue