Search in sources :

Example 1 with ResourceTagJoinVO

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

the class ProjectJoinDaoImpl method newProjectResponse.

@Override
public ProjectResponse newProjectResponse(ProjectJoinVO proj) {
    ProjectResponse response = new ProjectResponse();
    response.setId(proj.getUuid());
    response.setName(proj.getName());
    response.setDisplaytext(proj.getDisplayText());
    if (proj.getState() != null) {
        response.setState(proj.getState().toString());
    }
    response.setDomainId(proj.getDomainUuid());
    response.setDomain(proj.getDomainName());
    response.setOwner(proj.getOwner());
    // update tag information
    Long tag_id = proj.getTagId();
    if (tag_id != null && tag_id.longValue() > 0) {
        ResourceTagJoinVO vtag = ApiDBUtils.findResourceTagViewById(tag_id);
        if (vtag != null) {
            response.addTag(ApiDBUtils.newResourceTagResponse(vtag, false));
        }
    }
    //set resource limit/count information for the project (by getting the info of the project's account)
    Account account = _accountDao.findByIdIncludingRemoved(proj.getProjectAccountId());
    AccountJoinVO accountJn = ApiDBUtils.newAccountView(account);
    _accountJoinDao.setResourceLimits(accountJn, false, response);
    response.setProjectAccountName(accountJn.getAccountName());
    response.setObjectName("project");
    return response;
}
Also used : Account(com.cloud.user.Account) ProjectResponse(org.apache.cloudstack.api.response.ProjectResponse) ResourceTagJoinVO(com.cloud.api.query.vo.ResourceTagJoinVO) AccountJoinVO(com.cloud.api.query.vo.AccountJoinVO)

Example 2 with ResourceTagJoinVO

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

the class DataCenterJoinDaoImpl method newDataCenterResponse.

@Override
public ZoneResponse newDataCenterResponse(ResponseView view, DataCenterJoinVO dataCenter, Boolean showCapacities, Boolean showResourceImage) {
    ZoneResponse zoneResponse = new ZoneResponse();
    zoneResponse.setId(dataCenter.getUuid());
    zoneResponse.setName(dataCenter.getName());
    zoneResponse.setSecurityGroupsEnabled(ApiDBUtils.isSecurityGroupEnabledInZone(dataCenter.getId()));
    zoneResponse.setLocalStorageEnabled(dataCenter.isLocalStorageEnabled());
    if ((dataCenter.getDescription() != null) && !dataCenter.getDescription().equalsIgnoreCase("null")) {
        zoneResponse.setDescription(dataCenter.getDescription());
    }
    if (view == ResponseView.Full) {
        zoneResponse.setDns1(dataCenter.getDns1());
        zoneResponse.setDns2(dataCenter.getDns2());
        zoneResponse.setIp6Dns1(dataCenter.getIp6Dns1());
        zoneResponse.setIp6Dns2(dataCenter.getIp6Dns2());
        zoneResponse.setInternalDns1(dataCenter.getInternalDns1());
        zoneResponse.setInternalDns2(dataCenter.getInternalDns2());
        // FIXME zoneResponse.setVlan(dataCenter.get.getVnet());
        zoneResponse.setGuestCidrAddress(dataCenter.getGuestNetworkCidr());
        if (showCapacities != null && showCapacities) {
            zoneResponse.setCapacitites(ApiResponseHelper.getDataCenterCapacityResponse(dataCenter.getId()));
        }
    }
    // set network domain info
    zoneResponse.setDomain(dataCenter.getDomain());
    // set domain info
    zoneResponse.setDomainId(dataCenter.getDomainUuid());
    zoneResponse.setDomainName(dataCenter.getDomainName());
    zoneResponse.setNetworkType(dataCenter.getNetworkType().toString());
    zoneResponse.setAllocationState(dataCenter.getAllocationState().toString());
    zoneResponse.setZoneToken(dataCenter.getZoneToken());
    zoneResponse.setDhcpProvider(dataCenter.getDhcpProvider());
    // update tag information
    List<ResourceTagJoinVO> resourceTags = ApiDBUtils.listResourceTagViewByResourceUUID(dataCenter.getUuid(), ResourceObjectType.Zone);
    for (ResourceTagJoinVO resourceTag : resourceTags) {
        ResourceTagResponse tagResponse = ApiDBUtils.newResourceTagResponse(resourceTag, false);
        zoneResponse.addTag(tagResponse);
    }
    if (showResourceImage) {
        ResourceIconVO resourceIcon = ApiDBUtils.getResourceIconByResourceUUID(dataCenter.getUuid(), ResourceObjectType.Zone);
        if (resourceIcon != null) {
            ResourceIconResponse iconResponse = ApiDBUtils.newResourceIconResponse(resourceIcon);
            zoneResponse.setResourceIconResponse(iconResponse);
        }
    }
    zoneResponse.setResourceDetails(ApiDBUtils.getResourceDetails(dataCenter.getId(), ResourceObjectType.Zone));
    zoneResponse.setHasAnnotation(annotationDao.hasAnnotations(dataCenter.getUuid(), AnnotationService.EntityType.ZONE.name(), _accountMgr.isRootAdmin(CallContext.current().getCallingAccount().getId())));
    zoneResponse.setObjectName("zone");
    return zoneResponse;
}
Also used : ZoneResponse(org.apache.cloudstack.api.response.ZoneResponse) ResourceIconResponse(org.apache.cloudstack.api.response.ResourceIconResponse) ResourceTagResponse(org.apache.cloudstack.api.response.ResourceTagResponse) ResourceTagJoinVO(com.cloud.api.query.vo.ResourceTagJoinVO) ResourceIconVO(com.cloud.resource.icon.ResourceIconVO)

Example 3 with ResourceTagJoinVO

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

the class GenericDaoBaseWithTagInformation method addTagInformation.

/**
 * Update tag information on baseResponse
 * @param baseView base view containing tag information
 * @param baseResponse response to update
 */
protected void addTagInformation(T baseView, Z baseResponse) {
    ResourceTagJoinVO vtag = new ResourceTagJoinVO();
    vtag.setId(baseView.getTagId());
    vtag.setUuid(baseView.getTagUuid());
    vtag.setKey(baseView.getTagKey());
    vtag.setValue(baseView.getTagValue());
    vtag.setDomainId(baseView.getTagDomainId());
    vtag.setAccountId(baseView.getTagAccountId());
    vtag.setResourceId(baseView.getTagResourceId());
    vtag.setResourceUuid(baseView.getTagResourceUuid());
    vtag.setResourceType(baseView.getTagResourceType());
    vtag.setCustomer(baseView.getTagCustomer());
    vtag.setAccountName(baseView.getTagAccountName());
    vtag.setDomainName(baseView.getTagDomainName());
    vtag.setDomainUuid(baseView.getTagDomainUuid());
    baseResponse.addTag(ApiDBUtils.newResourceTagResponse(vtag, false));
}
Also used : ResourceTagJoinVO(com.cloud.api.query.vo.ResourceTagJoinVO)

Example 4 with ResourceTagJoinVO

use of com.cloud.api.query.vo.ResourceTagJoinVO in project cosmic by MissionCriticalCloud.

the class QueryManagerImpl method listTagsInternal.

private Pair<List<ResourceTagJoinVO>, Integer> listTagsInternal(final ListTagsCmd cmd) {
    final Account caller = CallContext.current().getCallingAccount();
    final List<Long> permittedAccounts = new ArrayList<>();
    final String key = cmd.getKey();
    final String value = cmd.getValue();
    final String resourceId = cmd.getResourceId();
    final String resourceType = cmd.getResourceType();
    final String customerName = cmd.getCustomer();
    final boolean listAll = cmd.listAll();
    final Ternary<Long, Boolean, ListProjectResourcesCriteria> domainIdRecursiveListProject = new Ternary<>(cmd.getDomainId(), cmd.isRecursive(), null);
    _accountMgr.buildACLSearchParameters(caller, null, cmd.getAccountName(), cmd.getProjectId(), permittedAccounts, domainIdRecursiveListProject, listAll, false);
    final Long domainId = domainIdRecursiveListProject.first();
    final Boolean isRecursive = domainIdRecursiveListProject.second();
    final ListProjectResourcesCriteria listProjectResourcesCriteria = domainIdRecursiveListProject.third();
    final Filter searchFilter = new Filter(ResourceTagJoinVO.class, "resourceType", false, cmd.getStartIndex(), cmd.getPageSizeVal());
    final SearchBuilder<ResourceTagJoinVO> sb = _resourceTagJoinDao.createSearchBuilder();
    _accountMgr.buildACLViewSearchBuilder(sb, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria);
    sb.and("key", sb.entity().getKey(), SearchCriteria.Op.EQ);
    sb.and("value", sb.entity().getValue(), SearchCriteria.Op.EQ);
    if (resourceId != null) {
        sb.and("resourceId", sb.entity().getResourceId(), SearchCriteria.Op.EQ);
        sb.and("resourceUuid", sb.entity().getResourceUuid(), SearchCriteria.Op.EQ);
    }
    sb.and("resourceType", sb.entity().getResourceType(), SearchCriteria.Op.EQ);
    sb.and("customer", sb.entity().getCustomer(), SearchCriteria.Op.EQ);
    // now set the SC criteria...
    final SearchCriteria<ResourceTagJoinVO> sc = sb.create();
    _accountMgr.buildACLViewSearchCriteria(sc, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria);
    if (key != null) {
        sc.setParameters("key", key);
    }
    if (value != null) {
        sc.setParameters("value", value);
    }
    if (resourceId != null) {
        try {
            final long rid = Long.parseLong(resourceId);
            sc.setParameters("resourceId", rid);
        } catch (final NumberFormatException ex) {
            // internal id instead of resource id is passed
            sc.setParameters("resourceUuid", resourceId);
        }
    }
    if (resourceType != null) {
        sc.setParameters("resourceType", resourceType);
    }
    if (customerName != null) {
        sc.setParameters("customer", customerName);
    }
    final Pair<List<ResourceTagJoinVO>, Integer> result = _resourceTagJoinDao.searchAndCount(sc, searchFilter);
    return result;
}
Also used : Account(com.cloud.user.Account) Ternary(com.cloud.utils.Ternary) ArrayList(java.util.ArrayList) ListProjectResourcesCriteria(com.cloud.projects.Project.ListProjectResourcesCriteria) TemplateFilter(com.cloud.template.VirtualMachineTemplate.TemplateFilter) Filter(com.cloud.utils.db.Filter) ResourceTagJoinVO(com.cloud.api.query.vo.ResourceTagJoinVO) ArrayList(java.util.ArrayList) List(java.util.List)

Example 5 with ResourceTagJoinVO

use of com.cloud.api.query.vo.ResourceTagJoinVO in project cosmic by MissionCriticalCloud.

the class TemplateJoinDaoImpl method setTemplateResponse.

@Override
public TemplateResponse setTemplateResponse(final ResponseView view, final TemplateResponse templateResponse, final TemplateJoinVO template) {
    // update details map
    if (template.getDetailName() != null) {
        Map<String, String> details = templateResponse.getDetails();
        if (details == null) {
            details = new HashMap<>();
        }
        details.put(template.getDetailName(), template.getDetailValue());
        templateResponse.setDetails(details);
    }
    // update tag information
    final long tag_id = template.getTagId();
    if (tag_id > 0) {
        final ResourceTagJoinVO vtag = ApiDBUtils.findResourceTagViewById(tag_id);
        if (vtag != null) {
            templateResponse.addTag(ApiDBUtils.newResourceTagResponse(vtag, false));
        }
    }
    return templateResponse;
}
Also used : ResourceTagJoinVO(com.cloud.api.query.vo.ResourceTagJoinVO)

Aggregations

ResourceTagJoinVO (com.cloud.api.query.vo.ResourceTagJoinVO)19 Account (com.cloud.user.Account)9 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)5 AccountJoinVO (com.cloud.api.query.vo.AccountJoinVO)3 TemplateResponse (com.cloud.api.response.TemplateResponse)3 ResourceTagResponse (org.apache.cloudstack.api.response.ResourceTagResponse)3 AffinityGroupResponse (com.cloud.affinity.AffinityGroupResponse)2 SecurityGroupJoinVO (com.cloud.api.query.vo.SecurityGroupJoinVO)2 NicResponse (com.cloud.api.response.NicResponse)2 NicSecondaryIpResponse (com.cloud.api.response.NicSecondaryIpResponse)2 ListProjectResourcesCriteria (com.cloud.projects.Project.ListProjectResourcesCriteria)2 TemplateFilter (com.cloud.template.VirtualMachineTemplate.TemplateFilter)2 User (com.cloud.user.User)2 Ternary (com.cloud.utils.Ternary)2 Filter (com.cloud.utils.db.Filter)2 NicSecondaryIpVO (com.cloud.vm.dao.NicSecondaryIpVO)2 HashSet (java.util.HashSet)2 List (java.util.List)2 ChildTemplateResponse (org.apache.cloudstack.api.response.ChildTemplateResponse)2