SearchCondition to find UsageLink
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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.
- Labels:
-
Other
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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
