cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

How to revise WTPartDescribeLink

VINO
Visitor

How to revise WTPartDescribeLink

I have WTPart object with describe links WTDocuments associated with that.Now I need to revise the PartDescribeLink through code.

Below is the code I have tried so far..

Vector localVector=new Vector();

QueryResult localQueryResult=WTPartHelper.service.getDescribedByWTDocuments(part,false);

System.out.println("size is "+localQueryResult.size());

if((localQueryResult!=null)&&(localQueryResult.hasMoreElements()))

{

while(localQueryResult.hasMoreElements())

{

WTObject localObject=(WTObject) localQueryResult.nextElement();

localVector.addElement(localObject);

}

}

if((localVector!=null)&&(localVector.size()>0))

{

for(int i=0;i<localVector.size();i++)

{

WTPartDescribeLink localPartlink=(WTPartDescribeLink) localVector.elementAt(i);

WTDocument localWTDocument=localPartlink.getDescribedBy();

System.out.println("values are "+localWTDocument.getNumber());

RevisionControlled localRevisionControlled=null;

localRevisionControlled=(RevisionControlled) VersionControlHelper.service.newVersion(localWTDocument);

localRevisionControlled=(RevisionControlled) PersistenceHelper.manager.save(localRevisionControlled);

}

}

This code is revising only the WTDocument object but not the partDescribelink.If I tried to pass the Describelink object directly like this

localRevisionControlled=(RevisionControlled) VersionControlHelper.service.newVersion((Versioned)localPartlink);

means it is showing the following error message.

Exception in thread "main" java.lang.ClassCastException: wt.part.WTPartDescribeLink cannot be cast to wt.vc.Versioned

at ext.gt.test.CheckLink.getPartlink(CheckLink.java:94)

at ext.gt.test.CheckLink.searchPart(CheckLink.java:52)

at ext.gt.test.CheckLink.main(CheckLink.java:32)

I need to revise the link in code.Someone help me with giving the API or some example code snippets would be helpful for me.

Thank you

1 REPLY 1

Re: How to revise WTPartDescribeLink

Hello

it is the normal behavior regarding your code

the describe link is "owned" by the WTpart. If you revise the WTPart, the link is carried forward by the Out of the Box business logic.

But if your revise the WTdoc only, you will have a standalone new version of your WTDoc. The link is not a Versionable object.

If you do not want to revise the WTpart, you have to checkout (not necessary by code) the WTPart. remove the link to the old version of the Doc, and link to the new version of your Doc.

If you want to revise also the WTpart. You should be able to use "collector API" (don't know exactly which API, but it exists), to revise both objects together, and the link will be carried forward between the 2 new versions.

regards

Gregory

Announcements