Skip to main content
6-Contributor
October 19, 2023
Solved

Windchill part Usagelink deletion using api

  • October 19, 2023
  • 2 replies
  • 3787 views

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.

 

 

 

 

Best answer by HelesicPetr

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

2 replies

HelesicPetr
22-Sapphire II
22-Sapphire II
October 19, 2023

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

6-Contributor
October 19, 2023

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

HelesicPetr
22-Sapphire II
22-Sapphire II
October 19, 2023

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

17-Peridot
October 19, 2023

Hello @AK_10341824 

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

 

What is the error reported?

If convenient, you can also provide your code

 

 

6-Contributor
October 19, 2023

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.

17-Peridot
October 19, 2023

Hi @AK_10341824 

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

I think that's why.