@@ -3037,18 +3037,21 @@ private Pair<List<TemplateJoinVO>, Integer> searchForIsosInternal(ListIsosCmd cm
30373037 }
30383038
30393039 @ Override
3040- public ListResponse <AffinityGroupResponse > listAffinityGroups (Long affinityGroupId , String affinityGroupName , String affinityGroupType , Long vmId ,
3041- String accountName , Long domainId , boolean isRecursive , boolean listAll , Long startIndex , Long pageSize ) {
3042- Pair <List <AffinityGroupJoinVO >, Integer > result =
3043- listAffinityGroupsInternal (affinityGroupId , affinityGroupName , affinityGroupType , vmId , accountName , domainId , isRecursive , listAll , startIndex , pageSize );
3040+ public ListResponse <AffinityGroupResponse > listAffinityGroups (Long affinityGroupId , String affinityGroupName ,
3041+ String affinityGroupType , Long vmId , String accountName , Long domainId , boolean isRecursive ,
3042+ boolean listAll , Long startIndex , Long pageSize , String keyword ) {
3043+ Pair <List <AffinityGroupJoinVO >, Integer > result = listAffinityGroupsInternal (affinityGroupId ,
3044+ affinityGroupName , affinityGroupType , vmId , accountName , domainId , isRecursive , listAll , startIndex ,
3045+ pageSize , keyword );
30443046 ListResponse <AffinityGroupResponse > response = new ListResponse <AffinityGroupResponse >();
30453047 List <AffinityGroupResponse > agResponses = ViewResponseHelper .createAffinityGroupResponses (result .first ());
30463048 response .setResponses (agResponses , result .second ());
30473049 return response ;
30483050 }
30493051
3050- public Pair <List <AffinityGroupJoinVO >, Integer > listAffinityGroupsInternal (Long affinityGroupId , String affinityGroupName , String affinityGroupType , Long vmId ,
3051- String accountName , Long domainId , boolean isRecursive , boolean listAll , Long startIndex , Long pageSize ) {
3052+ public Pair <List <AffinityGroupJoinVO >, Integer > listAffinityGroupsInternal (Long affinityGroupId ,
3053+ String affinityGroupName , String affinityGroupType , Long vmId , String accountName , Long domainId ,
3054+ boolean isRecursive , boolean listAll , Long startIndex , Long pageSize , String keyword ) {
30523055
30533056 Account caller = CallContext .current ().getCallingAccount ();
30543057
@@ -3072,9 +3075,8 @@ public Pair<List<AffinityGroupJoinVO>, Integer> listAffinityGroupsInternal(Long
30723075 ListProjectResourcesCriteria listProjectResourcesCriteria = domainIdRecursiveListProject .third ();
30733076
30743077 Filter searchFilter = new Filter (AffinityGroupJoinVO .class , "id" , true , startIndex , pageSize );
3075- SearchCriteria <AffinityGroupJoinVO > sc =
3076- buildAffinityGroupSearchCriteria (domainId , isRecursive , permittedAccounts , listProjectResourcesCriteria , affinityGroupId , affinityGroupName ,
3077- affinityGroupType );
3078+ SearchCriteria <AffinityGroupJoinVO > sc = buildAffinityGroupSearchCriteria (domainId , isRecursive ,
3079+ permittedAccounts , listProjectResourcesCriteria , affinityGroupId , affinityGroupName , affinityGroupType , keyword );
30783080
30793081 Pair <List <AffinityGroupJoinVO >, Integer > uniqueGroupsPair = _affinityGroupJoinDao .searchAndCount (sc , searchFilter );
30803082 // search group details by ids
@@ -3093,35 +3095,36 @@ public Pair<List<AffinityGroupJoinVO>, Integer> listAffinityGroupsInternal(Long
30933095 if (!permittedAccounts .isEmpty ()) {
30943096 // add domain level affinity groups
30953097 if (domainId != null ) {
3096- SearchCriteria <AffinityGroupJoinVO > scDomain =
3097- buildAffinityGroupSearchCriteria ( null , isRecursive , new ArrayList <Long >(), listProjectResourcesCriteria , affinityGroupId , affinityGroupName ,
3098- affinityGroupType );
3098+ SearchCriteria <AffinityGroupJoinVO > scDomain = buildAffinityGroupSearchCriteria ( null , isRecursive ,
3099+ new ArrayList <Long >(), listProjectResourcesCriteria , affinityGroupId , affinityGroupName ,
3100+ affinityGroupType , keyword );
30993101 vrs .addAll (listDomainLevelAffinityGroups (scDomain , searchFilter , domainId ));
31003102 } else {
31013103
31023104 for (Long permAcctId : permittedAccounts ) {
31033105 Account permittedAcct = _accountDao .findById (permAcctId );
3104- SearchCriteria <AffinityGroupJoinVO > scDomain =
3105- buildAffinityGroupSearchCriteria ( null , isRecursive , new ArrayList <Long >(), listProjectResourcesCriteria , affinityGroupId , affinityGroupName ,
3106- affinityGroupType );
3106+ SearchCriteria <AffinityGroupJoinVO > scDomain = buildAffinityGroupSearchCriteria (
3107+ null , isRecursive , new ArrayList <Long >(),
3108+ listProjectResourcesCriteria , affinityGroupId , affinityGroupName , affinityGroupType , keyword );
31073109
31083110 vrs .addAll (listDomainLevelAffinityGroups (scDomain , searchFilter , permittedAcct .getDomainId ()));
31093111 }
31103112 }
31113113 } else if (((permittedAccounts .isEmpty ()) && (domainId != null ) && isRecursive )) {
31123114 // list all domain level affinity groups for the domain admin case
3113- SearchCriteria <AffinityGroupJoinVO > scDomain =
3114- buildAffinityGroupSearchCriteria ( null , isRecursive , new ArrayList <Long >(), listProjectResourcesCriteria , affinityGroupId , affinityGroupName ,
3115- affinityGroupType );
3115+ SearchCriteria <AffinityGroupJoinVO > scDomain = buildAffinityGroupSearchCriteria ( null , isRecursive ,
3116+ new ArrayList <Long >(), listProjectResourcesCriteria , affinityGroupId , affinityGroupName ,
3117+ affinityGroupType , keyword );
31163118 vrs .addAll (listDomainLevelAffinityGroups (scDomain , searchFilter , domainId ));
31173119 }
31183120
31193121 return new Pair <List <AffinityGroupJoinVO >, Integer >(vrs , vrs .size ());
31203122
31213123 }
31223124
3123- private SearchCriteria <AffinityGroupJoinVO > buildAffinityGroupSearchCriteria (Long domainId , boolean isRecursive , List <Long > permittedAccounts ,
3124- ListProjectResourcesCriteria listProjectResourcesCriteria , Long affinityGroupId , String affinityGroupName , String affinityGroupType ) {
3125+ private SearchCriteria <AffinityGroupJoinVO > buildAffinityGroupSearchCriteria (Long domainId , boolean isRecursive ,
3126+ List <Long > permittedAccounts , ListProjectResourcesCriteria listProjectResourcesCriteria ,
3127+ Long affinityGroupId , String affinityGroupName , String affinityGroupType , String keyword ) {
31253128
31263129 SearchBuilder <AffinityGroupJoinVO > groupSearch = _affinityGroupJoinDao .createSearchBuilder ();
31273130 _accountMgr .buildACLViewSearchBuilder (groupSearch , domainId , isRecursive , permittedAccounts , listProjectResourcesCriteria );
@@ -3144,6 +3147,14 @@ private SearchCriteria<AffinityGroupJoinVO> buildAffinityGroupSearchCriteria(Lon
31443147 sc .addAnd ("type" , SearchCriteria .Op .EQ , affinityGroupType );
31453148 }
31463149
3150+ if (keyword != null ) {
3151+ SearchCriteria <AffinityGroupJoinVO > ssc = _affinityGroupJoinDao .createSearchCriteria ();
3152+ ssc .addOr ("name" , SearchCriteria .Op .LIKE , "%" + keyword + "%" );
3153+ ssc .addOr ("type" , SearchCriteria .Op .LIKE , "%" + keyword + "%" );
3154+
3155+ sc .addAnd ("name" , SearchCriteria .Op .SC , ssc );
3156+ }
3157+
31473158 return sc ;
31483159
31493160 }
0 commit comments