1 Task 4 – Advanced Topics - Introduction Chris Woyton Support/Training ...

15
1 Task 4 – Advanced Topics - Introduction Chris Woyton Support/Training [email protected]

Transcript of 1 Task 4 – Advanced Topics - Introduction Chris Woyton Support/Training ...

Page 1: 1 Task 4 – Advanced Topics - Introduction  Chris Woyton  Support/Training  Chris.woyton@kineticdata.com.

1

Task 4 – Advanced Topics - Introduction Chris Woyton Support/Training [email protected]

Page 2: 1 Task 4 – Advanced Topics - Introduction  Chris Woyton  Support/Training  Chris.woyton@kineticdata.com.

2

Task 4 – Advanced Topics – What we’re going to learn.

Source Data Accessing Source Data Setting up a “harness” Retrieving Results Processing Results

Routine Scope (time permitting) Global vs Local Calling a Routine from an External Source

Page 3: 1 Task 4 – Advanced Topics - Introduction  Chris Woyton  Support/Training  Chris.woyton@kineticdata.com.

3

Source Data – What is it?

Source Data is the raw presentation of data submitted to a Task Tree. It is in JSON format.

Page 4: 1 Task 4 – Advanced Topics - Introduction  Chris Woyton  Support/Training  Chris.woyton@kineticdata.com.

4

Source Data – Why use it?

Source Data has ALL the data, not just what is exposed by the source file.

Useful for AdHoc Sources. Always available. Good starting point for creating Source Files.

Page 5: 1 Task 4 – Advanced Topics - Introduction  Chris Woyton  Support/Training  Chris.woyton@kineticdata.com.

5

Source Data – Activity 1 – Planning. Use Case: create a Task Tree that takes two numbers and multiplies

them together. Be able to extract the terms to be multiplied from the source. Use an Echo node to perform the main function of the Tree.

Page 6: 1 Task 4 – Advanced Topics - Introduction  Chris Woyton  Support/Training  Chris.woyton@kineticdata.com.

6

Source Data – Activity 1 – Create the “stub” Tree. Open the Kinetic Task 4 console. Select “Build” Add an Echo Node with the following parameter

<%= @source['Data'] %> Save the Tree.

Page 7: 1 Task 4 – Advanced Topics - Introduction  Chris Woyton  Support/Training  Chris.woyton@kineticdata.com.

7

Source Data –Activity 2 – build a Harness. A harness page lets us specify precise parameters. It’s a good method to see what format the Source Data will be in.

Page 8: 1 Task 4 – Advanced Topics - Introduction  Chris Woyton  Support/Training  Chris.woyton@kineticdata.com.

8

Source Data – Activity 2 – Build a Harness. Create a Text File with your favorite editor. Insert the following HTML:<html> <body> <form action="http://matrix.kineticdata.com/kinetic-task/app/api/v1/run-tree/Playground/Test/MyTree" method="post"> Term1: <input type="text" name="Term1"/></br> Term2: <input type="text" name="Term2"/><br> <input type="submit" value="Submit"/></form></body></html>

Page 9: 1 Task 4 – Advanced Topics - Introduction  Chris Woyton  Support/Training  Chris.woyton@kineticdata.com.

9

Source Data – Activity 2 – Build a Harness. The important line of our harness is the URL:

<form action="http://matrix.kineticdata.com/kinetic-task/app/api/v1/run-tree/Playground/Test/MyTree" method="post">

Note the naming of the URL matches the Tree “path” in the Builder: /kinetic-task/app/api/v1/run-tree/Playground/Test/MyTree

Page 10: 1 Task 4 – Advanced Topics - Introduction  Chris Woyton  Support/Training  Chris.woyton@kineticdata.com.

10

Source Data – Activity 2 – Build a harness. Save the file. Open it with your favorite Web Browser. You should see something like this:

Page 11: 1 Task 4 – Advanced Topics - Introduction  Chris Woyton  Support/Training  Chris.woyton@kineticdata.com.

11

Source Data – Activity 2 – Execute the Tree. Enter 2 numbers in the “Term”fields. Submit. You should see a result similar to this: {"message":"Initiated run #6485 for the \"Playground :: Test :: MyTree\"

Tree.","run":{"createdAt":"2015-05-07T12:33:36.307Z","createdBy":“Demo","id":6485}}

Note the Run Number.

Page 12: 1 Task 4 – Advanced Topics - Introduction  Chris Woyton  Support/Training  Chris.woyton@kineticdata.com.

12

Source Data – Activity 2 – Build a Harness. Open the Run in the Task Admin Console. Note the results of the Echo Node. You should see something like this:

{"Term2":["4"],"Term1":["17"]}

Page 13: 1 Task 4 – Advanced Topics - Introduction  Chris Woyton  Support/Training  Chris.woyton@kineticdata.com.

13

Source Data – Activity 3 – Parse our Data. Now that we have results back from the harness, we can proceed to

work on providing the functionality.

The JSON object is natively available in the Task Engine and usable via an Echo node.

No separate handler is needed!

Page 14: 1 Task 4 – Advanced Topics - Introduction  Chris Woyton  Support/Training  Chris.woyton@kineticdata.com.

14

Source Data – Activity 3 – Parse our Data Note the structure of the JSON being returned:

A label attached to an array. When we create the JSON object, we can reference the terms by

name and values by index. For example:

txt = JSON.parse(@source['Data'])txt['Term2'][0].to_i * txt['Term1'][0].to_i

Page 15: 1 Task 4 – Advanced Topics - Introduction  Chris Woyton  Support/Training  Chris.woyton@kineticdata.com.

15

Advanced Task 4

Questions?