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

com.dottydingo.hyperion.jpa.configuration.JpaDefaultsVersionPluginBuilder Maven / Gradle / Ivy

package com.dottydingo.hyperion.jpa.configuration;

import com.dottydingo.hyperion.core.configuration.AbstractDefaultsVersionPluginBuilder;
import com.dottydingo.hyperion.core.registry.EntityQueryBuilder;
import com.dottydingo.hyperion.core.registry.EntitySortBuilder;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Map;

/**
 */
public class JpaDefaultsVersionPluginBuilder extends AbstractDefaultsVersionPluginBuilder
{
    @Override
    protected Map generateQueryBuilders()
    {
        JpaEntityQueryBuilderFactoryBean factoryBean = new JpaEntityQueryBuilderFactoryBean();
        if(queryExcludeFields != null && queryExcludeFields.length >0)
            factoryBean.setExcludeFields(new HashSet(Arrays.asList(queryExcludeFields)));

        factoryBean.setFieldNameRemapping(queryFieldNameRemapping);
        factoryBean.setApiClass(apiClass);

        try
        {
            return factoryBean.getObject();
        }
        catch (Exception e)
        {
            throw new RuntimeException("Error generating queries",e);
        }
    }

    @Override
    protected Map generateSortBuilders()
    {
        JpaEntitySortBuilderFactoryBean factoryBean = new JpaEntitySortBuilderFactoryBean();
        if(sortExcludeFields != null && sortExcludeFields.length > 0)
            factoryBean.setExcludeFields(new HashSet(Arrays.asList(sortExcludeFields)));

        factoryBean.setFieldNameRemapping(sortFieldNameRemapping);
        factoryBean.setApiClass(apiClass);

        try
        {
            return factoryBean.getObject();
        }
        catch (Exception e)
        {
            throw new RuntimeException("Error generating sorts",e);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy