I need to build a java service which extracts the value of a field at runtime. The path of the field in the canonical and the canonical document itself should be given as input.
Eg: fromDoc consists of sub documents within it, in a hierarchy, ie. fromDoc/Data/Parameters/outDate
•fromDoc
•Data
•Parameters
•outDate(string)
For inStringValues I give the input as 'fromDoc/Data/Parameters/outDate'
the output should return the value of the variable 'fromDoc/Data/Parameters/outDate' at run time.
I have a code which implements this with the key value pair logic.
IDataCursor pipelineCursor = pipeline.getCursor();
// fromDoc
IData fromDoc = IDataUtil.getIData( pipelineCursor, "fromDoc" );
String[] inStringValues = IDataUtil.getStringArray( pipelineCursor, "inStringValues" );
if ( fromDoc == null)
{
return;
}
pipelineCursor.destroy();
int len = inStringValues.length;
String[] outStrings = new String[len];
IDataCursor fromCursor = fromDoc.getCursor();
boolean hasData = false;
while( fromCursor.next() )
{
for(int i=0;i<len;i++)
{
String key = fromCursor.getKey();
String val = fromCursor.getValue().toString();
if(key.equals(inStringValues[i]))
{
outStrings[i]=key + "," + val;
}
}
}
fromCursor.destroy();
IDataCursor pipelineCursor_1 = pipeline.getCursor();
IDataUtil.put( pipelineCursor_1, "outStrings", outStrings );
pipelineCursor_1.destroy();
Please let me know how I can modify this code to implement the above mentioned logic? Or let me know if anyone has such an existing service with you.
What about this ?