details:   /erp/stable/2.50/rev/2ea674a2e961
changeset: 9436:2ea674a2e961
user:      Mikel Irurita <mikel.irurita <at> openbravo.com>
date:      Wed May 18 18:44:30 2011 +0200
summary:   [Buildvalidation] Check minimun APRM version (1.0.15) for updating 
to MP30 or higher

diffstat:

 
src-util/buildvalidation/build/classes/org/openbravo/buildvalidation/CheckAPRMVersionDependency.class
     |    0 
 
src-util/buildvalidation/build/classes/org/openbravo/buildvalidation/CheckAPRMVersionDependencyData.class
 |    0 
 
src-util/buildvalidation/src/org/openbravo/buildvalidation/CheckAPRMVersionDependency.java
                |   76 ++++++++++
 
src-util/buildvalidation/src/org/openbravo/buildvalidation/CheckAPRMVersionDependency_data.xsql
           |   39 +++++
 4 files changed, 115 insertions(+), 0 deletions(-)

diffs (127 lines):

diff -r 176fcee60aa5 -r 2ea674a2e961 
src-util/buildvalidation/build/classes/org/openbravo/buildvalidation/CheckAPRMVersionDependency.class
Binary file 
src-util/buildvalidation/build/classes/org/openbravo/buildvalidation/CheckAPRMVersionDependency.class
 has changed
diff -r 176fcee60aa5 -r 2ea674a2e961 
src-util/buildvalidation/build/classes/org/openbravo/buildvalidation/CheckAPRMVersionDependencyData.class
Binary file 
src-util/buildvalidation/build/classes/org/openbravo/buildvalidation/CheckAPRMVersionDependencyData.class
 has changed
diff -r 176fcee60aa5 -r 2ea674a2e961 
src-util/buildvalidation/src/org/openbravo/buildvalidation/CheckAPRMVersionDependency.java
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ 
b/src-util/buildvalidation/src/org/openbravo/buildvalidation/CheckAPRMVersionDependency.java
        Wed May 18 18:44:30 2011 +0200
@@ -0,0 +1,76 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.1  (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) 2011 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+package org.openbravo.buildvalidation;
+
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.openbravo.database.ConnectionProvider;
+
+public class CheckAPRMVersionDependency extends BuildValidation {
+
+  //Minimun APRM version required 1.0.15
+  private final static BigDecimal minPart1 = BigDecimal.ONE;
+  private final static BigDecimal minPart2 = BigDecimal.ZERO;
+  private final static BigDecimal minPart3 = new BigDecimal("15");
+
+  // The minimum APRM version required for updating to this MP is 1.0.15
+  // Force to apply APRM version 1.0.15 or higher to update to this MP
+  @Override
+  public List<String> execute() {
+    ConnectionProvider cp = getConnectionProvider();
+    ArrayList<String> errors = new ArrayList<String>();
+    boolean isValid = true;
+
+    try {
+      if (CheckAPRMVersionDependencyData.isAPRMinstalled(cp)) {
+        CheckAPRMVersionDependencyData[] data = 
CheckAPRMVersionDependencyData.getAPRMversion(cp);
+        String[] versionParts = data[0].version.split("\\.");
+        if (versionParts.length == 3) {
+          BigDecimal part1 = new BigDecimal(versionParts[0]);
+          BigDecimal part2 = new BigDecimal(versionParts[1]);
+          BigDecimal part3 = new BigDecimal(versionParts[2]);
+
+          if (part1.compareTo(minPart1) < 0) {
+            isValid = false;
+          } else if (part1.compareTo(minPart1) == 0) {
+            if (part2.compareTo(minPart2) < 0) {
+              isValid = false;
+            } else if (part2.compareTo(minPart2) == 0) {
+              if (part3.compareTo(minPart3) < 0) {
+                isValid = false;
+              }
+            }
+          }
+
+          if (!isValid) {
+            errors.add("You can not apply this MP because your instance fails 
in a pre-validation: the minimun version required of Advanced Payables and 
Receivables for updating to this MP is 1.0.15. Your current version is " + 
data[0].version + ", please scan for new updates.");
+          }
+        } else {
+          errors.add("Incorrect version, it must follow x.y.z format: " + 
data[0].version);
+        }
+      }
+    } catch (Exception e) {
+      return handleError(e);
+    }
+    return errors;
+  }
+
+}
diff -r 176fcee60aa5 -r 2ea674a2e961 
src-util/buildvalidation/src/org/openbravo/buildvalidation/CheckAPRMVersionDependency_data.xsql
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ 
b/src-util/buildvalidation/src/org/openbravo/buildvalidation/CheckAPRMVersionDependency_data.xsql
   Wed May 18 18:44:30 2011 +0200
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.1  (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) 2011 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+-->
+
+<SqlClass name="CheckAPRMVersionDependencyData" 
package="org.openbravo.buildvalidation">
+   <SqlMethod name="getAPRMversion" type="preparedStatement" return="multiple">
+      <SqlMethodComment>Return the version of installed APRM 
module</SqlMethodComment>
+      <Sql><![CDATA[
+        SELECT version, '' as isinstalled
+        FROM ad_module
+        WHERE ad_module_id = 'A918E3331C404B889D69AA9BFAFB23AC'
+      ]]></Sql>
+   </SqlMethod>
+   <SqlMethod name="isAPRMinstalled" type="preparedStatement" return="boolean">
+      <SqlMethodComment>Checks if the Advanced Payables and Receivables module 
is installed in the system.</SqlMethodComment>
+      <Sql><![CDATA[
+        SELECT count(*) as isinstalled
+        FROM ad_module
+        WHERE ad_module_id = 'A918E3331C404B889D69AA9BFAFB23AC'
+              AND enabled = 'Y'
+      ]]></Sql>
+   </SqlMethod>
+</SqlClass>

------------------------------------------------------------------------------
What Every C/C++ and Fortran developer Should Know!
Read this article and learn how Intel has extended the reach of its 
next-generation tools to help Windows* and Linux* C/C++ and Fortran 
developers boost performance applications - including clusters. 
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to