Search code examples
apiserviceptc-windchill

wt.vc.VersionControlServiceEvent.NEW_VERSION


I have a windchill service from which I'm capturing the revision event.I'm using the API VersionControlServiceEvent.NEW_VERSION

But this event is capturing both checkout and revision event.I need to capture only the revise event.How to modify this to capture revise event alone or Is there any other API to do that.I need some help

Thanks


Solution

  • Starting from my previous answer (here), you just need to test the status of the target object :

    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))
        {
            //Check if the object is checkedOut
            if (target instanceof Workable && WorkInProgressHelper.isCheckedOut((Workable)target) {
                 return;
            }
    
            /** Call your business code here 
                example : yourMethod(target);
             **/
        }
    }