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

Community Tip - You can Bookmark boards, posts or articles that you'd like to access again easily! X

SearchCondition to find UsageLink

VasiliyRepecki
1-Newbie

SearchCondition to find UsageLink

Hi.

I need to create QuerySpec to find WTPartUsageLink, where parent WTPart has specified state.

Can anyone provide me sample code?

I tried:

QuerySpec querySpec = new QuerySpec(WTPartUsageLink.class);

int linkIndex = querySpec.appendClassList(WTPartUsageLink.class, false);

int partIndex = querySpec.appendClassList(WTPart.class, false);

querySpec.appendJoin(linkIndex, "roleAObjectRef", partIndex);

CompositeWhereExpression where = new CompositeWhereExpression(LogicalOperator.AND);

where.append(new SearchCondition(WTPart.class, WTPart.LIFE_CYCLE_STATE, SearchCondition.EQUAL, "APPROVED"), new int[]{partIndex});

querySpec.appendWhere(where, new int[]{0});

I get QueryException that WTPart is not parent for WTPartUsageLink.

What am i doing wrong?

Thanks.

2 REPLIES 2

WTPartUsageLink is Master to Iteration link. That means WTPartmaster <------>WTPartUsageLink<----->Iteration of WTPart(A.1, A.2 any version), I think you need to use the WTPart master object insted WTPart or have to change the direction to role B.

QuerySpec querySpec = new QuerySpec();

int linkIndex = querySpec.appendClassList(WTPartUsageLink.class, true);

int partIndex = querySpec.appendClassList(WTPart.class, false);

querySpec.appendJoin(linkIndex,wt.part.WTPartUsageLink.USED_BY_ROLE, partIndex);

querySpec.appendWhere(new SearchCondition(WTPart.class, WTPart.LIFE_CYCLE_STATE, SearchCondition.EQUAL, "APPROVED"),new int[]{partIndex});

I just wonder why you want to get the links for all iterations -- maybe you should only search for wtparts where islatestiteration is 1

Top Tags