class AccountDetailKeyRepository {

	@Transactional
	public List<AccountDetailKey> save(List<AccountDetailKey> accountDetailKies, RequestInfo requestInfo) {

		ModelMapper mapper = new ModelMapper();
		AccountDetailKeyContract contract;

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

			AccountDetailKeyRequest request = new AccountDetailKeyRequest();
			request.setRequestInfo(requestInfo);
			request.setAccountDetailKeys(new ArrayList<>());

			for (AccountDetailKey f : accountDetailKies) {

				contract = new AccountDetailKeyContract();
				contract.setCreatedDate(new Date());
				mapper.map(f, contract);
				request.getAccountDetailKeys().add(contract);

			}

			addToQue(request);

			return accountDetailKies;
		} else {

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

			for (AccountDetailKey f : accountDetailKies) {

				resultList.add(save(f));
			}

			AccountDetailKeyRequest request = new AccountDetailKeyRequest();
			request.setRequestInfo(requestInfo);
			request.setAccountDetailKeys(new ArrayList<>());

			for (AccountDetailKey f : resultList) {

				contract = new AccountDetailKeyContract();
				contract.setCreatedDate(new Date());
				mapper.map(f, contract);
				request.getAccountDetailKeys().add(contract);

			}

			addToSearchQueue(request);

			return resultList;
		}

	}

	@Autowired public  AccountDetailKeyRepository(AccountDetailKeyJdbcRepository accountDetailKeyJdbcRepository,
			MastersQueueRepository accountDetailKeyQueueRepository,
			FinancialConfigurationService financialConfigurationService,
			AccountDetailKeyESRepository accountDetailKeyESRepository,
			@Value("${persist.through.kafka}") String persistThroughKafka);

}