Closed gvaidees closed 8 years ago
Re-assigning to Justin for prioritization. I'm glad to add this. If it's a must-have, let's do it. If it can wait, that would probably be best given my current backlog of tasks and bugs. I estimate 2 days effort.
Is this all client code or do we need to make changes to the REST API to support this?
Erik says REST API supports this already
Perfect. So if it's just client-side code then I think we're much safer to ship this in a minor or patch release after 3.0.0, if we need to.
New test method available in TestBiTemporal.java class: /*
Insert multiple temporal documents to test bulk write of temporal documents. */ @Test public void testBulkWritReadeWithTransaction() throws Exception {
boolean tstatus = false;
DocumentPage termQueryResults = null;
Transaction tx = writerClient.openTransaction();
try {
XMLDocumentManager docMgr = writerClient.newXMLDocumentManager();
DocumentWriteSet writeset = docMgr.newWriteSet();
String[] docId = new String[4];
docId[0] = "1.xml";
docId[1] = "2.xml";
docId[2] = "3.xml";
docId[3] = "4.xml";
DOMHandle handle1 = getXMLDocumentHandle("2001-01-01T00:00:00",
"2011-12-31T23:59:56", "999 Skyway Park - XML", docId[0]);
DOMHandle handle2 = getXMLDocumentHandle("2001-01-02T00:00:00",
"2011-12-31T23:59:57", "999 Skyway Park - XML", docId[1]);
DOMHandle handle3 = getXMLDocumentHandle("2001-01-03T00:00:00",
"2011-12-31T23:59:58", "999 Skyway Park - XML", docId[2]);
DOMHandle handle4 = getXMLDocumentHandle("2001-01-04T00:00:00",
"2011-12-31T23:59:59", "999 Skyway Park - XML", docId[3]);
DocumentMetadataHandle mh = setMetadata(false);
writeset.add(docId[0], mh, handle1);
writeset.add(docId[1], mh, handle2);
writeset.add(docId[2], mh, handle3);
writeset.add(docId[3], mh, handle4);
Map<String, DOMHandle> map = new TreeMap<String, DOMHandle>();
map.put(docId[0], handle1);
map.put(docId[1], handle2);
map.put(docId[2], handle3);
map.put(docId[3], handle4);
docMgr.write(writeset, null, null, bulktemporalCollectionName);
QueryManager queryMgr = readerClient.newQueryManager();
StructuredQueryBuilder sqb = queryMgr.newStructuredQueryBuilder();
String[] collections = { latestCollectionName, bulktemporalCollectionName, "insertCollection" };
StructuredQueryDefinition termQuery = sqb.collection(collections);
long start = 1;
docMgr = readerClient.newXMLDocumentManager();
docMgr.setMetadataCategories(Metadata.ALL); // Get all metadata
termQueryResults = docMgr.search(termQuery, start);
assertEquals("Records counts is incorrect", 4, termQueryResults.size());
// Verify the Document Record content with map contents for each record.
while (termQueryResults.hasNext()) {
DocumentRecord record = termQueryResults.next();
DOMHandle recordHandle = new DOMHandle();
record.getContent(recordHandle);
String recordContent = recordHandle.toString();
System.out.println("Record URI = " + record.getUri());
System.out.println("Record content is = " + recordContent);
DOMHandle readDOMHandle = map.get(record.getUri());
String mapContent = readDOMHandle.evaluateXPath("/root/Address/text()", String.class);
assertTrue("Address value is incorrect ", recordContent.contains(mapContent));
readDOMHandle = null;
mapContent = null;
}
}
catch(Exception e) {
System.out.println(e.getMessage());
tstatus=true;
throw e;
}
finally {
if(tstatus) {
if (termQueryResults != null)
termQueryResults.close();
tx.rollback();}
}
}
Today, there is no way to do it. It would be nice if this support was added