13362: api check build 393 fails
authorSathiyan Sivaprakasam <sathiyan.sivaprakasam@openbravo.com>
Wed, 19 May 2010 17:24:09 +0530
changeset 7403 7719a5d32346
parent 7402 6d330abd6826
child 7404 6a7a2295a014
13362: api check build 393 fails
src-util/buildvalidation/build/classes/org/openbravo/buildvalidation/PaymentGLItemCheck.class
src-util/buildvalidation/build/classes/org/openbravo/buildvalidation/PaymentGLItemCheckData.class
src-util/buildvalidation/src/org/openbravo/buildvalidation/PaymentGLItemCheck.java
src-util/buildvalidation/src/org/openbravo/buildvalidation/PaymentGLItemCheck_data.xsql
Binary file src-util/buildvalidation/build/classes/org/openbravo/buildvalidation/PaymentGLItemCheck.class has changed
Binary file src-util/buildvalidation/build/classes/org/openbravo/buildvalidation/PaymentGLItemCheckData.class has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-util/buildvalidation/src/org/openbravo/buildvalidation/PaymentGLItemCheck.java	Wed May 19 17:24:09 2010 +0530
@@ -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=12929 The
+ * constraint C_BANKSTATLN_PA_GLITEM_ID_CHK was made more restrictive, and it will fail if the data
+ * is not correct and is not fixed before updating.
+ */
+public class PaymentGLItemCheck extends BuildValidation {
+
+  @Override
+  public List<String> execute() {
+    ConnectionProvider cp = getConnectionProvider();
+    ArrayList<String> errors = new ArrayList<String>();
+    try {
+      int a = Integer.parseInt(PaymentGLItemCheckData.countWithConstraint(cp));
+      int b = Integer.parseInt(PaymentGLItemCheckData.countWithoutConstraint(cp));
+      if (a != b) {
+        errors
+            .add("Due to a database constraint modification, is no longer allowed you select a debt payment and g/l item at same time in bank statement line. 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;
+  }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-util/buildvalidation/src/org/openbravo/buildvalidation/PaymentGLItemCheck_data.xsql	Wed May 19 17:24:09 2010 +0530
@@ -0,0 +1,36 @@
+<?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="PaymentGLItemCheckData" package="org.openbravo.buildvalidation">
+  <SqlMethod name="countWithConstraint" type="preparedStatement" return="string">
+      <SqlMethodComment>This query counts the number of rows in c_bankstatementline with constraint</SqlMethodComment>
+      <Sql><![CDATA[
+         SELECT count(*) as count FROM c_bankstatementline where ((C_DEBT_PAYMENT_ID IS NOT NULL) AND (C_GLITEM_ID IS NULL)) OR (C_DEBT_PAYMENT_ID IS NULL)
+          ]]>
+      </Sql>
+  </SqlMethod>
+  <SqlMethod name="countWithoutConstraint" type="preparedStatement" return="string">
+      <SqlMethodComment>This query counts the number of rows in c_bankstatementline without constraint</SqlMethodComment>
+      <Sql><![CDATA[
+         SELECT count(*) as count FROM c_bankstatementline
+          ]]>
+      </Sql>
+  </SqlMethod>
+</SqlClass>