Also make a iteration strategy
1 file changed
tree: a3a04d1af92bf7b83892fcfae31b60e44406b420
  1. .gitignore
  2. .travis.yml
  4. helloanyone.json
  5. helloanyone.t2flow
  6. helloanyone.wfbundle
  7. helloworld.json
  8. helloworld.t2flow
  9. helloworld.wfbundle
  10. pom.xml
  11. src/

SCUFL2 examples

Examples of using the SCUFL2 API v0.14.0.

Build Status

As this code is meant only as examples that you can extend and modify, the groupId and package name are com.example, which should be changed in your application.


Download the scufl2-examples-0.x.x-standalone.jar from the latest build, or browse the Maven snapshot repository.

This is a standalone executable JAR (see below).


To build, you'll need Maven 3.0.5 or newer, and run mvn clean install:

C:\Users\stain\workspace\scufl2-examples> mvn clean install

[INFO] ------------------------------------------------------------------------
[INFO] Building SCUFL2 examples 0.1.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ scufl2-examples ---
[INFO] Deleting C:\Users\stain\workspace\scufl2-examples\target
[INFO] Installing C:\Users\stain\workspace\scufl2-examples\target\scufl2-examples-0.1.1-SNAPSHOT.jar to C:\Users\stain\.m2\repository\com\example\scufl2-examples\0.1.1-SNAPSHOT\scufl2-examples-0.1.1-SNAPSHOT.jar
[INFO] Installing C:\Users\stain\workspace\scufl2-examples\pom.xml to C:\Users\stain\.m2\repository\com\example\scufl2-examples\0.1.1-SNAPSHOT\scufl2-examples-0.1.1-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.223s
[INFO] Finished at: Tue Apr 23 11:00:27 BST 2013
[INFO] Final Memory: 15M/243M
[INFO] ----------------    

To run the examples, see the folder target\scufl2-examples which has a bin/ executable for each of the below tools. Note that these tools require the provided bin/ and lib/ folder structure.

Alternatively you can use java -jar target/scufl2-examples-0.2.0-SNAPSHOT-standalone.jar - this is a standalone JAR file that can execute any of the tools as the first argument.

Linux users can install this with:

chmod 755 target/scufl2-examples-*-standalone.jar
sudo cp target/scufl2-examples-*-standalone.jar /usr/local/bin/scufl2tool

as long as JAR files are recognized as executables:

stain@biggie-mint ~/src/scufl2-examples $ target/scufl2-examples-0.2.0-SNAPSHOT-standalone.jar 
SCUFL2 workflow tool
Usage: scufl2tool <tool> [option] ...

Available tools:
t2flowtowfbundle - Convert t2flow workflows to wfbundle
jsonexport - Export JSON structure of workflow
processornames - List tree of processor names in workflow
servicetypes - List service types used in workflow
workflowmaker - Create an example workflow programmatically


This tool lists a tree of the processor names in the workflows of the given bundle.

C:\Users\stain\workspace\scufl2-examples> target\scufl2-examples\bin\processornames helloworld.t2flow
+ Hello_World
  - hello

C:\Users\stain\workspace\scufl2-examples> target\scufl2-examples\bin\processornames helloanyone.t2flow
+ Hello_Anyone
  - Concatenate_two_strings
  - hello

See the source code for com.example.ProcessorNames for how this is implemented.


This tool lists the URIs of the types of services (activities) used in the workflow.

C:\Users\stain\workspace\scufl2-examples> target\scufl2-examples\bin\servicetypes helloanyone.t2flow

See the source code for com.example.ServiceTypes for how this is implemented.


This tool shows how to construct a workflow from scratch and save it as a SCUFL2 wfbundle.

C:\Users\stain\workspace\scufl2-examples> target\scufl2-examples\bin\workflowmaker
Written to C:\Users\stain\AppData\Local\Temp\test6264603033381329995.wfbundle

WorkflowBundle '4fdb73e3-a5c6-41a8-aafb-32f67ca552b2'
  MainWorkflow 'Echotest'
  Workflow 'Echotest'
    In 'in1'
    Out 'out1'
    Processor 'p'
      In 'pIn'
      Out 'pOut'
      'in1' -> 'p:pIn'
      'p:pOut' -> 'out1'
  MainProfile 'default'
  Profile 'default'
    Activity 'myBeanshell'
      Type <>
      In 'in1'
      Out 'out1'
    ProcessorBinding '434e7226-1d7f-498d-a19f-75be9f38f266'
      Activity 'myBeanshell'
      Processor 'Echotest:p'
        'pIn' -> 'in1'
        'out1' -> 'pOut'
    Configuration 'beanshellConf'
      Type <>
      Configures 'activity/myBeanshell'
      Property <>
        '''out1 = in1'''

See the source code for com.example.WorkflowMaker for how this is implemented.


This tool shows how to convert a .t2flow file to a SCUFL2 .wfbundle.

C:\Users\stain\workspace\scufl2-examples> rm helloworld.wfbundle

C:\Users\stain\workspace\scufl2-examples> target\scufl2-examples\bin\t2flowtowfbu

C:\Users\stain\workspace\scufl2-examples> unzip -t helloworld.wfbundle
Archive:  helloworld.wfbundle
    testing: mimetype                 OK
    testing: META-INF/                OK
    testing: META-INF/manifest.xml    OK
    testing: history/                 OK
    testing: history/8781d5f4-d0ba-48a8-a1d1-14281bd8a917.t2flow   OK
    testing: workflow/                OK
    testing: workflow/Hello_World.rdf   OK
    testing: profile/                 OK
    testing: profile/taverna-2.2.0.rdf   OK
    testing: annotation/              OK
    testing: annotation/0c2f3c2c-7b5f-49cc-a448-92d707da3795.rdf   OK
    testing: annotation/48c04fe7-90f8-42f2-be61-a0480aa826d1.rdf   OK
    testing: annotation/9558f2e4-b629-4d1d-a62e-8c0dd39d7746.rdf   OK
    testing: workflowBundle.rdf       OK
    testing: META-INF/container.xml   OK
No errors detected in compressed data of helloworld.wfbundle.

See the source code for for how this is implemented.

The included files helloworld.wfbundle and helloanyone.wfbundle are examples of converting helloworld.t2flow and helloanyone.t2flow


This tool exports a JSON structure of the workflow, including basic annotations on workflows, ports, processors, nested workflows and revision log of the workflows.


c:\Users\stain\src\scufl2-examples> target\scufl2-examples\bin\jsonexport -h
Export workflow structore as JSON.
Usage: jsonexport [filename] ...
If the filename is - the workflow will be read from STDIN and
JSON written to STDOUT.
Otherwise, the file is read as a workflow (t2flow, workflow bundle)
and written as JSON to a file with the .json extension.
Multiple filenames can be given. JSON filenames are written to STDOUT

Converting multiple files:

c:\Users\stain\src\scufl2-examples> target\scufl2-examples\bin\jsonexport helloworld.t2flow helloanyone.wfbundle

See the converted helloworld.json and helloanyone.json

Example using STDIN/STDOUT:

c:\Users\stain\src\scufl2-examples> target\scufl2-examples\bin\jsonexport - < helloworld.t2flow
  "@context" : [ "", {
    "@base" : ""
  } ],
  "id" : "",
  "workflow" : {
    "id" : "workflow/Hello_World/",
    "name" : "Hello_World",
    "revisions" : [ {
      "id" : "",
      "generatedAtTime" : "2012-01-03T15:12:21Z"
    } ],
    "inputs" : [ ],
    "outputs" : [ {
      "name" : "greeting",
      "id" : "workflow/Hello_World/out/greeting"
    } ],
    "processors" : [ {
      "id" : "workflow/Hello_World/processor/hello/",
      "name" : "hello",
      "inputs" : [ ],
      "outputs" : [ {
        "name" : "value",
        "id" : "workflow/Hello_World/processor/hello/out/value",
        "depth" : 0
      } ]
    } ],
    "datalinks" : [ {
      "receivesFrom" : "workflow/Hello_World/processor/hello/out/value",
      "sendsTo" : "workflow/Hello_World/out/greeting"
    } ],
    "controllinks" : [ ],
    "" : "One of the simplest workflows possible. No workflow input ports, a single workflow output port \"greeting\",  outputting \"Hello, world!\" as produced by the String Constant \"hello\".",
    "" : "Stian Soiland-Reyes",
    "" : "Hello World"