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

Community Tip - You can change your system assigned username to something more personal in your community settings. X

Creating several links between parts

abaranov
1-Visitor

Creating several links between parts

Hello,

I need to create several WTPartUsageLinks with one part as parent and different parts as childs. I want to checkout parent part only once and I use code like that:

String parentNumber = new String(parentNumber_param.getBytes(), "windows-1251");

QuerySpec qspecParent = new QuerySpec(WTPart.class);

qspecParent.appendWhere(new SearchCondition(WTPart.class, WTPart.NUMBER, SearchCondition.EQUAL, parentNumber), new int[] {0,1});

QueryResult qrParent = PersistenceHelper.manager.find((StatementSpec)qspecParent);

while (qrParent.hasMoreElements())

{

partParent = (WTPart)qrParent.nextElement();

if (partParent.isLatestIteration())

break;

}

//some code skipped

Quantity wcQty = new Quantity();

wcQty.setAmount(qty);

wcQty.setUnit(qUnit);

WTPart checkedOutParent = null;

if (!WorkInProgressHelper.isCheckedOut(partParent))

checkedOutParent = (WTPart) WorkInProgressHelper.service.checkout(partParent, WorkInProgressHelper.service.getCheckoutFolder(), "checked out").getWorkingCopy();

else

{

if (!WorkInProgressHelper.isWorkingCopy(partParent))

checkedOutParent = (WTPart) WorkInProgressHelper.service.workingCopyOf(partParent);

else

checkedOutParent = partParent;

}

WTPartUsageLink link = WTPartUsageLink.newWTPartUsageLink(checkedOutParent, (WTPartMaster) partChild.getMaster());

link.setQuantity(wcQty);

PersistenceHelper.manager.save(link);

if (needsCheckIn)

WorkInProgressHelper.service.checkin(checkedOutParent, "");


When I call this page for the first time, parent part checks out and a new link appears in Windchill client, but when parent part is already checked out

before, links don't appear after part checkin. But when I check out this part one more time in windchill cilent, I can see all the links created.

Can someone tell what is wrong with this code? Thanks in advance.

0 REPLIES 0
Announcements


Top Tags