<beans default-lazy-init="false" 
    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-3.0.xsd">
       
	<!--  Batch Process Services -->
	<bean id="batchProcessService" class="gov.va.med.fw.batchprocess.BatchProcessServiceImpl">
		<property name="loginManager" ref="LoginManager"/>					
		<property name="jobLauncher" ref="jobLauncher" />
		<property name="jobLocator" ref="jobRegistry" />										
	</bean>
	
	<alias name="batchProcessService" alias="BatchProcessService"/>	
	
	<!-- Default ProcessStatisticsHandler -->
	<bean id="common.batchProcessMessageTemplate" class="org.springframework.mail.SimpleMailMessage">
		<property name="from"><value>donotReply@ihta</value></property>
		<property name="subject"><value>IHTA Batch Process Completed [@appEnv@ @appVersion@]- @subject@</value></property>		
		<property name="to" value="PII                       "/>
	</bean>	
	<bean id="common.batchProcessFailureMessageTemplate" class="org.springframework.mail.SimpleMailMessage">
		<property name="from"><value>donotReply@ihta</value></property>
		<property name="subject"><value>IHTA Batch Process Failed [@appEnv@ @appVersion@]- @subject@</value></property>		
		<property name="to" value="PII                       "/>
	</bean>	
	<bean id="common.abstractProcessStatisticsMailer" abstract="true" 
			class="gov.va.med.fw.batchprocess.ProcessStatisticsMailer">
		<property name="mailService" ref="mailService"/>
		<property name="ignoreEmptyStatistics" value="true"/>
		<property name="environmentParamService" ref="environmentParamService"/>
	</bean>		
	<bean id="common.processStatisticsMailer" parent="common.abstractProcessStatisticsMailer">	
		<property name="messageTemplate">
			<ref local="common.batchProcessMessageTemplate"/>
		</property>
		<property name="failedMessageTemplate">
			<ref local="common.batchProcessFailureMessageTemplate"/>
		</property>
	</bean>	
	

	<!--  Sequence Incrementors for spring batch tables -->
    <bean id="sqlServerMaxValueIncrementer"  abstract="true" 
    	class="org.springframework.jdbc.support.incrementer.SqlServerMaxValueIncrementer">    
        <property name="dataSource" ref="dataSource" />
        <property name="columnName" value="ID" />         
    </bean>
    <bean id="stepExecSeqIncrementer"  parent="sqlServerMaxValueIncrementer"> 
        <property name="incrementerName" value="INF.BATCH_STEP_EXECUTION_SEQ" /> 
    </bean>
    <bean id="jobExecSeqIncrementer"  parent="sqlServerMaxValueIncrementer"> 
        <property name="incrementerName" value="INF.BATCH_JOB_EXECUTION_SEQ" /> 
    </bean>
    <bean id="jobSeqIncrementer"  parent="sqlServerMaxValueIncrementer"> 
        <property name="incrementerName" value="INF.BATCH_JOB_SEQ" /> 
    </bean>        
       
	<bean 
		id="cchtJdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
		<constructor-arg><ref bean="dataSource"/></constructor-arg>
	</bean>
	
	<!--  Job Launcher -->
    <bean id="jobLauncher" class="org.springframework.batch.core.launch.support.SimpleJobLauncher">
		<property name="jobRepository" ref="jobRepository" />
	</bean>
	
	<!--  Job Repository and Registry -->
    <bean id="jobRegistry" class="gov.va.med.fw.batchprocess.BatchJobLocator"/>
            
	<bean id="jobRepository" class="org.springframework.batch.core.repository.support.SimpleJobRepository">  
	      <constructor-arg>  
	          <bean class="org.springframework.batch.core.repository.dao.JdbcJobInstanceDao">
	          	<property name="jdbcTemplate" ref="cchtJdbcTemplate"/>
	          	<property name="jobIncrementer" ref="jobSeqIncrementer"></property>
	          	<property name="tablePrefix" value="INF.BATCH_"></property>
	          </bean>  
	      </constructor-arg>  
	      <constructor-arg>  
	          <bean class="org.springframework.batch.core.repository.dao.JdbcJobExecutionDao">
	          		<property name="jdbcTemplate" ref="cchtJdbcTemplate"/>
	          		<property name="tablePrefix" value="INF.BATCH_"></property>
	          		<property name="jobExecutionIncrementer" ref="jobExecSeqIncrementer"></property>
	          </bean>  
	      </constructor-arg>  
	      <constructor-arg>  
	          <bean class="org.springframework.batch.core.repository.dao.JdbcStepExecutionDao">
	          		<property name="jdbcTemplate" ref="cchtJdbcTemplate"/>
	          		<property name="stepExecutionIncrementer" ref="stepExecSeqIncrementer"></property>
	          		<property name="tablePrefix" value="INF.BATCH_"></property>
	          </bean>  
	      </constructor-arg>
	      <constructor-arg>  
	          <bean class="org.springframework.batch.core.repository.dao.JdbcExecutionContextDao">
	          		<property name="jdbcTemplate" ref="cchtJdbcTemplate"/>
	          		<property name="tablePrefix" value="INF.BATCH_"></property>
	          </bean>  
	      </constructor-arg>	        	      
	</bean> 
		
	<!--  Abstract beans for job, step, task -->
	<bean id="taskletStep" abstract="true"  
      class="org.springframework.batch.core.step.tasklet.TaskletStep">  
      <property name="jobRepository" ref="jobRepository"/>  
      <property name="transactionManager" ref="transactionManager"/>
      <property name="transactionAttribute">      	
            <bean class="org.springframework.transaction.interceptor.DefaultTransactionAttribute">             	  
            	<property name="propagationBehaviorName" value="PROPAGATION_NOT_SUPPORTED"/>         	
            </bean>
       </property>      
  	</bean>
  	
  	<bean id="abstractTask" abstract="true">  
      <property name="processStatisticsMailer" ref="common.processStatisticsMailer"/>
      <property name="processName" value= "IHTA-BatchProcess"/>
      <property name="batchProcessService" ref= "batchProcessService"/>
  	</bean>

  	<bean id="abstractJob" abstract="true">  
		<property name="restartable" value="true"/>   
		<property name="jobRepository" ref="jobRepository"/>  
  	</bean>
  	
	<!-- Tasks and Jobs -->
	
  	<!--  Purge expired Reports and send alerts for reports expiring in 30 days -->
  	<bean id="purgeCompletedReportsJob" parent="abstractJob" class="org.springframework.batch.core.job.SimpleJob">  
      <property name="name" value="PurgeCompletedReports"/>
       <property name="steps">  
          <list>  
              <bean name="PurgeCompletedReports" parent="taskletStep">  
                <property name="tasklet" >
					<bean id="purgeCompletedReportsTask" parent="abstractTask" class="gov.va.med.fw.batchprocess.ConfigurableBatchProcess">
						<property name="serviceName"> <idref bean="standardReportService"/></property>
						<property name="methodName" value="purgeCompletedReports"></property>
						<property name="processName" value= "PurgeCompletedReports"/>
					</bean>
				</property>
              </bean>
          </list>  
      </property>  
  	</bean>	
  	
  	<!--  Generate Weekly Vendor Compliance Report and send an e-mail to the group 
  	bean id="weeklyVendorComplianceReportJob" parent="abstractJob" class="org.springframework.batch.core.job.SimpleJob">  
      <property name="name" value="WeeklyVendorComplianceReport"/>
       <property name="steps">  
          <list>  
              <bean name="WeeklyVendorComplianceReport" parent="taskletStep">  
                  <property name="tasklet">
	                  	<bean id="weeklyVendorComplianceReportTask" parent="abstractTask" class="gov.va.med.fw.batchprocess.ConfigurableBatchProcess">
							<property name="serviceName"> <idref bean="inventoryService"/></property>
							<property name="methodName" value="generateWeeklyVendorComplianceReport"></property>
							<property name="processName" value= "WeeklyVendorComplianceReport"/>
						</bean>	
					</property>
              </bean>
          </list>  
      </property>  
  	</bean
  	-->
  	<bean id="QIRVendorResponseDueJob" parent="abstractJob" class="org.springframework.batch.core.job.SimpleJob">  
      <property name="name" value="QIRVendorResponseDue"/>
       <property name="steps">  
          <list>  
              <bean name="QIRVendorResponseDue" parent="taskletStep">  
                  <property name="tasklet">
	                  	<bean id="qirVendorResponseDueTask" parent="abstractTask" class="gov.va.med.fw.batchprocess.ConfigurableBatchProcess">
							<property name="serviceName"> <idref bean="qirService"/></property>
							<property name="methodName" value="generateVendorResponseDueNotifications"></property>
							<property name="processName" value= "QIRVendorResponseDue"/>
						</bean>	
					</property>
              </bean>
          </list>  
      </property>  
  	</bean>  	
</beans>
