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
I am on Windchill 9.0 M50.
My question is
how to get "Referenced By Parts" from WTdocument ?
I have checked the API and search the web, but not find the anwser.
Can someone provide any clue?
Solved! Go to Solution.
Hi Ruo,
You can use this method
PartDocServiceCommand.getAssociatedRefParts(paramWTDocument);
Below is the implementation.
public static WTArrayList getAssociatedRefParts(WTDocument paramWTDocument)
/* */ throws WTException
/* */ {
/* 203 */ QueryResult localQueryResult = StructHelper.service.navigateReferencedBy(paramWTDocument.getMaster(), WTPartReferenceLink.class, true);
/* 204 */ WTArrayList localWTArrayList = new WTArrayList();
/* */ Iterator localIterator;
/* 206 */ if (localQueryResult.size() > 0) {
/* 207 */ WTValuedMap localWTValuedMap = VersionControlHelper.service.getLatestIterations(new WTArrayList(localQueryResult), false);
/* 208 */ for (localIterator = localWTValuedMap.entrySet().iterator(); localIterator.hasNext(); ) {
/* 209 */ WTValuedMap.WTValuedEntry localWTValuedEntry = (WTValuedMap.WTValuedEntry)localIterator.next();
/* 210 */ Versioned localVersioned = (Versioned)localWTValuedEntry.getValueAsPersistable();
/* 211 */ if (localVersioned instanceof WTPart) {
/* 212 */ String str = ((Workable)localVersioned).getCheckoutInfo().getState().toString();
/* */
/* 216 */ if (!(str.equals("c/o"))) {
/* 217 */ localWTArrayList.add(localVersioned);
/* */ }
/* */ }
/* */ }
/* */
/* */ }
/* */
/* 224 */ return localWTArrayList;
/* */ }
Regards,
Kaushik
Have a look in the WTPartHelper.service.getReference... something like that
Seems to be deprecated in 9.1
or try navigateReferencedBy() method in StandardStructService
Hi Ruo,
You can use this method
PartDocServiceCommand.getAssociatedRefParts(paramWTDocument);
Below is the implementation.
public static WTArrayList getAssociatedRefParts(WTDocument paramWTDocument)
/* */ throws WTException
/* */ {
/* 203 */ QueryResult localQueryResult = StructHelper.service.navigateReferencedBy(paramWTDocument.getMaster(), WTPartReferenceLink.class, true);
/* 204 */ WTArrayList localWTArrayList = new WTArrayList();
/* */ Iterator localIterator;
/* 206 */ if (localQueryResult.size() > 0) {
/* 207 */ WTValuedMap localWTValuedMap = VersionControlHelper.service.getLatestIterations(new WTArrayList(localQueryResult), false);
/* 208 */ for (localIterator = localWTValuedMap.entrySet().iterator(); localIterator.hasNext(); ) {
/* 209 */ WTValuedMap.WTValuedEntry localWTValuedEntry = (WTValuedMap.WTValuedEntry)localIterator.next();
/* 210 */ Versioned localVersioned = (Versioned)localWTValuedEntry.getValueAsPersistable();
/* 211 */ if (localVersioned instanceof WTPart) {
/* 212 */ String str = ((Workable)localVersioned).getCheckoutInfo().getState().toString();
/* */
/* 216 */ if (!(str.equals("c/o"))) {
/* 217 */ localWTArrayList.add(localVersioned);
/* */ }
/* */ }
/* */ }
/* */
/* */ }
/* */
/* 224 */ return localWTArrayList;
/* */ }
Regards,
Kaushik
Thank for suggestions.
I have solved the problem.