[mod-check] WADValidation comes back to src-wad
authorAsier Lostalé <asier.lostale@openbravo.com>
Fri, 20 Nov 2009 16:11:41 +0100
changeset 5535 fded2a7916a3
parent 5534 94802adc1311
child 5536 e27763df3e01
[mod-check] WADValidation comes back to src-wad
Other case we have problems when the src is not compiled yet
src-wad/.classpath
src-wad/src/org/openbravo/wad/validation/WADValidationResult.java
src-wad/src/org/openbravo/wad/validation/WADValidator.java
src-wad/src/org/openbravo/wad/validation/WADValidatorTask.java
src-wad/src/org/openbravo/wad/validation/WADValidator_data.xsql
src/build.xml
src/org/openbravo/service/system/WADValidationResult.java
src/org/openbravo/service/system/WADValidator.java
src/org/openbravo/service/system/WADValidatorTask.java
src/org/openbravo/service/system/WADValidator_data.xsql
--- a/src-wad/.classpath	Fri Nov 20 15:46:19 2009 +0100
+++ b/src-wad/.classpath	Fri Nov 20 16:11:41 2009 +0100
@@ -9,5 +9,6 @@
 	<classpathentry kind="lib" path="/openbravo/lib/runtime/servlet-api.jar"/>
 	<classpathentry kind="lib" path="/openbravo/lib/runtime/postgresql-jdbc3-8.2.jar"/>
 	<classpathentry kind="lib" path="/openbravo/lib/runtime/log4j-1.2.8.jar"/>
+	<classpathentry kind="lib" path="/openbravo/lib/runtime/ant-1.7.1.jar"/>
 	<classpathentry kind="output" path="build/classes"/>
 </classpath>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-wad/src/org/openbravo/wad/validation/WADValidationResult.java	Fri Nov 20 16:11:41 2009 +0100
@@ -0,0 +1,137 @@
+/*
+ *************************************************************************
+ * 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 SL 
+ * All portions are Copyright (C) 2009 Openbravo SL 
+ * All Rights Reserved. 
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+
+package org.openbravo.wad.validation;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.log4j.Logger;
+
+/**
+ * Contains information of all the warnings and errors detected during the WAD validation
+ * 
+ */
+public class WADValidationResult {
+  Logger log = Logger.getLogger(WADValidationResult.class);
+
+  /**
+   * Types of possible WAD validations, they have an identifier and a description
+   * 
+   */
+  public enum WADValidationType {
+    SQL("SQL"), MISSING_IDENTIFIER("Missing Identifier"), MISSING_KEY("Missing Key Column"), MODEL_OBJECT(
+        "Model Object");
+
+    private String description;
+
+    WADValidationType(String description) {
+      this.description = description;
+    }
+
+    /**
+     * Returns the description for the validation type
+     * 
+     * @return description
+     */
+    public String getDescription() {
+      return description;
+    }
+  }
+
+  private HashMap<WADValidationType, List<String>> errors = new HashMap<WADValidationType, List<String>>();
+  private HashMap<WADValidationType, List<String>> warnings = new HashMap<WADValidationType, List<String>>();
+
+  /**
+   * Adds a warning message to a validation type
+   * 
+   * @param validationType
+   *          validation type to add the warning to
+   * @param warning
+   *          warning message
+   */
+  public void addWarning(WADValidationType validationType, String warning) {
+    addToResult(warnings, validationType, warning);
+  }
+
+  /**
+   * Adds an error message to a validation type
+   * 
+   * @param validationType
+   *          validation type to add the error to
+   * @param error
+   *          error message
+   */
+  public void addError(WADValidationType validationType, String warning) {
+    addToResult(errors, validationType, warning);
+  }
+
+  private void addToResult(Map<WADValidationType, List<String>> result,
+      WADValidationType validationType, String msg) {
+
+    List<String> msgList = result.get(validationType);
+    if (msgList == null) {
+      msgList = new ArrayList<String>();
+      result.put(validationType, msgList);
+    }
+    msgList.add(msg);
+  }
+
+  /**
+   * Returns true in case the validation contain errors
+   * 
+   * @return
+   */
+  public boolean hasErrors() {
+    return errors.size() > 0;
+  }
+
+  /**
+   * Prints the result in the log
+   */
+  public void printLog(boolean stopOnError) {
+    for (WADValidationType type : warnings.keySet()) {
+      log.warn("+++++++++++++++++++++++++++++++++++++++++++++++++++");
+      log.warn("Warnings for Validation type: " + type.getDescription());
+      log.warn("+++++++++++++++++++++++++++++++++++++++++++++++++++");
+      for (String warn : warnings.get(type)) {
+        log.warn(warn);
+      }
+    }
+
+    if (!stopOnError && errors.size() > 0) {
+      log.error("The following errors during validation do not stop the");
+      log.error("compilation process to allow backwards compatibility for");
+      log.error("modules, but they MUST be fixed because in future core ");
+      log.error("releases they will not be allowed.");
+    }
+
+    for (WADValidationType type : errors.keySet()) {
+      log.error("+++++++++++++++++++++++++++++++++++++++++++++++++++");
+      log.error("Errors for Validation type: " + type.getDescription());
+      log.error("+++++++++++++++++++++++++++++++++++++++++++++++++++");
+      for (String error : errors.get(type)) {
+        log.error(error);
+      }
+    }
+
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-wad/src/org/openbravo/wad/validation/WADValidator.java	Fri Nov 20 16:11:41 2009 +0100
@@ -0,0 +1,108 @@
+/*
+ *************************************************************************
+ * 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 SL 
+ * All portions are Copyright (C) 2009 Openbravo SL 
+ * All Rights Reserved. 
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+
+package org.openbravo.wad.validation;
+
+import org.openbravo.database.ConnectionProvider;
+import org.openbravo.wad.validation.WADValidationResult.WADValidationType;
+
+/**
+ * Performs a series of validations for WAD tabs. It does not use DAL but sqlc not to have to init
+ * DAL for each compilation.
+ * 
+ */
+public class WADValidator {
+  private String modules;
+  private ConnectionProvider conn;
+  private String checkAll;
+
+  /**
+   * Constructor
+   * 
+   * @param conn
+   *          Database ConnectionProvider
+   * @param moduleId
+   *          Module to check
+   */
+  public WADValidator(ConnectionProvider conn, String modules) {
+    checkAll = (modules == null || modules.equals("%") || modules.equals("")) ? "Y" : "N";
+    this.modules = "'"
+        + (checkAll.equals("Y") ? "%" : modules.replace(", ", ",").replace(",", "', '")) + "'";
+    this.conn = conn;
+  }
+
+  /**
+   * Performs the validations on the assigned tabs
+   * 
+   * @return the result of the validations
+   */
+  public WADValidationResult validate() {
+    WADValidationResult result = new WADValidationResult();
+    validateIdentifier(result);
+    validateKey(result);
+    validateModelObject(result);
+    return result;
+  }
+
+  /**
+   * Validates tables have at least one column set as identifier
+   */
+  private void validateIdentifier(WADValidationResult result) {
+    try {
+      WADValidatorData data[] = WADValidatorData.checkIdentifier(conn, modules, checkAll);
+      for (WADValidatorData issue : data) {
+        result.addError(WADValidationType.MISSING_IDENTIFIER, "Table " + issue.objectname
+            + " has not identifier.");
+      }
+    } catch (Exception e) {
+      result.addWarning(WADValidationType.SQL,
+          "Error when executing query for validating identifiers: " + e.getMessage());
+    }
+  }
+
+  /**
+   * Validates tables have a primary key column
+   */
+  private void validateKey(WADValidationResult result) {
+    try {
+      WADValidatorData data[] = WADValidatorData.checkKey(conn, modules, checkAll);
+      for (WADValidatorData issue : data) {
+        result.addError(WADValidationType.MISSING_KEY, "Table " + issue.objectname
+            + " has not primary key.");
+      }
+    } catch (Exception e) {
+      result.addWarning(WADValidationType.SQL,
+          "Error when executing query for validating primary keys: " + e.getMessage());
+    }
+  }
+
+  private void validateModelObject(WADValidationResult result) {
+    try {
+      WADValidatorData data[] = WADValidatorData.checkModelObject(conn, modules, checkAll);
+      for (WADValidatorData issue : data) {
+        result.addError(WADValidationType.MODEL_OBJECT, issue.objecttype + " " + issue.objectname
+            + " has classname: " + issue.currentvalue + ". But it should be in "
+            + issue.expectedvalue + " package.");
+      }
+    } catch (Exception e) {
+      result.addWarning(WADValidationType.SQL,
+          "Error when executing query for validating moel object: " + e.getMessage());
+    }
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-wad/src/org/openbravo/wad/validation/WADValidatorTask.java	Fri Nov 20 16:11:41 2009 +0100
@@ -0,0 +1,66 @@
+/*
+ *************************************************************************
+ * 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 SL 
+ * All portions are Copyright (C) 2009 Openbravo SL 
+ * All Rights Reserved. 
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+package org.openbravo.wad.validation;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
+import org.openbravo.database.CPStandAlone;
+
+public class WADValidatorTask extends Task {
+  private String propertiesFile;
+  private String modules;
+  private boolean stoponerror;
+
+  @Override
+  public void execute() throws BuildException {
+    System.out.println("stop on error:" + stoponerror);
+    CPStandAlone conn = new CPStandAlone(propertiesFile);
+    WADValidator val = new WADValidator(conn, modules);
+    WADValidationResult result = val.validate();
+    result.printLog(stoponerror);
+    if (result.hasErrors() && stoponerror) {
+      throw new BuildException("WAD verification has errors");
+    }
+  }
+
+  public String getPropertiesFile() {
+    return propertiesFile;
+  }
+
+  public void setPropertiesFile(String propertiesFile) {
+    this.propertiesFile = propertiesFile;
+  }
+
+  public String getModules() {
+    return modules;
+  }
+
+  public void setModules(String modules) {
+    this.modules = modules;
+  }
+
+  public boolean isStoponerror() {
+    return stoponerror;
+  }
+
+  public void setStoponerror(boolean failonerror) {
+    this.stoponerror = failonerror;
+  }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-wad/src/org/openbravo/wad/validation/WADValidator_data.xsql	Fri Nov 20 16:11:41 2009 +0100
@@ -0,0 +1,106 @@
+<?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 SL 
+ * All portions are Copyright (C) 2009 Openbravo SL 
+ * All Rights Reserved. 
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+-->
+
+<SqlClass name="WADValidatorData" package="org.openbravo.wad.validation">
+  <SqlMethod name="checkIdentifier" type="preparedStatement" return="multiple">
+    <Sql>
+      <![CDATA[
+          select t.tablename as objectName
+          from ad_table t, ad_module m, ad_package p
+         where not exists (select 1
+                             from ad_column c
+                            where c.ad_table_id = t.ad_table_id
+                              and c.isidentifier = 'Y')
+           and t.ad_package_id = p.ad_package_id
+           and m.ad_module_id = p.ad_module_id
+           and (m.javapackage in ('1') or 'Y'=?)
+      ]]>
+    </Sql>
+    <Field name="objecttype" value=""/>
+    <Field name="currentvalue" value=""/>
+    <Field name="expectedvalue" value=""/>
+    <Parameter name="module" optional="true" type="replace" after="m.javapackage in (" text="'1'"/>
+    <Parameter name="checkAll"/>
+  </SqlMethod>
+  
+  <SqlMethod name="checkKey" type="preparedStatement" return="multiple">
+    <Sql>
+      <![CDATA[
+        select t.tablename as objectName
+          from ad_table t, ad_module m, ad_package p
+         where not exists (select 1
+                             from ad_column c
+                            where c.ad_table_id = t.ad_table_id
+                              and c.iskey = 'Y')
+           and t.ad_package_id = p.ad_package_id
+           and m.ad_module_id = p.ad_module_id
+           and (m.javapackage in ('1') or 'Y'=?)
+      ]]>
+    </Sql>
+    <Parameter name="module" optional="true" type="replace" after="m.javapackage in (" text="'1'"/>
+    <Parameter name="checkAll"/>
+  </SqlMethod>
+  
+  
+  <SqlMethod name="checkModelObject" type="preparedStatement" return="multiple">
+    <Sql>
+      <![CDATA[
+        select to_char(p.name) objectname, 'Process' as objectType, o.classname as currentvalue, m.javapackage as expectedvalue 
+          from ad_model_object o, ad_process p, ad_module m
+         where o.ad_process_id = p.ad_process_id
+           and p.ad_module_id = m.ad_module_id
+           and o.classname not like m.javapackage||'.%'
+           and (1=1 and m.javapackage in ('1') or 'Y'=?)
+         union
+        select to_char(f.name), 'Form' as objectType, o.classname as currentvalue, m.javapackage as expectedvalue 
+          from ad_model_object o, ad_form f, ad_module m
+         where o.ad_form_id = f.ad_form_id
+           and f.ad_module_id = m.ad_module_id
+           and o.classname not like m.javapackage||'.%'
+           and (2=2 and m.javapackage in ('2') or 'Y'=?)
+         union
+        select to_char(c.name), 'Callout' as objectType, o.classname as currentvalue, m.javapackage as expectedvalue 
+          from ad_model_object o, ad_callout c, ad_module m
+         where o.ad_callout_id = c.ad_callout_id
+           and c.ad_module_id = m.ad_module_id
+           and o.classname not like m.javapackage||'.%'
+           and (3=3 and m.javapackage in ('3') or 'Y'=?)
+         union
+        select to_char(r.name), 'Reference' as objectType, o.classname as currentvalue, m.javapackage as expectedvalue 
+          from ad_model_object o, ad_reference r, ad_module m
+         where o.ad_reference_id = r.ad_reference_id
+           and r.ad_module_id = m.ad_module_id
+           and o.classname not like m.javapackage||'.%'
+           and (4=4 and m.javapackage in ('4') or 'Y'=?)
+         order by 4, 2, 1
+      ]]>
+    </Sql>
+    <Parameter name="module" optional="true" type="replace" after="1=1 and m.javapackage in (" text="'1'"/>
+    <Parameter name="checkAll"/>
+    <Parameter name="module" optional="true" type="replace" after="2=2 and m.javapackage in (" text="'2'"/>
+    <Parameter name="checkAll"/>
+    <Parameter name="module" optional="true" type="replace" after="3=3 and m.javapackage in (" text="'3'"/>
+    <Parameter name="checkAll"/>
+    <Parameter name="module" optional="true" type="replace" after="4=4 and m.javapackage in (" text="'4'"/>
+    <Parameter name="checkAll"/>
+  </SqlMethod>
+  
+  
+</SqlClass>
--- a/src/build.xml	Fri Nov 20 15:46:19 2009 +0100
+++ b/src/build.xml	Fri Nov 20 16:11:41 2009 +0100
@@ -346,7 +346,7 @@
   </target>
 
   <target name="wadvalidation">
-    <taskdef name="WADValidation" classname="org.openbravo.service.system.WADValidatorTask">
+    <taskdef name="WADValidation" classname="org.openbravo.wad.validation.WADValidatorTask">
             <classpath refid="project.class.path" />
           </taskdef>
         
--- a/src/org/openbravo/service/system/WADValidationResult.java	Fri Nov 20 15:46:19 2009 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,137 +0,0 @@
-/*
- *************************************************************************
- * 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 SL 
- * All portions are Copyright (C) 2009 Openbravo SL 
- * All Rights Reserved. 
- * Contributor(s):  ______________________________________.
- ************************************************************************
- */
-
-package org.openbravo.service.system;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.log4j.Logger;
-
-/**
- * Contains information of all the warnings and errors detected during the WAD validation
- * 
- */
-public class WADValidationResult {
-  Logger log = Logger.getLogger(WADValidationResult.class);
-
-  /**
-   * Types of possible WAD validations, they have an identifier and a description
-   * 
-   */
-  public enum WADValidationType {
-    SQL("SQL"), MISSING_IDENTIFIER("Missing Identifier"), MISSING_KEY("Missing Key Column"), MODEL_OBJECT(
-        "Model Object");
-
-    private String description;
-
-    WADValidationType(String description) {
-      this.description = description;
-    }
-
-    /**
-     * Returns the description for the validation type
-     * 
-     * @return description
-     */
-    public String getDescription() {
-      return description;
-    }
-  }
-
-  private HashMap<WADValidationType, List<String>> errors = new HashMap<WADValidationType, List<String>>();
-  private HashMap<WADValidationType, List<String>> warnings = new HashMap<WADValidationType, List<String>>();
-
-  /**
-   * Adds a warning message to a validation type
-   * 
-   * @param validationType
-   *          validation type to add the warning to
-   * @param warning
-   *          warning message
-   */
-  public void addWarning(WADValidationType validationType, String warning) {
-    addToResult(warnings, validationType, warning);
-  }
-
-  /**
-   * Adds an error message to a validation type
-   * 
-   * @param validationType
-   *          validation type to add the error to
-   * @param error
-   *          error message
-   */
-  public void addError(WADValidationType validationType, String warning) {
-    addToResult(errors, validationType, warning);
-  }
-
-  private void addToResult(Map<WADValidationType, List<String>> result,
-      WADValidationType validationType, String msg) {
-
-    List<String> msgList = result.get(validationType);
-    if (msgList == null) {
-      msgList = new ArrayList<String>();
-      result.put(validationType, msgList);
-    }
-    msgList.add(msg);
-  }
-
-  /**
-   * Returns true in case the validation contain errors
-   * 
-   * @return
-   */
-  public boolean hasErrors() {
-    return errors.size() > 0;
-  }
-
-  /**
-   * Prints the result in the log
-   */
-  public void printLog(boolean stopOnError) {
-    for (WADValidationType type : warnings.keySet()) {
-      log.warn("+++++++++++++++++++++++++++++++++++++++++++++++++++");
-      log.warn("Warnings for Validation type: " + type.getDescription());
-      log.warn("+++++++++++++++++++++++++++++++++++++++++++++++++++");
-      for (String warn : warnings.get(type)) {
-        log.warn(warn);
-      }
-    }
-
-    if (!stopOnError && errors.size() > 0) {
-      log.error("The following errors during validation do not stop the");
-      log.error("compilation process to allow backwards compatibility for");
-      log.error("modules, but they MUST be fixed because in future core ");
-      log.error("releases they will not be allowed.");
-    }
-
-    for (WADValidationType type : errors.keySet()) {
-      log.error("+++++++++++++++++++++++++++++++++++++++++++++++++++");
-      log.error("Errors for Validation type: " + type.getDescription());
-      log.error("+++++++++++++++++++++++++++++++++++++++++++++++++++");
-      for (String error : errors.get(type)) {
-        log.error(error);
-      }
-    }
-
-  }
-}
--- a/src/org/openbravo/service/system/WADValidator.java	Fri Nov 20 15:46:19 2009 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,108 +0,0 @@
-/*
- *************************************************************************
- * 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 SL 
- * All portions are Copyright (C) 2009 Openbravo SL 
- * All Rights Reserved. 
- * Contributor(s):  ______________________________________.
- ************************************************************************
- */
-
-package org.openbravo.service.system;
-
-import org.openbravo.database.ConnectionProvider;
-import org.openbravo.service.system.WADValidationResult.WADValidationType;
-
-/**
- * Performs a series of validations for WAD tabs. It does not use DAL but sqlc not to have to init
- * DAL for each compilation.
- * 
- */
-public class WADValidator {
-  private String modules;
-  private ConnectionProvider conn;
-  private String checkAll;
-
-  /**
-   * Constructor
-   * 
-   * @param conn
-   *          Database ConnectionProvider
-   * @param moduleId
-   *          Module to check
-   */
-  public WADValidator(ConnectionProvider conn, String modules) {
-    checkAll = (modules == null || modules.equals("%") || modules.equals("")) ? "Y" : "N";
-    this.modules = "'"
-        + (checkAll.equals("Y") ? "%" : modules.replace(", ", ",").replace(",", "', '")) + "'";
-    this.conn = conn;
-  }
-
-  /**
-   * Performs the validations on the assigned tabs
-   * 
-   * @return the result of the validations
-   */
-  public WADValidationResult validate() {
-    WADValidationResult result = new WADValidationResult();
-    validateIdentifier(result);
-    validateKey(result);
-    validateModelObject(result);
-    return result;
-  }
-
-  /**
-   * Validates tables have at least one column set as identifier
-   */
-  private void validateIdentifier(WADValidationResult result) {
-    try {
-      WADValidatorData data[] = WADValidatorData.checkIdentifier(conn, modules, checkAll);
-      for (WADValidatorData issue : data) {
-        result.addError(WADValidationType.MISSING_IDENTIFIER, "Table " + issue.objectname
-            + " has not identifier.");
-      }
-    } catch (Exception e) {
-      result.addWarning(WADValidationType.SQL,
-          "Error when executing query for validating identifiers: " + e.getMessage());
-    }
-  }
-
-  /**
-   * Validates tables have a primary key column
-   */
-  private void validateKey(WADValidationResult result) {
-    try {
-      WADValidatorData data[] = WADValidatorData.checkKey(conn, modules, checkAll);
-      for (WADValidatorData issue : data) {
-        result.addError(WADValidationType.MISSING_KEY, "Table " + issue.objectname
-            + " has not primary key.");
-      }
-    } catch (Exception e) {
-      result.addWarning(WADValidationType.SQL,
-          "Error when executing query for validating primary keys: " + e.getMessage());
-    }
-  }
-
-  private void validateModelObject(WADValidationResult result) {
-    try {
-      WADValidatorData data[] = WADValidatorData.checkModelObject(conn, modules, checkAll);
-      for (WADValidatorData issue : data) {
-        result.addError(WADValidationType.MODEL_OBJECT, issue.objecttype + " " + issue.objectname
-            + " has classname: " + issue.currentvalue + ". But it should be in "
-            + issue.expectedvalue + " package.");
-      }
-    } catch (Exception e) {
-      result.addWarning(WADValidationType.SQL,
-          "Error when executing query for validating moel object: " + e.getMessage());
-    }
-  }
-}
--- a/src/org/openbravo/service/system/WADValidatorTask.java	Fri Nov 20 15:46:19 2009 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,66 +0,0 @@
-/*
- *************************************************************************
- * 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 SL 
- * All portions are Copyright (C) 2009 Openbravo SL 
- * All Rights Reserved. 
- * Contributor(s):  ______________________________________.
- ************************************************************************
- */
-package org.openbravo.service.system;
-
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Task;
-import org.openbravo.database.CPStandAlone;
-
-public class WADValidatorTask extends Task {
-  private String propertiesFile;
-  private String modules;
-  private boolean stoponerror;
-
-  @Override
-  public void execute() throws BuildException {
-    System.out.println("stop on error:" + stoponerror);
-    CPStandAlone conn = new CPStandAlone(propertiesFile);
-    WADValidator val = new WADValidator(conn, modules);
-    WADValidationResult result = val.validate();
-    result.printLog(stoponerror);
-    if (result.hasErrors() && stoponerror) {
-      throw new BuildException("WAD verification has errors");
-    }
-  }
-
-  public String getPropertiesFile() {
-    return propertiesFile;
-  }
-
-  public void setPropertiesFile(String propertiesFile) {
-    this.propertiesFile = propertiesFile;
-  }
-
-  public String getModules() {
-    return modules;
-  }
-
-  public void setModules(String modules) {
-    this.modules = modules;
-  }
-
-  public boolean isStoponerror() {
-    return stoponerror;
-  }
-
-  public void setStoponerror(boolean failonerror) {
-    this.stoponerror = failonerror;
-  }
-
-}
--- a/src/org/openbravo/service/system/WADValidator_data.xsql	Fri Nov 20 15:46:19 2009 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,106 +0,0 @@
-<?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 SL 
- * All portions are Copyright (C) 2009 Openbravo SL 
- * All Rights Reserved. 
- * Contributor(s):  ______________________________________.
- ************************************************************************
--->
-
-<SqlClass name="WADValidatorData" package="org.openbravo.service.system">
-  <SqlMethod name="checkIdentifier" type="preparedStatement" return="multiple">
-    <Sql>
-      <![CDATA[
-          select t.tablename as objectName
-          from ad_table t, ad_module m, ad_package p
-         where not exists (select 1
-                             from ad_column c
-                            where c.ad_table_id = t.ad_table_id
-                              and c.isidentifier = 'Y')
-           and t.ad_package_id = p.ad_package_id
-           and m.ad_module_id = p.ad_module_id
-           and (m.javapackage in ('1') or 'Y'=?)
-      ]]>
-    </Sql>
-    <Field name="objecttype" value=""/>
-    <Field name="currentvalue" value=""/>
-    <Field name="expectedvalue" value=""/>
-    <Parameter name="module" optional="true" type="replace" after="m.javapackage in (" text="'1'"/>
-    <Parameter name="checkAll"/>
-  </SqlMethod>
-  
-  <SqlMethod name="checkKey" type="preparedStatement" return="multiple">
-    <Sql>
-      <![CDATA[
-        select t.tablename as objectName
-          from ad_table t, ad_module m, ad_package p
-         where not exists (select 1
-                             from ad_column c
-                            where c.ad_table_id = t.ad_table_id
-                              and c.iskey = 'Y')
-           and t.ad_package_id = p.ad_package_id
-           and m.ad_module_id = p.ad_module_id
-           and (m.javapackage in ('1') or 'Y'=?)
-      ]]>
-    </Sql>
-    <Parameter name="module" optional="true" type="replace" after="m.javapackage in (" text="'1'"/>
-    <Parameter name="checkAll"/>
-  </SqlMethod>
-  
-  
-  <SqlMethod name="checkModelObject" type="preparedStatement" return="multiple">
-    <Sql>
-      <![CDATA[
-        select to_char(p.name) objectname, 'Process' as objectType, o.classname as currentvalue, m.javapackage as expectedvalue 
-          from ad_model_object o, ad_process p, ad_module m
-         where o.ad_process_id = p.ad_process_id
-           and p.ad_module_id = m.ad_module_id
-           and o.classname not like m.javapackage||'.%'
-           and (1=1 and m.javapackage in ('1') or 'Y'=?)
-         union
-        select to_char(f.name), 'Form' as objectType, o.classname as currentvalue, m.javapackage as expectedvalue 
-          from ad_model_object o, ad_form f, ad_module m
-         where o.ad_form_id = f.ad_form_id
-           and f.ad_module_id = m.ad_module_id
-           and o.classname not like m.javapackage||'.%'
-           and (2=2 and m.javapackage in ('2') or 'Y'=?)
-         union
-        select to_char(c.name), 'Callout' as objectType, o.classname as currentvalue, m.javapackage as expectedvalue 
-          from ad_model_object o, ad_callout c, ad_module m
-         where o.ad_callout_id = c.ad_callout_id
-           and c.ad_module_id = m.ad_module_id
-           and o.classname not like m.javapackage||'.%'
-           and (3=3 and m.javapackage in ('3') or 'Y'=?)
-         union
-        select to_char(r.name), 'Reference' as objectType, o.classname as currentvalue, m.javapackage as expectedvalue 
-          from ad_model_object o, ad_reference r, ad_module m
-         where o.ad_reference_id = r.ad_reference_id
-           and r.ad_module_id = m.ad_module_id
-           and o.classname not like m.javapackage||'.%'
-           and (4=4 and m.javapackage in ('4') or 'Y'=?)
-         order by 4, 2, 1
-      ]]>
-    </Sql>
-    <Parameter name="module" optional="true" type="replace" after="1=1 and m.javapackage in (" text="'1'"/>
-    <Parameter name="checkAll"/>
-    <Parameter name="module" optional="true" type="replace" after="2=2 and m.javapackage in (" text="'2'"/>
-    <Parameter name="checkAll"/>
-    <Parameter name="module" optional="true" type="replace" after="3=3 and m.javapackage in (" text="'3'"/>
-    <Parameter name="checkAll"/>
-    <Parameter name="module" optional="true" type="replace" after="4=4 and m.javapackage in (" text="'4'"/>
-    <Parameter name="checkAll"/>
-  </SqlMethod>
-  
-  
-</SqlClass>