workflow api and workflow services a case study of biodiversity analysis using windows workflow...

13
Workf low API and workflow services A case study of biodiversity analysis using Windows Workflow Foundation Boris Milašinović Faculty of Electrical Engineering and Computing University of Zagreb, C roatia Software Engineering: Computer Science Education and Research Cooperation 13th Workshop, Bansko, Bulgaria, August 25 –September 1, 2013

Upload: juniper-baker

Post on 23-Dec-2015

239 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Workflow API and workflow services A case study of biodiversity analysis using Windows Workflow Foundation Boris Milašinović Faculty of Electrical Engineering

Workflow API and workflow services A case study of biodiversity analysis using Windows Workflow Foundation

Boris

Milašinović

Faculty of Electrical

Engineering and

Computing

University of Zagreb, Croatia

Software Engineering: Computer Science Education and Research Cooperation13th Workshop, Bansko, Bulgaria, August 25 –September 1, 2013

Page 2: Workflow API and workflow services A case study of biodiversity analysis using Windows Workflow Foundation Boris Milašinović Faculty of Electrical Engineering

What is workflow?0 The automation of a business process, in whole or part, during

which documents, information or tasks are passed from one participant to another for action, according to a set of procedural rules.

0 [Workflow Management Coalition, Terminology & Glossary, Document Number WFMC-TC-1011]

0 Why workflow?0 Not (only) coding activities but orchestrating them and gluing

together0 Usually people associate workflows with

0 big automated systems0 various document management systems with many users0 various BPM tools0 But… nothing of that in this case study

Page 3: Workflow API and workflow services A case study of biodiversity analysis using Windows Workflow Foundation Boris Milašinović Faculty of Electrical Engineering

Case study context - simplified description

0 Input: 0 geocoded findings of floristic species filtered according to

various (and in future expandable) filters0 an ESRI GIS layer: shape file with polygons and dbf file with

additional information (attributes) for each polygon0Calculation:

0 Determine which findings belong to which polygon0 Calculate biodiversity and ecological niche for a polygon and/or

set of polygons having same attribute value0Output:

0 Create new dbf file extended with calculated data0 Create result matrices (ecological niche, biodiversity data, taxa

data, additional data...)

Page 4: Workflow API and workflow services A case study of biodiversity analysis using Windows Workflow Foundation Boris Milašinović Faculty of Electrical Engineering

Biodiversity and ecological niche analysis

0Ecological niche analysis0 Species distribution - find in how many polygons (of the same

GIS attribute) a species is present0Biodiversity analysis

0 – diversity: number of different species in an areaα0 Research intensity: Number of findings of each finding source

per spatial unit (single polygon and/or GIS attribute consisting of multiple polygons)

0 Categories data0F(p, V) = N where V is one of possible values in a category (e.g. an

ecological index) => N species in polygon p have value V

Page 5: Workflow API and workflow services A case study of biodiversity analysis using Windows Workflow Foundation Boris Milašinović Faculty of Electrical Engineering

Why Workflow?0 Visualizing the code

0 Frequent changes of order during development0 Especially hard when parts of code are run in parallel => drag & drop

0 Result set depends on user’s permission and input criteria0many (hard to read) if-else/switch parts of code => flowchart

0 Logging, benchmarking, robustness0 Try-catch blocks with stopwatch/log code before and after =>

composite activities0 Continuation depends on an activity success/failure

0 Activities with many input and output arguments0 using C# out/ref for parameters?0 many new classes used only once?

0 Layering application

Page 6: Workflow API and workflow services A case study of biodiversity analysis using Windows Workflow Foundation Boris Milašinović Faculty of Electrical Engineering

Why Windows Workflow Foundation?

0Choosing one (from too many others) that easily plugs into environment and existing code

0Windows Workflow Foundation (WF)0 workflow engine and API integrated in .NET

0differs from BPM tools as it is not intended for automatic form design

0main purpose is control flow: sequential workflows, flowcharts and state machines

0easily used from an application or exposed as a web service

0workflow stored in xaml file (except code of custom activities) and designed inside Visual Studio

Page 7: Workflow API and workflow services A case study of biodiversity analysis using Windows Workflow Foundation Boris Milašinović Faculty of Electrical Engineering

An excerpt from the workflow (1)

Page 8: Workflow API and workflow services A case study of biodiversity analysis using Windows Workflow Foundation Boris Milašinović Faculty of Electrical Engineering

An excerpt from the workflow (2)

Page 9: Workflow API and workflow services A case study of biodiversity analysis using Windows Workflow Foundation Boris Milašinović Faculty of Electrical Engineering

Workflow Activities0built in activities0 custom ones

0 simple sequential activities (extending CodeActivity)

0 long running activities (AsyncCodeActivity)

0 complex activities (NativeActivity) - e.g. composite activities

0 combination of existing ones (mini-workflow)

0 each activitiy have Input/Output arguments

0workflow has own variables

Page 10: Workflow API and workflow services A case study of biodiversity analysis using Windows Workflow Foundation Boris Milašinović Faculty of Electrical Engineering

What have been done0Core GIS calculation extracted to separate library

referenced by the workflow project0Workflow project contains

0 Composite activity for logging and benchmarking + try/catch0 10-15 rather simple custom activities (20-100 lines of code)0 A few custom activities designed as mini workflows

consisting of built-in activities and custom ones0 2 main workflows:

0EcologicalNiche.xaml0BioDiversityWorkflow.xaml

0Used in a separate workflow (web) service project0 can be used from an application if needed

Page 11: Workflow API and workflow services A case study of biodiversity analysis using Windows Workflow Foundation Boris Milašinović Faculty of Electrical Engineering

Exposing workflow as a web service

0Precisely WCF service so does not need to be HTTP(S) protocol0 WCF service contract shared or

WSDL can be generated0PickActivity with many branches

0 Branches wait for invocation of a method from WCF service

0 start new instance or continues an existing one

0 common (initial) code before PickActivity executed every time new instance is created

0 Trigger – Action pattern0Trigger: receive and send response0Action: run after response

Page 12: Workflow API and workflow services A case study of biodiversity analysis using Windows Workflow Foundation Boris Milašinović Faculty of Electrical Engineering

Problems0 Not so easy to learn WF and some initial effort is needed to

become familiar with the tool0 Demanding GUI (relatively fast computer needed)0 Rectangular design, quite large and wide, not printable0 Declarative code

0 Error in xaml can cause visual design to fail0 Error descriptions and debugging not so clear like in „normal”

code0 Dependency graph not correct if project referenced only in xaml0 Refactoring is painful

0 changing activity name, namespace or parameter name does not make changes in xaml file

0Removing a parameter from a custom activity does not update xaml file – changes have to be done manually in xaml file

Page 13: Workflow API and workflow services A case study of biodiversity analysis using Windows Workflow Foundation Boris Milašinović Faculty of Electrical Engineering

Conclusion0WF (or similar workflow engine) is very useful

0 Visualize a process0 Helps layering application0 Offers easy use from an application or advanced scenarios with

web services0 Enables flowchart design0 Ease changing order of a execution (drag & drop and visual

design)0 Activities are well defined with input/output parameters and

easy to test

0… but still have some teething troubles0 …but (in personal opinion) have bright future