@@ -2860,6 +2860,7 @@ private Pair<List<Long>, Integer> searchForDomainIdsAndCount(ListDomainsCmd cmd)
28602860 boolean listAll = cmd .listAll ();
28612861 boolean isRecursive = false ;
28622862 Domain domain = null ;
2863+ Map <String , String > tags = cmd .getTags ();
28632864
28642865 if (domainId != null ) {
28652866 domain = _domainDao .findById (domainId );
@@ -2889,6 +2890,24 @@ private Pair<List<Long>, Integer> searchForDomainIdsAndCount(ListDomainsCmd cmd)
28892890 domainSearchBuilder .and ("path" , domainSearchBuilder .entity ().getPath (), SearchCriteria .Op .LIKE );
28902891 domainSearchBuilder .and ("state" , domainSearchBuilder .entity ().getState (), SearchCriteria .Op .EQ );
28912892
2893+ if (MapUtils .isNotEmpty (tags )) {
2894+ SearchBuilder <ResourceTagVO > resourceTagSearch = resourceTagDao .createSearchBuilder ();
2895+ resourceTagSearch .and ("resourceType" , resourceTagSearch .entity ().getResourceType (), Op .EQ );
2896+ resourceTagSearch .and ().op ();
2897+ for (int count = 0 ; count < tags .size (); count ++) {
2898+ if (count == 0 ) {
2899+ resourceTagSearch .op ("tagKey" + count , resourceTagSearch .entity ().getKey (), Op .EQ );
2900+ } else {
2901+ resourceTagSearch .or ().op ("tagKey" + count , resourceTagSearch .entity ().getKey (), Op .EQ );
2902+ }
2903+ resourceTagSearch .and ("tagValue" + count , resourceTagSearch .entity ().getValue (), Op .EQ );
2904+ resourceTagSearch .cp ();
2905+ }
2906+ resourceTagSearch .cp ();
2907+
2908+ domainSearchBuilder .join ("tags" , resourceTagSearch , resourceTagSearch .entity ().getResourceId (), domainSearchBuilder .entity ().getId (), JoinBuilder .JoinType .INNER );
2909+ }
2910+
28922911 if (keyword != null ) {
28932912 domainSearchBuilder .and ("keywordName" , domainSearchBuilder .entity ().getName (), SearchCriteria .Op .LIKE );
28942913 }
@@ -2918,6 +2937,16 @@ private Pair<List<Long>, Integer> searchForDomainIdsAndCount(ListDomainsCmd cmd)
29182937 }
29192938 }
29202939
2940+ if (MapUtils .isNotEmpty (tags )) {
2941+ int count = 0 ;
2942+ sc .setJoinParameters ("tags" , "resourceType" , ResourceObjectType .Domain );
2943+ for (Map .Entry <String , String > entry : tags .entrySet ()) {
2944+ sc .setJoinParameters ("tags" , "tagKey" + count , entry .getKey ());
2945+ sc .setJoinParameters ("tags" , "tagValue" + count , entry .getValue ());
2946+ count ++;
2947+ }
2948+ }
2949+
29212950 // return only Active domains to the API
29222951 sc .setParameters ("state" , Domain .State .Active );
29232952
0 commit comments