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

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

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

Q.find介绍

暂无

代码示例

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

public static SessionInventory getSession(String uuid) {
    SessionInventory s = sessions.get(uuid);
    if (s == null) {
      SessionVO vo = Q.New(SessionVO.class).eq(SessionVO_.uuid, uuid).find();
      if (vo == null) {
        return null;
      }

      s = SessionInventory.valueOf(vo);
      sessions.put(s.getUuid(), s);
    }

    return s;
  }
}

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

@Override
public Integer getL2NetworkVni(String l2NetworkUuid) {
  VxlanNetworkVO vxlanNetworkVO = Q.New(VxlanNetworkVO.class).eq(VxlanNetworkVO_.uuid, l2NetworkUuid).find();
  return vxlanNetworkVO.getVni();
}

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

@Override
public LdapAccountRefVO findLdapAccountRefVO(String ldapDn){
  LdapAccountRefVO ldapAccountRefVO = Q.New(LdapAccountRefVO.class)
      .eq(LdapAccountRefVO_.ldapUid, ldapDn).find();
  if(ldapAccountRefVO != null){
    return ldapAccountRefVO;
  }
  ldapAccountRefVO = findLdapAccountRefByAffiliatedGroup(ldapDn);
  return ldapAccountRefVO;
}

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

@Override
public Integer getL2NetworkVni(String l2NetworkUuid) {
  L2VlanNetworkVO l2VlanNetworkVO = Q.New(L2VlanNetworkVO.class).eq(L2VlanNetworkVO_.uuid, l2NetworkUuid).find();
  return l2VlanNetworkVO.getVlan();
}

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

private Boolean isCephPrimaryStorageVolume(String volumeUuid) {
    VolumeVO volumeVO = Q.New(VolumeVO.class).eq(VolumeVO_.uuid, volumeUuid).find();
    PrimaryStorageVO primaryStorageVO = Q.New(PrimaryStorageVO.class)
        .eq(PrimaryStorageVO_.uuid, volumeVO.getPrimaryStorageUuid()).find();

    return primaryStorageVO.getType().equals(type.toString());
  }
}

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

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(APIAttachL3NetworkToVmMsg msg) {
  VmInstanceVO vmInstanceVO = Q.New(VmInstanceVO.class).eq(VmInstanceVO_.uuid, msg.getVmInstanceUuid()).find();
  if (vmInstanceVO.getType().equals(ApplianceVmConstant.APPLIANCE_VM_TYPE)){
    validateIpRangeOverlapWithVm(msg.getL3NetworkUuid(), msg.getVmInstanceUuid());
  }
}

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

@Override
  public SessionInventory doAuth(RestAuthenticationParams params) throws RestException {
    SessionVO vo = Q.New(SessionVO.class).eq(SessionVO_.uuid, params.authKey).find();
    if (vo != null) {
      return SessionInventory.valueOf(vo);
    }

    /* invalid session error should be raised in ApiMessageProcessorImpl */
    SessionInventory session = new SessionInventory();
    session.setUuid(params.authKey);
    return session;
  }
}

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

private void validate(APIDeleteVniRangeMsg msg) {
  VniRangeVO vo = Q.New(VniRangeVO.class).eq(VniRangeVO_.uuid, msg.getUuid()).find();
  msg.setL2NetworkUuid(vo.getL2NetworkUuid());
}

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

@Override
public void deleteSystemTag(String uuid) {
  SystemTagVO vo = Q.New(SystemTagVO.class).eq(SystemTagVO_.uuid, uuid).find();
  if (vo == null) {
    return;
  }
  preTagDeleted(SystemTagInventory.valueOf(vo));
  dbf.remove(vo);
  fireTagDeleted(Collections.singletonList(SystemTagInventory.valueOf(vo)));
}

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

private void validate(APIUpdateVniRangeMsg msg) {
  VniRangeVO vo = Q.New(VniRangeVO.class).eq(VniRangeVO_.uuid, msg.getUuid()).find();
  msg.setL2NetworkUuid(vo.getL2NetworkUuid());
}

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

private void validate(APICreateL2VxlanNetworkMsg msg) {
  VxlanNetworkPoolVO vo = Q.New(VxlanNetworkPoolVO.class).eq(VxlanNetworkPoolVO_.uuid, msg.getPoolUuid()).find();
  if (msg.getZoneUuid() != null && !msg.getZoneUuid().equals(vo.getZoneUuid()))  {
    throw new ApiMessageInterceptionException(Platform.err(SysErrors.INVALID_ARGUMENT_ERROR,
        String.format("the zone uuid provided not equals to zone uuid of pool [%s], please correct it or do not fill it",
            msg.getPoolUuid())
    ));
  } else if (msg.getZoneUuid() == null ) {
    msg.setZoneUuid(vo.getZoneUuid());
  }
}

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

private IpAllocatorType getIpAllocatorType(AllocateIpMsg msg) {
  if (msg.getAllocatorStrategy() != null) {
    return IpAllocatorType.valueOf(msg.getAllocatorStrategy());
  }
  L3NetworkVO l3Vo = Q.New(L3NetworkVO.class).eq(L3NetworkVO_.uuid, msg.getL3NetworkUuid()).find();
  if (l3Vo.getIpVersion() == IPv6Constants.IPv4) {
    return RandomIpAllocatorStrategy.type;
  }
  return RandomIpv6AllocatorStrategy.type;
}

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

@Override
public StorageTrashSpec getTrash(String storageUuid, Long trashId) {
  JsonLabelVO lable = Q.New(JsonLabelVO.class).eq(JsonLabelVO_.resourceUuid, storageUuid).eq(JsonLabelVO_.id, trashId).find();
  if (lable == null) {
    return null;
  }
  StorageTrashSpec spec = JSONObjectUtil.toObject(lable.getLabelValue(), StorageTrashSpec.class);
  spec.setTrashId(trashId);
  spec.setCreateDate(lable.getCreateDate());
  if (spec.getTrashType() == null) {
    spec.setTrashType(lable.getLabelKey().split("-")[0]);
  }
  return spec;
}

代码示例来源: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 handle(final APIUpdateVniRangeMsg msg) {
  VniRangeVO vo = Q.New(VniRangeVO.class).eq(VniRangeVO_.uuid, msg.getUuid()).find();
  vo.setName(msg.getName());
  vo = dbf.updateAndRefresh(vo);
  APIUpdateVniRangeEvent event = new APIUpdateVniRangeEvent(msg.getId());
  event.setInventory(new VniRangeInventory(vo));
  bus.publish(event);
  logger.info(String.format("update l2 vxlan vni range[%s] name[%s]", msg.getUuid(), msg.getName()));
}

代码示例来源: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();
}

相关文章