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

com.droidlogix.dbflare.hub.RetrievalRestApiConfigurerAdapter Maven / Gradle / Ivy

There is a newer version: 1.0.8
Show newest version
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");
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy