本文整理汇总了Java中com.datastax.driver.core.utils.UUIDs类的典型用法代码示例。如果您正苦于以下问题:Java UUIDs类的具体用法?Java UUIDs怎么用?Java UUIDs使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
UUIDs类属于com.datastax.driver.core.utils包,在下文中一共展示了UUIDs类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import com.datastax.driver.core.utils.UUIDs; //导入依赖的package包/类
public static void main(String[] args) {
Session session = Connection.connect();
PreparedStatement preparedStatement = session.prepare("insert into user (id, name, age) values (?, ?, ?)");
try {
BoundStatement boundStatement = preparedStatement.bind(UUIDs.timeBased(), "Hector", 34);
ResultSet rs = session.execute(boundStatement);
System.out.println(rs);
} catch (Exception ex) {
ex.printStackTrace();
}
Connection.close();
}
示例2: main
import com.datastax.driver.core.utils.UUIDs; //导入依赖的package包/类
public static void main(String[] args) {
Session session = Connection.connect();
BatchStatement batchStatement = new BatchStatement();
PreparedStatement preparedStatement = session.prepare("insert into user (id, name) values (?, ?)");
int i = 0;
while(i < 10) {
batchStatement.add(preparedStatement.bind(UUIDs.timeBased(), "user-" + i));
++i;
}
try {
ResultSet rs = session.execute(batchStatement);
System.out.println(rs);
} catch (Exception ex) {
ex.printStackTrace();
}
Connection.close();
}
示例3: toData
import com.datastax.driver.core.utils.UUIDs; //导入依赖的package包/类
@Override
public Alarm toData() {
Alarm alarm = new Alarm(new AlarmId(id));
alarm.setCreatedTime(UUIDs.unixTimestamp(id));
if (tenantId != null) {
alarm.setTenantId(new TenantId(tenantId));
}
alarm.setOriginator(EntityIdFactory.getByTypeAndUuid(originatorType, originatorId));
alarm.setType(type);
alarm.setSeverity(severity);
alarm.setStatus(status);
alarm.setPropagate(propagate);
alarm.setStartTs(startTs);
alarm.setEndTs(endTs);
alarm.setAckTs(ackTs);
alarm.setClearTs(clearTs);
alarm.setDetails(details);
return alarm;
}
示例4: toData
import com.datastax.driver.core.utils.UUIDs; //导入依赖的package包/类
@Override
public WidgetsBundle toData() {
WidgetsBundle widgetsBundle = new WidgetsBundle(new WidgetsBundleId(id));
widgetsBundle.setCreatedTime(UUIDs.unixTimestamp(id));
if (tenantId != null) {
widgetsBundle.setTenantId(new TenantId(tenantId));
}
widgetsBundle.setAlias(alias);
widgetsBundle.setTitle(title);
if (image != null) {
byte[] imageByteArray = new byte[image.remaining()];
image.get(imageByteArray);
widgetsBundle.setImage(imageByteArray);
}
return widgetsBundle;
}
示例5: toData
import com.datastax.driver.core.utils.UUIDs; //导入依赖的package包/类
@Override
public Customer toData() {
Customer customer = new Customer(new CustomerId(id));
customer.setCreatedTime(UUIDs.unixTimestamp(id));
customer.setTenantId(new TenantId(tenantId));
customer.setTitle(title);
customer.setCountry(country);
customer.setState(state);
customer.setCity(city);
customer.setAddress(address);
customer.setAddress2(address2);
customer.setZip(zip);
customer.setPhone(phone);
customer.setEmail(email);
customer.setAdditionalInfo(additionalInfo);
return customer;
}
示例6: toData
import com.datastax.driver.core.utils.UUIDs; //导入依赖的package包/类
@Override
public User toData() {
User user = new User(new UserId(id));
user.setCreatedTime(UUIDs.unixTimestamp(id));
user.setAuthority(authority);
if (tenantId != null) {
user.setTenantId(new TenantId(tenantId));
}
if (customerId != null) {
user.setCustomerId(new CustomerId(customerId));
}
user.setEmail(email);
user.setFirstName(firstName);
user.setLastName(lastName);
user.setAdditionalInfo(additionalInfo);
return user;
}
示例7: toData
import com.datastax.driver.core.utils.UUIDs; //导入依赖的package包/类
@Override
public Tenant toData() {
Tenant tenant = new Tenant(new TenantId(id));
tenant.setCreatedTime(UUIDs.unixTimestamp(id));
tenant.setTitle(title);
tenant.setRegion(region);
tenant.setCountry(country);
tenant.setState(state);
tenant.setCity(city);
tenant.setAddress(address);
tenant.setAddress2(address2);
tenant.setZip(zip);
tenant.setPhone(phone);
tenant.setEmail(email);
tenant.setAdditionalInfo(additionalInfo);
return tenant;
}
示例8: toData
import com.datastax.driver.core.utils.UUIDs; //导入依赖的package包/类
@Override
public Alarm toData() {
Alarm alarm = new Alarm(new AlarmId(UUIDConverter.fromString(id)));
alarm.setCreatedTime(UUIDs.unixTimestamp(UUIDConverter.fromString(id)));
if (tenantId != null) {
alarm.setTenantId(new TenantId(UUIDConverter.fromString(tenantId)));
}
alarm.setOriginator(EntityIdFactory.getByTypeAndUuid(originatorType, UUIDConverter.fromString(originatorId)));
alarm.setType(type);
alarm.setSeverity(severity);
alarm.setStatus(status);
alarm.setPropagate(propagate);
alarm.setStartTs(startTs);
alarm.setEndTs(endTs);
alarm.setAckTs(ackTs);
alarm.setClearTs(clearTs);
alarm.setDetails(details);
return alarm;
}
示例9: toData
import com.datastax.driver.core.utils.UUIDs; //导入依赖的package包/类
@Override
public Customer toData() {
Customer customer = new Customer(new CustomerId(getId()));
customer.setCreatedTime(UUIDs.unixTimestamp(getId()));
customer.setTenantId(new TenantId(UUIDConverter.fromString(tenantId)));
customer.setTitle(title);
customer.setCountry(country);
customer.setState(state);
customer.setCity(city);
customer.setAddress(address);
customer.setAddress2(address2);
customer.setZip(zip);
customer.setPhone(phone);
customer.setEmail(email);
customer.setAdditionalInfo(additionalInfo);
return customer;
}
示例10: toData
import com.datastax.driver.core.utils.UUIDs; //导入依赖的package包/类
@Override
public User toData() {
User user = new User(new UserId(getId()));
user.setCreatedTime(UUIDs.unixTimestamp(getId()));
user.setAuthority(authority);
if (tenantId != null) {
user.setTenantId(new TenantId(UUIDConverter.fromString(tenantId)));
}
if (customerId != null) {
user.setCustomerId(new CustomerId(UUIDConverter.fromString(customerId)));
}
user.setEmail(email);
user.setFirstName(firstName);
user.setLastName(lastName);
user.setAdditionalInfo(additionalInfo);
return user;
}
示例11: toData
import com.datastax.driver.core.utils.UUIDs; //导入依赖的package包/类
@Override
public Tenant toData() {
Tenant tenant = new Tenant(new TenantId(getId()));
tenant.setCreatedTime(UUIDs.unixTimestamp(getId()));
tenant.setTitle(title);
tenant.setRegion(region);
tenant.setCountry(country);
tenant.setState(state);
tenant.setCity(city);
tenant.setAddress(address);
tenant.setAddress2(address2);
tenant.setZip(zip);
tenant.setPhone(phone);
tenant.setEmail(email);
tenant.setAdditionalInfo(additionalInfo);
return tenant;
}
示例12: save
import com.datastax.driver.core.utils.UUIDs; //导入依赖的package包/类
private Optional<Event> save(EventEntity entity, boolean ifNotExists) {
if (entity.getId() == null) {
entity.setId(UUIDs.timeBased());
}
Insert insert = QueryBuilder.insertInto(getColumnFamilyName())
.value(ModelConstants.ID_PROPERTY, entity.getId())
.value(ModelConstants.EVENT_TENANT_ID_PROPERTY, entity.getTenantId())
.value(ModelConstants.EVENT_ENTITY_TYPE_PROPERTY, entity.getEntityType())
.value(ModelConstants.EVENT_ENTITY_ID_PROPERTY, entity.getEntityId())
.value(ModelConstants.EVENT_TYPE_PROPERTY, entity.getEventType())
.value(ModelConstants.EVENT_UID_PROPERTY, entity.getEventUid())
.value(ModelConstants.EVENT_BODY_PROPERTY, entity.getBody());
if (ifNotExists) {
insert = insert.ifNotExists();
}
ResultSet rs = executeWrite(insert);
if (rs.wasApplied()) {
return Optional.of(DaoUtil.getData(entity));
} else {
return Optional.empty();
}
}
示例13: save
import com.datastax.driver.core.utils.UUIDs; //导入依赖的package包/类
@Override
@Transactional
public D save(D domain) {
E entity;
try {
entity = getEntityClass().getConstructor(domain.getClass()).newInstance(domain);
} catch (Exception e) {
log.error("Can't create entity for domain object {}", domain, e);
throw new IllegalArgumentException("Can't create entity for domain object {" + domain + "}", e);
}
setSearchText(entity);
log.debug("Saving entity {}", entity);
if (entity.getId() == null) {
entity.setId(UUIDs.timeBased());
}
entity = getCrudRepository().save(entity);
return DaoUtil.getData(entity);
}
示例14: save
import com.datastax.driver.core.utils.UUIDs; //导入依赖的package包/类
public Optional<Event> save(EventEntity entity, boolean ifNotExists) {
log.debug("Save event [{}] ", entity);
if (entity.getTenantId() == null) {
log.trace("Save system event with predefined id {}", systemTenantId);
entity.setTenantId(UUIDConverter.fromTimeUUID(systemTenantId));
}
if (entity.getId() == null) {
entity.setId(UUIDs.timeBased());
}
if (StringUtils.isEmpty(entity.getEventUid())) {
entity.setEventUid(entity.getId().toString());
}
if (ifNotExists &&
eventRepository.findByTenantIdAndEntityTypeAndEntityId(entity.getTenantId(), entity.getEntityType(), entity.getEntityId()) != null) {
return Optional.empty();
}
return Optional.of(DaoUtil.getData(eventRepository.save(entity)));
}
示例15: saveIfNotExist
import com.datastax.driver.core.utils.UUIDs; //导入依赖的package包/类
private Optional<ComponentDescriptor> saveIfNotExist(ComponentDescriptorEntity entity) {
if (entity.getId() == null) {
entity.setId(UUIDs.timeBased());
}
ResultSet rs = executeRead(QueryBuilder.insertInto(getColumnFamilyName())
.value(ModelConstants.ID_PROPERTY, entity.getId())
.value(ModelConstants.COMPONENT_DESCRIPTOR_NAME_PROPERTY, entity.getName())
.value(ModelConstants.COMPONENT_DESCRIPTOR_CLASS_PROPERTY, entity.getClazz())
.value(ModelConstants.COMPONENT_DESCRIPTOR_TYPE_PROPERTY, entity.getType())
.value(ModelConstants.COMPONENT_DESCRIPTOR_SCOPE_PROPERTY, entity.getScope())
.value(ModelConstants.COMPONENT_DESCRIPTOR_CONFIGURATION_DESCRIPTOR_PROPERTY, entity.getConfigurationDescriptor())
.value(ModelConstants.COMPONENT_DESCRIPTOR_ACTIONS_PROPERTY, entity.getActions())
.value(ModelConstants.SEARCH_TEXT_PROPERTY, entity.getSearchText())
.ifNotExists()
);
if (rs.wasApplied()) {
return Optional.of(DaoUtil.getData(entity));
} else {
return Optional.empty();
}
}