From c04ca7a926abca58ea8c0e371e1d9dffb3e2108f Mon Sep 17 00:00:00 2001 From: Ziver Koc Date: Mon, 7 Dec 2015 22:51:11 +0100 Subject: [PATCH] Some small fixes Former-commit-id: 2b6db2d58ec76bba2d3e67ac66ce510d3920aba3 --- src/se/koc/hal/HalContext.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/se/koc/hal/HalContext.java b/src/se/koc/hal/HalContext.java index 886b2563..f639ba7c 100755 --- a/src/se/koc/hal/HalContext.java +++ b/src/se/koc/hal/HalContext.java @@ -51,15 +51,16 @@ public class HalContext { db = new DBConnection(DBConnection.DBMS.SQLite, DB_FILE); // Read DB conf - dbConf = new Properties(); - db.exec("SELECT * FROM conf", new PropertiesSQLHandler(dbConf)); + dbConf = + db.exec("SELECT * FROM conf", new PropertiesSQLHandler()); // Upgrade DB needed? DBConnection defaultDB = new DBConnection(DBConnection.DBMS.SQLite, DEFAULT_DB_FILE); Properties defaultDBConf = - db.exec("SELECT * FROM conf", new PropertiesSQLHandler(new Properties())); - if(defaultDBConf.getProperty("db_version").compareTo(dbConf.getProperty("db_version")) > 0) { - logger.info("Upgrading DB (from: v"+dbConf.getProperty("db_version") +", to: v"+defaultDBConf.getProperty("db_version")); + db.exec("SELECT * FROM conf", new PropertiesSQLHandler()); + if(defaultDBConf.getProperty("db_version") != null && + defaultDBConf.getProperty("db_version").compareTo(dbConf.getProperty("db_version")) > 0) { + logger.info("Upgrading DB (from: v"+dbConf.getProperty("db_version") +", to: v"+defaultDBConf.getProperty("db_version") +")..."); upgradeDB(); } defaultDB.close(); @@ -71,8 +72,8 @@ public class HalContext { public static String getStringProperty(String key){ String value = fileConf.getProperty(key); - //if(value == null) // TODO: DB property - // value = dbConf.getProperty(key); + if(value == null) + value = dbConf.getProperty(key); return value; } public static int getIntegerProperty(String key){ @@ -107,7 +108,7 @@ public class HalContext { - remove backup table (DROP table 'temp_" + TableName) - setTransactionSuccessful */ - logger.severe("DB Upgrade not implemented yes!"); + logger.severe("DB Upgrade not implemented yet!"); //db.exec("BeginTransaction"); //db.exec("EndTransaction");