-
Notifications
You must be signed in to change notification settings - Fork 11
Bindaas Modifiers
- 1 Overview
- 2 IModifier Interface
- 3 IQueryModifier Interface
- 4 IQueryResultModifier interface
- 5 ISubmitPayloadModifier interface
- 6 More Information
Bindaas Framework has a pluggable architecture that provides variety of interfaces for various classes of applications. Bindaas can be easily extended and customized by implementing these interfaces. In this article we shall learn how to write applications using the Modifier interface. There are three different types of Modifiers that Bindaas provides :
- Query Modifier (QM)
- Query Result Modifier (QRM)
- Submit Payload Modifier (SPM)
QM is associated with the Query Execution workflow. When a RESTful request is fired,HTTP GET, right before delegating control to a QueryHandler, the raw query is passed through a series of Query Modifiers, if declared by the Query Author at the time of creating the query API. These QMs are intended to "change" the query is some meaningful way before passing it downstream. A classic use-case of a QM would be performing access-control by looking at the query and the privileges of the user who invoked this API.
QRM is also associated with the Query Execution workflow, but instead of acting on the query it acts on the results of query execution. It is intended to augment or modify the results in some meaningful way before writing it over the wire. For example, the Image Download QRM written for the TCIA API use-case processes raw JSON produced by the upstream QueryHandler, looks-up physical filepaths of the images and packages them in a zip file while streaming it over the network.
SPM is associated with the Submit API Execution workflow. Right before the data BLOB produced as a result of HTTP POST request is supplied to a Submit Handler, it is passed through a SPM, which is suppose to modify/preprocess it in some meaningful way. SPM could be used to process DICOM images, extract relevant DICOM tags and pass it on to the downstream database for storage.
The source code for sample modifiers that are referenced in this section
can be found in the Bindaas repository at : source/projects/demos/LoggingModifiers
public interface IModifier {
public JsonObject getDocumentation(); // documentation pertaining the Modifier (optional)
public void validate() throws ModifierException; // any validation that needs to performed (optional)
public String getDescriptiveName(); // descriptive name of the Modifier plugin. Used in the webconsole to identify this plugin (required)
}
public interface IQueryModifier extends IModifier {
public String modifyQuery(String query , JsonObject dataSource , RequestContext requestContext, JsonObject modifierProperties) throws AbstractHttpCodeException;
public Map<String,String> modiftQueryParameters(Map<String,String> queryParams , JsonObject dataSource , RequestContext requestContext , JsonObject modifierProperties) throws AbstractHttpCodeException;
}
String query :
Query passed on to the QM before it passes to
QueryHandler
JsonObject dataSource :
Configuration object hosting values specified
at the time of creating an instance of Data Provider
RequestContext requestContext :
Context object representing the state
of the request. Contains information about the user who invoked this API
JsonObject modifierProperties :
Properties required to configure this
QM
Map<String,String> queryParams :
Runtime query parameters provided by
the user
The method returns the query modified by the plugin.
public interface IQueryResultModifier extends IModifier {
public QueryResult modifyQueryResult(QueryResult queryResult , JsonObject dataSource , RequestContext requestContext , JsonObject modifierProperties , Map<String,String> queryParams) throws AbstractHttpCodeException;
}
QueryResult queryResult :
QueryResult object resulting from the query
API execution
JsonObject dataSource :
Configuration object hosting values specified
at the time of creating an instance of Data Provider
RequestContext requestContext :
Context object representing the state
of the request. Contains information about the user who invoked this API
JsonObject modifierProperties :
Properties required to configure this
QRM
Map<String,String> queryParams :
Query parameters provided with the
URL
The method returns the modified QueryResult object.
public interface ISubmitPayloadModifier extends IModifier {
public InputStream transformPayload( InputStream data , SubmitEndpoint submitEndpoint , JsonObject modifierProperties, RequestContext requestContext) throws AbstractHttpCodeException;
public String transformPayload( String data , SubmitEndpoint submitEndpoint , JsonObject modifierProperties , RequestContext requestContext) throws AbstractHttpCodeException;
}
InputStream/String data :
data to be processed by the SubmitHandler
SubmitEndpoint submitEndpoint :
The instance of submitEndpoint
associated with the request
RequestContext requestContext :
Context object representing the state
of the request. Contains information about the user who invoked this API
JsonObject modifierProperties :
Properties required to configure this
QRM
The method returns the modified data object.
Writing a Query Modifier Writing a Query Result Modifier Writing a Payload Modifier Testing and distributing modifiers