-
Notifications
You must be signed in to change notification settings - Fork 11
Writing a Query Modifier
Pradeeban Kathiravelu edited this page Aug 24, 2018
·
1 revision
Writing a QM is very much like writing a new Data Provider. The only difference is you import a different set of interfaces. Follow the documentation for creating a Data Provider and create a new plugin project.
After creating a brand new project, $PROJECT_HOME/META-INF/MANIFEST.MF
must be modified to import packages that are
required by this project to develop a QM. These packages are as
follows.
Import-Package: com.google.gson;version="2.1.0",
com.google.gson.annotations;version="2.1.0",
com.google.gson.internal;version="2.1.0",
com.google.gson.internal.bind;version="2.1.0",
com.google.gson.reflect;version="2.1.0",
com.google.gson.stream;version="2.1.0",
edu.emory.cci.bindaas.framework.api,
edu.emory.cci.bindaas.framework.event,
edu.emory.cci.bindaas.framework.event.listeners,
edu.emory.cci.bindaas.framework.model,
edu.emory.cci.bindaas.framework.provider.exception,
edu.emory.cci.bindaas.framework.util,
org.apache.commons.logging;version="1.1.1",
org.osgi.framework;version="1.3.0"
One more entry needs to be added in order to tell Bindaas where to pick-up spring configuration files :
Spring-Context: META-INF/spring/*.xml
public class LoggingQRM implements IQueryModifier{
private Log log = LogFactory.getLog(getClass());
@Override
public JsonObject getDocumentation() {
return new JsonObject();
}
@Override
public void validate() throws ModifierException {
// not implemented
}
@Override
public String getDescriptiveName() {
return "Plugin for logging query";
}
@Override
public String modifyQuery(String query, JsonObject dataSource,
RequestContext requestContext, JsonObject modifierProperties)
throws AbstractHttpCodeException {
log.info("Query intercepted [" + query + "]");
return query;
}
@Override
public Map<String, String> modiftQueryParameters(Map<String, String> queryParams, JsonObject dataSource, RequestContext requestContext, JsonObject modifierProperties) throws AbstractHttpCodeException {
return queryParams;
}
}