本文整理汇总了Java中com.marklogic.client.io.DocumentMetadataHandle类的典型用法代码示例。如果您正苦于以下问题:Java DocumentMetadataHandle类的具体用法?Java DocumentMetadataHandle怎么用?Java DocumentMetadataHandle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DocumentMetadataHandle类属于com.marklogic.client.io包,在下文中一共展示了DocumentMetadataHandle类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: write_single_json_document_with_metas
import com.marklogic.client.io.DocumentMetadataHandle; //导入依赖的package包/类
@Test
public void write_single_json_document_with_metas() throws Exception {
Document document = getDocument("json/doc3_uri.json");
mlClient.save(document.toJson(), onSuccess(ids -> {
String id = ids.getString(0);
assertNotNull(id);
retrieveMetadatas(id, databaseClient.newJSONDocumentManager(), onSuccess(metadataHandle -> {
assertThat(metadataHandle.getCollections(), is(new HashSet(Arrays.asList("coll/c1", "coll/c2"))));
assertEquals(2, metadataHandle.getQuality());
assertThat(metadataHandle.getProperties().keySet(),
is(new HashSet(Arrays.asList(new QName("aProp1"), new QName("aProp2")))));
assertThat(new HashSet(metadataHandle.getProperties().values()),
is(new HashSet(Arrays.asList("aValue1", "aValue2"))));
assertTrue(metadataHandle.getPermissions().containsKey("app-user"));
assertThat(metadataHandle.getPermissions().get("app-user"), is(new HashSet(Collections.singletonList(
DocumentMetadataHandle.Capability.UPDATE))));
testComplete();
}));
}));
await();
}
开发者ID:etourdot,项目名称:vertx-marklogic,代码行数:22,代码来源:MarklogicDocumentWriteTest.java
示例2: testCustomSchemasPathWithCustomFileFilter
import com.marklogic.client.io.DocumentMetadataHandle; //导入依赖的package包/类
@Test
public void testCustomSchemasPathWithCustomFileFilter() {
initializeAppDeployer(new DeploySchemasDatabaseCommand(), new DeployTriggersDatabaseCommand(),
new DeployContentDatabasesCommand(1), newCommand());
appConfig.setSchemasPath("src/test/resources/schemas-marklogic9");
appConfig.setSchemasFileFilter(new CustomFileFilter());
appDeployer.deploy(appConfig);
DatabaseClient client = appConfig.newSchemasDatabaseClient();
GenericDocumentManager docMgr = client.newDocumentManager();
assertNotNull("TDEXML document loaded", docMgr.exists("/x.tdex").getUri());
assertNotNull("TDEJSON document loaded", docMgr.exists("/x.tdej").getUri());
assertNull(docMgr.exists("/to-be-ignored/test.xml"));
assertNull(docMgr.exists("to-be-ignored/test.xml"));
for (String uri : new String[]{"/x.tdex", "/x.tdej"}) {
DocumentMetadataHandle h = docMgr.readMetadata(uri, new DocumentMetadataHandle());
assertEquals("Files ending in tdex and tdej go into a special collection", "http://marklogic.com/xdmp/tde",
h.getCollections().iterator().next());
}
}
开发者ID:marklogic-community,项目名称:ml-app-deployer,代码行数:25,代码来源:LoadSchemasTest.java
示例3: getDocuments
import com.marklogic.client.io.DocumentMetadataHandle; //导入依赖的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;
}
开发者ID:marklogic-community,项目名称:marklogic-spring-batch,代码行数:20,代码来源:MarkLogicItemWriterTest.java
示例4: getBadDocument
import com.marklogic.client.io.DocumentMetadataHandle; //导入依赖的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;
}
开发者ID:marklogic-community,项目名称:marklogic-spring-batch,代码行数:20,代码来源:MarkLogicItemWriterTest.java
示例5: writeDocumentWithTransformNoParametersTest
import com.marklogic.client.io.DocumentMetadataHandle; //导入依赖的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");
}
开发者ID:marklogic-community,项目名称:marklogic-spring-batch,代码行数:20,代码来源:MarkLogicItemWriterTest.java
示例6: writeDocumentWithTransformWithParametersTest
import com.marklogic.client.io.DocumentMetadataHandle; //导入依赖的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']");
}
开发者ID:marklogic-community,项目名称:marklogic-spring-batch,代码行数:22,代码来源:MarkLogicItemWriterTest.java
示例7: setup
import com.marklogic.client.io.DocumentMetadataHandle; //导入依赖的package包/类
@Before
public void setup() {
DatabaseClientFactory.SecurityContext securityContext =
new DatabaseClientFactory.DigestAuthContext(databaseClientConfig.getUsername(),
databaseClientConfig.getPassword());
client = DatabaseClientFactory.newClient(databaseClientConfig.getHost(),
databaseClientConfig.getPort(), securityContext);
helper = new ClientTestHelper();
helper.setDatabaseClientProvider(getClientProvider());
XMLDocumentManager docMgr = client.newXMLDocumentManager();
StringHandle xml1 = new StringHandle("<hello />");
DocumentMetadataHandle metadata = new DocumentMetadataHandle();
metadata.withCollections("a");
DocumentMetadataHandle metadata2 = new DocumentMetadataHandle();
metadata2.withCollections("b");
for (int i = 0; i < 600; i++) {
DocumentMetadataHandle h = (i % 2 == 0) ? metadata : metadata2;
docMgr.write("hello" + i + ".xml", h, xml1);
}
helper.assertCollectionSize("a = 300", "a", 300);
helper.assertCollectionSize("b = 300", "b", 300);
}
开发者ID:marklogic-community,项目名称:marklogic-spring-batch,代码行数:27,代码来源:ValuesItemReaderTest.java
示例8: test
import com.marklogic.client.io.DocumentMetadataHandle; //导入依赖的package包/类
@Test
public void test() {
DefaultSchemasLoader loader = new DefaultSchemasLoader(client);
List<DocumentFile> files = loader.loadSchemas(Paths.get("src", "test", "resources", "rulesets", "collection-test").toString());
assertEquals(2, files.size());
ClientHelper helper = new ClientHelper(client);
List<String> collections = helper.getCollections("/ruleset1.xml");
assertEquals(1, collections.size());
assertTrue(collections.contains("ruleset-abc"));
collections = helper.getCollections("/ruleset2.json");
assertEquals(2, collections.size());
assertTrue(collections.contains("ruleset-abc"));
assertTrue(collections.contains("ruleset-xyz"));
DocumentMetadataHandle.DocumentPermissions perms = helper.getMetadata("/ruleset1.xml").getPermissions();
assertEquals("Should have the two default perms plus the two custom ones", 4, perms.size());
assertEquals(DocumentMetadataHandle.Capability.READ, perms.get("rest-reader").iterator().next());
assertEquals(DocumentMetadataHandle.Capability.UPDATE, perms.get("rest-writer").iterator().next());
assertEquals(DocumentMetadataHandle.Capability.READ, perms.get("rest-admin").iterator().next());
assertEquals(DocumentMetadataHandle.Capability.UPDATE, perms.get("manage-admin").iterator().next());
}
开发者ID:marklogic-community,项目名称:ml-javaclient-util,代码行数:25,代码来源:LoadRulesetsTest.java
示例9: getPermissionNode
import com.marklogic.client.io.DocumentMetadataHandle; //导入依赖的package包/类
public static ObjectNode getPermissionNode(String roleName, DocumentMetadataHandle.Capability... cap){
ObjectMapper mapper= new ObjectMapper();
ObjectNode mNode = mapper.createObjectNode();
ArrayNode aNode = mapper.createArrayNode();
for(DocumentMetadataHandle.Capability c : cap){
ObjectNode roleNode =mapper.createObjectNode();
roleNode.put("role-name",roleName);
roleNode.put("capability", c.toString().toLowerCase());
aNode.add(roleNode);
}
mNode.withArray("permission").addAll(aNode);
return mNode;
}
开发者ID:marklogic,项目名称:marklogic-rdf4j,代码行数:15,代码来源:ConnectedRESTQA.java
示例10: process
import com.marklogic.client.io.DocumentMetadataHandle; //导入依赖的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));
}
开发者ID:rjrudin,项目名称:ml-migration-starter,代码行数:34,代码来源:ColumnMapProcessor.java
示例11: retrieveMetadatas
import com.marklogic.client.io.DocumentMetadataHandle; //导入依赖的package包/类
private void retrieveMetadatas(String id, DocumentManager documentManager, Handler<AsyncResult<DocumentMetadataHandle>> resultHandler) {
vertx.executeBlocking(future -> {
DocumentMetadataHandle metadataHandle = new DocumentMetadataHandle();
documentManager.readMetadata(id, metadataHandle);
future.complete(metadataHandle);
}, resultHandler);
}
开发者ID:etourdot,项目名称:vertx-marklogic,代码行数:8,代码来源:MarklogicDocumentWriteTest.java
示例12: buildMetadata
import com.marklogic.client.io.DocumentMetadataHandle; //导入依赖的package包/类
protected DocumentMetadataHandle buildMetadata() {
DocumentMetadataHandle h = new DocumentMetadataHandle();
h = h.withCollections(collections);
if (permissions != null) {
String[] array = permissions.split(",");
for (int i = 0; i < array.length; i += 2) {
h.getPermissions().add(array[i], Capability.valueOf(array[i + 1].toUpperCase()));
}
}
return h;
}
开发者ID:marklogic-community,项目名称:marklogic-spring-batch,代码行数:12,代码来源:AbstractDocumentWriter.java
示例13: getDocumentMetadata
import com.marklogic.client.io.DocumentMetadataHandle; //导入依赖的package包/类
protected DocumentMetadataHandle getDocumentMetadata(T item) {
DocumentMetadataHandle metadata = new DocumentMetadataHandle();
if (collections != null) {
metadata.withCollections(collections);
}
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 metadata;
}
开发者ID:marklogic-community,项目名称:marklogic-spring-batch,代码行数:15,代码来源:AbstractMarkLogicItemProcessor.java
示例14: saveStepExecution
import com.marklogic.client.io.DocumentMetadataHandle; //导入依赖的package包/类
@Override
public void saveStepExecution(StepExecution stepExecution) {
Assert.isTrue(stepExecution.getId() == null);
Assert.isTrue(stepExecution.getVersion() == null);
Assert.notNull(stepExecution.getJobExecutionId(), "JobExecution must be saved already.");
validateStepExecution(stepExecution);
stepExecution.setId(ThreadLocalRandom.current().nextLong(Long.MAX_VALUE));
AdaptedStepExecution adaptedStepExecution = null;
try {
adaptedStepExecution = adapter.marshal(stepExecution);
} catch (Exception ex) {
throw new RuntimeException(ex);
}
DocumentMetadataHandle metadata = new DocumentMetadataHandle();
metadata.withCollections(properties.getCollection(), properties.getStepExecutionCollection());
JAXBHandle<AdaptedStepExecution> jaxbHandle = new JAXBHandle<AdaptedStepExecution>(jaxbContext());
jaxbHandle.set(adaptedStepExecution);
XMLDocumentManager docMgr = databaseClient.newXMLDocumentManager();
String uri = getUri(stepExecution);
docMgr.write(uri, metadata, jaxbHandle);
DocumentDescriptor desc = docMgr.exists(uri);
stepExecution.setVersion((int) desc.getVersion());
}
开发者ID:marklogic-community,项目名称:marklogic-spring-batch,代码行数:32,代码来源:MarkLogicStepExecutionDao.java
示例15: updateStepExecution
import com.marklogic.client.io.DocumentMetadataHandle; //导入依赖的package包/类
@Override
public void updateStepExecution(StepExecution stepExecution) {
validateStepExecution(stepExecution);
Assert.notNull(stepExecution.getId(), "StepExecution Id cannot be null. StepExecution must saved"
+ " before it can be updated.");
Assert.notNull(stepExecution.getJobExecutionId(), "JobExecution must be saved already.");
synchronized (stepExecution) {
XMLDocumentManager docMgr = databaseClient.newXMLDocumentManager();
String uri = getUri(stepExecution);
DocumentMetadataHandle metadata = new DocumentMetadataHandle();
metadata.withCollections(properties.getCollection(), properties.getStepExecutionCollection());
AdaptedStepExecution ase = null;
try {
ase = adapter.marshal(stepExecution);
} catch (Exception ex) {
logger.error(ex.getMessage());
throw new RuntimeException(ex);
}
JAXBHandle<AdaptedStepExecution> jaxbHandle = new JAXBHandle<AdaptedStepExecution>(jaxbContext());
jaxbHandle.set(ase);
DocumentDescriptor desc = docMgr.exists(uri);
if (desc == null) {
logger.error(uri + " does not exist and is attempting an update");
throw new RuntimeException(uri + " does not exist and is attempting an update");
} else if (stepExecution.getVersion() != (int) desc.getVersion()) {
throw new OptimisticLockingFailureException(uri);
}
docMgr.write(desc, metadata, jaxbHandle);
desc = docMgr.exists(uri);
stepExecution.setVersion((int) desc.getVersion());
}
}
开发者ID:marklogic-community,项目名称:marklogic-spring-batch,代码行数:38,代码来源:MarkLogicStepExecutionDao.java
示例16: saveJobExecution
import com.marklogic.client.io.DocumentMetadataHandle; //导入依赖的package包/类
@Override
public void saveJobExecution(JobExecution jobExecution) {
validateJobExecution(jobExecution);
if (jobExecution.getId() == null) {
jobExecution.setId(ThreadLocalRandom.current().nextLong(Long.MAX_VALUE));
}
AdaptedJobExecution aJobInstance;
try {
aJobInstance = adapter.marshal(jobExecution);
} catch (Exception ex) {
logger.error(ex.getMessage());
throw new RuntimeException(ex);
}
XMLDocumentManager xmlDocMgr = databaseClient.newXMLDocumentManager();
String uri = getUri(jobExecution);
//Set document metadata
DocumentMetadataHandle jobInstanceMetadata = new DocumentMetadataHandle();
jobInstanceMetadata.withCollections(properties.getCollection(), properties.getJobExecutionCollection());
JAXBHandle<AdaptedJobExecution> handle = new JAXBHandle<AdaptedJobExecution>(jaxbContext());
handle.set(aJobInstance);
xmlDocMgr.write(uri, jobInstanceMetadata, handle);
DocumentDescriptor desc = xmlDocMgr.exists(uri);
jobExecution.setVersion((int) desc.getVersion());
}
开发者ID:marklogic-community,项目名称:marklogic-spring-batch,代码行数:29,代码来源:MarkLogicJobExecutionDao.java
示例17: updateJobExecution
import com.marklogic.client.io.DocumentMetadataHandle; //导入依赖的package包/类
@Override
public void updateJobExecution(JobExecution jobExecution) {
validateJobExecution(jobExecution);
Assert.notNull(jobExecution.getId(),
"JobExecution ID cannot be null. JobExecution must be saved before it can be updated");
Assert.notNull(jobExecution.getVersion(),
"JobExecution version cannot be null. JobExecution must be saved before it can be updated");
JobExecution je = getJobExecution(jobExecution.getId());
if (je == null) {
throw new NoSuchObjectException("JobExecution " + jobExecution.getJobInstance().getJobName() + " " + jobExecution.getId() + " not found");
}
synchronized (jobExecution) {
AdaptedJobExecution aJobExecution;
try {
aJobExecution = adapter.marshal(jobExecution);
} catch (Exception ex) {
logger.error(ex.getMessage());
throw new RuntimeException(ex);
}
XMLDocumentManager docMgr = databaseClient.newXMLDocumentManager();
String uri = getUri(jobExecution);
DocumentDescriptor desc = docMgr.exists(uri);
if (jobExecution.getVersion() != (int) desc.getVersion()) {
throw new OptimisticLockingFailureException(uri);
}
//Set document metadata
DocumentMetadataHandle metadata = new DocumentMetadataHandle();
metadata.withCollections(properties.getCollection(), properties.getJobExecutionCollection());
JAXBHandle<AdaptedJobExecution> handle = new JAXBHandle<AdaptedJobExecution>(jaxbContext());
handle.set(aJobExecution);
docMgr.write(desc, metadata, handle);
desc = docMgr.exists(uri);
jobExecution.setVersion((int) desc.getVersion());
}
}
开发者ID:marklogic-community,项目名称:marklogic-spring-batch,代码行数:41,代码来源:MarkLogicJobExecutionDao.java
示例18: saveExecutionContext
import com.marklogic.client.io.DocumentMetadataHandle; //导入依赖的package包/类
private void saveExecutionContext(String uri, ExecutionContext ec) {
XMLDocumentManager docMgr = databaseClient.newXMLDocumentManager();
DocumentMetadataHandle metadata = new DocumentMetadataHandle();
metadata.withCollections(properties.getCollection(), properties.getExecutionContextCollection());
JAXBHandle<AdaptedExecutionContext> handle = new JAXBHandle<AdaptedExecutionContext>(jaxbContext());
AdaptedExecutionContext aec = null;
try {
aec = adapter.marshal(ec);
} catch (Exception e) {
logger.error(e.getMessage());
throw new RuntimeException(e);
}
handle.set(aec);
DocumentDescriptor desc = docMgr.exists(uri);
if (desc == null) {
desc = docMgr.newDescriptor(uri);
}
docMgr.write(desc, metadata, handle);
}
开发者ID:marklogic-community,项目名称:marklogic-spring-batch,代码行数:22,代码来源:MarkLogicExecutionContextDao.java
示例19: writeBatchDocumentsWithTransformTest
import com.marklogic.client.io.DocumentMetadataHandle; //导入依赖的package包/类
@Test
public void writeBatchDocumentsWithTransformTest() {
GenericDocumentManager docMgr = testDatabaseClient.newDocumentManager();
docMgr.setContentFormat(Format.XML);
DocumentWriteSet batch = docMgr.newWriteSet();
batch.add("hello.xml", new DocumentMetadataHandle(), new StringHandle("<hello />"));
batch.add("hello2.xml", new DocumentMetadataHandle(), new StringHandle("<hello2 />"));
ServerTransform serverTransform = new ServerTransform("simple");
itemWriter = new MarkLogicItemWriter(client, new ServerTransform(transformName));
docMgr.write(batch, serverTransform);
}
开发者ID:marklogic-community,项目名称:marklogic-spring-batch,代码行数:12,代码来源:MarkLogicItemWriterTest.java
示例20: conflictingUpdateTest
import com.marklogic.client.io.DocumentMetadataHandle; //导入依赖的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);
}
开发者ID:marklogic-community,项目名称:marklogic-spring-batch,代码行数:16,代码来源:MarkLogicItemWriterTest.java
注:本文中的com.marklogic.client.io.DocumentMetadataHandle类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论