@@ -616,48 +616,69 @@ public List<? extends Cluster> searchForClusters(long zoneId, Long startIndex, L
616616
617617 @ Override
618618 public Pair <List <? extends Cluster >, Integer > searchForClusters (ListClustersCmd cmd ) {
619- Filter searchFilter = new Filter (ClusterVO .class , "id" , true , cmd .getStartIndex (), cmd .getPageSizeVal ());
620- SearchCriteria <ClusterVO > sc = _clusterDao .createSearchCriteria ();
621-
622- Object id = cmd .getId ();
619+ Object id = cmd .getId ();
623620 Object name = cmd .getClusterName ();
624621 Object podId = cmd .getPodId ();
625622 Long zoneId = cmd .getZoneId ();
626623 Object hypervisorType = cmd .getHypervisorType ();
627624 Object clusterType = cmd .getClusterType ();
628625 Object allocationState = cmd .getAllocationState ();
626+ String zoneType = cmd .getZoneType ();
629627 String keyword = cmd .getKeyword ();
630-
631628 zoneId = _accountMgr .checkAccessAndSpecifyAuthority (UserContext .current ().getCaller (), zoneId );
632-
629+
630+
631+ Filter searchFilter = new Filter (ClusterVO .class , "id" , true , cmd .getStartIndex (), cmd .getPageSizeVal ());
632+
633+ SearchBuilder <ClusterVO > sb = _clusterDao .createSearchBuilder ();
634+ sb .and ("id" , sb .entity ().getId (), SearchCriteria .Op .EQ );
635+ sb .and ("name" , sb .entity ().getName (), SearchCriteria .Op .LIKE );
636+ sb .and ("podId" , sb .entity ().getPodId (), SearchCriteria .Op .EQ );
637+ sb .and ("dataCenterId" , sb .entity ().getDataCenterId (), SearchCriteria .Op .EQ );
638+ sb .and ("hypervisorType" , sb .entity ().getHypervisorType (), SearchCriteria .Op .EQ );
639+ sb .and ("clusterType" , sb .entity ().getClusterType (), SearchCriteria .Op .EQ );
640+ sb .and ("allocationState" , sb .entity ().getAllocationState (), SearchCriteria .Op .EQ );
641+
642+ if (zoneType != null ) {
643+ SearchBuilder <DataCenterVO > zoneSb = _dcDao .createSearchBuilder ();
644+ zoneSb .and ("zoneNetworkType" , zoneSb .entity ().getNetworkType (), SearchCriteria .Op .EQ );
645+ sb .join ("zoneSb" , zoneSb , sb .entity ().getDataCenterId (), zoneSb .entity ().getId (), JoinBuilder .JoinType .INNER );
646+ }
647+
648+
649+ SearchCriteria <ClusterVO > sc = sb .create ();
633650 if (id != null ) {
634- sc .addAnd ("id" , SearchCriteria . Op . EQ , id );
651+ sc .setParameters ("id" , id );
635652 }
636653
637654 if (name != null ) {
638- sc .addAnd ("name" , SearchCriteria . Op . LIKE , "%" + name + "%" );
655+ sc .setParameters ("name" , "%" + name + "%" );
639656 }
640657
641658 if (podId != null ) {
642- sc .addAnd ("podId" , SearchCriteria . Op . EQ , podId );
659+ sc .setParameters ("podId" , podId );
643660 }
644661
645662 if (zoneId != null ) {
646- sc .addAnd ("dataCenterId" , SearchCriteria . Op . EQ , zoneId );
663+ sc .setParameters ("dataCenterId" , zoneId );
647664 }
648665
649666 if (hypervisorType != null ) {
650- sc .addAnd ("hypervisorType" , SearchCriteria . Op . EQ , hypervisorType );
667+ sc .setParameters ("hypervisorType" , hypervisorType );
651668 }
652669
653670 if (clusterType != null ) {
654- sc .addAnd ("clusterType" , SearchCriteria . Op . EQ , clusterType );
671+ sc .setParameters ("clusterType" , clusterType );
655672 }
656673
657674 if (allocationState != null ) {
658- sc .addAnd ("allocationState" , SearchCriteria . Op . EQ , allocationState );
675+ sc .setParameters ("allocationState" , allocationState );
659676 }
660677
678+ if (zoneType != null ) {
679+ sc .setJoinParameters ("zoneSb" , "zoneNetworkType" , zoneType );
680+ }
681+
661682 if (keyword != null ) {
662683 SearchCriteria <ClusterVO > ssc = _clusterDao .createSearchCriteria ();
663684 ssc .addOr ("name" , SearchCriteria .Op .LIKE , "%" + keyword + "%" );
0 commit comments