Lab2 - Query
Create a new Flogo application called “TGDB_RESTful_Service”

Click “+ Create” button to build from scratch

Create the first flow for querying metadata

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)

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

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

Clicking “Save” button triggers schema definition generation

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

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

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

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

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

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

Add query activity by selecting GraphBuilder_TGDB -> TGDBQuery activity

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

Map input data for TGDBQuery activity
- QueryType : $flow.queryType

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

Map outputs for Return activity
- queryResult : $activity[TGDBQuery].queryResult (map entire object)

You’ve finished creating metadata query flow

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

Add a name and description for the new flow

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

Click save to generate data schema definition

Flow output data schema same as metadata flow

Add another trigger for receiving content query

POST method for content query

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.

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

Set the reply data (same as metadata flow)


Add query activity by select GraphBuilder_TGDB -> TGDBQuery activity

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

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

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

Map outputs for Return activity
- queryResult: $activity[TGDBQuery].queryResult (map entire object)

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

Test TGDB_RESTful_Service so you can see Nothwind data after querying against TGDB server
For building Flogo application
- In project click “Build” button
- Select the build target OS (in my case Darwin/amd64) then click to build

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

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

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

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

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

Now, Northwind data from TGDB server can be seen
Feedback
Was this page helpful?