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

Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X

Windchill part Usagelink deletion using api

AK_10341824
5-Regular Member

Windchill part Usagelink deletion using api

Hi Community members, I was using Part Helper API to fetch all the usage links present in windchill. I am getting referential integrity violation / exception when I am trying to delete the part usage link using Persistence Helper API. Please help me with the solution approach.

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @AK_10341824 

The main question is why do you want to delete the uses links without check-out?

Check out the parent and remove the uses links

 

PetrH

View solution in original post

11 REPLIES 11

Hi @AK_10341824 

This is common 😄 if there is any reference to usage link as EPMBuildHistory you need to find all references and delete them.

First I would check what the exception says, usually there is useful information that can help to solve the error.

 

PetrH

AK_10341824
5-Regular Member
(To:HelesicPetr)

Hi @HelesicPetr , we need to first get all the Usage Links from WTPartUsageLink table right? Now I was trying to get all the links and delete one by one. So, now getting ModificationNotAllowed exception.

 

Attaching the details of error below:
Exception in thread "main" java.lang.reflect.InvocationTargetException
at wt.method.RemoteMethodServer.invoke(RemoteMethodServer.java:912)
at ext.itc.test.DeleteElectricalWTPartsAndLinks.main(DeleteElectricalWTPartsAndLinks.java:51)
Caused by: wt.fc.ModificationNotAllowedException: (wt.vc.wip.wipResource/47) wt.vc.wip.WorkInProgressException: TEST_123, Test_123, B.1 (Design) is not checked out and cannot be modified.
Nested exception is: (wt.vc.wip.wipResource/47) wt.vc.wip.WorkInProgressException: TEST_123, Test_123, B.1 (Design) is not checked out and cannot be modified.
... 2 more
Caused by: (wt.vc.wip.wipResource/47) wt.vc.wip.WorkInProgressException: TEST_123, Test_123, B.1 (Design) is not checked out and cannot be modified.
at wt.vc.wip.StandardWorkInProgressService.validateModifiable(StandardWorkInProgressService.java:617)
at wt.vc.wip.StandardWorkInProgressService$3.notifyVetoableMultiObjectEvent(StandardWorkInProgressService.java:461)
at wt.events.StandardKeyedEventBranch.intDispatchEvent(StandardKeyedEventBranch.java:306)
at wt.events.StandardKeyedEventBranch.dispatchVetoableMultiObjectEvent(StandardKeyedEventBranch.java:268)
at wt.events.StandardKeyedEventDispatcher.intDispatchEvent(StandardKeyedEventDispatcher.java:306)
at wt.events.StandardKeyedEventDispatcher.dispatchVetoableMultiObjectEvent(StandardKeyedEventDispatcher.java:244)
at wt.services.StandardManagerService.intDispatchVetoableEvent(StandardManagerService.java:412)
at wt.services.StandardManagerService.dispatchVetoableMultiObjectEvent(StandardManagerService.java:314)
at wt.fc.StandardPersistenceManager.dispatchVetoableEvent(StandardPersistenceManager.java:2976)
at wt.fc.StandardPersistenceManager.dispatchVetoableEvent(StandardPersistenceManager.java:2959)
at wt.fc.StandardPersistenceManager.prepareForModification(StandardPersistenceManager.java:902)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at wt.services.ServiceFactory$ServerInvocationHandler.invoke(ServiceFactory.java:399)
at com.sun.proxy.$Proxy29.prepareForModification(Unknown Source)
at wt.vc.struct.StandardStructService.validateLinkAction(StandardStructService.java:3233)
at wt.vc.struct.StandardStructService.initializeValidateLinkAction(StandardStructService.java:3135)
at wt.vc.struct.StandardStructService$8.notifyVetoableMultiObjectEvent(StandardStructService.java:747)
at wt.events.StandardKeyedEventBranch.intDispatchEvent(StandardKeyedEventBranch.java:306)
at wt.events.StandardKeyedEventBranch.dispatchVetoableMultiObjectEvent(StandardKeyedEventBranch.java:268)
at wt.events.StandardKeyedEventDispatcher.intDispatchEvent(StandardKeyedEventDispatcher.java:306)
at wt.events.StandardKeyedEventDispatcher.dispatchVetoableMultiObjectEvent(StandardKeyedEventDispatcher.java:244)
at wt.services.StandardManagerService.intDispatchVetoableEvent(StandardManagerService.java:412)
at wt.services.StandardManagerService.dispatchVetoableMultiObjectEvent(StandardManagerService.java:314)
at wt.fc.StandardPersistenceManager.dispatchVetoableEvent(StandardPersistenceManager.java:2976)
at wt.fc.StandardPersistenceManager.dispatchVetoableEvent(StandardPersistenceManager.java:2959)
at wt.fc.StandardPersistenceManager.delete(StandardPersistenceManager.java:814)
at wt.fc.StandardPersistenceManager.delete(StandardPersistenceManager.java:400)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at wt.services.ServiceFactory$ServerInvocationHandler.invoke(ServiceFactory.java:399)
at com.sun.proxy.$Proxy29.delete(Unknown Source)
at ext.itc.test.DeleteElectricalWTPartsAndLinks.deleteAllUsageLinks(DeleteElectricalWTPartsAndLinks.java:115)
at ext.itc.test.DeleteElectricalWTPartsAndLinks.deleteAllPartsFromMap(DeleteElectricalWTPartsAndLinks.java:107)
at ext.itc.test.DeleteElectricalWTPartsAndLinks.listingElectricalWTParts(DeleteElectricalWTPartsAndLinks.java:77)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at wt.method.MethodResultWriter.writeExternal(MethodResultWriter.java:165)
at wt.method.MethodResult.writeExternal(MethodResult.java:226)
at java.base/java.io.ObjectOutputStream.writeExternalData(ObjectOutputStream.java:1447)
at java.base/java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1421)
at java.base/java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1169)
at java.base/java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:345)
at java.rmi/sun.rmi.server.UnicastRef.marshalValue(UnicastRef.java:293)
at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:369)
at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:200)
at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:197)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.rmi/sun.rmi.transport.Transport.serviceCall(Transport.java:196)
at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:562)
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:796)
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:677)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:676)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:829)

**For your reference:

-------------------------
Test_123 part latest revision/iteration is : C.1

Hi @AK_10341824 

The main question is why do you want to delete the uses links without check-out?

Check out the parent and remove the uses links

 

PetrH

The problem with checking out/delete link/checkin is that previously linked iterations are still linked.

I like using a coding technique that uses the APIs. To delete all the links that connect any interations of the WTPart to the WTPartMaster.

This technique does NOT iterate anything and all the links get deleted.

Its really the only way to break the reference completely if you want to use supported APIs.

The links delete can certainly be limited to all iterations of a version branch if so desired.

As always, once the desired spec is defined whatever that spec is is what gets done.

 

David

@d_graham Do you have such api to delete all the links without checkout or iterating Parent object? Can you please elaborate little more?

@IJ_10422614 , hi

 

Yes, I do have the code that I wrote to delete links (and add links) without iterating anything.

 

If need this send me an email from your work email account.  I’m sure we can work something out.

I can be reached windchill.developer@yahoo.com 


BTW, I write code for lots of people and whereas I’m retired now, I do it for fun and at far less than anyone else.

Whereas others compensate me to write code for them it would not be fair for me to write code for others for free.

But I am cheap, real cheap.😁

 

I don’t post code on this site anymore, too many people in the past have used my code and sold it to their customers. Once I learned this was happening I stop tell people how to do something.

Now, I just tell what can be done and sometimes include screenshots to prove it.

 

David

@d_graham Hi, 

I have sent you mail, Can you please check?

Thanks,
Irfan

Hello @AK_10341824 

Which API? wt.clients.prodmgmt.PartHelper.deletePartUsageLink() ?

 

What is the error reported?

If convenient, you can also provide your code

 

 

AK_10341824
5-Regular Member
(To:Rocket_Max)

Hi @Rocket_Max , yes it will be very helpful if you review my code. I am attaching the code in .txt format.
Now I was trying to get all the links and delete one by one. So, now getting ModificationNotAllowed exception.
Thank you.

Hi @AK_10341824 

TEST_123, Test_123, B.1 (Design) is not checked out and cannot be modified.

I think that's why.

@Rocket_Max I am still getting following error even after Parent Part Checkout?
I even confirmed after printing checkout info to confirm if Parent part is getting checked out. 

2024-03-08 07:09:47,709 ERROR [RMI TCP Connection(11)-127.0.0.1] wt.pds.exception wcadminnonprod - Unable to perform delete for 1 records wt.fc.ModificationNotAllowedException: (wt.vc.wip.wipResource/5) wt.vc.wip.WorkInProgressException: LY107228, Engineering Layout Assembly, A.1 (PBOM_LX) is the original version of a working copy and cannot be modified.

Can you please help here?

Top Tags