|
52 | 52 | import com.cloud.user.AccountManager; |
53 | 53 | import com.cloud.utils.component.ComponentContext; |
54 | 54 | import com.cloud.utils.component.ManagerBase; |
| 55 | +import com.cloud.utils.db.Filter; |
| 56 | +import com.cloud.utils.db.SearchBuilder; |
| 57 | +import com.cloud.utils.db.SearchCriteria; |
55 | 58 | import com.cloud.utils.exception.CloudRuntimeException; |
56 | 59 | import com.google.common.base.Strings; |
57 | 60 |
|
@@ -246,19 +249,25 @@ public ListResponse<KubernetesSupportedVersionResponse> listKubernetesSupportedV |
246 | 249 | } |
247 | 250 | minimumSemanticVersion = minVersion.getSemanticVersion(); |
248 | 251 | } |
249 | | - List <KubernetesSupportedVersionVO> versions = new ArrayList<>(); |
| 252 | + Filter searchFilter = new Filter(KubernetesSupportedVersionVO.class, "id", true, cmd.getStartIndex(), cmd.getPageSizeVal()); |
| 253 | + SearchBuilder<KubernetesSupportedVersionVO> sb = kubernetesSupportedVersionDao.createSearchBuilder(); |
| 254 | + sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ); |
| 255 | + sb.and("keyword", sb.entity().getName(), SearchCriteria.Op.LIKE); |
| 256 | + SearchCriteria<KubernetesSupportedVersionVO> sc = sb.create(); |
| 257 | + String keyword = cmd.getKeyword(); |
250 | 258 | if (versionId != null) { |
251 | | - KubernetesSupportedVersionVO version = kubernetesSupportedVersionDao.findById(versionId); |
252 | | - if (version != null && (zoneId == null || version.getZoneId() == null || version.getZoneId().equals(zoneId))) { |
253 | | - versions.add(version); |
254 | | - } |
255 | | - } else { |
256 | | - if (zoneId == null) { |
257 | | - versions = kubernetesSupportedVersionDao.listAll(); |
258 | | - } else { |
259 | | - versions = kubernetesSupportedVersionDao.listAllInZone(zoneId); |
260 | | - } |
| 259 | + sc.setParameters("id", versionId); |
| 260 | + } |
| 261 | + if (zoneId == null) { |
| 262 | + SearchCriteria<KubernetesSupportedVersionVO> scc = kubernetesSupportedVersionDao.createSearchCriteria(); |
| 263 | + scc.addOr("zoneId", SearchCriteria.Op.EQ, zoneId); |
| 264 | + scc.addOr("zoneId", SearchCriteria.Op.NULL); |
| 265 | + sc.addAnd("zoneId", SearchCriteria.Op.SC, scc); |
| 266 | + } |
| 267 | + if(keyword != null){ |
| 268 | + sc.setParameters("keyword", "%" + keyword + "%"); |
261 | 269 | } |
| 270 | + List <KubernetesSupportedVersionVO> versions = kubernetesSupportedVersionDao.search(sc, searchFilter); |
262 | 271 | versions = filterKubernetesSupportedVersions(versions, minimumSemanticVersion); |
263 | 272 |
|
264 | 273 | return createKubernetesSupportedVersionListResponse(versions); |
|
0 commit comments