org.zstack.core.db.Q.isExists()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(7.7k)|赞(0)|评价(0)|浏览(110)

本文整理了Java中org.zstack.core.db.Q.isExists方法的一些代码示例,展示了Q.isExists的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Q.isExists方法的具体详情如下:
包路径:org.zstack.core.db.Q
类名称:Q
方法名:isExists

Q.isExists介绍

暂无

代码示例

代码示例来源:origin: zstackio/zstack

private boolean isLdapServerExist(){
  if(Q.New(LdapServerVO.class).isExists()){
    logger.warn("update ldapUid to ldapDn fail, There is no ldap server in the system");
    return true;
  }
  return false;
}

代码示例来源:origin: zstackio/zstack

private boolean isBindingExist(){
  if(Q.New(LdapAccountRefVO.class).isExists()){
    logger.warn("update ldapUid to ldapDn fail, There is no bindings in the system");
    return true;
  }
  return false;
}

代码示例来源:origin: zstackio/zstack

private boolean makeSureInstallPathNotUsedBySnapshot(String installPath) {
  return !Q.New(VolumeSnapshotVO.class).eq(VolumeSnapshotVO_.primaryStorageInstallPath, installPath).isExists() &&
      !Q.New(ImageCacheVO.class).eq(ImageCacheVO_.installUrl, installPath).isExists();
}

代码示例来源: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 void validate(APIAddMonToCephPrimaryStorageMsg msg) {
  checkMonUrls(msg.getMonUrls());
  List<String> hostnames = msg.getMonUrls().stream()
      .map(MonUri::new)
      .map(MonUri::getHostname)
      .collect(Collectors.toList());
  if (Q.New(CephPrimaryStorageMonVO.class).in(CephPrimaryStorageMonVO_.hostname, hostnames).isExists()){
    throw new ApiMessageInterceptionException(argerr("Adding the same Mon node is not allowed"));
  }
}

代码示例来源: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

private void validateLdapServerExist(){
  if(!Q.New(LdapServerVO.class).isExists()){
    throw new ApiMessageInterceptionException(argerr("There is no ldap server in the system, Please add a ldap server first."));
  }
}

代码示例来源:origin: zstackio/zstack

public static boolean isIsoAttachedToVm(String vmUuid) {
  boolean exsit = Q.New(VmCdRomVO.class)
      .eq(VmCdRomVO_.vmInstanceUuid, vmUuid)
      .notNull(VmCdRomVO_.isoUuid)
      .isExists();
  return exsit;
}

代码示例来源:origin: zstackio/zstack

private Boolean isLocalStorage(String psUuid) {
  return Q.New(PrimaryStorageVO.class)
      .eq(PrimaryStorageVO_.type, type.toString())
      .eq(PrimaryStorageVO_.uuid, psUuid)
      .isExists();
}

代码示例来源:origin: zstackio/zstack

@Override
public boolean verifyCaptcha(String uuid, String verifyCode, String targetResourceIdentify) {
  if (Q.New(CaptchaVO.class)
      .eq(CaptchaVO_.uuid, uuid)
      .eq(CaptchaVO_.verifyCode, verifyCode)
      .eq(CaptchaVO_.targetResourceIdentity, targetResourceIdentify)
      .isExists()) {
    return true;
  }
  return false;
}

代码示例来源:origin: zstackio/zstack

private boolean isTagExisting(String resourceUuid, String tag, TagType type, String resourceType) {
  if (type == TagType.User) {
    return Q.New(UserTagVO.class).eq(UserTagVO_.resourceType, resourceType)
        .eq(UserTagVO_.tag, tag)
        .eq(UserTagVO_.resourceUuid, resourceUuid)
        .isExists();
  } else {
    return Q.New(SystemTagVO.class).eq(SystemTagVO_.resourceType, resourceType)
        .eq(SystemTagVO_.tag, tag)
        .eq(SystemTagVO_.resourceUuid, resourceUuid)
        .isExists();
  }
}

代码示例来源:origin: zstackio/zstack

private void handle(APIGetEipAttachableVmNicsMsg msg) {
  APIGetEipAttachableVmNicsReply reply = new APIGetEipAttachableVmNicsReply();
  boolean isAttached = Q.New(EipVO.class).eq(EipVO_.uuid, msg.getEipUuid()).notNull(EipVO_.vmNicUuid).isExists();
  reply.setInventories(isAttached ? new ArrayList<>() : getEipAttachableVmNics(msg));
  bus.reply(msg, reply);
}

代码示例来源:origin: zstackio/zstack

@Override
public void afterDeleteIpRange(IpRangeInventory ipRange) {
  String dhcpServerIp = getDHCPServerIP(ipRange.getL3NetworkUuid());
  boolean ipRangeExisted = Q.New(IpRangeVO.class).eq(IpRangeVO_.l3NetworkUuid, ipRange.getL3NetworkUuid()).isExists();
  if (!ipRangeExisted && dhcpServerIp != null) {
    deleteDhcpServerIp(ipRange.getL3NetworkUuid(), dhcpServerIp);
    logger.debug(String.format("delete DHCP IP[%s] of the flat network[uuid:%s] as the IP range[uuid:%s] is deleted",
        dhcpServerIp, ipRange.getL3NetworkUuid(), ipRange.getUuid()));
  }
}

代码示例来源:origin: zstackio/zstack

private void validate(APIUpdateRoleMsg msg) {
  if (Q.New(RoleVO.class).in(RoleVO_.type, list(RoleType.Predefined, RoleType.System)).eq(RoleVO_.uuid, msg.getUuid()).isExists()) {
    throw new ApiMessageInterceptionException(argerr("cannot update a system or predefined role"));
  }
}

代码示例来源:origin: zstackio/zstack

private void validate(APIDeleteRoleMsg msg) {
    if (Q.New(RoleVO.class).in(RoleVO_.type, list(RoleType.Predefined, RoleType.System)).eq(RoleVO_.uuid, msg.getUuid()).isExists()) {
      throw new ApiMessageInterceptionException(argerr("cannot delete a system or predefined role"));
    }
  }
}

代码示例来源:origin: zstackio/zstack

@Override
  protected void scripts() {
    if (!q(LdapServerVO.class).eq(LdapServerVO_.uuid, msg.getUuid()).isExists()) {
      return;
    }
    LdapServerVO vo = q(LdapServerVO.class).eq(LdapServerVO_.uuid, msg.getUuid()).find();
    remove(vo);
    flush();
  }
}.execute();

代码示例来源: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

@Override
  protected void scripts() {
    if (!q(VolumeSnapshotVO.class).eq(VolumeSnapshotVO_.volumeUuid, volumeUuid).isExists()) {
      return;
    }
    List<String> treeUuids = q(VolumeSnapshotVO.class).select(VolumeSnapshotVO_.treeUuid).eq(VolumeSnapshotVO_.volumeUuid, volumeUuid).listValues();
    sql(VolumeSnapshotTreeVO.class).in(VolumeSnapshotTreeVO_.uuid, treeUuids).delete();
    sql(VolumeSnapshotVO.class).eq(VolumeSnapshotVO_.volumeUuid, volumeUuid).delete();
  }
}.execute();

代码示例来源: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(APIRemoveCertificateFromLoadBalancerListenerMsg msg) {
    if (!Q.New(LoadBalancerListenerCertificateRefVO.class).eq(LoadBalancerListenerCertificateRefVO_.listenerUuid, msg.getListenerUuid())
        .eq(LoadBalancerListenerCertificateRefVO_.certificateUuid, msg.getCertificateUuid()).isExists()) {
      throw new ApiMessageInterceptionException(argerr("certificate [uuid:%s] is not added to loadbalancer listener [uuid:%s]",
          msg.getCertificateUuid(), msg.getListenerUuid()));
    }

    LoadBalancerListenerVO vo = dbf.findByUuid(msg.getListenerUuid(), LoadBalancerListenerVO.class);
    msg.setLoadBalancerUuid(vo.getLoadBalancerUuid());
  }
}

相关文章