Search in sources :

Example 1 with StorageTagVO

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);
}
Also used : TemplateFilter(com.cloud.template.VirtualMachineTemplate.TemplateFilter) Filter(com.cloud.utils.db.Filter) ArrayList(java.util.ArrayList) List(java.util.List) StorageTagVO(com.cloud.api.query.vo.StorageTagVO) Pair(com.cloud.utils.Pair)

Aggregations

StorageTagVO (com.cloud.api.query.vo.StorageTagVO)1 TemplateFilter (com.cloud.template.VirtualMachineTemplate.TemplateFilter)1 Pair (com.cloud.utils.Pair)1 Filter (com.cloud.utils.db.Filter)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1