private void upsertRecord(String docId, AbstractWriteHandle genericHandle) { docMgr.write(docId, genericHandle); }
private void upsertRecord(String docId, AbstractWriteHandle genericHandle) { docMgr.write(docId, genericHandle); }
@Override public void handleBatch(DatabaseClient client, List<? extends DocumentWriteOperation> items) { DocumentManager<?, ?> mgr = buildDocumentManager(client); if (contentFormat != null) { mgr.setContentFormat(contentFormat); } DocumentWriteSet set = mgr.newWriteSet(); for (DocumentWriteOperation item : items) { set.add(item); } int count = set.size(); if (logger.isDebugEnabled()) { logger.debug("Writing " + count + " documents to MarkLogic"); } if (serverTransform != null) { mgr.write(set, serverTransform); } else { mgr.write(set); } if (logger.isInfoEnabled()) { logger.info("Wrote " + count + " documents to MarkLogic"); } }
public void writeDocumentUsingInputStreamHandle(DatabaseClient client, String filename, String uri, Transaction transaction, String type) throws FileNotFoundException { // create doc manager DocumentManager docMgr = null; docMgr = documentManagerSelector(client, docMgr, type); // create handle InputStreamHandle contentHandle = new InputStreamHandle(); // get the file InputStream inputStream = new FileInputStream("src/test/java/com/marklogic/client/functionaltest/data/" + filename); // set uri String docId = uri + filename; contentHandle.set(inputStream); // write doc docMgr.write(docId, contentHandle, transaction); System.out.println("Write " + docId + " to database"); }
/** * Update document using FileHandle * * @param client * @param filename * @param uri * @param type * @throws IOException */ public void updateDocumentUsingFileHandle(DatabaseClient client, String filename, String uri, String type) throws IOException { // create doc manager DocumentManager docMgr = null; docMgr = documentManagerSelector(client, docMgr, type); File file = new File("src/test/java/com/marklogic/client/functionaltest/data/" + filename); // create an identifier for the document String docId = uri; // create a handle on the content FileHandle handle = new FileHandle(file); handle.set(file); // write the document content docMgr.write(docId, handle); System.out.println("Update " + docId + " to database"); }
/** * Write document using FileHandle * * @param client * @param filename * @param uri * @param type * @throws IOException */ public void writeDocumentUsingFileHandle(DatabaseClient client, String filename, String uri, String type) throws IOException { // create doc manager DocumentManager docMgr = null; docMgr = documentManagerSelector(client, docMgr, type); File file = new File("src/test/java/com/marklogic/client/functionaltest/data/" + filename); // create an identifier for the document String docId = uri + filename; // create a handle on the content FileHandle handle = new FileHandle(file); handle.set(file); // write the document content docMgr.write(docId, handle); System.out.println("Write " + docId + " to database"); }
/** * Write document using InputStreamHandle * * @param client * @param filename * @param uri * @param type * @throws FileNotFoundException */ public void writeDocumentUsingInputStreamHandle(DatabaseClient client, String filename, String uri, String type) throws FileNotFoundException { // create doc manager DocumentManager docMgr = null; docMgr = documentManagerSelector(client, docMgr, type); // create handle InputStreamHandle contentHandle = new InputStreamHandle(); // get the file InputStream inputStream = new FileInputStream("src/test/java/com/marklogic/client/functionaltest/data/" + filename); // set uri String docId = uri + filename; contentHandle.set(inputStream); // write doc docMgr.write(docId, contentHandle); System.out.println("Write " + docId + " to database"); }
/** * Update document using InputStreamHandle * * @param client * @param filename * @param uri * @param type * @throws FileNotFoundException */ public void updateDocumentUsingInputStreamHandle(DatabaseClient client, String filename, String uri, String type) throws FileNotFoundException { // create doc manager DocumentManager docMgr = null; docMgr = documentManagerSelector(client, docMgr, type); // create handle InputStreamHandle contentHandle = new InputStreamHandle(); // get the file InputStream inputStream = new FileInputStream("src/test/java/com/marklogic/client/functionaltest/data/" + filename); // set uri String docId = uri; contentHandle.set(inputStream); // write doc docMgr.write(docId, contentHandle); System.out.println("Update " + docId + " to database"); }
public static void writeGeoDoubleFilesToDB(DatabaseClient client, String filename, String uri, String type) throws IOException, ParserConfigurationException, SAXException { // create doc manager DocumentManager docMgr = null; docMgr = documentMgrSelect(client, docMgr, type); File file = new File(datasource + filename); // create a handle on the content FileHandle handle = new FileHandle(file); handle.set(file); // write the document content DocumentWriteSet writeset = docMgr.newWriteSet(); writeset.add(uri, handle); docMgr.write(writeset); System.out.println("Write " + uri + " to database"); }
@Test public void testTextFormatOnXML() throws KeyManagementException, NoSuchAlgorithmException, IOException, ParserConfigurationException, SAXException, XpathException { System.out.println("Running testTextFormatOnXML"); String filename = "flipper.xml"; String uri = "/txt-format-xml-file/"; // connect the client DatabaseClient client = getDatabaseClient("rest-writer", "x", getConnType()); // create doc manager DocumentManager docMgr = client.newDocumentManager(); File file = new File("src/test/java/com/marklogic/client/functionaltest/data/" + filename); // create a handle on the content FileHandle handle = new FileHandle(file); handle.set(file); handle.setFormat(Format.TEXT); // create docId String docId = uri + filename; docMgr.write(docId, handle); String expectedUri = uri + filename; String docUri = docMgr.exists(expectedUri).getUri(); assertEquals("URI is not found", expectedUri, docUri); // release the client client.release(); }
@Test public void testBinaryFormatOnJSON() throws KeyManagementException, NoSuchAlgorithmException, IOException, ParserConfigurationException, SAXException, XpathException { System.out.println("Running testBinaryFormatOnJSON"); String filename = "json-original.json"; String uri = "/bin-format-json-file/"; // connect the client DatabaseClient client = getDatabaseClient("rest-writer", "x", getConnType()); // create doc manager DocumentManager docMgr = client.newDocumentManager(); File file = new File("src/test/java/com/marklogic/client/functionaltest/data/" + filename); // create a handle on the content FileHandle handle = new FileHandle(file); handle.set(file); handle.setFormat(Format.BINARY); // create docId String docId = uri + filename; docMgr.write(docId, handle); String expectedUri = uri + filename; String docUri = docMgr.exists(expectedUri).getUri(); assertEquals("URI is not found", expectedUri, docUri); // release the client client.release(); }
@Test public void testXMLFormatOnText() throws KeyManagementException, NoSuchAlgorithmException, IOException, ParserConfigurationException, SAXException, XpathException { System.out.println("Running testXMLFormatOnText"); String filename = "text-original.txt"; String uri = "/xml-format-txt-file/"; // connect the client DatabaseClient client = getDatabaseClient("rest-writer", "x", getConnType()); // create doc manager DocumentManager docMgr = client.newDocumentManager(); File file = new File("src/test/java/com/marklogic/client/functionaltest/data/" + filename); // create a handle on the content FileHandle handle = new FileHandle(file); handle.set(file); handle.setFormat(Format.XML); // create docId String docId = uri + filename; docMgr.write(docId, handle); String expectedUri = uri + filename; String docUri = docMgr.exists(expectedUri).getUri(); assertEquals("URI is not found", expectedUri, docUri); // release the client client.release(); }
@Test public void testXMLFormatOnJSON() throws KeyManagementException, NoSuchAlgorithmException, IOException, ParserConfigurationException, SAXException, XpathException { System.out.println("Running testXMLFormatOnJSON"); String filename = "json-original.json"; String uri = "/xml-format-json-file/"; // connect the client DatabaseClient client = getDatabaseClient("rest-writer", "x", getConnType()); // create doc manager DocumentManager docMgr = client.newDocumentManager(); File file = new File("src/test/java/com/marklogic/client/functionaltest/data/" + filename); // create a handle on the content FileHandle handle = new FileHandle(file); handle.set(file); handle.setFormat(Format.XML); // create docId String docId = uri + filename; docMgr.write(docId, handle); String expectedUri = uri + filename; String docUri = docMgr.exists(expectedUri).getUri(); assertEquals("URI is not found", expectedUri, docUri); // release the client client.release(); }
@Test public void testTextFormatOnText() throws KeyManagementException, NoSuchAlgorithmException, IOException, ParserConfigurationException, SAXException, XpathException { System.out.println("Running testTextFormatOnText"); String filename = "text-original.txt"; String uri = "/txt-format-txt-file/"; // connect the client DatabaseClient client = getDatabaseClient("rest-writer", "x", getConnType()); // create doc manager DocumentManager docMgr = client.newDocumentManager(); File file = new File("src/test/java/com/marklogic/client/functionaltest/data/" + filename); // create a handle on the content FileHandle handle = new FileHandle(file); handle.set(file); handle.setFormat(Format.TEXT); // create docId String docId = uri + filename; docMgr.write(docId, handle); String expectedUri = uri + filename; String docUri = docMgr.exists(expectedUri).getUri(); assertEquals("URI is not found", expectedUri, docUri); // release the client client.release(); }
@Test public void testTextFormatOnJSON() throws KeyManagementException, NoSuchAlgorithmException, IOException, ParserConfigurationException, SAXException, XpathException { System.out.println("Running testTextFormatOnJSON"); String filename = "json-original.json"; String uri = "/txt-format-json-file/"; // connect the client DatabaseClient client = getDatabaseClient("rest-writer", "x", getConnType()); // create doc manager DocumentManager docMgr = client.newDocumentManager(); File file = new File("src/test/java/com/marklogic/client/functionaltest/data/" + filename); // create a handle on the content FileHandle handle = new FileHandle(file); handle.set(file); handle.setFormat(Format.TEXT); // create docId String docId = uri + filename; docMgr.write(docId, handle); String expectedUri = uri + filename; String docUri = docMgr.exists(expectedUri).getUri(); assertEquals("URI is not found", expectedUri, docUri); // release the client client.release(); }
@Test public void testBinaryFormatOnBinary() throws KeyManagementException, NoSuchAlgorithmException, IOException, ParserConfigurationException, SAXException, XpathException { System.out.println("Running testBinaryFormatOnBinary"); String filename = "Pandakarlino.jpg"; String uri = "/bin-format-bin-file/"; // connect the client DatabaseClient client = getDatabaseClient("rest-writer", "x", getConnType()); // create doc manager DocumentManager docMgr = client.newDocumentManager(); File file = new File("src/test/java/com/marklogic/client/functionaltest/data/" + filename); // create a handle on the content FileHandle handle = new FileHandle(file); handle.set(file); handle.setFormat(Format.BINARY); // create docId String docId = uri + filename; docMgr.write(docId, handle); String expectedUri = uri + filename; String docUri = docMgr.exists(expectedUri).getUri(); assertEquals("URI is not found", expectedUri, docUri); // release the client client.release(); }
@Test public void testXMLFormatOnXML() throws KeyManagementException, NoSuchAlgorithmException, IOException, ParserConfigurationException, SAXException, XpathException { System.out.println("Running testXMLFormatOnXML"); String filename = "flipper.xml"; String uri = "/xml-format-xml-file/"; // connect the client DatabaseClient client = getDatabaseClient("rest-writer", "x", getConnType()); // create doc manager DocumentManager<GenericReadHandle, GenericWriteHandle> docMgr = client.newDocumentManager(); File file = new File("src/test/java/com/marklogic/client/functionaltest/data/" + filename); // create a handle on the content FileHandle handle = new FileHandle(file); handle.set(file); handle.setFormat(Format.XML); // create docId String docId = uri + filename; docMgr.write(docId, handle); String expectedUri = uri + filename; String docUri = docMgr.exists(expectedUri).getUri(); assertEquals("URI is not found", expectedUri, docUri); // release the client client.release(); }
@Test public void testBinaryFormatOnXML() throws KeyManagementException, NoSuchAlgorithmException, IOException, ParserConfigurationException, SAXException, XpathException { System.out.println("Running testBinaryFormatOnXML"); String filename = "flipper.xml"; String uri = "/bin-format-xml-file/"; // connect the client DatabaseClient client = getDatabaseClient("rest-writer", "x", getConnType()); // create doc manager DocumentManager docMgr = client.newDocumentManager(); File file = new File("src/test/java/com/marklogic/client/functionaltest/data/" + filename); // create a handle on the content FileHandle handle = new FileHandle(file); handle.set(file); handle.setFormat(Format.BINARY); // create docId String docId = uri + filename; docMgr.write(docId, handle); String expectedUri = uri + filename; String docUri = docMgr.exists(expectedUri).getUri(); assertEquals("URI is not found", expectedUri, docUri); // release the client client.release(); }
@Test public void testJSONFormatOnJSON() throws KeyManagementException, NoSuchAlgorithmException, IOException, ParserConfigurationException, SAXException, XpathException { System.out.println("Running testJSONFormatOnJSON"); String filename = "json-original.json"; String uri = "/json-format-json-file/"; // connect the client DatabaseClient client = getDatabaseClient("rest-writer", "x", getConnType()); // create doc manager DocumentManager docMgr = client.newDocumentManager(); File file = new File("src/test/java/com/marklogic/client/functionaltest/data/" + filename); // create a handle on the content FileHandle handle = new FileHandle(file); handle.set(file); handle.setFormat(Format.JSON); // create docId String docId = uri + filename; docMgr.write(docId, handle); String expectedUri = uri + filename; String docUri = docMgr.exists(expectedUri).getUri(); assertEquals("URI is not found", expectedUri, docUri); // release the client client.release(); }
@Test public void testBinaryFormatOnText() throws KeyManagementException, NoSuchAlgorithmException, IOException, ParserConfigurationException, SAXException, XpathException { System.out.println("Running testBinaryFormatOnText"); String filename = "text-original.txt"; String uri = "/bin-format-txt-file/"; // connect the client DatabaseClient client = getDatabaseClient("rest-writer", "x", getConnType()); // create doc manager DocumentManager docMgr = client.newDocumentManager(); File file = new File("src/test/java/com/marklogic/client/functionaltest/data/" + filename); // create a handle on the content FileHandle handle = new FileHandle(file); handle.set(file); handle.setFormat(Format.BINARY); // create docId String docId = uri + filename; docMgr.write(docId, handle); String expectedUri = uri + filename; String docUri = docMgr.exists(expectedUri).getUri(); assertEquals("URI is not found", expectedUri, docUri); // release the client client.release(); }