<?xml version="1.0" encoding="UTF-8"?>
<!--
    Copyright 2018 The MIT Internet Trust Consortium
   
    Portions copyright 2011-2013 The MITRE Corporation
   
    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at
   
      http://www.apache.org/licenses/LICENSE-2.0
   
    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
 -->
<beans xmlns="http://www.springframework.org/schema/beans"
	   xmlns:jdbc="http://www.springframework.org/schema/jdbc"
       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.xsd
       						http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd">

	<bean id="dataSource" class="com.zaxxer.hikari.HikariDataSource" destroy-method="close">
		<property name="driverClassName" value="org.hsqldb.jdbcDriver" />
		<property name="jdbcUrl" value="jdbc:hsqldb:mem:oic;sql.syntax_mys=true" />
<!-- 		<property name="jdbcUrl" value="jdbc:hsqldb:file:/tmp/oic;sql.syntax_mys=true" /> -->
		<property name="username" value="oic" />
		<property name="password" value="oic" />
	</bean>

	<!-- Use the following to set up the OIC tables in the in-memory DB
 		   If you are using a file based HSQLDB you should not run this every time. -->
	<jdbc:initialize-database data-source="dataSource">
		<jdbc:script location="classpath:/db/hsql/hsql_database_tables.sql"/>
		<!-- The following file is for the jdbc-user-service spring security implementation -->
		<jdbc:script location="classpath:/db/hsql/security-schema.sql"/>
		<!-- The following files are for safely bootstrapping users and clients into the database -->
		<jdbc:script location="classpath:/db/hsql/loading_temp_tables.sql"/>
		<jdbc:script location="classpath:/db/hsql/users.sql"/>
		<jdbc:script location="classpath:/db/hsql/clients.sql"/>
		<jdbc:script location="classpath:/db/hsql/scopes.sql"/>
	</jdbc:initialize-database>

	<bean id="jpaAdapter" class="org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter">
 		<property name="databasePlatform" value="org.eclipse.persistence.platform.database.HSQLPlatform" />
		<property name="showSql" value="true" />
	</bean>

	<!--  The following is for connecting to a MySQL database that has been initialized with 
			src/main/resources/db/mysql/mysql_database_tables.sql -->
<!-- 	<bean id="dataSource" class="com.zaxxer.hikari.HikariDataSource" destroy-method="close"> -->
<!-- 		<property name="driverClassName" value="com.mysql.jdbc.Driver" /> -->
<!-- 		<property name="jdbcUrl" value="jdbc:mysql://127.0.0.1:3306/oic" /> -->
<!-- 		<property name="username" value="oic" /> -->
<!-- 		<property name="password" value="oic" /> -->
<!--  	</bean> -->

<!-- 	<bean id="jpaAdapter" class="org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter"> -->
<!-- 		<property name="databasePlatform" value="org.eclipse.persistence.platform.database.MySQLPlatform" /> -->
<!-- 		<property name="showSql" value="true" /> -->
<!-- 	</bean> -->

	<!-- You can optionally initialize the database with test values here, 
		but this is not recommended for real systems -->
<!-- 	<jdbc:initialize-database data-source="dataSource"> -->
<!-- 		<jdbc:script location="classpath:/db/tables/mysql_database_tables.sql"/> -->
<!-- 		<jdbc:script location="classpath:/db/tables/security-schema.sql"/> -->
<!-- 		<jdbc:script location="classpath:/db/tables/loading_temp_tables.sql"/> -->
<!-- 		<jdbc:script location="classpath:/db/mysql/users.sql"/> -->
<!-- 		<jdbc:script location="classpath:/db/mysql/clients.sql"/> -->
<!-- 		<jdbc:script location="classpath:/db/mysql/scopes.sql"/> -->
<!-- 	</jdbc:initialize-database> -->

	<!--  The following is for connecting to a PostgreSQL database that has been initialized with
			src/main/resources/db/psql/psql_database_tables.sql -->
	<!--
	<bean id="dataSource" class="com.zaxxer.hikari.HikariDataSource" destroy-method="close">
		<property name="driverClassName" value="org.postgresql.Driver" />
		<property name="jdbcUrl" value="jdbc:postgresql://localhost/oic" />
		<property name="username" value="oic" />
		<property name="password" value="oic" />
	</bean>


	<bean id="jpaAdapter" class="org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter">
		<property name="databasePlatform" value="org.eclipse.persistence.platform.database.PostgreSQLPlatform" />
		<property name="showSql" value="true" />
	</bean>
	-->
	
	<!-- You can optionally initialize the database with test values here, 
		but this is not recommended for real systems -->
<!-- 	<jdbc:initialize-database data-source="dataSource"> -->
<!-- 		<jdbc:script location="classpath:/db/psql/psql_database_tables.sql"/> -->
<!-- 		<jdbc:script location="classpath:/db/psql/security-schema.sql"/> -->
<!-- 		<jdbc:script location="classpath:/db/psql/loading_temp_tables.sql"/> -->
<!-- 		<jdbc:script location="classpath:/db/psql/users.sql"/> -->
<!-- 		<jdbc:script location="classpath:/db/psql/clients.sql"/> -->
<!-- 		<jdbc:script location="classpath:/db/psql/scopes.sql"/> -->
<!-- 	</jdbc:initialize-database> -->

	<!--  The following is for connecting to a Oracle database that has been initialized with
			src/main/resources/db/oracle/oracle_database_tables.sql -->
	<!--<bean id="dataSource" class="com.zaxxer.hikari.HikariDataSource" destroy-method="close">
		<property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" />
		<property name="jdbcUrl" value="jdbc:oracle:thin:@localhost:1521:XE" />
		<property name="username" value="oic" />
		<property name="password" value="oic" />
	</bean>-->

	<!--<bean id="jpaAdapter" class="org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter">
		<property name="databasePlatform" value="org.eclipse.persistence.platform.database.OraclePlatform" />
		<property name="showSql" value="true" />
	</bean>-->

	<!-- Use the following to set up the OIC tables in the Oracle DB
		   Below scripts are intended to be run once at startup. -->
	<!--<jdbc:initialize-database data-source="dataSource">
		<jdbc:script location="classpath:/db/oracle/oracle_database_tables.sql"/>
		<jdbc:script location="classpath:/db/oracle/security-schema_oracle.sql"/>
		<jdbc:script location="classpath:/db/oracle/loading_temp_tables_oracle.sql"/>
		<jdbc:script location="classpath:/db/oracle/users_oracle.sql"/>
		<jdbc:script location="classpath:/db/oracle/clients_oracle.sql"/>
		<jdbc:script location="classpath:/db/oracle/scopes_oracle.sql"/>
	</jdbc:initialize-database>-->
</beans>