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

import java.util.HashMap;
import java.util.List;
import java.util.Map;

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

import com.bankaudit.dao.RiskScoreAuditSubgrpDao;
import com.bankaudit.dto.DataTableResponse;
import com.bankaudit.model.RiskScoreAuditSubgrp;

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

	
	/**
	 * The risk score audit subgrp dao is autowired and make methods available
	 * from dao layer .
	 */
	@Autowired
	RiskScoreAuditSubgrpDao riskScoreAuditSubgrpDao;
	
	/* (non-Javadoc)
	 * @see com.bankaudit.service.RiskScoreAuditSubgrpService#getRiskScoreAuditSubgrp(java.lang.Integer, java.lang.String, java.lang.String, java.lang.String)
	 */
	@Override
	public RiskScoreAuditSubgrp getRiskScoreAuditSubgrp(Integer legalEntityCode, String auditGroupCode,
			String auditSubGroupCode, String auditTypeCode) {
		Map<String, Object> properties=new HashMap<String,Object>();
		properties.put("legalEntityCode", legalEntityCode);
		properties.put("auditGroupCode", auditGroupCode);
		properties.put("auditSubGroupCode", auditSubGroupCode);
		properties.put("auditTypeCode", auditTypeCode);
		return (RiskScoreAuditSubgrp)riskScoreAuditSubgrpDao.getUniqueEntityByMatchingProperties(RiskScoreAuditSubgrp.class, properties);
	}



	/* (non-Javadoc)
	 * @see com.bankaudit.service.RiskScoreAuditSubgrpService#createRiskScoreAuditSubgrp(java.util.List)
	 */
	@Override
	public void createRiskScoreAuditSubgrp(List<RiskScoreAuditSubgrp> riskScoreAuditSubgrps) {
		for (RiskScoreAuditSubgrp riskScoreAuditSubgrp : riskScoreAuditSubgrps) {
			riskScoreAuditSubgrpDao.save(riskScoreAuditSubgrp);
		}
		
	}

	/* (non-Javadoc)
	 * @see com.bankaudit.service.RiskScoreAuditSubgrpService#updateRiskScoreAuditSubgrp(java.util.List)
	 */
	@Override
	public void updateRiskScoreAuditSubgrp(List<RiskScoreAuditSubgrp> riskScoreAuditSubgrps) {
		riskScoreAuditSubgrpDao.deleteByLegalEntityCodeAndAuditTypeCodeAndAuditGroupCode(riskScoreAuditSubgrps.get(0).getLegalEntityCode(),riskScoreAuditSubgrps.get(0).getAuditTypeCode(),riskScoreAuditSubgrps.get(0).getAuditGroupCode());
		/*for (RiskScoreAuditSubgrp riskScoreAuditSubgrp : riskScoreAuditSubgrps) {
			riskScoreAuditSubgrpDao.save(riskScoreAuditSubgrp);
		}*/
	}



	

}
