@@ -3138,10 +3138,10 @@ private Pair<List<TemplateJoinVO>, Integer> searchForIsosInternal(ListIsosCmd cm
31383138 @ Override
31393139 public ListResponse <AffinityGroupResponse > listAffinityGroups (Long affinityGroupId , String affinityGroupName ,
31403140 String affinityGroupType , Long vmId , String accountName , Long domainId , boolean isRecursive ,
3141- boolean listAll , Long startIndex , Long pageSize ) {
3141+ boolean listAll , Long startIndex , Long pageSize , String keyword ) {
31423142 Pair <List <AffinityGroupJoinVO >, Integer > result = listAffinityGroupsInternal (affinityGroupId ,
31433143 affinityGroupName , affinityGroupType , vmId , accountName , domainId , isRecursive , listAll , startIndex ,
3144- pageSize );
3144+ pageSize , keyword );
31453145 ListResponse <AffinityGroupResponse > response = new ListResponse <AffinityGroupResponse >();
31463146 List <AffinityGroupResponse > agResponses = ViewResponseHelper .createAffinityGroupResponses (result .first ());
31473147 response .setResponses (agResponses , result .second ());
@@ -3150,7 +3150,7 @@ public ListResponse<AffinityGroupResponse> listAffinityGroups(Long affinityGroup
31503150
31513151 public Pair <List <AffinityGroupJoinVO >, Integer > listAffinityGroupsInternal (Long affinityGroupId ,
31523152 String affinityGroupName , String affinityGroupType , Long vmId , String accountName , Long domainId ,
3153- boolean isRecursive , boolean listAll , Long startIndex , Long pageSize ) {
3153+ boolean isRecursive , boolean listAll , Long startIndex , Long pageSize , String keyword ) {
31543154
31553155 Account caller = CallContext .current ().getCallingAccount ();
31563156
@@ -3177,7 +3177,7 @@ public Pair<List<AffinityGroupJoinVO>, Integer> listAffinityGroupsInternal(Long
31773177
31783178 Filter searchFilter = new Filter (AffinityGroupJoinVO .class , "id" , true , startIndex , pageSize );
31793179 SearchCriteria <AffinityGroupJoinVO > sc = buildAffinityGroupSearchCriteria (domainId , isRecursive ,
3180- permittedAccounts , listProjectResourcesCriteria , affinityGroupId , affinityGroupName , affinityGroupType );
3180+ permittedAccounts , listProjectResourcesCriteria , affinityGroupId , affinityGroupName , affinityGroupType , keyword );
31813181
31823182 Pair <List <AffinityGroupJoinVO >, Integer > uniqueGroupsPair = _affinityGroupJoinDao .searchAndCount (sc ,
31833183 searchFilter );
@@ -3199,15 +3199,15 @@ public Pair<List<AffinityGroupJoinVO>, Integer> listAffinityGroupsInternal(Long
31993199 if (domainId != null ) {
32003200 SearchCriteria <AffinityGroupJoinVO > scDomain = buildAffinityGroupSearchCriteria (null , isRecursive ,
32013201 new ArrayList <Long >(), listProjectResourcesCriteria , affinityGroupId , affinityGroupName ,
3202- affinityGroupType );
3202+ affinityGroupType , keyword );
32033203 vrs .addAll (listDomainLevelAffinityGroups (scDomain , searchFilter , domainId ));
32043204 } else {
32053205
32063206 for (Long permAcctId : permittedAccounts ) {
32073207 Account permittedAcct = _accountDao .findById (permAcctId );
32083208 SearchCriteria <AffinityGroupJoinVO > scDomain = buildAffinityGroupSearchCriteria (
32093209 null , isRecursive , new ArrayList <Long >(),
3210- listProjectResourcesCriteria , affinityGroupId , affinityGroupName , affinityGroupType );
3210+ listProjectResourcesCriteria , affinityGroupId , affinityGroupName , affinityGroupType , keyword );
32113211
32123212 vrs .addAll (listDomainLevelAffinityGroups (scDomain , searchFilter , permittedAcct .getDomainId ()));
32133213 }
@@ -3216,7 +3216,7 @@ public Pair<List<AffinityGroupJoinVO>, Integer> listAffinityGroupsInternal(Long
32163216 // list all domain level affinity groups for the domain admin case
32173217 SearchCriteria <AffinityGroupJoinVO > scDomain = buildAffinityGroupSearchCriteria (null , isRecursive ,
32183218 new ArrayList <Long >(), listProjectResourcesCriteria , affinityGroupId , affinityGroupName ,
3219- affinityGroupType );
3219+ affinityGroupType , keyword );
32203220 vrs .addAll (listDomainLevelAffinityGroups (scDomain , searchFilter , domainId ));
32213221 }
32223222
@@ -3226,7 +3226,7 @@ public Pair<List<AffinityGroupJoinVO>, Integer> listAffinityGroupsInternal(Long
32263226
32273227 private SearchCriteria <AffinityGroupJoinVO > buildAffinityGroupSearchCriteria (Long domainId , boolean isRecursive ,
32283228 List <Long > permittedAccounts , ListProjectResourcesCriteria listProjectResourcesCriteria ,
3229- Long affinityGroupId , String affinityGroupName , String affinityGroupType ) {
3229+ Long affinityGroupId , String affinityGroupName , String affinityGroupType , String keyword ) {
32303230
32313231 SearchBuilder <AffinityGroupJoinVO > groupSearch = _affinityGroupJoinDao .createSearchBuilder ();
32323232 _accountMgr .buildACLViewSearchBuilder (groupSearch , domainId , isRecursive , permittedAccounts ,
@@ -3251,6 +3251,14 @@ private SearchCriteria<AffinityGroupJoinVO> buildAffinityGroupSearchCriteria(Lon
32513251 sc .addAnd ("type" , SearchCriteria .Op .EQ , affinityGroupType );
32523252 }
32533253
3254+ if (keyword != null ) {
3255+ SearchCriteria <AffinityGroupJoinVO > ssc = _affinityGroupJoinDao .createSearchCriteria ();
3256+ ssc .addOr ("name" , SearchCriteria .Op .LIKE , "%" + keyword + "%" );
3257+ ssc .addOr ("type" , SearchCriteria .Op .LIKE , "%" + keyword + "%" );
3258+
3259+ sc .addAnd ("name" , SearchCriteria .Op .SC , ssc );
3260+ }
3261+
32543262 return sc ;
32553263
32563264 }
0 commit comments