本文整理汇总了Java中com.arangodb.entity.DocumentDeleteEntity类的典型用法代码示例。如果您正苦于以下问题:Java DocumentDeleteEntity类的具体用法?Java DocumentDeleteEntity怎么用?Java DocumentDeleteEntity使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DocumentDeleteEntity类属于com.arangodb.entity包,在下文中一共展示了DocumentDeleteEntity类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: deleteDocumentReturnOld
import com.arangodb.entity.DocumentDeleteEntity; //导入依赖的package包/类
@Test
public void deleteDocumentReturnOld() throws InterruptedException, ExecutionException {
final BaseDocument doc = new BaseDocument();
doc.addAttribute("a", "test");
final DocumentCreateEntity<BaseDocument> createResult = db.collection(COLLECTION_NAME).insertDocument(doc, null)
.get();
final DocumentDeleteOptions options = new DocumentDeleteOptions().returnOld(true);
final CompletableFuture<DocumentDeleteEntity<BaseDocument>> f = db.collection(COLLECTION_NAME)
.deleteDocument(createResult.getKey(), BaseDocument.class, options);
assertThat(f, is(notNullValue()));
f.whenComplete((deleteResult, ex) -> {
assertThat(deleteResult.getOld(), is(notNullValue()));
assertThat(deleteResult.getOld(), instanceOf(BaseDocument.class));
assertThat(deleteResult.getOld().getAttribute("a"), is(notNullValue()));
assertThat(String.valueOf(deleteResult.getOld().getAttribute("a")), is("test"));
});
f.get();
}
示例2: deleteDocumentsByKeyOne
import com.arangodb.entity.DocumentDeleteEntity; //导入依赖的package包/类
@Test
public void deleteDocumentsByKeyOne() throws InterruptedException, ExecutionException {
final Collection<BaseDocument> values = new ArrayList<>();
{
final BaseDocument e = new BaseDocument();
e.setKey("1");
values.add(e);
}
db.collection(COLLECTION_NAME).insertDocuments(values, null).get();
final Collection<String> keys = new ArrayList<>();
keys.add("1");
final CompletableFuture<MultiDocumentEntity<DocumentDeleteEntity<Object>>> f = db.collection(COLLECTION_NAME)
.deleteDocuments(keys, null, null);
assertThat(f, is(notNullValue()));
f.whenComplete((deleteResult, ex) -> {
assertThat(deleteResult, is(notNullValue()));
assertThat(deleteResult.getDocuments().size(), is(1));
for (final DocumentDeleteEntity<Object> i : deleteResult.getDocuments()) {
assertThat(i.getKey(), is("1"));
}
assertThat(deleteResult.getErrors().size(), is(0));
});
f.get();
}
示例3: deleteDocumentsByDocumentOne
import com.arangodb.entity.DocumentDeleteEntity; //导入依赖的package包/类
@Test
public void deleteDocumentsByDocumentOne() throws InterruptedException, ExecutionException {
final Collection<BaseDocument> values = new ArrayList<>();
{
final BaseDocument e = new BaseDocument();
e.setKey("1");
values.add(e);
}
db.collection(COLLECTION_NAME).insertDocuments(values, null).get();
final CompletableFuture<MultiDocumentEntity<DocumentDeleteEntity<Object>>> f = db.collection(COLLECTION_NAME)
.deleteDocuments(values, null, null);
assertThat(f, is(notNullValue()));
f.whenComplete((deleteResult, ex) -> {
assertThat(deleteResult, is(notNullValue()));
assertThat(deleteResult.getDocuments().size(), is(1));
for (final DocumentDeleteEntity<Object> i : deleteResult.getDocuments()) {
assertThat(i.getKey(), is("1"));
}
assertThat(deleteResult.getErrors().size(), is(0));
});
f.get();
}
示例4: deleteDocumentsByKeyNotExisting
import com.arangodb.entity.DocumentDeleteEntity; //导入依赖的package包/类
@Test
public void deleteDocumentsByKeyNotExisting() throws InterruptedException, ExecutionException {
final Collection<BaseDocument> values = new ArrayList<>();
db.collection(COLLECTION_NAME).insertDocuments(values, null).get();
final Collection<String> keys = new ArrayList<>();
keys.add("1");
keys.add("2");
final CompletableFuture<MultiDocumentEntity<DocumentDeleteEntity<Object>>> f = db.collection(COLLECTION_NAME)
.deleteDocuments(keys, null, null);
assertThat(f, is(notNullValue()));
f.whenComplete((deleteResult, ex) -> {
assertThat(deleteResult, is(notNullValue()));
assertThat(deleteResult.getDocuments().size(), is(0));
assertThat(deleteResult.getErrors().size(), is(2));
});
f.get();
}
示例5: deleteDocumentResponseDeserializer
import com.arangodb.entity.DocumentDeleteEntity; //导入依赖的package包/类
protected <T> ResponseDeserializer<DocumentDeleteEntity<T>> deleteDocumentResponseDeserializer(
final Class<T> type) {
return new ResponseDeserializer<DocumentDeleteEntity<T>>() {
@SuppressWarnings("unchecked")
@Override
public DocumentDeleteEntity<T> deserialize(final Response response) throws VPackException {
final VPackSlice body = response.getBody();
final DocumentDeleteEntity<T> doc = util().deserialize(body, DocumentDeleteEntity.class);
final VPackSlice oldDoc = body.get(ArangoDBConstants.OLD);
if (oldDoc.isObject()) {
doc.setOld((T) util().deserialize(oldDoc, type));
}
return doc;
}
};
}
示例6: deleteDocumentsByKeyOne
import com.arangodb.entity.DocumentDeleteEntity; //导入依赖的package包/类
@Test
public void deleteDocumentsByKeyOne() {
final Collection<BaseDocument> values = new ArrayList<BaseDocument>();
{
final BaseDocument e = new BaseDocument();
e.setKey("1");
values.add(e);
}
db.collection(COLLECTION_NAME).insertDocuments(values, null);
final Collection<String> keys = new ArrayList<String>();
keys.add("1");
final MultiDocumentEntity<DocumentDeleteEntity<Object>> deleteResult = db.collection(COLLECTION_NAME)
.deleteDocuments(keys, null, null);
assertThat(deleteResult, is(notNullValue()));
assertThat(deleteResult.getDocuments().size(), is(1));
for (final DocumentDeleteEntity<Object> i : deleteResult.getDocuments()) {
assertThat(i.getKey(), is("1"));
}
assertThat(deleteResult.getErrors().size(), is(0));
}
示例7: deleteDocumentsByDocumentOne
import com.arangodb.entity.DocumentDeleteEntity; //导入依赖的package包/类
@Test
public void deleteDocumentsByDocumentOne() {
final Collection<BaseDocument> values = new ArrayList<BaseDocument>();
{
final BaseDocument e = new BaseDocument();
e.setKey("1");
values.add(e);
}
db.collection(COLLECTION_NAME).insertDocuments(values, null);
final MultiDocumentEntity<DocumentDeleteEntity<Object>> deleteResult = db.collection(COLLECTION_NAME)
.deleteDocuments(values, null, null);
assertThat(deleteResult, is(notNullValue()));
assertThat(deleteResult.getDocuments().size(), is(1));
for (final DocumentDeleteEntity<Object> i : deleteResult.getDocuments()) {
assertThat(i.getKey(), is("1"));
}
assertThat(deleteResult.getErrors().size(), is(0));
}
示例8: delete
import com.arangodb.entity.DocumentDeleteEntity; //导入依赖的package包/类
public int delete(String key) {
if (key == null) {
return 0;
}
DocumentDeleteEntity deleteEntity = collection()
.deleteDocument(key);
return 1;
}
示例9: deleteDocumentsEmpty
import com.arangodb.entity.DocumentDeleteEntity; //导入依赖的package包/类
@Test
public void deleteDocumentsEmpty() throws InterruptedException, ExecutionException {
final Collection<BaseDocument> values = new ArrayList<>();
db.collection(COLLECTION_NAME).insertDocuments(values, null).get();
final Collection<String> keys = new ArrayList<>();
final CompletableFuture<MultiDocumentEntity<DocumentDeleteEntity<Object>>> f = db.collection(COLLECTION_NAME)
.deleteDocuments(keys, null, null);
assertThat(f, is(notNullValue()));
f.whenComplete((deleteResult, ex) -> {
assertThat(deleteResult, is(notNullValue()));
assertThat(deleteResult.getDocuments().size(), is(0));
assertThat(deleteResult.getErrors().size(), is(0));
});
f.get();
}
示例10: deleteDocumentsResponseDeserializer
import com.arangodb.entity.DocumentDeleteEntity; //导入依赖的package包/类
protected <T> ResponseDeserializer<MultiDocumentEntity<DocumentDeleteEntity<T>>> deleteDocumentsResponseDeserializer(
final Class<T> type) {
return new ResponseDeserializer<MultiDocumentEntity<DocumentDeleteEntity<T>>>() {
@SuppressWarnings("unchecked")
@Override
public MultiDocumentEntity<DocumentDeleteEntity<T>> deserialize(final Response response)
throws VPackException {
final MultiDocumentEntity<DocumentDeleteEntity<T>> multiDocument = new MultiDocumentEntity<DocumentDeleteEntity<T>>();
final Collection<DocumentDeleteEntity<T>> docs = new ArrayList<DocumentDeleteEntity<T>>();
final Collection<ErrorEntity> errors = new ArrayList<ErrorEntity>();
final Collection<Object> documentsAndErrors = new ArrayList<Object>();
final VPackSlice body = response.getBody();
for (final Iterator<VPackSlice> iterator = body.arrayIterator(); iterator.hasNext();) {
final VPackSlice next = iterator.next();
if (next.get(ArangoDBConstants.ERROR).isTrue()) {
final ErrorEntity error = (ErrorEntity) util().deserialize(next, ErrorEntity.class);
errors.add(error);
documentsAndErrors.add(error);
} else {
final DocumentDeleteEntity<T> doc = util().deserialize(next, DocumentDeleteEntity.class);
final VPackSlice oldDoc = next.get(ArangoDBConstants.OLD);
if (oldDoc.isObject()) {
doc.setOld((T) util().deserialize(oldDoc, type));
}
docs.add(doc);
documentsAndErrors.add(doc);
}
}
multiDocument.setDocuments(docs);
multiDocument.setErrors(errors);
multiDocument.setDocumentsAndErrors(documentsAndErrors);
return multiDocument;
}
};
}
示例11: deleteDocumentReturnOld
import com.arangodb.entity.DocumentDeleteEntity; //导入依赖的package包/类
@Test
public void deleteDocumentReturnOld() {
final BaseDocument doc = new BaseDocument();
doc.addAttribute("a", "test");
final DocumentCreateEntity<BaseDocument> createResult = db.collection(COLLECTION_NAME).insertDocument(doc,
null);
final DocumentDeleteOptions options = new DocumentDeleteOptions().returnOld(true);
final DocumentDeleteEntity<BaseDocument> deleteResult = db.collection(COLLECTION_NAME)
.deleteDocument(createResult.getKey(), BaseDocument.class, options);
assertThat(deleteResult.getOld(), is(notNullValue()));
assertThat(deleteResult.getOld(), instanceOf(BaseDocument.class));
assertThat(deleteResult.getOld().getAttribute("a"), is(notNullValue()));
assertThat(String.valueOf(deleteResult.getOld().getAttribute("a")), is("test"));
}
示例12: deleteDocumentsEmpty
import com.arangodb.entity.DocumentDeleteEntity; //导入依赖的package包/类
@Test
public void deleteDocumentsEmpty() {
final Collection<BaseDocument> values = new ArrayList<BaseDocument>();
db.collection(COLLECTION_NAME).insertDocuments(values, null);
final Collection<String> keys = new ArrayList<String>();
final MultiDocumentEntity<DocumentDeleteEntity<Object>> deleteResult = db.collection(COLLECTION_NAME)
.deleteDocuments(keys, null, null);
assertThat(deleteResult, is(notNullValue()));
assertThat(deleteResult.getDocuments().size(), is(0));
assertThat(deleteResult.getErrors().size(), is(0));
}
示例13: deleteDocumentsByKeyNotExisting
import com.arangodb.entity.DocumentDeleteEntity; //导入依赖的package包/类
@Test
public void deleteDocumentsByKeyNotExisting() {
final Collection<BaseDocument> values = new ArrayList<BaseDocument>();
db.collection(COLLECTION_NAME).insertDocuments(values, null);
final Collection<String> keys = new ArrayList<String>();
keys.add("1");
keys.add("2");
final MultiDocumentEntity<DocumentDeleteEntity<Object>> deleteResult = db.collection(COLLECTION_NAME)
.deleteDocuments(keys, null, null);
assertThat(deleteResult, is(notNullValue()));
assertThat(deleteResult.getDocuments().size(), is(0));
assertThat(deleteResult.getErrors().size(), is(2));
}
示例14: deleteDocument
import com.arangodb.entity.DocumentDeleteEntity; //导入依赖的package包/类
/**
* Removes a document
*
* @see <a href="https://docs.arangodb.com/current/HTTP/Document/WorkingWithDocuments.html#removes-a-document">API
* Documentation</a>
* @param key
* The key of the document
* @param type
* The type of the document (POJO class, VPackSlice or String for Json). Only necessary if
* options.returnOld is set to true, otherwise can be null.
* @param options
* Additional options, can be null
* @return information about the document
*/
public <T> CompletableFuture<DocumentDeleteEntity<T>> deleteDocument(
final String key,
final Class<T> type,
final DocumentDeleteOptions options) {
return executor.execute(deleteDocumentRequest(key, options), deleteDocumentResponseDeserializer(type));
}
示例15: deleteDocuments
import com.arangodb.entity.DocumentDeleteEntity; //导入依赖的package包/类
/**
* Removes multiple document
*
* @see <a href=
* "https://docs.arangodb.com/current/HTTP/Document/WorkingWithDocuments.html#removes-multiple-documents">API
* Documentation</a>
* @param values
* The keys of the documents or the documents themselves
* @param type
* The type of the documents (POJO class, VPackSlice or String for Json). Only necessary if
* options.returnOld is set to true, otherwise can be null.
* @param options
* Additional options, can be null
* @return information about the documents
*/
public <T> CompletableFuture<MultiDocumentEntity<DocumentDeleteEntity<T>>> deleteDocuments(
final Collection<?> values,
final Class<T> type,
final DocumentDeleteOptions options) {
return executor.execute(deleteDocumentsRequest(values, options), deleteDocumentsResponseDeserializer(type));
}