@Override
public Pair<List<? extends GuestOSHypervisor>, Integer> listGuestOSMappingByCriteria(final ListGuestOsMappingCmd cmd) {
final Filter searchFilter = new Filter(GuestOSHypervisorVO.class, "hypervisorType", true, cmd.getStartIndex(), cmd.getPageSizeVal());
final Long id = cmd.getId();
final Long osTypeId = cmd.getOsTypeId();
final String hypervisor = cmd.getHypervisor();
final String hypervisorVersion = cmd.getHypervisorVersion();
if (hypervisorVersion != null && (hypervisor == null || hypervisor.isEmpty())) {
throw new InvalidParameterValueException("Hypervisor version parameter cannot be used without specifying a hypervisor : XenServer, KVM or VMware");
}
final SearchCriteria<GuestOSHypervisorVO> sc = _guestOSHypervisorDao.createSearchCriteria();
if (id != null) {
sc.addAnd("id", SearchCriteria.Op.EQ, id);
}
if (osTypeId != null) {
sc.addAnd("guestOsId", SearchCriteria.Op.EQ, osTypeId);
}
if (hypervisor != null) {
sc.addAnd("hypervisorType", SearchCriteria.Op.EQ, hypervisor);
}
if (hypervisorVersion != null) {
sc.addAnd("hypervisorVersion", SearchCriteria.Op.EQ, hypervisorVersion);
}
final Pair<List<GuestOSHypervisorVO>, Integer> result = _guestOSHypervisorDao.searchAndCount(sc, searchFilter);
return new Pair<List<? extends GuestOSHypervisor>, Integer>(result.first(), result.second());
}