cancel
Showing results for 
Search instead for 
Did you mean: 

How to extend Modeler?

m2spring
Champ in-the-making
Champ in-the-making
I want to add my own task type to the Modeler palette.
Is there a good example I can follow?
I was told Modeler accepts the same extensions as Designer, but I'm unclear how to get started on this.
Thanks!
-Max
21 REPLIES 21

jbarrez
Star Contributor
Star Contributor
Afaik, the modeler uses 'stencilsets' and it should be easy to add new stuff to. At least that is what Tijs sold us 😉

I'll ping him to answer.

trademak
Star Contributor
Star Contributor
Hi,

With the stencilset.json file you can create every element and attribute group you want, so in that sense it has all capabilities.
You would need some coding for translating the Modeler JSON of a new element to a Java class and then to BPMN XML (and vice versa if you need that).
I'll see if I can put together a tutorial for that.

Best regards,

m2spring
Champ in-the-making
Champ in-the-making
Hi Tijs,

yes, if you could provide a little example that would be great.

Will this work incrementally, i.e. can I just add another webapp, or do I need to modify the existing webapp?

Thanks!
-Max

trademak
Star Contributor
Star Contributor
Hi Max,

You can add another webapp and use the activiti-modeler module, that should work.

Best regards,

m2spring
Champ in-the-making
Champ in-the-making
Hi Tijs,

I make some progress in extending the Modeler.

So far I have basically "hacked" my extension into the activiti-webapp-explorer2 module by copying&modifying the script task definitions.
That gives me something in the Modeler editor.
I'm still unclear how I would do this by giving another webapp, but that's a minor problem at the moment.

I'm now trying to do a similar "hack" in the activiti-bpmn-converter and activiti-bpmn-model modules, by copying&modifying what's there for script task.
It doesn't feel right, though, because with Designer my extension ended up as a serviceTask.
So I guess I should also get a serviceTask with a Modeler extension, right?

Can you please give me some word of advice here?

Thanks!
-Max

trademak
Star Contributor
Star Contributor
Hi,

If you change the activiti-json-converter and the stencilset.json you can create every BPMN element you want for your custom palette element.
So if you want to have a service task then you can transform your custom element to a service task in the activiti-json-converter.

Best regards,

m2spring
Champ in-the-making
Champ in-the-making
I made some progress.
I added a JenkinsTaskJsonConverter which populates a ServiceTask object.

There's a strange problem when I try to deploy this workflow, though.
[img]http://dl.dropbox.com/u/1917727/20130125-131922.png[/img]

(I'm using the user task's SVG for the time being, until I have figured out the proper "art work".)


<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlnsSmiley Surprisedmgdc="http://www.omg.org/spec/DD/20100524/DC" xmlnsSmiley Surprisedmgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/test">
  <process id="process" name="process1" isExecutable="true">
    <startEvent id="sid-2BB933AE-E0AE-48D2-9ACC-B5EC35AD3687"></startEvent>
    <sequenceFlow id="sid-974EF4BD-0E76-4983-B84D-FA92053B98DC" sourceRef="sid-2BB933AE-E0AE-48D2-9ACC-B5EC35AD3687" targetRef="jtID"></sequenceFlow>
    <endEvent id="sid-65043A85-6BAD-4616-AD1E-FF3FA8D64D4B"></endEvent>
    <serviceTask id="jtID" name="jenkins task" activiti:exclusive="false" activiti:class="com.cisco.step.jenkins.plugins.jenkow.JenkinsTaskDelegate">
      <documentation>docs</documentation>
      <extensionElements>
        <activiti:field name="jobName" stringValue="launchee"></activiti:field>
        <activiti:field name="isManualJobLaunchMode" stringValue="true"></activiti:field>
      </extensionElements>
    </serviceTask>
    <sequenceFlow id="sid-BDAE7F44-F378-4981-8857-6ADA7C191757" sourceRef="jtID" targetRef="sid-65043A85-6BAD-4616-AD1E-FF3FA8D64D4B"></sequenceFlow>
  </process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_process">
    <bpmndi:BPMNPlane bpmnElement="process" id="BPMNPlane_process">
      <bpmndi:BPMNShape bpmnElement="sid-2BB933AE-E0AE-48D2-9ACC-B5EC35AD3687" id="BPMNShape_sid-2BB933AE-E0AE-48D2-9ACC-B5EC35AD3687">
        <omgdc:Bounds height="30.0" width="30.0" x="139.5" y="130.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="jtID" id="BPMNShape_jtID">
        <omgdc:Bounds height="80.0" width="100.0" x="240.0" y="105.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="sid-65043A85-6BAD-4616-AD1E-FF3FA8D64D4B" id="BPMNShape_sid-65043A85-6BAD-4616-AD1E-FF3FA8D64D4B">
        <omgdc:Bounds height="28.0" width="28.0" x="390.0" y="131.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge bpmnElement="sid-974EF4BD-0E76-4983-B84D-FA92053B98DC" id="BPMNEdge_sid-974EF4BD-0E76-4983-B84D-FA92053B98DC">
        <omgdi:waypoint x="169.5" y="145.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="sid-BDAE7F44-F378-4981-8857-6ADA7C191757" id="BPMNEdge_sid-BDAE7F44-F378-4981-8857-6ADA7C191757">
        <omgdi:waypoint x="390.0" y="145.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</definitions>

It gives this exception:

SEVERE: Error while closing command context
org.activiti.engine.ActivitiException: cvc-complex-type.2.4.b: The content of element 'bpmndi:BPMNEdge' is not complete. One of '{"http://www.omg.org/spec/DD/20100524/DI':waypoint}' is expected. | Demo model.bpmn20.xml | line 29 | column 25
cvc-complex-type.2.4.b: The content of element 'bpmndi:BPMNEdge' is not complete. One of '{"http://www.omg.org/spec/DD/20100524/DI':waypoint}' is expected. | Demo model.bpmn20.xml | line 32 | column 25
Minimum 2 waypoint elements must be definted for a 'BPMNEdge' | Demo model.bpmn20.xml | line 27 | column 134
Minimum 2 waypoint elements must be definted for a 'BPMNEdge' | Demo model.bpmn20.xml | line 30 | column 134

        at org.activiti.engine.impl.util.xml.Parse.throwActivitiExceptionForErrors(Parse.java:186)
        at org.activiti.engine.impl.bpmn.parser.BpmnParse.execute(BpmnParse.java:242)
        at org.activiti.engine.impl.bpmn.deployer.BpmnDeployer.deploy(BpmnDeployer.java:92)
        at org.activiti.engine.impl.persistence.deploy.DeploymentCache.deploy(DeploymentCache.java:38)
        at org.activiti.engine.impl.persistence.entity.DeploymentManager.insertDeployment(DeploymentManager.java:44)
        at org.activiti.engine.impl.cmd.DeployCmd.execute(DeployCmd.java:61)
        at org.activiti.engine.impl.cmd.DeployCmd.execute(DeployCmd.java:33)
        at org.activiti.engine.impl.interceptor.CommandExecutorImpl.execute(CommandExecutorImpl.java:24)
        at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:60)
        at org.activiti.spring.SpringTransactionInterceptor$1.doInTransaction(SpringTransactionInterceptor.java:42)
        at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:130)
        at org.activiti.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:40)
        at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:32)
        at org.activiti.engine.impl.RepositoryServiceImpl.deploy(RepositoryServiceImpl.java:68)
        at org.activiti.engine.impl.repository.DeploymentBuilderImpl.deploy(DeploymentBuilderImpl.java:119)
        at org.activiti.editor.ui.EditorProcessDefinitionDetailPanel.deployModel(EditorProcessDefinitionDetailPanel.java:256)
        at org.activiti.editor.ui.EditorProcessDefinitionDetailPanel$1.valueChange(EditorProcessDefinitionDetailPanel.java:153)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:490)
        at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:164)
        at com.vaadin.ui.AbstractComponent.fireEvent(AbstractComponent.java:1193)
        at com.vaadin.ui.AbstractField.fireValueChange(AbstractField.java:891)
        at com.vaadin.ui.AbstractField.setValue(AbstractField.java:529)
        at com.vaadin.ui.AbstractSelect.setValue(AbstractSelect.java:666)
        at com.vaadin.ui.Select.changeVariables(Select.java:658)
        at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.handleVariableBurst(AbstractCommunicationManager.java:1299)
        at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.handleVariables(AbstractCommunicationManager.java:1219)
        at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.doHandleUidlRequest(AbstractCommunicationManager.java:735)
        at com.vaadin.terminal.gwt.server.CommunicationManager.handleUidlRequest(CommunicationManager.java:296)
        at com.vaadin.terminal.gwt.server.AbstractApplicationServlet.service(AbstractApplicationServlet.java:501)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
        at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
        at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:390)
        at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
        at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
        at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
        at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
        at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:230)
        at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
        at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
        at org.mortbay.jetty.Server.handle(Server.java:326)
        at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
        at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:943)
        at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:756)
        at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
        at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
        at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:410)
        at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)

What could be the cause?

-Max

trademak
Star Contributor
Star Contributor
Hi Max,

Are you using the current Github master version of the Modeler?
Can you sent me your source code so I can give it a try?

Best regards,

m2spring
Champ in-the-making
Champ in-the-making
Hi Tijs,
I forked Activiti on Github and put my changes on a new branch "jenkow-0.3.0" from off branch "activiti-511":
https://github.com/m2spring/Activiti/commits/jenkow-0.3.0
Regards,
-Max