Skip to content
Skip to breadcrumbs
Skip to header menu
Skip to action menu
Skip to quick search
Quick Search
Browse
Pages
Blog
Labels
Attachments
Mail
Advanced
What’s New
Space Directory
Feed Builder
Keyboard Shortcuts
Confluence Gadgets
Log In
Sign Up
Dashboard
Activiti
Copy Page
You are not logged in. Any changes you make will be marked as
anonymous
. You may want to
Log In
if you already have an account. You can also
Sign Up
for a new account.
This page is being edited by
.
Paragraph
Paragraph
Heading 1
Heading 2
Heading 3
Heading 4
Heading 5
Heading 6
Preformatted
Quote
Bold
Italic
Underline
More colours
Strikethrough
Subscript
Superscript
Monospace
Clear Formatting
Bullet list
Numbered list
Outdent
Indent
Align left
Align center
Align right
Link
Table
Insert
Insert Content
Image
Link
Attachment
Symbol
Emoticon
Wiki Markup
Horizontal rule
tinymce.confluence.insert_menu.macro_desc
Info
JIRA Issue
Status
Gallery
Tasklist
Table of Contents
Other Macros
Page Layout
No Layout
Two column (simple)
Two column (simple, left sidebar)
Two column (simple, right sidebar)
Three column (simple)
Two column
Two column (left sidebar)
Two column (right sidebar)
Three column
Three column (left and right sidebars)
Undo
Redo
Find/Replace
Keyboard Shortcuts Help
<p>As part of the <a href="https://wiki.jenkins-ci.org/display/JENKINS/Jenkow+Plugin">Jenkow Jenkins Plugin</a> which leverages the Activiti workflow engine for Jenkins job orchestration, I have added a new task type "Jenkins task" to the Activiti Modeler. Because unlike the Designer, the Modeler doesn't (yet) have a mechanism for incrementally adding new task types, I had to modify the Activiti code base. This Wiki page summarizes the changes I had to do. The enhanced Activiti code base is available on <a href="https://github.com/m2spring/Activiti/commits/jenkow-0.3.0">GitHub</a>. My enhancement is done on top of Activiti 5.11.</p><p>My new task type is mapped onto the existing ServiceTask, using a custom task delegate class at run time.</p><p>It's good to take an existing task type as the starting point. User task or script task is a good choice.</p><h3>The artwork</h3><p>The new artwork went into <code>modules/activiti-webapp-explorer2/src/main/webapp/editor/stencilsets/bpmn2.0/icons/jenkins</code>.</p><ul><li>Created an icon PNG file</li><li>Created a stencil SVG file<ul><li>I used Inkscape with "Save as Plain SVG"<ul><li>Manually copied the relevant <g> element (SVG group) defining the stencil logo into the desired stencil SVG. The SVG saved with Inkscape didn't fully work.</li><li>Initially my logo <g> element had a transform attribute which confused the Modeler's calculation of the stencil's bounding box. Ungrouping & regrouping made Inkscape remove the transform attribute and place the recalculated path coordinates into the <g> element. That solved the bounding box problem.</li><li>I had to add an oryx:anchors="top left" attribute to each path element, otherwise the logo would not remain intact when the stencil got resized.</li></ul></li></ul></li></ul><h3>New stencil</h3><p>In <code>modules/activiti-webapp-explorer2/src/main/resources/stencilset.json</code></p><ul><li><p>added a task base</p><table class="wysiwyg-macro" data-macro-name="code" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGV9&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre>{ "name" : "mynewtaskbase", "properties" : [ { "id" : "mytaskprop1", "type" : "String", "title" : "My Task Prop One", "value" : "", "description" : "One and only property of my new task", "popular" : true } ] } </pre></td></tr></table></li><li><p>added the actual task</p><table class="wysiwyg-macro" data-macro-name="code" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGV9&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre>{ "type" : "node", "id" : "MyNewTask", "title" : "My new task", "description" : "Does something new", "view" : "mynewtask/mynewtask.svg", "icon" : "mynewtask/mynewtask.png", "groups" : [ "My New Group" ], "propertyPackages" : [ "elementbase", "baseattributes", "mynewtaskbase" ], "roles" : [ "sequence_start", "Activity", "sequence_end", "ActivitiesMorph", "all" ] } </pre></td></tr></table><p>I don't fully understand the semantics of all existing propertyPackages.</p></li></ul><h3>Java Code</h3><p>Declared a new stencil name constant in <code>modules/activiti-json-converter/src/main/java/org/activiti/editor/constants/StencilConstants.java</code>:</p><table class="wysiwyg-macro" data-macro-name="code" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGV9&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre>final String STENCIL_TASK_MYNEW = "MyNewTask"; </pre></td></tr></table><p>The heavy lifting is done by a new class <code>modules/activiti-json-converter/src/main/java/org/activiti/editor/language/json/converter/MyNewTaskJsonConverter.java</code>. It is added to the existing converters in <code>modules/activiti-json-converter/src/main/java/org/activiti/editor/language/json/converter/BpmnJsonConverter.java</code> by calling <code>MyNewTaskJsconConverter.fillTypes()</code> in the static initializer. It's important to also add the stencil name into the right <code>DI_</code>... shape map, otherwise edges to the new stencil miss a waypoint.</p><table class="wysiwyg-macro" data-macro-name="code" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGV9&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre>DI_RECTANGLES.add(STENCIL_TASK_MYNEW); </pre></td></tr></table><p>Here, the method <code>convertJsonToElement()</code> is used to populate a ServiceTask model object which later gets converted into XML.</p><p>Added another element in the static initializer of the diagram generator <code>modules/activiti-engine/src/main/java/org/activiti/engine/impl/bpmn/diagram/ProcessDiagramGenerator.java</code>:</p><table class="wysiwyg-macro" data-macro-name="code" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGV9&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre> // my new task activityDrawInstructions.put("myNewTask", new ActivityDrawInstruction() { public void draw(ProcessDiagramCanvas processDiagramCreator, ActivityImpl activityImpl) { processDiagramCreator.drawScriptTask((String) activityImpl.getProperty("name"), activityImpl.getX(), activityImpl.getY(), activityImpl.getWidth(), activityImpl.getHeight()); } }); </pre></td></tr></table><h3>Import</h3><p>Adding support for importing processes with a new task type is a bit more complicated in this case, because the Jenkins task is internally mapped to the Service Task.</p><p>I had to hard-code logic into the</p><p>As part of the <a href="https://wiki.jenkins-ci.org/display/JENKINS/Jenkow+Plugin">Jenkow Jenkins Plugin</a> which leverages the Activiti workflow engine for Jenkins job orchestration, I have added a new task type "Jenkins task" to the Activiti Modeler. Because unlike the Designer, the Modeler doesn't (yet) have a mechanism for incrementally adding new task types, I had to modify the Activiti code base. This Wiki page summarizes the changes I had to do. The enhanced Activiti code base is available on <a href="https://github.com/m2spring/Activiti/commits/jenkow-0.3.0">GitHub</a>. My enhancement is done on top of Activiti 5.11.</p><p>My new task type is mapped onto the existing ServiceTask, using a custom task delegate class at run time.</p><p>It's good to take an existing task type as the starting point. User task or script task is a good choice.</p><h3>The artwork</h3><p>The new artwork went into <code>modules/activiti-webapp-explorer2/src/main/webapp/editor/stencilsets/bpmn2.0/icons/jenkins</code>.</p><ul><li>Created an icon PNG file</li><li>Created a stencil SVG file<ul><li>I used Inkscape with "Save as Plain SVG"<ul><li>Manually copied the relevant <g> element (SVG group) defining the stencil logo into the desired stencil SVG. The SVG saved with Inkscape didn't fully work.</li><li>Initially my logo <g> element had a transform attribute which confused the Modeler's calculation of the stencil's bounding box. Ungrouping & regrouping made Inkscape remove the transform attribute and place the recalculated path coordinates into the <g> element. That solved the bounding box problem.</li><li>I had to add an <a>oryx:anchors="top</a> left" attribute to each path element, otherwise the logo would not remain intact when the stencil got resized.</li></ul></li></ul></li></ul><h3>New stencil</h3><p>In <code>modules/activiti-webapp-explorer2/src/main/resources/stencilset.json</code></p><ul><li><p>added a task base</p><table class="wysiwyg-macro" data-macro-name="code" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGV9&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre>{ "name" : "mynewtaskbase", "properties" : [ { "id" : "mytaskprop1", "type" : "String", "title" : "My Task Prop One", "value" : "", "description" : "One and only property of my new task", "popular" : true } ] } </pre></td></tr></table></li><li><p>added the actual task</p><table class="wysiwyg-macro" data-macro-name="code" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGV9&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre>{ "type" : "node", "id" : "MyNewTask", "title" : "My new task", "description" : "Does something new", "view" : "mynewtask/mynewtask.svg", "icon" : "mynewtask/mynewtask.png", "groups" : [ "My New Group" ], "propertyPackages" : [ "elementbase", "baseattributes", "mynewtaskbase" ], "roles" : [ "sequence_start", "Activity", "sequence_end", "ActivitiesMorph", "all" ] } </pre></td></tr></table><p>I don't fully understand the semantics of all existing propertyPackages.</p></li></ul><h3>Java Code</h3><p>Declared a new stencil name constant in <code>modules/activiti-json-converter/src/main/java/org/activiti/editor/constants/StencilConstants.java</code>:</p><table class="wysiwyg-macro" data-macro-name="code" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGV9&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre>final String STENCIL_TASK_MYNEW = "MyNewTask"; </pre></td></tr></table><p>The heavy lifting is done by a new class <code>modules/activiti-json-converter/src/main/java/org/activiti/editor/language/json/converter/MyNewTaskJsonConverter.java</code>. It is added to the existing converters in <code>modules/activiti-json-converter/src/main/java/org/activiti/editor/language/json/converter/BpmnJsonConverter.java</code> by calling <code>MyNewTaskJsconConverter.fillTypes()</code> in the static initializer. It's important to also add the stencil name into the right <code>DI_</code>... shape map, otherwise edges to the new stencil miss a waypoint.</p><table class="wysiwyg-macro" data-macro-name="code" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGV9&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre>DI_RECTANGLES.add(STENCIL_TASK_MYNEW); </pre></td></tr></table><p>Here, the method <code>convertJsonToElement()</code> is used to populate a ServiceTask model object which later gets converted into XML.</p><p>Added another element in the static initializer of the diagram generator <code>modules/activiti-engine/src/main/java/org/activiti/engine/impl/bpmn/diagram/ProcessDiagramGenerator.java</code>:</p><table class="wysiwyg-macro" data-macro-name="code" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGV9&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre> // my new task activityDrawInstructions.put("myNewTask", new ActivityDrawInstruction() { public void draw(ProcessDiagramCanvas processDiagramCreator, ActivityImpl activityImpl) { processDiagramCreator.drawScriptTask((String) activityImpl.getProperty("name"), activityImpl.getX(), activityImpl.getY(), activityImpl.getWidth(), activityImpl.getHeight()); } }); </pre></td></tr></table><h3>Import</h3><p>Adding support for importing processes with a new task type is a bit more complicated in this case, because the Jenkins task is internally mapped to the Service Task.</p><p>I had to hard-code logic into the</p><p>As part of the <a href="https://wiki.jenkins-ci.org/display/JENKINS/Jenkow+Plugin">Jenkow Jenkins Plugin</a> which leverages the Activiti workflow engine for Jenkins job orchestration, I have added a new task type "Jenkins task" to the Activiti Modeler. Because unlike the Designer, the Modeler doesn't (yet) have a mechanism for incrementally adding new task types, I had to modify the Activiti code base. This Wiki page summarizes the changes I had to do. The enhanced Activiti code base is available on <a href="https://github.com/m2spring/Activiti/commits/jenkow-0.3.0">GitHub</a>. My enhancement is done on top of Activiti 5.11.</p><p>My new task type is mapped onto the existing ServiceTask, using a custom task delegate class at run time.</p><p>It's good to take an existing task type as the starting point. User task or script task is a good choice.</p><h3>The artwork</h3><p>The new artwork went into <code>modules/activiti-webapp-explorer2/src/main/webapp/editor/stencilsets/bpmn2.0/icons/jenkins</code>.</p><ul><li>Created an icon PNG file</li><li>Created a stencil SVG file<ul><li>I used Inkscape with "Save as Plain SVG"<ul><li>Manually copied the relevant <g> element (SVG group) defining the stencil logo into the desired stencil SVG. The SVG saved with Inkscape didn't fully work.</li><li>Initially my logo <g> element had a transform attribute which confused the Modeler's calculation of the stencil's bounding box. Ungrouping & regrouping made Inkscape remove the transform attribute and place the recalculated path coordinates into the <g> element. That solved the bounding box problem.</li><li>I had to add an <a>oryx:anchors="top</a> left" attribute to each path element, otherwise the logo would not remain intact when the stencil got resized.</li></ul></li></ul></li></ul><h3>New stencil</h3><p>In <code>modules/activiti-webapp-explorer2/src/main/resources/stencilset.json</code></p><ul><li><p>added a task base</p><table class="wysiwyg-macro" data-macro-name="code" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGV9&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre>{ "name" : "mynewtaskbase", "properties" : [ { "id" : "mytaskprop1", "type" : "String", "title" : "My Task Prop One", "value" : "", "description" : "One and only property of my new task", "popular" : true } ] } </pre></td></tr></table></li><li><p>added the actual task</p><table class="wysiwyg-macro" data-macro-name="code" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGV9&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre>{ "type" : "node", "id" : "MyNewTask", "title" : "My new task", "description" : "Does something new", "view" : "mynewtask/mynewtask.svg", "icon" : "mynewtask/mynewtask.png", "groups" : [ "My New Group" ], "propertyPackages" : [ "elementbase", "baseattributes", "mynewtaskbase" ], "roles" : [ "sequence_start", "Activity", "sequence_end", "ActivitiesMorph", "all" ] } </pre></td></tr></table><p>I don't fully understand the semantics of all existing propertyPackages.</p></li></ul><h3>Java Code</h3><p>Declared a new stencil name constant in <code>modules/activiti-json-converter/src/main/java/org/activiti/editor/constants/StencilConstants.java</code>:</p><table class="wysiwyg-macro" data-macro-name="code" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGV9&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre>final String STENCIL_TASK_MYNEW = "MyNewTask"; </pre></td></tr></table><p>The heavy lifting is done by a new class <code>modules/activiti-json-converter/src/main/java/org/activiti/editor/language/json/converter/MyNewTaskJsonConverter.java</code>. It is added to the existing converters in <code>modules/activiti-json-converter/src/main/java/org/activiti/editor/language/json/converter/BpmnJsonConverter.java</code> by calling <code>MyNewTaskJsconConverter.fillTypes()</code> in the static initializer. It's important to also add the stencil name into the right <code>DI_</code>... shape map, otherwise edges to the new stencil miss a waypoint.</p><table class="wysiwyg-macro" data-macro-name="code" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGV9&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre>DI_RECTANGLES.add(STENCIL_TASK_MYNEW); </pre></td></tr></table><p>Here, the method <code>convertJsonToElement()</code> is used to populate a ServiceTask model object which later gets converted into XML.</p><p>Added another element in the static initializer of the diagram generator <code>modules/activiti-engine/src/main/java/org/activiti/engine/impl/bpmn/diagram/ProcessDiagramGenerator.java</code>:</p><table class="wysiwyg-macro" data-macro-name="code" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGV9&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre> // my new task activityDrawInstructions.put("myNewTask", new ActivityDrawInstruction() { public void draw(ProcessDiagramCanvas processDiagramCreator, ActivityImpl activityImpl) { processDiagramCreator.drawScriptTask((String) activityImpl.getProperty("name"), activityImpl.getX(), activityImpl.getY(), activityImpl.getWidth(), activityImpl.getHeight()); } }); </pre></td></tr></table><h3>Import</h3><p>Adding support for importing processes with a new task type is a bit more complicated in this case, because the Jenkins task is internally mapped to the Service Task.<br />I had to hard-code logic into modules/activiti-json-converter/src/main/java/org/activiti/editor/language/json/converter/ServiceTaskJsonConverter.java to get this mapping.<br /><a href="https://github.com/m2spring/Activiti/commit/317383d963eb94df89f439258c600b6a9a8104c1">details</a></p>
Please type the word appearing in the picture.
Attachments
Labels
Location
Watch this page
< Edit
Preview >
Loading…
Save
Cancel
Next hint
search
attachments
weblink
advanced