I am writting a java service where I am building the document for output. But My structure should be : OutPut Doc is the top level doc. Inside that i want to have another Doc say Intermediate doc and in this intermediate doc i want to have Key values.
But My question is how can i insert one doc to another. I see the IDataUtil has put method which ask for key as string and value can be object.
My code is IDataUtil.put(idcvalueDoc, "Body", FullValue.toString());
But this Body should not be string it should be document .I want to insert one Doc to another.
Please help me
To accomplish what you're after, you will need to do the following:
The following is an example Java service that demonstrates this (note the key value tuples added to the intermediateDoc are hard-coded here for convenience):
public static final void exampleService(IData pipeline) throws ServiceException {
IDataCursor pipelineCursor = pipeline.getCursor();
try {
// create an intermediateDoc IData object
IData intermediateDoc = IDataFactory.create();
// create a cursor to use to add key value tuples to the intermediateDoc
IDataCursor intermediateCursor = intermediateDoc.getCursor();
// add key value tuples as required to the intermediateDoc
IDataUtil.put(intermediateCursor, "key1", "value1");
IDataUtil.put(intermediateCursor, "key2", "value2");
// ...
// destroy the intermediateCursor when done adding key value tuples
intermediateCursor.destroy();
// create an outputDoc IData object
IData outputDoc = IDataFactory.create();
// create a cursor to use to add key value tuples to the outputDoc
IDataCursor outputCursor = outputDoc.getCursor();
// add the intermediateDoc to the outputDoc
IDataUtil.put(outputCursor, "intermediateDoc", intermediateDoc);
// destroy the outputCursor when done adding key value tuples
outputCursor.destroy();
// add the outputDoc to the pipeline
IDataUtil.put(pipelineCursor, "outputDoc", outputDoc);
} finally {
// destroy the pipelineCursor
pipelineCursor.destroy();
}
}