class BudgetDetailRepository {

    public Pagination<BudgetDetail> search(final BudgetDetailSearch domain) {

        if (financialConfigurationContractRepository.fetchDataFrom() != null
                && financialConfigurationContractRepository.fetchDataFrom().equalsIgnoreCase("es")) {

            BudgetDetailMapper mapper = new BudgetDetailMapper();
            BudgetDetailSearchContract budgetDetailSearchContract = new BudgetDetailSearchContract();
            budgetDetailSearchContract = mapper.toSearchContract(domain);
            Pagination<BudgetDetail> budgetDetails = budgetDetailESRepository.search(budgetDetailSearchContract);
            return budgetDetails;
        } else {

            return budgetDetailJdbcRepository.search(domain);
        }

    }

    @Autowired public  BudgetDetailRepository(final BudgetDetailJdbcRepository budgetDetailJdbcRepository,
                                  final BudgetDetailQueueRepository budgetDetailQueueRepository,
                                  @Value("${persist.through.kafka}") final String persistThroughKafka,
                                  FinancialConfigurationContractRepository financialConfigurationContractRepository,
                                  BudgetDetailESRepository budgetDetailESRepository
    );

}