AnsweredAssumed Answered

Trying to call a ProcessValidator from Command

Question asked by igoyetche on Aug 6, 2014
Latest reply on Aug 17, 2014 by igoyetche

I'm trying to call a custom ProccesValidator of Activiti designer from a toolbar command, so I started with the example of ProcessValidator in GitHub "BPMN20ProcessValidator".
I took this code and added to it a Command to call the "validateDiagram(Diagram diagram, IProgressMonitor monitor)" Method, that I'm not sure if is it OK. After trying with a lot of things, to call this method with no success, I given up with this:

public Object execute(ExecutionEvent event) throws ExecutionException {
    final IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
    final IEditorPart activeEditor = window.getActivePage().getActiveEditor();
    ActivitiDiagramEditor editor = (ActivitiDiagramEditor) activeEditor;
    final IDiagramTypeProvider pro = editor.getDiagramTypeProvider();
    final Diagram diagram = pro.getDiagram();

    final ProcessValidator processValidator = (ProcessValidator) ExtensionPointUtil.getProcessValidator(PluginConstants.VALIDATOR_ID);   

    processValidator.validateDiagram(diagram, new NullProgressMonitor());

The problem with the code above is that when I obtain the processValidator I defined, it comes with the diagramWorkerContext in null, and it throws a NullReferenceException.

I searched in all the GitHub Activiti Designer code and I didn't find how could I set the diagramWorkerContext, so I'm starting to believe that I'm using it in a way that is not expected to use it.

My doubt is: how is expected way to use the processValidator??, exist any example of it??

Please I appreciate any help!!, I been trying to made this for weeks without luck and It's for a very important project.

Thanks in advance,