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

Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X

how to get "Referenced By Parts" from WTdocument

rhuang1
1-Newbie

how to get "Referenced By Parts" from WTdocument

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?

1 ACCEPTED SOLUTION

Accepted Solutions
KD
4-Participant
4-Participant
(To:GregoryPERASSO)

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

View solution in original post

3 REPLIES 3
GregoryPERASSO
14-Alexandrite
(To:rhuang1)

Have a look in the WTPartHelper.service.getReference... something like that

Seems to be deprecated in 9.1

or try navigateReferencedBy() method in StandardStructService

KD
4-Participant
4-Participant
(To:GregoryPERASSO)

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.

Top Tags