All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cn.dceast.platform.task.quartz.data.OutputToDataBase Maven / Gradle / Ivy

The newest version!
package cn.dceast.platform.task.quartz.data;

import java.util.Date;
import java.util.List;
import java.util.Map;

import cn.dceast.platform.task.config.TaskConfig;
import cn.dceast.platform.task.db.DBUtil;
import cn.dceast.platform.task.quartz.JobEntity;
import cn.dceast.platform.task.quartz.JobExecutedEntity;

/**
 * 写入数据库
 * @author zhang
 *
 */
public class OutputToDataBase implements OutputJobInfoExecutor {

	@Override
	public void addJob(JobExecutedEntity jee) {
		
		if(!OutputJobToDataBaseService.isExistsOfJob(jee.getTaskId(), jee.getJobGroup(), jee.getJobName())){
			OutputJobToDataBaseService.saveJob(jee);
		}else{
			OutputJobToDataBaseService.updateJob(jee);
		}
		
	}

	@Override
	public void deleteJob(String jobId) {
		OutputJobToDataBaseService.deleteJobExecHistory(jobId);
		OutputJobToDataBaseService.deleteJobLifecycleHistory(jobId);
		OutputJobToDataBaseService.deleteJob(jobId);
	}

    @Override
    public void deleteJob(String groupName, String jobName) {
        JobExecutedEntity jee = this.getJob(groupName, jobName);
        if(jee!=null){
            OutputJobToDataBaseService.deleteJobExecHistory(jee.getJobId());
            OutputJobToDataBaseService.deleteJobLifecycleHistory(jee.getJobId());
            OutputJobToDataBaseService.deleteJob(jee.getJobId());
        }
    }

	@Override
	public void updateJob(JobExecutedEntity jee) {
		OutputJobToDataBaseService.updateJob(jee);
	}

	@Override
	public void addJobHistory(JobExecutedEntity jee) {
		OutputJobToDataBaseService.saveJobExecHistory(jee);
	}

	@Override
	public void addJobLifecycleManageLog(JobEntity jobEntity, String action) {
		OutputJobToDataBaseService.saveJobLifecycleHistory(jobEntity, action);
	}

	@Override
	public JobExecutedEntity getJob(String jobId) {
		return OutputJobToDataBaseService.getJob(jobId);
	}

    @Override
    public JobExecutedEntity getJob(String groupName, String jobName) {
        return OutputJobToDataBaseService.getJob(groupName, jobName);
    }

	@Override
	public List getJobs() {
		return OutputJobToDataBaseService.getJobs(TaskConfig.appName);
	}

	@Override
	public Map getJobExecutedHistory(int pageNo, int pageSize,
			String jobGroup, String jobName, Date beginTime, Date endtime,String jobId) {
	
		return OutputJobToDataBaseService.getJobExecutedHistory(pageNo, pageSize, jobGroup, jobName, beginTime, endtime,jobId);
	}

	@Override
	public Map getJobLifecycleHistory(int pageNo, int pageSize,
			String jobGroup, String jobName, Date beginTime, Date endtime,
			String action,String jobId) {
		return OutputJobToDataBaseService.getJobLifecycleHistory(pageNo, pageSize, jobGroup, jobName, beginTime, endtime, action,jobId);
	}
	
	@Override
	public String getNextJobId(){
		return "JOB"+String.format("%08d", DBUtil.nextValue("jobId"));
	}
	
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy