// Decompiled by Jad v1.5.8e. Copyright 2001 Pavel Kouznetsov. // Jad home page: http://www.geocities.com/kpdus/jad.html // Decompiler options: braces fieldsfirst space lnc package com.olio.data.object.analytics.database; import android.content.Context; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteException; import android.database.sqlite.SQLiteOpenHelper; import com.olio.olios.model.record.DatabaseRecord; import com.olio.util.ALog; import java.lang.reflect.Method; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Set; // Referenced classes of package com.olio.data.object.analytics.database: // AnalyticsDataContract public class AnalyticsDatabaseHelper extends SQLiteOpenHelper { private static final String DATABASE_NAME = "analytics_database"; private static final int DATABASE_VERSION = 3; private static final long MAXIMUM_DATABASE_SIZE = 0x989680L; private HashMap mModifiedTables; public AnalyticsDatabaseHelper(Context context) { super(context, "analytics_database", null, 3); mModifiedTables = new HashMap(); } private void cleanTables(SQLiteDatabase sqlitedatabase, int i) { Iterator iterator = mModifiedTables.entrySet().iterator(); do { if (!iterator.hasNext()) { break; } Object obj = (java.util.Map.Entry)iterator.next(); if (((Integer)((java.util.Map.Entry) (obj)).getKey()).intValue() > i) { obj = ((List)((java.util.Map.Entry) (obj)).getValue()).iterator(); while (((Iterator) (obj)).hasNext()) { Object obj1 = (String)((Iterator) (obj)).next(); try { obj1 = ((com.olio.olios.model.record.DatabaseRecord.DatabaseRecordFactory)(com.olio.olios.model.record.DatabaseRecord.DatabaseRecordFactory)Class.forName(((String) (obj1))).getMethod("staticFactory", new Class[0]).invoke(null, new Object[0])).getRecordInstance(); ALog.d("dropping table %s", new Object[] { ((DatabaseRecord) (obj1)).tableName() }); sqlitedatabase.execSQL((new StringBuilder()).append("DROP TABLE IF EXISTS ").append(((DatabaseRecord) (obj1)).tableName()).toString()); } catch (ReflectiveOperationException reflectiveoperationexception) { ALog.e(reflectiveoperationexception.toString(), new Object[0]); reflectiveoperationexception.printStackTrace(); } catch (IllegalArgumentException illegalargumentexception) { ALog.e(illegalargumentexception.toString(), new Object[0]); illegalargumentexception.printStackTrace(); } } } } while (true); } private String createStatementForRecordFactory(com.olio.olios.model.record.DatabaseRecord.DatabaseRecordFactory databaserecordfactory) { Object obj = databaserecordfactory.getRecordInstance(); databaserecordfactory = new StringBuilder(); databaserecordfactory.append((new StringBuilder()).append("CREATE TABLE ").append(((DatabaseRecord) (obj)).tableName()).append(" ( \n").toString()); databaserecordfactory.append("_id INTEGER PRIMARY KEY,\n"); obj = ((DatabaseRecord) (obj)).recordFields().iterator(); do { if (!((Iterator) (obj)).hasNext()) { break; } com.olio.olios.model.record.DatabaseRecord.RecordField recordfield = (com.olio.olios.model.record.DatabaseRecord.RecordField)((Iterator) (obj)).next(); if (!recordfield.columnName().equals("_id")) { databaserecordfactory.append((new StringBuilder()).append(recordfield.columnName()).append(" ").append(recordfield.createType()).append(",\n").toString()); } } while (true); databaserecordfactory.append("date_created LONG,\n"); databaserecordfactory.append("date_modified LONG\n"); databaserecordfactory.append(");"); return databaserecordfactory.toString(); } public void onCreate(SQLiteDatabase sqlitedatabase) { com.olio.olios.model.record.DatabaseRecord.DatabaseRecordFactory adatabaserecordfactory[] = AnalyticsDataContract.getDatabaseTables(); int j = adatabaserecordfactory.length; int i = 0; while (i < j) { com.olio.olios.model.record.DatabaseRecord.DatabaseRecordFactory databaserecordfactory = adatabaserecordfactory[i]; try { sqlitedatabase.execSQL(createStatementForRecordFactory(databaserecordfactory)); } catch (SQLiteException sqliteexception) { ALog.w("Problem creating database: %s", sqliteexception, new Object[] { databaserecordfactory.getRecordInstance().tableName() }); } i++; } } public void onDowngrade(SQLiteDatabase sqlitedatabase, int i, int j) { com.olio.olios.model.record.DatabaseRecord.DatabaseRecordFactory adatabaserecordfactory[] = AnalyticsDataContract.getDatabaseTables(); j = adatabaserecordfactory.length; for (i = 0; i < j; i++) { com.olio.olios.model.record.DatabaseRecord.DatabaseRecordFactory databaserecordfactory = adatabaserecordfactory[i]; sqlitedatabase.execSQL((new StringBuilder()).append("DROP TABLE IF EXISTS ").append(databaserecordfactory.getRecordInstance().tableName()).toString()); } onCreate(sqlitedatabase); } public void onOpen(SQLiteDatabase sqlitedatabase) { ALog.d("Current DB Max size: %d", new Object[] { Long.valueOf(sqlitedatabase.getMaximumSize()) }); ALog.d("Database max size set to: %d", new Object[] { Long.valueOf(sqlitedatabase.setMaximumSize(0x989680L)) }); } public void onUpgrade(SQLiteDatabase sqlitedatabase, int i, int j) { ALog.d("onUpgrade -- old version: %d new version: %d", new Object[] { Integer.valueOf(i), Integer.valueOf(j) }); cleanTables(sqlitedatabase, i); onCreate(sqlitedatabase); } }