logger.debug("Writing set of documents"); mgr.write(set); if (logger.isDebugEnabled()) { logger.debug("Finished writing set of documents");
docMgr.write( docId, new BytesHandle(content.getBytes(Charset.forName("UTF-8")))
/** * @param moduleName appended to the baseUri to determine the model definition URI * @param modelDefinition JSON or XML * @return */ public String loadModel(String moduleName, String modelDefinition) { GenericDocumentManager mgr = client.newDocumentManager(); DocumentMetadataHandle dmh = new DocumentMetadataHandle(); dmh.getCollections().add(modelCollection); String modelUri = baseUri + moduleName; mgr.write(modelUri, dmh, new BytesHandle(modelDefinition.getBytes())); return modelUri; }
protected void installStagingDoc(String uri, DocumentMetadataHandle meta, String resource) { FileHandle handle = new FileHandle(getResourceFile(resource)); stagingDocMgr.write(uri, meta, handle); }
protected void installFinalDoc(String uri, DocumentMetadataHandle meta, String resource) { FileHandle handle = new FileHandle(getResourceFile(resource)); finalDocMgr.write(uri, meta, handle); }
writeSet.getClient().newDocumentManager().write( writeSet.getWriteSet(), writeSet.getTransform(), transaction );
protected void installModule(String path, String localPath) { InputStreamHandle handle = new InputStreamHandle(HubTestBase.class.getClassLoader().getResourceAsStream(localPath)); String ext = FilenameUtils.getExtension(path); DocumentMetadataHandle permissions = new DocumentMetadataHandle() .withPermission(getHubAdminConfig().getHubRoleName(), DocumentMetadataHandle.Capability.EXECUTE, UPDATE, READ); switch(ext) { case "xml": handle.setFormat(Format.XML); break; case "json": handle.setFormat(Format.JSON); break; default: handle.setFormat(Format.TEXT); } modMgr.write(path, permissions, handle); clearFlowCache(); }
protected void installModules(Map<String, String> modules) { DocumentWriteSet writeSet = modMgr.newWriteSet(); modules.forEach((String path, String localPath) -> { InputStreamHandle handle = new InputStreamHandle(HubTestBase.class.getClassLoader().getResourceAsStream(localPath)); String ext = FilenameUtils.getExtension(path); switch(ext) { case "xml": handle.setFormat(Format.XML); break; case "json": handle.setFormat(Format.JSON); break; default: handle.setFormat(Format.TEXT); } DocumentMetadataHandle permissions = new DocumentMetadataHandle() .withPermission(getHubAdminConfig().getHubRoleName(), DocumentMetadataHandle.Capability.EXECUTE, UPDATE, READ); writeSet.add(path, permissions, handle); }); modMgr.write(writeSet); clearFlowCache(); }
@Test public void testRawCombinedCtsQueryFromFileHandle() throws Exception { Common.client.newDocumentManager().write("testRawCtsQueryFromFileHandle.xml", new FileHandle(new File("src/test/resources/constraint5.xml")).withFormat(Format.XML)); FileHandle ctsHandle = new FileHandle(new File("src/test/resources/combinedCtsQuery.xml")); QueryDefinition[] queries = new QueryDefinition[] { queryMgr.newRawCombinedQueryDefinition(ctsHandle), queryMgr.newRawCtsQueryDefinition(ctsHandle), }; for ( QueryDefinition query : queries ) { // create result handle DOMHandle resultsHandle = new DOMHandle(); queryMgr.search(query, resultsHandle); // get the result Document resultDoc = resultsHandle.get(); assertXpathEvaluatesTo("1", "string(//*[local-name()='result'][last()]//@*[local-name()='index'])", resultDoc); assertXpathEvaluatesTo("0026", "string(//*[local-name()='result'][1]//*[local-name()='id' or local-name()='highlight'])", resultDoc); } } }
docMgr.write(writeset);
@Test public void test_issue581_RawStructuredQueryFromFileHandle() throws Exception { Common.client.newDocumentManager().write("test_issue581_RawStructuredQueryFromFileHandle.xml", new FileHandle(new File("src/test/resources/constraint5.xml")).withFormat(Format.XML)); // get the combined query File file = new File("src/test/resources/combinedQueryOption.xml"); // create a handle for the search criteria FileHandle rawHandle = new FileHandle(file); QueryManager queryMgr = Common.client.newQueryManager(); // create a search definition based on the handle RawStructuredQueryDefinition querydef = queryMgr.newRawStructuredQueryDefinition(rawHandle); // create result handle DOMHandle resultsHandle = new DOMHandle(); queryMgr.search(querydef, resultsHandle); // get the result Document resultDoc = resultsHandle.get(); assertXpathEvaluatesTo("1", "string(//*[local-name()='result'][last()]//@*[local-name()='index'])", resultDoc); assertXpathEvaluatesTo("0026", "string(//*[local-name()='result'][1]//*[local-name()='id'])", resultDoc); }
@Test public void testRawCtsQueryFromFileHandle() throws Exception { Common.client.newDocumentManager().write("testRawCtsQueryFromFileHandle.xml", new FileHandle(new File("src/test/resources/constraint5.xml")).withFormat(Format.XML)); String ctsQueryFilePath = "ctsQuery1.xml"; String ctsQueryAsString = Common.testFileToString(ctsQueryFilePath); File ctsQueryFile = new File(Common.getResourceUri(ctsQueryFilePath)); FileHandle ctsHandle = new FileHandle(ctsQueryFile); QueryDefinition[] queries = new QueryDefinition[] { queryMgr.newRawCombinedQueryDefinition(ctsHandle), queryMgr.newRawCtsQueryDefinition(ctsHandle), queryMgr.newRawCombinedQueryDefinitionAs(Format.XML, ctsQueryFile), queryMgr.newRawCtsQueryDefinitionAs(Format.XML, ctsQueryFile), queryMgr.newRawCtsQueryDefinition(new InputStreamHandle(new FileInputStream(ctsQueryFile))), queryMgr.newRawCtsQueryDefinition(new StringHandle(ctsQueryAsString)), queryMgr.newRawCtsQueryDefinition(new DOMHandle(Common.testStringToDocument(ctsQueryAsString))) }; for ( QueryDefinition query : queries ) { // create result handle DOMHandle resultsHandle = new DOMHandle(); queryMgr.search(query, resultsHandle); // get the result Document resultDoc = resultsHandle.get(); assertXpathEvaluatesTo("1", "string(//*[local-name()='result'][last()]//@*[local-name()='index'])", resultDoc); assertXpathEvaluatesTo("0026", "string(//*[local-name()='result'][1]//*[local-name()='id' or local-name()='highlight'])", resultDoc); } }
docMgr.write(writeset);
InputStreamHandle handle1 = new InputStreamHandle(fis); handle1.setFormat(Format.BINARY); docMgr.write("/binary4mbdoc", handle1); String query = "declare variable $myInteger as xs:integer external;" + "(fn:doc()/binary(),$myInteger,xdmp:database-name(xdmp:database()))";
docMgr.write(writeset); DocumentMetadataHandle mh1 = new DocumentMetadataHandle(); DocumentPage page = docMgr.read("/generic/Sega.jpg");
docMgr.write(writeset);
handle.getMapper().addMixInAnnotations(Toponym.class, ToponymMixIn2.class); set.add(DIRECTORY + "/thirdPartyJsonCities/" + city.getGeoNameId() + ".json", handle); } docMgr.write(set);
flowRunnerDocMgr.write("/input" + fileSuffix + "." + dataFormat.toString(), handle, serverTransform); if (finalCounts.stagingCount == 0) { fail("Should have thrown an exception.");