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

Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X

How can we get the enditem of wtpart subtype?

CH_10078393
6-Contributor

How can we get the enditem of wtpart subtype?

How can we get the enditem of wtpart subtype?

 

 

 

5 REPLIES 5

Hi @CH_10078393 

What do you need?

 

Search for specific subtype and all enditems in that subtype? 

 

if yes, then this code will search for the subtype and enditem 

 

final IdentifierFactory IDENTIFIER_FACTORY = (IdentifierFactory) DefaultServiceProvider.getService(IdentifierFactory.class, "logical");
try
{
	TypeIdentifier tid = (TypeIdentifier) IDENTIFIER_FACTORY.get("com.aveng.SubType"); // Example: subtype=com.ptc.ElectricalPart
	SearchCondition sc = TypedUtilityServiceHelper.service.getSearchCondition(tid, true);
	QuerySpec queryspec = new QuerySpec();
	int idWTPartObject = queryspec.appendClassList(WTPart.class, true);
	// definice typu v sc (andCondition zamenena za sc)
	queryspec.appendWhere(sc, new int[]{idWTPartObject, idWTPartObject});
	queryspec.appendAnd();
	queryspec.appendWhere(new SearchCondition(WTPart.class, WTPart.END_ITEM, SearchCondition.IS_TRUE), new int[]{idWTPartObject});
	queryspec.appendOrderBy(new OrderBy(new ClassAttribute(WTPart.class, WTPart.NUMBER), false), new int[]{0});

	QueryResult resultDocument = PersistenceHelper.manager.find((StatementSpec) queryspec);

	while (resultDocument.hasMoreElements())
	{

		Object obj[] = (Object[]) resultDocument.nextElement();
		if (obj[0] instanceof WTPart)
		{
			WTPart wtp = (WTPart) obj[0];
			System.out.printf("endItem: %s", wtp.getNumber());
		}
	}
} catch (WTException e)
{
	e.printStackTrace();
}

 

PetrH

Hi PetrH, 

-> We have PartA , PartB and PartC as sube types of wt part.

-> I want check whether PartC is a enditem or not ?.

 

 

How can I do this ?.

 

Thanks, 

Chandra

 

Hi @CH_10078393 

If you have the WTPart object then use simple method on that WTPart

WTPart wtp = (WTPart) primaryBussinessObject;
boolean endItem = wtp.isEndItem();

 

Or use the previous example to search a specific WTPart number .

You just need to add additional condition with a NUMBER.

If the queryresult contains any results, it means that the wtpart number is enditem...

 

PetrH

Hi PetrH, 

Still doesn't works, 

How Can I get the subtype of WTPart ?

 

 

Thanks, 

Chandra

 

avillanueva
22-Sapphire II
(To:CH_10078393)

To clarify, you are not asking how to figure out if something is an end item. You are trying to determine if its the type you are looking for.

String type = TypedUtilityServiceHelper.service.getExternalTypeIdentifier(part);

I've used this line above which should show you the soft-type of the part. You can then compare to the logical name part "PartC" matches.

Announcements

Top Tags