com.droidlogix.dbflare.hub.RetrievalRestApiConfigurerAdapter Maven / Gradle / Ivy
package com.droidlogix.dbflare.hub;
import com.droidlogix.dbflare.a2e.ApiCore;
import com.droidlogix.dbflare.a2e.DbFlareResultCache;
import com.droidlogix.dbflare.datahandler.PagingParameter;
import com.droidlogix.dbflare.endpoint.core.IEndpointCore;
import com.droidlogix.dbflare.exceptions.DbFlareGenericException;
import com.fasterxml.jackson.databind.ObjectMapper;
import javax.persistence.EntityManager;
import java.util.Map;
/**
* @author John Pili
* @since 11/09/16
*/
public abstract class RetrievalRestApiConfigurerAdapter implements IRetrievalRestApiConfigurerAdapter, IRetrievalRestApiInterface
{
private EntityManager entityManager;
private ObjectMapper objectMapper;
private IEndpointCore endpointCore;
@Override
public void setEntityManager(EntityManager entityManager)
{
this.entityManager = entityManager;
}
@Override
public void setObjectMapper(ObjectMapper objectMapper)
{
this.objectMapper = objectMapper;
}
@Override
public void setEndpointCore(IEndpointCore endpointCore)
{
this.endpointCore = endpointCore;
}
@Override
public String zget(String api, boolean prettify, boolean container, Map urlParameters) throws DbFlareGenericException
{
if (entityManager != null && endpointCore != null && objectMapper != null)
{
return new ApiCore(entityManager, endpointCore, objectMapper).execute(api, prettify, container, null, urlParameters);
}
throw new DbFlareGenericException("EntityManager, EndpointCore or ObjectMapper is null");
}
@Override
public String zget(String api, boolean prettify, boolean container, PagingParameter pagingParameter, Map urlParameters) throws DbFlareGenericException
{
if (entityManager != null && endpointCore != null && objectMapper != null)
{
return new ApiCore(entityManager, endpointCore, objectMapper).execute(api, prettify, container, pagingParameter, urlParameters);
}
throw new DbFlareGenericException("EntityManager, EndpointCore or ObjectMapper is null");
}
@Override
public String runNativeSqlQuery(String sqlQuery) throws DbFlareGenericException
{
if (entityManager != null && endpointCore != null && objectMapper != null)
{
return new ApiCore(entityManager, endpointCore, objectMapper).sqlQuery(sqlQuery);
}
throw new DbFlareGenericException("EntityManager, EndpointCore or ObjectMapper is null");
}
@Override
public String runJpqlQuery(String jpqlQuery) throws DbFlareGenericException
{
if (entityManager != null && endpointCore != null && objectMapper != null)
{
return new ApiCore(entityManager, endpointCore, objectMapper).jpqlQuery(jpqlQuery);
}
throw new DbFlareGenericException("EntityManager, EndpointCore or ObjectMapper is null");
}
}