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

expression, folder move

Participant

expression, folder move

Hello,

 

So, I have successfully coded an expression robot to move objects from one subfolder to another...within the same Product, but I have need to move them from one Product to another.

 

i.e.:

FROM current location...

site/myOrg/Product_WIP/SomeAreaFolder/CurrentFolder

TO location...

site/myOrg/Product_PROD/Somewhere/DestinationFolder (just need the java address of this?)

 

In java, the initial address is "/Default/AreaFolder/CurrentFolder".  I can move object anywhere within Product_WIP or /Default no problem, such as "/Default/AreaFolder/NewFolder".

 

With "/Default" being the "top" folder (which is 1 Product_WIP)...how do I address for folders in Product_PROD?  Normal java relative paths do not work like "../folder-up1level".

 

Thanks,

~PB

Tags (1)
2 REPLIES 2

Re: expression, folder move

here is my code...

 

wt.maturity.PromotionNotice promotionNotice = (wt.maturity.PromotionNotice) primaryBusinessObject;
wt.fc.QueryResult queryResult = wt.maturity.MaturityHelper.service.getPromotionTargets(promotionNotice);
String objectTypeName = null;
while(queryResult.hasMoreElements()) {
  wt.fc.WTObject object = (wt.fc.WTObject) queryResult.nextElement();
  com.ptc.core.meta.common.TypeIdentifier objectType = wt.type.ClientTypedUtility.getTypeIdentifier(object);
  //objectType = object.getClass().getName();
    objectTypeName = String.valueOf(objectType);

if(objectTypeName.contains("wt.part.WTPart")){
  try{
    wt.folder.FolderEntry fentry = (wt.folder.FolderEntry) object;
    wt.folder.Folder f = wt.folder.FolderHelper.service.getFolder(fentry);


//the following line works fine, as I am moving the object within Product_WIP ("/Default")
//    wt.folder.Folder fldrloc = wt.folder.FolderHelper.service.getFolder("/Default/SomeAreaFolder/CurrentFolder/test-within-same-folder", ((wt.inf.container.WTContained)object).getContainerReference());

//the following line DO NOT work, as I am trying to use relative paths...which (in my thinking) would allow me to get to other Products
    wt.folder.Folder fldrloc = wt.folder.FolderHelper.service.getFolder("../Test-up1level", ((wt.inf.container.WTContained)object).getContainerReference());
    wt.folder.Folder fldrloc = wt.folder.FolderHelper.service.getFolder("../", ((wt.inf.container.WTContained)object).getContainerReference());
    wt.folder.Folder fldrloc = wt.folder.FolderHelper.service.getFolder("../../", ((wt.inf.container.WTContained)object).getContainerReference());
    wt.folder.Folder fldrloc = wt.folder.FolderHelper.service.getFolder("../.././", ((wt.inf.container.WTContained)object).getContainerReference());


    wt.fc.collections.WTValuedHashMap map = new wt.fc.collections.WTValuedHashMap();
    map.put(object,fldrloc);
    wt.dataops.containermove.ContainerMoveHelper.service.moveAllVersions(map);
    moved = true; //needed for release conditional robot
  }
  catch(wt.util.WTException wex){
    errorMsg = errorMsg + "...Cannot move because " + wex.getLocalizedMessage();
    moved = false;
  }
}else{
  errorMsg = errorMsg + "...*if* was FALSE...";
}
}
Tags (1)
Highlighted

Re: expression, folder move

Try adding this bit of code before your folder line to get the host or target context info:

wt.inf.container.WTContainerRef cref = wt.inf.container.WTContainerHelper.service.getByPath("/wt.inf.container.OrgContainer=<org name>/wt.pdmlink.PDMLinkProduct=<product name>");

  I've recently had to implement this same thing and asked for help from one of our support vendors. Seems to work (thanks Kevin!).

 

If you're moving to a Library context, the wt.pdmlink bit above becomes wt.inf.library.WTLibrary. 

Announcements
LiveWorx Call For Papers Happening Now!