details: /erp/devel/pi/rev/ade5b974f0db changeset: 7139:ade5b974f0db user: Adrián Romero <adrianromero <at> openbravo.com> date: Fri Apr 23 17:32:58 2010 +0200 summary: Fixes issue 0012628: When clicking Linked Items in Business Partner window, Accounting Transaction Details show database IDs
diffstat: src-core/src/org/openbravo/data/Parameter.java | 6 ++++-- src-core/src/org/openbravo/data/Sql.java | 6 +++--- src-core/src/org/openbravo/data/Sqlc.java | 21 ++++++++++++++++++--- src-core/src/org/openbravo/data/UtilSql.java | 12 ++++++++++++ src-db/database/sourcedata/AD_COLUMN.xml | 4 ++-- 5 files changed, 39 insertions(+), 10 deletions(-) diffs (183 lines): diff -r cb15f7a33252 -r ade5b974f0db src-core/src/org/openbravo/data/Parameter.java --- a/src-core/src/org/openbravo/data/Parameter.java Fri Apr 23 16:11:53 2010 +0200 +++ b/src-core/src/org/openbravo/data/Parameter.java Fri Apr 23 17:32:58 2010 +0200 @@ -1,6 +1,6 @@ /* ************************************************************************************ - * Copyright (C) 2001-2009 Openbravo S.L.U. + * Copyright (C) 2001-2010 Openbravo S.L.U. * Licensed under the Apache Software License version 2.0 * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software distributed @@ -23,9 +23,10 @@ String strText; String strIgnoreValue; boolean boolOptional = false; + String filter; public Parameter(boolean sequence, String strName, String strDefault, String strInOut, - String strOptional, String strAfter, String strText, String strIgnoreValue) { + String strOptional, String strAfter, String strText, String strIgnoreValue, String filter) { boolSequence = sequence; this.strName = strName; this.strDefault = strDefault; @@ -36,6 +37,7 @@ this.strAfter = strAfter; this.strText = strText; this.strIgnoreValue = strIgnoreValue; + this.filter = filter; } } diff -r cb15f7a33252 -r ade5b974f0db src-core/src/org/openbravo/data/Sql.java --- a/src-core/src/org/openbravo/data/Sql.java Fri Apr 23 16:11:53 2010 +0200 +++ b/src-core/src/org/openbravo/data/Sql.java Fri Apr 23 17:32:58 2010 +0200 @@ -1,6 +1,6 @@ /* ************************************************************************************ - * Copyright (C) 2001-2009 Openbravo S.L.U. + * Copyright (C) 2001-2010 Openbravo S.L.U. * Licensed under the Apache Software License version 2.0 * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software distributed @@ -41,7 +41,7 @@ } public Parameter addParameter(boolean sequence, String strName, String strDefault, - String strInOut, String strOptional, String strAfter, String strText, String strIgnoreValue) { + String strInOut, String strOptional, String strAfter, String strText, String strIgnoreValue, String filter) { if (log4j.isDebugEnabled()) log4j.debug("addParameter sequence: " + sequence + " name: " + strName); if (strOptional != null) @@ -49,7 +49,7 @@ if (log4j.isDebugEnabled()) log4j.debug("previous new Parameter"); Parameter parameterNew = new Parameter(sequence, strName, strDefault, strInOut, strOptional, - strAfter, strText, strIgnoreValue); + strAfter, strText, strIgnoreValue, filter); if (log4j.isDebugEnabled()) log4j.debug("called new Parameter"); for (Enumeration<Parameter> e = vecParameter.elements(); e.hasMoreElements();) { diff -r cb15f7a33252 -r ade5b974f0db src-core/src/org/openbravo/data/Sqlc.java --- a/src-core/src/org/openbravo/data/Sqlc.java Fri Apr 23 16:11:53 2010 +0200 +++ b/src-core/src/org/openbravo/data/Sqlc.java Fri Apr 23 17:32:58 2010 +0200 @@ -1,6 +1,6 @@ /* ************************************************************************************ - * Copyright (C) 2001-2009 Openbravo S.L.U. + * Copyright (C) 2001-2010 Openbravo S.L.U. * Licensed under the Apache Software License version 2.0 * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software distributed @@ -456,6 +456,7 @@ String strAfter = null; String strText = null; String strIgnoreValue = null; + String filter = null; final int size = amap.getLength(); for (int i = 0; i < size; i++) { if (amap.getQName(i).equals("name")) { @@ -472,12 +473,14 @@ strText = amap.getValue(i); } else if (amap.getQName(i).equals("ignoreValue")) { strIgnoreValue = amap.getValue(i); + } else if (amap.getQName(i).equals("filter")) { + filter = amap.getValue(i); } } if (log4j.isDebugEnabled()) log4j.debug("Configuration: call to addParameter "); parameterSql = sql.addParameter(false, strName, strDefault, strInOut, strOptional, strAfter, - strText, strIgnoreValue); + strText, strIgnoreValue, filter); } else if (name.equals("Field")) { FieldAdded field = null; final int size = amap.getLength(); @@ -497,7 +500,7 @@ } } parameterSql = sql - .addParameter(true, sql.strSequenceName, null, null, null, null, null, null); + .addParameter(true, sql.strSequenceName, null, null, null, null, null, null, null); } } @@ -895,6 +898,16 @@ out2.append(" }\n"); } + private void appendFilterSQLParameter(Parameter parameter) { + if (parameter.filter != null && !parameter.filter.equals("")) { + out2.append(" UtilSql.filterSQLParameter(SqlcFilters.get"); + out2.append(parameter.filter); + out2.append(", "); + out2.append(parameter.strName); + out2.append(");\n"); + } + } + private void printSQLBody() throws IOException { // codigo para imprimir trozos de Sql opcionales int posSQL = 0; @@ -919,6 +932,7 @@ out2.append(" strSql = strSql + ((" + parameter.strName + ".equals(\"" + parameter.strName + "\"))?\" " + parameter.strText + " \":\"\");\n"); } else if (parameter.strInOut.equals("argument")) { + appendFilterSQLParameter(parameter); out2.append(" strSql = strSql + ((" + parameter.strName + "==null || " + parameter.strName + ".equals(\"\")"); if (parameter.strIgnoreValue != null) { @@ -927,6 +941,7 @@ } out2.append(")?\"\":\" " + parameter.strText + "\" + " + parameter.strName + ");\n"); } else if (parameter.strInOut.equals("replace")) { + appendFilterSQLParameter(parameter); out2.append(" strSql = strSql + ((" + parameter.strName + "==null || " + parameter.strName + ".equals(\"\")"); if (parameter.strIgnoreValue != null) { diff -r cb15f7a33252 -r ade5b974f0db src-core/src/org/openbravo/data/UtilSql.java --- a/src-core/src/org/openbravo/data/UtilSql.java Fri Apr 23 16:11:53 2010 +0200 +++ b/src-core/src/org/openbravo/data/UtilSql.java Fri Apr 23 17:32:58 2010 +0200 @@ -17,9 +17,21 @@ import java.sql.ResultSet; import java.text.SimpleDateFormat; import java.util.Date; +import javax.servlet.ServletException; +import org.openbravo.base.filter.RequestFilter; public class UtilSql { + public static void filterSQLParameter (String value, String filter) throws ServletException { + if (value != null && !value.equals("")) { + RequestFilter reqfilter = null; + if (!reqfilter.accept(value)) { + // log4j.error("Exception in query: " + strSql + "Exception:"+ ex); + throw new ServletException("@co...@query parameter error" ); + } + } + } + // setValue and getValue method to be used in sqlc public static boolean setValue(PreparedStatement ps, int posicion, int tipo, String strDefault, diff -r cb15f7a33252 -r ade5b974f0db src-db/database/sourcedata/AD_COLUMN.xml --- a/src-db/database/sourcedata/AD_COLUMN.xml Fri Apr 23 16:11:53 2010 +0200 +++ b/src-db/database/sourcedata/AD_COLUMN.xml Fri Apr 23 17:32:58 2010 +0200 @@ -46727,7 +46727,7 @@ <!--3001--> <ISPARENT><![CDATA[N]]></ISPARENT> <!--3001--> <ISMANDATORY><![CDATA[Y]]></ISMANDATORY> <!--3001--> <ISUPDATEABLE><![CDATA[N]]></ISUPDATEABLE> -<!--3001--> <ISIDENTIFIER><![CDATA[Y]]></ISIDENTIFIER> +<!--3001--> <ISIDENTIFIER><![CDATA[N]]></ISIDENTIFIER> <!--3001--> <SEQNO><![CDATA[1]]></SEQNO> <!--3001--> <ISTRANSLATED><![CDATA[N]]></ISTRANSLATED> <!--3001--> <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED> @@ -96415,7 +96415,7 @@ <!--5855--> <ISPARENT><![CDATA[N]]></ISPARENT> <!--5855--> <ISMANDATORY><![CDATA[N]]></ISMANDATORY> <!--5855--> <ISUPDATEABLE><![CDATA[Y]]></ISUPDATEABLE> -<!--5855--> <ISIDENTIFIER><![CDATA[N]]></ISIDENTIFIER> +<!--5855--> <ISIDENTIFIER><![CDATA[Y]]></ISIDENTIFIER> <!--5855--> <SEQNO><![CDATA[0]]></SEQNO> <!--5855--> <ISTRANSLATED><![CDATA[N]]></ISTRANSLATED> <!--5855--> <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED> ------------------------------------------------------------------------------ _______________________________________________ Openbravo-commits mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/openbravo-commits
