<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
        				http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd">
	
	<!-- Spring Quartz Job for Census Transformation -->
	<bean name="censusTransAckJob" class="org.springframework.scheduling.quartz.JobDetailFactoryBean">
		<property name="jobClass" value="gov.va.med.cds.scheduler.CensusTransformAcknowledgementJob"/>
		<property name="durability" value="true" />
	</bean>

	<!-- Cron Trigger, run for every 5 minutes -->
	<bean id="censusTransAckCronTrigger" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
		<property name="jobDetail" ref="censusTransAckJob"/>
		<!-- Fire every 5 minutes every day -->
		<property name="cronExpression" value="0 0/5 * * * ?"/>
	</bean>
	
	<!-- Spring Quartz Job for expired Census reports -->
	<bean name="expiredCensusReportsAckJob" class="org.springframework.scheduling.quartz.JobDetailFactoryBean">
		<property name="jobClass" value="gov.va.med.cds.scheduler.ExpiredCensusReportsJob"/>
		<property name="durability" value="true" />
	</bean>

	<!-- Cron Trigger, run for every 10 minutes -->
	<bean id="expiredCensusReportsAckCronTrigger" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
		<property name="jobDetail" ref="expiredCensusReportsAckJob"/>
		<!-- Fire every 5 minutes every day -->
		<property name="cronExpression" value="0 0/10 * * * ?"/>
	</bean>

	<!-- Our 'AutowiringSpringBeanJobFactory' implemented in the previous section: -->
	<bean id="quartzJobFactory" class="gov.va.med.cds.scheduler.AutowiringSpringBeanJobFactory">
	    <!-- I will not explain this setting, just use it as shown: -->
	    <property name="ignoredUnknownProperties" value="applicationContext"/>
	</bean>
	
	<bean id="censusQuartzScheduler" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
		<!-- Quartz requires a separate 'quartz.properties' file -->
    	<property name="configLocation" value="classpath:gov/va/med/cds/scheduler/census.quartz.properties"/>

		<!-- <property name="jobDetails">
			<list>
				<ref bean="censusTransAckJob" />
			</list>
		</property> -->
		<property name="triggers">
			<list>
				<ref bean="censusTransAckCronTrigger" /> 
				<ref bean="expiredCensusReportsAckCronTrigger" />
			</list>
		</property>
		
		<!-- Will update database cron triggers to what is in this jobs file on each deploy.
	      Replaces all previous trigger and job data that was in the database. -->
		<property name="overwriteExistingJobs" value="true"/>

		<property name="autoStartup" value="true" />
   		<property name="schedulerName" value="CDS_CensusQuartzScheduler"/>
    	<property name="applicationContextSchedulerContextKey" value="applicationContext"/>
		
		<!-- reference to our 'autowiring job factory bean', defined above: -->
    	<property name="jobFactory" ref="quartzJobFactory" />
	</bean>
</beans>
