OData Translator Paging Extension in Web Services Translator
ws6wws6w Oct 17, 2018 6:41 PMHello, all.
I just joined the group today and have just been working in JBoss for 5 months.
I have been tasked with adding the OData Translator paging capability to the Web Services Translator. The OData translator paging is in ODataSQLVisitor.java. The pagination is in ODataSQLVIsitor::buildURL(), in which both $top and $skip are arguments to uriBuilder.queryParam(). My team has written a test driver program that instantiates an ODataSQLVisitor object and tests the paging.
@Test
public void testLimit() throws Exception {
helpExecute("SELECT ContactName FROM Customers limit 10", "Customers?$select=ContactName&$top=10");
}
@Test
public void testLimitOffset() throws Exception {
helpExecute("SELECT ContactName FROM Customers limit 10, 19", "Customers?$select=ContactName&$skip=10&$top=19");
}
The test driver's helpExecute() function actually instantiates the ODataSQLVisitor object and compares the URLs returned to the expected values.
private void helpExecute(String query, String expected) throws Exception {
Select cmd = (Select)this.utility.parseCommand(query);
ODataSQLVisitor visitor = new ODataSQLVisitor(this.translator, utility.createRuntimeMetadata());
visitor.visitNode(cmd);
String actual = URLDecoder.decode(visitor.buildURL(), "UTF-8");
assertEquals(expected, actual);
}
private void helpExecute(String query, String expected) throws Exception {
Select cmd = (Select)this.utility.parseCommand(query);
ODataSQLVisitor visitor = new ODataSQLVisitor(this.translator, utility.createRuntimeMetadata());
visitor.visitNode(cmd);
String actual = URLDecoder.decode(visitor.buildURL(), "UTF-8");
assertEquals(expected, actual);
}
The function invokehttp() in the WS Translator seems to be the way to go to get the streams of data and translate the SQL queries to pass to the OData Translator.
The link: https://docs.jboss.org/author/display/TEIID/OData+Translator has the line:
"Native or direct query execution is not supported through OData translator. However, user can use Web Service Translator's invokehttp method directory to issue a Rest based call and parse results using SQLXML."
I think the data flow involves the database being directly connected to the OData Translator, with the queries going from OData to the database, and the results going from the database to OData. In turn, the Web Services Translator sends the query to the OData Translator, which passes the results to Web Services, which in turn returns the results to the driver program (like the Test Java programs). The results are non-paginated; the task is to include pagination, which is to be passed to the OData Translator to be used in the variables top and skip.
Am I clear on what I am trying to do, and am I on the right track as far as the solution? I would appreciate any help I can get. Getting a SQL query from WS Translator in a form that the OData Translator can use is the biggest hurdle.