Search in sources :

Example 16 with ListProjectResourcesCriteria

use of com.cloud.projects.Project.ListProjectResourcesCriteria in project cloudstack by apache.

the class SnapshotManagerImpl method listSnapshots.

@Override
public Pair<List<? extends Snapshot>, Integer> listSnapshots(ListSnapshotsCmd cmd) {
    Long volumeId = cmd.getVolumeId();
    String name = cmd.getSnapshotName();
    Long id = cmd.getId();
    String keyword = cmd.getKeyword();
    String snapshotTypeStr = cmd.getSnapshotType();
    String intervalTypeStr = cmd.getIntervalType();
    Map<String, String> tags = cmd.getTags();
    Long zoneId = cmd.getZoneId();
    Account caller = CallContext.current().getCallingAccount();
    List<Long> permittedAccounts = new ArrayList<Long>();
    // Verify parameters
    if (volumeId != null) {
        VolumeVO volume = _volsDao.findById(volumeId);
        if (volume != null) {
            _accountMgr.checkAccess(CallContext.current().getCallingAccount(), null, true, volume);
        }
    }
    List<Long> ids = getIdsListFromCmd(cmd.getId(), cmd.getIds());
    Ternary<Long, Boolean, ListProjectResourcesCriteria> domainIdRecursiveListProject = new Ternary<Long, Boolean, ListProjectResourcesCriteria>(cmd.getDomainId(), cmd.isRecursive(), null);
    _accountMgr.buildACLSearchParameters(caller, id, cmd.getAccountName(), cmd.getProjectId(), permittedAccounts, domainIdRecursiveListProject, cmd.listAll(), false);
    Long domainId = domainIdRecursiveListProject.first();
    Boolean isRecursive = domainIdRecursiveListProject.second();
    ListProjectResourcesCriteria listProjectResourcesCriteria = domainIdRecursiveListProject.third();
    Filter searchFilter = new Filter(SnapshotVO.class, "created", false, cmd.getStartIndex(), cmd.getPageSizeVal());
    SearchBuilder<SnapshotVO> sb = _snapshotDao.createSearchBuilder();
    _accountMgr.buildACLSearchBuilder(sb, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria);
    // exclude those Destroyed snapshot, not showing on UI
    sb.and("statusNEQ", sb.entity().getState(), SearchCriteria.Op.NEQ);
    sb.and("volumeId", sb.entity().getVolumeId(), SearchCriteria.Op.EQ);
    sb.and("name", sb.entity().getName(), SearchCriteria.Op.LIKE);
    sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ);
    sb.and("idIN", sb.entity().getId(), SearchCriteria.Op.IN);
    sb.and("snapshotTypeEQ", sb.entity().getSnapshotType(), SearchCriteria.Op.IN);
    sb.and("snapshotTypeNEQ", sb.entity().getSnapshotType(), SearchCriteria.Op.NEQ);
    sb.and("dataCenterId", sb.entity().getDataCenterId(), SearchCriteria.Op.EQ);
    if (tags != null && !tags.isEmpty()) {
        SearchBuilder<ResourceTagVO> tagSearch = _resourceTagDao.createSearchBuilder();
        for (int count = 0; count < tags.size(); count++) {
            tagSearch.or().op("key" + String.valueOf(count), tagSearch.entity().getKey(), SearchCriteria.Op.EQ);
            tagSearch.and("value" + String.valueOf(count), tagSearch.entity().getValue(), SearchCriteria.Op.EQ);
            tagSearch.cp();
        }
        tagSearch.and("resourceType", tagSearch.entity().getResourceType(), SearchCriteria.Op.EQ);
        sb.groupBy(sb.entity().getId());
        sb.join("tagSearch", tagSearch, sb.entity().getId(), tagSearch.entity().getResourceId(), JoinBuilder.JoinType.INNER);
    }
    SearchCriteria<SnapshotVO> sc = sb.create();
    _accountMgr.buildACLSearchCriteria(sc, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria);
    sc.setParameters("statusNEQ", Snapshot.State.Destroyed);
    if (volumeId != null) {
        sc.setParameters("volumeId", volumeId);
    }
    if (tags != null && !tags.isEmpty()) {
        int count = 0;
        sc.setJoinParameters("tagSearch", "resourceType", ResourceObjectType.Snapshot.toString());
        for (String key : tags.keySet()) {
            sc.setJoinParameters("tagSearch", "key" + String.valueOf(count), key);
            sc.setJoinParameters("tagSearch", "value" + String.valueOf(count), tags.get(key));
            count++;
        }
    }
    if (zoneId != null) {
        sc.setParameters("dataCenterId", zoneId);
    }
    setIdsListToSearchCriteria(sc, ids);
    if (name != null) {
        sc.setParameters("name", "%" + name + "%");
    }
    if (id != null) {
        sc.setParameters("id", id);
    }
    if (keyword != null) {
        SearchCriteria<SnapshotVO> ssc = _snapshotDao.createSearchCriteria();
        ssc.addOr("name", SearchCriteria.Op.LIKE, "%" + keyword + "%");
        sc.addAnd("name", SearchCriteria.Op.SC, ssc);
    }
    if (snapshotTypeStr != null) {
        Type snapshotType = SnapshotVO.getSnapshotType(snapshotTypeStr);
        if (snapshotType == null) {
            throw new InvalidParameterValueException("Unsupported snapshot type " + snapshotTypeStr);
        }
        if (snapshotType == Type.RECURRING) {
            sc.setParameters("snapshotTypeEQ", Type.HOURLY.ordinal(), Type.DAILY.ordinal(), Type.WEEKLY.ordinal(), Type.MONTHLY.ordinal());
        } else {
            sc.setParameters("snapshotTypeEQ", snapshotType.ordinal());
        }
    } else if (intervalTypeStr != null && volumeId != null) {
        Type type = SnapshotVO.getSnapshotType(intervalTypeStr);
        if (type == null) {
            throw new InvalidParameterValueException("Unsupported snapstho interval type " + intervalTypeStr);
        }
        sc.setParameters("snapshotTypeEQ", type.ordinal());
    } else {
        // Show only MANUAL and RECURRING snapshot types
        sc.setParameters("snapshotTypeNEQ", Snapshot.Type.TEMPLATE.ordinal());
    }
    Pair<List<SnapshotVO>, Integer> result = _snapshotDao.searchAndCount(sc, searchFilter);
    return new Pair<List<? extends Snapshot>, Integer>(result.first(), result.second());
}
Also used : Account(com.cloud.user.Account) Ternary(com.cloud.utils.Ternary) ArrayList(java.util.ArrayList) EndPoint(org.apache.cloudstack.engine.subsystem.api.storage.EndPoint) ListProjectResourcesCriteria(com.cloud.projects.Project.ListProjectResourcesCriteria) ScopeType(com.cloud.storage.ScopeType) Type(com.cloud.storage.Snapshot.Type) HypervisorType(com.cloud.hypervisor.Hypervisor.HypervisorType) ResourceType(com.cloud.configuration.Resource.ResourceType) IntervalType(com.cloud.utils.DateUtil.IntervalType) ResourceObjectType(com.cloud.server.ResourceTag.ResourceObjectType) StoragePoolType(com.cloud.storage.Storage.StoragePoolType) VMSnapshotVO(com.cloud.vm.snapshot.VMSnapshotVO) SnapshotVO(com.cloud.storage.SnapshotVO) VolumeVO(com.cloud.storage.VolumeVO) Filter(com.cloud.utils.db.Filter) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) ResourceTagVO(com.cloud.tags.ResourceTagVO) ArrayList(java.util.ArrayList) List(java.util.List) Pair(com.cloud.utils.Pair)

Example 17 with ListProjectResourcesCriteria

use of com.cloud.projects.Project.ListProjectResourcesCriteria in project cloudstack by apache.

the class Site2SiteVpnManagerImpl method searchForCustomerGateways.

@Override
public Pair<List<? extends Site2SiteCustomerGateway>, Integer> searchForCustomerGateways(ListVpnCustomerGatewaysCmd cmd) {
    Long id = cmd.getId();
    Long domainId = cmd.getDomainId();
    boolean isRecursive = cmd.isRecursive();
    String accountName = cmd.getAccountName();
    boolean listAll = cmd.listAll();
    long startIndex = cmd.getStartIndex();
    long pageSizeVal = cmd.getPageSizeVal();
    String keyword = cmd.getKeyword();
    Account caller = CallContext.current().getCallingAccount();
    List<Long> permittedAccounts = new ArrayList<Long>();
    Ternary<Long, Boolean, ListProjectResourcesCriteria> domainIdRecursiveListProject = new Ternary<Long, Boolean, ListProjectResourcesCriteria>(domainId, isRecursive, null);
    _accountMgr.buildACLSearchParameters(caller, id, accountName, cmd.getProjectId(), permittedAccounts, domainIdRecursiveListProject, listAll, false);
    domainId = domainIdRecursiveListProject.first();
    isRecursive = domainIdRecursiveListProject.second();
    ListProjectResourcesCriteria listProjectResourcesCriteria = domainIdRecursiveListProject.third();
    Filter searchFilter = new Filter(Site2SiteCustomerGatewayVO.class, "id", false, startIndex, pageSizeVal);
    SearchBuilder<Site2SiteCustomerGatewayVO> sb = _customerGatewayDao.createSearchBuilder();
    _accountMgr.buildACLSearchBuilder(sb, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria);
    sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ);
    sb.and("name", sb.entity().getName(), SearchCriteria.Op.LIKE);
    SearchCriteria<Site2SiteCustomerGatewayVO> sc = sb.create();
    _accountMgr.buildACLSearchCriteria(sc, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria);
    if (id != null) {
        sc.setParameters("id", id);
    }
    if (keyword != null && !keyword.isEmpty()) {
        sc.setParameters("name", "%" + keyword + "%");
    }
    Pair<List<Site2SiteCustomerGatewayVO>, Integer> result = _customerGatewayDao.searchAndCount(sc, searchFilter);
    return new Pair<List<? extends Site2SiteCustomerGateway>, Integer>(result.first(), result.second());
}
Also used : Account(com.cloud.user.Account) Ternary(com.cloud.utils.Ternary) Site2SiteCustomerGatewayVO(com.cloud.network.dao.Site2SiteCustomerGatewayVO) ArrayList(java.util.ArrayList) ListProjectResourcesCriteria(com.cloud.projects.Project.ListProjectResourcesCriteria) Filter(com.cloud.utils.db.Filter) List(java.util.List) ArrayList(java.util.ArrayList) Pair(com.cloud.utils.Pair)

Example 18 with ListProjectResourcesCriteria

use of com.cloud.projects.Project.ListProjectResourcesCriteria in project cloudstack by apache.

the class VMSnapshotManagerImpl method listVMSnapshots.

@Override
public Pair<List<? extends VMSnapshot>, Integer> listVMSnapshots(ListVMSnapshotCmd cmd) {
    Account caller = getCaller();
    List<Long> permittedAccounts = new ArrayList<Long>();
    boolean listAll = cmd.listAll();
    Long id = cmd.getId();
    Long vmId = cmd.getVmId();
    String state = cmd.getState();
    String keyword = cmd.getKeyword();
    String name = cmd.getVmSnapshotName();
    String accountName = cmd.getAccountName();
    Map<String, String> tags = cmd.getTags();
    List<Long> ids = getIdsListFromCmd(cmd.getId(), cmd.getIds());
    Ternary<Long, Boolean, ListProjectResourcesCriteria> domainIdRecursiveListProject = new Ternary<Long, Boolean, ListProjectResourcesCriteria>(cmd.getDomainId(), cmd.isRecursive(), null);
    _accountMgr.buildACLSearchParameters(caller, id, cmd.getAccountName(), cmd.getProjectId(), permittedAccounts, domainIdRecursiveListProject, listAll, false);
    Long domainId = domainIdRecursiveListProject.first();
    Boolean isRecursive = domainIdRecursiveListProject.second();
    ListProjectResourcesCriteria listProjectResourcesCriteria = domainIdRecursiveListProject.third();
    Filter searchFilter = new Filter(VMSnapshotVO.class, "created", false, cmd.getStartIndex(), cmd.getPageSizeVal());
    SearchBuilder<VMSnapshotVO> sb = _vmSnapshotDao.createSearchBuilder();
    _accountMgr.buildACLSearchBuilder(sb, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria);
    sb.and("vm_id", sb.entity().getVmId(), SearchCriteria.Op.EQ);
    sb.and("domain_id", sb.entity().getDomainId(), SearchCriteria.Op.EQ);
    sb.and("status", sb.entity().getState(), SearchCriteria.Op.IN);
    sb.and("state", sb.entity().getState(), SearchCriteria.Op.EQ);
    sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ);
    sb.and("idIN", sb.entity().getId(), SearchCriteria.Op.IN);
    sb.and("display_name", sb.entity().getDisplayName(), SearchCriteria.Op.EQ);
    sb.and("account_id", sb.entity().getAccountId(), SearchCriteria.Op.EQ);
    if (MapUtils.isNotEmpty(tags)) {
        SearchBuilder<ResourceTagVO> tagSearch = _resourceTagDao.createSearchBuilder();
        for (int count = 0; count < tags.size(); count++) {
            tagSearch.or().op(ApiConstants.KEY + String.valueOf(count), tagSearch.entity().getKey(), SearchCriteria.Op.EQ);
            tagSearch.and(ApiConstants.VALUE + String.valueOf(count), tagSearch.entity().getValue(), SearchCriteria.Op.EQ);
            tagSearch.cp();
        }
        tagSearch.and(ApiConstants.RESOURCE_TYPE, tagSearch.entity().getResourceType(), SearchCriteria.Op.EQ);
        sb.groupBy(sb.entity().getId());
        sb.join("tagSearch", tagSearch, sb.entity().getId(), tagSearch.entity().getResourceId(), JoinBuilder.JoinType.INNER);
    }
    SearchCriteria<VMSnapshotVO> sc = sb.create();
    _accountMgr.buildACLSearchCriteria(sc, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria);
    if (MapUtils.isNotEmpty(tags)) {
        int count = 0;
        sc.setJoinParameters("tagSearch", ApiConstants.RESOURCE_TYPE, ResourceTag.ResourceObjectType.VMSnapshot.toString());
        for (String key : tags.keySet()) {
            sc.setJoinParameters("tagSearch", ApiConstants.KEY + String.valueOf(count), key);
            sc.setJoinParameters("tagSearch", ApiConstants.VALUE + String.valueOf(count), tags.get(key));
            count++;
        }
    }
    if (accountName != null && cmd.getDomainId() != null) {
        Account account = _accountMgr.getActiveAccountByName(accountName, cmd.getDomainId());
        sc.setParameters("account_id", account.getId());
    }
    if (vmId != null) {
        sc.setParameters("vm_id", vmId);
    }
    setIdsListToSearchCriteria(sc, ids);
    if (domainId != null) {
        sc.setParameters("domain_id", domainId);
    }
    if (state == null) {
        VMSnapshot.State[] status = { VMSnapshot.State.Ready, VMSnapshot.State.Creating, VMSnapshot.State.Allocated, VMSnapshot.State.Error, VMSnapshot.State.Expunging, VMSnapshot.State.Reverting };
        sc.setParameters("status", (Object[]) status);
    } else {
        sc.setParameters("state", state);
    }
    if (name != null) {
        sc.setParameters("display_name", name);
    }
    if (keyword != null) {
        SearchCriteria<VMSnapshotVO> ssc = _vmSnapshotDao.createSearchCriteria();
        ssc.addOr("name", SearchCriteria.Op.LIKE, "%" + keyword + "%");
        ssc.addOr("displayName", SearchCriteria.Op.LIKE, "%" + keyword + "%");
        ssc.addOr("description", SearchCriteria.Op.LIKE, "%" + keyword + "%");
        sc.addAnd("name", SearchCriteria.Op.SC, ssc);
    }
    if (id != null) {
        sc.setParameters("id", id);
    }
    Pair<List<VMSnapshotVO>, Integer> searchAndCount = _vmSnapshotDao.searchAndCount(sc, searchFilter);
    return new Pair<List<? extends VMSnapshot>, Integer>(searchAndCount.first(), searchAndCount.second());
}
Also used : Account(com.cloud.user.Account) ArrayList(java.util.ArrayList) ResourceTagVO(com.cloud.tags.ResourceTagVO) ArrayList(java.util.ArrayList) List(java.util.List) Pair(com.cloud.utils.Pair) Ternary(com.cloud.utils.Ternary) ListProjectResourcesCriteria(com.cloud.projects.Project.ListProjectResourcesCriteria) Filter(com.cloud.utils.db.Filter) State(com.cloud.vm.VirtualMachine.State)

Example 19 with ListProjectResourcesCriteria

use of com.cloud.projects.Project.ListProjectResourcesCriteria in project cloudstack by apache.

the class ApplicationLoadBalancerManagerImpl method listApplicationLoadBalancers.

@Override
public Pair<List<? extends ApplicationLoadBalancerRule>, Integer> listApplicationLoadBalancers(ListApplicationLoadBalancersCmd cmd) {
    Long id = cmd.getId();
    String name = cmd.getLoadBalancerRuleName();
    String ip = cmd.getSourceIp();
    Long ipNtwkId = cmd.getSourceIpNetworkId();
    String keyword = cmd.getKeyword();
    Scheme scheme = cmd.getScheme();
    Long networkId = cmd.getNetworkId();
    Boolean display = cmd.getDisplay();
    Map<String, String> tags = cmd.getTags();
    Account caller = CallContext.current().getCallingAccount();
    List<Long> permittedAccounts = new ArrayList<Long>();
    Ternary<Long, Boolean, ListProjectResourcesCriteria> domainIdRecursiveListProject = new Ternary<Long, Boolean, ListProjectResourcesCriteria>(cmd.getDomainId(), cmd.isRecursive(), null);
    _accountMgr.buildACLSearchParameters(caller, id, cmd.getAccountName(), cmd.getProjectId(), permittedAccounts, domainIdRecursiveListProject, cmd.listAll(), false);
    Long domainId = domainIdRecursiveListProject.first();
    Boolean isRecursive = domainIdRecursiveListProject.second();
    ListProjectResourcesCriteria listProjectResourcesCriteria = domainIdRecursiveListProject.third();
    Filter searchFilter = new Filter(ApplicationLoadBalancerRuleVO.class, "id", true, cmd.getStartIndex(), cmd.getPageSizeVal());
    SearchBuilder<ApplicationLoadBalancerRuleVO> sb = _lbDao.createSearchBuilder();
    _accountMgr.buildACLSearchBuilder(sb, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria);
    sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ);
    sb.and("name", sb.entity().getName(), SearchCriteria.Op.EQ);
    sb.and("sourceIpAddress", sb.entity().getSourceIp(), SearchCriteria.Op.EQ);
    sb.and("sourceIpAddressNetworkId", sb.entity().getSourceIpNetworkId(), SearchCriteria.Op.EQ);
    sb.and("scheme", sb.entity().getScheme(), SearchCriteria.Op.EQ);
    sb.and("networkId", sb.entity().getNetworkId(), SearchCriteria.Op.EQ);
    sb.and("display", sb.entity().isDisplay(), SearchCriteria.Op.EQ);
    // list only load balancers having not null sourceIp/sourceIpNtwkId
    sb.and("sourceIpAddress", sb.entity().getSourceIp(), SearchCriteria.Op.NNULL);
    sb.and("sourceIpAddressNetworkId", sb.entity().getSourceIpNetworkId(), SearchCriteria.Op.NNULL);
    if (tags != null && !tags.isEmpty()) {
        SearchBuilder<ResourceTagVO> tagSearch = _resourceTagDao.createSearchBuilder();
        for (int count = 0; count < tags.size(); count++) {
            tagSearch.or().op("key" + String.valueOf(count), tagSearch.entity().getKey(), SearchCriteria.Op.EQ);
            tagSearch.and("value" + String.valueOf(count), tagSearch.entity().getValue(), SearchCriteria.Op.EQ);
            tagSearch.cp();
        }
        tagSearch.and("resourceType", tagSearch.entity().getResourceType(), SearchCriteria.Op.EQ);
        sb.groupBy(sb.entity().getId());
        sb.join("tagSearch", tagSearch, sb.entity().getId(), tagSearch.entity().getResourceId(), JoinBuilder.JoinType.INNER);
    }
    SearchCriteria<ApplicationLoadBalancerRuleVO> sc = sb.create();
    _accountMgr.buildACLSearchCriteria(sc, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria);
    if (keyword != null) {
        SearchCriteria<ApplicationLoadBalancerRuleVO> ssc = _lbDao.createSearchCriteria();
        ssc.addOr("name", SearchCriteria.Op.LIKE, "%" + keyword + "%");
        ssc.addOr("description", SearchCriteria.Op.LIKE, "%" + keyword + "%");
        sc.addAnd("name", SearchCriteria.Op.SC, ssc);
    }
    if (name != null) {
        sc.setParameters("name", name);
    }
    if (id != null) {
        sc.setParameters("id", id);
    }
    if (ip != null) {
        sc.setParameters("sourceIpAddress", ip);
    }
    if (ipNtwkId != null) {
        sc.setParameters("sourceIpAddressNetworkId", ipNtwkId);
    }
    if (scheme != null) {
        sc.setParameters("scheme", scheme);
    }
    if (networkId != null) {
        sc.setParameters("networkId", networkId);
    }
    if (tags != null && !tags.isEmpty()) {
        int count = 0;
        sc.setJoinParameters("tagSearch", "resourceType", ResourceObjectType.LoadBalancer.toString());
        for (String key : tags.keySet()) {
            sc.setJoinParameters("tagSearch", "key" + String.valueOf(count), key);
            sc.setJoinParameters("tagSearch", "value" + String.valueOf(count), tags.get(key));
            count++;
        }
    }
    if (display != null) {
        sc.setParameters("display", display);
    }
    Pair<List<ApplicationLoadBalancerRuleVO>, Integer> result = _lbDao.searchAndCount(sc, searchFilter);
    return new Pair<List<? extends ApplicationLoadBalancerRule>, Integer>(result.first(), result.second());
}
Also used : Account(com.cloud.user.Account) ApplicationLoadBalancerRuleVO(org.apache.cloudstack.lb.ApplicationLoadBalancerRuleVO) Scheme(com.cloud.network.rules.LoadBalancerContainer.Scheme) Ternary(com.cloud.utils.Ternary) ArrayList(java.util.ArrayList) ListProjectResourcesCriteria(com.cloud.projects.Project.ListProjectResourcesCriteria) Filter(com.cloud.utils.db.Filter) ResourceTagVO(com.cloud.tags.ResourceTagVO) List(java.util.List) ArrayList(java.util.ArrayList) Pair(com.cloud.utils.Pair)

Example 20 with ListProjectResourcesCriteria

use of com.cloud.projects.Project.ListProjectResourcesCriteria in project cosmic by MissionCriticalCloud.

the class QueryManagerImpl method searchForVmGroupsInternal.

private Pair<List<InstanceGroupJoinVO>, Integer> searchForVmGroupsInternal(final ListVMGroupsCmd cmd) {
    final Long id = cmd.getId();
    final String name = cmd.getGroupName();
    final String keyword = cmd.getKeyword();
    final Account caller = CallContext.current().getCallingAccount();
    final List<Long> permittedAccounts = new ArrayList<>();
    final Ternary<Long, Boolean, ListProjectResourcesCriteria> domainIdRecursiveListProject = new Ternary<>(cmd.getDomainId(), cmd.isRecursive(), null);
    _accountMgr.buildACLSearchParameters(caller, id, cmd.getAccountName(), cmd.getProjectId(), permittedAccounts, domainIdRecursiveListProject, cmd.listAll(), false);
    final Long domainId = domainIdRecursiveListProject.first();
    final Boolean isRecursive = domainIdRecursiveListProject.second();
    final ListProjectResourcesCriteria listProjectResourcesCriteria = domainIdRecursiveListProject.third();
    final Filter searchFilter = new Filter(InstanceGroupJoinVO.class, "id", true, cmd.getStartIndex(), cmd.getPageSizeVal());
    final SearchBuilder<InstanceGroupJoinVO> sb = _vmGroupJoinDao.createSearchBuilder();
    _accountMgr.buildACLViewSearchBuilder(sb, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria);
    sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ);
    sb.and("name", sb.entity().getName(), SearchCriteria.Op.LIKE);
    final SearchCriteria<InstanceGroupJoinVO> sc = sb.create();
    _accountMgr.buildACLViewSearchCriteria(sc, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria);
    if (keyword != null) {
        final SearchCriteria<InstanceGroupJoinVO> ssc = _vmGroupJoinDao.createSearchCriteria();
        ssc.addOr("name", SearchCriteria.Op.LIKE, "%" + keyword + "%");
        sc.addAnd("name", SearchCriteria.Op.SC, ssc);
    }
    if (id != null) {
        sc.setParameters("id", id);
    }
    if (name != null) {
        sc.setParameters("name", "%" + name + "%");
    }
    return _vmGroupJoinDao.searchAndCount(sc, searchFilter);
}
Also used : Account(com.cloud.user.Account) Ternary(com.cloud.utils.Ternary) ArrayList(java.util.ArrayList) InstanceGroupJoinVO(com.cloud.api.query.vo.InstanceGroupJoinVO) ListProjectResourcesCriteria(com.cloud.projects.Project.ListProjectResourcesCriteria) TemplateFilter(com.cloud.template.VirtualMachineTemplate.TemplateFilter) Filter(com.cloud.utils.db.Filter)

Aggregations

ListProjectResourcesCriteria (com.cloud.projects.Project.ListProjectResourcesCriteria)62 Ternary (com.cloud.utils.Ternary)62 ArrayList (java.util.ArrayList)62 Account (com.cloud.user.Account)61 Filter (com.cloud.utils.db.Filter)57 List (java.util.List)49 Pair (com.cloud.utils.Pair)48 TemplateFilter (com.cloud.template.VirtualMachineTemplate.TemplateFilter)24 ResourceTagVO (com.cloud.tags.ResourceTagVO)19 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)15 InvalidParameterValueException (com.cloud.utils.exception.InvalidParameterValueException)11 IPAddressVO (com.cloud.network.dao.IPAddressVO)10 HypervisorType (com.cloud.hypervisor.Hypervisor.HypervisorType)8 DomainVO (com.cloud.domain.DomainVO)6 Date (java.util.Date)6 LinkedList (java.util.LinkedList)6 UserVmVO (com.cloud.vm.UserVmVO)5 AffinityGroupJoinVO (com.cloud.api.query.vo.AffinityGroupJoinVO)4 AsyncJobJoinVO (com.cloud.api.query.vo.AsyncJobJoinVO)4 DomainRouterJoinVO (com.cloud.api.query.vo.DomainRouterJoinVO)4