Community Tip - Did you get called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. X
Hello Community,
I am working on some coding to Link an EPMDocument to a WTPart, and then build the WTPart structure. I've got the association portion working but am having difficulty with the build task. I found this in the Windchill API to build structures:
BuildHelper.service.buildTarget(WTCollection alwaysBuild, WTCollection buildIfNotAlreadyBuilt, BuildResolverDelegate[] buildResolverDelegate, ConfigSpec configSpec)
I feed this a collection containing my working copy of the WTPart, and it appears to run without issue.
It returns a WTValuedMap, which I am not familiar with. My question is there any I need to do with the WTValued Map to update the working copy of my WTPart object prior to service.checkin? Or has anyone had any success with using the BuildHelper.service ?
Snippet:
\\Checkout OBJ_prt
\\create WRK_Prt = workingcopyof (OBJ_Prt)
\\Create links to EMPDoc
\\add WRK_prt to WTCollection alwaysBuild. No buildresolverDelegate, no config spec.
WTValuedMap myMap = BuildHelper.Service.BuildTargets(alwaysBuild)
\\CI_Prt = ...service.check(ONJPrt)
Got it to work. Not sure if it is correct, but I get the results I am shooting for.
Snippet:
//WRK_prt = workingcopy of checkedout OBJ_prt
Link cadpartlink = EPMBuildRule.newEPMBuildRule(OBJ_epm, WRK_prt);
Link savedlink = (Link)PersistenceHelper.manager.save(cadpartlink);
WTCollection wtCol = new WTHashSet();
wtCol.add(WRK_prt);
WTValuedMap vMap = (WTValuedMap) BuildHelper.service.buildTarget(wtCol,null,null,null);
Iterator iter = vMap.entrySet().iterator();
outLog.println("iter set");
WTKeyedMap.WTEntry entry = (WTKeyedMap.WTEntry)iter.next();
outLog.println("WTEntry Set");
WRK_prt = (WTPart)entry.getKeyAsPersistable();
WTPart CI_prt = (WTPart)WorkInProgressHelper.service.checkin(OBJ_prt, "");