/**
 * Project Name : 전사 법무/계약관리시스템 개선
 * File Name    : GaisJobConfig.java
 * Description  : 
 * Author       : basslee 
 * Date         : 2023.03.03
 * Copyright 	: 2023 by SAMSUNG. All rights reserved.
 */
package com.samsung.embo.cronJob.config;


import java.util.Objects;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.quartz.CronTriggerFactoryBean;
import org.springframework.scheduling.quartz.JobDetailFactoryBean;

import com.samsung.embo.cronJob.executor.GhrpJobExecutor;


@Configuration
public class GhrpJobConfig {
	
	@Value("${batch.dept.cron}")
    private String deptCron;
	
	@Value("${batch.user.cron}")
    private String userCron;	
	
	
	
	
    /**
     * 부서정보 I/F
     * 
     * @return
     */
    @Bean
    public JobDetailFactoryBean recvDeptInfo() {
        JobDetailFactoryBean  jobDetailFactoryBean = new JobDetailFactoryBean();
        jobDetailFactoryBean.setName("recvDeptInfo");
        jobDetailFactoryBean.setJobClass(GhrpJobExecutor.class);
        jobDetailFactoryBean.setDescription("recvDeptInfo Batch");
        jobDetailFactoryBean.setDurability(true);
        return jobDetailFactoryBean;
    }

    @Bean
    public CronTriggerFactoryBean recvDeptInfoTrigger() {
        CronTriggerFactoryBean trigger = new CronTriggerFactoryBean();
        trigger.setJobDetail(Objects.requireNonNull(recvDeptInfo().getObject()));
        trigger.setCronExpression(deptCron);
        return trigger;
    }
    
    /**
     * 임직원정보 I/F
     * 
     * @return
     */
    @Bean
    public JobDetailFactoryBean recvUserInfo() {
        JobDetailFactoryBean  jobDetailFactoryBean = new JobDetailFactoryBean();
        jobDetailFactoryBean.setName("recvUserInfo");
        jobDetailFactoryBean.setJobClass(GhrpJobExecutor.class);
        jobDetailFactoryBean.setDescription("recvUserInfo Batch");
        jobDetailFactoryBean.setDurability(true);
        return jobDetailFactoryBean;
    }

    @Bean
    public CronTriggerFactoryBean recvUserInfoTrigger() {
        CronTriggerFactoryBean trigger = new CronTriggerFactoryBean();
        trigger.setJobDetail(Objects.requireNonNull(recvUserInfo().getObject()));
        trigger.setCronExpression(userCron);
        return trigger;
    }
    
}