Lab2 - Query

Build an application to query against TIBCO® Graph Database

Create a new Flogo application called “TGDB_RESTful_Service”

Build RESTful

Click “+ Create” button to build from scratch

Build RESTful

Create the first flow for querying metadata

Build RESTful

Define the data schema for the input of current flow sample data (queryType in string data type).

  • queryType: the value could be “metadata”, “edgetypes” or “nodetypes” (metadata querying flow)

Build RESTful

Saving sample data will evoke schema builder to generate the schema definition from it

Build RESTful

Define the output schema for the current flow by pasting sample output data

  • Content: contains the data of query result
  • Success: true means query go through without error
  • Code: error code
  • Message: error message

Click “Save” button

Build RESTful

Clicking “Save” button triggers schema definition generation

Build RESTful

Add a trigger to receive HTTP request by clicking “+” -> “ReceiveHTTPMessage”

Build RESTful

Select GET, enter resource path “/tgdb/{queryType}” then click “Finish”

Build RESTful

Now we have a trigger with HTTP GET methods and listen on port 9999)

Build RESTful

Click the icon of trigger to map incoming query data to flow input data

Build RESTful

In “Reply Settings” set reply schema make it same as flow output data schema

Build RESTful

In “Map from flow outputs” mapping data.queryResult to $flow.queryResult

Build RESTful

Add query activity by selecting GraphBuilder_TGDB -> TGDBQuery activity

Build RESTful

Select the “TGDB” connection that was created in Lab1 so the TGDBQuery activity executes against the server where the Northwind data was inserted

Build RESTful

Map input data for TGDBQuery activity

  • QueryType : $flow.queryType

Build RESTful

Add return activity to link the query result back to HTTP trigger

Build RESTful

Map outputs for Return activity

  • queryResult : $activity[TGDBQuery].queryResult (map entire object)

Build RESTful

You’ve finished creating metadata query flow

Build RESTful

Click “Create” button to create another flow for querying the content of Northwind graph

Build RESTful

Add a name and description for the new flow

Build RESTful

Define the flow inputs data schema by pasting sample data (for schema detail; see TGDB documentation)

  • queryType: search (for content flow)
  • language: TGQL (TIBCO graph query language) or Gremlin
  • queryString: for TGQL and Gremlin
  • traversalCondition: TGQL only
  • traversalDepth: TGQL only

Build RESTful

Click save to generate data schema definition

Build RESTful

Flow output data schema same as metadata flow

Build RESTful

Add another trigger for receiving content query

Build RESTful

POST method for content query

Build RESTful

Adding sample query for the output (to the flow) setting. To be noticed that the schema is very similar to flow input schema but grouped under “query” keyword.

Build RESTful

Map to flow input

  • queryType: $trigger.pathParams.queryType
  • language: $trigger.body.query.language
  • queryString: $trigger.body.query.queryString
  • traversalCondition: $trigger.body.query.traversalCondition
  • endCondition: $trigger.body.query.endCondition
  • traversalDepth: $trigger.body.query.traversalDepth

Click save

Build RESTful

Set the reply data (same as metadata flow)

Build RESTful

Build RESTful

Add query activity by select GraphBuilder_TGDB -> TGDBQuery activity

Build RESTful

Select “TGDB” connection that was created in Lab1 so the TGDBQuery activity queries the same server updated Northwind data was inserted into

Build RESTful

Map input data for TGDBQuery activity

  • QueryType: $flow.queryType
  • params.language: $flow.language
  • params.queryString: $flow.queryString
  • params.traversalCondition: $flow.traversalCondition
  • params.endCondition: $flow.endCondition
  • params.traversalDepth: $flow.traversalDepth

Build RESTful

Add “Return” activity to link the query result back to HTTP trigger

Build RESTful

Map outputs for Return activity

  • queryResult: $activity[TGDBQuery].queryResult (map entire object)

Build RESTful

The TGDB_RESTful_Service is configured and it’s ready for query Nothwind graph

Build RESTful

Test TGDB_RESTful_Service so you can see Nothwind data after querying against TGDB server

For building Flogo application

  1. In project click “Build” button
  2. Select the build target OS (in my case Darwin/amd64) then click to build

Build RESTful

Once finished you can get your executable in your browser’s download folder

Build RESTful

Find your executable and change its permission to executable then run it

Build RESTful

Switch to local labs -> utilities -> lite folder

  • Launch UI tool by type “npm start”
  • It is required to have npm and lite-server installed before using this tool

Build RESTful

Upon launching the server, the default browser will pop up and show Project GraphBuilder UI utility. For querying data against TGDB server, click “TGDB Data” tab

Build RESTful

A query to TGDB using TGQL expression can be made as shown in screenshot below

Build RESTful

Now, Northwind data from TGDB server can be seen


Last modified December 3, 2020: move docs (4458cdf)