/** * This constructor should never be used directly - use {@link #Empty} instead. * It is left here only because GWT requires it. */ @Deprecated private Guid() { this(Empty.getUuid()); }
public Guid(String candidate) { if (candidate == null) { throw new NullPointerException( "candidate can not be null please use static method createGuidFromString"); } if (candidate.isEmpty()) { uuid = Empty.getUuid(); } else { uuid = UUID.fromString(candidate); } }
@Override public List<Label> getAllByIds(Iterable<Guid> ids) { List<UUID> uuids = new ArrayList<>(); for (Guid guid: ids) { uuids.add(guid.getUuid()); } MapSqlParameterSource parameterSource = getCustomMapSqlParameterSource() .addValue("label_ids", createArrayOf("uuid", uuids.toArray())); return getCallsHandler() .executeReadList("GetLabelByIds", labelRowMapper, parameterSource); }
@Override public List<Label> getAllByEntityIds(Iterable<Guid> entities) { List<UUID> uuids = new ArrayList<>(); for (Guid guid: entities) { uuids.add(guid.getUuid()); } MapSqlParameterSource parameterSource = getCustomMapSqlParameterSource() .addValue("entity_ids", createArrayOf("uuid", uuids.toArray())); return getCallsHandler() .executeReadList("GetLabelsByReferencedIds", labelRowMapper, parameterSource); }
@Override public MapSqlParameterSource addValue(String paramName, Object value) { Object tmpValue = value; // just to be safe if (tmpValue != null) { // lets check if we need to translate value if (tmpValue instanceof Enum) { tmpValue = extractEnumValue(tmpValue); } else if (tmpValue instanceof Guid) { tmpValue = ((Guid) tmpValue).getUuid(); } else if (tmpValue instanceof Version) { tmpValue = value.toString(); } } return super.addValue(dialect.getParamNamePrefix() + paramName, tmpValue); }
@Override public void nullifyQosForStorageDomain(Guid storageDomainId) { getCallsHandler().executeModification("nullifyQosForStorageDomain", getCustomMapSqlParameterSource().addValue("storage_domain_id", storageDomainId.getUuid())); }
/** * Ensures that a collection of tags is returned. */ @Test public void testGetAllForVm() { List<Tags> result = dao.getAllForTemplate(template.getUuid().toString()); assertNotNull(result); assertFalse(result.isEmpty()); }
/** * Ensures that a collection of tags is returned. */ @Test public void testGetAllForTemplate() { List<Tags> result = dao.getAllForTemplate(vm.getUuid().toString()); assertNotNull(result); assertFalse(result.isEmpty()); }
/** * Ensures that the right set of tags are returned for a specified user. */ @Test public void testGetAllForUser() { List<Tags> result = dao.getAllForUsers(user.getUuid().toString()); assertNotNull(result); assertFalse(result.isEmpty()); }
@Override public List<T> getAllForStoragePoolId(Guid storagePoolId) { MapSqlParameterSource parameterSource = getCustomMapSqlParameterSource() .addValue("storage_pool_id", storagePoolId.getUuid()) .addValue("qos_type", getQosType()); return getCallsHandler().executeReadList("GetAllQosForStoragePoolByQosType", createEntityRowMapper(), parameterSource); }
/** * Asserts that an VDS with no tags returns an empty collection. */ @Test public void testGetAllForVdsWithInvalidVds() { List<Tags> result = dao.getAllForVds(Guid.newGuid().getUuid() .toString()); assertNotNull(result); assertTrue(result.isEmpty()); }
/** * Ensures that an empty collection is returned. */ @Test public void testGetAllForVmWithInvalidVm() { List<Tags> result = dao .getAllForVm(Guid.newGuid().getUuid().toString()); assertNotNull(result); assertTrue(result.isEmpty()); }
/** * Ensures that an empty collection is returned. */ @Test public void testGetAllForUserIdsWithInvalidIds() { List<Tags> result = dao.getAllForUsersWithIds(Guid.newGuid().getUuid() .toString()); assertNotNull(result); assertTrue(result.isEmpty()); }
/** * Ensures that an empty collection is returned. */ @Test public void testGetAllForVmWithInvalidTemplate() { List<Tags> result = dao .getAllForTemplate(Guid.newGuid().getUuid().toString()); assertNotNull(result); assertTrue(result.isEmpty()); }
@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"); }