SlideShare una empresa de Scribd logo
1 de 26
Descargar para leer sin conexión
Advanced Workflow: Deeper Dive!
                     Nick Smith!
    Senior Software Engineer, Services Team, Alfresco!
Agenda!

Service Tasks
  •  Java Delegate Class!
  •  Java Delegate Bean!
  •  Arbitrary Expressions!

Listeners
  •  Execution Listeners!
  •  Task Listeners!

Scripting
  •  Scope Variables!
  •  Execution Variables!
  •  Examples!

Timers
Questions
Service Tasks
            !
Service Tasks!

  •  Service Tasks allow Java code to be executed as part of a
     workflow!

  •  Allows easy unit testing and code re-use!
  •  Three ways to implement:!
    •    JavaDelegate Class!
    •    JavaDelegate Bean:!

    •    Arbitrary Expression!
Service Tasks: Java Delegate Class!

  •  The supplied class must implement JavaDelegate interface!
  •  Fields can be set on the class!

  •  Use the ʻactiviti:classʼ attribute to specify the delegate class

  <serviceTask id=“getMimetypet" name=“Get Mimetype”
     activiti:class="org.alfresco.examples.MimetypeGetter“ >
    <extensionElements>
      <activiti:field name=“document">
        <activiti:expression>${dcwkflw_document}</activiti:expression>
      </activiti:field>
    </extensionElements>
  </serviceTask>
Service Tasks: Java Delegate Bean!

  •  The supplied bean must implement JavaDelegate interface!
  •  The same bean instance is used for all executions!

  •  The bean must be defined in Spring and registered with the
     activitiBeanRegistry!

  •  Use ʻactiviti:delegateExpressionʼ attribute to specify the
     delegate bean in the process definition:!

  <serviceTask id=“getMimetype" name=“Get Mimetype“
    activiti:delegateExpression="${mimetypeGetter}" />
Service Tasks: Java Delegate Bean!

  •  Recommended to extend BaseJavaDelegate class!
  •  Recommend extending baseJavaDelegate bean!

  •  If the bean class extends BaseJavaDelegate and the Spring bean
     definition extends baseJavaDelegate, then the bean will
     automatically be registered with the activitiBeanRegistry and will
     have access to the serviceRegistry!

  <bean id=“mimetypeGetter" parent="baseJavaDelegate"
       class="org.alfresco.example.MimetypeGetter" />
Service Tasks: Java Delegate Bean!
public class MimetypeGetter extends BaseJavaDelegate
{
    @Override
    public void execute(DelegateExecution execution) throws Exception
    {
        ScriptNode document = (ActivitiScriptNode) execution.getVariable("dcwkflw_document");
        NodeRef nodeRef = document.getNodeRef();

        ServiceRegistry serviceRegistry = getServiceRegistry();
        FileFolderService fileService = serviceRegistry.getFileFolderService();
        FileInfo file = fileService.getFileInfo(nodeRef);
        String mimetype = file.getContentData().getMimetype();

        execution.setVariable("dcwkflw_mimetype“, mimetype);
    }
}
Service Tasks: Arbitrary Expression!

  •  Execute any arbitrary expression!
  •  The expression may reference any bean defined in Spring and
     registered with the activitiBeanRegistry!
  •  A process variable can be specified for the return value using the
     activiti:result attribute!

  <serviceTask id=”getMimetype” name="Get Mimetype" activiti:resultVariable="dcwkflw_mimetype"
   activiti:expression=“${mimetypeGetter.getMimetype(dcwkflow_document)}” />!
Listeners
        !
Listeners!

  •  Used to react to certain events during workflow execution!
  •  Two types: TaskLisener and ExecutionListener!

  •  Three ways to configure, as with ServiceTasks:!
     •    Listener Class:!
     <activiti:executionListener class="org.alfresco.example.MyExecutionListener" event=“start” />!

     •    Listener Bean:!
     <activiti:taskListener delegateExpression=“${myTaskListener}" event=“create" />!

     •    Arbitrary Expression
  <activiti:executionListener expression=“myPojo.myMethod(myVar)" event="start" />
Listeners: Execution Listener Events!
  •  Event: Execution (Workflow) starts or ends!
  <extensionElements>
    <activiti:executionListener class=“org.alfresco.example.ExecutionEventLogger" event=“start” />
  </extensionElements>!

  •  Event: Activiti (Workflow Node) starts or ends!
  <userTask id=“theTask” name=“The Task” >
    <extensionElements>
       <activiti:executionListener delegateExpression=“${executionEventLogger}" event=“end” />
    </extensionElements>
  </userTask>!

  •  Event: Sequence Flow (Transition) is taken!
  <sequenceFlow id=“theFlow” sourceRef=“theTask” targetRef=“theEnd” >
    <extensionElements>
       <activiti:executionListener expression=“${logger.info(execution.eventName)}" />
    </ sequenceFlow >
  </userTask>
Listeners: Execution Listener Implementation!

  Execution Listener class or delegate bean must implement
        ExecutionListener interface:!

  public class ExecutionEventLogger implements ExecutionListener
  {
    private static final Log LOGGER = LogFactory.getLog(ExecutionEventLogger.class);

       @Override
       public void notify(DelegateExecution execution) throws Exception
       {
         String eventName = execution.getEventName();
         LOGGER.info("Received event: " + eventName);
       }

  }!
Listeners: Task Listener Events!
  •  All Task Listeners defined inside task elements:!
  <userTask id=“theTask” name=“The Task” >
    <extensionElements>
       <activiti:taskListener ... [Listener Details] ... />
    </extensionElements>
  </userTask>!

  •  Event: assignment is called when a task is assigned to a user,
      usually called before create:!
  <activiti:taskListener event=“assignment” class=“org.alfresco.example.TaskEventLogger” />

  •  Event: create is called when the task is created, after assignment:!
  <activiti:taskListener event=“create” delegateExpression=“${taskEventLogger}” />

  •  Event: completed is called when the task is completed:!
  <activiti:taskListener event=“completed” expression=“${logger.info(task.eventName)}” />
Listeners: Task Listener Implementation!

  Task Listener class or delegate bean must implement TaskListener
       interface:!

  public class ExecutionEventLogger implements TaskListener
  {
    private static final Log LOGGER = LogFactory.getLog(ExecutionEventLogger.class);

      @Override
      public void notify(DelegateTask task)
      {
        String eventName = task.getEventName();
        LOGGER.info("Received event: " + eventName);
      }

  }
Scripting!
Scripting!

  •  Scripting Lagnuage:!
    •    JavaScript!



  •  Activiti Implementations:!
    •    AlfrescoScriptDelegate!

    •    ScriptExecutionListener !

    •    ScriptTaskListener!
Scripting: Scope Variables!

  •  person ScriptNode, the current user!
  •  userhome ScriptNode, the home space of the current user!

  •  execution DelegateExecution, the current execution.!
  •  task DelegateTask, the current task (ScriptTaskListener only)!
  •  cancelled boolean, was the execution cancelled
    (ScriptExecutionListener only)!
  •  deleted boolean, was the execution deleted
    (ScriptExecutionListener)!
Scripting: Execution Variables!

  •  All execution variables added to scope!

  •  Variable names translated from “prefix:suffix” to “prefix_suffix”!

  •  Associations and noderef properties converted to ScriptNodes!

  •  Use execution.setVariable(name, value) to modify variables!

  •  Check if a variable exists using:!
       if (typeof <variable name> != 'undefined')
Scripting: Examples!

  •  Copy a task variable to a process variable:
    execution.setVariable('dcwkflw_reviewOutcome', task.getVariable('dcwkflw_reviewOutcome'));



  •  Set a task property from a pocess variable if it exists:
    if (typeof bpm_workflowDueDate != 'undefined') task.dueDate = bpm_workflowDueDate;



  •  Apply an aspect ʻdcwkflw:publishedʼ to a document:
    var presentation = bpm_package.children[0]; // Get the presentation
    presentation.addAspect('dcwkflw:published'); // Apply published aspect
Timers
     !
Timers!

  •  Timers are used to delay an event until a specified time/duration!
  •  Timers can be attached to three types of event:!
    •    startEvent: Starts the workflow!
    •    intermediateCatchEvent: Between nodes/events!

    •    boundaryEvent: Associated with a node (e.g. a userTask)!

  •  Three ways to set trigger time:!
    •    timeDate: Triggers at specified date/time!

    •    timeDuration: Triggers after specified delay duration!

    •    timeCycle: Triggers repeatedly with specified delay/interval!

  •  All dates/times/durations/intervals use ISO8601 format!
Timers: Start Event Date Example!

 •  Create a workflow which sends a Christmas Greeting
 <!-- Start workflow at 12:05 on Christmas Day -->
 <startEvent id="start" >
       <timerEventDefinition>
          <timeDate>2011-12-25T12:05:00</timeDate>
        </timerEventDefinition>
    </startEvent>


 <sequenceFlow id='flow1' sourceRef='start' targetRef='sendGreeting' />
Timers: Intermediate Event Delay Example!

 •  Delay after some service task performs some asynchronous event

     to wait for the job to complete:!

 <sequenceFlow id='flow1' sourceRef='asyncJob' targetRef='waitForJobToFinish' />

 <!-- Wait 1 hour 30 mins for the job to finish -->
 <intermediateEvent id="waitForJobToFinish" >
   <timerEventDefinition>
      <timeDuration>PT1H30M</timeDate>
   </timerEventDefinition>
 </intermediateEvent>

 <sequenceFlow id='flow2' sourceRef='waitForJobToFinish' targetRef='nextTask' />
Timers: Repeating Boundary Event Example!

 •  Send a reminder email if a task isnʼt completed after 1 week.

     Repeat the email every day for 3 days:!
  <userTask id="theTask" >

  <!-- Wait 1 week, then repeat every 2 days a further 2 times -->
  <boundaryEvent id="repeatingNotification" cancelActivity="false" attachedToRef="theTask" />
    <timerEventDefinition>
       <timeCycle>R3/P1W/P1D</timeDate>
    </timerEventDefinition>
  </boundaryEvent>


  <sequenceFlow id='flow1' sourceRef='repeatingNotification' targetRef='sendEmail' />

  <serviceTask id="sendEmail" activiti:delegateExpression="${sendEmailDelegate}" />
Questions ?!

Más contenido relacionado

La actualidad más candente

PrimeTime JSF with PrimeFaces - Dec 2014
PrimeTime JSF with PrimeFaces - Dec 2014PrimeTime JSF with PrimeFaces - Dec 2014
PrimeTime JSF with PrimeFaces - Dec 2014
cagataycivici
 

La actualidad más candente (20)

Building and deploying React applications
Building and deploying React applicationsBuilding and deploying React applications
Building and deploying React applications
 
Basics of AngularJS
Basics of AngularJSBasics of AngularJS
Basics of AngularJS
 
Sane Async Patterns
Sane Async PatternsSane Async Patterns
Sane Async Patterns
 
Enjoy the vue.js
Enjoy the vue.jsEnjoy the vue.js
Enjoy the vue.js
 
Обзор автоматизации тестирования на JavaScript
Обзор автоматизации тестирования на JavaScriptОбзор автоматизации тестирования на JavaScript
Обзор автоматизации тестирования на JavaScript
 
PrimeTime JSF with PrimeFaces - Dec 2014
PrimeTime JSF with PrimeFaces - Dec 2014PrimeTime JSF with PrimeFaces - Dec 2014
PrimeTime JSF with PrimeFaces - Dec 2014
 
Reliable Javascript
Reliable Javascript Reliable Javascript
Reliable Javascript
 
AtlasCamp 2015: Connect everywhere - Cloud and Server
AtlasCamp 2015: Connect everywhere - Cloud and ServerAtlasCamp 2015: Connect everywhere - Cloud and Server
AtlasCamp 2015: Connect everywhere - Cloud and Server
 
Angular js routing options
Angular js routing optionsAngular js routing options
Angular js routing options
 
AngularJS Directives
AngularJS DirectivesAngularJS Directives
AngularJS Directives
 
Angular Promises and Advanced Routing
Angular Promises and Advanced RoutingAngular Promises and Advanced Routing
Angular Promises and Advanced Routing
 
In The Brain of Cagatay Civici: Exploring JavaServer Faces 2.0 and PrimeFaces
In The Brain of Cagatay Civici: Exploring JavaServer Faces 2.0 and PrimeFaces In The Brain of Cagatay Civici: Exploring JavaServer Faces 2.0 and PrimeFaces
In The Brain of Cagatay Civici: Exploring JavaServer Faces 2.0 and PrimeFaces
 
Dart and AngularDart
Dart and AngularDartDart and AngularDart
Dart and AngularDart
 
Laravel 8 export data as excel file with example
Laravel 8 export data as excel file with exampleLaravel 8 export data as excel file with example
Laravel 8 export data as excel file with example
 
Modules and injector
Modules and injectorModules and injector
Modules and injector
 
Dethroning Grunt: Simple and Effective Builds with gulp.js
Dethroning Grunt: Simple and Effective Builds with gulp.jsDethroning Grunt: Simple and Effective Builds with gulp.js
Dethroning Grunt: Simple and Effective Builds with gulp.js
 
Building a js widget
Building a js widgetBuilding a js widget
Building a js widget
 
The Rails Way
The Rails WayThe Rails Way
The Rails Way
 
Introduction to backbone presentation
Introduction to backbone presentationIntroduction to backbone presentation
Introduction to backbone presentation
 
Training in Android with Maven
Training in Android with MavenTraining in Android with Maven
Training in Android with Maven
 

Destacado

JWT-To-Activiti
JWT-To-ActivitiJWT-To-Activiti
JWT-To-Activiti
E P
 

Destacado (8)

JWT-To-Activiti
JWT-To-ActivitiJWT-To-Activiti
JWT-To-Activiti
 
Activiti - the Open Source Business Process Management platform by Alfresco
Activiti - the Open Source Business Process Management platform by AlfrescoActiviti - the Open Source Business Process Management platform by Alfresco
Activiti - the Open Source Business Process Management platform by Alfresco
 
Launching Activiti v6 (Activiti Community Day Paris 2015)
Launching Activiti v6 (Activiti Community Day Paris 2015) Launching Activiti v6 (Activiti Community Day Paris 2015)
Launching Activiti v6 (Activiti Community Day Paris 2015)
 
Introduction to Activiti
Introduction to ActivitiIntroduction to Activiti
Introduction to Activiti
 
Bpmn
BpmnBpmn
Bpmn
 
Introduction to Activiti BPM
Introduction to Activiti BPMIntroduction to Activiti BPM
Introduction to Activiti BPM
 
BPMN 2.0 Tutorial 01 - Basic Constructs
BPMN 2.0 Tutorial 01 - Basic ConstructsBPMN 2.0 Tutorial 01 - Basic Constructs
BPMN 2.0 Tutorial 01 - Basic Constructs
 
Introduction à BPMN 2.0 - Business Process Modeling Notation
Introduction à BPMN 2.0 - Business Process Modeling NotationIntroduction à BPMN 2.0 - Business Process Modeling Notation
Introduction à BPMN 2.0 - Business Process Modeling Notation
 

Similar a BPM-3 Advanced Workflow Deep Dive

Simple blog wall creation on Java
Simple blog wall creation on JavaSimple blog wall creation on Java
Simple blog wall creation on Java
Max Titov
 
GR8Conf 2011: Grails Webflow
GR8Conf 2011: Grails WebflowGR8Conf 2011: Grails Webflow
GR8Conf 2011: Grails Webflow
GR8Conf
 
Concurrency in Scala - the Akka way
Concurrency in Scala - the Akka wayConcurrency in Scala - the Akka way
Concurrency in Scala - the Akka way
Yardena Meymann
 
Intro To JavaScript Unit Testing - Ran Mizrahi
Intro To JavaScript Unit Testing - Ran MizrahiIntro To JavaScript Unit Testing - Ran Mizrahi
Intro To JavaScript Unit Testing - Ran Mizrahi
Ran Mizrahi
 

Similar a BPM-3 Advanced Workflow Deep Dive (20)

Plone Interactivity
Plone InteractivityPlone Interactivity
Plone Interactivity
 
Simple blog wall creation on Java
Simple blog wall creation on JavaSimple blog wall creation on Java
Simple blog wall creation on Java
 
Introduction to advanced workflow
Introduction to advanced workflowIntroduction to advanced workflow
Introduction to advanced workflow
 
GR8Conf 2011: Grails Webflow
GR8Conf 2011: Grails WebflowGR8Conf 2011: Grails Webflow
GR8Conf 2011: Grails Webflow
 
BPM-4 Migration from jBPM to Activiti
BPM-4 Migration from jBPM to ActivitiBPM-4 Migration from jBPM to Activiti
BPM-4 Migration from jBPM to Activiti
 
Build Widgets
Build WidgetsBuild Widgets
Build Widgets
 
Primefaces Nextgen Lju
Primefaces Nextgen LjuPrimefaces Nextgen Lju
Primefaces Nextgen Lju
 
Concurrency in Scala - the Akka way
Concurrency in Scala - the Akka wayConcurrency in Scala - the Akka way
Concurrency in Scala - the Akka way
 
CUST-1 Share Document Library Extension Points
CUST-1 Share Document Library Extension PointsCUST-1 Share Document Library Extension Points
CUST-1 Share Document Library Extension Points
 
Background Jobs with Resque
Background Jobs with ResqueBackground Jobs with Resque
Background Jobs with Resque
 
Java EE 7 Recipes for Concurrency - JavaOne 2014
Java EE 7 Recipes for Concurrency - JavaOne 2014Java EE 7 Recipes for Concurrency - JavaOne 2014
Java EE 7 Recipes for Concurrency - JavaOne 2014
 
Dancing with websocket
Dancing with websocketDancing with websocket
Dancing with websocket
 
Intro To JavaScript Unit Testing - Ran Mizrahi
Intro To JavaScript Unit Testing - Ran MizrahiIntro To JavaScript Unit Testing - Ran Mizrahi
Intro To JavaScript Unit Testing - Ran Mizrahi
 
[1C1]Service Workers
[1C1]Service Workers[1C1]Service Workers
[1C1]Service Workers
 
Java Servlets.pdf
Java Servlets.pdfJava Servlets.pdf
Java Servlets.pdf
 
Service workers
Service workersService workers
Service workers
 
Rails 3 (beta) Roundup
Rails 3 (beta) RoundupRails 3 (beta) Roundup
Rails 3 (beta) Roundup
 
[NDC 2019] Enterprise-Grade Serverless
[NDC 2019] Enterprise-Grade Serverless[NDC 2019] Enterprise-Grade Serverless
[NDC 2019] Enterprise-Grade Serverless
 
[NDC 2019] Functions 2.0: Enterprise-Grade Serverless
[NDC 2019] Functions 2.0: Enterprise-Grade Serverless[NDC 2019] Functions 2.0: Enterprise-Grade Serverless
[NDC 2019] Functions 2.0: Enterprise-Grade Serverless
 
DjangoCon 2010 Scaling Disqus
DjangoCon 2010 Scaling DisqusDjangoCon 2010 Scaling Disqus
DjangoCon 2010 Scaling Disqus
 

Más de Alfresco Software

Más de Alfresco Software (20)

Alfresco Day Benelux Inholland studentendossier
Alfresco Day Benelux Inholland studentendossierAlfresco Day Benelux Inholland studentendossier
Alfresco Day Benelux Inholland studentendossier
 
Alfresco Day Benelux Hogeschool Inholland Records Management application
Alfresco Day Benelux Hogeschool Inholland Records Management applicationAlfresco Day Benelux Hogeschool Inholland Records Management application
Alfresco Day Benelux Hogeschool Inholland Records Management application
 
Alfresco Day BeNelux: Customer Success Showcase - Saxion Hogescholen
Alfresco Day BeNelux: Customer Success Showcase - Saxion HogescholenAlfresco Day BeNelux: Customer Success Showcase - Saxion Hogescholen
Alfresco Day BeNelux: Customer Success Showcase - Saxion Hogescholen
 
Alfresco Day BeNelux: Customer Success Showcase - Gemeente Amsterdam
Alfresco Day BeNelux: Customer Success Showcase - Gemeente AmsterdamAlfresco Day BeNelux: Customer Success Showcase - Gemeente Amsterdam
Alfresco Day BeNelux: Customer Success Showcase - Gemeente Amsterdam
 
Alfresco Day BeNelux: The success of Alfresco
Alfresco Day BeNelux: The success of AlfrescoAlfresco Day BeNelux: The success of Alfresco
Alfresco Day BeNelux: The success of Alfresco
 
Alfresco Day BeNelux: Customer Success Showcase - Credendo Group
Alfresco Day BeNelux: Customer Success Showcase - Credendo GroupAlfresco Day BeNelux: Customer Success Showcase - Credendo Group
Alfresco Day BeNelux: Customer Success Showcase - Credendo Group
 
Alfresco Day BeNelux: Digital Transformation - It's All About Flow
Alfresco Day BeNelux: Digital Transformation - It's All About FlowAlfresco Day BeNelux: Digital Transformation - It's All About Flow
Alfresco Day BeNelux: Digital Transformation - It's All About Flow
 
Alfresco Day Vienna 2016: Activiti – ein Katalysator für die DMS-Strategie be...
Alfresco Day Vienna 2016: Activiti – ein Katalysator für die DMS-Strategie be...Alfresco Day Vienna 2016: Activiti – ein Katalysator für die DMS-Strategie be...
Alfresco Day Vienna 2016: Activiti – ein Katalysator für die DMS-Strategie be...
 
Alfresco Day Vienna 2016: Elektronische Geschäftsprozesse auf Basis von Alfre...
Alfresco Day Vienna 2016: Elektronische Geschäftsprozesse auf Basis von Alfre...Alfresco Day Vienna 2016: Elektronische Geschäftsprozesse auf Basis von Alfre...
Alfresco Day Vienna 2016: Elektronische Geschäftsprozesse auf Basis von Alfre...
 
Alfresco Day Vienna 2016: Alfrescos neue Rest API
Alfresco Day Vienna 2016: Alfrescos neue Rest APIAlfresco Day Vienna 2016: Alfrescos neue Rest API
Alfresco Day Vienna 2016: Alfrescos neue Rest API
 
Alfresco Day Vienna 2016: Support Tools für die Admin-Konsole
Alfresco Day Vienna 2016: Support Tools für die Admin-KonsoleAlfresco Day Vienna 2016: Support Tools für die Admin-Konsole
Alfresco Day Vienna 2016: Support Tools für die Admin-Konsole
 
Alfresco Day Vienna 2016: Entwickeln mit Alfresco
Alfresco Day Vienna 2016: Entwickeln mit AlfrescoAlfresco Day Vienna 2016: Entwickeln mit Alfresco
Alfresco Day Vienna 2016: Entwickeln mit Alfresco
 
Alfresco Day Vienna 2016: Activiti goes enterprise: Die Evolution der BPM Sui...
Alfresco Day Vienna 2016: Activiti goes enterprise: Die Evolution der BPM Sui...Alfresco Day Vienna 2016: Activiti goes enterprise: Die Evolution der BPM Sui...
Alfresco Day Vienna 2016: Activiti goes enterprise: Die Evolution der BPM Sui...
 
Alfresco Day Vienna 2016: Partner Lightning Talk: Westernacher
Alfresco Day Vienna 2016: Partner Lightning Talk: WesternacherAlfresco Day Vienna 2016: Partner Lightning Talk: Westernacher
Alfresco Day Vienna 2016: Partner Lightning Talk: Westernacher
 
Alfresco Day Vienna 2016: Bringing Content & Process together with the App De...
Alfresco Day Vienna 2016: Bringing Content & Process together with the App De...Alfresco Day Vienna 2016: Bringing Content & Process together with the App De...
Alfresco Day Vienna 2016: Bringing Content & Process together with the App De...
 
Alfresco Day Vienna 2016: Partner Lightning Talk - it-novum
Alfresco Day Vienna 2016: Partner Lightning Talk - it-novumAlfresco Day Vienna 2016: Partner Lightning Talk - it-novum
Alfresco Day Vienna 2016: Partner Lightning Talk - it-novum
 
Alfresco Day Vienna 2016: How to Achieve Digital Flow in the Enterprise - Joh...
Alfresco Day Vienna 2016: How to Achieve Digital Flow in the Enterprise - Joh...Alfresco Day Vienna 2016: How to Achieve Digital Flow in the Enterprise - Joh...
Alfresco Day Vienna 2016: How to Achieve Digital Flow in the Enterprise - Joh...
 
Alfresco Day Warsaw 2016 - Czy możliwe jest spełnienie wszystkich regulacji p...
Alfresco Day Warsaw 2016 - Czy możliwe jest spełnienie wszystkich regulacji p...Alfresco Day Warsaw 2016 - Czy możliwe jest spełnienie wszystkich regulacji p...
Alfresco Day Warsaw 2016 - Czy możliwe jest spełnienie wszystkich regulacji p...
 
Alfresco Day Warsaw 2016: Identyfikacja i podpiselektroniczny - Safran
Alfresco Day Warsaw 2016: Identyfikacja i podpiselektroniczny - SafranAlfresco Day Warsaw 2016: Identyfikacja i podpiselektroniczny - Safran
Alfresco Day Warsaw 2016: Identyfikacja i podpiselektroniczny - Safran
 
Alfresco Day Warsaw 2016: Advancing the Flow of Digital Business
Alfresco Day Warsaw 2016: Advancing the Flow of Digital BusinessAlfresco Day Warsaw 2016: Advancing the Flow of Digital Business
Alfresco Day Warsaw 2016: Advancing the Flow of Digital Business
 

Último

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 

Último (20)

Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 

BPM-3 Advanced Workflow Deep Dive

  • 1. Advanced Workflow: Deeper Dive! Nick Smith! Senior Software Engineer, Services Team, Alfresco!
  • 2. Agenda! Service Tasks •  Java Delegate Class! •  Java Delegate Bean! •  Arbitrary Expressions! Listeners •  Execution Listeners! •  Task Listeners! Scripting •  Scope Variables! •  Execution Variables! •  Examples! Timers Questions
  • 4. Service Tasks! •  Service Tasks allow Java code to be executed as part of a workflow! •  Allows easy unit testing and code re-use! •  Three ways to implement:! •  JavaDelegate Class! •  JavaDelegate Bean:! •  Arbitrary Expression!
  • 5. Service Tasks: Java Delegate Class! •  The supplied class must implement JavaDelegate interface! •  Fields can be set on the class! •  Use the ʻactiviti:classʼ attribute to specify the delegate class <serviceTask id=“getMimetypet" name=“Get Mimetype” activiti:class="org.alfresco.examples.MimetypeGetter“ > <extensionElements> <activiti:field name=“document"> <activiti:expression>${dcwkflw_document}</activiti:expression> </activiti:field> </extensionElements> </serviceTask>
  • 6. Service Tasks: Java Delegate Bean! •  The supplied bean must implement JavaDelegate interface! •  The same bean instance is used for all executions! •  The bean must be defined in Spring and registered with the activitiBeanRegistry! •  Use ʻactiviti:delegateExpressionʼ attribute to specify the delegate bean in the process definition:! <serviceTask id=“getMimetype" name=“Get Mimetype“ activiti:delegateExpression="${mimetypeGetter}" />
  • 7. Service Tasks: Java Delegate Bean! •  Recommended to extend BaseJavaDelegate class! •  Recommend extending baseJavaDelegate bean! •  If the bean class extends BaseJavaDelegate and the Spring bean definition extends baseJavaDelegate, then the bean will automatically be registered with the activitiBeanRegistry and will have access to the serviceRegistry! <bean id=“mimetypeGetter" parent="baseJavaDelegate" class="org.alfresco.example.MimetypeGetter" />
  • 8. Service Tasks: Java Delegate Bean! public class MimetypeGetter extends BaseJavaDelegate { @Override public void execute(DelegateExecution execution) throws Exception { ScriptNode document = (ActivitiScriptNode) execution.getVariable("dcwkflw_document"); NodeRef nodeRef = document.getNodeRef(); ServiceRegistry serviceRegistry = getServiceRegistry(); FileFolderService fileService = serviceRegistry.getFileFolderService(); FileInfo file = fileService.getFileInfo(nodeRef); String mimetype = file.getContentData().getMimetype(); execution.setVariable("dcwkflw_mimetype“, mimetype); } }
  • 9. Service Tasks: Arbitrary Expression! •  Execute any arbitrary expression! •  The expression may reference any bean defined in Spring and registered with the activitiBeanRegistry! •  A process variable can be specified for the return value using the activiti:result attribute! <serviceTask id=”getMimetype” name="Get Mimetype" activiti:resultVariable="dcwkflw_mimetype" activiti:expression=“${mimetypeGetter.getMimetype(dcwkflow_document)}” />!
  • 11. Listeners! •  Used to react to certain events during workflow execution! •  Two types: TaskLisener and ExecutionListener! •  Three ways to configure, as with ServiceTasks:! •  Listener Class:! <activiti:executionListener class="org.alfresco.example.MyExecutionListener" event=“start” />! •  Listener Bean:! <activiti:taskListener delegateExpression=“${myTaskListener}" event=“create" />! •  Arbitrary Expression <activiti:executionListener expression=“myPojo.myMethod(myVar)" event="start" />
  • 12. Listeners: Execution Listener Events! •  Event: Execution (Workflow) starts or ends! <extensionElements> <activiti:executionListener class=“org.alfresco.example.ExecutionEventLogger" event=“start” /> </extensionElements>! •  Event: Activiti (Workflow Node) starts or ends! <userTask id=“theTask” name=“The Task” > <extensionElements> <activiti:executionListener delegateExpression=“${executionEventLogger}" event=“end” /> </extensionElements> </userTask>! •  Event: Sequence Flow (Transition) is taken! <sequenceFlow id=“theFlow” sourceRef=“theTask” targetRef=“theEnd” > <extensionElements> <activiti:executionListener expression=“${logger.info(execution.eventName)}" /> </ sequenceFlow > </userTask>
  • 13. Listeners: Execution Listener Implementation! Execution Listener class or delegate bean must implement ExecutionListener interface:! public class ExecutionEventLogger implements ExecutionListener { private static final Log LOGGER = LogFactory.getLog(ExecutionEventLogger.class); @Override public void notify(DelegateExecution execution) throws Exception { String eventName = execution.getEventName(); LOGGER.info("Received event: " + eventName); } }!
  • 14. Listeners: Task Listener Events! •  All Task Listeners defined inside task elements:! <userTask id=“theTask” name=“The Task” > <extensionElements> <activiti:taskListener ... [Listener Details] ... /> </extensionElements> </userTask>! •  Event: assignment is called when a task is assigned to a user, usually called before create:! <activiti:taskListener event=“assignment” class=“org.alfresco.example.TaskEventLogger” /> •  Event: create is called when the task is created, after assignment:! <activiti:taskListener event=“create” delegateExpression=“${taskEventLogger}” /> •  Event: completed is called when the task is completed:! <activiti:taskListener event=“completed” expression=“${logger.info(task.eventName)}” />
  • 15. Listeners: Task Listener Implementation! Task Listener class or delegate bean must implement TaskListener interface:! public class ExecutionEventLogger implements TaskListener { private static final Log LOGGER = LogFactory.getLog(ExecutionEventLogger.class); @Override public void notify(DelegateTask task) { String eventName = task.getEventName(); LOGGER.info("Received event: " + eventName); } }
  • 17. Scripting! •  Scripting Lagnuage:! •  JavaScript! •  Activiti Implementations:! •  AlfrescoScriptDelegate! •  ScriptExecutionListener ! •  ScriptTaskListener!
  • 18. Scripting: Scope Variables! •  person ScriptNode, the current user! •  userhome ScriptNode, the home space of the current user! •  execution DelegateExecution, the current execution.! •  task DelegateTask, the current task (ScriptTaskListener only)! •  cancelled boolean, was the execution cancelled (ScriptExecutionListener only)! •  deleted boolean, was the execution deleted (ScriptExecutionListener)!
  • 19. Scripting: Execution Variables! •  All execution variables added to scope! •  Variable names translated from “prefix:suffix” to “prefix_suffix”! •  Associations and noderef properties converted to ScriptNodes! •  Use execution.setVariable(name, value) to modify variables! •  Check if a variable exists using:! if (typeof <variable name> != 'undefined')
  • 20. Scripting: Examples! •  Copy a task variable to a process variable: execution.setVariable('dcwkflw_reviewOutcome', task.getVariable('dcwkflw_reviewOutcome')); •  Set a task property from a pocess variable if it exists: if (typeof bpm_workflowDueDate != 'undefined') task.dueDate = bpm_workflowDueDate; •  Apply an aspect ʻdcwkflw:publishedʼ to a document: var presentation = bpm_package.children[0]; // Get the presentation presentation.addAspect('dcwkflw:published'); // Apply published aspect
  • 21. Timers !
  • 22. Timers! •  Timers are used to delay an event until a specified time/duration! •  Timers can be attached to three types of event:! •  startEvent: Starts the workflow! •  intermediateCatchEvent: Between nodes/events! •  boundaryEvent: Associated with a node (e.g. a userTask)! •  Three ways to set trigger time:! •  timeDate: Triggers at specified date/time! •  timeDuration: Triggers after specified delay duration! •  timeCycle: Triggers repeatedly with specified delay/interval! •  All dates/times/durations/intervals use ISO8601 format!
  • 23. Timers: Start Event Date Example! •  Create a workflow which sends a Christmas Greeting <!-- Start workflow at 12:05 on Christmas Day --> <startEvent id="start" > <timerEventDefinition> <timeDate>2011-12-25T12:05:00</timeDate> </timerEventDefinition> </startEvent> <sequenceFlow id='flow1' sourceRef='start' targetRef='sendGreeting' />
  • 24. Timers: Intermediate Event Delay Example! •  Delay after some service task performs some asynchronous event to wait for the job to complete:! <sequenceFlow id='flow1' sourceRef='asyncJob' targetRef='waitForJobToFinish' /> <!-- Wait 1 hour 30 mins for the job to finish --> <intermediateEvent id="waitForJobToFinish" > <timerEventDefinition> <timeDuration>PT1H30M</timeDate> </timerEventDefinition> </intermediateEvent> <sequenceFlow id='flow2' sourceRef='waitForJobToFinish' targetRef='nextTask' />
  • 25. Timers: Repeating Boundary Event Example! •  Send a reminder email if a task isnʼt completed after 1 week. Repeat the email every day for 3 days:! <userTask id="theTask" > <!-- Wait 1 week, then repeat every 2 days a further 2 times --> <boundaryEvent id="repeatingNotification" cancelActivity="false" attachedToRef="theTask" /> <timerEventDefinition> <timeCycle>R3/P1W/P1D</timeDate> </timerEventDefinition> </boundaryEvent> <sequenceFlow id='flow1' sourceRef='repeatingNotification' targetRef='sendEmail' /> <serviceTask id="sendEmail" activiti:delegateExpression="${sendEmailDelegate}" />