Quantcast
Channel: PTC Community: Message List - Windchill
Viewing all articles
Browse latest Browse all 8876

Re: FolderHelper.assignFolderByReference

$
0
0

Wasim

 

  1. If want to call any class in Workflow you should give fully qualified class name. for example: WTContainer  -----> wt.inf.container.WTContainer
  2. doc.getContainer() will get container of your PBO
  3. For getting container by Name you have to write some QuerySpec for that.
  4. In case, If getting in situation where you need to Bulk of codes in Workflow ,better write your code into one java class file and call the same from Workflow Expression

 

Past is two lines of code in workflow
wt.part.WTPart pbo =(wt.part.WTPart)primaryBusinessObject;

ext.CustomWTPartMover.PartMover(pbo ,"GOLF_CART ","Manufacturing");

//Here GOLF_CART Target product Name & Manufacturing is my folder Name inside Target product

 

This my Java class called in workflow

package ext;

import wt.dataops.containermove.ContainerMoveHelper;

import wt.fc.PersistenceHelper;

import wt.fc.QueryResult;

import wt.fc.collections.WTValuedHashMap;

import wt.folder.Folder;

import wt.folder.FolderHelper;

import wt.inf.container.WTContainer;

import wt.inf.container.WTContainerRef;

import wt.method.RemoteAccess;

import wt.part.WTPart;

import wt.pdmlink.PDMLinkProduct;

import wt.pds.StatementSpec;

import wt.query.QuerySpec;

import wt.query.SearchCondition;

import wt.util.WTException;

 

 

public class CustomWTPartMover implements RemoteAccess{

 

 

          public static void PartMover(WTPart part,String ContainerName,String location)

          {

                    try {

                              WTContainer cont=getMyProduct(ContainerName);

                              WTContainerRef containerRef = WTContainerRef.newWTContainerRef(cont);

                              Folder folder = FolderHelper.service.getFolder("/Default/"+location, containerRef);

                              WTValuedHashMap map = new WTValuedHashMap();

                              map.put(part,folder);

                              ContainerMoveHelper.service.moveAllVersions(map);  

                    }

                    catch (WTException e) {

                              e.printStackTrace();

                    } 

          }

 

 

                    public static PDMLinkProduct getMyProduct(String ContainerName)

                    {

                              PDMLinkProduct product = null;

                              try {

                                        QuerySpec qs = new QuerySpec(PDMLinkProduct.class);

                                        qs.appendWhere(

                                                            new SearchCondition(PDMLinkProduct.class,

                                                                                PDMLinkProduct.NAME, SearchCondition.EQUAL,

                                                                                ContainerName), new int[] { 0 });

                                        QueryResult qr;

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

                                        while (qr.hasMoreElements()) {

                                                  product = (PDMLinkProduct) qr.nextElement();

                                        }

                              } catch (WTException e) {

                                        e.printStackTrace();

                              }

                              return product;

                    }

          }


Viewing all articles
Browse latest Browse all 8876

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>