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

import java.util.Date;
import java.util.HashMap;
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.BusinessDateDao;
import com.bankaudit.model.BusinessDate;

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

	/**
	 * The business date dao is autowired and make methods available from dao
	 * layer .
	 */
	@Autowired
	BusinessDateDao businessDateDao;

	/* (non-Javadoc)
	 * @see com.bankaudit.service.BusinessDateService#getBusinessDateTimestampByLegalEntityCode(java.lang.Integer)
	 */
	@Override
	public Date getBusinessDateTimestampByLegalEntityCode(Integer legalEntityCode) {
		
		return businessDateDao.getBusinessDateTimestampByLegalEntityCode(legalEntityCode);
	}

	/* (non-Javadoc)
	 * @see com.bankaudit.service.BusinessDateService#getBusinessDateByLegalEntityCode(java.lang.Integer)
	 */
	@Override
	public BusinessDate getBusinessDateByLegalEntityCode(Integer legalEntityCode) {
		Map<String,Object> properties=new HashMap<String,Object>();
		properties.put("legalEntityCode", legalEntityCode);
		return (BusinessDate)businessDateDao.getUniqueEntityByMatchingProperties(BusinessDate.class, properties);
	}

	/* (non-Javadoc)
	 * @see com.bankaudit.service.BusinessDateService#createBusinessDate(com.bankaudit.model.BusinessDate)
	 */
	@Override
	public void createBusinessDate(BusinessDate businessDate) {
		businessDateDao.save(businessDate);
	}
	
	@Override
	public void updateBusinessDateBasedOnSysDate(Integer legalEntityCode) {
		businessDateDao.updateBusinessDateBasedOnSysDate(legalEntityCode);
	}
}
