How to capture revision event of WTObject?

爱⌒轻易说出口 提交于 2021-02-07 10:22:26

问题


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.


回答1:


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)



来源:https://stackoverflow.com/questions/15429038/how-to-capture-revision-event-of-wtobject

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!