本文整理汇总了Java中com.marklogic.client.impl.DocumentWriteOperationImpl类的典型用法代码示例。如果您正苦于以下问题:Java DocumentWriteOperationImpl类的具体用法?Java DocumentWriteOperationImpl怎么用?Java DocumentWriteOperationImpl使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DocumentWriteOperationImpl类属于com.marklogic.client.impl包,在下文中一共展示了DocumentWriteOperationImpl类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: write
import com.marklogic.client.impl.DocumentWriteOperationImpl; //导入依赖的package包/类
@Override
public void write(List<? extends DocumentWriteOperation> items) throws Exception {
if (isDataMovementSdk) {
for (DocumentWriteOperation item : items) {
batcher.add(uriTransformer.transform(item.getUri()), item.getMetadata(), item.getContent());
}
} else {
List<DocumentWriteOperation> newItems = new ArrayList<>();
for (DocumentWriteOperation op : items) {
String newUri = uriTransformer.transform(op.getUri());
newItems.add(
new DocumentWriteOperationImpl(
DocumentWriteOperation.OperationType.DOCUMENT_WRITE,
newUri,
op.getMetadata(),
op.getContent()));
}
batchWriter.write(newItems);
}
}
示例2: getDocuments
import com.marklogic.client.impl.DocumentWriteOperationImpl; //导入依赖的package包/类
public List<DocumentWriteOperation> getDocuments() {
List<DocumentWriteOperation> handles = new ArrayList<DocumentWriteOperation>();
DocumentWriteOperation handle = new DocumentWriteOperationImpl(
DocumentWriteOperation.OperationType.DOCUMENT_WRITE,
"abc.xml",
new DocumentMetadataHandle().withCollections("raw"),
new StringHandle("<hello />"));
handles.add(handle);
DocumentWriteOperation handle2 = new DocumentWriteOperationImpl(
DocumentWriteOperation.OperationType.DOCUMENT_WRITE,
"abc2.xml",
new DocumentMetadataHandle().withCollections("raw"),
new StringHandle("<hello2 />"));
handles.add(handle2);
return handles;
}
示例3: getBadDocument
import com.marklogic.client.impl.DocumentWriteOperationImpl; //导入依赖的package包/类
public List<DocumentWriteOperation> getBadDocument() {
List<DocumentWriteOperation> handles = new ArrayList<DocumentWriteOperation>();
DocumentWriteOperation handle2 = new DocumentWriteOperationImpl(
DocumentWriteOperation.OperationType.DOCUMENT_WRITE,
"good.xml",
new DocumentMetadataHandle().withCollections("raw"),
new StringHandle("<hello />"));
handles.add(handle2);
DocumentWriteOperation handle = new DocumentWriteOperationImpl(
DocumentWriteOperation.OperationType.DOCUMENT_WRITE,
"fail.xml",
new DocumentMetadataHandle().withCollections("raw"),
new StringHandle("<hello #&3; />"));
handles.add(handle);
return handles;
}
示例4: writeDocumentWithTransformNoParametersTest
import com.marklogic.client.impl.DocumentWriteOperationImpl; //导入依赖的package包/类
@Test
public void writeDocumentWithTransformNoParametersTest() {
DocumentWriteOperation writeOp = new DocumentWriteOperationImpl(DocumentWriteOperation.OperationType.DOCUMENT_WRITE,
"hello.xml", new DocumentMetadataHandle(), new StringHandle(xml));
List<DocumentWriteOperation> writeOps = new ArrayList<DocumentWriteOperation>();
writeOps.add(writeOp);
try {
itemWriter = new MarkLogicItemWriter(client, new ServerTransform(transformName));
write(writeOps);
} catch (Exception e) {
e.printStackTrace();
}
StringHandle handle = docMgr.read("hello.xml", new StringHandle());
Fragment frag = new Fragment(handle.toString());
frag.assertElementExists("//hello[text() = 'world']");
frag.assertElementExists("//transform");
}
示例5: writeDocumentWithTransformWithParametersTest
import com.marklogic.client.impl.DocumentWriteOperationImpl; //导入依赖的package包/类
@Test
public void writeDocumentWithTransformWithParametersTest() {
DocumentWriteOperation writeOp = new DocumentWriteOperationImpl(DocumentWriteOperation.OperationType.DOCUMENT_WRITE,
"hello.xml", new DocumentMetadataHandle(), new StringHandle(xml));
List<DocumentWriteOperation> writeOps = new ArrayList<DocumentWriteOperation>();
writeOps.add(writeOp);
try {
ServerTransform serverTransform = new ServerTransform(transformName);
serverTransform.addParameter("monster", "grover");
serverTransform.addParameter("trash-can", "oscar");
itemWriter = new MarkLogicItemWriter(client, serverTransform, Format.XML);
write(writeOps);
} catch (Exception e) {
e.printStackTrace();
}
StringHandle handle = docMgr.read("hello.xml", new StringHandle());
Fragment frag = new Fragment(handle.toString());
frag.assertElementExists("//transform");
frag.assertElementExists("//monster[text() = 'grover']");
frag.assertElementExists("//trash-can[text() = 'oscar']");
}
示例6: failureTest
import com.marklogic.client.impl.DocumentWriteOperationImpl; //导入依赖的package包/类
@Test
public void failureTest() {
RestBatchWriter writer = new RestBatchWriter(newClient("Documents"));
TestWriteListener testWriteListener = new TestWriteListener();
writer.setWriteListener(testWriteListener);
DocumentWriteOperation op = new DocumentWriteOperationImpl(DocumentWriteOperation.OperationType.DOCUMENT_WRITE,
"/test.xml", null, new StringHandle("<hello>world</hello>asdf"));
writer.initialize();
writer.write(Arrays.asList(op));
writer.waitForCompletion();
Throwable caughtError = testWriteListener.caughtError;
assertNotNull("An error should have been thrown due to the invalid XML", caughtError);
assertTrue(caughtError instanceof FailedRequestException);
}
示例7: process
import com.marklogic.client.impl.DocumentWriteOperationImpl; //导入依赖的package包/类
@Override
public DocumentWriteOperation process(Map<String, Object> item) throws Exception {
String tableName = null;
if (item.containsKey(tableNameKey)) {
tableName = (String)item.get(tableNameKey);
item.remove(tableNameKey);
}
String thisRootLocalName = tableName != null ? tableName : rootLocalName;
String content = columnMapSerializer.serializeColumnMap(item, thisRootLocalName);
String uuid = UUID.randomUUID().toString();
String uri = "/" + thisRootLocalName + "/" + uuid + uriSuffix;
DocumentMetadataHandle metadata = new DocumentMetadataHandle();
if (collections != null) {
metadata.withCollections(collections);
}
if (tableName != null) {
metadata.withCollections(tableName);
}
if (permissions != null) {
for (int i = 0; i < permissions.length; i += 2) {
String role = permissions[i];
DocumentMetadataHandle.Capability c = DocumentMetadataHandle.Capability.valueOf(permissions[i + 1].toUpperCase());
metadata.withPermission(role, c);
}
}
return new DocumentWriteOperationImpl(DocumentWriteOperation.OperationType.DOCUMENT_WRITE,
uri, metadata, new StringHandle(content));
}
示例8: process
import com.marklogic.client.impl.DocumentWriteOperationImpl; //导入依赖的package包/类
public DocumentWriteOperation process(T item) throws Exception {
return new DocumentWriteOperationImpl(
DocumentWriteOperation.OperationType.DOCUMENT_WRITE,
uriGenerator.generateUri(item),
getDocumentMetadata(item),
getContentHandle(item));
}
开发者ID:marklogic-community,项目名称:marklogic-spring-batch,代码行数:8,代码来源:AbstractMarkLogicItemProcessor.java
示例9: conflictingUpdateTest
import com.marklogic.client.impl.DocumentWriteOperationImpl; //导入依赖的package包/类
@Test
public void conflictingUpdateTest() throws Exception {
List<DocumentWriteOperation> handles = getDocuments();
//Add a document with a replica uri
DocumentWriteOperation handle = new DocumentWriteOperationImpl(
DocumentWriteOperation.OperationType.DOCUMENT_WRITE,
"abc.xml",
new DocumentMetadataHandle().withCollections("raw"),
new StringHandle("<hello />"));
handles.add(handle);
itemWriter = new MarkLogicItemWriter(client);
write(handles);
clientTestHelper.assertCollectionSize("Expecting zero items in raw collection", "raw", 0);
}
示例10: getDocument
import com.marklogic.client.impl.DocumentWriteOperationImpl; //导入依赖的package包/类
private DocumentWriteOperation getDocument() {
DocumentWriteOperation handle = new DocumentWriteOperationImpl(
DocumentWriteOperation.OperationType.DOCUMENT_WRITE,
UUID.randomUUID().toString(),
new DocumentMetadataHandle().withCollections("raw"),
new StringHandle("<hello />"));
return handle;
}
示例11: writeDocumentWithTransform
import com.marklogic.client.impl.DocumentWriteOperationImpl; //导入依赖的package包/类
@Test
public void writeDocumentWithTransform() throws IOException {
DatabaseClient client = newClient("Documents");
Resource transform = new FileSystemResource(Paths.get("src", "test", "resources", "transform", "simple.xqy").toString());
TransformExtensionsManager transMgr = client.newServerConfigManager().newTransformExtensionsManager();
FileHandle fileHandle = new FileHandle(transform.getFile());
fileHandle.setFormat(Format.XML);
transMgr.writeXQueryTransform("simple", fileHandle);
DocumentWriteOperation op = new DocumentWriteOperationImpl(DocumentWriteOperation.OperationType.DOCUMENT_WRITE,
"/test.xml", null, new StringHandle("<hello>world</hello>"));
client = newClient("Documents");
RestBatchWriter writer = new RestBatchWriter(client);
writer.setServerTransform(new ServerTransform("simple"));
writer.setContentFormat(Format.XML);
writer.initialize();
writer.write(Arrays.asList(op));
writer.waitForCompletion();
client = newClient("Documents");
XMLDocumentManager docMgr = client.newXMLDocumentManager();
DocumentPage page = docMgr.read("/test.xml");
StringHandle handle = page.nextContent(new StringHandle());
assertTrue(handle.toString().contains("<transform/>"));
}
示例12: test
import com.marklogic.client.impl.DocumentWriteOperationImpl; //导入依赖的package包/类
@Test
public void test() throws Exception {
String xml = "<hello>World</hello>";
String uri = "/test.xml";
DocumentMetadataHandle metadata = new DocumentMetadataHandle();
metadata.withCollections("collection1", "collection2");
metadata.withPermission("role1", DocumentMetadataHandle.Capability.EXECUTE, DocumentMetadataHandle.Capability.READ);
metadata.withPermission("role2", DocumentMetadataHandle.Capability.UPDATE);
metadata.withPermission("role3", DocumentMetadataHandle.Capability.INSERT);
metadata.setFormat(Format.XML);
DocumentWriteOperation operation = new DocumentWriteOperationImpl(
DocumentWriteOperation.OperationType.DOCUMENT_WRITE, uri, metadata, new StringHandle(xml));
Content content = sut.adapt(operation);
assertEquals(uri, content.getUri());
String xccXml = new String(FileCopyUtils.copyToByteArray(content.openDataStream()));
assertEquals(xml, xccXml);
ContentCreateOptions options = content.getCreateOptions();
String[] collections = options.getCollections();
assertEquals("collection1", collections[0]);
assertEquals("collection2", collections[1]);
// Permissions are in a set, and thus not ordered, so our assertions a little funky here
ContentPermission[] permissions = options.getPermissions();
assertEquals(4, permissions.length);
for (ContentPermission perm : permissions) {
String role = perm.getRole();
ContentCapability capability = perm.getCapability();
if ("role1".equals(role)) {
assertTrue(ContentCapability.EXECUTE.equals(capability) || ContentCapability.READ.equals(capability));
} else if ("role2".equals(role)) {
assertEquals(ContentCapability.UPDATE, capability);
} else if ("role3".equals(role)) {
assertEquals(ContentCapability.INSERT, capability);
} else {
fail("Unexpected role: " + role);
}
}
}
开发者ID:marklogic-community,项目名称:ml-javaclient-util,代码行数:44,代码来源:DefaultDocumentWriteOperationAdapterTest.java