details: /erp/devel/pi/rev/5c592e20669a
changeset: 6970:5c592e20669a
user: David Alsasua <david.alsasua <at> openbravo.com>
date: Fri Apr 09 18:50:30 2010 +0200
summary: Fixes issue 12824: api check build 327
diffstat:
src-db/database/sourcedata/AD_MESSAGE.xml
| 2 +-
src-util/buildvalidation/src/org/openbravo/buildvalidation/Cbpvendoracct.java
| 50 ++++++++++
src-util/buildvalidation/src/org/openbravo/buildvalidation/Cbpvendoracct_data.xsql
| 37 +++++++
3 files changed, 88 insertions(+), 1 deletions(-)
diffs (107 lines):
diff -r e809fe06034d -r 5c592e20669a src-db/database/sourcedata/AD_MESSAGE.xml
--- a/src-db/database/sourcedata/AD_MESSAGE.xml Fri Apr 09 16:05:37 2010 +0200
+++ b/src-db/database/sourcedata/AD_MESSAGE.xml Fri Apr 09 18:50:30 2010 +0200
@@ -8731,7 +8731,7 @@
<!--800203--> <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
<!--800203--> <ISACTIVE><![CDATA[Y]]></ISACTIVE>
<!--800203--> <VALUE><![CDATA[C_BP_VENDOR_ACCT_ACCTSCHEMA_UN]]></VALUE>
-<!--800203--> <MSGTEXT><![CDATA[The vendor already has a record with the same
accounting schema, with the same organization and with the same status. At
least change one of the three]]></MSGTEXT>
+<!--800203--> <MSGTEXT><![CDATA[The vendor already has a record with the same
accounting schema and with the same status. At least change one of
them]]></MSGTEXT>
<!--800203--> <MSGTYPE><![CDATA[E]]></MSGTYPE>
<!--800203--> <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
<!--800203--></AD_MESSAGE>
diff -r e809fe06034d -r 5c592e20669a
src-util/buildvalidation/src/org/openbravo/buildvalidation/Cbpvendoracct.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++
b/src-util/buildvalidation/src/org/openbravo/buildvalidation/Cbpvendoracct.java
Fri Apr 09 18:50:30 2010 +0200
@@ -0,0 +1,50 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo Public License
+ * Version 1.0 (the "License"), being the Mozilla Public License
+ * Version 1.1 with a permitted attribution clause; you may not use this
+ * file except in compliance with the License. You may obtain a copy of
+ * the License at http://www.openbravo.com/legal/license.html
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ * The Original Code is Openbravo ERP.
+ * The Initial Developer of the Original Code is Openbravo SLU
+ * All portions are Copyright (C) 2010 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s): ______________________________________.
+ ************************************************************************
+ */
+package org.openbravo.buildvalidation;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.openbravo.database.ConnectionProvider;
+
+/**
+ * This validation is related to this issue:
https://issues.openbravo.com/view.php?id=12824 The
+ * unique constraint C_BP_VENDOR_ACCT_ACCTSCHEMA_UN was made more restrictive,
and it will fail if
+ * the data is not correct and is not fixed before updating.
+ */
+public class Cbpvendoracct extends BuildValidation {
+
+ @Override
+ public List<String> execute() {
+ ConnectionProvider cp = getConnectionProvider();
+ ArrayList<String> errors = new ArrayList<String>();
+ try {
+ int a = Integer.parseInt(CbpvendoracctData.countNoDistinct(cp));
+ int b = Integer.parseInt(CbpvendoracctData.countDistinct(cp));
+ if (a != b) {
+ errors
+ .add("Due to a database constraint modification, is no longer
allowed to have more than one entry in business partner -> vendor -> accounting
tab, for the same accounting schema and status. In previous releases, one per
organization was allowed, but is not the case now. There exists data in your
database that do not fit this new constraint. Please fix it before updating the
database.");
+ }
+ } catch (Exception e) {
+ return handleError(e);
+ }
+ return errors;
+ }
+
+}
diff -r e809fe06034d -r 5c592e20669a
src-util/buildvalidation/src/org/openbravo/buildvalidation/Cbpvendoracct_data.xsql
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++
b/src-util/buildvalidation/src/org/openbravo/buildvalidation/Cbpvendoracct_data.xsql
Fri Apr 09 18:50:30 2010 +0200
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo Public License
+ * Version 1.0 (the "License"), being the Mozilla Public License
+ * Version 1.1 with a permitted attribution clause; you may not use this
+ * file except in compliance with the License. You may obtain a copy of
+ * the License at http://www.openbravo.com/legal/license.html
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ * The Original Code is Openbravo ERP.
+ * The Initial Developer of the Original Code is Openbravo SLU
+ * All portions are Copyright (C) 2010 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s): ______________________________________.
+ ************************************************************************
+-->
+
+
+<SqlClass name="CbpvendoracctData" package="org.openbravo.buildvalidation">
+ <SqlMethod name="countNoDistinct" type="preparedStatement" return="string">
+ <SqlMethodComment>This query counts the number of rows in
c_bp_vendor_acct</SqlMethodComment>
+ <Sql><![CDATA[
+ SELECT count(*) as count from (select c_acctschema_id, c_bpartner_id,
status from c_bp_vendor_acct) a
+ ]]>
+ </Sql>
+ </SqlMethod>
+ <SqlMethod name="countDistinct" type="preparedStatement" return="string">
+ <SqlMethodComment>This query counts the number of unique combinations of
(c_acctschema_id, c_bpartner_id, status) tuples in
c_bp_vendor_acct</SqlMethodComment>
+ <Sql><![CDATA[
+ SELECT count(*) as count from (select distinct c_acctschema_id,
c_bpartner_id, status from c_bp_vendor_acct) a
+ ]]>
+ </Sql>
+ </SqlMethod>
+</SqlClass>
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits