Search in sources :

Example 1 with HostTagVO

use of com.cloud.api.query.vo.HostTagVO in project cloudstack by apache.

the class QueryManagerImpl method searchForHostTagsInternal.

private Pair<List<HostTagVO>, Integer> searchForHostTagsInternal(ListHostTagsCmd cmd) {
    Filter searchFilter = new Filter(HostTagVO.class, "id", Boolean.TRUE, null, null);
    SearchBuilder<HostTagVO> sb = _hostTagDao.createSearchBuilder();
    // select distinct
    sb.select(null, Func.DISTINCT, sb.entity().getId());
    SearchCriteria<HostTagVO> sc = sb.create();
    // search host tag details by ids
    Pair<List<HostTagVO>, Integer> uniqueTagPair = _hostTagDao.searchAndCount(sc, searchFilter);
    Integer count = uniqueTagPair.second();
    if (count.intValue() == 0) {
        return uniqueTagPair;
    }
    List<HostTagVO> uniqueTags = uniqueTagPair.first();
    Long[] vrIds = new Long[uniqueTags.size()];
    int i = 0;
    for (HostTagVO v : uniqueTags) {
        vrIds[i++] = v.getId();
    }
    List<HostTagVO> vrs = _hostTagDao.searchByIds(vrIds);
    return new Pair<List<HostTagVO>, Integer>(vrs, count);
}
Also used : TemplateFilter(com.cloud.template.VirtualMachineTemplate.TemplateFilter) Filter(com.cloud.utils.db.Filter) HostTagVO(com.cloud.api.query.vo.HostTagVO) ArrayList(java.util.ArrayList) List(java.util.List) Pair(com.cloud.utils.Pair)

Aggregations

HostTagVO (com.cloud.api.query.vo.HostTagVO)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