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

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

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

Q.like介绍

暂无

代码示例

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

public static Collection<String> queryVmInGC(final String hostUuid, final Collection<String> vmUuids) {
    Collection<String> vmUuidsInGC = new HashSet<>();
    List<String> gcNames = Q.New(GarbageCollectorVO.class).select(GarbageCollectorVO_.name)
                    .eq(GarbageCollectorVO_.runnerClass, DeleteVmGC.class.getName())
                    .like(GarbageCollectorVO_.name, String.format("%%on-host-%s%%", hostUuid))
                    .notEq(GarbageCollectorVO_.status, GCStatus.Done).listValues();
    if (gcNames != null && !gcNames.isEmpty()) {
      vmUuidsInGC = vmUuids.stream().filter(uuid ->
          gcNames.contains(String.format("gc-vm-%s-on-host-%s", uuid, hostUuid))).collect(Collectors.toSet());
    }
    return vmUuidsInGC;
  }
}

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

public SystemTagInventory updateUnique(String resourceUuid, String oldTag, String newTag) {
  String tagUuid = Q.New(SystemTagVO.class).eq(SystemTagVO_.resourceUuid, resourceUuid).
      eq(SystemTagVO_.resourceType, resourceClass.getSimpleName()).like(SystemTagVO_.tag, oldTag).
      select(SystemTagVO_.uuid).findValue();
  if (tagUuid == null) {
    return null;
  }
  return tagMgr.updateSystemTag(tagUuid, newTag);
}

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

public List<SystemTagInventory> getTagInventories(String resourceUuid) {
  return SystemTagInventory.valueOf(Q.New(SystemTagVO.class).eq(SystemTagVO_.resourceType, getResourceClass().getSimpleName()).
      eq(SystemTagVO_.resourceUuid, resourceUuid).like(SystemTagVO_.tag, useTagFormat()).list());
}

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

@Override
public Long getTrashId(String storageUuid, String installPath) {
  DebugUtils.Assert(installPath != null, "installPath is not allowed null here");
  List<JsonLabelVO> lables = Q.New(JsonLabelVO.class).eq(JsonLabelVO_.resourceUuid, storageUuid).like(JsonLabelVO_.labelValue, String.format("%%%s%%", installPath)).list();
  if (!lables.isEmpty()) {
    for (JsonLabelVO lable: lables) {
      for (TrashType type: TrashType.values()) {
        if (!lable.getLabelKey().startsWith(type.name())) {
          // if lable key not starts with type, it may not be storage trash
          continue;
        }
      }
      StorageTrashSpec spec = JSONObjectUtil.toObject(lable.getLabelValue(), StorageTrashSpec.class);
      if (spec.getInstallPath().equals(installPath)) {
        return lable.getId();
      }
    }
  }
  return null;
}

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

@Override
public Map<String, StorageTrashSpec> getTrashList(String storageUuid, List<TrashType> types) {
  Map<String, StorageTrashSpec> specs = new HashMap<>();
  for (TrashType type: types) {
    List<JsonLabelVO> labels = Q.New(JsonLabelVO.class).eq(JsonLabelVO_.resourceUuid, storageUuid).like(JsonLabelVO_.labelKey, type.toString() + "-%").list();
    labels.forEach(l -> {
      StorageTrashSpec spec = JSONObjectUtil.toObject(l.getLabelValue(), StorageTrashSpec.class);
      spec.setTrashId(l.getId());
      spec.setCreateDate(l.getCreateDate());
      if (spec.getTrashType() == null) {
        spec.setTrashType(type.toString());
      }
      specs.put(l.getLabelKey(), spec);
    });
  }
  return specs;
}

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

.select(PrimaryStorageVO_.uuid)
.eq(PrimaryStorageVO_.type, NfsPrimaryStorageConstant.NFS_PRIMARY_STORAGE_TYPE)
.like(PrimaryStorageVO_.url, String.format("%s:/%%", hostIp))
.limit(1)
.findValue();

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

@Override
protected void checkImageIfNeedToDownload(DownloadIsoToPrimaryStorageMsg msg){
  logger.debug("check if image exist in disabled primary storage");
  if(self.getState() != PrimaryStorageState.Disabled){
    return ;
  }
  if( !Q.New(ImageCacheVO.class)
      .eq(ImageCacheVO_.primaryStorageUuid, self.getUuid())
      .eq(ImageCacheVO_.imageUuid, msg.getIsoSpec().getInventory().getUuid())
      .like(ImageCacheVO_.installUrl, String.format("%%hostUuid://%s%%", msg.getDestHostUuid()))
      .isExists()){
    throw new OperationFailureException(operr(
        "cannot attach ISO to a primary storage[uuid:%s] which is disabled",
        self.getUuid()));
  }
}

相关文章