cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From prachida...@apache.org
Subject git commit: updated refs/heads/master to 42e5370
Date Fri, 10 Jan 2014 23:17:46 GMT
Updated Branches:
  refs/heads/master 2571dd771 -> 42e53702a


CLOUDSTACK-5732 [UI] Search is not working in Affinity Groups panel

- Added keyword support

Conflicts:

	api/src/org/apache/cloudstack/api/command/user/affinitygroup/ListAffinityGroupsCmd.java
	api/src/org/apache/cloudstack/query/QueryService.java
	server/src/com/cloud/api/query/QueryManagerImpl.java


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

Branch: refs/heads/master
Commit: 42e53702a2096176aee9fff75cdc4df9aef605f5
Parents: 2571dd7
Author: Prachi Damle <prachi@cloud.com>
Authored: Wed Jan 8 22:45:15 2014 -0800
Committer: Prachi Damle <prachi@cloud.com>
Committed: Fri Jan 10 14:45:08 2014 -0800

----------------------------------------------------------------------
 .../affinitygroup/ListAffinityGroupsCmd.java    |  7 ++-
 .../apache/cloudstack/query/QueryService.java   | 13 ++---
 .../com/cloud/api/query/QueryManagerImpl.java   | 51 ++++++++++++--------
 3 files changed, 41 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/42e53702/api/src/org/apache/cloudstack/api/command/user/affinitygroup/ListAffinityGroupsCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/affinitygroup/ListAffinityGroupsCmd.java
b/api/src/org/apache/cloudstack/api/command/user/affinitygroup/ListAffinityGroupsCmd.java
index 367dec9..0761a64 100644
--- a/api/src/org/apache/cloudstack/api/command/user/affinitygroup/ListAffinityGroupsCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/affinitygroup/ListAffinityGroupsCmd.java
@@ -17,7 +17,6 @@
 package org.apache.cloudstack.api.command.user.affinitygroup;
 
 import org.apache.log4j.Logger;
-
 import org.apache.cloudstack.affinity.AffinityGroupResponse;
 import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.ApiCommandJobType;
@@ -79,9 +78,9 @@ public class ListAffinityGroupsCmd extends BaseListAccountResourcesCmd {
     @Override
     public void execute() {
 
-        ListResponse<AffinityGroupResponse> response =
-            _queryService.listAffinityGroups(id, affinityGroupName, affinityGroupType, virtualMachineId,
this.getAccountName(), this.getDomainId(), this.isRecursive(),
-                this.listAll(), this.getStartIndex(), this.getPageSizeVal());
+        ListResponse<AffinityGroupResponse> response = _queryService.listAffinityGroups(id,
affinityGroupName,
+                affinityGroupType, virtualMachineId, this.getAccountName(), this.getDomainId(),
this.isRecursive(),
+                this.listAll(), this.getStartIndex(), this.getPageSizeVal(), this.getKeyword());
         response.setResponseName(getCommandName());
         this.setResponseObject(response);
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/42e53702/api/src/org/apache/cloudstack/query/QueryService.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/query/QueryService.java b/api/src/org/apache/cloudstack/query/QueryService.java
index 792ed04..65a6b06 100644
--- a/api/src/org/apache/cloudstack/query/QueryService.java
+++ b/api/src/org/apache/cloudstack/query/QueryService.java
@@ -18,10 +18,6 @@ package org.apache.cloudstack.query;
 
 import java.util.List;
 
-import org.apache.cloudstack.affinity.AffinityGroupResponse;
-import org.apache.cloudstack.api.command.admin.host.ListHostsCmd;
-import org.apache.cloudstack.api.command.admin.internallb.ListInternalLBVMsCmd;
-import org.apache.cloudstack.api.command.admin.router.ListRoutersCmd;
 import org.apache.cloudstack.api.command.admin.storage.ListImageStoresCmd;
 import org.apache.cloudstack.api.command.admin.storage.ListSecondaryStagingStoresCmd;
 import org.apache.cloudstack.api.command.admin.storage.ListStoragePoolsCmd;
@@ -43,6 +39,10 @@ import org.apache.cloudstack.api.command.user.vmgroup.ListVMGroupsCmd;
 import org.apache.cloudstack.api.command.user.volume.ListResourceDetailsCmd;
 import org.apache.cloudstack.api.command.user.volume.ListVolumesCmd;
 import org.apache.cloudstack.api.command.user.zone.ListZonesByCmd;
+import org.apache.cloudstack.affinity.AffinityGroupResponse;
+import org.apache.cloudstack.api.command.admin.host.ListHostsCmd;
+import org.apache.cloudstack.api.command.admin.internallb.ListInternalLBVMsCmd;
+import org.apache.cloudstack.api.command.admin.router.ListRoutersCmd;
 import org.apache.cloudstack.api.response.AccountResponse;
 import org.apache.cloudstack.api.response.AsyncJobResponse;
 import org.apache.cloudstack.api.response.DiskOfferingResponse;
@@ -118,8 +118,9 @@ public interface QueryService {
 
     public ListResponse<TemplateResponse> listIsos(ListIsosCmd cmd);
 
-    public ListResponse<AffinityGroupResponse> listAffinityGroups(Long affinityGroupId,
String affinityGroupName, String affinityGroupType, Long vmId,
-        String accountName, Long domainId, boolean isRecursive, boolean listAll, Long startIndex,
Long pageSize);
+    public ListResponse<AffinityGroupResponse> listAffinityGroups(Long affinityGroupId,
String affinityGroupName,
+            String affinityGroupType, Long vmId, String accountName, Long domainId, boolean
isRecursive,
+            boolean listAll, Long startIndex, Long pageSize, String keyword);
 
     public List<ResourceDetailResponse> listResourceDetails(ListResourceDetailsCmd
cmd);
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/42e53702/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 7fe7b89..bdd4132 100644
--- a/server/src/com/cloud/api/query/QueryManagerImpl.java
+++ b/server/src/com/cloud/api/query/QueryManagerImpl.java
@@ -3037,18 +3037,21 @@ public class QueryManagerImpl extends ManagerBase implements QueryService
{
     }
 
     @Override
-    public ListResponse<AffinityGroupResponse> listAffinityGroups(Long affinityGroupId,
String affinityGroupName, String affinityGroupType, Long vmId,
-        String accountName, Long domainId, boolean isRecursive, boolean listAll, Long startIndex,
Long pageSize) {
-        Pair<List<AffinityGroupJoinVO>, Integer> result =
-            listAffinityGroupsInternal(affinityGroupId, affinityGroupName, affinityGroupType,
vmId, accountName, domainId, isRecursive, listAll, startIndex, pageSize);
+    public ListResponse<AffinityGroupResponse> listAffinityGroups(Long affinityGroupId,
String affinityGroupName,
+            String affinityGroupType, Long vmId, String accountName, Long domainId, boolean
isRecursive,
+            boolean listAll, Long startIndex, Long pageSize, String keyword) {
+        Pair<List<AffinityGroupJoinVO>, Integer> result = listAffinityGroupsInternal(affinityGroupId,
+                affinityGroupName, affinityGroupType, vmId, accountName, domainId, isRecursive,
listAll, startIndex,
+                pageSize, keyword);
         ListResponse<AffinityGroupResponse> response = new ListResponse<AffinityGroupResponse>();
         List<AffinityGroupResponse> agResponses = ViewResponseHelper.createAffinityGroupResponses(result.first());
         response.setResponses(agResponses, result.second());
         return response;
     }
 
-    public Pair<List<AffinityGroupJoinVO>, Integer> listAffinityGroupsInternal(Long
affinityGroupId, String affinityGroupName, String affinityGroupType, Long vmId,
-        String accountName, Long domainId, boolean isRecursive, boolean listAll, Long startIndex,
Long pageSize) {
+    public Pair<List<AffinityGroupJoinVO>, Integer> listAffinityGroupsInternal(Long
affinityGroupId,
+            String affinityGroupName, String affinityGroupType, Long vmId, String accountName,
Long domainId,
+            boolean isRecursive, boolean listAll, Long startIndex, Long pageSize, String
keyword) {
 
         Account caller = CallContext.current().getCallingAccount();
 
@@ -3072,9 +3075,8 @@ public class QueryManagerImpl extends ManagerBase implements QueryService
{
         ListProjectResourcesCriteria listProjectResourcesCriteria = domainIdRecursiveListProject.third();
 
         Filter searchFilter = new Filter(AffinityGroupJoinVO.class, "id", true, startIndex,
pageSize);
-        SearchCriteria<AffinityGroupJoinVO> sc =
-            buildAffinityGroupSearchCriteria(domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria,
affinityGroupId, affinityGroupName,
-                affinityGroupType);
+        SearchCriteria<AffinityGroupJoinVO> sc = buildAffinityGroupSearchCriteria(domainId,
isRecursive,
+                permittedAccounts, listProjectResourcesCriteria, affinityGroupId, affinityGroupName,
affinityGroupType, keyword);
 
         Pair<List<AffinityGroupJoinVO>, Integer> uniqueGroupsPair = _affinityGroupJoinDao.searchAndCount(sc,
searchFilter);
         // search group details by ids
@@ -3093,26 +3095,26 @@ public class QueryManagerImpl extends ManagerBase implements QueryService
{
         if (!permittedAccounts.isEmpty()) {
             // add domain level affinity groups
             if (domainId != null) {
-                SearchCriteria<AffinityGroupJoinVO> scDomain =
-                    buildAffinityGroupSearchCriteria(null, isRecursive, new ArrayList<Long>(),
listProjectResourcesCriteria, affinityGroupId, affinityGroupName,
-                        affinityGroupType);
+                SearchCriteria<AffinityGroupJoinVO> scDomain = buildAffinityGroupSearchCriteria(null,
isRecursive,
+                        new ArrayList<Long>(), listProjectResourcesCriteria, affinityGroupId,
affinityGroupName,
+                        affinityGroupType, keyword);
                 vrs.addAll(listDomainLevelAffinityGroups(scDomain, searchFilter, domainId));
             } else {
 
                 for (Long permAcctId : permittedAccounts) {
                     Account permittedAcct = _accountDao.findById(permAcctId);
-                    SearchCriteria<AffinityGroupJoinVO> scDomain =
-                        buildAffinityGroupSearchCriteria(null, isRecursive, new ArrayList<Long>(),
listProjectResourcesCriteria, affinityGroupId, affinityGroupName,
-                            affinityGroupType);
+                    SearchCriteria<AffinityGroupJoinVO> scDomain = buildAffinityGroupSearchCriteria(
+                            null, isRecursive, new ArrayList<Long>(),
+                            listProjectResourcesCriteria, affinityGroupId, affinityGroupName,
affinityGroupType, keyword);
 
                     vrs.addAll(listDomainLevelAffinityGroups(scDomain, searchFilter, permittedAcct.getDomainId()));
                 }
             }
         } else if (((permittedAccounts.isEmpty()) && (domainId != null) &&
isRecursive)) {
             // list all domain level affinity groups for the domain admin case
-            SearchCriteria<AffinityGroupJoinVO> scDomain =
-                buildAffinityGroupSearchCriteria(null, isRecursive, new ArrayList<Long>(),
listProjectResourcesCriteria, affinityGroupId, affinityGroupName,
-                    affinityGroupType);
+            SearchCriteria<AffinityGroupJoinVO> scDomain = buildAffinityGroupSearchCriteria(null,
isRecursive,
+                    new ArrayList<Long>(), listProjectResourcesCriteria, affinityGroupId,
affinityGroupName,
+                    affinityGroupType, keyword);
             vrs.addAll(listDomainLevelAffinityGroups(scDomain, searchFilter, domainId));
         }
 
@@ -3120,8 +3122,9 @@ public class QueryManagerImpl extends ManagerBase implements QueryService
{
 
     }
 
-    private SearchCriteria<AffinityGroupJoinVO> buildAffinityGroupSearchCriteria(Long
domainId, boolean isRecursive, List<Long> permittedAccounts,
-        ListProjectResourcesCriteria listProjectResourcesCriteria, Long affinityGroupId,
String affinityGroupName, String affinityGroupType) {
+    private SearchCriteria<AffinityGroupJoinVO> buildAffinityGroupSearchCriteria(Long
domainId, boolean isRecursive,
+            List<Long> permittedAccounts, ListProjectResourcesCriteria listProjectResourcesCriteria,
+            Long affinityGroupId, String affinityGroupName, String affinityGroupType, String
keyword) {
 
         SearchBuilder<AffinityGroupJoinVO> groupSearch = _affinityGroupJoinDao.createSearchBuilder();
         _accountMgr.buildACLViewSearchBuilder(groupSearch, domainId, isRecursive, permittedAccounts,
listProjectResourcesCriteria);
@@ -3144,6 +3147,14 @@ public class QueryManagerImpl extends ManagerBase implements QueryService
{
             sc.addAnd("type", SearchCriteria.Op.EQ, affinityGroupType);
         }
 
+        if (keyword != null) {
+            SearchCriteria<AffinityGroupJoinVO> ssc = _affinityGroupJoinDao.createSearchCriteria();
+            ssc.addOr("name", SearchCriteria.Op.LIKE, "%" + keyword + "%");
+            ssc.addOr("type", SearchCriteria.Op.LIKE, "%" + keyword + "%");
+
+            sc.addAnd("name", SearchCriteria.Op.SC, ssc);
+        }
+
         return sc;
 
     }


Mime
View raw message