From 0becee9edb13d1f5e17527432717fa0ccae0409e Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Fri, 11 Jul 2014 19:57:23 -0500 Subject: [PATCH] IDEMPIERE-1968:valid check box in info window can manual editable / peer review --- .../oracle/201406031604_IDEMPIERE-1968.sql | 14 +---- ...=> 201406031605_IDEMPIERE-1968-Access.sql} | 9 +-- .../201406031604_IDEMPIERE-1968.sql | 13 +--- ...=> 201406031605_IDEMPIERE-1968-Access.sql} | 11 ++-- .../compiere/process/InfoWindowValidate.java | 60 +------------------ .../src/org/compiere/model/MInfoColumn.java | 27 ++++++--- 6 files changed, 30 insertions(+), 104 deletions(-) rename migration/i2.0z/oracle/{201406031604_IDEMPIERE-1968-Access.sql => 201406031605_IDEMPIERE-1968-Access.sql} (96%) rename migration/i2.0z/postgresql/{201406031604_IDEMPIERE-1968-Access.sql => 201406031605_IDEMPIERE-1968-Access.sql} (95%) diff --git a/migration/i2.0z/oracle/201406031604_IDEMPIERE-1968.sql b/migration/i2.0z/oracle/201406031604_IDEMPIERE-1968.sql index 902b39b2b0..cf046995d9 100644 --- a/migration/i2.0z/oracle/201406031604_IDEMPIERE-1968.sql +++ b/migration/i2.0z/oracle/201406031604_IDEMPIERE-1968.sql @@ -2,21 +2,9 @@ SET SQLBLANKLINES ON SET DEFINE OFF -- Jun 3, 2014 4:22:36 PM ICT --- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator +-- IDEMPIERE-1968 valid check box in info window can manual editable UPDATE AD_Field SET IsReadOnly='Y',Updated=TO_DATE('2014-06-03 16:22:36','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=201639 ; --- Jun 3, 2014 11:42:11 PM ICT --- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator -UPDATE AD_Column SET AD_Process_ID=NULL,Updated=TO_DATE('2014-06-03 23:42:11','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=15759 -; - --- Jun 3, 2014 11:44:39 PM ICT -UPDATE AD_Column SET IsToolbarButton='N', AD_Reference_ID=10,Updated=TO_DATE('2014-06-03 23:44:39','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=15759 -; - --- Jun 3, 2014 11:47:13 PM ICT -UPDATE AD_Field SET IsDisplayed='N',Updated=TO_DATE('2014-06-03 23:47:13','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=13580 -; SELECT register_migration_script('201406031604_IDEMPIERE-1968.sql') FROM dual ; diff --git a/migration/i2.0z/oracle/201406031604_IDEMPIERE-1968-Access.sql b/migration/i2.0z/oracle/201406031605_IDEMPIERE-1968-Access.sql similarity index 96% rename from migration/i2.0z/oracle/201406031604_IDEMPIERE-1968-Access.sql rename to migration/i2.0z/oracle/201406031605_IDEMPIERE-1968-Access.sql index acbb110e87..25b1e80d92 100644 --- a/migration/i2.0z/oracle/201406031604_IDEMPIERE-1968-Access.sql +++ b/migration/i2.0z/oracle/201406031605_IDEMPIERE-1968-Access.sql @@ -2,14 +2,10 @@ SET SQLBLANKLINES ON SET DEFINE OFF -- Jun 3, 2014 5:05:09 PM ICT --- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator +-- IDEMPIERE-1968 valid check box in info window can manual editable UPDATE AD_Column SET IsUpdateable='N', FKConstraintType='C',Updated=TO_DATE('2014-06-03 17:05:09','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=208377 ; --- Jun 3, 2014 5:05:16 PM ICT -ALTER TABLE AD_InfoWindow_Access MODIFY AD_InfoWindow_ID NUMBER(10) -; - -- Jun 3, 2014 5:05:16 PM ICT ALTER TABLE AD_InfoWindow_Access DROP CONSTRAINT adinfowindow_adinfowindowacces ; @@ -62,7 +58,6 @@ UPDATE AD_Field SET DisplayLogic=NULL, DefaultValue='@AD_InfoWindow_ID@',Updated ; -- Jun 3, 2014 5:21:06 PM ICT --- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator UPDATE AD_Tab SET TabLevel=1,Updated=TO_DATE('2014-06-03 17:21:06','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Tab_ID=200144 ; @@ -74,5 +69,5 @@ UPDATE AD_Field SET IsReadOnly='Y',Updated=TO_DATE('2014-06-03 17:25:34','YYYY-M UPDATE AD_Field SET IsReadOnly='Y',Updated=TO_DATE('2014-06-03 17:26:17','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=203053 ; -SELECT register_migration_script('201406031604_IDEMPIERE-1968-Access.sql') FROM dual +SELECT register_migration_script('201406031605_IDEMPIERE-1968-Access.sql') FROM dual ; diff --git a/migration/i2.0z/postgresql/201406031604_IDEMPIERE-1968.sql b/migration/i2.0z/postgresql/201406031604_IDEMPIERE-1968.sql index 63addd80f2..4f7ece05a0 100644 --- a/migration/i2.0z/postgresql/201406031604_IDEMPIERE-1968.sql +++ b/migration/i2.0z/postgresql/201406031604_IDEMPIERE-1968.sql @@ -1,18 +1,7 @@ -- Jun 3, 2014 4:22:36 PM ICT --- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator +-- IDEMPIERE-1968 valid check box in info window can manual editable UPDATE AD_Field SET IsReadOnly='Y',Updated=TO_TIMESTAMP('2014-06-03 16:22:36','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=201639 ; --- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator -UPDATE AD_Column SET AD_Process_ID=NULL,Updated=TO_TIMESTAMP('2014-06-03 23:42:11','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=15759 -; - --- Jun 3, 2014 11:44:39 PM ICT -UPDATE AD_Column SET IsToolbarButton='N', AD_Reference_ID=10,Updated=TO_TIMESTAMP('2014-06-03 23:44:39','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=15759 -; - --- Jun 3, 2014 11:47:13 PM ICT -UPDATE AD_Field SET IsDisplayed='N',Updated=TO_TIMESTAMP('2014-06-03 23:47:13','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=13580 -; SELECT register_migration_script('201406031604_IDEMPIERE-1968.sql') FROM dual ; diff --git a/migration/i2.0z/postgresql/201406031604_IDEMPIERE-1968-Access.sql b/migration/i2.0z/postgresql/201406031605_IDEMPIERE-1968-Access.sql similarity index 95% rename from migration/i2.0z/postgresql/201406031604_IDEMPIERE-1968-Access.sql rename to migration/i2.0z/postgresql/201406031605_IDEMPIERE-1968-Access.sql index c7ae28e960..e62a009052 100644 --- a/migration/i2.0z/postgresql/201406031604_IDEMPIERE-1968-Access.sql +++ b/migration/i2.0z/postgresql/201406031605_IDEMPIERE-1968-Access.sql @@ -1,12 +1,8 @@ -- Jun 3, 2014 5:05:09 PM ICT --- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator +-- IDEMPIERE-1968 valid check box in info window can manual editable UPDATE AD_Column SET IsUpdateable='N', FKConstraintType='C',Updated=TO_TIMESTAMP('2014-06-03 17:05:09','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=208377 ; --- Jun 3, 2014 5:05:16 PM ICT -INSERT INTO t_alter_column values('ad_infowindow_access','AD_InfoWindow_ID','NUMERIC(10)',null,null) -; - -- Jun 3, 2014 5:05:16 PM ICT ALTER TABLE AD_InfoWindow_Access DROP CONSTRAINT adinfowindow_adinfowindowacces ; @@ -57,8 +53,8 @@ UPDATE AD_Field SET IsReadOnly='Y', DisplayLogic='@AD_InfoWindow_ID@',Updated=TO -- Jun 3, 2014 5:17:05 PM ICT UPDATE AD_Field SET DisplayLogic=NULL, DefaultValue='@AD_InfoWindow_ID@',Updated=TO_TIMESTAMP('2014-06-03 17:17:05','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=203055 ; + -- Jun 3, 2014 5:21:06 PM ICT --- I forgot to set the DICTIONARY_ID_COMMENTS System Configurator UPDATE AD_Tab SET TabLevel=1,Updated=TO_TIMESTAMP('2014-06-03 17:21:06','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Tab_ID=200144 ; @@ -69,5 +65,6 @@ UPDATE AD_Field SET IsReadOnly='Y',Updated=TO_TIMESTAMP('2014-06-03 17:25:34','Y -- Jun 3, 2014 5:26:17 PM ICT UPDATE AD_Field SET IsReadOnly='Y',Updated=TO_TIMESTAMP('2014-06-03 17:26:17','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=203053 ; -SELECT register_migration_script('201406031604_IDEMPIERE-1968-Access.sql') FROM dual + +SELECT register_migration_script('201406031605_IDEMPIERE-1968-Access.sql') FROM dual ; diff --git a/org.adempiere.base.process/src/org/compiere/process/InfoWindowValidate.java b/org.adempiere.base.process/src/org/compiere/process/InfoWindowValidate.java index a0d17642b7..de4310422e 100644 --- a/org.adempiere.base.process/src/org/compiere/process/InfoWindowValidate.java +++ b/org.adempiere.base.process/src/org/compiere/process/InfoWindowValidate.java @@ -16,11 +16,7 @@ *****************************************************************************/ package org.compiere.process; -import java.sql.PreparedStatement; - -import org.compiere.model.MInfoColumn; import org.compiere.model.MInfoWindow; -import org.compiere.util.DB; /** * Validate Info Window SQL @@ -50,60 +46,10 @@ public class InfoWindowValidate extends SvrProcess throws Exception { MInfoWindow infoWindow = new MInfoWindow(getCtx(), p_AD_InfoWindow_ID, (String)null); - infoWindow.setIsValid(false); + infoWindow.validate(); infoWindow.saveEx(); - - StringBuilder builder = new StringBuilder("SELECT "); - if (infoWindow.isDistinct()) - builder.append("DISTINCT "); - - MInfoColumn[] infoColumns = infoWindow.getInfoColumns(); - if (infoColumns.length == 0) - throw new Exception("NoColumns"); - - for (int columnIndex = 0; columnIndex < infoColumns.length; columnIndex++) { - if (columnIndex > 0) - { - builder.append(", "); - } - builder.append(infoColumns[columnIndex].getSelectClause()); - } - - builder.append( " FROM ").append(infoWindow.getFromClause()); - if (infoWindow.getWhereClause() != null && infoWindow.getWhereClause().trim().length() > 0) { - builder.append(" WHERE ").append(infoWindow.getWhereClause()); - } - - if (infoWindow.getOtherClause() != null && infoWindow.getOtherClause().trim().length() > 0) { - builder.append(" ").append(infoWindow.getOtherClause()); - } - - if (infoWindow.getOrderByClause() != null && infoWindow.getOrderByClause().trim().length() > 0) { - builder.append(" ORDER BY ").append(infoWindow.getOrderByClause()); - } - - while(builder.indexOf("@") >= 0) { - int start = builder.indexOf("@"); - int end = builder.indexOf("@", start+1); - if (start >=0 && end > start) { - builder.replace(start, end+1, "0"); - } else { - break; - } - } - - PreparedStatement pstmt = null; - try { - pstmt = DB.prepareStatement(builder.toString(), get_TrxName()); - pstmt.executeQuery(); - } finally { - DB.close(pstmt); - } - - infoWindow.setIsValid(true); - infoWindow.saveEx(); - - return "Ok"; + + return infoWindow.isValid() ? "@OK@" : "@NotValid@"; } // doIt } // InfoWindowValidate diff --git a/org.adempiere.base/src/org/compiere/model/MInfoColumn.java b/org.adempiere.base/src/org/compiere/model/MInfoColumn.java index d296fbbda7..66e7549ffc 100644 --- a/org.adempiere.base/src/org/compiere/model/MInfoColumn.java +++ b/org.adempiere.base/src/org/compiere/model/MInfoColumn.java @@ -36,7 +36,7 @@ public class MInfoColumn extends X_AD_InfoColumn /** * */ - private static final long serialVersionUID = 4317064257861102601L; + private static final long serialVersionUID = 9198213211937136870L; /** * Stanfard Constructor @@ -60,6 +60,20 @@ public class MInfoColumn extends X_AD_InfoColumn super (ctx, rs, trxName); } // MInfoColumn + /** Parent */ + private MInfoWindow m_parent = null; + + /** + * Get Parent + * @return parent + */ + public MInfoWindow getParent() + { + if (m_parent == null) + m_parent = new MInfoWindow(getCtx(), getAD_InfoWindow_ID(), get_TrxName()); + return m_parent; + } // getParent + /** * check column read access * @param tableInfos @@ -144,11 +158,9 @@ public class MInfoColumn extends X_AD_InfoColumn // call valid of parrent if (isNeedValid){ - MInfoWindow parentInfo = new MInfoWindow (getCtx(), this.getAD_InfoWindow_ID(), get_TrxName()); - parentInfo.validate(); - parentInfo.saveEx(); + getParent().validate(); + getParent().saveEx(get_TrxName()); } - return super.afterSave(newRecord, success); } @@ -160,9 +172,8 @@ public class MInfoColumn extends X_AD_InfoColumn */ @Override protected boolean afterDelete(boolean success) { - MInfoWindow parentInfo = new MInfoWindow (getCtx(), this.getAD_InfoWindow_ID(), get_TrxName()); - parentInfo.validate(); - parentInfo.saveEx(); + getParent().validate(); + getParent().saveEx(get_TrxName()); return super.afterDelete(success); } } // MInfoColumn