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

FolderHelper.assignFolderByReference

SOLVED

Re: FolderHelper.assignFolderByReference

Hi Mani,

The error got resolved as

the reason was:

In Windchill 9.1, the class ContainerMoveHelper.class is located in codebase\wt\dataops\containermove

In Windchill 10.1, it is in codebase\WEB-INF\lib\wncWeb.jar

I added codebase\WEB-INF\lib\wncWeb.jar in classpath for the project in Eclipse and it resolved the above mentioned error.

However, now I have issues with WTContainerRef containerRef = WTContainerRef.newWTContainerRef(cont);

On hover, it says: "The type com.ptc.windchill.annotations.metadata.ColumnType cannot be resolved. It is indirectly referenced from required .class files"

I even tried to modify the method with another method:

public static PDMLinkProduct getMyProduct(String ContainerName) throws WTException {

PDMLinkProduct product = null;

QuerySpec qs = new QuerySpec(PDMLinkProduct.class);

SearchCondition sc = new SearchCondition(PDMLinkProduct.class, PDMLinkProduct.NAME, SearchCondition.EQUAL, ContainerName);

qs.appendSearchCondition(sc);

QueryResult qr = PersistenceHelper.manager.find(qs);

if(qr.hasMoreElements())

product = (PDMLinkProduct) qr.nextElement();

return product;

}

But it says appendSearchCondition is deprecated.

Any more help please.

Thanks,

Wasim

Re: FolderHelper.assignFolderByReference

Hi Wasim,

Use qs.appendWhere(sc,new int[]{ 0 }); and cast qs with (StatementSpec) when you are using Persistencehelper.manager.find

To get container reference from WTContainer you can use cont.getContainerReference(); also.

Thanks and Regards,

Kaushik

Message was edited by: kaushik das

Re: FolderHelper.assignFolderByReference

Hi Kaushik,

I've had a little success with the below mentioned code:

public class CustomWTPartMover implements RemoteAccess{

public static void PartMover(WTPart part)

{

System.out.println("try started");

try {

ObjectIdentifier oid2 = ObjectIdentifier.newObjectIdentifier("wt.pdmlink.PDMLinkProduct:12551258277");

System.out.println(" My Product Found");

PDMLinkProduct product = (PDMLinkProduct) PersistenceHelper.manager.refresh(oid2);

System.out.println("Product Refreshed");

Folder folder = FolderHelper.service.getFolder("/Default/NewPart", (WTContainerRef)product.getContainerReference());

System.out.println("Folder Found");

FolderHelper.service.changeFolder((FolderEntry)part, folder);

/*

WTValuedHashMap map = new WTValuedHashMap();

map.put((FolderEntry)part,folder);

System.out.println("Folder mapped");

ContainerMoveHelper.service.moveAllVersions(map);

*/

System.out.println("Change Folder successfully!!!!!");

}

catch (WTException e) {

e.printStackTrace();

}

}}

The problem is, the program doesn't recognize the Product, instead move the object to Organization/Folders. Any help here?

Thanks,

Wasim

Re: FolderHelper.assignFolderByReference

Hi Wasim,

Try this code to fetch the PDMLinkProduct object.

ReferenceFactory factory = new ReferenceFactory();

ObjectReference objRef = (ObjectReference)factory.getReference("OR: wt.pdmlink.PDMLinkProduct:162524”);

PDMLinkProduct product=(( PDMLinkProduct) objRef.getObject());

Regards,

Kaushik

Re: FolderHelper.assignFolderByReference

Hi Kaushik,

Even this code can't fetch the Product. It still moves the object to Organization folder.

Could you please advice?

Thanks,

Wasim

Re: FolderHelper.assignFolderByReference

Thanks Mani. Finally the code is working. Thanks a lot for your help.

The minor change which I made to your code was:

map.put((FolderEntry)part,folder);

Announcements
LiveWorx Call For Papers Happening Now!