All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.droidlogix.dbflare.a2e.ApiCoreInterface Maven / Gradle / Ivy

There is a newer version: 1.0.8
Show newest version
package com.droidlogix.dbflare.a2e;

import com.dbflare.core.models.IEndpoint;
import com.droidlogix.dbflare.datahandler.PagingParameter;
import com.droidlogix.dbflare.exceptions.DbFlareGenericException;

import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;

/**
 * @author John Pili
 */

public interface ApiCoreInterface
{
	/**
	 * This will process URL query string parameters into named or positional Map. It will
	 * convert the necessary values to a corresponding type or List type.
	 * @param endpoint
	 * @param parameters
	 * @return
	 * @throws DbFlareGenericException
	 */
	Map processIncomingURLParameters(IEndpoint endpoint, Map parameters) throws DbFlareGenericException;

	/**
	 * This will handle the conversion of placeholders located in the endpoint queryString.
	 * @param endpoint
	 * @param parameters
	 * @return
	 * @throws DbFlareGenericException
	 */
	String transposeQueryStringPlaceholders(IEndpoint endpoint, Map parameters) throws DbFlareGenericException;

	/**
	 * This method handles the conversion of placeholders in the endpoint query string
	 * @param queryString
	 * @param endpoint
	 * @param parameters
	 * @return
	 * @throws DbFlareGenericException
	 */
	String transposeQueryStringSort(String queryString, IEndpoint endpoint, Map parameters) throws DbFlareGenericException;

	/**
	 * This is used to convert HTTP REQUEST Body into an Object by using GSON
	 *
	 * @param clazz
	 * @param request
	 * @return
	 * @throws DbFlareGenericException
	 */
	Object processBindingFromRequest(Class clazz, HttpServletRequest request) throws DbFlareGenericException;

	/**
	 * This is used to convert HTTP REQUEST Body into an List of Objects by using GSON
	 * @param className
	 * @param request
	 * @return
	 * @throws DbFlareGenericException
	 */
	List processBindingFromRequestToList(String className, HttpServletRequest request) throws DbFlareGenericException;

	/**
	 * This method will generate result as a JSON Object
	 * @param apiEndPoint
	 * @param result
	 * @return
	 * @throws Exception
	 */
	JsonResult resultOutputProcessor(IEndpoint apiEndPoint, Object result) throws Exception;

	/**
	 * This method will generate result as an JSON Array object
	 * @param apiEndPoint
	 * @param resultList
	 * @return
	 * @throws Exception
	 */
	JsonResult resultOutputProcessor(IEndpoint apiEndPoint, List resultList) throws Exception;

	/**
	 * This method will execute the API and will return JSON string as a result
	 * @param api
	 * @param prettify
	 * @param container
	 * @param pagingParameter
	 * @param parameters
	 * @return
	 * @throws DbFlareGenericException
	 */
	String execute(String api, boolean prettify, boolean container, PagingParameter pagingParameter, Map parameters) throws DbFlareGenericException;


	/**
	 * This method handles the JPQL query from JPQL/SQL editor
	 * @param jpqlQuery
	 * @return
	 * @throws Exception
	 */
	String jpqlQuery(String jpqlQuery) throws Exception;


	/**
	 * This method handle the native SQL from JPQL/SQL editor
	 * @param sqlQuery
	 * @return
	 * @throws Exception
	 */
	String sqlQuery(String sqlQuery) throws Exception;
}