public PrimaryDataStoreDaoImpl() { AllFieldSearch = createSearchBuilder(); AllFieldSearch.and("name", AllFieldSearch.entity().getName(), SearchCriteria.Op.EQ); AllFieldSearch.and("uuid", AllFieldSearch.entity().getUuid(), SearchCriteria.Op.EQ); AllFieldSearch.done(); DcPodSearch = createSearchBuilder(); DcPodSearch.and("datacenterId", DcPodSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ); DcPodSearch.and("status", DcPodSearch.entity().getStatus(), SearchCriteria.Op.EQ); DcPodSearch.done(); DcPodAnyClusterSearch = createSearchBuilder(); DcPodAnyClusterSearch.and("datacenterId", DcPodAnyClusterSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ); DcPodAnyClusterSearch.and("status", DcPodAnyClusterSearch.entity().getStatus(), SearchCriteria.Op.EQ); DeleteLvmSearch = createSearchBuilder(); DeleteLvmSearch.and("ids", DeleteLvmSearch.entity().getId(), SearchCriteria.Op.IN); DeleteLvmSearch.and().op("LVM", DeleteLvmSearch.entity().getPoolType(), SearchCriteria.Op.EQ); StatusCountSearch = createSearchBuilder(Long.class); StatusCountSearch.and("status", StatusCountSearch.entity().getStatus(), SearchCriteria.Op.IN); StatusCountSearch.select(null, Func.COUNT, null); StatusCountSearch.done(); DcLocalStorageSearch = createSearchBuilder(); DcLocalStorageSearch.and("datacenterId", DcLocalStorageSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ); DcLocalStorageSearch.and("path", DcLocalStorageSearch.entity().getPath(), SearchCriteria.Op.EQ);
@Override public List<StoragePoolVO> findLocalStoragePoolsByHostAndTags(long hostId, String[] tags) { SearchBuilder<StoragePoolVO> hostSearch = createSearchBuilder(); SearchBuilder<StoragePoolHostVO> hostPoolSearch = _hostDao.createSearchBuilder(); SearchBuilder<StoragePoolTagVO> tagPoolSearch = _tagsDao.createSearchBuilder(); ; // Search for pools on the host hostPoolSearch.and("hostId", hostPoolSearch.entity().getHostId(), Op.EQ); // Set criteria for pools hostSearch.and("scope", hostSearch.entity().getScope(), Op.EQ); hostSearch.and("removed", hostSearch.entity().getRemoved(), Op.NULL); hostSearch.and("status", hostSearch.entity().getStatus(), Op.EQ); hostSearch.join("hostJoin", hostPoolSearch, hostSearch.entity().getId(), hostPoolSearch.entity().getPoolId(), JoinBuilder.JoinType.INNER); if (!(tags == null || tags.length == 0)) { tagPoolSearch.and("tag", tagPoolSearch.entity().getTag(), Op.EQ); hostSearch.join("tagJoin", tagPoolSearch, hostSearch.entity().getId(), tagPoolSearch.entity().getPoolId(), JoinBuilder.JoinType.INNER); } SearchCriteria<StoragePoolVO> sc = hostSearch.create(); sc.setJoinParameters("hostJoin", "hostId", hostId); sc.setParameters("scope", ScopeType.HOST.toString()); sc.setParameters("status", Status.Up.toString()); if (!(tags == null || tags.length == 0)) { for (String tag : tags) { sc.setJoinParameters("tagJoin", "tag", tag); } } return listBy(sc); }