本文整理汇总了Java中com.microsoft.azure.documentdb.Document.setId方法的典型用法代码示例。如果您正苦于以下问题:Java Document.setId方法的具体用法?Java Document.setId怎么用?Java Document.setId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.microsoft.azure.documentdb.Document
的用法示例。
在下文中一共展示了Document.setId方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: alarmToDocument
import com.microsoft.azure.documentdb.Document; //导入方法依赖的package包/类
private Document alarmToDocument(AlarmServiceModel alarm) {
Document document = new Document();
// TODO: make inserts idempotent
document.setId(UUID.randomUUID().toString());
document.set(docSchemaKey, docSchemaValue);
document.set(docSchemaVersionKey, docSchemaVersionValue);
document.set(createdKey, alarm.getDateCreated().getMillis());
document.set(modifiedKey, alarm.getDateModified().getMillis());
document.set(statusKey, alarm.getStatus());
document.set(descriptionKey, alarm.getDescription());
document.set(deviceIdKey, alarm.getDeviceId());
document.set(ruleIdKey, alarm.getRuleId());
document.set(ruleSeverityKey, alarm.getRuleSeverity());
document.set(ruleDescriptionKey, alarm.getRuleDescription());
// The logic used to generate the alarm (future proofing for ML)
document.set("logic", "1Device-1Rule-1Message");
return document;
}
示例2: writeInternal
import com.microsoft.azure.documentdb.Document; //导入方法依赖的package包/类
public void writeInternal(final Object entity,
final Document targetDocument,
final DocumentDbPersistentEntity<?> entityInformation) {
if (entity == null) {
return;
}
if (entityInformation == null) {
throw new MappingException("no mapping metadata for entity type: " + entity.getClass().getName());
}
final ConvertingPropertyAccessor accessor = getPropertyAccessor(entity);
final DocumentDbPersistentProperty idProperty = entityInformation.getIdProperty();
if (idProperty != null) {
targetDocument.setId((String) accessor.getProperty(idProperty));
}
for (final Field field : entity.getClass().getDeclaredFields()) {
if (null != idProperty && field.getName().equals(idProperty.getName())) {
continue;
}
targetDocument.set(field.getName(),
accessor.getProperty(entityInformation.getPersistentProperty(field.getName())));
}
}
示例3: getCreateDocumentRequest
import com.microsoft.azure.documentdb.Document; //导入方法依赖的package包/类
private RxDocumentServiceRequest getCreateDocumentRequest(String documentCollectionLink, Object document,
RequestOptions options, boolean disableAutomaticIdGeneration, OperationType operationType) {
if (StringUtils.isEmpty(documentCollectionLink)) {
throw new IllegalArgumentException("documentCollectionLink");
}
if (document == null) {
throw new IllegalArgumentException("document");
}
Document typedDocument = documentFromObject(document);
RxDocumentClientImpl.validateResource(typedDocument);
if (typedDocument.getId() == null && !disableAutomaticIdGeneration) {
// We are supposed to use GUID. Basically UUID is the same as GUID
// when represented as a string.
typedDocument.setId(UUID.randomUUID().toString());
}
String path = Utils.joinPath(documentCollectionLink, Paths.DOCUMENTS_PATH_SEGMENT);
Map<String, String> requestHeaders = this.getRequestHeaders(options);
RxDocumentServiceRequest request = RxDocumentServiceRequest.create(operationType, ResourceType.Document, path,
typedDocument, requestHeaders);
// NOTE: if the collection is not currently cached this will be a
// blocking call
DocumentCollection collection = this.collectionCache.resolveCollection(request);
this.addPartitionKeyInformation(request, typedDocument, options, collection);
return request;
}
示例4: convertDocumentToAddressCorrectly
import com.microsoft.azure.documentdb.Document; //导入方法依赖的package包/类
@Test
public void convertDocumentToAddressCorrectly() {
final Document document = new Document();
document.setId("testId");
document.set("city", "testCity");
document.set("street", "testStreet");
final Address address = dbConverter.read(Address.class, document);
assertThat(address.getPostalCode()).isEqualTo("testId");
assertThat(address.getCity()).isEqualTo("testCity");
assertThat(address.getStreet()).isEqualTo("testStreet");
}