[Nuxeo World 2013] Workshop - Implement your Business Logic

29
Implement your business logic Oct 10th, 2013 Benjamin Jalon & Frédéric Vadon

description

- Create chains of operations to model your business logic - Design workflows to implement your processes, with fork/merge points, escalation support, due date management, dynamic sub-workflows, etc. - Configure user actions (actionable buttons) and event reactors triggering chains of operations - Configure email notifications

Transcript of [Nuxeo World 2013] Workshop - Implement your Business Logic

Page 1: [Nuxeo World 2013] Workshop - Implement your Business Logic

Implement your business logic

Oct 10th, 2013 Benjamin Jalon & Frédéric Vadon

Page 2: [Nuxeo World 2013] Workshop - Implement your Business Logic

Implement Business Logic ?

2

= Make sure your system enforce your business constraints

Page 3: [Nuxeo World 2013] Workshop - Implement your Business Logic

Example of business Logic

3

- My documents should have a topic field

- Documents should be moved to another department when they are validated

- They should become obsolete after one year

- Only the group “validators” can see it while the document is not published ....

....

Page 4: [Nuxeo World 2013] Workshop - Implement your Business Logic

Technical translation

4

It is usually means the system (Nuxeo) will do things for you, like:

- Updating one or more metadata of a document

- Creating a document automatically

- Changing the lifecycle of a document (done this morning)

- Doing a conversion of a document

- Setting an ACL automatically on the document

- Assigning tasks to users on the resources

Page 5: [Nuxeo World 2013] Workshop - Implement your Business Logic

How can this be done ?

5

Automation

Page 6: [Nuxeo World 2013] Workshop - Implement your Business Logic

Automation - an operation

6

Category

oInput/outpout

Parameters

oDescription

Page 7: [Nuxeo World 2013] Workshop - Implement your Business Logic

Automation - a chain

7

Document on which we will

work

Update of a metadata

Log in Nuxeo Audit

Page 8: [Nuxeo World 2013] Workshop - Implement your Business Logic

How to use an chain?

8

• Bind it to a button

• Bind it to an event handler

• To Workflow

• Call it as a webservice

Page 9: [Nuxeo World 2013] Workshop - Implement your Business Logic

Let’s try !

9

1. Create a button that updates the description property with “Hello world” value

2. Use the latter chain so that each time you create a document, the description is equal to “Hello World”.

3. Create a button that moves the current document just under /default-domain/workspaces

Page 10: [Nuxeo World 2013] Workshop - Implement your Business Logic

I want more !

10

Use MVEL @{ }

Page 11: [Nuxeo World 2013] Workshop - Implement your Business Logic

Referencing a metadata

11

@{ Document[“dc:title] }

Page 12: [Nuxeo World 2013] Workshop - Implement your Business Logic

Let’s try !

12

1. On the previous button that adds “Hello world”, make sure it logs in the audit an entry with a comment that prints the value of the dc:title, dc:description, dc:creator

Page 13: [Nuxeo World 2013] Workshop - Implement your Business Logic

I want more !

13

Use Automation Context

Page 14: [Nuxeo World 2013] Workshop - Implement your Business Logic

A context for the whole chain

14

• Context is useful to “store” objects/information during the time of the execution of the chain

• Store a value at 2nd step of your chain, use it at the 5th step

• Store document, list of documents, metadata value, any value !

Page 15: [Nuxeo World 2013] Workshop - Implement your Business Logic

Tools to play with the context

15

• A “map of objects” called “Context” for accessing the context from MVEL: @{Context[“my_variable”}

• Some operations in the category “Execution context”

Page 16: [Nuxeo World 2013] Workshop - Implement your Business Logic

Tools to play with the context

16

Very useful !

Page 17: [Nuxeo World 2013] Workshop - Implement your Business Logic

Tools to play with the context

17

Very useful !

Page 18: [Nuxeo World 2013] Workshop - Implement your Business Logic

Let’s try !

18

1. When creating a File document, make sure you get automatically the same “coverage” than the one that is on the workspace.

2. Add a button that creates beside a given file a note called “Review of document XXX” where XXX is the title of the first document

Page 19: [Nuxeo World 2013] Workshop - Implement your Business Logic

Next

19

Automation is so cool, eh, why do I need workflow ?

Page 20: [Nuxeo World 2013] Workshop - Implement your Business Logic

Why Using Workflows

20

• Bring you time based automation

• Offers interaction with users, asking them their input (forms, buttons)

• Produces a very maintainable business logic implementation!

Page 21: [Nuxeo World 2013] Workshop - Implement your Business Logic

What Is a Workflow in Nuxeo

21

• A set of nodes linked on a graph

• References to automation chains to define what is automated at each nodes

• Definition of forms and buttons to defined what a user should contribute at a given node

Page 22: [Nuxeo World 2013] Workshop - Implement your Business Logic

Starting with workflows

22

Let’s go iterative

Page 23: [Nuxeo World 2013] Workshop - Implement your Business Logic

Create users on your instance

23

Page 24: [Nuxeo World 2013] Workshop - Implement your Business Logic

Create Users on Your Instance

24

• john/john , group: members

• jack/jack , group: members

• group: nxworld

Page 25: [Nuxeo World 2013] Workshop - Implement your Business Logic

Assign a task to john

25

• Drop a task node

• Make sure there is one or two buttons

• Link the transitions

• Deploy and test

Page 26: [Nuxeo World 2013] Workshop - Implement your Business Logic

More assignments cases

26

• assign to a group (group:nxworld)

• assign to the workflow initiator (“workflowInitiator”)

Page 27: [Nuxeo World 2013] Workshop - Implement your Business Logic

Play with the security

27

• Make sure John can read the document when he is assigned the task.

Page 28: [Nuxeo World 2013] Workshop - Implement your Business Logic

Plug an automation chain on your workflow

28

• Write a new automation chain

• Plut it to the workflow, for example for updating the title of the document, right at the end of the workflow.

Page 29: [Nuxeo World 2013] Workshop - Implement your Business Logic

#NxWor

ld13

!Thank you