本文整理汇总了Java中com.marklogic.client.io.DocumentMetadataHandle.withCollections方法的典型用法代码示例。如果您正苦于以下问题:Java DocumentMetadataHandle.withCollections方法的具体用法?Java DocumentMetadataHandle.withCollections怎么用?Java DocumentMetadataHandle.withCollections使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.marklogic.client.io.DocumentMetadataHandle
的用法示例。
在下文中一共展示了DocumentMetadataHandle.withCollections方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: 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));
}
示例3: 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;
}
示例4: 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
示例5: 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());
}
示例6: 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());
}
}
示例7: 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());
}
示例8: 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());
}
}
示例9: 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
示例10: getMetadata
import com.marklogic.client.io.DocumentMetadataHandle; //导入方法依赖的package包/类
@Override
public DocumentMetadataWriteHandle getMetadata() {
DocumentMetadataHandle h = new DocumentMetadataHandle();
if (collections != null) {
h.withCollections(collections);
}
if (permissions != null) {
for (String role : permissions.keySet()) {
h.withPermission(role, permissions.get(role));
}
}
return h;
}
示例11: test
import com.marklogic.client.io.DocumentMetadataHandle; //导入方法依赖的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