@@ -1068,17 +1068,29 @@ private Pair<List<HostVO>, Integer> searchForServers(Long startIndex, Long pageS
10681068
10691069 @ Override
10701070 public Pair <List <? extends Pod >, Integer > searchForPods (ListPodsByCmd cmd ) {
1071- Filter searchFilter = new Filter (HostPodVO .class , "dataCenterId" , true , cmd .getStartIndex (), cmd .getPageSizeVal ());
1072- SearchCriteria <HostPodVO > sc = _hostPodDao .createSearchCriteria ();
1073-
10741071 String podName = cmd .getPodName ();
10751072 Long id = cmd .getId ();
1076- Long zoneId = cmd .getZoneId ();
1073+ Long zoneId = cmd .getZoneId ();
10771074 Object keyword = cmd .getKeyword ();
10781075 Object allocationState = cmd .getAllocationState ();
1079-
1076+ String zoneType = cmd . getZoneType ();
10801077 zoneId = _accountMgr .checkAccessAndSpecifyAuthority (UserContext .current ().getCaller (), zoneId );
10811078
1079+
1080+ Filter searchFilter = new Filter (HostPodVO .class , "dataCenterId" , true , cmd .getStartIndex (), cmd .getPageSizeVal ());
1081+ SearchBuilder <HostPodVO > sb = _hostPodDao .createSearchBuilder ();
1082+ sb .and ("id" , sb .entity ().getId (), SearchCriteria .Op .EQ );
1083+ sb .and ("name" , sb .entity ().getName (), SearchCriteria .Op .LIKE );
1084+ sb .and ("dataCenterId" , sb .entity ().getDataCenterId (), SearchCriteria .Op .EQ );
1085+ sb .and ("allocationState" , sb .entity ().getAllocationState (), SearchCriteria .Op .EQ );
1086+
1087+ if (zoneType != null ) {
1088+ SearchBuilder <DataCenterVO > zoneSb = _dcDao .createSearchBuilder ();
1089+ zoneSb .and ("zoneNetworkType" , zoneSb .entity ().getNetworkType (), SearchCriteria .Op .EQ );
1090+ sb .join ("zoneSb" , zoneSb , sb .entity ().getDataCenterId (), zoneSb .entity ().getId (), JoinBuilder .JoinType .INNER );
1091+ }
1092+
1093+ SearchCriteria <HostPodVO > sc = sb .create ();
10821094 if (keyword != null ) {
10831095 SearchCriteria <HostPodVO > ssc = _hostPodDao .createSearchCriteria ();
10841096 ssc .addOr ("name" , SearchCriteria .Op .LIKE , "%" + keyword + "%" );
@@ -1088,21 +1100,25 @@ public Pair<List<? extends Pod>, Integer> searchForPods(ListPodsByCmd cmd) {
10881100 }
10891101
10901102 if (id != null ) {
1091- sc .addAnd ("id" , SearchCriteria . Op . EQ , id );
1103+ sc .setParameters ("id" , id );
10921104 }
1093-
1105+
10941106 if (podName != null ) {
1095- sc .addAnd ("name" , SearchCriteria . Op . LIKE , "%" + podName + "%" );
1107+ sc .setParameters ("name" , "%" + podName + "%" );
10961108 }
1097-
1109+
10981110 if (zoneId != null ) {
1099- sc .addAnd ("dataCenterId" , SearchCriteria . Op . EQ , zoneId );
1111+ sc .setParameters ("dataCenterId" , zoneId );
11001112 }
1101-
1113+
11021114 if (allocationState != null ) {
1103- sc .addAnd ("allocationState" , SearchCriteria .Op .EQ , allocationState );
1115+ sc .setParameters ("allocationState" , allocationState );
1116+ }
1117+
1118+ if (zoneType != null ) {
1119+ sc .setJoinParameters ("zoneSb" , "zoneNetworkType" , zoneType );
11041120 }
1105-
1121+
11061122 Pair <List <HostPodVO >, Integer > result = _hostPodDao .searchAndCount (sc , searchFilter );
11071123 return new Pair <List <? extends Pod >, Integer >(result .first (), result .second ());
11081124 }
0 commit comments