Workflow JavaScript API

From AlfrescoWiki

Jump to: navigation, search


DRAFT/WIP

NOTE: This document is a "work in progress"

NOTE: This new API is currently available in Alfresco Community 2.9 Labs release for testing and evaluation.

Contents

[edit] Overview

The Workflow JavaScript API enables script writers to write JavaScript files to start and interact with workflows within Alfresco. The API supports scripts that are EMCA Script 1.6 compatible. It provides a simple object-oriented API to interact with workflow objects, such as workflow definitions, instances, nodes, paths, tasks and transitions.

Script developers can interact with workflows within Alfresco by developing JavaScript files against this API. This is done in much the same way that one develops against the general Alfresco JavaScript API to script repository objects.

Script writers can use this API to do things like, get a list of the deployed workflow definitions, create a workflow package, get assigned and completed tasks, start a workflow instance from a deployed definition etc.

The object model for this API is similar to that of the Advanced Workflow API. The relationships between the various objects exposed by this API are the same as those between the various objects exposed by the Advanced Workflow API. Each object in the Workflow JavaScript API is a simpler, stripped-down version of its counterpart in the Advanced Workflow API. One reason for following this design pattern was to keep the objects exposed by this API as simple as possible. The complexities of the objects in the Advanced Workflow API are hidden away from the script developer. Another reason is to achieve loose coupling between the Workflow JavaScript object model and the Advanced Workflow object model. We don't want to automatically expose any changes made to the classes in the Advanced Workflow object model. And the final reason (I may think up more), the backing Beans for the JavaScript Workflow API need to be Serializable to be scriptable and those exposed by the Advanced Workflow API are not.

[edit] The Workflow Manager

The WorkflowManager acts as the front-end for interacting with the JavaScript Workflow object model. It acts as the gateway into the API. It is the only object here that is exposed to the root scripting scope. In the root scripting scope, the WorkflowManager object is identified as "workflow".

The properties and operations exposed by the WorkflowManager are as follows:

[edit] WorkflowManager

[edit] properties

   definition(id) <read-only>
   assignedTasks <read-only>
   completedTasks <read-only>
   instance(String workflowInstanceId) <read-only>
   pooledTasks(authority) <read-only>
   task(id) <read-only>
   latestDefinitions <read-only>
   allDefinitions <read-only>

[edit] operations

   getTaskById(String id)
   createPackage()

[edit] Backing Beans

The JavaBeans exposed by the WorkflowManager are as follows:

[edit] JscriptWorkflowDefinition

[edit] properties

   id <read-only>
   name <read-only>
   version <read-only>
   title <read-only>
   description <read-only>
   activeInstances <read-only>

[edit] operations

   startWorkflow(workflowPackage, properties)
   

[edit] JscriptWorkflowInstance

[edit] properties

   id <read-only>
   description <read-only>
   active <read-only>
   startDate <read-only>
   endDate <read-only>
   paths <read-only>

[edit] operations

   cancel()
   delete()
   

[edit] JscriptWorkflowNode

[edit] properties

   name <read-only>
   title <read-only>
   description <read-only>
   taskNode <read-only>
   transitions <read-only>

[edit] JscriptWorkflowPath

[edit] properties

   id <read-only>
   active <read-only>
   node <read-only>
   instance <read-only>
   tasks <read-only>    

[edit] operation

   signal(transitionId)
   

[edit] JscriptWorkflowTask

[edit] properties

   properties
   id <read-only>
   name <read-only>
   title <read-only>
   description <read-only>
   complete <read-only>
   pooled
   transactions
   packageResources

[edit] operations

   endTask(transitionId)
   getPackageResources()
   getTransitions()

[edit] JscriptWorkflowTransition

[edit] properties

   id <read-only>
   title <read-only>
   description <read-only>