I am new to apache olingo web service. I struck for the past two weeks to implement filter and pagination to my service.I am using latest olingo version 4. I google it and looked many blogs but there is no clear explanation. Kindly help me with sample code.It will be more use full for me.
Following are my scenario,
I am gettting the data from existing web service as XML and then i parse the XML using JAXB make it as list of entity in olingo web services.
Here how can i apply filter. If i having $filter in my URL means it throws page not found exception. If i remove that means it will work and give full result.
My question is How to apply olingo filter in XML string or How to apply it in List of entity which i having it in a method. Kindly give me the explenation with some sample code.
I need to give pagination to my response JSON.I need to limit the JSON value as 25 per page and need to next page URL also(For 25 to 50) like that. How to implement this also.
I overcome lots of blogs but didn't work for me. Here https://templth.wordpress.com/2015/04/03/handling-odata-queries-with-elasticsearch/
In this blog,They didn't explain with full code.My problem is,I am getting data from existing web service as XML string and parse it and having in list of entity.
And I also refer this blog,
https://olingo.apache.org/doc/odata2/tutorials/Olingo_Tutorial_AdvancedRead_FilterVisitor.html
In this blog also they tell how to construct the query,My problem is how to implement $filter,$select etc from ODATA in my web service and how to filter from xml string or list of entity
Kindly suggest me with sample code.Thanks.
The Olingo team provides a huge amount of well organized help resources. The sample projects can be found by these instructions: http://olingo.staging.apache.org/doc/odata4/tutorials/prerequisites/prerequisites.html#tutorial-sources Complete tutorial about hte pagination can be found here: https://olingo.apache.org/doc/odata4/tutorials/sqo_tcs/tutorial_sqo_tcs.html
I can also provide you the sample code. For example, if talking about the pagination, in your EntityCollectionProcessor
implementation you just have to read the top and skip parameters and use them when generating a query to your existing web service using XML, JSON or whatever:
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 passing the top/skip parameters and retrieves the response. It is not advisable to filter the result set on the OData service side. Some additional steps you can find in the above mentioned tutorial.
Filtering is more complex but the main idea you can find from here:
https://olingo.apache.org/doc/odata4/tutorials/sqo_f/tutorial_sqo_f.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With