dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #41269
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21016: Supporting 'dhis.conf' as dhis configuration file as an alternative to 'hibarnate.properties'. Ne...
------------------------------------------------------------
revno: 21016
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2015-11-10 18:56:46 +0100
message:
Supporting 'dhis.conf' as dhis configuration file as an alternative to 'hibarnate.properties'. New framework-agnostic conf properties are connection.dialect, connection.driver_class, connection.url, connection.username, connection.password, connection.schema.
modified:
dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/DefaultHibernateConfigurationProvider.java
dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/HibernateConfigurationProvider.java
dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/HibernateMappingDirectoryLocationsFactoryBean.java
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/DefaultHibernateConfigurationProvider.java'
--- dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/DefaultHibernateConfigurationProvider.java 2015-11-10 17:36:28 +0000
+++ dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/DefaultHibernateConfigurationProvider.java 2015-11-10 17:56:46 +0000
@@ -43,6 +43,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.cfg.Configuration;
+import org.hisp.dhis.external.conf.ConfigurationKey;
import org.hisp.dhis.external.conf.DhisConfigurationProvider;
import org.hisp.dhis.external.location.LocationManagerException;
import org.springframework.core.io.ClassPathResource;
@@ -144,7 +145,9 @@
{
Properties fileProperties = configurationProvider.getProperties();
- configuration.addProperties( fileProperties );
+ mapDhisToHibernateProperties( fileProperties );
+
+ configuration.addProperties( fileProperties );
}
catch ( LocationManagerException ex )
{
@@ -194,6 +197,26 @@
// Supportive methods
// -------------------------------------------------------------------------
+ private void mapDhisToHibernateProperties( Properties properties )
+ {
+ putIfExists( properties, ConfigurationKey.CONNECTION_DIALECT.getKey(), "hibernate.dialect" );
+ putIfExists( properties, ConfigurationKey.CONNECTION_DRIVER_CLASS.getKey(), "hibernate.connection.driver_class" );
+ putIfExists( properties, ConfigurationKey.CONNECTION_URL.getKey(), "hibernate.connection.url" );
+ putIfExists( properties, ConfigurationKey.CONNECTION_USERNAME.getKey(), "hibernate.connection.username" );
+ putIfExists( properties, ConfigurationKey.CONNECTION_PASSWORD.getKey(), "hibernate.connection.password" );
+ putIfExists( properties, ConfigurationKey.CONNECTION_SCHEMA.getKey(), "hibernate.hbm2ddl.auto" );
+ }
+
+ private void putIfExists( Properties properties, String from, String to )
+ {
+ String value = properties.getProperty( from );
+
+ if ( value != null && !value.isEmpty() )
+ {
+ properties.put( to, value );
+ }
+ }
+
private Properties getProperties( String path )
throws IOException
{
=== modified file 'dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/HibernateConfigurationProvider.java'
--- dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/HibernateConfigurationProvider.java 2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/HibernateConfigurationProvider.java 2015-11-10 17:56:46 +0000
@@ -36,7 +36,6 @@
/**
* @author Torgeir Lorange Ostby
- * @version $Id: HibernateConfigurationProvider.java 3217 2007-04-02 08:54:21Z torgeilo $
*/
public interface HibernateConfigurationProvider
{
=== modified file 'dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/HibernateMappingDirectoryLocationsFactoryBean.java'
--- dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/HibernateMappingDirectoryLocationsFactoryBean.java 2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/HibernateMappingDirectoryLocationsFactoryBean.java 2015-11-10 17:56:46 +0000
@@ -33,7 +33,6 @@
/**
* @author Lars Helge Overland
- * @version $Id$
*/
public class HibernateMappingDirectoryLocationsFactoryBean
implements FactoryBean<Object[]>