org.ovirt.engine.core.compat.Guid类的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(8.1k)|赞(0)|评价(0)|浏览(157)

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

Guid介绍

暂无

代码示例

代码示例来源:origin: oVirt/ovirt-engine

@Test
public void testStringCreation() {
  Guid guid = Guid.newGuid();
  Guid guidFromString = new Guid(guid.toString());
  assertEquals(guidFromString, guid);
  guidFromString = Guid.createGuidFromString(guid.toString());
  assertEquals(guidFromString, guid);
  guidFromString = Guid.createGuidFromString(null);
  assertNull(guidFromString);
  guidFromString = Guid.createGuidFromStringDefaultEmpty(guid.toString());
  assertEquals(guidFromString, guid);
  guidFromString = Guid.createGuidFromStringDefaultEmpty(null);
  assertEquals(Guid.Empty, guidFromString);
}

代码示例来源:origin: oVirt/ovirt-engine

public VmDeviceFeEntity(VmDevice vmDevice, VM vm, boolean beingUnplugged) {
  if (!vmDevice.getVmId().equals(vm.getId())) {
    throw new IllegalArgumentException("IDs of VM and device's VM doesn't match."); //$NON-NLS-1$
  }
  this.vmDevice = vmDevice;
  this.vm = vm;
  this.beingUnplugged = beingUnplugged;
}

代码示例来源:origin: oVirt/ovirt-engine

private void setIdIfNeeded(DbUser user) {
  if (Guid.isNullOrEmpty(user.getId())) {
    user.setId(Guid.newGuid());
  }
}

代码示例来源:origin: oVirt/ovirt-engine

private void addUuid(PDU pdu, final OID prefix, int suffix, Guid val) {
  if (!Guid.isNullOrEmpty(val)) {
    addString(pdu, prefix, suffix, val.toString(), false);
  }
}

代码示例来源:origin: oVirt/ovirt-engine

@Override
public void buildDisk() {
  XmlNodeList list = selectNodes(_document, "//*/Section/Disk");
  for (XmlNode node : list) {
    Guid guid = new Guid(node.attributes.get("ovf:diskId").getValue());
    _images.stream().filter(d -> d.getImageId().equals(guid)).findFirst().ifPresent(img -> readDisk(node, img));
    luns.stream().filter(d -> d.getId().equals(guid)).findFirst().ifPresent(lun -> readLunDisk(node, lun));
  }
}

代码示例来源:origin: oVirt/ovirt-engine

private org.ovirt.engine.core.common.businessentities.network.Network getNetwork() {
  List<org.ovirt.engine.core.common.businessentities.network.Network> networks = parent.getNetworks();
  for (org.ovirt.engine.core.common.businessentities.network.Network entity : networks) {
    if (entity.getId().toString().equals(id)) {
      return entity;
    }
  }
  return null;
}

代码示例来源:origin: oVirt/ovirt-engine

private static LinkedList<Guid> convertToGuidList(String str, char delimiter) {
  LinkedList<Guid> results = new LinkedList<>();
  if (str != null) {
    for (String id : str.split(String.format(" *%s *", delimiter))) {
      results.add(Guid.createGuidFromString(id));
    }
  }
  return results;
}

代码示例来源:origin: oVirt/ovirt-engine

/**
 * Ensures that if the id is invalid then no EngineSession is returned.
 */
@Test
public void testGetWithInvalidId() {
  EngineSession result = dao.getBySessionId(Guid.newGuid().toString());
  assertNull(result);
}

代码示例来源:origin: oVirt/ovirt-engine

/**
 * @return A generic {@link Guid} result mapper which always takes the {@link Guid} result, regardless of how it's
 *         column is called.
 */
protected RowMapper<Guid> createGuidMapper() {
  return (rs, rowNum) -> new Guid((UUID) rs.getObject(1));
}

代码示例来源:origin: oVirt/ovirt-engine

private VmDevice createUnmanagedNetworkInterface(boolean plugged) {
  VmDevice device = createNetworkInterfaceDevice(plugged, Guid.newGuid());
  device.setManaged(false);
  return device;
}

代码示例来源:origin: oVirt/ovirt-engine

@Override
public DiskAttachment get() {
  DiskAttachment diskAttachment = performGet(QueryType.GetDiskVmElementById, new VmDeviceIdQueryParameters(new VmDeviceId(Guid.createGuidFromString(diskId), vmId)), Vm.class);
  /*
   * Href of the diskattachment must be set manually due to a bug (https://bugzilla.redhat.com/1647018).
   * The bug is the result of an exceptional case where the same entity (disk-attachment)
   * has the same parent (vm) in 2 different locations in the API, causing ambiguity
   * in the link generation process.
   */
  diskAttachment.setHref("/ovirt-engine/api/vms/" + vmId.toString() + "/diskattachments/" + diskAttachment.getId());
  return diskAttachment;
}

代码示例来源:origin: oVirt/ovirt-engine

@Test
@Override
public void testRoundtrip() throws Exception {
  Application model = Application.class.cast(populate(Application.class));
  model = postPopulate(model);
  model.setName(NAMES[0]);
  model.setId(new Guid(NAMES[0].getBytes()).toString());
  Mapper<String, Application> back = getMappingLocator().getMapper(String.class, Application.class);
  Application transform = back.map(NAMES[0], null);
  verify(model, transform);
}

代码示例来源:origin: oVirt/ovirt-engine

public org.ovirt.engine.core.common.businessentities.network.Network lookupNetwork(Guid id, String name, String dataCenterId) {
  for (org.ovirt.engine.core.common.businessentities.network.Network entity : getBackendCollection(queryType, getQueryParameters())) {
    if ((id != null && id.equals(entity.getId())) ||
      (name != null && name.equals(entity.getName()))
      && (entity.getDataCenterId()!=null) && entity.getDataCenterId().toString().equals(dataCenterId)) {
      return entity;
    }
  }
  return null;
}

代码示例来源:origin: oVirt/ovirt-engine

private AuditLogEvent extractAuditLogEvent(ResultSet rs, Set<String> downEvents) throws SQLException {
  AuditLogEvent auditLogEvent = new AuditLogEvent();
  auditLogEvent.setId(rs.getLong("audit_log_id"));
  auditLogEvent.setLogTypeName(rs.getString("log_type_name"));
  if (downEvents.contains(auditLogEvent.getLogTypeName())) {
    auditLogEvent.setType(AuditLogEventType.resolveMessage);
  } else {
    auditLogEvent.setType(AuditLogEventType.alertMessage);
  }
  auditLogEvent.setUserId(Guid.createGuidFromString(rs.getString("user_id")));
  auditLogEvent.setUserName(rs.getString("user_name"));
  auditLogEvent.setVmId(Guid.createGuidFromString(rs.getString("vm_id")));
  auditLogEvent.setVmName(rs.getString("vm_name"));
  auditLogEvent.setVmTemplateId(Guid.createGuidFromString(rs.getString("vm_template_id")));
  auditLogEvent.setVmTemplateName(rs.getString("vm_template_name"));
  auditLogEvent.setVdsId(Guid.createGuidFromString(rs.getString("vds_id")));
  auditLogEvent.setVdsName(rs.getString("vds_name"));
  auditLogEvent.setStoragePoolId(Guid.createGuidFromStringDefaultEmpty(rs.getString("storage_pool_id")));
  auditLogEvent.setStoragePoolName(rs.getString("storage_pool_name"));
  auditLogEvent.setStorageDomainId(Guid.createGuidFromStringDefaultEmpty(rs.getString("storage_domain_id")));
  auditLogEvent.setStorageDomainName(rs.getString("storage_domain_name"));
  auditLogEvent.setLogTime(rs.getTimestamp("log_time"));
  auditLogEvent.setSeverity(AuditLogSeverity.forValue(rs.getInt("severity")));
  auditLogEvent.setMessage(rs.getString("message"));
  return auditLogEvent;
}

代码示例来源:origin: oVirt/ovirt-engine

public static Guid getImageGroupIdFromImageFile(String imageFile) {
  if (!StringUtils.isBlank(imageFile)) {
    return Guid.createGuidFromStringDefaultEmpty(imageFile.split("[/]", -1)[0]);
  }
  return null;
}

代码示例来源:origin: oVirt/ovirt-engine

@Test
public void testGuidListValues() {
  String listValues = "e61f7070-cd52-46ca-88c2-686e1c70fe44,1eaa381a-fbf9-4ef5-bec2-6e4337f85d66";
  List<Guid> stringList = Guid.createGuidListFromString(listValues);
  List<Guid> expectedList = new ArrayList<>();
  expectedList.add(new Guid("e61f7070-cd52-46ca-88c2-686e1c70fe44"));
  expectedList.add(new Guid("1eaa381a-fbf9-4ef5-bec2-6e4337f85d66"));
  assertEquals(expectedList, stringList);
}

代码示例来源:origin: oVirt/ovirt-engine

@Test
public void testAddValueGuid() {
  Guid guid = new Guid(UUID.randomUUID());
  paramSource.addValue(paramName, guid);
  assertEquals(
      guid.getUuid(),
      paramSource.getValue(paramName), "wrong value returned from parameter source");
}

代码示例来源:origin: oVirt/ovirt-engine

private Guid getGuid(Guid guid) {
  return Guid.isNullOrEmpty(guid) ? Guid.Empty : guid;
}

代码示例来源:origin: oVirt/ovirt-engine

@Override
public StorageConnection get() {
  return performGet(QueryType.GetStorageServerConnectionById,
      new StorageServerConnectionQueryParametersBase(guid.toString()));
}

代码示例来源:origin: oVirt/ovirt-engine

private void readDedicatedHostsList(XmlNode content) {
  vmBase.setDedicatedVmForVdsList(new LinkedList<>()); // initialize to empty list
  for (XmlNode hostNode : selectNodes(content, DEDICATED_VM_FOR_VDS)) {
    if (hostNode != null && StringUtils.isNotEmpty(hostNode.innerText)) {
      vmBase.getDedicatedVmForVdsList().add(Guid.createGuidFromString(hostNode.innerText));
    }
  }
}

相关文章