cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mc...@apache.org
Subject git commit: updated refs/heads/master-6-17-stable to b10f109
Date Thu, 20 Jun 2013 22:34:44 GMT
Updated Branches:
  refs/heads/master-6-17-stable 4834b8983 -> b10f10962


CLOUDSTACK-3080: listVirtualMachines tag search refinement no longer
working.


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

Branch: refs/heads/master-6-17-stable
Commit: b10f10962c974f960ed2b1b7061e6cf1e3904bb4
Parents: 4834b89
Author: Min Chen <min.chen@citrix.com>
Authored: Thu Jun 20 15:26:07 2013 -0700
Committer: Min Chen <min.chen@citrix.com>
Committed: Thu Jun 20 15:28:52 2013 -0700

----------------------------------------------------------------------
 .../com/cloud/api/query/QueryManagerImpl.java   | 73 ++++++--------------
 1 file changed, 21 insertions(+), 52 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b10f1096/server/src/com/cloud/api/query/QueryManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/QueryManagerImpl.java b/server/src/com/cloud/api/query/QueryManagerImpl.java
index 8605c08..f54fb58 100644
--- a/server/src/com/cloud/api/query/QueryManagerImpl.java
+++ b/server/src/com/cloud/api/query/QueryManagerImpl.java
@@ -721,14 +721,6 @@ public class QueryManagerImpl extends ManagerBase implements QueryService
{
             sb.and("instanceGroupId", sb.entity().getInstanceGroupId(), SearchCriteria.Op.EQ);
         }
 
-        if (tags != null && !tags.isEmpty()) {
-            for (int count=0; count < tags.size(); count++) {
-                sb.or().op("key" + String.valueOf(count), sb.entity().getTagKey(), SearchCriteria.Op.EQ);
-                sb.and("value" + String.valueOf(count), sb.entity().getTagValue(), SearchCriteria.Op.EQ);
-                sb.cp();
-            }
-        }
-
         if (networkId != null) {
             sb.and("networkId", sb.entity().getNetworkId(), SearchCriteria.Op.EQ);
         }
@@ -752,12 +744,14 @@ public class QueryManagerImpl extends ManagerBase implements QueryService
{
         _accountMgr.buildACLViewSearchCriteria(sc, domainId, isRecursive, permittedAccounts,
listProjectResourcesCriteria);
 
         if (tags != null && !tags.isEmpty()) {
-            int count = 0;
+            SearchCriteria<UserVmJoinVO> tagSc = _userVmJoinDao.createSearchCriteria();
             for (String key : tags.keySet()) {
-                sc.setParameters("key" + String.valueOf(count), key);
-                sc.setParameters("value" + String.valueOf(count), tags.get(key));
-                count++;
+                SearchCriteria<UserVmJoinVO> tsc = _userVmJoinDao.createSearchCriteria();
+                tsc.addAnd("tagKey", SearchCriteria.Op.EQ, key);
+                tsc.addAnd("tagValue", SearchCriteria.Op.EQ, tags.get(key));
+                tagSc.addOr("tagKey", SearchCriteria.Op.SC, tsc);
             }
+            sc.addAnd("tagKey", SearchCriteria.Op.SC, tagSc);
         }
 
         if (groupId != null && (Long)groupId != -1) {
@@ -906,13 +900,6 @@ public class QueryManagerImpl extends ManagerBase implements QueryService
{
         sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ);
         sb.and("name", sb.entity().getName(), SearchCriteria.Op.EQ);
 
-        if (tags != null && !tags.isEmpty()) {
-            for (int count=0; count < tags.size(); count++) {
-                sb.or().op("key" + String.valueOf(count), sb.entity().getTagKey(), SearchCriteria.Op.EQ);
-                sb.and("value" + String.valueOf(count), sb.entity().getTagValue(), SearchCriteria.Op.EQ);
-                sb.cp();
-            }
-        }
 
         SearchCriteria<SecurityGroupJoinVO> sc = sb.create();
         _accountMgr.buildACLViewSearchCriteria(sc, domainId, isRecursive, permittedAccounts,
listProjectResourcesCriteria);
@@ -922,14 +909,16 @@ public class QueryManagerImpl extends ManagerBase implements QueryService
{
         }
 
         if (tags != null && !tags.isEmpty()) {
-            int count = 0;
+            SearchCriteria<SecurityGroupJoinVO> tagSc = _securityGroupJoinDao.createSearchCriteria();
             for (String key : tags.keySet()) {
-                sc.setParameters("key" + String.valueOf(count), key);
-                sc.setParameters("value" + String.valueOf(count), tags.get(key));
-                count++;
+                SearchCriteria<SecurityGroupJoinVO> tsc = _securityGroupJoinDao.createSearchCriteria();
+                tsc.addAnd("tagKey", SearchCriteria.Op.EQ, key);
+                tsc.addAnd("tagValue", SearchCriteria.Op.EQ, tags.get(key));
+                tagSc.addOr("tagKey", SearchCriteria.Op.SC, tsc);
             }
+            sc.addAnd("tagKey", SearchCriteria.Op.SC, tagSc);
         }
-
+        
         if (securityGroup != null) {
             sc.setParameters("name", securityGroup);
         }
@@ -1199,13 +1188,7 @@ public class QueryManagerImpl extends ManagerBase implements QueryService
{
             sb.and("accountId", sb.entity().getAccountId(), SearchCriteria.Op.EQ);
         }
 
-        if (tags != null && !tags.isEmpty()) {
-            for (int count = 0; count < tags.size(); count++) {
-                sb.or().op("key" + String.valueOf(count), sb.entity().getTagKey(), SearchCriteria.Op.EQ);
-                sb.and("value" + String.valueOf(count), sb.entity().getTagValue(), SearchCriteria.Op.EQ);
-                sb.cp();
-            }
-        }
+
 
         SearchCriteria<ProjectJoinVO> sc = sb.create();
 
@@ -1244,14 +1227,7 @@ public class QueryManagerImpl extends ManagerBase implements QueryService
{
             sc.setParameters("domainPath", path);
         }
 
-        if (tags != null && !tags.isEmpty()) {
-            int count = 0;
-            for (String key : tags.keySet()) {
-                sc.setParameters("key" + String.valueOf(count), key);
-                sc.setParameters("value" + String.valueOf(count), tags.get(key));
-                count++;
-            }
-        }
+
 
         // search distinct projects to get count
         Pair<List<ProjectJoinVO>, Integer> uniquePrjPair = _projectJoinDao.searchAndCount(sc,
searchFilter);
@@ -1569,15 +1545,6 @@ public class QueryManagerImpl extends ManagerBase implements QueryService
{
         sb.or("nulltype", sb.entity().getVmType(), SearchCriteria.Op.NULL);
         sb.cp();
 
-        if (tags != null && !tags.isEmpty()) {
-            for (int count=0; count < tags.size(); count++) {
-                sb.or().op("key" + String.valueOf(count), sb.entity().getTagKey(), SearchCriteria.Op.EQ);
-                sb.and("value" + String.valueOf(count), sb.entity().getTagValue(), SearchCriteria.Op.EQ);
-                sb.cp();
-            }
-        }
-
-
 
         // now set the SC criteria...
         SearchCriteria<VolumeJoinVO> sc = sb.create();
@@ -1598,12 +1565,14 @@ public class QueryManagerImpl extends ManagerBase implements QueryService
{
         sc.setParameters("systemUse", 1);
 
         if (tags != null && !tags.isEmpty()) {
-            int count = 0;
+            SearchCriteria<VolumeJoinVO> tagSc = _volumeJoinDao.createSearchCriteria();
             for (String key : tags.keySet()) {
-                sc.setParameters("key" + String.valueOf(count), key);
-                sc.setParameters("value" + String.valueOf(count), tags.get(key));
-                count++;
+                SearchCriteria<VolumeJoinVO> tsc = _volumeJoinDao.createSearchCriteria();
+                tsc.addAnd("tagKey", SearchCriteria.Op.EQ, key);
+                tsc.addAnd("tagValue", SearchCriteria.Op.EQ, tags.get(key));
+                tagSc.addOr("tagKey", SearchCriteria.Op.SC, tsc);
             }
+            sc.addAnd("tagKey", SearchCriteria.Op.SC, tagSc);
         }
 
         if (id != null) {


Mime
View raw message