use of com.cloud.api.query.vo.StorageTagVO in project cosmic by MissionCriticalCloud.
the class QueryManagerImpl method searchForStorageTagsInternal.
private Pair<List<StorageTagVO>, Integer> searchForStorageTagsInternal(final ListStorageTagsCmd cmd) {
final Filter searchFilter = new Filter(StorageTagVO.class, "id", Boolean.TRUE, null, null);
final SearchBuilder<StorageTagVO> sb = _storageTagDao.createSearchBuilder();
// select distinct
sb.select(null, Func.DISTINCT, sb.entity().getId());
final SearchCriteria<StorageTagVO> sc = sb.create();
// search storage tag details by ids
final Pair<List<StorageTagVO>, Integer> uniqueTagPair = _storageTagDao.searchAndCount(sc, searchFilter);
final Integer count = uniqueTagPair.second();
if (count.intValue() == 0) {
return uniqueTagPair;
}
final List<StorageTagVO> uniqueTags = uniqueTagPair.first();
final Long[] vrIds = new Long[uniqueTags.size()];
int i = 0;
for (final StorageTagVO v : uniqueTags) {
vrIds[i++] = v.getId();
}
final List<StorageTagVO> vrs = _storageTagDao.searchByIds(vrIds);
return new Pair<>(vrs, count);
}
Aggregations