Wasim
- If want to call any class in Workflow you should give fully qualified class name. for example: WTContainer -----> wt.inf.container.WTContainer
- doc.getContainer() will get container of your PBO
- For getting container by Name you have to write some QuerySpec for that.
- 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;
}
}