Executing Pass-Through Queries
In addition to providing object model-like access to the Digital.ai Agility Data API, the Java SDK also provides a way to execute queries using the Query API. The Query API provides read-only access to Agility data, and allows you to submit hierarchical queries in a JSON or YAML format. In addition, data returned from the Query API is in a JSON format.
Executing a JSON Query
In this example, a JSON query is used to get all Story assets with an estimate greater than ten:
String query =
"{" +
" \"from\": \"Story\"," +
" \"select\": [\"Name\",\"Number\"]" +
"}";
String result = services.executePassThroughQuery(query);
System.out.println(result);
This is an example ofthe raw JSON data that is returned:
[
[
{
"_oid": "Story:6555",
"Name": "Test Story on Scope:6527 - Name attribute"
},
{
"_oid": "Story:6588",
"Name": "Test Story Scope:6527 Query filter with multiple attributes"
}
]
]
Executing a YAML Query
In this example, a YAML query is used to get all Story assets with an estimate greater than ten, the raw JSON that is returned is the same as when submitting the query in a JSON format:
String query = "from: Story\n" +
"select:\n" +
" - Name\n" +
" - Number\n";
String result = services.executePassThroughQuery(query);
System.out.println(result);