package com.eactive.eai.rms.onl.statistics.backup.service;

import org.apache.log4j.Logger;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.quartz.SchedulerException;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;

import com.eactive.eai.rms.onl.common.util.DateUtil;

/**
 * <pre>
 * 1. 기능 : New Log Daily Backup의 비즈니스 로직이 담겨져 있다.
 * 2. 처리 개요 : 
 *     - 
 * 3. 주의사항 : 
 * </pre>
 * @author  : 
 * @version : 
 * @since : rts 1.0
 */
@Service("newLogDailyBackupJob")
public class NewLogDailyBackupJob implements Job {

    /**
     * Logger for this class
     */
	private static final Logger logger = Logger.getLogger(NewLogDailyBackupJob.class);
	
	private NewLogDailyBackupService service;

    
	@Override
	public void execute(JobExecutionContext context) throws JobExecutionException {
        //JobKey jobKey = context.getJobDetail().getKey();

		ApplicationContext appContext = null;
		try {
			appContext = (ApplicationContext)context.getScheduler().getContext().get("applicationContext");
		} catch (SchedulerException e) {
			logger.error("applicationContext get module error",e);
			return ;
		}
		
		service = (NewLogDailyBackupService)appContext.getBean("newLogDailyBackupService");

		String date = DateUtil.getDate(-1);
        service.doAction(date);
	}
}
