From 8645aae18dce1b461d3f960bd15705b90b6be396 Mon Sep 17 00:00:00 2001 From: Juan Miguel Boyero Corral Date: Fri, 13 Sep 2013 22:02:31 +0200 Subject: [PATCH] Updated begin and end transaction methods --- .../swad/swadroid/model/DataBaseHelper.java | 29 ++++++++++++------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/SWADroid/src/es/ugr/swad/swadroid/model/DataBaseHelper.java b/SWADroid/src/es/ugr/swad/swadroid/model/DataBaseHelper.java index 66cd5903..6256d738 100644 --- a/SWADroid/src/es/ugr/swad/swadroid/model/DataBaseHelper.java +++ b/SWADroid/src/es/ugr/swad/swadroid/model/DataBaseHelper.java @@ -308,7 +308,8 @@ public class DataBaseHelper { ent.getInt("multiple"), ent.getLong("openTime")); } else if (table.equals(Constants.DB_TABLE_PRACTICE_SESSIONS)) { - SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy HH:mm"); + //SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy HH:mm"); + java.text.DateFormat format = SimpleDateFormat.getDateTimeInstance(); try { o = new PracticeSession(ent.getId(), @@ -962,7 +963,7 @@ public class DataBaseHelper { //it should not insert/modify rows in the relationship table if the course does not exists if (course != null) { if (rows.isEmpty()) { - PairTable pair = new PairTable(Constants.DB_TABLE_GROUPS_COURSES, g.getId(), courseCode); + PairTable pair = new PairTable(Constants.DB_TABLE_GROUPS_COURSES, g.getId(), courseCode); insertPairTable(pair); } else { rows.get(0).setValue("crsCod", courseCode); @@ -981,8 +982,10 @@ public class DataBaseHelper { if (rows.isEmpty()) { insertPairTable(new PairTable(Constants.DB_TABLE_GROUPS_GROUPTYPES, groupTypeCode, groupCode)); } else { - PairTable prev = new PairTable(Constants.DB_TABLE_GROUPS_GROUPTYPES, rows.get(0).getValue("grpTypCod"), rows.get(0).getValue("grpCod")); - PairTable current = new PairTable(Constants.DB_TABLE_GROUPS_GROUPTYPES, groupTypeCode, groupCode); + @SuppressWarnings({ "unchecked", "rawtypes" }) + PairTable prev = new PairTable(Constants.DB_TABLE_GROUPS_GROUPTYPES, rows.get(0).getValue("grpTypCod"), rows.get(0).getValue("grpCod")); + @SuppressWarnings({ "unchecked", "rawtypes" }) + PairTable current = new PairTable(Constants.DB_TABLE_GROUPS_GROUPTYPES, groupTypeCode, groupCode); updatePairTable(prev, current); } /*}else returnValue = false;*/ @@ -1375,8 +1378,10 @@ public class DataBaseHelper { insertPairTable(new PairTable(Constants.DB_TABLE_GROUPS_GROUPTYPES, groupTypeCode[0], groupCode)); } else { - PairTable prev = new PairTable(Constants.DB_TABLE_GROUPS_GROUPTYPES, rows.get(0).getValue("grpTypCod"), rows.get(0).getValue("grpCod")); - PairTable current = new PairTable(Constants.DB_TABLE_GROUPS_GROUPTYPES, groupTypeCode[0], groupCode); + @SuppressWarnings({ "rawtypes", "unchecked" }) + PairTable prev = new PairTable(Constants.DB_TABLE_GROUPS_GROUPTYPES, rows.get(0).getValue("grpTypCod"), rows.get(0).getValue("grpCod")); + @SuppressWarnings({ "rawtypes", "unchecked" }) + PairTable current = new PairTable(Constants.DB_TABLE_GROUPS_GROUPTYPES, groupTypeCode[0], groupCode); updatePairTable(prev, current); } @@ -1387,7 +1392,8 @@ public class DataBaseHelper { return false; } - private boolean updateRelationship(Pair tables, Pair idsTables, String relationTable, Pair remainField, Pair changedField) { + @SuppressWarnings("unused") + private boolean updateRelationship(Pair tables, Pair idsTables, String relationTable, Pair remainField, Pair changedField) { return true; @@ -1413,7 +1419,8 @@ public class DataBaseHelper { /** * Updates an existing group type */ - private boolean updateGroupType(GroupType prv, GroupType current) { + @SuppressWarnings("unused") + private boolean updateGroupType(GroupType prv, GroupType current) { List rows = db.getEntityList(Constants.DB_TABLE_GROUP_TYPES, "id=" + prv.getId()); boolean returnValue = true; if (!rows.isEmpty()) { @@ -1803,14 +1810,16 @@ public class DataBaseHelper { * Begin a database transaction */ public void beginTransaction() { - db.getDB().execSQL("BEGIN;"); + //db.getDB().execSQL("BEGIN;"); + db.startTransaction(); } /** * End a database transaction */ public void endTransaction() { - db.getDB().execSQL("END;"); + //db.getDB().execSQL("END;"); + db.endTransaction(); } /**