Liferay Devcon Presentation on Dynamic Forms with Liferay Workflow

3,797 views

Published on

In this presentation we first present an overview of Liferay workflow. How to define a worklfow and how to use it together with your custom assets. Then we show how to use workflow to manage a business process, in this case the processing of application forms. The forms are defined in Orbeon XForms and integrated into your Liferay portlet app using the Orbeon Proxy Portlet. It allows you to leverage the role-based user management for evaluation of the form submissions.

Published in: Technology
0 Comments
4 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
3,797
On SlideShare
0
From Embeds
0
Number of Embeds
93
Actions
Shares
0
Downloads
112
Comments
0
Likes
4
Embeds 0
No embeds

No notes for slide

Liferay Devcon Presentation on Dynamic Forms with Liferay Workflow

  1. 1. Dynamic forms processing with Liferay workflow Overview and lessons learnt Willem Vermeer Worth IT Den Haag, The Netherlands 10 October 2013
  2. 2. Presenter overview Willem Vermeer  Java developer  Based in The Netherlands  Working for Worth IT  Back-end oriented  Liferay enthusiast
  3. 3. Presentation overview  Kaleo Workflow overview + demo  Integration with Orbeon forms + demo
  4. 4. Kaleo Workflow “allows a user to define any number of simple to complex business processes/workflows, deploy them, and manage them through a portal interface. The processes have knowledge of users, groups and roles. You don’t have to write a single line of code to accomplish this: all you have to do is create a single XML document.”
  5. 5. WWW.LIFERAY.COM WWW.FACEBOOK.COOM/LIFERAY @LIFERAY Prerequisites Install Kaleo from Marketplace (CE or EE) into your Liferay Installation
  6. 6. WWW.LIFERAY.COM WWW.FACEBOOK.COOM/LIFERAY @LIFERAY Terminology A workflow - is a directed graph of states, tasks, transitions, actions and notifications - can be applied to Liferay Assets such as Web Content or even Custom Assets - is executed by an asynchronous engine
  7. 7. WWW.LIFERAY.COM WWW.FACEBOOK.COOM/LIFERAY @LIFERAY Start and finish A workflow - starts in an initial state - must finish at the end state - can contain any number of tasks, including parallel tasks (fork-join)
  8. 8. WWW.LIFERAY.COM WWW.FACEBOOK.COOM/LIFERAY @LIFERAY Task assignation A task can be assigned to - a certain user - a role Important: only user with assigned task can transition it to the next task or state
  9. 9. WWW.LIFERAY.COM WWW.FACEBOOK.COOM/LIFERAY @LIFERAY Example start submit review accepted rejectstate task user reviewerrole transition accept submit
  10. 10. WWW.LIFERAY.COM WWW.FACEBOOK.COOM/LIFERAY @LIFERAY Workflow Definition Liferay EE has a graphical editor to create/modify workflows
  11. 11. WWW.LIFERAY.COM WWW.FACEBOOK.COOM/LIFERAY @LIFERAY Workflow Definition Liferay EE has a graphical editor to create/modify workflows pulled from marketplace From Liferay Support: “Unfortunately we had to pull it from the Marketplace as many major issues were discovered with it.“
  12. 12. WWW.LIFERAY.COM WWW.FACEBOOK.COOM/LIFERAY @LIFERAY Workflow Definition Liferay EE has a graphical editor to create/modify workflows Liferay CE has XML pulled from marketplace From Liferay Support: “Unfortunately we had to pull it from the Marketplace as many major issues were discovered with it.“
  13. 13. WWW.LIFERAY.COM WWW.FACEBOOK.COOM/LIFERAY @LIFERAY Workflow definition part 1 <workflow-definition xmlns="urn:liferay.com:liferay-workflow_6.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:liferay.com:liferay-workflow_6.1.0 http://www.liferay.com/dtd/liferay-workflow-definition_6_1_0.xsd" > <name>DevCon Demo</name> <description>Workflow example</description> <version>1</version> <state> <name>created</name> <initial>true</initial> <transitions> <transition> <name>submit</name> <target>submit</target> </transition> </transitions> </state>
  14. 14. WWW.LIFERAY.COM WWW.FACEBOOK.COOM/LIFERAY @LIFERAY Workflow definition part 2 <task> <name>submit</name> <actions> <action> <name>submit</name> <script> <![CDATA[ Packages.com.liferay.portal.kernel.workflow.WorkflowStatusManagerUtil.updateStatus( Packages.com.liferay.portal.kernel.workflow.WorkflowConstants.toStatus("pending"), workflowContext ); ]]> </script> <script-language>javascript</script-language> <execution-type>onAssignment</execution-type> </action> </actions> <assignments> <user /> </assignments> <transitions> <transition> <name>submit</name> <target>review</target> </transition> </transitions> </task>
  15. 15. WWW.LIFERAY.COM WWW.FACEBOOK.COOM/LIFERAY @LIFERAY Workflow definition part 3 <task> <name>review</name> <actions> <notification> <name>Review Notification</name> <template>You have a new submission waiting for your review in the workflow.</template> <template-language>text</template-language> <notification-type>email</notification-type> <execution-type>onAssignment</execution-type> </notification> </actions> <assignments> <roles> <role> <role-type>regular</role-type> <name>Application Reviewer</name> </role> </roles> </assignments> <!-- left out the transitions --> </task>
  16. 16. WWW.LIFERAY.COM WWW.FACEBOOK.COOM/LIFERAY @LIFERAY Workflow definition part 4 <state> <name>approved</name> <actions> <action> <name>approve</name> <script> <![CDATA[ Packages.com.liferay.portal.kernel.workflow.WorkflowStatusManagerUtil. updateStatus( Packages.com.liferay.portal.kernel.workflow.WorkflowConstants. toStatus("approved"), workflowContext);]]> </script> <script-language>javascript</script-language> <execution-type>onEntry</execution-type> </action> </actions> </state> </workflow-definition>
  17. 17. WWW.LIFERAY.COM WWW.FACEBOOK.COOM/LIFERAY @LIFERAY Demo app Extremely simplified version of customer case CreateApplication portlet to apply for a grant ListApplication portlet to display overview of applications DEMO
  18. 18. WWW.LIFERAY.COM WWW.FACEBOOK.COOM/LIFERAY @LIFERAY How to apply a workflow to a custom asset your portlet app WorkflowHandler workflow engine
  19. 19. WWW.LIFERAY.COM WWW.FACEBOOK.COOM/LIFERAY @LIFERAY Workflow handler declaration In liferay-portlet.xml add the following to your portlet: <portlet> .. <workflow-handler> demo.workflow.ApplicationWorkflowHandler </workflow-handler> .. </portlet>
  20. 20. WWW.LIFERAY.COM WWW.FACEBOOK.COOM/LIFERAY @LIFERAY Workflow handler public abstract interface WorkflowHandler { public String getClassName(); public abstract java.lang.Object updateStatus( int status, Map workflowContext) throws PortalException, SystemException; // more... }
  21. 21. WWW.LIFERAY.COM WWW.FACEBOOK.COOM/LIFERAY @LIFERAY Workflow handler implementation @Override public Object updateStatus(int status, Map<String, Serializable> workflowContext) throws PortalException, SystemException { Object applicationId = workflowContext.get(WorkflowConstants.CONTEXT_ENTRY_CLASS_PK); long appId = Long.parseLong(applicationId.toString()); Application application = ApplicationLocalServiceUtil.fetchApplication(appId); application.setStatus(status); return ApplicationLocalServiceUtil.updateApplication(application); }
  22. 22. WWW.LIFERAY.COM WWW.FACEBOOK.COOM/LIFERAY @LIFERAY Workflow handler invocation <action> <name>submit</name> <script> <![CDATA[ Packages.com.liferay.portal.kernel.workflow. WorkflowStatusManagerUtil.updateStatus( Packages.com.liferay.portal.kernel.workflow. WorkflowConstants.toStatus("pending"), workflowContext); ]]> </script> <script-language>javascript</script-language> <execution-type>onAssignment</execution-type> </action>
  23. 23. WWW.LIFERAY.COM WWW.FACEBOOK.COOM/LIFERAY @LIFERAY How to start the workflow ServiceContext serviceContext = ServiceContextFactory.getInstance( Application.class.getName(), request); Map<String, Serializable> context = new HashMap<String, Serializable>(); context.put(WorkflowConstants.CONTEXT_ENTRY_CLASS_NAME, Application.class.getName()); context.put(WorkflowConstants.CONTEXT_ENTRY_CLASS_PK, Long.toString(app.getApplicationId())); context.put(WorkflowConstants.CONTEXT_SERVICE_CONTEXT, serviceContext); WorkflowInstanceManagerUtil.startWorkflowInstance( companyId, groupId, userId, workflowDefinitionName, workflowDefinitionVersion, phase, context);
  24. 24. WWW.LIFERAY.COM WWW.FACEBOOK.COOM/LIFERAY @LIFERAY How to move the workflow WorkflowTaskManagerUtil.completeWorkflowTask( companyId, owningUserId, workflowTaskId, nextPhase, // "submit" or "reject" or .. "comment", context );
  25. 25. WWW.LIFERAY.COM WWW.FACEBOOK.COOM/LIFERAY @LIFERAY How to assign a task to a user WorkflowTaskManagerUtil.assignWorkflowTaskToUser( companyId, userId, // owner workflowTaskId, userId, // assignee "comment", dueDate, context // can be an empty Map );
  26. 26. WWW.LIFERAY.COM WWW.FACEBOOK.COOM/LIFERAY @LIFERAY How to re-assign a task to another user long[] userIds = WorkflowTaskManagerUtil.getPooledActorsIds( companyId, workflowTaskId );
  27. 27. WWW.LIFERAY.COM WWW.FACEBOOK.COOM/LIFERAY @LIFERAY Integration with Orbeon XForms Orbeon Forms Builder & Forms Runner Proxy portlet to execute the form runner Combination with workflow
  28. 28. WWW.LIFERAY.COM WWW.FACEBOOK.COOM/LIFERAY @LIFERAY Orbeon Xforms Builder Insert User Group Logo (please resize)
  29. 29. WWW.LIFERAY.COM WWW.FACEBOOK.COOM/LIFERAY @LIFERAY Integration with Orbeon - architecture Insert User Group Logo (please resize) application group page proxy portlet custom portlet (drives workflow) javascript
  30. 30. WWW.LIFERAY.COM WWW.FACEBOOK.COOM/LIFERAY @LIFERAY Integration with Orbeon - demo DEMO
  31. 31. WWW.LIFERAY.COM WWW.FACEBOOK.COOM/LIFERAY @LIFERAY Things to like about Kaleo workflow Nice, deep integration with Liferay (users, roles) Control panel access to workflow tasks Simplicity
  32. 32. WWW.LIFERAY.COM WWW.FACEBOOK.COOM/LIFERAY @LIFERAY Room for improvement Extensibility - limited to scripting in workflow definition Flexibility - can't change definition once a workflow has started Thread safety - workflow engine is thread UNsafe Error recovery - What's wrong with my XML?
  33. 33. WWW.LIFERAY.COM WWW.FACEBOOK.COOM/LIFERAY @LIFERAY Questions? @willemvermeer For more information on Orbeon please visit orbeon.com

×