cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bfede...@apache.org
Subject [07/31] git commit: updated refs/heads/ui-restyle to ef74127
Date Mon, 30 Sep 2013 21:52:06 GMT
Changed SearchCriteria2 to GenericQueryBuilder to reflect the same placement


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

Branch: refs/heads/ui-restyle
Commit: 38e69fb9f99d0a544b7ef0036db16b6d90a731cf
Parents: e8cac2c
Author: Alex Huang <alex.huang@citrix.com>
Authored: Fri Sep 27 17:12:37 2013 -0700
Committer: Alex Huang <alex.huang@citrix.com>
Committed: Sat Sep 28 07:53:27 2013 -0700

----------------------------------------------------------------------
 .../com/cloud/utils/db/GenericQueryBuilder.java | 47 ++++++++++++++++++--
 .../cloud/utils/db/GenericSearchBuilder.java    | 47 ++++----------------
 2 files changed, 53 insertions(+), 41 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/38e69fb9/framework/db/src/com/cloud/utils/db/GenericQueryBuilder.java
----------------------------------------------------------------------
diff --git a/framework/db/src/com/cloud/utils/db/GenericQueryBuilder.java b/framework/db/src/com/cloud/utils/db/GenericQueryBuilder.java
index 8581d80..570a10e 100755
--- a/framework/db/src/com/cloud/utils/db/GenericQueryBuilder.java
+++ b/framework/db/src/com/cloud/utils/db/GenericQueryBuilder.java
@@ -44,6 +44,11 @@ public class GenericQueryBuilder<T, K> extends SearchBase<T, K>
{
         return create(entityType, entityType);
     }
 
+    public GenericQueryBuilder<T, K> or() {
+        constructCondition(null, " OR ", null, null);
+        return this;
+    }
+
     public void selectField(Object... useless) {
         assert _entity != null : "SearchBuilder cannot be modified once it has been setup";
         assert _specifiedAttrs.size() > 0 : "You didn't specify any attributes";
@@ -66,10 +71,48 @@ public class GenericQueryBuilder<T, K> extends SearchBase<T,
K> {
         _specifiedAttrs.clear();
     }
 
-    public void and(Object useless, Op op, Object... values) {
+    public GenericQueryBuilder<T, K> and(Object useless, Op op, Object... values) {
         String uuid = UUID.randomUUID().toString();
         Condition condition = constructCondition(uuid, " AND ", _specifiedAttrs.get(0), op);
         condition.setPresets(values);
+        return this;
+    }
+
+    public GenericQueryBuilder<T, K> or(Object useless, Op op, Object... values) {
+        String uuid = UUID.randomUUID().toString();
+        Condition condition = constructCondition(uuid, " OR ", _specifiedAttrs.get(0), op);
+        condition.setPresets(values);
+        return this;
+    }
+
+    protected GenericQueryBuilder<T, K> left(Object useless, Op op, Object... values)
{
+        String uuid = UUID.randomUUID().toString();
+        Condition condition = constructCondition(uuid, " ( ", _specifiedAttrs.get(0), op);
+        condition.setPresets(values);
+        return this;
+    }
+
+    public GenericQueryBuilder<T, K> and() {
+        constructCondition(null, " AND ", null, null);
+        return this;
+    }
+
+    public GenericQueryBuilder<T, K> where() {
+        return and();
+    }
+
+    public GenericQueryBuilder<T, K> op(Object useless, Op op, Object... values) {
+        return left(useless, op, values);
+    }
+
+    protected GenericQueryBuilder<T, K> right() {
+        Condition condition = new Condition("rp", " ) ", null, Op.RP);
+        _conditions.add(condition);
+        return this;
+    }
+
+    public GenericQueryBuilder<T, K> cp() {
+        return right();
     }
 
     @SuppressWarnings("unchecked")
@@ -96,6 +139,4 @@ public class GenericQueryBuilder<T, K> extends SearchBase<T, K>
{
         SearchCriteria sc1 = create();
         return (K)_dao.findOneBy(sc1);
     }
-
-
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/38e69fb9/framework/db/src/com/cloud/utils/db/GenericSearchBuilder.java
----------------------------------------------------------------------
diff --git a/framework/db/src/com/cloud/utils/db/GenericSearchBuilder.java b/framework/db/src/com/cloud/utils/db/GenericSearchBuilder.java
index 8e46c30..e171635 100755
--- a/framework/db/src/com/cloud/utils/db/GenericSearchBuilder.java
+++ b/framework/db/src/com/cloud/utils/db/GenericSearchBuilder.java
@@ -127,6 +127,11 @@ public class GenericSearchBuilder<T, K> extends SearchBase<T,
K> {
         return this;
     }
     
+    public GenericSearchBuilder<T, K> and() {
+        constructCondition(null, " AND ", null, null);
+        return this;
+    }
+
     public GenericSearchBuilder<T, K> and(Object useless, Op op, String name) {
         constructCondition(name, " AND ", _specifiedAttrs.get(0), op);
         return this;
@@ -137,24 +142,11 @@ public class GenericSearchBuilder<T, K> extends SearchBase<T,
K> {
         return new Preset(this, condition);
     }
 
-    public GenericSearchBuilder<T, K> and() {
-        constructCondition(null, " AND ", null, null);
-        return this;
-    }
-    
-    public GenericSearchBuilder<T, K> where() {
-        return and();
-    }
-    
     public GenericSearchBuilder<T, K> or() {
         constructCondition(null, " OR ", null, null);
         return this;
     }
     
-    public GenericSearchBuilder<T, K> where(String name, Object useless, Op op) {
-        return and(name, useless, op);
-    }
-    
     public GenericSearchBuilder<T, K> where(Object useless, Op op, String name) {
         return and(name, useless, op);
     }
@@ -163,17 +155,12 @@ public class GenericSearchBuilder<T, K> extends SearchBase<T,
K> {
         return and(useless, op);
     }
 
-    public GenericSearchBuilder<T, K> left(String name, Object useless, Op op) {
-        constructCondition(name, " ( ", _specifiedAttrs.get(0), op);
-        return this;
-    }
-    
-    public GenericSearchBuilder<T, K> left(Object useless, Op op, String name) {
+    protected GenericSearchBuilder<T, K> left(Object useless, Op op, String name) {
         constructCondition(name, " ( ", _specifiedAttrs.get(0), op);
         return this;
     }
 
-    public Preset left(Object useless, Op op) {
+    protected Preset left(Object useless, Op op) {
         Condition condition = constructCondition(UUID.randomUUID().toString(), " ( ", _specifiedAttrs.get(0),
op);
         return new Preset(this, condition);
     }
@@ -187,21 +174,9 @@ public class GenericSearchBuilder<T, K> extends SearchBase<T,
K> {
     }
 
     public GenericSearchBuilder<T, K> op(String name, Object useless, Op op) {
-        return left(name, useless, op);
-    }
-    
-    public GenericSearchBuilder<T, K> openParen(Object useless, Op op, String name)
{
-        return left(name, useless, op);
-    }
-
-    public GenericSearchBuilder<T, K> openParen(String name, Object useless, Op op)
{
-        return left(name, useless, op);
+        return left(useless, op, name);
     }
     
-    public Preset openParen(Object useless, Op op) {
-        return left(useless, op);
-    }
-
     public GroupBy<GenericSearchBuilder<T, K>, T, K> groupBy(Object... useless)
{
         assert _groupBy == null : "Can't do more than one group bys";
         GroupBy<GenericSearchBuilder<T, K>, T, K> groupBy = new GroupBy<GenericSearchBuilder<T,
K>, T, K>(this);
@@ -258,7 +233,7 @@ public class GenericSearchBuilder<T, K> extends SearchBase<T,
K> {
         return sc;
     }
     
-    public GenericSearchBuilder<T, K> right() {
+    protected GenericSearchBuilder<T, K> right() {
         Condition condition = new Condition("rp", " ) ", null, Op.RP);
         _conditions.add(condition);
         return this;
@@ -268,10 +243,6 @@ public class GenericSearchBuilder<T, K> extends SearchBase<T,
K> {
         return right();
     }
     
-    public GenericSearchBuilder<T, K> closeParen() {
-        return right();
-    }
-    
     /**
      * Marks the SearchBuilder as completed in building the search conditions.
      */


Mime
View raw message