<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:aop="http://www.springframework.org/schema/aop" xmlns="http://www.springframework.org/schema/beans"
	xmlns:tx="http://www.springframework.org/schema/tx" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:util="http://www.springframework.org/schema/util"
	xsi:schemaLocation="
		http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
		http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
		
	<!--  This bean sets up property replacement so that variables can be externalized to system properties -->
	<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
		<property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" />
	</bean>
	
	<util:list id="haTemplateIdList">
       <value>HealthAdapterRead1</value>
       <value>HealthAdapterCreate1</value>
       <value>HealthAdapterUpdate1</value>
       <value>HealthAdapterDelete1</value>
       <value>HealthAdapterAssessmentDocumentDetailRead1</value>
       <value>HealthAdapterJournalDetailRead1</value>
    </util:list>
    

	<bean id="hdrDataSource" class="org.apache.commons.dbcp2.BasicDataSource" destroy-method="close">
		<property name="driverClassName" value="oracle.jdbc.OracleDriver" />
		<property name="url" value="${cds.jdbc.url}" />
		<property name="username" value="${cds.jdbc.username}" />
		<property name="password" value="${cds.jdbc.password}" />
		<property name="defaultAutoCommit" value="true"/>
	</bean>
	
	<bean id="auditLogPersistenceManager" class="gov.va.med.cds.audit.persistence.hibernate.HibernateAuditLogPersistenceManager">
		<property name="hibernateTemplate" ref="hibernateTemplate"/>
		<property name="haTemplateIdList" ref="haTemplateIdList"/>
	</bean>
	
	<bean id="auditLogPersistenceManagerPathways" class="gov.va.med.cds.audit.persistence.hibernate.HibernatePathwaysAuditLogPersistenceManager">
        <property name="hibernateTemplate" ref="hibernateTemplatePathways"/>
    </bean>
    
    <bean id="auditLogPersistenceManagerHa" class="gov.va.med.cds.audit.persistence.hibernate.HibernateAuditLogPersistenceManager">
		<property name="hibernateTemplate" ref="hibernateTemplate"/>
        <property name="hibernateTemplateHa" ref="hibernateTemplateHa"/>
        <property name="haTemplateIdList" ref="haTemplateIdList"/>
    </bean>
	
	<bean id="auditLogSessionFactory"
		class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
		<property name="dataSource" ref="hdrDataSource" />
		
		<property name="mappingResources">
			<list>
				<value>gov/va/med/cds/audit/persistence/hibernate/LegacyReadAuditLog.hbm.xml</value>
				<value>gov/va/med/cds/audit/persistence/hibernate/VhimReadAuditLog.hbm.xml</value>
				<value>gov/va/med/cds/audit/persistence/hibernate/ClientMapping.hbm.xml</value>
                <value>gov/va/med/cds/audit/persistence/hibernate/TemplateId.hbm.xml</value>
                <value>gov/va/med/cds/audit/persistence/hibernate/FilterId.hbm.xml</value>
			</list>
		</property>
		<property name="hibernateProperties">
			<props>
			    <prop key="hibernate.query.factory_class">org.hibernate.hql.internal.classic.ClassicQueryTranslatorFactory</prop>
				<prop key="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</prop>
				<prop key="hibernate.show_sql" >${hibernate.show.sql}</prop>
			</props>
		</property>
	</bean>
	
	
	   <bean id="auditLogSessionFactoryPathways" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
        <property name="dataSource" ref="hdrDataSource" />
        
        <property name="mappingResources">
            <list>
               <value>gov/va/med/cds/audit/persistence/hibernate/VhimReadPathwaysAuditLog.hbm.xml</value>
               <value>gov/va/med/cds/audit/persistence/hibernate/ClientMappingPathways.hbm.xml</value>
               <value>gov/va/med/cds/audit/persistence/hibernate/TemplateId.hbm.xml</value>
               <value>gov/va/med/cds/audit/persistence/hibernate/FilterId.hbm.xml</value>
            </list>
        </property>
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.query.factory_class">org.hibernate.hql.internal.classic.ClassicQueryTranslatorFactory</prop>
                <prop key="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</prop>
                <prop key="hibernate.show_sql" >${hibernate.show.sql}</prop>
            </props>
        </property>
    </bean>
    
    
    <bean id="auditLogSessionFactoryHa"
        class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
        <property name="dataSource" ref="hdrDataSource" />
        
        <property name="mappingResources">
            <list>
                <value>gov/va/med/cds/audit/persistence/hibernate/VhimReadAuditLogHa.hbm.xml</value>
                <value>gov/va/med/cds/audit/persistence/hibernate/ClientMapping.hbm.xml</value>
                <value>gov/va/med/cds/audit/persistence/hibernate/TemplateId.hbm.xml</value>
                <value>gov/va/med/cds/audit/persistence/hibernate/FilterId.hbm.xml</value>
            </list>
        </property>
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.query.factory_class">org.hibernate.hql.internal.classic.ClassicQueryTranslatorFactory</prop>
                <prop key="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</prop>
                <prop key="hibernate.show_sql" >${hibernate.show.sql}</prop>
            </props>
        </property>
    </bean>
	
	<bean id="hibernateTemplate" class="org.springframework.orm.hibernate4.HibernateTemplate">
        <property name="sessionFactory" ref="auditLogSessionFactory"/>
    </bean>
    
    <bean id="hibernateTemplatePathways" class="org.springframework.orm.hibernate4.HibernateTemplate">
        <property name="sessionFactory" ref="auditLogSessionFactoryPathways"/>
    </bean>
    
    <bean id="hibernateTemplateHa" class="org.springframework.orm.hibernate4.HibernateTemplate">
        <property name="sessionFactory" ref="auditLogSessionFactoryHa"/>
    </bean>
</beans>