Document name through java service.

Hi all,
I have read posts pertaining to how to retrieve the document name through java service using IDataCursor.getKey() method.

I have a different scenario here.
I have a document which in turn contain many sub documents like

xyz

  • abc1
  • abc2
  • abc3

where xyz is the parent document and abc1, abc2, abc3 are all the sub documents at the same level.

Now i need to retrieve the names of the sub documents(i.e. abc1, abc2, abc3)

Can anyone pls suggest?

Thanks,
Krithiga M

Hope this helps:

idc = pipeline.getCursor();
IData myRecord = IDataUtil.getIData(idc, “myRecordFromIS”);
idc.destroy();
if(myRecord != null)
{
idc = myRecord.getCursor();
myField = IDataUtil.getString(idc, “myFieldinDocument”);
}

IData resources = IDataUtil.getIDataArray(idc_r, “Resources”);
idc_r.destroy();
if(resources != null)
{
for(int i = 0; i < resources.length; i++)
{
idc_r = resources[i].getCursor();
String name = IDataUtil.getString(idc_r, “ResourceName”);
idc_r.destroy();
if(Resource == null)
{
Object ot = { { “ResourceName”, “WOLFThread” } };
Resource = new IData[1];
Resource[0] = IDataFactory.create(ot);
}
RESOURCEFINDLOOP:for(int j = 0; j < Resource.length; j++)
{
if(Resource[j] != null)
{
IDataCursor idc_tmp = Resource[j].getCursor();
String name_tmp = IDataUtil.getString(idc_tmp, “ResourceName”);
idc_tmp.destroy();
if(name_tmp != null && name_tmp.equals(name))
{
resources[i] = null;
Resource[j] = null;

break RESOURCEFINDLOOP;
}
}
}

check for syntax but I hope this helps…

Ok, If you’d go thru the Java API guide you would have seen these methods too along with getKey():

first() and next() both them return booleans.

the first one moves the cursor to the first element and the second moves the cursor to the next element in the cursor.

Using these three constuct a simple code block like so:

 
IData xyz = IDataUtil.getIData( pipelineCursor, "xyz" );
IDataCursor xyzCursor = xyz.getCursor();
 
xyzCursor.first();
 
do{
    String docName = xyzCursor.getKey();
    ...<do what ever you want with the docName>..
} while(xyzCursor.next());
 

This is just one simple way to do, hope you can improvise from here.

Hope this helps.

hi nigel_belanger and suren,
thanks for the suggestions.
it helped me a lot…

thanks again,
krithiga