/*
 * 
 */
package com.bankaudit.service;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.bankaudit.dao.GeneralParameterDao;
import com.bankaudit.model.GeneralParameter;

/**
 * The Class {@link GeneralParameterServiceImpl} Implements the business logic
 * method.
 *
 * @author amit.patel
 * @version 1.0
 */
@Service("generalParameterService")
@Transactional("transactionManager")
public class GeneralParameterServiceImpl implements GeneralParameterService {

	/**
	 * The general parameter dao is autowired and make methods available from
	 * dao layer .
	 */
	@Autowired
	GeneralParameterDao generalParameterDao;
	
	/* (non-Javadoc)
	 * @see com.bankaudit.service.GeneralParameterService#getGeneralParameter(java.lang.Integer, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
	 */
	@Override
	public List<GeneralParameter> getGeneralParameter(Integer legalEntityCode, String modCode, String language,
			String key1, String key2, String value, String maker) {
		return generalParameterDao.getGeneralParameter( legalEntityCode,  modCode,  language,
				 key1,  key2,  value,  maker);
	}
	
	@Override
	public Map<String, String> getGeneralParameterKeyValue(Integer legalEntityCode, String modCode, String language,
			String key1, String key2, String value, String maker) {
		List<GeneralParameter> genParams= generalParameterDao.getGeneralParameter( legalEntityCode,  modCode,  language,
				 key1,  key2,  value,  maker);
		Map<String, String> paramKeyValue= genParams.stream().collect(Collectors.toMap(GeneralParameter::getValue, GeneralParameter::getDescription));
		return paramKeyValue;
		
	}
	
}
