How to implement filter and pagination in apache olingo v4 web service

I am new to apache olingo web service. I hit the last two weeks to implement a filter and pagination on my service. I use the latest version of olingo 4. I google and watch a lot of blogs, but there are no clear explanations. Please help me with a sample code. It will be more good for me.

Below is my script,

  • I retrieve data from an existing web service as XML, and then parse the XML using JAXB to make it like a list of objects in olingo web services.

    Here is how I can apply a filter. If I have a $ filter filter in my URL, it means that I selected an exception from the page not found. If I remove, it means that it will work and give the full result.

    My question is: how to apply the olingo filter in an XML string or How to apply it in the list of objects that I have in a method. Please give me an explanation with some sample code.

  • I need to specify pagination on my JSON response. I need to limit the JSON value to 25 per page and you will also need the following page URL (25 to 50). How to implement this as well.

I overcame many blogs, but did not work for me. Here is https://templth.wordpress.com/2015/04/03/handling-odata-queries-with-elasticsearch/

On this blog they did not explain with the full code. My problem is that I get data from an existing web service as an XML string and parse it and have an entity in the list.

And I also link to this blog,

https://olingo.apache.org/doc/odata2/tutorials/Olingo_Tutorial_AdvancedRead_FilterVisitor.html

This blog also explains how to build a query. My problem is how to implement $ filter, $ select, etc. from ODATA in my web service and how to filter from an xml string or list of objects

Please offer me a sample code. Thanks.

+4
source share
1 answer

The Olingo team provides a wealth of well-organized help resources. Examples of projects can be found at the following instructions: http://olingo.staging.apache.org/doc/odata4/tutorials/prerequisites/prerequisites.html#tutorial-sources A complete tutorial on hte pagination can be found here: https: // olingo. apache.org/doc/odata4/tutorials/sqo_tcs/tutorial_sqo_tcs.html

I can also provide you with sample code. For example, if we talk about pagination, in your EntityCollectionProcessor implementation you just need to read the top one and skip the parameters and use them when creating a request to an existing web service using XML, JSON, or something else:

 int skipNumber = 0; SkipOption skipOption = uriInfo.getSkipOption(); if (skipOption != null) { skipNumber = skipOption.getValue(); } int topNumber = -1; TopOption topOption = uriInfo.getTopOption(); if (topOption != null) { topNumber = topOption.getValue(); } EntityCollection responseEntityCollection = getDataFromService(edmEntitySet, skipNumber, topNumber); 

Here, the getDataFromService method generates a request to your services that pass upper and lower case parameters and retrieves the response. It is not recommended that you filter the result set on the OData service side. You can find some additional steps in the above tutorial. Filtering is more complicated, but you can find the main idea here: https://olingo.apache.org/doc/odata4/tutorials/sqo_f/tutorial_sqo_f.html

+2
source

All Articles