package com.prime.sony.ecommerce.jobs;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.Scheduled;

import com.prime.sony.ecommerce.exceptions.DeleteRequestServiceException;
import com.prime.sony.ecommerce.service.DeleteRequestService;

//@Component
@Configuration
public class DeleteRequestServiceJob {

	private static final Logger log = LoggerFactory.getLogger(DeleteRequestServiceJob.class);

	
	@Autowired
	private DeleteRequestService deleteRequestService;

	@Scheduled(cron = "#{@getCronValueForDeleteReport}") 
	public void loadDeleteRequestReport() throws Exception {
		  
		  log.info("==>DeleteRequestServiceJob.loadDeleteRequestReport()"); 
		  try {
			  deleteRequestService.loadDeleteRequestReport(); 
		 } catch (Exception e) {
		  log.error("==> Exception at DeleteRequestServiceJob.loadDeleteRequestReport()",e)
		  ;
		  
		  throw new DeleteRequestServiceException(e.getMessage(), e.getCause(), null); 
		  }
		  log.info("<==DeleteRequestServiceJob.loadDeleteRequestReport()"); 
	}
	
	@Scheduled(cron = "#{@getCronValueForDeleteReport}") 
	public void loadDeleteRequestLog() throws Exception {
		  
		  log.info("==>DeleteRequestServiceJob.loadDeleteRequestLog()"); 
		  try {
			  deleteRequestService.loadDeleteRequestLog(); 
		 } catch (Exception e) {
		  log.error("==> Exception at DeleteRequestServiceJob.loadDeleteRequestReport()",e)
		  ;
		  
		  throw new DeleteRequestServiceException(e.getMessage(), e.getCause(), null); 
		  }
		  log.info("<==DeleteRequestServiceJob.loadDeleteRequestReport()"); 
	}
	
	@Scheduled(cron = "#{@getCronValueForDeleteReport}") 
	public void loadDeleteRequestProcess() throws Exception {
		  
		  log.info("==>DeleteRequestServiceJob.loadDeleteRequestProcess()"); 
		  try {
			  deleteRequestService.loadDeleteRequestProcess(); 
		 } catch (Exception e) {
		  log.error("==> Exception at DeleteRequestServiceJob.loadDeleteRequestProcess()",e)
		  ;
		  
		  throw new DeleteRequestServiceException(e.getMessage(), e.getCause(), null); 
		  }
		  log.info("<==DeleteRequestServiceJob.loadDeleteRequestProcess()"); 
	}
		 
	 
}
