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;
}
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;
}
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));
}
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;
}
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;
}
Aggregations