The Learning PathwayActions Rules and Simple and Advanced Workflow Integration Use CasesJörg Sauer
The longest title ever Actions, Rules and Simple and Advanced Workflow Integration Use Casesis about Actions to extend Alfresco functionality Rules to automate execution of Actions Use Simple Workflows to implement a Workflow without coding Add Rules to run certain Actions in Workflow steps Use a simple Advanced Workflow to leverage Tasks in Simple Workflows
Basic Example to be extended Review Publish Workflow with 2 phase approval review approve publish reject 1 Drafts 3 Approve 4 Published 2 Review reject
Simple Workflow Pros: User can build workflow Easy to understand Cons: No State: Implicit state by location (folder) No Task: Implicit task by folder access No branching: Serial workflow only review approve publish reject 1 Drafts 3 Approve 4 Published 2 Review reject
Adding Status Content Model: Provide custom Aspect to hold workflow status
Amend Workflow with status Set Status on each workflow folder Add Aspect: Workflow Status Set workflow status accordingly reject review approve publish reject 1 Drafts 3 Approve 4 Published 2 Review
Alfresco Repository Actions Action: Unit of work that is performed against a node Examples: Move node Transform content of node Send email Out of the Box Actions Custom Actions Implement own Action class Deploy in Application Context
Intention: Create User Task Every time simple workflow is assigned, create advanced workflow task for specific user. User can access task in task list see task description access attached document approve or reject directly from within task Advantage No notification emails No need to check simple workflow folders
Simple Workflow Task Architecture Required: Custom aspect for task description.(attached to simple workflow folder) Advanced workflow to be started by rule Configure user Provide task Implement simple workflow actions for Approve Reject Bug Fix for Alfresco StartWorkflowActionExecuter UI for Rule Config
Content Model for Workflow Aspects: simpleWorflow: Manage Action Labels Content Types: simpleWfTaskStart: Properties for Start Task Assignee Task Description Simple Workflow Approve & Reject Action Labels All above become process variables! ApprovalOnlyTask: Task properties to approve document ApproveOrRejectTask: Properties for approving or rejecting the document Simplicity: all in sample model Best practice: own workflow model
Simple Process Definition Create Process Definition Graphically Change root tag: Add Swimlanes Add tasks to task node, will render UI
Workflow Deployment Attention: No actions implemented yet! But want to check if model is correct &workflow deploys Context file: Redeploy off on production systems!
Workflow Actions User decides in task to Approve Reject Workflow will transition to nodes approveDocument: code will approve simple workflow rejectDocument: code will reject simple workflow Todo: Implement Event Handler for node-enter event(approve / reject)
Code (sneaking) UI has actions for approve/reject Look for action definition in web-client-config-actions.xml Sample implementation can be found in DocumentDetailsDialog.approve() / reject() methods! OpenSource Rules!
Direct Code reuse Problem: From Package org.alfresco.web.bean Workflow Event not within web context. DocNode not core object Solution: Reprogram but use native Foundation Services API Should be fool proof ;-)
Lets get the event Define in Process Definition Derive from JBPMSpringActionHandler
What to Implement Where initializeHandler(): Get all services needed from the factory ServiceRegistry (in case you need something) NodeService to deal with the node CopyService to copy/move the document execute(): Get the process variables through executionContext Implement the approve / reject action
Hiding Reject Transition if Not Set Hide reject transition accordingly task-assign event (has to be this event!) use bpm:hiddenTransitions (bpm_hiddenTransitions)
Testing First Version Redeploy Manually start Simple Workflow Task workflow Fill in all details in the start form Test both scenarios: Approval only (reject transition hidden?) Approve or Reject Task should show up in task list Open Task and pick Action Check if document has been moved / copied according to Simple Workflow configuration.
Final Demo Configured Simple Workflow Add Rule to kick off Simple Workflow Task Workflow Push Document into folder with simple workflow. Review document status Search for documents with status Review task list Manage tasks See documents transition through simple workflow by using advanced workflows functionality
Resume Actions extend Alfresco Simple workflows can be configured easily Rules are the binding glue Small advanced workflows can be leveraged in actions and simple workflows. Your imagination is the border Alfresco OpenSource helps you to code and find solutions to your problems.
Resources Training Alfresco API Development Course (3 days) Alfresco Workflow Course (2 days) Alfresco (API) Documentation http://docs.alfresco.com/3.4/index.jsp Wiki Resources http://wiki.alfresco.com/wiki/Data_Dictionary_Guide http://wiki.alfresco.com/wiki/Custom_Actions http://wiki.alfresco.com/wiki/Custom_Action_UI http://wiki.alfresco.com/wiki/Workflow http://wiki.alfresco.com/wiki/WorkflowAdministration Books Alfresco Developer Guide (Packt Publishing) Professional Alfresco (Wrox Press)
Questions? Email: email@example.com Twitter: joergsauer In Person: DevCon 2011 London
Have you got your ticket yet? DevCon Americas 201126-27th October at the Hard Rock Hotel, San Diego, CA Get some preconference training in on 25th October choose from Jump Start or Advanced Alfresco ∞∞∞∞∞∞∞∞∞ DevCon EMEA & APAC 20119-10th November at Prospero House, Central London, UKGet some preconference training in on 8th Novemberchoose from Jump Start or Advanced Alfresco