package com.bankaudit.rest.process.service;

import java.util.List;


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

import com.bankaudit.constants.BankAuditConstant;
import com.bankaudit.process.model.AuditScheduleStagesStatusHst;
import com.bankaudit.rest.process.dao.AuditLogDao;
import com.bankaudit.service.BusinessDateService;
import com.bankaudit.service.MaintEntityService;
import com.bankaudit.service.UserService;

@Service
@Transactional("transactionManager")
public class AuditLogServiceImpl implements AuditLogService {
	
	@Autowired
	AuditLogDao auditLogDao;
	
	@Autowired
	BusinessDateService businessDateService; 
	
	@Autowired
	MaintEntityService maintEntityService;
	
	@Autowired
	UserService userService;
	
	
	static final Logger logger = Logger.getLogger(AuditLogServiceImpl.class);
	
	@Override
	public List<AuditScheduleStagesStatusHst> getAuditLogByProcess(Integer legalEntityCode, String auditId, String userId, String role, String process, String code) {
		logger.debug("Inside getAuditLogByProcess of SrvcImpl .. "+ process +" :: "+userId );
		String userUnitLevel=null;
		if(BankAuditConstant.AUDIT_LOG_SUPERVISORY_RATING_PROCESS.equalsIgnoreCase(process) 
				|| BankAuditConstant.AUDIT_LOG_GRADING_PROCESS.equalsIgnoreCase(process)) {
			userUnitLevel=userService.getUnitLevelforUser(legalEntityCode, userId); // to get the userUnitLevel like RO or HO
		}
		
		return auditLogDao.getAuditLogByProcess(legalEntityCode, auditId, userId, role, process, code, userUnitLevel);
	}
	
	
	
}
