Alfresco : Implementing Business Rules

39
Alfresco Implementing Business Rules Doc. v rc0.1 - 21/05/09 Wildan Maulana | wildan [at] tobethink.com #6

Transcript of Alfresco : Implementing Business Rules

Page 1: Alfresco : Implementing Business Rules

Alfresco Implementing Business Rules

Doc. v rc0.1 - 21/05/09

Wildan Maulana | wildan [at] tobethink.com

#6

Page 2: Alfresco : Implementing Business Rules

About Me• Freelance Consultant - Software

Developer – System Integrator

• Founder of OpenThink Labs

• Open Source Software (OSS) Evangelist

• Main Developer of OpenThink SAS

• More Info : – Blog :

http://wildanm.wordpress.com

– Y! : hawking_123

– Gtalk : wildan.m

– Mobile Phone : +6287884599249

Page 3: Alfresco : Implementing Business Rules

Overview• Automatically organize documents into specific spaces when you

do a bulk upload of documents

• Define the sequence of business rules on a space

• Run time-consuming business rules in the background

• Automatically control document versions on specific documents in specific spaces

• Automatically categorize documents based on names

• Send notifications based on a specific event on a document

• Transform documents from one format to another

• Dynamically add custom properties to documents based on the location

• Configure business rules as scheduled actions to run periodically

• Extend business rules using customized JavaScript files

Page 4: Alfresco : Implementing Business Rules

Using Business Rules on Spaces• Organize Documents Automatically

• Run Rules in the Background to Improve Performance

• Dynamically Add Properties to a Document

• Automatic Versioning of Documents

• Send Notifications to Specified People

• Chaining All the Business Rules

Page 5: Alfresco : Implementing Business Rules

Using Business Rules on Spaces

Page 6: Alfresco : Implementing Business Rules

Organize Documents Automatically• Let us consider an example scenario. Let us say your finance

department receives thousands of documents every day in electronic format from your customers, vendors, and internal departments. Your finance department receives checks from customers in the form of scanned images, invoices from vendors in the form of PDF documents, and contracts and other documents from various departments in the form of Microsoft Word documents. The department would like to upload them to the Alfresco repository and automatically organize them into various spaces, which are shown in the following figure.

Page 7: Alfresco : Implementing Business Rules

Define Business Rule on Drop Zone• In the Drop Zone space, click on More Actions |

Manage Content Rules. You will see the Content Rules pane as shown in the following figure:

• Clicking on the Create Rule link (as shown in the figure) opens the Create Rule Wizard window

Page 8: Alfresco : Implementing Business Rules

Define Business Rule on Drop Zone #2

Page 9: Alfresco : Implementing Business Rules

Define Business Rule on Drop Zone #3

Available actions : 1. Add aspect to item2. Add simple workflow to item3. Blog-post4. Check in content5. Check out content6. Copy item to a folder in a web project7.Copy item to a spesific space8.Execute a script9.Extract common metadata fields from content10. Import an Alfresco content package

11. Increment Counter12. Link item to category13. Move item to a spesific space14. Remove an aspect from an item15. Send an email to specified users16. Specialise the type of an item17. Transform and copy content to aspecific space18. Transform and copy image to a spesific space

Page 10: Alfresco : Implementing Business Rules

Define Business Rule on Drop Zone #4

Page 11: Alfresco : Implementing Business Rules

Define Business Rule on Drop Zone #5

Page 12: Alfresco : Implementing Business Rules

Define Business Rule on Drop Zone #6• In the Step Three window, notice the business rule

triggering options in the Type drop-down list.

– Inbound means this rule is triggered when a document is created (in the Web Client) or copied or moved (from some other space) or added (using the Web Services API) or dropped (using the drag-and-drop feature of CIFS, WebDAV, or FTP) in to the Drop Zone space.

– Outbound means this rule is triggered when a document is deleted or cut (to move it to another space) from the Drop Zone space.

– Update means this rule is triggered when a document in Drop Zone is updated. Again the update can happen by various means such as manual updating in the Web Client, updating through network drives (CIFS, FTP, or

WebDAV), and updating through the Web Services API.

Page 13: Alfresco : Implementing Business Rules

Define Business Rule on Drop Zone #6

Page 14: Alfresco : Implementing Business Rules

Run Rules in the Background to ImprovePerformance

• Typically, business rules run in real time. Consider having a business rule that transforms 25 megabytes of Microsoft Word document to a PDF. Consider that rule being applied to hundreds of such files. If you upload a big Word document in the web client, then you might have to wait for a while till the business rule is completely executed. Similarly, think about having a business rule that sends email notifications to thousands of people. All these rules take significant amounts of time and resources to execute.

• To improve the performance of the system, the best practise is to execute such business rules in the background. Refer to the earlier figure (under the section describing Step Three) where the rule has been selected to run in the background. If this option is selected the rule will execute in the background, so the results may not appear immediately.

Page 15: Alfresco : Implementing Business Rules

Dynamically Add Properties to a Document

• Follow the steps provided below to add the Effectivity aspect to all the documents in the Finance Department space.

1. Make sure that you are in the Company Home | Intranet | Finance Department space.

2. In the Finance Department space click on More Actions | Manage Content Rules.

3. Click on the Create Rule link and you will see the Create Rules Wizard.

4. In the Step One window, Select Condition drop-down list, select All Items, and click on the Add to List button. Then click on the Next button.

5. In the Step Two window, Select Actions drop-down list, select Add aspect to item, and click on the Set Values and Add button. Select the Effectivity aspect and click OK. Then click on the Next button.

Page 16: Alfresco : Implementing Business Rules

Dynamically Add Properties to a Document #2

6. In the Step Three window, select Inbound Type and provide appropriate Title and Description for this rule. Select the Apply rule to sub-spaces checkbox to apply this rule to all the documents within the sub-spaces as well. Now this rule will be applicable to all sub-spaces including Customer Checks, Vendor Invoices, and Contracts and Other Documents.

7.Finish the Rule

Page 17: Alfresco : Implementing Business Rules

Dynamically Add Properties to a Document #3

Page 18: Alfresco : Implementing Business Rules

Automatic Versioning of Documents• In Alfresco, version control is disabled by default

• Our case on Finance Department space :

1. Drop Zone : without document versioning

2. Customer Checks : without document versioning

3. Vendor Invoices : without document versioning

4. Contracts and Other Documents : with document versioning

Page 19: Alfresco : Implementing Business Rules

Enable versioning for Contracts and Other Documents space

1. Make sure that you are in the Company Home | Intranet | Finance Department | Contracts and Other documents space.

2. In the Contracts and Other documents space click on More Actions | Manage Content Rules.

3. Click on the Create Rule link and you will see the Create Rules Wizard.

4. In Step One, Select Condition drop-down list, select All Items and click on the Add to List button. Then, click on the Next button.

5. In Step Two, Select Actions drop-down list, select Add aspect to item and click on the Set Values and Add button. Select Versionable aspect and click OK. Then click on the Next button.

6. In Step Three, select Inbound Type and provide appropriate Title and Description for this rule. Select the Apply rule to sub-spaces checkbox to enable versioning for all the documents within sub-spaces as well.

7. Finish the Rule.

Page 20: Alfresco : Implementing Business Rules

Send Notifications to Specified People• Let us say that in your organization the Sales Group is

responsible for following up on contracts with customers. Follow the steps below to send email notifications to all the people in the Sales Group when a document in the Contracts and Other Documents space is updated.

1. Make sure that you are in the Company Home | Intranet | Finance Department | Contracts and Other documents space.

2. In the Contracts and Other Documents space click on More Actions | Manage Content Rules.

3. Click on the Create Rule link and you will see the Create Rules Wizard.

4. In the Step One window, from the Select Condition drop-down list select All Items and click on the Add to List button. Then click on the Next button.

Page 21: Alfresco : Implementing Business Rules

Send Notifications to Specified People #25. In the Step Two window, from the Select Actions drop-

down list select Send an email to specified users and click on the Set Values and Add button.

Page 22: Alfresco : Implementing Business Rules

Send Notifications to Specified People #36. In the Step Three window, select the Update Type, to

send notification on every document update.

7. Finish the Rule

Page 23: Alfresco : Implementing Business Rules

Send Notifications to Specified People #25. In the Step Two window, from the Select Actions drop-

down list select Send an email to specified users and click on the Set Values and Add button.

Page 24: Alfresco : Implementing Business Rules

Chaining all the Business Rules

For example, consider the following sequence of operations when a document titled ProjectXYZ_Contract.doc is dropped in Company Home | Intranet | Finance Department | Drop Zone.

1. Due to the business rules defined in Drop Zone, the document ProjectXYZ_Contract.doc is automatically moved to Finance Department | Contracts and Other Documents space

2. Due to Effectivity rule defined in the parent Finance Department space, two properties (Effective From and Effective To) are added to the ProjectXYZ_Contract.doc document.

3.Due to the Versioning aspect rule defined in the space, the document ProjectXYZ_Contract.doc is automatically versioned

Page 25: Alfresco : Implementing Business Rules

Built-In Business Rules

• How these Business Rules Work• How the Conditions are Checked• What Actions are Executed• When are these Rules Triggered?

Page 26: Alfresco : Implementing Business Rules

How these Business Rules Work• Alfresco's underlying framework supports the latest technology,

called Aspect-Oriented Programming, which is useful to change the behavior of the server dynamically without making changes to the code. Business rules leverage this technology so that you can define them at any space in Alfresco and change the behavior of the system.

• Alfresco server follows a process to execute business rules:

– Whenever a document is added to a space (Inbound) or removed from a space (Outbound) or updated within a space (Update), Alfresco server checks whether that space or the parent spaces have any business rule to execute based on the triggering event type (Inbound, Outbound, or Update). The server checks if the business rule condition is satisfied. For example the business rule can be applied to documents that have certain pattern in their names.

– Then the server executes the action defined in the business rule.

Page 27: Alfresco : Implementing Business Rules

The Alfresco Business Rule Wizard1. The condition to apply the rule

2. The action to be performed as a result

3. The type of Event which triggers the action

4. The summary of the business rule to commit

Page 28: Alfresco : Implementing Business Rules

How the Conditions are Checked• The first step in the Rule Wizard is to select the content

items to apply the rule. The following can be checked against the content item.

– Does it have a particular name pattern?

– Is it in a particular category?

– Is it of a specific type or format?

– Does a property have a specific value?

Page 29: Alfresco : Implementing Business Rules

What Actions are Executed• The second step in the Rule Wizard is to define the list of actions

to be executed as a result. The following is the list of built-in actions to select from.

– Add aspect to item: Add additional properties and behavior to document

– Add simple workflow: Add approve and reject workflow

– Check in content: Check in the document

– Check out content: Check out the document to a space

– Copy item to a specific space: Copy the document to a space

– Execute a script: Execute a JavaScript as an action

– Extract common metadata fields from content: Extract document metadata

– Import Alfresco content package: Import as content package

– Link item to category: Link document to a specific existing category

Page 30: Alfresco : Implementing Business Rules

What Actions are Executed #2– Move item to a specific space: Cut document from the

current space and move to specified space

– Remove an aspect from an item: Remove property or set of properties from the document

– Send an email to specific users: Send email notifications to specific users or groups of users

– Specialize the type of an item: Define content type for the document

– Transform and copy content to a specific space: Transform content say from DOC to PDF and move the resultant file to the specified space

– Transform and copy image to a specific space: Transform and resize image say from JPG to PNG format and move the resultant image to the specified space

Page 31: Alfresco : Implementing Business Rules

Add Aspect to Item Action Values

• When you select the Add aspect to item action, you will have a list of built-in aspects to choose from as shown in the following figure:

– Classifiable

– Complianceable

– Dublin Core

– Effectivity

– Email Alias

– Emailed

– Summarizable

– Taggable

– Templatable

– Versionable

Page 32: Alfresco : Implementing Business Rules

Aspect Meaning• Classifiable: Enable Categorization so that categories can be linked

to the document.

• Complianceable: Add a compliance property called Remove after to the document.

• Dublin Core: Add Dublin core metadata to the document. Dublin core metadata includes properties such as Publisher, Contributor, Subject, and Rights.

• Effectivity: Add effectivity properties called Effective From and Effective To to the document.

• Emailed: Add a set of properties called Email Data to the document. This is useful to capture the email information if the document is an attachment to email.

• Localizable: Add a property called Locale to the document.

• Summarizable: Add a property called Summary to the document.

• Templatable: Enable template view.

• Translatable: Add a property called Translations to the document.

• Versionable: Enable versioning.

Page 33: Alfresco : Implementing Business Rules

When are these Rules Triggered?• The third step in the Rule Wizard is to define the

triggering event types. The rules are triggered by something happening and specified by the Type field as follows.

– Inbound: content arriving into a space either new, copied, or moved

– Outbound: content leaving a space either deleted or moved

– Update: content updated either uploaded or saved

Page 34: Alfresco : Implementing Business Rules

Applying Business Rules to Individual Content

• Removing an Aspect from Content

Page 35: Alfresco : Implementing Business Rules

Handling Content Transformations

• Transforming a Word Document to a PDF

• Resizing and Transforming Images• OpenDocument Format

– Converting Microsoft Office Documents to ODF

• Built-In Transformations

Page 36: Alfresco : Implementing Business Rules

Executing JavaScript as Business Rules

• Use Built-In JavaScript Files as Actions

• Extend Business Rules with Custom JavaScript

– Set up Website Space– Create Custom JavaScript– Execute Custom JavaScript as a

Business Rule

• JavaScript API

Page 37: Alfresco : Implementing Business Rules

Scheduled Actions• Example to Publish Effective Content

to Production• XML Configuration File for Scheduled

Actions– The cron Expression

Page 38: Alfresco : Implementing Business Rules

Summary

Page 39: Alfresco : Implementing Business Rules

Reference

• Alfresco, Enterprise Content Management Implementation, Munwar Sharif, PACKT Publishing