cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bfede...@apache.org
Subject [06/31] git commit: updated refs/heads/ui-restyle to ef74127
Date Mon, 30 Sep 2013 21:52:05 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/e8cac2c5
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/e8cac2c5
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/e8cac2c5

Branch: refs/heads/ui-restyle
Commit: e8cac2c5d8b9fa8d1aac2aedc4ad473534f43ad8
Parents: e298890
Author: Alex Huang <alex.huang@citrix.com>
Authored: Fri Sep 27 16:57:25 2013 -0700
Committer: Alex Huang <alex.huang@citrix.com>
Committed: Sat Sep 28 07:53:26 2013 -0700

----------------------------------------------------------------------
 .../cloud/network/VirtualRouterProvider.java    |   4 +-
 .../element/VirtualRouterElementService.java    |   4 +-
 .../router/CreateVirtualRouterElementCmd.java   |  14 +-
 .../cloud/agent/manager/AgentManagerImpl.java   |   4 +-
 .../manager/ClusteredAgentManagerImpl.java      |  19 +-
 .../ClusterBasedAgentLoadBalancerPlanner.java   |  22 +-
 .../dc/dao/StorageNetworkIpRangeDaoImpl.java    |   6 +-
 .../network/dao/VirtualRouterProviderDao.java   |  10 +-
 .../dao/VirtualRouterProviderDaoImpl.java       |  10 +-
 .../element/VirtualRouterProviderVO.java        |   8 +-
 .../com/cloud/user/AccountDetailsDaoImpl.java   |   6 +-
 .../datastore/db/PrimaryDataStoreDaoImpl.java   |  21 +-
 .../cache/manager/StorageCacheManagerImpl.java  |  61 +--
 .../StorageCacheReplacementAlgorithmLRU.java    |  64 +--
 .../storage/snapshot/SnapshotObject.java        | 109 ++---
 .../endpoint/DefaultEndPointSelector.java       |  16 +-
 .../db/TemplatePrimaryDataStoreDaoImpl.java     |  10 +-
 .../com/cloud/utils/db/GenericQueryBuilder.java |  67 +--
 .../cloud/utils/db/GenericSearchBuilder.java    |  45 ++
 .../BareMetalPingServiceImpl.java               |   4 +-
 .../networkservice/BaremetalDhcpElement.java    |  35 +-
 .../BaremetalDhcpManagerImpl.java               |   2 +-
 .../BaremetalKickStartServiceImpl.java          |   4 +-
 .../networkservice/BaremetalPxeElement.java     |   2 +-
 .../networkservice/BaremetalPxeManagerImpl.java |   2 +-
 .../com/cloud/ovm/hypervisor/OvmDiscoverer.java | 440 +++++++++----------
 .../com/cloud/ucs/manager/UcsManagerImpl.java   |  14 +-
 .../xen/discoverer/XcpServerDiscoverer.java     |   2 +-
 .../lb/ElasticLoadBalancerManagerImpl.java      |   4 +-
 .../element/InternalLoadBalancerElement.java    |  27 +-
 .../lb/InternalLoadBalancerVMManagerImpl.java   |   6 +-
 .../InternalLbElementServiceTest.java           |   8 +-
 .../InternalLbElementTest.java                  |  16 +-
 server/src/com/cloud/api/ApiResponseHelper.java |   6 +-
 .../consoleproxy/ConsoleProxyManagerImpl.java   |   4 +-
 .../com/cloud/ha/AbstractInvestigatorImpl.java  |  18 +-
 .../com/cloud/network/NetworkServiceImpl.java   |   6 +-
 .../network/StorageNetworkManagerImpl.java      |   2 +-
 .../network/element/VirtualRouterElement.java   | 127 +++---
 .../element/VpcVirtualRouterElement.java        |  10 +-
 .../VirtualNetworkApplianceManagerImpl.java     |   8 +-
 .../VpcVirtualNetworkApplianceManagerImpl.java  |   8 +-
 .../com/cloud/resource/ResourceManagerImpl.java |  85 ++--
 .../src/com/cloud/storage/OCFS2ManagerImpl.java |   8 +-
 .../secondary/SecondaryStorageManagerImpl.java  |  18 +-
 45 files changed, 672 insertions(+), 694 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e8cac2c5/api/src/com/cloud/network/VirtualRouterProvider.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/network/VirtualRouterProvider.java b/api/src/com/cloud/network/VirtualRouterProvider.java
index f67686e..02efb93 100644
--- a/api/src/com/cloud/network/VirtualRouterProvider.java
+++ b/api/src/com/cloud/network/VirtualRouterProvider.java
@@ -20,14 +20,14 @@ import org.apache.cloudstack.api.Identity;
 import org.apache.cloudstack.api.InternalIdentity;
 
 public interface VirtualRouterProvider extends InternalIdentity, Identity {
-    public enum VirtualRouterProviderType {
+    public enum Type {
         VirtualRouter,
         ElasticLoadBalancerVm,
         VPCVirtualRouter,
         InternalLbVm
     }
 
-    public VirtualRouterProviderType getType();
+    public Type getType();
 
     public boolean isEnabled();
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e8cac2c5/api/src/com/cloud/network/element/VirtualRouterElementService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/network/element/VirtualRouterElementService.java b/api/src/com/cloud/network/element/VirtualRouterElementService.java
index ea971b8..b0db3d9 100644
--- a/api/src/com/cloud/network/element/VirtualRouterElementService.java
+++ b/api/src/com/cloud/network/element/VirtualRouterElementService.java
@@ -22,12 +22,12 @@ import org.apache.cloudstack.api.command.admin.router.ConfigureVirtualRouterElem
 import org.apache.cloudstack.api.command.admin.router.ListVirtualRouterElementsCmd;
 
 import com.cloud.network.VirtualRouterProvider;
-import com.cloud.network.VirtualRouterProvider.VirtualRouterProviderType;
+import com.cloud.network.VirtualRouterProvider.Type;
 import com.cloud.utils.component.PluggableService;
 
 public interface VirtualRouterElementService extends PluggableService{
     VirtualRouterProvider configure(ConfigureVirtualRouterElementCmd cmd);
-    VirtualRouterProvider addElement(Long nspId, VirtualRouterProviderType providerType);
+    VirtualRouterProvider addElement(Long nspId, Type providerType);
     VirtualRouterProvider getCreatedElement(long id);
     List<? extends VirtualRouterProvider> searchForVirtualRouterElement(ListVirtualRouterElementsCmd cmd);
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e8cac2c5/api/src/org/apache/cloudstack/api/command/admin/router/CreateVirtualRouterElementCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/router/CreateVirtualRouterElementCmd.java b/api/src/org/apache/cloudstack/api/command/admin/router/CreateVirtualRouterElementCmd.java
index 66c8ae5..35da697 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/router/CreateVirtualRouterElementCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/router/CreateVirtualRouterElementCmd.java
@@ -36,7 +36,7 @@ import com.cloud.event.EventTypes;
 import com.cloud.exception.InvalidParameterValueException;
 import com.cloud.exception.ResourceAllocationException;
 import com.cloud.network.VirtualRouterProvider;
-import com.cloud.network.VirtualRouterProvider.VirtualRouterProviderType;
+import com.cloud.network.VirtualRouterProvider.Type;
 import com.cloud.network.element.VirtualRouterElementService;
 import com.cloud.user.Account;
 
@@ -70,15 +70,15 @@ public class CreateVirtualRouterElementCmd extends BaseAsyncCreateCmd {
         return nspId;
     }
     
-    public VirtualRouterProviderType getProviderType() {
+    public Type getProviderType() {
         if (providerType != null) {
-            if (providerType.equalsIgnoreCase(VirtualRouterProviderType.VirtualRouter.toString())) {
-                return VirtualRouterProviderType.VirtualRouter;
-            } else if (providerType.equalsIgnoreCase(VirtualRouterProviderType.VPCVirtualRouter.toString())) {
-                return VirtualRouterProviderType.VPCVirtualRouter;
+            if (providerType.equalsIgnoreCase(Type.VirtualRouter.toString())) {
+                return Type.VirtualRouter;
+            } else if (providerType.equalsIgnoreCase(Type.VPCVirtualRouter.toString())) {
+                return Type.VPCVirtualRouter;
             } else throw new InvalidParameterValueException("Invalid providerType specified");
         } 
-        return VirtualRouterProviderType.VirtualRouter;
+        return Type.VirtualRouter;
     }
 
     /////////////////////////////////////////////////////

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e8cac2c5/engine/orchestration/src/com/cloud/agent/manager/AgentManagerImpl.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/com/cloud/agent/manager/AgentManagerImpl.java b/engine/orchestration/src/com/cloud/agent/manager/AgentManagerImpl.java
index 4e11772..9c18753 100755
--- a/engine/orchestration/src/com/cloud/agent/manager/AgentManagerImpl.java
+++ b/engine/orchestration/src/com/cloud/agent/manager/AgentManagerImpl.java
@@ -1449,7 +1449,7 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl
                 List<Long> behindAgents = findAgentsBehindOnPing();
                 for (Long agentId : behindAgents) {
                     GenericQueryBuilder<HostVO, HostVO> sc = GenericQueryBuilder.create(HostVO.class);
-                    sc.addAnd(sc.getEntity().getId(), Op.EQ, agentId);
+                    sc.and(sc.entity().getId(), Op.EQ, agentId);
                     HostVO h = sc.find();
                     if (h != null) {
                         ResourceState resourceState = h.getResourceState();
@@ -1471,7 +1471,7 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl
                 }
 
                 GenericQueryBuilder<HostVO, HostVO> sc = GenericQueryBuilder.create(HostVO.class);
-                sc.addAnd(sc.getEntity().getResourceState(), Op.IN, ResourceState.PrepareForMaintenance, ResourceState.ErrorInMaintenance);
+                sc.and(sc.entity().getResourceState(), Op.IN, ResourceState.PrepareForMaintenance, ResourceState.ErrorInMaintenance);
                 List<HostVO> hosts = sc.list();
 
                 for (HostVO host : hosts) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e8cac2c5/engine/orchestration/src/com/cloud/agent/manager/ClusteredAgentManagerImpl.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/com/cloud/agent/manager/ClusteredAgentManagerImpl.java b/engine/orchestration/src/com/cloud/agent/manager/ClusteredAgentManagerImpl.java
index 3fcd656..76e1d8e 100755
--- a/engine/orchestration/src/com/cloud/agent/manager/ClusteredAgentManagerImpl.java
+++ b/engine/orchestration/src/com/cloud/agent/manager/ClusteredAgentManagerImpl.java
@@ -87,9 +87,8 @@ import com.cloud.serializer.GsonHelper;
 import com.cloud.utils.DateUtil;
 import com.cloud.utils.Profiler;
 import com.cloud.utils.concurrency.NamedThreadFactory;
+import com.cloud.utils.db.QueryBuilder;
 import com.cloud.utils.db.SearchCriteria.Op;
-import com.cloud.utils.db.GenericQueryBuilder;
-import com.cloud.utils.db.GenericQueryBuilder;
 import com.cloud.utils.db.Transaction;
 import com.cloud.utils.exception.CloudRuntimeException;
 import com.cloud.utils.nio.Link;
@@ -783,9 +782,9 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
     public void startRebalanceAgents() {
         s_logger.debug("Management server " + _nodeId + " is asking other peers to rebalance their agents");
         List<ManagementServerHostVO> allMS = _mshostDao.listBy(ManagementServerHost.State.Up);
-        GenericQueryBuilder<HostVO, HostVO> sc = GenericQueryBuilder.create(HostVO.class);
-        sc.addAnd(sc.getEntity().getManagementServerId(), Op.NNULL);
-        sc.addAnd(sc.getEntity().getType(), Op.EQ, Host.Type.Routing);
+        QueryBuilder<HostVO> sc = QueryBuilder.create(HostVO.class);
+        sc.and(sc.entity().getManagementServerId(), Op.NNULL);
+        sc.and(sc.entity().getType(), Op.EQ, Host.Type.Routing);
         List<HostVO> allManagedAgents = sc.list();
 
         int avLoad = 0;
@@ -1369,13 +1368,13 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
         profilerAgentLB.start();
         //initiate agent lb task will be scheduled and executed only once, and only when number of agents loaded exceeds _connectedAgentsThreshold
         if (EnableLB.value() && !_agentLbHappened) {
-            GenericQueryBuilder<HostVO, HostVO> sc = GenericQueryBuilder.create(HostVO.class);
-            sc.addAnd(sc.getEntity().getManagementServerId(), Op.NNULL);
-            sc.addAnd(sc.getEntity().getType(), Op.EQ, Host.Type.Routing);
+            QueryBuilder<HostVO> sc = QueryBuilder.create(HostVO.class);
+            sc.and(sc.entity().getManagementServerId(), Op.NNULL);
+            sc.and(sc.entity().getType(), Op.EQ, Host.Type.Routing);
             List<HostVO> allManagedRoutingAgents = sc.list();
 
-            sc = GenericQueryBuilder.create(HostVO.class);
-            sc.addAnd(sc.getEntity().getType(), Op.EQ, Host.Type.Routing);
+            sc = QueryBuilder.create(HostVO.class);
+            sc.and(sc.entity().getType(), Op.EQ, Host.Type.Routing);
             List<HostVO> allAgents = sc.list();
             double allHostsCount = allAgents.size();
             double managedHostsCount = allManagedRoutingAgents.size();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e8cac2c5/engine/orchestration/src/com/cloud/cluster/agentlb/ClusterBasedAgentLoadBalancerPlanner.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/com/cloud/cluster/agentlb/ClusterBasedAgentLoadBalancerPlanner.java b/engine/orchestration/src/com/cloud/cluster/agentlb/ClusterBasedAgentLoadBalancerPlanner.java
index 429e824..1d744b7 100755
--- a/engine/orchestration/src/com/cloud/cluster/agentlb/ClusterBasedAgentLoadBalancerPlanner.java
+++ b/engine/orchestration/src/com/cloud/cluster/agentlb/ClusterBasedAgentLoadBalancerPlanner.java
@@ -26,7 +26,6 @@ import java.util.Map;
 
 import javax.ejb.Local;
 import javax.inject.Inject;
-import javax.naming.ConfigurationException;
 
 import org.apache.log4j.Logger;
 import org.springframework.stereotype.Component;
@@ -36,9 +35,8 @@ import com.cloud.host.HostVO;
 import com.cloud.host.Status;
 import com.cloud.host.dao.HostDao;
 import com.cloud.utils.component.AdapterBase;
-import com.cloud.utils.db.GenericQueryBuilder;
+import com.cloud.utils.db.QueryBuilder;
 import com.cloud.utils.db.SearchCriteria.Op;
-import com.cloud.utils.db.GenericQueryBuilder;
 
 @Component
 @Local(value=AgentLoadBalancerPlanner.class)
@@ -49,9 +47,9 @@ public class ClusterBasedAgentLoadBalancerPlanner extends AdapterBase implements
     
     @Override
     public List<HostVO> getHostsToRebalance(long msId, int avLoad) {
-    	GenericQueryBuilder<HostVO, HostVO> sc = GenericQueryBuilder.create(HostVO.class);
-    	sc.addAnd(sc.getEntity().getType(), Op.EQ, Host.Type.Routing);
-    	sc.addAnd(sc.getEntity().getManagementServerId(), Op.EQ, msId);
+        QueryBuilder<HostVO> sc = QueryBuilder.create(HostVO.class);
+        sc.and(sc.entity().getType(), Op.EQ, Host.Type.Routing);
+        sc.and(sc.entity().getManagementServerId(), Op.EQ, msId);
         List<HostVO> allHosts = sc.list();
  
         if (allHosts.size() <= avLoad) {
@@ -59,15 +57,15 @@ public class ClusterBasedAgentLoadBalancerPlanner extends AdapterBase implements
             return null;
         }
         
-        sc = GenericQueryBuilder.create(HostVO.class);
-        sc.addAnd(sc.getEntity().getManagementServerId(), Op.EQ, msId);
-        sc.addAnd(sc.getEntity().getStatus(), Op.EQ, Status.Up);
+        sc = QueryBuilder.create(HostVO.class);
+        sc.and(sc.entity().getManagementServerId(), Op.EQ, msId);
+        sc.and(sc.entity().getStatus(), Op.EQ, Status.Up);
         List<HostVO> directHosts = sc.list();
         
         if (directHosts.isEmpty()) {
             s_logger.debug("No direct agents in status " + Status.Up + " exist for the management server " + msId + "; so it doesn't participate in agent rebalancing process");
             return null;
-        } 
+        }
         
        
         Map<Long, List<HostVO>> hostToClusterMap = new HashMap<Long, List<HostVO>>();
@@ -91,7 +89,7 @@ public class ClusterBasedAgentLoadBalancerPlanner extends AdapterBase implements
         int hostsLeft = directHosts.size();
         List<HostVO> hostsToReturn = new ArrayList<HostVO>();
         
-        s_logger.debug("Management server " + msId + " can give away " + hostsToGive + " as it currently owns " + allHosts.size() + 
+        s_logger.debug("Management server " + msId + " can give away " + hostsToGive + " as it currently owns " + allHosts.size() +
                 " and the average agent load in the system is " + avLoad + "; finalyzing list of hosts to give away...");
         for (Long cluster : hostToClusterMap.keySet()) {
             List<HostVO> hostsInCluster = hostToClusterMap.get(cluster);
@@ -105,7 +103,7 @@ public class ClusterBasedAgentLoadBalancerPlanner extends AdapterBase implements
                         continue;
                     } else {
                         break;
-                    }  
+                    }
                 } else {
                     s_logger.debug("Taking all " + hostsInCluster.size() + " hosts: " + hostsInCluster + " from cluster id=" + cluster);
                     hostsToReturn.addAll(hostsInCluster);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e8cac2c5/engine/schema/src/com/cloud/dc/dao/StorageNetworkIpRangeDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/dc/dao/StorageNetworkIpRangeDaoImpl.java b/engine/schema/src/com/cloud/dc/dao/StorageNetworkIpRangeDaoImpl.java
index 04bac51..f57acce 100755
--- a/engine/schema/src/com/cloud/dc/dao/StorageNetworkIpRangeDaoImpl.java
+++ b/engine/schema/src/com/cloud/dc/dao/StorageNetworkIpRangeDaoImpl.java
@@ -51,21 +51,21 @@ public class StorageNetworkIpRangeDaoImpl extends GenericDaoBase<StorageNetworkI
 	@Override
     public List<StorageNetworkIpRangeVO> listByPodId(long podId) {
 		GenericQueryBuilder<StorageNetworkIpRangeVO, StorageNetworkIpRangeVO> sc = GenericQueryBuilder.create(StorageNetworkIpRangeVO.class);
-	    sc.addAnd(sc.getEntity().getPodId(), Op.EQ, podId);
+	    sc.and(sc.entity().getPodId(), Op.EQ, podId);
 		return sc.list();
     }
 
 	@Override
     public List<StorageNetworkIpRangeVO> listByRangeId(long rangeId) {
 		GenericQueryBuilder<StorageNetworkIpRangeVO, StorageNetworkIpRangeVO> sc = GenericQueryBuilder.create(StorageNetworkIpRangeVO.class);
-	    sc.addAnd(sc.getEntity().getId(), Op.EQ, rangeId);
+	    sc.and(sc.entity().getId(), Op.EQ, rangeId);
 		return sc.list();
     }
 
 	@Override
     public List<StorageNetworkIpRangeVO> listByDataCenterId(long dcId) {
 		GenericQueryBuilder<StorageNetworkIpRangeVO, StorageNetworkIpRangeVO> sc = GenericQueryBuilder.create(StorageNetworkIpRangeVO.class);
-	    sc.addAnd(sc.getEntity().getDataCenterId(), Op.EQ, dcId);
+	    sc.and(sc.entity().getDataCenterId(), Op.EQ, dcId);
 		return sc.list();
     }
 	

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e8cac2c5/engine/schema/src/com/cloud/network/dao/VirtualRouterProviderDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/dao/VirtualRouterProviderDao.java b/engine/schema/src/com/cloud/network/dao/VirtualRouterProviderDao.java
index d929293..70d7130 100644
--- a/engine/schema/src/com/cloud/network/dao/VirtualRouterProviderDao.java
+++ b/engine/schema/src/com/cloud/network/dao/VirtualRouterProviderDao.java
@@ -20,12 +20,12 @@ import java.util.List;
 
 import com.cloud.network.VirtualRouterProvider;
 import com.cloud.network.element.VirtualRouterProviderVO;
-import com.cloud.network.VirtualRouterProvider.VirtualRouterProviderType;
+import com.cloud.network.VirtualRouterProvider.Type;
 import com.cloud.utils.db.GenericDao;
 
 public interface VirtualRouterProviderDao extends GenericDao<VirtualRouterProviderVO, Long> {
-    public VirtualRouterProviderVO findByNspIdAndType(long nspId, VirtualRouterProviderType type);
-    public List<VirtualRouterProviderVO> listByEnabledAndType(boolean enabled, VirtualRouterProviderType type);
-    public VirtualRouterProviderVO findByIdAndEnabledAndType(long id, boolean enabled, VirtualRouterProviderType type);
-    public List<VirtualRouterProviderVO> listByType(VirtualRouterProviderType type);
+    public VirtualRouterProviderVO findByNspIdAndType(long nspId, Type type);
+    public List<VirtualRouterProviderVO> listByEnabledAndType(boolean enabled, Type type);
+    public VirtualRouterProviderVO findByIdAndEnabledAndType(long id, boolean enabled, Type type);
+    public List<VirtualRouterProviderVO> listByType(Type type);
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e8cac2c5/engine/schema/src/com/cloud/network/dao/VirtualRouterProviderDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/dao/VirtualRouterProviderDaoImpl.java b/engine/schema/src/com/cloud/network/dao/VirtualRouterProviderDaoImpl.java
index dba835f..1c5d27e 100644
--- a/engine/schema/src/com/cloud/network/dao/VirtualRouterProviderDaoImpl.java
+++ b/engine/schema/src/com/cloud/network/dao/VirtualRouterProviderDaoImpl.java
@@ -23,7 +23,7 @@ import javax.ejb.Local;
 import org.springframework.stereotype.Component;
 
 import com.cloud.network.element.VirtualRouterProviderVO;
-import com.cloud.network.VirtualRouterProvider.VirtualRouterProviderType;
+import com.cloud.network.VirtualRouterProvider.Type;
 import com.cloud.utils.db.DB;
 import com.cloud.utils.db.GenericDaoBase;
 import com.cloud.utils.db.SearchBuilder;
@@ -46,7 +46,7 @@ public class VirtualRouterProviderDaoImpl extends GenericDaoBase<VirtualRouterPr
     }
 
     @Override
-    public VirtualRouterProviderVO findByNspIdAndType(long nspId, VirtualRouterProviderType type) {
+    public VirtualRouterProviderVO findByNspIdAndType(long nspId, Type type) {
         SearchCriteria<VirtualRouterProviderVO> sc = AllFieldsSearch.create();
         sc.setParameters("nsp_id", nspId);
         sc.setParameters("type", type);
@@ -54,7 +54,7 @@ public class VirtualRouterProviderDaoImpl extends GenericDaoBase<VirtualRouterPr
     }
     
     @Override
-    public List<VirtualRouterProviderVO> listByEnabledAndType(boolean enabled, VirtualRouterProviderType type) {
+    public List<VirtualRouterProviderVO> listByEnabledAndType(boolean enabled, Type type) {
         SearchCriteria<VirtualRouterProviderVO> sc = AllFieldsSearch.create();
         sc.setParameters("enabled", enabled);
         sc.setParameters("type", type);
@@ -62,7 +62,7 @@ public class VirtualRouterProviderDaoImpl extends GenericDaoBase<VirtualRouterPr
     }
     
     @Override
-    public VirtualRouterProviderVO findByIdAndEnabledAndType(long id, boolean enabled, VirtualRouterProviderType type) {
+    public VirtualRouterProviderVO findByIdAndEnabledAndType(long id, boolean enabled, Type type) {
         SearchCriteria<VirtualRouterProviderVO> sc = AllFieldsSearch.create();
         sc.setParameters("id", id);
         sc.setParameters("enabled", enabled);
@@ -71,7 +71,7 @@ public class VirtualRouterProviderDaoImpl extends GenericDaoBase<VirtualRouterPr
     }
 
     @Override
-    public List<VirtualRouterProviderVO> listByType(VirtualRouterProviderType type) {
+    public List<VirtualRouterProviderVO> listByType(Type type) {
         SearchCriteria<VirtualRouterProviderVO> sc = AllFieldsSearch.create();
         sc.setParameters("type", type);
         return listBy(sc);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e8cac2c5/engine/schema/src/com/cloud/network/element/VirtualRouterProviderVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/element/VirtualRouterProviderVO.java b/engine/schema/src/com/cloud/network/element/VirtualRouterProviderVO.java
index ff2b621..62a25c1 100644
--- a/engine/schema/src/com/cloud/network/element/VirtualRouterProviderVO.java
+++ b/engine/schema/src/com/cloud/network/element/VirtualRouterProviderVO.java
@@ -42,7 +42,7 @@ public class VirtualRouterProviderVO implements VirtualRouterProvider {
     
     @Column(name="type")
     @Enumerated(EnumType.STRING)
-    private VirtualRouterProviderType type;
+    private Type type;
     
     @Column(name="enabled")
     private boolean enabled;
@@ -60,7 +60,7 @@ public class VirtualRouterProviderVO implements VirtualRouterProvider {
         this.uuid = UUID.randomUUID().toString();
     }
     
-    public VirtualRouterProviderVO(long nspId, VirtualRouterProviderType type) {
+    public VirtualRouterProviderVO(long nspId, Type type) {
         this.nspId = nspId;
         this.type = type;
         this.uuid = UUID.randomUUID().toString();
@@ -81,7 +81,7 @@ public class VirtualRouterProviderVO implements VirtualRouterProvider {
     }
 
     @Override
-    public VirtualRouterProviderType getType() {
+    public Type getType() {
         return this.type;
     }
     
@@ -106,7 +106,7 @@ public class VirtualRouterProviderVO implements VirtualRouterProvider {
         this.id = id;
     }
 
-    public void setType(VirtualRouterProviderType type) {
+    public void setType(Type type) {
         this.type = type;
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e8cac2c5/engine/schema/src/com/cloud/user/AccountDetailsDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/user/AccountDetailsDaoImpl.java b/engine/schema/src/com/cloud/user/AccountDetailsDaoImpl.java
index 1d47fb6..81ae636 100755
--- a/engine/schema/src/com/cloud/user/AccountDetailsDaoImpl.java
+++ b/engine/schema/src/com/cloud/user/AccountDetailsDaoImpl.java
@@ -47,7 +47,7 @@ public class AccountDetailsDaoImpl extends GenericDaoBase<AccountDetailVO, Long>
     @Override
     public Map<String, String> findDetails(long accountId) {
         GenericQueryBuilder<AccountDetailVO, AccountDetailVO> sc = GenericQueryBuilder.create(AccountDetailVO.class);
-        sc.addAnd(sc.getEntity().getAccountId(), Op.EQ, accountId);
+        sc.and(sc.entity().getAccountId(), Op.EQ, accountId);
         List<AccountDetailVO> results = sc.list();
         Map<String, String> details = new HashMap<String, String>(results.size());
         for (AccountDetailVO r : results) {
@@ -73,8 +73,8 @@ public class AccountDetailsDaoImpl extends GenericDaoBase<AccountDetailVO, Long>
     @Override
     public AccountDetailVO findDetail(long accountId, String name) {
         GenericQueryBuilder<AccountDetailVO, AccountDetailVO> sc = GenericQueryBuilder.create(AccountDetailVO.class);
-        sc.addAnd(sc.getEntity().getAccountId(), Op.EQ, accountId);
-        sc.addAnd(sc.getEntity().getName(), Op.EQ, name);
+        sc.and(sc.entity().getAccountId(), Op.EQ, accountId);
+        sc.and(sc.entity().getName(), Op.EQ, name);
         return sc.find();
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e8cac2c5/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDaoImpl.java b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDaoImpl.java
index ccf9a1f..54a107b 100644
--- a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDaoImpl.java
+++ b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDaoImpl.java
@@ -35,12 +35,11 @@ import com.cloud.storage.StoragePoolStatus;
 import com.cloud.utils.db.DB;
 import com.cloud.utils.db.GenericDaoBase;
 import com.cloud.utils.db.GenericSearchBuilder;
+import com.cloud.utils.db.QueryBuilder;
 import com.cloud.utils.db.SearchBuilder;
 import com.cloud.utils.db.SearchCriteria;
 import com.cloud.utils.db.SearchCriteria.Func;
 import com.cloud.utils.db.SearchCriteria.Op;
-import com.cloud.utils.db.GenericQueryBuilder;
-import com.cloud.utils.db.GenericQueryBuilder;
 import com.cloud.utils.db.Transaction;
 import com.cloud.utils.exception.CloudRuntimeException;
 
@@ -316,10 +315,10 @@ public class PrimaryDataStoreDaoImpl extends GenericDaoBase<StoragePoolVO, Long>
     public List<StoragePoolVO> findZoneWideStoragePoolsByTags(long dcId, String[] tags) {
         List<StoragePoolVO> storagePools = null;
         if (tags == null || tags.length == 0) {
-            GenericQueryBuilder<StoragePoolVO, StoragePoolVO> sc = GenericQueryBuilder.create(StoragePoolVO.class);
-            sc.addAnd(sc.getEntity().getDataCenterId(), Op.EQ, dcId);
-            sc.addAnd(sc.getEntity().getStatus(), Op.EQ, Status.Up);
-            sc.addAnd(sc.getEntity().getScope(), Op.EQ, ScopeType.ZONE);
+            QueryBuilder<StoragePoolVO> sc = QueryBuilder.create(StoragePoolVO.class);
+            sc.and(sc.entity().getDataCenterId(), Op.EQ,dcId);
+            sc.and(sc.entity().getStatus(), Op.EQ,Status.Up);
+            sc.and(sc.entity().getScope(), Op.EQ,ScopeType.ZONE);
             return sc.list();
         } else {
             Map<String, String> details = tagsToDetails(tags);
@@ -421,11 +420,11 @@ public class PrimaryDataStoreDaoImpl extends GenericDaoBase<StoragePoolVO, Long>
 
     @Override
     public List<StoragePoolVO> findZoneWideStoragePoolsByHypervisor(long dataCenterId, HypervisorType hypervisorType) {
-        GenericQueryBuilder<StoragePoolVO, StoragePoolVO> sc =  GenericQueryBuilder.create(StoragePoolVO.class);
-        sc.addAnd(sc.getEntity().getDataCenterId(), Op.EQ, dataCenterId);
-        sc.addAnd(sc.getEntity().getStatus(), Op.EQ, Status.Up);
-        sc.addAnd(sc.getEntity().getScope(), Op.EQ, ScopeType.ZONE);
-        sc.addAnd(sc.getEntity().getHypervisor(), Op.EQ, hypervisorType);
+        QueryBuilder<StoragePoolVO> sc = QueryBuilder.create(StoragePoolVO.class);
+        sc.and(sc.entity().getDataCenterId(), Op.EQ,dataCenterId);
+        sc.and(sc.entity().getStatus(), Op.EQ,Status.Up);
+        sc.and(sc.entity().getScope(), Op.EQ,ScopeType.ZONE);
+        sc.and(sc.entity().getHypervisor(), Op.EQ,hypervisorType);
         return sc.list();
     }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e8cac2c5/engine/storage/cache/src/org/apache/cloudstack/storage/cache/manager/StorageCacheManagerImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/cache/src/org/apache/cloudstack/storage/cache/manager/StorageCacheManagerImpl.java b/engine/storage/cache/src/org/apache/cloudstack/storage/cache/manager/StorageCacheManagerImpl.java
index e869714..7f335c5 100644
--- a/engine/storage/cache/src/org/apache/cloudstack/storage/cache/manager/StorageCacheManagerImpl.java
+++ b/engine/storage/cache/src/org/apache/cloudstack/storage/cache/manager/StorageCacheManagerImpl.java
@@ -18,35 +18,46 @@
  */
 package org.apache.cloudstack.storage.cache.manager;
 
-import com.cloud.configuration.Config;
-import com.cloud.storage.DataStoreRole;
-import com.cloud.utils.NumbersUtil;
-import com.cloud.utils.component.Manager;
-import com.cloud.utils.concurrency.NamedThreadFactory;
-import com.cloud.utils.db.GlobalLock;
-import com.cloud.utils.db.SearchCriteria;
-import com.cloud.utils.db.GenericQueryBuilder;
-import com.cloud.utils.db.GenericQueryBuilder;
-import com.cloud.utils.exception.CloudRuntimeException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+
+import javax.inject.Inject;
+import javax.naming.ConfigurationException;
+
+import org.apache.log4j.Logger;
 
-import org.apache.cloudstack.engine.subsystem.api.storage.*;
+import org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataMotionService;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectInStore;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
+import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
 import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine.Event;
+import org.apache.cloudstack.engine.subsystem.api.storage.Scope;
+import org.apache.cloudstack.engine.subsystem.api.storage.StorageCacheManager;
 import org.apache.cloudstack.framework.async.AsyncCallFuture;
 import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
 import org.apache.cloudstack.storage.cache.allocator.StorageCacheAllocator;
 import org.apache.cloudstack.storage.datastore.ObjectInDataStoreManager;
 import org.apache.cloudstack.storage.datastore.db.ImageStoreVO;
 
-import org.apache.log4j.Logger;
-
-import javax.inject.Inject;
-import javax.naming.ConfigurationException;
-
-import java.util.*;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
+import com.cloud.configuration.Config;
+import com.cloud.storage.DataStoreRole;
+import com.cloud.utils.NumbersUtil;
+import com.cloud.utils.component.Manager;
+import com.cloud.utils.concurrency.NamedThreadFactory;
+import com.cloud.utils.db.GlobalLock;
+import com.cloud.utils.db.QueryBuilder;
+import com.cloud.utils.db.SearchCriteria;
+import com.cloud.utils.exception.CloudRuntimeException;
 
 public class StorageCacheManagerImpl implements StorageCacheManager, Manager {
     private static final Logger s_logger = Logger.getLogger(StorageCacheManagerImpl.class);
@@ -79,8 +90,8 @@ public class StorageCacheManagerImpl implements StorageCacheManager, Manager {
     }
 
     protected List<DataStore> getCacheStores() {
-        GenericQueryBuilder<ImageStoreVO, ImageStoreVO> sc = GenericQueryBuilder.create(ImageStoreVO.class);
-        sc.addAnd(sc.getEntity().getRole(), SearchCriteria.Op.EQ, DataStoreRole.ImageCache);
+        QueryBuilder<ImageStoreVO> sc = QueryBuilder.create(ImageStoreVO.class);
+        sc.and(sc.entity().getRole(), SearchCriteria.Op.EQ,DataStoreRole.ImageCache);
         List<ImageStoreVO> imageStoreVOs = sc.list();
         List<DataStore> stores = new ArrayList<DataStore>();
         for (ImageStoreVO vo : imageStoreVOs) {
@@ -232,7 +243,7 @@ public class StorageCacheManagerImpl implements StorageCacheManager, Manager {
 
     @Override
     public DataObject createCacheObject(DataObject data, Scope scope) {
-        DataStore cacheStore = this.getCacheStorage(scope);
+        DataStore cacheStore = getCacheStorage(scope);
 
         if (cacheStore == null)
         {
@@ -244,7 +255,7 @@ public class StorageCacheManagerImpl implements StorageCacheManager, Manager {
 
     @Override
     public DataObject getCacheObject(DataObject data, Scope scope) {
-        DataStore cacheStore = this.getCacheStorage(scope);
+        DataStore cacheStore = getCacheStorage(scope);
         DataObject objOnCacheStore = cacheStore.create(data);
         objOnCacheStore.incRefCount();
         return objOnCacheStore;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e8cac2c5/engine/storage/cache/src/org/apache/cloudstack/storage/cache/manager/StorageCacheReplacementAlgorithmLRU.java
----------------------------------------------------------------------
diff --git a/engine/storage/cache/src/org/apache/cloudstack/storage/cache/manager/StorageCacheReplacementAlgorithmLRU.java b/engine/storage/cache/src/org/apache/cloudstack/storage/cache/manager/StorageCacheReplacementAlgorithmLRU.java
index c59b060..fc96a0d 100644
--- a/engine/storage/cache/src/org/apache/cloudstack/storage/cache/manager/StorageCacheReplacementAlgorithmLRU.java
+++ b/engine/storage/cache/src/org/apache/cloudstack/storage/cache/manager/StorageCacheReplacementAlgorithmLRU.java
@@ -17,26 +17,28 @@
  * under the License.
  */
 package org.apache.cloudstack.storage.cache.manager;
-import com.cloud.configuration.Config;
-import com.cloud.utils.DateUtil;
-import com.cloud.utils.NumbersUtil;
-import com.cloud.utils.db.SearchCriteria;
-import com.cloud.utils.db.GenericQueryBuilder;
-import com.cloud.utils.db.GenericQueryBuilder;
+import java.util.Calendar;
+import java.util.Date;
 
-import org.apache.cloudstack.engine.subsystem.api.storage.*;
+import javax.annotation.PostConstruct;
+import javax.inject.Inject;
+
+import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
+import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
+import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotDataFactory;
+import org.apache.cloudstack.engine.subsystem.api.storage.TemplateDataFactory;
+import org.apache.cloudstack.engine.subsystem.api.storage.VolumeDataFactory;
 import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
 import org.apache.cloudstack.storage.datastore.db.SnapshotDataStoreVO;
 import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreVO;
 import org.apache.cloudstack.storage.datastore.db.VolumeDataStoreVO;
 
-import org.apache.commons.lang.math.NumberUtils;
-
-import java.util.Calendar;
-import java.util.Date;
-
-import javax.annotation.PostConstruct;
-import javax.inject.Inject;
+import com.cloud.configuration.Config;
+import com.cloud.utils.DateUtil;
+import com.cloud.utils.NumbersUtil;
+import com.cloud.utils.db.QueryBuilder;
+import com.cloud.utils.db.SearchCriteria;
 
 
 
@@ -72,33 +74,33 @@ public class StorageCacheReplacementAlgorithmLRU implements StorageCacheReplacem
         cal.add(Calendar.DAY_OF_MONTH, -unusedTimeInterval.intValue());
         Date bef = cal.getTime();
 
-        GenericQueryBuilder<TemplateDataStoreVO, TemplateDataStoreVO> sc = GenericQueryBuilder.create(TemplateDataStoreVO.class);
-        sc.addAnd(sc.getEntity().getLastUpdated(), SearchCriteria.Op.LT, bef);
-        sc.addAnd(sc.getEntity().getState(), SearchCriteria.Op.EQ, ObjectInDataStoreStateMachine.State.Ready);
-        sc.addAnd(sc.getEntity().getDataStoreId(), SearchCriteria.Op.EQ, store.getId());
-        sc.addAnd(sc.getEntity().getDataStoreRole(), SearchCriteria.Op.EQ, store.getRole());
-        sc.addAnd(sc.getEntity().getRefCnt(), SearchCriteria.Op.EQ, 0);
+        QueryBuilder<TemplateDataStoreVO> sc = QueryBuilder.create(TemplateDataStoreVO.class);
+        sc.and(sc.entity().getLastUpdated(), SearchCriteria.Op.LT, bef);
+        sc.and(sc.entity().getState(), SearchCriteria.Op.EQ,ObjectInDataStoreStateMachine.State.Ready);
+        sc.and(sc.entity().getDataStoreId(), SearchCriteria.Op.EQ,store.getId());
+        sc.and(sc.entity().getDataStoreRole(), SearchCriteria.Op.EQ,store.getRole());
+        sc.and(sc.entity().getRefCnt(), SearchCriteria.Op.EQ,0);
         TemplateDataStoreVO template = sc.find();
         if (template != null) {
             return templateFactory.getTemplate(template.getTemplateId(), store);
         }
 
-        GenericQueryBuilder<VolumeDataStoreVO, VolumeDataStoreVO> volSc = GenericQueryBuilder.create(VolumeDataStoreVO.class);
-        volSc.addAnd(volSc.getEntity().getLastUpdated(), SearchCriteria.Op.LT, bef);
-        volSc.addAnd(volSc.getEntity().getState(), SearchCriteria.Op.EQ, ObjectInDataStoreStateMachine.State.Ready);
-        volSc.addAnd(volSc.getEntity().getDataStoreId(), SearchCriteria.Op.EQ, store.getId());
-        volSc.addAnd(volSc.getEntity().getRefCnt(), SearchCriteria.Op.EQ, 0);
+        QueryBuilder<VolumeDataStoreVO> volSc = QueryBuilder.create(VolumeDataStoreVO.class);
+        volSc.and(volSc.entity().getLastUpdated(), SearchCriteria.Op.LT, bef);
+        volSc.and(volSc.entity().getState(), SearchCriteria.Op.EQ,ObjectInDataStoreStateMachine.State.Ready);
+        volSc.and(volSc.entity().getDataStoreId(), SearchCriteria.Op.EQ,store.getId());
+        volSc.and(volSc.entity().getRefCnt(), SearchCriteria.Op.EQ,0);
         VolumeDataStoreVO volume = volSc.find();
         if (volume != null) {
             return volumeFactory.getVolume(volume.getVolumeId(), store);
         }
 
-        GenericQueryBuilder<SnapshotDataStoreVO, SnapshotDataStoreVO> snapshotSc = GenericQueryBuilder.create(SnapshotDataStoreVO.class);
-        snapshotSc.addAnd(snapshotSc.getEntity().getLastUpdated(), SearchCriteria.Op.LT, bef);
-        snapshotSc.addAnd(snapshotSc.getEntity().getState(), SearchCriteria.Op.EQ, ObjectInDataStoreStateMachine.State.Ready);
-        snapshotSc.addAnd(snapshotSc.getEntity().getDataStoreId(), SearchCriteria.Op.EQ, store.getId());
-        snapshotSc.addAnd(snapshotSc.getEntity().getRole(), SearchCriteria.Op.EQ, store.getRole());
-        snapshotSc.addAnd(snapshotSc.getEntity().getRefCnt(), SearchCriteria.Op.EQ, 0);
+        QueryBuilder<SnapshotDataStoreVO> snapshotSc = QueryBuilder.create(SnapshotDataStoreVO.class);
+        snapshotSc.and(snapshotSc.entity().getLastUpdated(), SearchCriteria.Op.LT, bef);
+        snapshotSc.and(snapshotSc.entity().getState(), SearchCriteria.Op.EQ,ObjectInDataStoreStateMachine.State.Ready);
+        snapshotSc.and(snapshotSc.entity().getDataStoreId(), SearchCriteria.Op.EQ,store.getId());
+        snapshotSc.and(snapshotSc.entity().getRole(), SearchCriteria.Op.EQ,store.getRole());
+        snapshotSc.and(snapshotSc.entity().getRefCnt(), SearchCriteria.Op.EQ,0);
         SnapshotDataStoreVO snapshot = snapshotSc.find();
         if (snapshot != null) {
             return snapshotFactory.getSnapshot(snapshot.getSnapshotId(), store);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e8cac2c5/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotObject.java
----------------------------------------------------------------------
diff --git a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotObject.java b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotObject.java
index dcdc938..3f35e1d 100644
--- a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotObject.java
+++ b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotObject.java
@@ -22,14 +22,21 @@ import java.util.Date;
 
 import javax.inject.Inject;
 
-import org.apache.cloudstack.engine.subsystem.api.storage.*;
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectInStore;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
+import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
+import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotDataFactory;
+import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo;
+import org.apache.cloudstack.engine.subsystem.api.storage.VolumeDataFactory;
+import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
 import org.apache.cloudstack.storage.command.CopyCmdAnswer;
 import org.apache.cloudstack.storage.command.CreateObjectAnswer;
 import org.apache.cloudstack.storage.datastore.ObjectInDataStoreManager;
 import org.apache.cloudstack.storage.datastore.db.SnapshotDataStoreDao;
 import org.apache.cloudstack.storage.datastore.db.SnapshotDataStoreVO;
 import org.apache.cloudstack.storage.to.SnapshotObjectTO;
-import org.apache.log4j.Logger;
 
 import com.cloud.agent.api.Answer;
 import com.cloud.agent.api.to.DataObjectType;
@@ -42,9 +49,8 @@ import com.cloud.storage.VolumeVO;
 import com.cloud.storage.dao.SnapshotDao;
 import com.cloud.storage.dao.VolumeDao;
 import com.cloud.utils.component.ComponentContext;
+import com.cloud.utils.db.QueryBuilder;
 import com.cloud.utils.db.SearchCriteria.Op;
-import com.cloud.utils.db.GenericQueryBuilder;
-import com.cloud.utils.db.GenericQueryBuilder;
 import com.cloud.utils.exception.CloudRuntimeException;
 import com.cloud.utils.fsm.NoTransitionException;
 
@@ -83,19 +89,19 @@ public class SnapshotObject implements SnapshotInfo {
     }
 
     public DataStore getStore() {
-        return this.store;
+        return store;
     }
 
     @Override
     public SnapshotInfo getParent() {
 
-        SnapshotDataStoreVO snapStoreVO = this.snapshotStoreDao.findByStoreSnapshot(this.store.getRole(),
-                this.store.getId(), this.snapshot.getId());
+        SnapshotDataStoreVO snapStoreVO = snapshotStoreDao.findByStoreSnapshot(store.getRole(),
+                store.getId(), snapshot.getId());
         Long parentId = null;
         if (snapStoreVO != null) {
             parentId = snapStoreVO.getParentSnapshotId();
             if (parentId != null && parentId != 0) {
-                return this.snapshotFactory.getSnapshot(parentId, store);
+                return snapshotFactory.getSnapshot(parentId, store);
             }
         }
 
@@ -104,42 +110,41 @@ public class SnapshotObject implements SnapshotInfo {
 
     @Override
     public SnapshotInfo getChild() {
-        GenericQueryBuilder<SnapshotDataStoreVO, SnapshotDataStoreVO> sc = GenericQueryBuilder
-                .create(SnapshotDataStoreVO.class);
-        sc.addAnd(sc.getEntity().getDataStoreId(), Op.EQ, this.store.getId());
-        sc.addAnd(sc.getEntity().getRole(), Op.EQ, this.store.getRole());
-        sc.addAnd(sc.getEntity().getState(), Op.NIN, State.Destroying, State.Destroyed, State.Error);
-        sc.addAnd(sc.getEntity().getParentSnapshotId(), Op.EQ, this.getId());
+        QueryBuilder<SnapshotDataStoreVO> sc = QueryBuilder.create(SnapshotDataStoreVO.class);
+        sc.and(sc.entity().getDataStoreId(), Op.EQ,store.getId());
+        sc.and(sc.entity().getRole(), Op.EQ,store.getRole());
+        sc.and(sc.entity().getState(), Op.NIN, State.Destroying, State.Destroyed, State.Error);
+        sc.and(sc.entity().getParentSnapshotId(), Op.EQ,getId());
         SnapshotDataStoreVO vo = sc.find();
         if (vo == null) {
             return null;
         }
-        return this.snapshotFactory.getSnapshot(vo.getId(), store);
+        return snapshotFactory.getSnapshot(vo.getId(), store);
     }
 
     @Override
     public VolumeInfo getBaseVolume() {
-        return volFactory.getVolume(this.snapshot.getVolumeId());
+        return volFactory.getVolume(snapshot.getVolumeId());
     }
 
     @Override
     public long getId() {
-        return this.snapshot.getId();
+        return snapshot.getId();
     }
 
     @Override
     public String getUri() {
-        return this.snapshot.getUuid();
+        return snapshot.getUuid();
     }
 
     @Override
     public DataStore getDataStore() {
-        return this.store;
+        return store;
     }
 
     @Override
     public Long getSize() {
-        return this.snapshot.getSize();
+        return snapshot.getSize();
     }
 
     @Override
@@ -149,7 +154,7 @@ public class SnapshotObject implements SnapshotInfo {
 
     @Override
     public String getUuid() {
-        return this.snapshot.getUuid();
+        return snapshot.getUuid();
     }
 
     @Override
@@ -168,17 +173,17 @@ public class SnapshotObject implements SnapshotInfo {
 
     @Override
     public long getAccountId() {
-        return this.snapshot.getAccountId();
+        return snapshot.getAccountId();
     }
 
     @Override
     public long getVolumeId() {
-        return this.snapshot.getVolumeId();
+        return snapshot.getVolumeId();
     }
 
     @Override
     public String getPath() {
-        DataObjectInStore objectInStore = this.objectInStoreMgr.findObject(this, getDataStore());
+        DataObjectInStore objectInStore = objectInStoreMgr.findObject(this, getDataStore());
         if (objectInStore != null) {
             return objectInStore.getInstallPath();
         }
@@ -187,60 +192,60 @@ public class SnapshotObject implements SnapshotInfo {
 
     @Override
     public String getName() {
-        return this.snapshot.getName();
+        return snapshot.getName();
     }
 
     @Override
     public Date getCreated() {
-        return this.snapshot.getCreated();
+        return snapshot.getCreated();
     }
 
     @Override
     public Type getRecurringType() {
-        return this.snapshot.getRecurringType();
+        return snapshot.getRecurringType();
     }
 
     @Override
     public State getState() {
-        return this.snapshot.getState();
+        return snapshot.getState();
     }
 
     @Override
     public HypervisorType getHypervisorType() {
-        return this.snapshot.getHypervisorType();
+        return snapshot.getHypervisorType();
     }
 
     @Override
     public boolean isRecursive() {
-        return this.snapshot.isRecursive();
+        return snapshot.isRecursive();
     }
 
     @Override
     public short getsnapshotType() {
-        return this.snapshot.getsnapshotType();
+        return snapshot.getsnapshotType();
     }
 
     @Override
     public long getDomainId() {
-        return this.snapshot.getDomainId();
+        return snapshot.getDomainId();
     }
 
     @Override
     public Long getDataCenterId() {
-        return this.snapshot.getDataCenterId();
+        return snapshot.getDataCenterId();
     }
 
     public void processEvent(Snapshot.Event event) throws NoTransitionException {
-        stateMachineMgr.processEvent(this.snapshot, event);
+        stateMachineMgr.processEvent(snapshot, event);
     }
 
     public SnapshotVO getSnapshotVO() {
-        return this.snapshot;
+        return snapshot;
     }
 
     @Override
     public DataTO getTO() {
-        DataTO to = this.store.getDriver().getTO(this);
+        DataTO to = store.getDriver().getTO(this);
         if (to == null) {
             return new SnapshotObjectTO(this);
         }
@@ -250,28 +255,28 @@ public class SnapshotObject implements SnapshotInfo {
     @Override
     public void processEvent(ObjectInDataStoreStateMachine.Event event, Answer answer) {
         try {
-            SnapshotDataStoreVO snapshotStore = this.snapshotStoreDao.findByStoreSnapshot(
-                    this.getDataStore().getRole(), this.getDataStore().getId(), this.getId());
+            SnapshotDataStoreVO snapshotStore = snapshotStoreDao.findByStoreSnapshot(
+                    getDataStore().getRole(), getDataStore().getId(), getId());
             if (answer instanceof CreateObjectAnswer) {
                 SnapshotObjectTO snapshotTO = (SnapshotObjectTO) ((CreateObjectAnswer) answer).getData();
                 snapshotStore.setInstallPath(snapshotTO.getPath());
-                this.snapshotStoreDao.update(snapshotStore.getId(), snapshotStore);
+                snapshotStoreDao.update(snapshotStore.getId(), snapshotStore);
             } else if (answer instanceof CopyCmdAnswer) {
                 SnapshotObjectTO snapshotTO = (SnapshotObjectTO) ((CopyCmdAnswer) answer).getNewData();
                 snapshotStore.setInstallPath(snapshotTO.getPath());
                 if (snapshotTO.getParentSnapshotPath() == null) {
                     snapshotStore.setParentSnapshotId(0L);
                 }
-                this.snapshotStoreDao.update(snapshotStore.getId(), snapshotStore);
+                snapshotStoreDao.update(snapshotStore.getId(), snapshotStore);
                 
                 // update side-effect of snapshot operation
                 if(snapshotTO.getVolume() != null && snapshotTO.getVolume().getPath() != null) {
-                	VolumeVO vol = this.volumeDao.findByUuid(snapshotTO.getVolume().getUuid());
+                	VolumeVO vol = volumeDao.findByUuid(snapshotTO.getVolume().getUuid());
                 	if(vol != null) {
 	                	s_logger.info("Update volume path change due to snapshot operation, volume " + vol.getId() + " path: "
 	                		+ vol.getPath() + "->" + snapshotTO.getVolume().getPath());
 	                	vol.setPath(snapshotTO.getVolume().getPath());
-	                	this.volumeDao.update(vol.getId(), vol);
+	                	volumeDao.update(vol.getId(), vol);
                 	} else {
                 		s_logger.error("Cound't find the original volume with uuid: " + snapshotTO.getVolume().getUuid());
                 	}
@@ -290,13 +295,13 @@ public class SnapshotObject implements SnapshotInfo {
 
     @Override
     public void incRefCount() {
-        if (this.store == null) {
+        if (store == null) {
             return;
         }
 
-        if (this.store.getRole() == DataStoreRole.Image || this.store.getRole() == DataStoreRole.ImageCache) {
+        if (store.getRole() == DataStoreRole.Image || store.getRole() == DataStoreRole.ImageCache) {
             SnapshotDataStoreVO store = snapshotStoreDao.findByStoreSnapshot(this.store.getRole(), this.store.getId(),
-                    this.getId());
+                    getId());
             store.incrRefCnt();
             store.setLastUpdated(new Date());
             snapshotStoreDao.update(store.getId(), store);
@@ -305,12 +310,12 @@ public class SnapshotObject implements SnapshotInfo {
 
     @Override
     public void decRefCount() {
-        if (this.store == null) {
+        if (store == null) {
             return;
         }
-        if (this.store.getRole() == DataStoreRole.Image || this.store.getRole() == DataStoreRole.ImageCache) {
+        if (store.getRole() == DataStoreRole.Image || store.getRole() == DataStoreRole.ImageCache) {
             SnapshotDataStoreVO store = snapshotStoreDao.findByStoreSnapshot(this.store.getRole(), this.store.getId(),
-                    this.getId());
+                    getId());
             store.decrRefCnt();
             store.setLastUpdated(new Date());
             snapshotStoreDao.update(store.getId(), store);
@@ -319,12 +324,12 @@ public class SnapshotObject implements SnapshotInfo {
 
     @Override
     public Long getRefCount() {
-        if (this.store == null) {
+        if (store == null) {
             return null;
         }
-        if (this.store.getRole() == DataStoreRole.Image || this.store.getRole() == DataStoreRole.ImageCache) {
+        if (store.getRole() == DataStoreRole.Image || store.getRole() == DataStoreRole.ImageCache) {
             SnapshotDataStoreVO store = snapshotStoreDao.findByStoreSnapshot(this.store.getRole(), this.store.getId(),
-                    this.getId());
+                    getId());
             return store.getRefCnt();
         }
         return null;
@@ -332,7 +337,7 @@ public class SnapshotObject implements SnapshotInfo {
 
     @Override
     public ObjectInDataStoreStateMachine.State getStatus() {
-        return this.objectInStoreMgr.findObject(this, store).getObjectInStoreState();
+        return objectInStoreMgr.findObject(this, store).getObjectInStoreState();
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e8cac2c5/engine/storage/src/org/apache/cloudstack/storage/endpoint/DefaultEndPointSelector.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/endpoint/DefaultEndPointSelector.java b/engine/storage/src/org/apache/cloudstack/storage/endpoint/DefaultEndPointSelector.java
index 118db80..fdc12bf 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/endpoint/DefaultEndPointSelector.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/endpoint/DefaultEndPointSelector.java
@@ -45,8 +45,8 @@ import com.cloud.host.dao.HostDao;
 import com.cloud.storage.DataStoreRole;
 import com.cloud.storage.ScopeType;
 import com.cloud.utils.db.DB;
+import com.cloud.utils.db.QueryBuilder;
 import com.cloud.utils.db.SearchCriteria.Op;
-import com.cloud.utils.db.GenericQueryBuilder;
 import com.cloud.utils.db.Transaction;
 import com.cloud.utils.exception.CloudRuntimeException;
 
@@ -220,12 +220,12 @@ public class DefaultEndPointSelector implements EndPointSelector {
     }
 
     private List<HostVO> listUpAndConnectingSecondaryStorageVmHost(Long dcId) {
-        GenericQueryBuilder<HostVO, HostVO> sc = GenericQueryBuilder.create(HostVO.class);
+        QueryBuilder<HostVO> sc = QueryBuilder.create(HostVO.class);
         if (dcId != null) {
-            sc.addAnd(sc.getEntity().getDataCenterId(), Op.EQ, dcId);
+            sc.and(sc.entity().getDataCenterId(), Op.EQ,dcId);
         }
-        sc.addAnd(sc.getEntity().getStatus(), Op.IN, com.cloud.host.Status.Up, com.cloud.host.Status.Connecting);
-        sc.addAnd(sc.getEntity().getType(), Op.EQ, Host.Type.SecondaryStorageVM);
+        sc.and(sc.entity().getStatus(), Op.IN, Status.Up, Status.Connecting);
+        sc.and(sc.entity().getType(), Op.EQ, Host.Type.SecondaryStorageVM);
         return sc.list();
     }
 
@@ -258,9 +258,9 @@ public class DefaultEndPointSelector implements EndPointSelector {
             endPoints.add(RemoteHostEndPoint.getHypervisorHostEndPoint(host.getId(), host.getPrivateIpAddress(),
                     host.getPublicIpAddress()));
         } else if (store.getScope().getScopeType() == ScopeType.CLUSTER) {
-            GenericQueryBuilder<HostVO, HostVO> sc = GenericQueryBuilder.create(HostVO.class);
-            sc.addAnd(sc.getEntity().getClusterId(), Op.EQ, store.getScope().getScopeId());
-            sc.addAnd(sc.getEntity().getStatus(), Op.EQ, Status.Up);
+            QueryBuilder<HostVO> sc = QueryBuilder.create(HostVO.class);
+            sc.and(sc.entity().getClusterId(), Op.EQ, store.getScope().getScopeId());
+            sc.and(sc.entity().getStatus(), Op.EQ, Status.Up);
             List<HostVO> hosts = sc.list();
             for (HostVO host : hosts) {
                 endPoints.add(RemoteHostEndPoint.getHypervisorHostEndPoint(host.getId(), host.getPrivateIpAddress(),

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e8cac2c5/engine/storage/src/org/apache/cloudstack/storage/volume/db/TemplatePrimaryDataStoreDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/volume/db/TemplatePrimaryDataStoreDaoImpl.java b/engine/storage/src/org/apache/cloudstack/storage/volume/db/TemplatePrimaryDataStoreDaoImpl.java
index 20bc709..456471b 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/volume/db/TemplatePrimaryDataStoreDaoImpl.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/volume/db/TemplatePrimaryDataStoreDaoImpl.java
@@ -52,8 +52,8 @@ public class TemplatePrimaryDataStoreDaoImpl extends GenericDaoBase<TemplatePrim
     public TemplatePrimaryDataStoreVO findByTemplateIdAndPoolId(long templateId, long poolId) {
         GenericQueryBuilder<TemplatePrimaryDataStoreVO, TemplatePrimaryDataStoreVO> sc = GenericQueryBuilder
                 .create(TemplatePrimaryDataStoreVO.class);
-        sc.addAnd(sc.getEntity().getTemplateId(), Op.EQ, templateId);
-        sc.addAnd(sc.getEntity().getPoolId(), Op.EQ, poolId);
+        sc.and(sc.entity().getTemplateId(), Op.EQ, templateId);
+        sc.and(sc.entity().getPoolId(), Op.EQ, poolId);
         return sc.find();
     }
 
@@ -61,9 +61,9 @@ public class TemplatePrimaryDataStoreDaoImpl extends GenericDaoBase<TemplatePrim
     public TemplatePrimaryDataStoreVO findByTemplateIdAndPoolIdAndReady(long templateId, long poolId) {
         GenericQueryBuilder<TemplatePrimaryDataStoreVO, TemplatePrimaryDataStoreVO> sc = GenericQueryBuilder
                 .create(TemplatePrimaryDataStoreVO.class);
-        sc.addAnd(sc.getEntity().getTemplateId(), Op.EQ, templateId);
-        sc.addAnd(sc.getEntity().getPoolId(), Op.EQ, poolId);
-        sc.addAnd(sc.getEntity().getState(), Op.EQ, ObjectInDataStoreStateMachine.State.Ready);
+        sc.and(sc.entity().getTemplateId(), Op.EQ, templateId);
+        sc.and(sc.entity().getPoolId(), Op.EQ, poolId);
+        sc.and(sc.entity().getState(), Op.EQ, ObjectInDataStoreStateMachine.State.Ready);
         return sc.find();
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e8cac2c5/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 1dabbf8..8581d80 100755
--- a/framework/db/src/com/cloud/utils/db/GenericQueryBuilder.java
+++ b/framework/db/src/com/cloud/utils/db/GenericQueryBuilder.java
@@ -66,23 +66,21 @@ public class GenericQueryBuilder<T, K> extends SearchBase<T, K> {
         _specifiedAttrs.clear();
     }
 
-    private void setParameters(String conditionName, Object... params) {
-        assert _conditions.contains(new Condition(conditionName)) : "Couldn't find " + conditionName;
-        _params.put(conditionName, params);
-    }
-
-    public void addAnd(Object useless, Op op, Object... values) {
+    public void and(Object useless, Op op, Object... values) {
         String uuid = UUID.randomUUID().toString();
-        constructCondition(uuid, " AND ", _specifiedAttrs.get(0), op);
-        setParameters(uuid, values);
+        Condition condition = constructCondition(uuid, " AND ", _specifiedAttrs.get(0), op);
+        condition.setPresets(values);
     }
 
+    @SuppressWarnings("unchecked")
     public List<K> list() {
         finalize();
-        SearchCriteria sc1 = create();
         if (isSelectAll()) {
+            @SuppressWarnings("rawtypes")
+            SearchCriteria sc1 = create();
             return (List<K>)_dao.search(sc1, null);
         } else {
+            SearchCriteria<K> sc1 = create();
             return _dao.customSearch(sc1, null);
         }
     }
@@ -91,60 +89,13 @@ public class GenericQueryBuilder<T, K> extends SearchBase<T, K> {
         return _selects == null || _selects.size() == 0;
     }
 
-    public T getEntity() {
-        return _entity;
-    }
-
+    @SuppressWarnings("unchecked")
     public K find() {
-        assert isSelectAll() : "find doesn't support select search";
         finalize();
+        @SuppressWarnings("rawtypes")
         SearchCriteria sc1 = create();
         return (K)_dao.findOneBy(sc1);
     }
 
-    public Preset and(Object useless, Op op) {
-        Condition condition = constructCondition(UUID.randomUUID().toString(), " AND ", _specifiedAttrs.get(0), op);
-        return new Preset(this, condition);
-    }
-
-    public Preset where(Object useless, Op op) {
-        return and(useless, op);
-    }
-
-    public Preset left(Object useless, Op op) {
-        Condition condition = constructCondition(UUID.randomUUID().toString(), " ( ", _specifiedAttrs.get(0), op);
-        return new Preset(this, condition);
-    }
-
-    public Preset op(Object useless, Op op) {
-        return left(useless, op);
-    }
-
-    public Preset openParen(Object useless, Op op) {
-        return left(useless, op);
-    }
-
-    public Preset or(Object useless, Op op) {
-        Condition condition = constructCondition(UUID.randomUUID().toString(), " OR ", _specifiedAttrs.get(0), op);
-        return new Preset(this, condition);
-    }
-
-    public class Preset {
-        GenericQueryBuilder<T, K> builder;
-        Condition condition;
-
-        protected Preset(GenericQueryBuilder<T, K> builder, Condition condition) {
-            this.builder = builder;
-            this.condition = condition;
-        }
-
-        public GenericQueryBuilder<T, K> values(Object... params) {
-            if (condition.op.getParams() > 0 && condition.op.params != params.length) {
-                throw new RuntimeException("The # of parameters set " + params.length + " does not match # of parameters required by " + condition.op);
-            }
-            condition.setPresets(params);
-            return builder;
-        }
-    }
 
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e8cac2c5/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 16c77f1..8e46c30 100755
--- a/framework/db/src/com/cloud/utils/db/GenericSearchBuilder.java
+++ b/framework/db/src/com/cloud/utils/db/GenericSearchBuilder.java
@@ -19,6 +19,7 @@ package com.cloud.utils.db;
 import java.lang.reflect.Field;
 import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.UUID;
 
 import com.cloud.utils.db.SearchCriteria.Func;
 import com.cloud.utils.db.SearchCriteria.Op;
@@ -131,6 +132,11 @@ public class GenericSearchBuilder<T, K> extends SearchBase<T, K> {
         return this;
     }
 
+    public Preset and(Object useless, Op op) {
+        Condition condition = constructCondition(UUID.randomUUID().toString(), " AND ", _specifiedAttrs.get(0), op);
+        return new Preset(this, condition);
+    }
+
     public GenericSearchBuilder<T, K> and() {
         constructCondition(null, " AND ", null, null);
         return this;
@@ -153,6 +159,10 @@ public class GenericSearchBuilder<T, K> extends SearchBase<T, K> {
         return and(name, useless, op);
     }
 
+    public Preset where(Object useless, Op op) {
+        return and(useless, op);
+    }
+
     public GenericSearchBuilder<T, K> left(String name, Object useless, Op op) {
         constructCondition(name, " ( ", _specifiedAttrs.get(0), op);
         return this;
@@ -163,10 +173,19 @@ public class GenericSearchBuilder<T, K> extends SearchBase<T, K> {
         return this;
     }
 
+    public Preset left(Object useless, Op op) {
+        Condition condition = constructCondition(UUID.randomUUID().toString(), " ( ", _specifiedAttrs.get(0), op);
+        return new Preset(this, condition);
+    }
+
     public GenericSearchBuilder<T, K> op(Object useless, Op op, String name) {
         return left(useless, op, name);
     }
 
+    public Preset op(Object useless, Op op) {
+        return left(useless, op);
+    }
+
     public GenericSearchBuilder<T, K> op(String name, Object useless, Op op) {
         return left(name, useless, op);
     }
@@ -179,6 +198,10 @@ public class GenericSearchBuilder<T, K> extends SearchBase<T, K> {
         return left(name, useless, op);
     }
     
+    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);
@@ -205,6 +228,11 @@ public class GenericSearchBuilder<T, K> extends SearchBase<T, K> {
         return this;
     }
 
+    public Preset or(Object useless, Op op) {
+        Condition condition = constructCondition(UUID.randomUUID().toString(), " OR ", _specifiedAttrs.get(0), op);
+        return new Preset(this, condition);
+    }
+
     public GenericSearchBuilder<T, K> join(String name, GenericSearchBuilder<?, ?> builder, Object useless, Object useless2, JoinBuilder.JoinType joinType) {
         assert _entity != null : "SearchBuilder cannot be modified once it has been setup";
         assert _specifiedAttrs.size() == 1 : "You didn't select the attribute.";
@@ -251,4 +279,21 @@ public class GenericSearchBuilder<T, K> extends SearchBase<T, K> {
         super.finalize();
     }
     
+    public class Preset {
+        GenericSearchBuilder<T, K> builder;
+        Condition condition;
+
+        protected Preset(GenericSearchBuilder<T, K> builder, Condition condition) {
+            this.builder = builder;
+            this.condition = condition;
+        }
+
+        public GenericSearchBuilder<T, K> values(Object... params) {
+            if (condition.op.getParams() > 0 && condition.op.params != params.length) {
+                throw new RuntimeException("The # of parameters set " + params.length + " does not match # of parameters required by " + condition.op);
+            }
+            condition.setPresets(params);
+            return builder;
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e8cac2c5/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BareMetalPingServiceImpl.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BareMetalPingServiceImpl.java b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BareMetalPingServiceImpl.java
index 783755d..c8a178e 100755
--- a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BareMetalPingServiceImpl.java
+++ b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BareMetalPingServiceImpl.java
@@ -85,8 +85,8 @@ public class BareMetalPingServiceImpl extends BareMetalPxeServiceBase implements
 	@Override
     public boolean prepare(VirtualMachineProfile profile, NicProfile pxeNic, DeployDestination dest, ReservationContext context) {
 	    GenericQueryBuilder<BaremetalPxeVO, BaremetalPxeVO> sc = GenericQueryBuilder.create(BaremetalPxeVO.class);
-        sc.addAnd(sc.getEntity().getDeviceType(), Op.EQ, BaremetalPxeType.PING.toString());
-        sc.addAnd(sc.getEntity().getPodId(), Op.EQ, dest.getPod().getId());
+        sc.and(sc.entity().getDeviceType(), Op.EQ, BaremetalPxeType.PING.toString());
+        sc.and(sc.entity().getPodId(), Op.EQ, dest.getPod().getId());
         BaremetalPxeVO pxeVo = sc.find();
         if (pxeVo == null) {
             throw new CloudRuntimeException("No PING PXE server found in pod: " + dest.getPod().getId() + ", you need to add it before starting VM");

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e8cac2c5/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalDhcpElement.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalDhcpElement.java b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalDhcpElement.java
index 5459918..6cf94f2 100755
--- a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalDhcpElement.java
+++ b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalDhcpElement.java
@@ -5,19 +5,28 @@
 // to you under the Apache License, Version 2.0 (the
 // "License"); you may not use this file except in compliance
 // with the License.  You may obtain a copy of the License at
-// 
+//
 //   http://www.apache.org/licenses/LICENSE-2.0
-// 
+//
 // Unless required by applicable law or agreed to in writing,
 // software distributed under the License is distributed on an
 // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 // KIND, either express or implied.  See the License for the
 // specific language governing permissions and limitations
 // under the License.
-// 
+//
 // Automatically generated by addcopyright.py at 01/29/2013
 package com.cloud.baremetal.networkservice;
 
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+import javax.ejb.Local;
+import javax.inject.Inject;
+
+import org.apache.log4j.Logger;
+
 import com.cloud.baremetal.database.BaremetalDhcpVO;
 import com.cloud.dc.DataCenter.NetworkType;
 import com.cloud.dc.Pod;
@@ -39,20 +48,15 @@ import com.cloud.network.element.NetworkElement;
 import com.cloud.offering.NetworkOffering;
 import com.cloud.utils.component.AdapterBase;
 import com.cloud.utils.db.DB;
+import com.cloud.utils.db.QueryBuilder;
 import com.cloud.utils.db.SearchCriteria.Op;
-import com.cloud.utils.db.GenericQueryBuilder;
-import com.cloud.utils.db.GenericQueryBuilder;
 import com.cloud.utils.db.Transaction;
-import com.cloud.vm.*;
+import com.cloud.vm.NicProfile;
+import com.cloud.vm.NicVO;
+import com.cloud.vm.ReservationContext;
 import com.cloud.vm.VirtualMachine.Type;
+import com.cloud.vm.VirtualMachineProfile;
 import com.cloud.vm.dao.NicDao;
-import org.apache.log4j.Logger;
-
-import javax.ejb.Local;
-import javax.inject.Inject;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
 
 @Local(value = NetworkElement.class)
 public class BaremetalDhcpElement extends AdapterBase implements DhcpServiceProvider {
@@ -84,8 +88,8 @@ public class BaremetalDhcpElement extends AdapterBase implements DhcpServiceProv
     private boolean canHandle(DeployDestination dest, TrafficType trafficType, GuestType networkType) {
         Pod pod = dest.getPod();
         if (pod != null && dest.getDataCenter().getNetworkType() == NetworkType.Basic && trafficType == TrafficType.Guest) {
-            GenericQueryBuilder<BaremetalDhcpVO, BaremetalDhcpVO> sc = GenericQueryBuilder.create(BaremetalDhcpVO.class);
-            sc.addAnd(sc.getEntity().getPodId(), Op.EQ, pod.getId());
+            QueryBuilder<BaremetalDhcpVO> sc = QueryBuilder.create(BaremetalDhcpVO.class);
+            sc.and(sc.entity().getPodId(), Op.EQ,pod.getId());
             return sc.find() != null;
         }
         
@@ -159,6 +163,7 @@ public class BaremetalDhcpElement extends AdapterBase implements DhcpServiceProv
         return true;
     }
     
+    @Override
     public boolean addDhcpEntry(Network network, NicProfile nic, VirtualMachineProfile vm, DeployDestination dest,
             ReservationContext context) throws ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException {
         if (vm.getHypervisorType() != HypervisorType.BareMetal || !canHandle(dest, network.getTrafficType(), network.getGuestType())) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e8cac2c5/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalDhcpManagerImpl.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalDhcpManagerImpl.java b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalDhcpManagerImpl.java
index 9ab714d..930ca1b 100755
--- a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalDhcpManagerImpl.java
+++ b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalDhcpManagerImpl.java
@@ -313,7 +313,7 @@ public class BaremetalDhcpManagerImpl extends ManagerBase implements BaremetalDh
 
         GenericQueryBuilder<BaremetalDhcpVO, BaremetalDhcpVO> sc = GenericQueryBuilder.create(BaremetalDhcpVO.class);
         if (cmd.getDeviceType() != null) {
-        	sc.addAnd(sc.getEntity().getDeviceType(), Op.EQ, cmd.getDeviceType());
+        	sc.and(sc.entity().getDeviceType(), Op.EQ, cmd.getDeviceType());
         }
 
         List<BaremetalDhcpVO> vos = sc.list();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e8cac2c5/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalKickStartServiceImpl.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalKickStartServiceImpl.java b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalKickStartServiceImpl.java
index b4af709..661f391 100755
--- a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalKickStartServiceImpl.java
+++ b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalKickStartServiceImpl.java
@@ -88,8 +88,8 @@ public class BaremetalKickStartServiceImpl extends BareMetalPxeServiceBase imple
     public boolean prepare(VirtualMachineProfile profile, NicProfile nic, DeployDestination dest, ReservationContext context) {
         NetworkVO nwVO = _nwDao.findById(nic.getNetworkId());
         GenericQueryBuilder<BaremetalPxeVO, BaremetalPxeVO> sc = GenericQueryBuilder.create(BaremetalPxeVO.class);
-        sc.addAnd(sc.getEntity().getDeviceType(), Op.EQ, BaremetalPxeType.KICK_START.toString());
-        sc.addAnd(sc.getEntity().getPhysicalNetworkId(), Op.EQ, nwVO.getPhysicalNetworkId());
+        sc.and(sc.entity().getDeviceType(), Op.EQ, BaremetalPxeType.KICK_START.toString());
+        sc.and(sc.entity().getPhysicalNetworkId(), Op.EQ, nwVO.getPhysicalNetworkId());
         BaremetalPxeVO pxeVo = sc.find();
         if (pxeVo == null) {
             throw new CloudRuntimeException("No kickstart PXE server found in pod: " + dest.getPod().getId() + ", you need to add it before starting VM");

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e8cac2c5/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalPxeElement.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalPxeElement.java b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalPxeElement.java
index 3e0572a..f869fe6 100755
--- a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalPxeElement.java
+++ b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalPxeElement.java
@@ -92,7 +92,7 @@ public class BaremetalPxeElement extends AdapterBase implements NetworkElement {
         Pod pod = dest.getPod();
         if (pod != null && dest.getDataCenter().getNetworkType() == NetworkType.Basic && trafficType == TrafficType.Guest) {
             GenericQueryBuilder<BaremetalPxeVO, BaremetalPxeVO> sc = GenericQueryBuilder.create(BaremetalPxeVO.class);
-            sc.addAnd(sc.getEntity().getPodId(), Op.EQ, pod.getId());
+            sc.and(sc.entity().getPodId(), Op.EQ, pod.getId());
             return sc.find() != null;
         }
         

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e8cac2c5/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalPxeManagerImpl.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalPxeManagerImpl.java b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalPxeManagerImpl.java
index 1614756..ae3898b 100755
--- a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalPxeManagerImpl.java
+++ b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalPxeManagerImpl.java
@@ -223,7 +223,7 @@ public class BaremetalPxeManagerImpl extends ManagerBase implements BaremetalPxe
         GenericQueryBuilder<BaremetalPxeVO, BaremetalPxeVO> sc = GenericQueryBuilder.create(BaremetalPxeVO.class);
         //TODO: handle both kickstart and PING
         //sc.addAnd(sc.getEntity().getPodId(), Op.EQ, vm.getPodIdToDeployIn());
-        sc.addAnd(sc.getEntity().getPhysicalNetworkId(), Op.EQ, phy.getId());
+        sc.and(sc.entity().getPhysicalNetworkId(), Op.EQ, phy.getId());
         BaremetalPxeVO pxeVo = sc.find();
         if (pxeVo == null) {
             throw new CloudRuntimeException("No PXE server found in pod: " + vm.getPodIdToDeployIn() + ", you need to add it before starting VM");


Mime
View raw message