Reusing QueryService of Teiid Designer
sarin_ashish Jun 26, 2014 5:54 AMHi,
We are creating a web based client that will act as a replacement of Teiid Designer. As Teiid Designer is responsible for generating SQL queries based on the metadata, we thought that we'll reuse the query generation/parsing capability of Teiid Designer. Our web based client will use the query generation/parsing capability to generate SQLs and pass it to the Teiid runtime.
As I was going through the source code, I saw that there is a QueryService class (located in org,teiid.runtime.client plugin project) that provides access to the QueryParser, Validator and classes like ProcedureService, that help in creating SQL queries based on metadata information.
Now, I've the following questions:
1. Can we take the org,teiid.runtime.client plugin and expose its QueryService as a RESTful web service to out web client. This doesn't seem to be a problem to me if I write code to directly instantiate the QueryService class. If I start from the TeiidRuntimeRegistry class (which eventually creates an instance of QueryService), the dependency on Eclipse plugin infrastructure acts as a bottleneck.
2. If I directly create a QueryService instance, what are the things we need to take care to ensure that QueryService behaves correctly?
I've written the following code to quickly test if QueryParser is correctly initialized. And, it looks like it is.
import org.teiid.designer.query.IQueryParser; import org.teiid.designer.query.IQueryService; import org.teiid.designer.runtime.version.spi.TeiidServerVersion; import org.teiid.designer.udf.IFunctionLibrary.FunctionName; import org.teiid.runtime.client.query.QueryService; public class TestQueryService { public static void main(String args[]) { try { // TeiidRuntimeRegistry registry = // TeiidRuntimeRegistry.getInstance(); IQueryService queryService = new QueryService(new TeiidServerVersion("8", "7", "0")); IQueryParser queryParser = queryService.getQueryParser(); System.out.println(queryService.getReservedWords()); System.out.println(queryService.getJDBCSQLTypeName(1)); System.out.println(queryService.getNonReservedWords()); System.out.println(queryParser.parseCommand("SELECT * FROM ABCD")); System.out.println(queryParser.parseDesignerCommand("SELECT * FROM ABCD")); System.out.println(queryService.createFunctionLibrary().getFunctionName(FunctionName.CONCAT)); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
thanks
ashish