I am trying to extend the Web Services translator to have pagination like that of the OData translator, which uses the $top variable to choose the top number of results to choose, and $skip variable to choose how many results to jump over. Even though OData is an extension of Web Services, the latter does not have any pagination. The Web Services translator will be designed to have a more general approach to pagination rather than using the OData specific $top and $skip values. The Web Services translator uses $rows and $page, but the final product should be more generic to integrate with multiple data sources. I am just learning Data Virt and Teiid, and want to make progress on this task.
Asked
Active
Viewed 63 times
0
-
1https://stackoverflow.com/questions/52097451/extending-jboss-data-virt-ws-translator-to-handle-paginated-source/52106939#52106939 – Ramesh Reddy Sep 21 '18 at 13:48
-
Thank you. That is my understanding of how to do it. Specifically, though, which OData Java file would be the correct one to look at? Looking at the code, I found this to be the calling sequence: BaseQueryExecution.java -> ODataExecutionFactory.java -> ODataQueryExecution.java -> ODataSQLVisitor.java. I think I should look in ODataExecutionFactory.java or ODataQueryExecution.java. – PyNerd Sep 21 '18 at 14:56
-
Basically, this depends on the rest service you are consuming, that should support a way to query results in a paginated way. The way OData works is with every response it also includes a special url called 'nextToken' if there are more results available. Then the extended web service translator in Teiid should be smart enough to sniff out that URL from response and at the end of current batch of rows excute the that next URL to fetch more results and serve until there are no more. if results are ordered then $top and $skip could be handled by Teiid runtime engine. – Ramesh Reddy Sep 21 '18 at 15:12
-
Working with some colleagues, I came up with the following function. – PyNerd Oct 24 '18 at 21:14
-
`private Blob insertPaging(CommandBuilder cmd, String baseSQLCmd, int rows, int page) { /* Error checking */ /* Negative page or rows values are invalid */ if (rows < 0){ System.out.println("Invalid rows value: " + rows.toString()); System.out.println("rows cannot be negative"); return; } if (page < 0) { System.out.println("Invalid page value: " + rows.toString()); System.out.println("page cannot be negative"); return; } /* Parse the SQL query */ String baseSQLQuery = (String)this.utility.parseCommand(query);` – PyNerd Oct 24 '18 at 21:16
-
`/* Append the rows and page value for the corresponding OData Translator $top and $skip values, if present */ String topString = ""; String skipString = ""; if (rows > 0 and rows != null) { topString = "&$top=" + String.valueOf(rows); if (page > 0 and page != null) { skipString = "&skip=" + String.valueOf(page); } } /* Determine queryString and command string for use in invokeHttp */ String queryString = baseSQLQuery + topString + skipString; String cmdString = "call invokeHttp(action => 'GET', endpoint => '" + queryString + "', stream => 'TRUE'";` – PyNerd Oct 24 '18 at 21:16
-
`/* Execute invokeHttp and return Blob */ Call call = (Call)cb.getCommand(cmdString); /* The this pointer is used because we are in WSExecutionFactory */ BinaryWSProcedureExecution pe = new BinaryWSProcedureExecution(call, rm, Mockito.mock(ExecutionContext.class), this, mockConnection); pe.execute(); List> result = pe.getOutputParameterValues(); Blob b = (Blob) result.get(0); return b; }` – PyNerd Oct 24 '18 at 21:17
-
I would appreciate any comments about my method. I think **invokeHttp** is the route to go, rather than using a bunch of spaghetti code. – PyNerd Oct 24 '18 at 21:18