class FunctionRepository {

	@Transactional
	public List<Function> update(List<Function> functions, RequestInfo requestInfo) {

		ModelMapper mapper = new ModelMapper();
		FunctionContract contract;

		if (persistThroughKafka != null && !persistThroughKafka.isEmpty()
				&& persistThroughKafka.equalsIgnoreCase("yes")) {

			FunctionRequest request = new FunctionRequest();
			request.setRequestInfo(requestInfo);
			request.setFunctions(new ArrayList<>());

			for (Function f : functions) {

				contract = new FunctionContract();
				contract.setCreatedDate(new Date());
				mapper.map(f, contract);
				request.getFunctions().add(contract);

			}

			addToQue(request);

			return functions;
		} else {

			List<Function> resultList = new ArrayList<Function>();

			for (Function f : functions) {

				resultList.add(update(f));
			}

			FunctionRequest request = new FunctionRequest();
			request.setRequestInfo(requestInfo);
			request.setFunctions(new ArrayList<>());

			for (Function f : resultList) {

				contract = new FunctionContract();
				contract.setCreatedDate(new Date());
				mapper.map(f, contract);
				request.getFunctions().add(contract);

			}

			addToSearchQueue(request);

			return resultList;
		}

	}

	@Autowired public  FunctionRepository(FunctionJdbcRepository functionJdbcRepository,
			MastersQueueRepository functionQueueRepository, FinancialConfigurationService financialConfigurationService,
			FunctionESRepository functionESRepository, @Value("${persist.through.kafka}") String persistThroughKafka);

}