cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dkazimirc...@apache.org
Subject cayenne git commit: CAY-2060 Change cgen datamap API to use query descriptor objects instead of real queries.
Date Wed, 25 May 2016 13:57:36 GMT
Repository: cayenne
Updated Branches:
  refs/heads/master 917928f55 -> bb83921a1


CAY-2060 Change cgen datamap API to use query descriptor objects instead of real queries.


Project: http://git-wip-us.apache.org/repos/asf/cayenne/repo
Commit: http://git-wip-us.apache.org/repos/asf/cayenne/commit/bb83921a
Tree: http://git-wip-us.apache.org/repos/asf/cayenne/tree/bb83921a
Diff: http://git-wip-us.apache.org/repos/asf/cayenne/diff/bb83921a

Branch: refs/heads/master
Commit: bb83921a17c376a35f36545fd2a02e483c85138a
Parents: 917928f
Author: Dzmitry Kazimirchyk <dkazimirchyk@gmail.com>
Authored: Wed May 25 16:50:05 2016 +0300
Committer: Dzmitry Kazimirchyk <dkazimirchyk@gmail.com>
Committed: Wed May 25 16:51:51 2016 +0300

----------------------------------------------------------------------
 .../org/apache/cayenne/gen/DataMapUtils.java    | 36 +++++++++-----------
 1 file changed, 17 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/bb83921a/cayenne-tools/src/main/java/org/apache/cayenne/gen/DataMapUtils.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/java/org/apache/cayenne/gen/DataMapUtils.java b/cayenne-tools/src/main/java/org/apache/cayenne/gen/DataMapUtils.java
index a6caf08..64a3a38 100644
--- a/cayenne-tools/src/main/java/org/apache/cayenne/gen/DataMapUtils.java
+++ b/cayenne-tools/src/main/java/org/apache/cayenne/gen/DataMapUtils.java
@@ -40,10 +40,10 @@ import org.apache.cayenne.map.ObjAttribute;
 import org.apache.cayenne.map.ObjEntity;
 import org.apache.cayenne.map.ObjRelationship;
 import org.apache.cayenne.map.PathComponent;
+import org.apache.cayenne.map.QueryDescriptor;
+import org.apache.cayenne.map.SelectQueryDescriptor;
 import org.apache.cayenne.map.naming.NameConverter;
 import org.apache.cayenne.query.Ordering;
-import org.apache.cayenne.query.Query;
-import org.apache.cayenne.query.SelectQuery;
 import org.apache.cayenne.util.CayenneMapEntry;
 import org.apache.commons.collections.set.ListOrderedSet;
 
@@ -63,7 +63,7 @@ public class DataMapUtils {
 	 * @param query
 	 * @return Method name that perform query.
 	 */
-	public String getQueryMethodName(Query query) {
+	public String getQueryMethodName(QueryDescriptor query) {
 		return NameConverter.underscoredToJava(query.getName(), true);
 	}
 
@@ -73,7 +73,7 @@ public class DataMapUtils {
 	 * @param query
 	 * @return Parameter names.
 	 */
-	public Collection getParameterNames(SelectQuery<?> query) {
+	public Collection getParameterNames(SelectQueryDescriptor query) {
 
 		if (query.getQualifier() == null) {
 			return Collections.EMPTY_SET;
@@ -89,7 +89,7 @@ public class DataMapUtils {
 		return parseQualifier(query.getQualifier().toString());
 	}
 
-	public Boolean isValidParameterNames(SelectQuery<?> query) {
+	public Boolean isValidParameterNames(SelectQueryDescriptor query) {
 
 		if (query.getQualifier() == null) {
 			return true;
@@ -106,18 +106,16 @@ public class DataMapUtils {
 			}
 		}
 
-		if (query instanceof SelectQuery) {
-			for (Ordering ordering : ((SelectQuery<?>) query).getOrderings()) {
-				// validate paths in ordering
-				String path = ordering.getSortSpecString();
-				Iterator<CayenneMapEntry> it = ((ObjEntity) query.getRoot()).resolvePathComponents(path);
-				while (it.hasNext()) {
-					try {
-						it.next();
-					} catch (ExpressionException e) {
-						// if we have wrong path in orderings return false.
-						return false;
-					}
+		for (Ordering ordering : query.getOrderings()) {
+			// validate paths in ordering
+			String path = ordering.getSortSpecString();
+			Iterator<CayenneMapEntry> it = ((ObjEntity) query.getRoot()).resolvePathComponents(path);
+			while (it.hasNext()) {
+				try {
+					it.next();
+				} catch (ExpressionException e) {
+					// if we have wrong path in orderings return false.
+					return false;
 				}
 			}
 		}
@@ -144,7 +142,7 @@ public class DataMapUtils {
 		return result;
 	}
 
-	public boolean hasParameters(SelectQuery<?> query) {
+	public boolean hasParameters(SelectQueryDescriptor query) {
 		Map queryParameters = queriesMap.get(query.getName());
 
 		if (queryParameters == null) {
@@ -162,7 +160,7 @@ public class DataMapUtils {
 	 * @param name
 	 * @return Parameter type.
 	 */
-	public String getParameterType(SelectQuery<?> query, String name) {
+	public String getParameterType(SelectQueryDescriptor query, String name) {
 		return queriesMap.get(query.getName()).get(name);
 	}
 


Mime
View raw message