public void service(SourceBean request, SourceBean response) {
String searchType;
String searchFilter;
QbeEngineInstance engineInstance;
QueryCatalogue queryCatalogue;
Set<Query> queries;
JSONObject queryJSON;
JSONObject responseJSON;
JSONArray resultsJSON;
logger.debug("IN");
try {
super.service(request, response);
searchType = getAttributeAsString(SEARCH_TYPE);
logger.debug("Parameter [" + SEARCH_TYPE + "] is equals to [" + searchType + "]");
if(StringUtilities.isEmpty(searchType)) searchType = SEARCH_TYPE_FULLDUMP;
searchFilter = getAttributeAsString(SEARCH_FILTER);
logger.debug("Parameter [" + SEARCH_FILTER + "] is equals to [" + searchFilter + "]");
// retrieve first query from catalog
engineInstance = getEngineInstance();
queryCatalogue = engineInstance.getQueryCatalogue();
queries = new HashSet();
if(SEARCH_TYPE_FULLDUMP.equalsIgnoreCase(searchType)) {
queries.addAll( queryCatalogue.getAllQueries(false) );
} else if (SEARCH_TYPE_BYID.equalsIgnoreCase(searchType)) {
queries.add(queryCatalogue.getQuery(searchFilter));
} else if (SEARCH_TYPE_BYNAME.equalsIgnoreCase(searchType)) {
queries.addAll(queryCatalogue.getQueryByName(searchFilter));
} else if (SEARCH_TYPE_BYTYPE.equalsIgnoreCase(searchType)) {
if(searchFilter.equalsIgnoreCase("first")) {
queries.add(queryCatalogue.getFirstQuery());
}
}
// serialize query
resultsJSON = new JSONArray();