本文整理汇总了Java中com.marklogic.client.io.DocumentMetadataHandle类的典型用法代码示例。如果您正苦于以下问题:Java DocumentMetadataHandle类的具体用法?Java DocumentMetadataHandle怎么用?Java DocumentMetadataHandle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DocumentMetadataHandle类属于com.marklogic.client.io包,在下文中一共展示了DocumentMetadataHandle类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
示例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());
}
}
示例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;
}
示例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;
}
示例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");
}
示例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']");
}
示例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);
}
示例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());
}
示例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;
}
示例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));
}
示例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);
}
示例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;
}
示例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());
}
示例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());
}
}