class FundRepository {

	@Transactional
	public List<Fund> update(List<Fund> funds, RequestInfo requestInfo) {
		ModelMapper mapper = new ModelMapper();
		Map<String, Object> message = new HashMap<>();
		FundRequest request = new FundRequest();
		FundContract contract;
		if (persistThroughKafka != null && !persistThroughKafka.isEmpty()
				&& persistThroughKafka.equalsIgnoreCase("yes")) {

			request.setRequestInfo(requestInfo);
			request.setFunds(new ArrayList<>());
			for (Fund f : funds) {
				contract = new FundContract();
				contract.setCreatedDate(new Date());
				mapper.map(f, contract);
				request.getFunds().add(contract);
			}
			message.put("fund_update", request);
			fundQueueRepository.add(message);
			return funds;
		} else {
			List<Fund> resultList = new ArrayList<Fund>();
			for (Fund f : funds) {
				resultList.add(update(f));
			}
			request.setRequestInfo(requestInfo);
			request.setFunds(new ArrayList<>());
			for (Fund f : resultList) {
				contract = new FundContract();
				contract.setCreatedDate(new Date());
				mapper.map(f, contract);
				request.getFunds().add(contract);
			}
			message.put("fund_persisted", request);
			fundQueueRepository.addToSearch(message);
			return resultList;
		}

	}

	@Autowired public  FundRepository(FundJdbcRepository fundJdbcRepository, MastersQueueRepository fundQueueRepository,
			FinancialConfigurationService financialConfigurationService, FundESRepository fundESRepository,
			@Value("${persist.through.kafka}") String persistThroughKafka);

}