本文整理了Java中org.zstack.core.db.Q.New
方法的一些代码示例,展示了Q.New
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Q.New
方法的具体详情如下:
包路径:org.zstack.core.db.Q
类名称:Q
方法名:New
暂无
代码示例来源:origin: zstackio/zstack
private void deleteListenersForLoadBalancer(String lbUuid) {
List<LoadBalancerListenerVO> listenerVOS = Q.New(LoadBalancerListenerVO.class)
.eq(LoadBalancerListenerVO_.loadBalancerUuid, lbUuid)
.list();
if (listenerVOS != null && !listenerVOS.isEmpty()) {
logger.debug(String.format("delete loadBalancerListeners[%s] for loadBalancer[uuid:%s]",
listenerVOS.stream().map(vo -> vo.getUuid()).collect(Collectors.toList()), lbUuid));
listenerVOS.forEach(vo -> dbf.remove(vo));
}
}
代码示例来源:origin: zstackio/zstack
public boolean checkDuplicateMac(String hypervisorType, String mac) {
return Q.New(VmNicVO.class)
.eq(VmNicVO_.hypervisorType, hypervisorType)
.eq(VmNicVO_.mac, mac.toLowerCase())
.isExists();
}
}
代码示例来源:origin: zstackio/zstack
private String getAvailableHostUuidForOperation() {
List<String> hostUuids = Q.New(PrimaryStorageHostRefVO.class).
eq(PrimaryStorageHostRefVO_.primaryStorageUuid, self.getUuid()).select(PrimaryStorageHostRefVO_.hostUuid).listValues();
if (hostUuids == null || hostUuids.size() == 0) {
return null;
}
return hostUuids.get(0);
}
代码示例来源:origin: zstackio/zstack
@Override
public void call() {
List<WebhookVO> vos = Q.New(WebhookVO.class).eq(WebhookVO_.type, EventFacade.WEBHOOK_TYPE).list();
vos = vos.stream().filter(
vo -> event.getPath().matches(
createRegexFromGlob(vo.getOpaque().replaceAll("\\{.*\\}", ".*"))
)).collect(Collectors.toList());
if (!vos.isEmpty()) {
postToWebhooks(WebhookInventory.valueOf(vos), JSONObjectUtil.toJsonString(event));
}
}
}.call();
代码示例来源:origin: zstackio/zstack
private void validate(APIAddMonToCephBackupStorageMsg msg) {
checkMonUrls(msg.getMonUrls());
List<String> hostnames = msg.getMonUrls().stream()
.map(MonUri::new)
.map(MonUri::getHostname)
.collect(Collectors.toList());
if (Q.New(CephBackupStorageMonVO.class).in(CephBackupStorageMonVO_.hostname, hostnames).isExists()){
throw new ApiMessageInterceptionException(argerr("Adding the same Mon node is not allowed"));
}
}
private void validate(APIUpdateCephBackupStorageMonMsg msg) {
代码示例来源:origin: zstackio/zstack
public static List<String> getIsoUuidByVmUuid(String vmUuid) {
List<String> isoUuids = Q.New(VmCdRomVO.class)
.select(VmCdRomVO_.isoUuid)
.eq(VmCdRomVO_.vmInstanceUuid, vmUuid)
.notNull(VmCdRomVO_.isoUuid)
.listValues();
return isoUuids;
}
代码示例来源:origin: zstackio/zstack
public static Integer getIsoDeviceId(String vmUuid, String isoUuid) {
VmCdRomVO vmCdRomVO = Q.New(VmCdRomVO.class)
.eq(VmCdRomVO_.vmInstanceUuid, vmUuid)
.eq(VmCdRomVO_.isoUuid, isoUuid)
.find();
if (vmCdRomVO == null) {
return null;
}
return vmCdRomVO.getDeviceId();
}
代码示例来源:origin: zstackio/zstack
private LdapTemplateContextSource readLdapServerConfiguration() {
LdapServerVO ldapServerVO = Q.New(LdapServerVO.class).find();
LdapServerInventory ldapServerInventory = LdapServerInventory.valueOf(ldapServerVO);
return new LdapUtil().loadLdap(ldapServerInventory);
}
代码示例来源:origin: zstackio/zstack
@Override
public void prepareDbInitialValue() {
List<VipVO> vipVOS = Q.New(VipVO.class).isNull(VipVO_.prefixLen).list();
for (VipVO vip : vipVOS) {
vip.setPrefixLen(NetworkUtils.getPrefixLengthFromNetwork(vip.getNetmask()));
}
if (!vipVOS.isEmpty()) {
dbf.updateCollection(vipVOS);
}
}
}
代码示例来源:origin: zstackio/zstack
static VmCdRomVO getEmptyCdRom(String vmUuid) {
VmCdRomVO cdRomVO = Q.New(VmCdRomVO.class)
.eq(VmCdRomVO_.vmInstanceUuid, vmUuid)
.isNull(VmCdRomVO_.isoUuid)
.orderBy(VmCdRomVO_.deviceId, SimpleQuery.Od.ASC)
.limit(1)
.find();
return cdRomVO;
}
代码示例来源:origin: zstackio/zstack
@Override
protected void scripts() {
if(Q.New(CephPrimaryStorageVO.class).eq(CephPrimaryStorageVO_.fsid, fsid).find() == null){
SQL.New(CephCapacityVO.class).eq(CephCapacityVO_.fsid, fsid).delete();
}
}
}.execute();
代码示例来源:origin: zstackio/zstack
private void validate(APIDeleteLongJobMsg msg) {
LongJobState state = Q.New(LongJobVO.class)
.select(LongJobVO_.state)
.eq(LongJobVO_.uuid, msg.getUuid())
.findValue();
if (state != LongJobState.Succeeded && state != LongJobState.Canceled && state != LongJobState.Failed) {
throw new ApiMessageInterceptionException(argerr("delete longjob only when it's succeeded, canceled, or failed"));
}
}
代码示例来源:origin: zstackio/zstack
private void validate(APIUpdateLoadBalancerListenerMsg msg) {
String loadBalancerUuid = Q.New(LoadBalancerListenerVO.class).
select(LoadBalancerListenerVO_.loadBalancerUuid).
eq(LoadBalancerListenerVO_.uuid,msg.
getLoadBalancerListenerUuid()).findValue();
msg.setLoadBalancerUuid(loadBalancerUuid);
bus.makeTargetServiceIdByResourceUuid(msg, LoadBalancerConstants.SERVICE_ID, loadBalancerUuid);
}
代码示例来源:origin: zstackio/zstack
private void validate(final APIGetCandidatePrimaryStoragesForCreatingVmMsg msg) {
ImageMediaType mediaType = Q.New(ImageVO.class).eq(ImageVO_.uuid, msg.getImageUuid()).select(ImageVO_.mediaType).findValue();
if (ImageMediaType.ISO == mediaType && msg.getRootDiskOfferingUuid() == null) {
throw new ApiMessageInterceptionException(argerr("rootVolumeOffering is needed when image media type is ISO"));
}
}
代码示例来源:origin: zstackio/zstack
private void validate(APICreateVxlanVtepMsg msg) {
long count = Q.New(VtepVO.class).eq(VtepVO_.hostUuid, msg.getHostUuid()).eq(VtepVO_.poolUuid, msg.getPoolUuid()).count();
if (count > 0) {
throw new ApiMessageInterceptionException(argerr("vxlan vtep address for host [uuid : %s] and pool [uuid : %s] pair already existed",
msg.getHostUuid(), msg.getPoolUuid())
);
}
}
代码示例来源:origin: zstackio/zstack
@Override
public Result getMessageParams(APIMessage message) {
APILogInByAccountMsg msg = (APILogInByAccountMsg) message;
String resourceIdentity = Q.New(AccountVO.class).select(AccountVO_.uuid).eq(AccountVO_.name, msg.getAccountName()).findValue();
Result r = new Result();
r.setCaptchaUuid(msg.getCaptchaUuid());
r.setTargetResourceIdentity(resourceIdentity);
r.setVerifyCode(msg.getVerifyCode());
return r;
}
}
代码示例来源:origin: zstackio/zstack
private void validate(APIAddCertificateToLoadBalancerListenerMsg msg) {
LoadBalancerListenerVO vo = dbf.findByUuid(msg.getListenerUuid(), LoadBalancerListenerVO.class);
if (!vo.getProtocol().equals(LoadBalancerConstants.LB_PROTOCOL_HTTPS)) {
throw new ApiMessageInterceptionException(argerr("loadbalancer listener with type %s does not need certificate", vo.getProtocol()));
}
if (Q.New(LoadBalancerListenerCertificateRefVO.class).eq(LoadBalancerListenerCertificateRefVO_.listenerUuid, msg.getListenerUuid()).isExists()) {
throw new ApiMessageInterceptionException(argerr("loadbalancer listener [uuid:%s] already had certificate",
msg.getCertificateUuid(), msg.getListenerUuid()));
}
msg.setLoadBalancerUuid(vo.getLoadBalancerUuid());
}
代码示例来源:origin: zstackio/zstack
protected LocalStorageHypervisorFactory getHypervisorBackendFactoryByHostUuid(String hostUuid, boolean checkPsRef) {
if (checkPsRef && !Q.New(LocalStorageHostRefVO.class)
.eq(LocalStorageHostRefVO_.hostUuid, hostUuid)
.eq(LocalStorageHostRefVO_.primaryStorageUuid, self.getUuid()).isExists()) {
throw new OperationFailureException(operr("host[uuid:%s] cannot access local storage[uuid:%s], maybe it is detached", hostUuid, self.getUuid()));
}
SimpleQuery<HostVO> q = dbf.createQuery(HostVO.class);
q.select(HostVO_.hypervisorType);
q.add(HostVO_.uuid, Op.EQ, hostUuid);
String hvType = q.findValue();
return getHypervisorBackendFactory(hvType);
}
代码示例来源:origin: zstackio/zstack
private void validate(APIGetEipAttachableVmNicsMsg msg) {
if (msg.getVipUuid() == null && msg.getEipUuid() == null) {
throw new ApiMessageInterceptionException(argerr("either eipUuid or vipUuid must be set"));
}
if (msg.getEipUuid() != null) {
EipState state = Q.New(EipVO.class).select(EipVO_.state).eq(EipVO_.uuid,msg.getEipUuid()).findValue();
if (state != EipState.Enabled) {
throw new ApiMessageInterceptionException(operr("eip[uuid:%s] is not in state of Enabled, cannot get attachable vm nic", msg.getEipUuid()));
}
}
}
代码示例来源:origin: zstackio/zstack
@Override
public void success() {
logger.debug(String.format("successfully acquired vip[uuid:%s, name:%s, ip:%s] on service[%s]",
self.getUuid(), self.getName(), self.getIp(), s.getServiceProvider()));
VipUseForList useForList = new VipUseForList(self.getUseFor());
useForList.add(s.getUseFor());
VipVO vo = Q.New(VipVO.class).eq(VipVO_.uuid, self.getUuid()).find();
vo.setUseFor(useForList.toString());
dbf.updateAndRefresh(vo);
addPeerL3NetworkUuid(s.getPeerL3NetworkUuid());
completion.success();
}
内容来源于网络,如有侵权,请联系作者删除!