1

I am using Windchill 10.0 M030. I have created a windchill service that captures some actions. I am done with capturing the delete, checkin, and state change events, but I don't know how to capture the revision event of an object. Can someone help me out?

Some example code snippets would be helpful. The events that are working fine are the following:

public void notifyEvent(KeyedEvent event) throws RemoteException,
            WTException {


        if (event instanceof PersistenceManagerEvent) {
            notifyEvent((PersistenceManagerEvent) event);
        }
        if (event instanceof WorkInProgressServiceEvent) {
            notifyEvent((WorkInProgressServiceEvent) event);
        }
        if (event instanceof EPMWorkspaceManagerEvent) {
            notifyEvent((EPMWorkspaceManagerEvent) event);
        }

        if (event instanceof LifeCycleServiceEvent) {
            notifyEvent((LifeCycleServiceEvent) event);
        }
    }

Is there any separate event like Revise event to be captured in this way? How can I do that?

Thank you.

Mario Cervera
  • 671
  • 1
  • 8
  • 19
Vignesh Vino
  • 1,242
  • 4
  • 25
  • 50

1 Answers1

3

Here is the code for your ListenerAdapter :

public class VersionEventListenerAdapter extends ServiceEventListenerAdapter {

public VersionEventListenerAdapter(String serviceId) {
    super(serviceId);
}

public void notifyVetoableEvent(Object event) throws WTException, WTPropertyVetoException {
    if (!(event instanceof KeyedEvent)) {
        return;
    }

    Object target = ((KeyedEvent) event).getEventTarget();
    Object eventType = ((KeyedEvent) event).getEventType();

    if (eventType.equals(VersionControlServiceEvent.NEW_VERSION)
    {
       /** Call your business code here 
           example : yourMethod(target);
        **/
    }
}

And then the service to register the listener

public class MyStandardListenerService extends StandardManager implements MyListenerServiceInterface {

private static final long serialVersionUID = 1L;

protected synchronized void performStartupProcess() throws ManagerException {

    VersionEventListenerAdapter versionEventListenerAdapter = new VersionEventListenerAdapter(getName());
    getManagerService().addEventListener(versionEventListenerAdapter, VersionControlServiceEvent.generateEventKey(VersionControlServiceEvent.NEW_VERSION));

}

public static MyStandardListenerService newMyStandardListenerService() throws WTException {
    MyStandardListenerService instance = new MyStandardListenerService();
    instance.initialize();
    return instance;
}

This new service need to be registered in the wt.properties. See the customizer's guide for more details about how to register it (with xconfmanager command line utility)

Julien Boulay
  • 1,164
  • 7
  • 15
  • What jar file needed to include StandardManager, ManagerException, VersionEventListenerAdapter, VersionControlServiceEvent, WTException, etc? Can you please add more details to this post so that a beginner could figure it out? As usual, PTC documentation is abysmal. – user3217883 Jun 14 '18 at 14:55
  • @user3217883 you just have to configure your eclipse with windchill by following the steps given in the help center. That will import all the necessary libraries. In case you don't want to do that, then add all jars from codebase/WEB-INF/lib folder,jars from srclib folder and jars from WT_HOME/lib folder to your project's classpath. – Vignesh Vino Jan 23 '19 at 14:55