java/webservice/src/main/java/be/bosa/dt/best/webservice/LookupResource.java
/**
	 * Add pagination links to parent object
	 * 
	 * @param info URI info
	 * @param parentObj parent JSON object
	 * @param arr result array
	 * @return JSON object with pagination
	 */
Add pagination links to parent object

@param info URI info
@param parentObj parent JSON object
@param arr result array
@return JSON object with pagination
Add pagination links to parent object @param info URI info @param parentObj parent JSON object @param arr result array @return JSON object with pagination
private static JsonObject paginate(UriInfo info, JsonObject parentObj, JsonArray arr) {
		int size = arr.size();
		if (size >= Repository.PAGE_LIMIT) {
			JsonObject lastObj = arr.getJsonObject(size - 1);
			String first = info.getRequestUriBuilder()
								.replaceQueryParam("after", null)
								.queryParam("pageSize", Repository.PAGE_LIMIT)
								.build().toString();
			String next = info.getRequestUriBuilder()
								.replaceQueryParam("after", lastObj.getString("id"))
								.queryParam("pageSize", Repository.PAGE_LIMIT)
								.build().toString();
			parentObj.put("pageSize", Repository.PAGE_LIMIT);
			parentObj.put("first", first);
			parentObj.put("next", next);
		}
		return parentObj;
	}
private static JsonObject paginate ( UriInfo info , JsonObject parentObj , JsonArray arr ) { int size = arr . size ( ) ; if ( size >= Repository . PAGE_LIMIT ) { JsonObject lastObj = arr . getJsonObject ( size - 1 ) ; String first = info . getRequestUriBuilder ( ) . replaceQueryParam ( "after" , null ) . queryParam ( "pageSize" , Repository . PAGE_LIMIT ) . build ( ) . toString ( ) ; String next = info . getRequestUriBuilder ( ) . replaceQueryParam ( "after" , lastObj . getString ( "id" ) ) . queryParam ( "pageSize" , Repository . PAGE_LIMIT ) . build ( ) . toString ( ) ; parentObj . put ( "pageSize" , Repository . PAGE_LIMIT ) ; parentObj . put ( "first" , first ) ; parentObj . put ( "next" , next ) ; } return parentObj ; }
Add pagination links to parent object
Add pagination links to parent object
//pagination