cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r921861 [2/2] - in /cayenne/main/trunk/framework: cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/ cayenne-project-unpublished/src/main/java/org/apache/cayenne/projec...
Date Thu, 11 Mar 2010 14:19:26 GMT
Modified: cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/validation/ProcedureParameterValidator.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/validation/ProcedureParameterValidator.java?rev=921861&r1=921860&r2=921861&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/validation/ProcedureParameterValidator.java
(original)
+++ cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/validation/ProcedureParameterValidator.java
Thu Mar 11 14:19:25 2010
@@ -18,40 +18,49 @@
  ****************************************************************/
 package org.apache.cayenne.project2.validation;
 
+import java.sql.Types;
+
 import org.apache.cayenne.dba.TypesMapping;
 import org.apache.cayenne.map.ProcedureParameter;
 import org.apache.cayenne.util.Util;
+import org.apache.cayenne.validation.ValidationResult;
 
-class ProcedureParameterValidator {
-
-    void validate(Object object, ValidationVisitor validationVisitor) {
+class ProcedureParameterValidator extends ConfigurationNodeValidator {
 
-        ProcedureParameter parameter = (ProcedureParameter) object;
+    void validate(ProcedureParameter parameter, ValidationResult validationResult) {
 
         // Must have name
         if (Util.isEmptyString(parameter.getName())) {
-            validationVisitor.registerError("Unnamed ProcedureParameter.", object);
+            addFailure(validationResult, parameter, "Unnamed ProcedureParameter");
         }
 
         // all attributes must have type
         if (parameter.getType() == TypesMapping.NOT_DEFINED) {
-            validationVisitor.registerWarning("ProcedureParameter has no type.", object);
+            addFailure(
+                    validationResult,
+                    parameter,
+                    "ProcedureParameter '%s' has no type",
+                    parameter.getName());
         }
 
         // VARCHAR and CHAR attributes must have max length
         if (parameter.getMaxLength() < 0
-                && (parameter.getType() == java.sql.Types.VARCHAR || parameter.getType()
== java.sql.Types.CHAR)) {
+                && (parameter.getType() == Types.VARCHAR || parameter.getType() ==
Types.CHAR)) {
 
-            validationVisitor.registerWarning(
-                    "Character procedure parameter doesn't have max length.",
-                    object);
+            addFailure(
+                    validationResult,
+                    parameter,
+                    "Character ProcedureParameter '%s' doesn't have max length",
+                    parameter.getName());
         }
 
         // all attributes must have type
         if (parameter.getDirection() <= 0) {
-            validationVisitor.registerWarning(
-                    "ProcedureParameter has no direction.",
-                    object);
+            addFailure(
+                    validationResult,
+                    parameter,
+                    "ProcedureParameter '%s' has no direction",
+                    parameter.getName());
         }
     }
 }

Modified: cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/validation/ProcedureQueryValidator.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/validation/ProcedureQueryValidator.java?rev=921861&r1=921860&r2=921861&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/validation/ProcedureQueryValidator.java
(original)
+++ cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/validation/ProcedureQueryValidator.java
Thu Mar 11 14:19:25 2010
@@ -23,23 +23,23 @@ import org.apache.cayenne.map.Procedure;
 import org.apache.cayenne.query.ProcedureQuery;
 import org.apache.cayenne.query.Query;
 import org.apache.cayenne.util.Util;
+import org.apache.cayenne.validation.ValidationResult;
 
-class ProcedureQueryValidator {
+class ProcedureQueryValidator extends ConfigurationNodeValidator {
 
-    void validate(Object object, ValidationVisitor validationVisitor) {
-        ProcedureQuery query = (ProcedureQuery) object;
-
-        validateName(query, validationVisitor);
-        validateRoot(query, validationVisitor);
+    void validate(ProcedureQuery query, ValidationResult validationResult) {
+        validateName(query, validationResult);
+        validateRoot(query, validationResult);
     }
 
-    void validateRoot(ProcedureQuery query, ValidationVisitor validationVisitor) {
+    void validateRoot(ProcedureQuery query, ValidationResult validationResult) {
 
         DataMap map = query.getDataMap();
         Object root = query.getRoot();
 
         if (root == null && map != null) {
-            validationVisitor.registerWarning("Query has no root", query);
+            addFailure(validationResult, query, "ProcedureQuery '%s' has no root", query
+                    .getName());
         }
 
         // procedure query only supports procedure root
@@ -48,8 +48,12 @@ class ProcedureQueryValidator {
 
             // procedure may have been deleted...
             if (map != null && map.getProcedure(procedure.getName()) != procedure)
{
-                validationVisitor.registerWarning("Invalid Procedure Root - "
-                        + procedure.getName(), query);
+                addFailure(
+                        validationResult,
+                        query,
+                        "ProcedureQuery '%s' has invalid Procedure root: %s",
+                        query.getName(),
+                        procedure.getName());
             }
 
             return;
@@ -57,19 +61,22 @@ class ProcedureQueryValidator {
 
         if (root instanceof String) {
             if (map != null && map.getProcedure(root.toString()) == null) {
-                validationVisitor.registerWarning(
-                        "Invalid Procedure Root - " + root,
-                        query);
+                addFailure(
+                        validationResult,
+                        query,
+                        "ProcedureQuery '%s' has invalid Procedure root: %s",
+                        query.getName(),
+                        root);
             }
         }
     }
 
-    void validateName(ProcedureQuery query, ValidationVisitor validationVisitor) {
+    void validateName(ProcedureQuery query, ValidationResult validationResult) {
         String name = query.getName();
 
         // Must have name
         if (Util.isEmptyString(name)) {
-            validationVisitor.registerError("Unnamed Query.", query);
+            addFailure(validationResult, query, "Unnamed ProcedureQuery");
             return;
         }
 
@@ -85,9 +92,11 @@ class ProcedureQueryValidator {
             }
 
             if (name.equals(otherQuery.getName())) {
-                validationVisitor.registerError(
-                        "Duplicate Query name: " + name + ".",
-                        query);
+                addFailure(
+                        validationResult,
+                        query,
+                        "Dulicate ProcedureQuery name: %s",
+                        name);
                 break;
             }
         }

Modified: cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/validation/ProcedureValidator.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/validation/ProcedureValidator.java?rev=921861&r1=921860&r2=921861&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/validation/ProcedureValidator.java
(original)
+++ cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/validation/ProcedureValidator.java
Thu Mar 11 14:19:25 2010
@@ -24,31 +24,33 @@ import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.map.Procedure;
 import org.apache.cayenne.map.ProcedureParameter;
 import org.apache.cayenne.util.Util;
+import org.apache.cayenne.validation.ValidationResult;
 
-class ProcedureValidator {
+class ProcedureValidator extends ConfigurationNodeValidator {
 
-    void validate(Object object, ValidationVisitor validationVisitor) {
-        Procedure procedure = (Procedure) object;
+    void validate(Procedure procedure, ValidationResult validationResult) {
 
-        validateName(procedure, validationVisitor);
+        validateName(procedure, validationResult);
 
         // check that return value is present
         if (procedure.isReturningValue()) {
             List<ProcedureParameter> parameters = procedure.getCallParameters();
-            if (parameters.size() == 0) {
-                validationVisitor.registerWarning(
-                        "Procedure returns a value, but has no parameters.",
-                        object);
+            if (parameters.isEmpty()) {
+                addFailure(
+                        validationResult,
+                        procedure,
+                        "Procedure '%s' returns a value, but has no parameters",
+                        procedure.getName());
             }
         }
     }
 
-    void validateName(Procedure procedure, ValidationVisitor validationVisitor) {
+    void validateName(Procedure procedure, ValidationResult validationResult) {
         String name = procedure.getName();
 
         // Must have name
         if (Util.isEmptyString(name)) {
-            validationVisitor.registerError("Unnamed Procedure.", procedure);
+            addFailure(validationResult, procedure, "Unnamed Procedure");
             return;
         }
 
@@ -64,9 +66,11 @@ class ProcedureValidator {
             }
 
             if (name.equals(otherProcedure.getName())) {
-                validationVisitor.registerError(
-                        "Duplicate Procedure name: " + name + ".",
-                        procedure);
+                addFailure(
+                        validationResult,
+                        procedure,
+                        "Duplicate Procedure name: %s",
+                        procedure.getName());
                 break;
             }
         }

Modified: cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/validation/ProjectValidator.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/validation/ProjectValidator.java?rev=921861&r1=921860&r2=921861&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/validation/ProjectValidator.java
(original)
+++ cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/validation/ProjectValidator.java
Thu Mar 11 14:19:25 2010
@@ -21,7 +21,12 @@ package org.apache.cayenne.project2.vali
 import org.apache.cayenne.configuration.ConfigurationNode;
 import org.apache.cayenne.validation.ValidationResult;
 
+/**
+ * A project validating service.
+ * 
+ * @since 3.1
+ */
 public interface ProjectValidator {
 
-    public ValidationResult validate(ConfigurationNode node);
+    ValidationResult validate(ConfigurationNode node);
 }

Modified: cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/validation/SQLTemplateValidator.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/validation/SQLTemplateValidator.java?rev=921861&r1=921860&r2=921861&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/validation/SQLTemplateValidator.java
(original)
+++ cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/validation/SQLTemplateValidator.java
Thu Mar 11 14:19:25 2010
@@ -22,18 +22,17 @@ import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.query.Query;
 import org.apache.cayenne.query.SQLTemplate;
 import org.apache.cayenne.util.Util;
+import org.apache.cayenne.validation.ValidationResult;
 
-class SQLTemplateValidator {
+class SQLTemplateValidator extends ConfigurationNodeValidator {
 
-    void validate(Object object, ValidationVisitor validationVisitor) {
-        SQLTemplate query = (SQLTemplate) object;
-
-        validateName(query, validationVisitor);
-        validateRoot(query, validationVisitor);
-        validateDefaultSQL(query, validationVisitor);
+    void validate(SQLTemplate query, ValidationResult validationResult) {
+        validateName(query, validationResult);
+        validateRoot(query, validationResult);
+        validateDefaultSQL(query, validationResult);
     }
 
-    void validateDefaultSQL(SQLTemplate query, ValidationVisitor validationVisitor) {
+    void validateDefaultSQL(SQLTemplate query, ValidationResult validationResult) {
 
         if (Util.isEmptyString(query.getDefaultTemplate())) {
             // see if there is at least one adapter-specific template...
@@ -44,23 +43,31 @@ class SQLTemplateValidator {
                 }
             }
 
-            validationVisitor.registerWarning("Query has no default SQL template", query);
+            addFailure(
+                    validationResult,
+                    query,
+                    "SQLTemplate query '%s' has no default SQL template",
+                    query.getName());
         }
     }
 
-    void validateRoot(SQLTemplate query, ValidationVisitor validationVisitor) {
+    void validateRoot(SQLTemplate query, ValidationResult validationResult) {
         DataMap map = query.getDataMap();
         if (query.getRoot() == null && map != null) {
-            validationVisitor.registerWarning("Query has no root", query);
+            addFailure(
+                    validationResult,
+                    query,
+                    "SQLTemplate query '%s' has no root",
+                    query.getName());
         }
     }
 
-    void validateName(SQLTemplate query, ValidationVisitor validationVisitor) {
+    void validateName(SQLTemplate query, ValidationResult validationResult) {
         String name = query.getName();
 
         // Must have name
         if (Util.isEmptyString(name)) {
-            validationVisitor.registerError("Unnamed Query.", query);
+            addFailure(validationResult, query, "Unnamed SQLTemplate");
             return;
         }
 
@@ -76,9 +83,7 @@ class SQLTemplateValidator {
             }
 
             if (name.equals(otherQuery.getName())) {
-                validationVisitor.registerError(
-                        "Duplicate Query name: " + name + ".",
-                        query);
+                addFailure(validationResult, query, "Duplicate query name: %s", name);
                 break;
             }
         }

Modified: cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/validation/SelectQueryValidator.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/validation/SelectQueryValidator.java?rev=921861&r1=921860&r2=921861&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/validation/SelectQueryValidator.java
(original)
+++ cayenne/main/trunk/framework/cayenne-project-unpublished/src/main/java/org/apache/cayenne/project2/validation/SelectQueryValidator.java
Thu Mar 11 14:19:25 2010
@@ -26,54 +26,57 @@ import org.apache.cayenne.query.Prefetch
 import org.apache.cayenne.query.Query;
 import org.apache.cayenne.query.SelectQuery;
 import org.apache.cayenne.util.Util;
+import org.apache.cayenne.validation.ValidationResult;
 
-class SelectQueryValidator {
+class SelectQueryValidator extends ConfigurationNodeValidator {
 
-    void validate(Object object, ValidationVisitor validationVisitor) {
-        SelectQuery query = (SelectQuery) object;
+    void validate(SelectQuery query, ValidationResult validationResult) {
 
-        validateName(query, validationVisitor);
+        validateName(query, validationResult);
 
         // Resolve root to Entity for further validation
-        Entity root = validateRoot(query, validationVisitor);
+        Entity root = validateRoot(query, validationResult);
 
         // validate path-based parts
         if (root != null) {
-            validateQualifier(root, query.getQualifier(), validationVisitor);
+            validateQualifier(root, query.getQualifier(), validationResult);
 
             for (final Ordering ordering : query.getOrderings()) {
-                validateOrdering(root, ordering, validationVisitor);
+                validateOrdering(root, ordering, validationResult);
             }
 
             if (query.getPrefetchTree() != null) {
-                for (final PrefetchTreeNode prefetchTreeNode : query
+                for (PrefetchTreeNode prefetchTreeNode : query
                         .getPrefetchTree()
                         .nonPhantomNodes()) {
-                    validatePrefetch(root, prefetchTreeNode.getPath(), validationVisitor);
+                    validatePrefetch(root, prefetchTreeNode.getPath(), validationResult);
                 }
             }
         }
     }
 
-    void validatePrefetch(Entity root, String path, ValidationVisitor validationVisitor)
{
+    void validatePrefetch(Entity root, String path, ValidationResult validationResult) {
+        // TODO: andrus 03/10/2010 - should this be implemented?
     }
 
     void validateOrdering(
             Entity root,
             Ordering ordering,
-            ValidationVisitor validationVisitor) {
+            ValidationResult validationResult) {
+        // TODO: andrus 03/10/2010 - should this be implemented?
     }
 
     void validateQualifier(
             Entity root,
             Expression qualifier,
-            ValidationVisitor validationVisitor) {
+            ValidationResult validationResult) {
+        // TODO: andrus 03/10/2010 - should this be implemented?
     }
 
-    Entity validateRoot(SelectQuery query, ValidationVisitor validationVisitor) {
+    Entity validateRoot(SelectQuery query, ValidationResult validationResult) {
         DataMap map = query.getDataMap();
         if (query.getRoot() == null && map != null) {
-            validationVisitor.registerWarning("Query has no root", query);
+            addFailure(validationResult, query, "Query '%s' has no root", query.getName());
             return null;
         }
 
@@ -92,7 +95,7 @@ class SelectQueryValidator {
         }
 
         // can't validate Class root - it is likely not accessible from here...
-        if (query.getRoot() instanceof Class) {
+        if (query.getRoot() instanceof Class<?>) {
             return null;
         }
 
@@ -109,12 +112,12 @@ class SelectQueryValidator {
         return null;
     }
 
-    void validateName(SelectQuery query, ValidationVisitor validationVisitor) {
+    void validateName(SelectQuery query, ValidationResult validationResult) {
         String name = query.getName();
 
         // Must have name
         if (Util.isEmptyString(name)) {
-            validationVisitor.registerError("Unnamed SelectQuery.", query);
+            addFailure(validationResult, query, "Unnamed SelectQuery");
             return;
         }
 
@@ -131,9 +134,7 @@ class SelectQueryValidator {
             }
 
             if (name.equals(otherQuery.getName())) {
-                validationVisitor.registerError(
-                        "Duplicate Query name: " + name + ".",
-                        query);
+                addFailure(validationResult, query, "Duplicate query name: %s", name);
                 break;
             }
         }



Mime
View raw message