Managing Filtered Queries
A query from a TIBCO Scribe® Solution can either request all of the data for a specific entity, or include one or more filtering criteria or constraints. When a query that includes filtering criteria reaches the Connector, it is the Connector developer's responsibility to parse the constraints, filter the data, and return only what the user has requested.
Before you begin to create parsing code, it can be helpful to understand that a query with filter criteria contains one or more ComparisonExpressions, such as Name = "Bob". If there are multiple ComparisonExpressions, they are connected by the following logical operators:
- AND
- OR
Parsing for a single ComparisonExpression is fairly simple. For example, if a user creates a filter on TIBCO Scribe® requesting only data for which Name = “Bob”, the constraint is similar to the following example:
ComparisonExpression
LeftValue = Name
Operator = Equals
RightValue = "Bob"
Logical expressions, however, have two expression properties. For example:
LogicalExpression
LeftExpression
LeftValue = Name
Operator = Equals
RightValue = "Bob"
LogicalOperator = OR
RightExpression
LeftValue = Name
Operator = Equals
RightValue = "Jimmy"
For LogicalExpressions, note that the LeftExpression and RightExpression properties are both Expression, rather than ComparisonExpression. This allows nesting of additional logical expressions.
Filtered Queries With REST Web Services
For REST Web Service Connectors, you need to understand how your REST API behaves:
- Some REST APIs may allow filtering to be sent, which limits the data that is returned from their server. You may then need to apply any remaining filters that you couldn’t include in the API call to the data that is returned.
- The REST Web Service Sample Connector is based on the GoToWebinar REST API, where you can only filter based on Start and End dates. The Connector searches for these fields in the query and applies them to the API call. It then applies all other filters to the results that are returned.
See the REST Web Service Sample CDK project for an example of a recursive method used to parse through these expressions.
See Also