Serial Workflow – Alfresco

November 6th, 2009

What is workflow?

Workflow is an electronic routing of documents from one authorized person to another. A document does not become visible to the general public unless it’s approved by an authority. In large organizations, work is not managed by individuals but by te ams. So it is important to release the document through a proper channel.

In Alfresco business process is defined using the process definition. Process definition describes the states (steps) and transitions (choices) of a workflow. A step is a task which may be performed by a human- or system-based. Human steps create and assign tasks to users. System steps perform some kind of operation against the Alfresco repository.

In Open Source alfresco 2 categories of business process can be defined using jbpm those are Parallel and Serial workflow.

Parallel Workflow Process:

When files are submitted to a review workflow process, the files are reviewed by a set of approvers specified for the workflow process. in a parallel review workflow process, all approvers review the submitted files or request at the same time. The number of approvals or rejections for a completed approval or rejection is set in the Workflow tab of the folder or Library Properties window.

Serial Workflow Process:

When files are submitted to a review workflow process, the files are reviewed by a set of approvers specified for the workflow process. In a serial review workflow process, each approver reviews the submitted files or request in turn, one approver at a time. All reviewers must approve the request to complete the approval process; a single rejection ends the review process, and results in the request being rejected.

Steps to create Serial Workflow process:

Consider a scenario where generalized workflow is required in which a documents are sent for review sequentially and the number of reviewers varies ie from 1 and more.

Example: Initiator initiates the workflow and selects 3 reviewers. Task will go to each reviewers sequentially based on the previous reviewers decision. Each reviewer will have option of approve and reject. Approve will send the document to another reviewer and reject will send it to the previous reviewer if applicable otherwise to the initiator. Once everybody reviews the document task comes back to the initiator for final approval.

Key points in above scenario:

  • No of reviewers not fixed.
  • No of document not fixed.
  • Option to be provided for selecting multiple reviewers in the initiator screen.

Steps to implement Serial workflow:

1. Create Process Definition

There are two ways of building the process definition (as dictated by JBoss jBPM):

  • By hand i.e. create a jPDL xml document
  • By designer i.e. use a tool to generate the jPDL xml document (or process archive)

<?xml version=”1.0″ encoding=”UTF-8″?><process-definition xmlns=”urn:jbpm.org:jpdl-3.1″ name=”CustomReviewProcess”>

<swimlane name=”initiator” />

<start-state name=”start”>

<task  name=”ncm:startTask” description=”Submit Serial Review Task”

swimlane=”initiator”/>

<event type=”node-leave”>

<script>

<variable name=”approveCount” access=”write”/>

<expression>approveCount = 0;</expression>

</script>

</event>

<transition name=”Send For Review” to=”review”></transition>

</start-state>

<task-node name=”review”>

<task name=”wf:reviewTask” >

<assignment  class=”org.alfresco.repo.workflow.jbpm.AlfrescoAssignment”>

<actor>#{bpm_assignees.get(approveCount)}</actor>

</assignment>

<event type=”task-create”>

<script>System.out.println(”–Task—–first_review——”+approveCount+”—reviewerCount–”+reviewerCount);</script>

<script>

if (bpm_workflowDueDate != void) taskInstance.dueDate = bpm_workflowDueDate;

if (bpm_workflowPriority != void)  taskInstance.priority = bpm_workflowPriority;

</script>

</event>

</task>

<event type=”node-enter”>

<script>

<variable name=”reviewerCount”  access=”write”></variable>

<expression>reviewerCount = bpm_assignees.size();</expression>

</script>

</event>

<transition name=”Approved” to=”isLast”>

<script>

<variable name=”approveCount” access=”write”/>

<expression>approveCount =approveCount+1 ;</expression>

</script>

</transition>

<transition name=”Reject” to=”isFirst”>

<script>

<variable name=”approveCount” access=”write”/>

<expression>approveCount =approveCount – 1 ;</expression>

</script>

</transition>

</task-node>

<decision name=”isLast”>

<transition name=”No” to=”review”>

<condition> #{approveCount &lt; reviewerCount}</condition>

</transition>

<transition name=”Yes” to=”FinalSubmit”>

<condition> #{approveCount == reviewerCount}</condition>

</transition>

</decision>

<end-state name=”end” />

<decision name=”isFirst”>

<transition name=”No” to=”review”>

</transition>

<transition name=”Yes” to=”re_submit”>

<condition> #{approveCount &lt; 0 }</condition>

</transition>

</decision>

<task-node name=”re_submit”>

<task name=”wf:reviewTask” swimlane=”initiator” >

<event type=”task-create”>

<script>System.out.println(”–Task—–re_submit——”+approveCount+”—reviewerCount–”+reviewerCount);</script>

<script>

if (bpm_workflowDueDate != void) taskInstance.dueDate = bpm_workflowDueDate;

if (bpm_workflowPriority != void) taskInstance.priority = bpm_workflowPriority;

</script>

</event>

</task>

<transition name=”ReSubmit” to=”review”>

<script>

<variable name=”approveCount” access=”write”/>

<expression>approveCount =0 ;</expression>

</script>

</transition>

<transition name=”Finish” to=”end”></transition>

</task-node>

<task-node name=”FinalSubmit”  >

<task name=”wf:reviewTask” swimlane=”initiator” >

</task>

<transition name=”Finish” to=”end”></transition>

</task-node>

</process-definition>

2. Deploy the process definition in Alfresco Server.

3. Create Task Model for the workflow:

For each Task in the process definition (as defined by <task> elements in jPDL) it is possible to associate a Task description. The description specifies the information that may be attached to a Task i.e. properties (name and datatype) and associations (name and type of associated object). A user may view and edit this information in the Task dialog within the Alfresco Web Client.

4. Deploy the Task Model in Alfresco Server.

5. Configure the Web client

Go to the location <<tomcat_directory>>\shared\classes\alfresco\extension and add the following line of code in the web-client-config-custom.xml.

<config evaluator=”node-type” condition=”ncm:startTask” replace=”true”> <property-sheet>

<separator name=”sep1″ display-label-id=”general” component-generator=”HeaderSeparatorGenerator” />

<show-property name=”bpm:workflowDescription” component-generator=”TextAreaGenerator” />

<show-property name=”bpm:workflowPriority” display-label-id=”wf_review_priority” />

<show-property name=”bpm:workflowDueDate” display-label-id=”wf_review_due_date” />

<separator name=”sep2″ display-label-id=”users_and_roles” component-generator=”HeaderSeparatorGenerator” />

<show-association name=”bpm:assignees” display-label-id=”wf_reviewers” />

<separator name=”sep3″ display-label-id=”wf_review_options” component-generator=”HeaderSeparatorGenerator” />

<separator name=”sep2″ display-label-id=”wf_reviewers” component-generator=”HeaderSeparatorGenerator” />

<show-property name=”bpm:priority” read-only=”true” />

<separator name=”sep3″ display-label-id=”wf_review_options” component-generator=”HeaderSeparatorGenerator” />

<show-association name=”bpm:package” read-only=”true”/>

</property-sheet>

<condition-handlers>

<show-association name=”bpm:package” read-only=”true”/>

</condition-handlers>

</config>

6. Upload the updated web-client-config-custom.xml file at location Company Home > Data Dictionary > Web Client Extension.

7. Test the Workflow

Custom workflow definitions may be tested using one of the following methods:

  • Start the Alfresco Server and test via the Alfresco Web Client
  • Use the Workflow Console to interactively step through workflows

Alfresco on cloud Amazon EC2

November 6th, 2009

Cloud computing

Cloud computing is a term given for anything that involves in delivering hosted services over the wide area network. There are three categories for cloud computing services: Infrastructure-as-a-Service (IaaS), Platform-as-a-Service (PaaS) and Software-as-a-Service (SaaS).

There are three distinct characteristics that differentiate cloud computing from traditional hosting. It is sold on demand, typically by the minute or the hour; it is elastic — a user can have as much or as little of a service as they want at any given time; and the service is fully managed by the provider (the consumer needs nothing but a personal computer and Internet access).

Platform-as-a-service in the cloud is a set of software and product development tools hosted on the provider’s infrastructure. Developers create applications on the provider’s platform over the Internet. PaaS provider’s uses APIs, website portals or gateway software installed on the customer’s computer. Force.com, (an outgrowth of Salesforce.com) and GoogleApps are examples of PaaS.

In the software-as-a-service cloud model, the vendor supplies the hardware infrastructure, the software product and interacts with the user through a front-end portal. SaaS is a very broad market. Services can be anything from Web-based email to inventory control and database processing.

Infrastructure-as-a-Service like Amazon Web Services provides virtual server instances with unique IP addresses and blocks of storage on demand. Customers use the provider’s application program interface (API) to start, stop, access and configure their virtual servers and storage. In the enterprise, cloud computing allows a company to pay for only as much capacity as is needed, and bring more online as soon as required.

About Alfresco
Alfresco is the leading open source alternative for enterprise content management. The open source model allows Alfresco to use best-of-breed open source technologies and contributions from the open source community to get higher quality software produced more quickly at much lower cost.

The Benefits of Using Alfresco

  • Ease-of-Use
  • Intelligent Virtual File System – As simple to use as a shared drive through CIFS, WebDAV or FTP
  • Google®-Like Search and Yahoo!®-Like Folder Browsing
  • Distributed Architecture

Alfresco is not just an application, but also a platform on top of which SaaS providers can build new apps and services.

Amazon EC2
Amazon Elastic Compute Cloud (Amazon EC2) is a web service that provides resizable compute capacity in the cloud. Amazon EC2’s simple web service interface allows you to obtain and configure capacity with minimal friction. It provides you with complete control of your application resources and lets you run on it’s proven computing environment.

It enables customers to rent processing space by the hour on which to run their own applications. The Alfresco’s offering is an AMI (Amazon Machine Image), a pre-built software package for creating a virtual machine on EC2.

Benefit of Alfresco on Amazon EC2
Cloud allows you to provision preconfigured ECM on demand and scale it dynamically, thus reducing total ownership costs considerably.

How to Cluster Alfresco on Amazon EC2:

Run management instance for clustering Alfresco.

ElasticFox can be used as extension for configuring basic tasks on EC2. Run instance of Amazon Machine Image ami-68af4b01. After state of the instance changes from pending to running, obtain the Public DNS and open it into browser address bar. This will bring Web User Interface for Alfresco Cluster Management. Login the application with following credentials: username alfresco, password alfresco.

Following left navigation options will be available on the screen:

* Add New Alfresco Cluster

* Alfresco Cluster Home

* Cluster Provisioning Status

* General Settings

* List All Alfresco Clusters

* Provision Alfresco Cluster Nodes

EC2 credentials Configuration:

Using client like Putty or other ssh client, log in to Public DNS address and download your key files to dedicated path (e.g. /root).

Now Edit following file /var/www/sites/all/modules/alfresco_ec2/ws-amazon-ec2-client.php and add names of your key files.

Configure minimal cluster.

At this point alfresco application is ready to configure minimal 3-node Alfresco Cluster. Proceed to web interface and choose Add New Alfresco Cluster option. Fill the details and choose List All Alfresco Clusters option in the left navigation to see your new cluster. Now click on radio button for specific cluster and press submit button ‘Provision Nodes for Selected Cluster Now’. This will lock browser for some time (around 6-7 minutes). After configuration is finished, result screen will get displayed.

Test cluster functionality:

See ElasticFox extension and note new instances, that are respectively, DB Node, Master Node and Slave Node. Get its Public DNS addresses and open it in browser (it should like http://ec2-00-100-200-100.compute-1.amazonaws.com:8080/alfresco). Log in to one of the instances (or re-log in) as admin: admin and Add Content. Then log in to another instance and see if content of the space shows new file.

This setup allows one click configuration of Alfresco Cluster on EC2 and provides enterprise content management system that can be used for multiple purposes. Cloud computing is highly beneficial for the small and mid enterprises where cost is a constraint for the ECM.