Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

LAPI/Java: Cannot list objects in Project nodes 1

Status
Not open for further replies.

bedonath

Programmer
Jun 8, 2004
3
DE
Hi

I am desperately trying to display a document tree using LAPI from Java. I wrote a recursive method which traverses the tree. This works fine except for nodes with a subType of 'Project'. It seems as if these nodes do not have descendants.
However, when I use the XMLExport method to create an XML export of the document tree all descendants of the Project nodes are included. What I have noticed is that all the parentIds of the project node descendants are negative here.

Anyone has a glue why this is the case? How can I modify the method below to traverse also the project nodes?

Thanks
Bernd


Code:
private int parseTree( int parentId )
{
    int nodesVisited = 0;

    LLValue node = new LLValue();
    documents.ListObjects( volumeID, parentId, "DTree",
        null, LAPI_DOCUMENTS.PERM_FULL, node );

    LLValueEnumeration enumVal = node.enumerateValues();
    while( enumVal.hasMoreElements() )
    {
        LLValue element = (LLValue) enumVal.nextElement();
        nodesVisited++;

        String name = element.toString( "Name" );
        int id = element.toInteger( "ID" );
        int pid = element.toInteger( "ParentID" );
        int subType = element.toInteger( "SubType" );

        log.debug( name + " (id=" + id + ";pid=" + pid + 
                   ";type=" + subType + ")" );

        nodesVisited += parseTree( id );

    }

    return nodesVisited;
}
 
Hi Bernd

Livelink creates two objects for one project.
One is the project node which you can see in your folder (subtype 202). It has the same volumeId as the parent node.
(Example: VolumeID -2000, NodeID 1234)

The other object is the project volume (subtype 201). It contains all folder and documents. The nodeid for this object is the negative nodeid of the other object and the volumeid is the positive nodeid, the parentid is -1.(Example: VolumeID 1234, NodeId -1234). All other child objects have the new volumeid 1234 from their parent.

I think there is no LAPI function to handle this situation and you have to write your own function...

Greetings

Lars


 
Hi Lars,

thank you for the quick reply. When I get the object info for objects with subType=202 (Project) like in the following code fragment

Code:
    ...
    LLValue info = new LLValue();
    documents.GetObjectInfo( id, -id, info );
    log.debug( ident + "info:"+info);
    ...

I can actually see the correct number of children of the Project nodes. But do I really cannot access them with LAPI?

greetings
Bernd
 
Hi,

Did you try it with the ListObjects function? In the example you only use GetObjectInfo.

And you have to add the volumeID as a second argument for the method parseTree. Because you need the volumeid of the project volume if you call istObjects the next time.

Lars

 
Hi Lars,

I've got it working now :) !
Here is the method again:

Code:
private int parseTree( int volumeId, int parentId )
{
    int nodesVisited = 0;

    LLValue node = new LLValue();
    documents.ListObjects( volumeId, parentId, "DTree", null, 
        LAPI_DOCUMENTS.PERM_FULL, node );

    LLValueEnumeration enumVal = node.enumerateValues();
    while( enumVal.hasMoreElements() )
    {
        LLValue element = (LLValue) enumVal.nextElement();
        nodesVisited++;

        String name = element.toString( "Name" );
        int volId = element.toInteger( "VolumeId" );
        int id = element.toInteger( "ID" );
        int pid = element.toInteger( "ParentID" );
        int subType = element.toInteger( "SubType" );

        log.debug( name + " (id=" + id + ";pid=" + pid + 
                   ";type=" + subType + ")" );

        if( subType == 202 )
        {
            volId = id;
            id = -id;
        }

        nodesVisited += parseTree( volId, id );

    }

    return nodesVisited;
}

You really gave me the missing bit ;-)

Thanks again!
Bernd
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top