From 10ce8aa22e2c86eb662cc64012ed70bd4728499f Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Wed, 23 Jul 2014 11:10:24 -0500 Subject: [PATCH] IDEMPIERE-2073 AD_Val_Rule_ID is missing from AD_UserDef_Field --- .../oracle/201407172028_IDEMPIERE-2073.sql | 0 .../oracle/201407231109_IDEMPIERE-2073.sql | 11 ++ .../201407172028_IDEMPIERE-2073.sql | 0 .../201407231109_IDEMPIERE-2073.sql | 8 ++ .../src/org/compiere/model/GridFieldVO.java | 3 +- .../src/org/compiere/model/MValRule.java | 103 ++++++++++++++++++ 6 files changed, 123 insertions(+), 2 deletions(-) rename migration/{i2.0 => i2.0z}/oracle/201407172028_IDEMPIERE-2073.sql (100%) create mode 100644 migration/i2.0z/oracle/201407231109_IDEMPIERE-2073.sql rename migration/{i2.0 => i2.0z}/postgresql/201407172028_IDEMPIERE-2073.sql (100%) create mode 100644 migration/i2.0z/postgresql/201407231109_IDEMPIERE-2073.sql create mode 100644 org.adempiere.base/src/org/compiere/model/MValRule.java diff --git a/migration/i2.0/oracle/201407172028_IDEMPIERE-2073.sql b/migration/i2.0z/oracle/201407172028_IDEMPIERE-2073.sql similarity index 100% rename from migration/i2.0/oracle/201407172028_IDEMPIERE-2073.sql rename to migration/i2.0z/oracle/201407172028_IDEMPIERE-2073.sql diff --git a/migration/i2.0z/oracle/201407231109_IDEMPIERE-2073.sql b/migration/i2.0z/oracle/201407231109_IDEMPIERE-2073.sql new file mode 100644 index 0000000000..8888bd21f7 --- /dev/null +++ b/migration/i2.0z/oracle/201407231109_IDEMPIERE-2073.sql @@ -0,0 +1,11 @@ +SET SQLBLANKLINES ON +SET DEFINE OFF + +-- Jul 23, 2014 11:07:39 AM COT +-- IDEMPIERE-2073 AD_Val_Rule_ID is missing from AD_UserDef_Field +UPDATE AD_Field SET IsAdvancedField='Y',Updated=TO_DATE('2014-07-23 11:07:39','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=203266 +; + +SELECT register_migration_script('201407231109_IDEMPIERE-2073.sql') FROM dual +; + diff --git a/migration/i2.0/postgresql/201407172028_IDEMPIERE-2073.sql b/migration/i2.0z/postgresql/201407172028_IDEMPIERE-2073.sql similarity index 100% rename from migration/i2.0/postgresql/201407172028_IDEMPIERE-2073.sql rename to migration/i2.0z/postgresql/201407172028_IDEMPIERE-2073.sql diff --git a/migration/i2.0z/postgresql/201407231109_IDEMPIERE-2073.sql b/migration/i2.0z/postgresql/201407231109_IDEMPIERE-2073.sql new file mode 100644 index 0000000000..cdc0cc622f --- /dev/null +++ b/migration/i2.0z/postgresql/201407231109_IDEMPIERE-2073.sql @@ -0,0 +1,8 @@ +-- Jul 23, 2014 11:07:39 AM COT +-- IDEMPIERE-2073 AD_Val_Rule_ID is missing from AD_UserDef_Field +UPDATE AD_Field SET IsAdvancedField='Y',Updated=TO_TIMESTAMP('2014-07-23 11:07:39','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=203266 +; + +SELECT register_migration_script('201407231109_IDEMPIERE-2073.sql') FROM dual +; + diff --git a/org.adempiere.base/src/org/compiere/model/GridFieldVO.java b/org.adempiere.base/src/org/compiere/model/GridFieldVO.java index 6220f6123e..d051465393 100644 --- a/org.adempiere.base/src/org/compiere/model/GridFieldVO.java +++ b/org.adempiere.base/src/org/compiere/model/GridFieldVO.java @@ -28,7 +28,6 @@ import java.util.Properties; import java.util.logging.Level; import org.compiere.util.CLogger; -import org.compiere.util.DB; import org.compiere.util.DisplayType; import org.compiere.util.Env; @@ -300,7 +299,7 @@ public class GridFieldVO implements Serializable if (userDef.getSeqNo() > 0) vo.SeqNo = userDef.getSeqNo(); if (userDef.getAD_Val_Rule_ID() > 0) - vo.ValidationCode = DB.getSQLValueStringEx(null, "SELECT Code FROM AD_Val_Rule WHERE AD_Val_Rule_ID = ?", userDef.getAD_Val_Rule_ID()); + vo.ValidationCode = MValRule.get(ctx, userDef.getAD_Val_Rule_ID()).getCode(); } } // diff --git a/org.adempiere.base/src/org/compiere/model/MValRule.java b/org.adempiere.base/src/org/compiere/model/MValRule.java new file mode 100644 index 0000000000..ef38c0bc07 --- /dev/null +++ b/org.adempiere.base/src/org/compiere/model/MValRule.java @@ -0,0 +1,103 @@ +/********************************************************************** +* This file is part of iDempiere ERP Open Source * +* http://www.idempiere.org * +* * +* Copyright (C) Contributors * +* * +* This program is free software; you can redistribute it and/or * +* modify it under the terms of the GNU General Public License * +* as published by the Free Software Foundation; either version 2 * +* of the License, or (at your option) any later version. * +* * +* 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., 51 Franklin Street, Fifth Floor, Boston, * +* MA 02110-1301, USA. * +* * +* Contributors: * +* - Carlos Ruiz - globalqss * +**********************************************************************/ +package org.compiere.model; + +import java.sql.ResultSet; +import java.util.Properties; + +import org.compiere.util.CCache; +import org.compiere.util.CLogger; + +/** + * Persistent Validation Rule Model + * @author Carlos Ruiz + * @version $Id: MValRule.java + */ +public class MValRule extends X_AD_Val_Rule +{ + /** + * + */ + private static final long serialVersionUID = -8482599477870030638L; + + /** + * Get Rule from Cache + * @param ctx context + * @param AD_Val_Rule_ID id + * @return MValRule + */ + public static MValRule get (Properties ctx, int AD_Val_Rule_ID) + { + Integer key = new Integer (AD_Val_Rule_ID); + MValRule retValue = (MValRule) s_cache.get (key); + if (retValue != null) + return retValue; + retValue = new MValRule (ctx, AD_Val_Rule_ID, null); + if (retValue.get_ID () != 0) + s_cache.put (key, retValue); + return retValue; + } // get + + /** Cache */ + private static CCache s_cache = new CCache(Table_Name, 20); + + /** Static Logger */ + @SuppressWarnings("unused") + private static CLogger s_log = CLogger.getCLogger (MValRule.class); + + /************************************************************************** + * Standard Constructor + * @param ctx context + * @param AD_Val_Rule_ID id + * @param trxName transaction + */ + public MValRule (Properties ctx, int AD_Val_Rule_ID, String trxName) + { + super (ctx, AD_Val_Rule_ID, trxName); + } // MValRule + + /** + * Load Constructor + * @param ctx context + * @param rs result set + * @param trxName transaction + */ + public MValRule (Properties ctx, ResultSet rs, String trxName) + { + super(ctx, rs, trxName); + } // MValRule + + /** + * String Representation + * @return info + */ + public String toString() + { + StringBuilder sb = new StringBuilder ("MValRule["); + sb.append (get_ID()).append ("-").append (getName()).append ("]"); + return sb.toString (); + } // toString + +} // MValRule \ No newline at end of file