Permalink
Browse files

Migrate measurements from session into streams

  • Loading branch information...
1 parent 8ef4b2a commit 9e104ef9bc42855de86f920a0739d187573d119b @ags313 ags313 committed Mar 30, 2012
@@ -19,16 +19,18 @@
*/
package pl.llp.aircasting.guice;
-import pl.llp.aircasting.model.SchemaMigrator;
+import pl.llp.aircasting.model.AirCastingDB;
import com.google.inject.Inject;
import com.google.inject.Provider;
-public class DBHelperProvider implements Provider<SchemaMigrator> {
+public class AirCastingDBProvider implements Provider<AirCastingDB>
+{
@Inject AirCastingApplication application;
@Override
- public SchemaMigrator get() {
- return new SchemaMigrator(application);
+ public AirCastingDB get()
+ {
+ return new AirCastingDB(application);
}
}
@@ -19,7 +19,7 @@
*/
package pl.llp.aircasting.guice;
-import pl.llp.aircasting.model.SchemaMigrator;
+import pl.llp.aircasting.model.AirCastingDB;
import pl.llp.aircasting.util.http.HttpBuilder;
import pl.llp.aircasting.view.overlay.NoteOverlay;
@@ -38,26 +38,26 @@
public class AirCastingModule extends AbstractAndroidModule
{
- @Override
- protected void configure() {
- requestStaticInjection(HttpBuilder.class);
+ @Override
+ protected void configure() {
+ requestStaticInjection(HttpBuilder.class);
- bind(Gson.class).toProvider(GsonProvider.class).in(Scopes.SINGLETON);
+ bind(Gson.class).toProvider(GsonProvider.class).in(Scopes.SINGLETON);
- bind(HttpClient.class).to(DefaultHttpClient.class);
+ bind(HttpClient.class).to(DefaultHttpClient.class);
- bind(SchemaMigrator.class).toProvider(DBHelperProvider.class);
+ bind(AirCastingDB.class).toProvider(AirCastingDBProvider.class);
- bind(NoteOverlay.class).toProvider(NoteOverlayProvider.class);
+ bind(NoteOverlay.class).toProvider(NoteOverlayProvider.class);
- bind(Geocoder.class).toProvider(GeocoderProvider.class);
+ bind(Geocoder.class).toProvider(GeocoderProvider.class);
- bind(EventBus.class).in(Scopes.SINGLETON);
+ bind(EventBus.class).in(Scopes.SINGLETON);
- bindConstant().annotatedWith(SharedPreferencesName.class).to("pl.llp.aircasting_preferences");
+ bindConstant().annotatedWith(SharedPreferencesName.class).to("pl.llp.aircasting_preferences");
- bind(BluetoothAdapter.class).toProvider(BluetoothAdapterProvider.class);
+ bind(BluetoothAdapter.class).toProvider(BluetoothAdapterProvider.class);
- bind(TelephonyManager.class).toProvider(new SystemServiceProvider<TelephonyManager>(Context.TELEPHONY_SERVICE));
- }
+ bind(TelephonyManager.class).toProvider(new SystemServiceProvider<TelephonyManager>(Context.TELEPHONY_SERVICE));
+ }
}
@@ -0,0 +1,27 @@
+package pl.llp.aircasting.model;
+
+import android.content.Context;
+import android.database.sqlite.SQLiteDatabase;
+import android.database.sqlite.SQLiteOpenHelper;
+
+/**
+ * Created by ags on 28/03/12 at 16:23
+ */
+public class AirCastingDB extends SQLiteOpenHelper implements DBConstants
+{
+ public AirCastingDB(Context context) {
+ super(context, DB_NAME, null, DB_VERSION);
+ }
+
+ @Override
+ public void onCreate(SQLiteDatabase db)
+ {
+ new SchemaMigrator().create(db);
+ }
+
+ @Override
+ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion)
+ {
+ new SchemaMigrator().migrate(db, oldVersion, newVersion);
+ }
+}
@@ -24,7 +24,7 @@
public interface DBConstants
{
String DB_NAME = "sessions.db";
- int DB_VERSION = 22;
+ int DB_VERSION = 23;
String SESSION_TABLE_NAME = "Sessions";
String SESSION_ID = BaseColumns._ID;
@@ -64,8 +64,6 @@
String STREAM_ID = BaseColumns._ID;
String STREAM_AVG = "Average";
String STREAM_PEAK = "Peak";
- String STREAM_START = "Start";
- String STREAM_END = "End";
String STREAM_SESSION_ID = "stream_session_id";
String STREAM_SENSOR_NAME = "sensor_name";
String STREAM_MEASUREMENT_TYPE = "measurement_type";
@@ -1,100 +0,0 @@
-/**
- AirCasting - Share your Air!
- Copyright (C) 2011-2012 HabitatMap, Inc.
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
- You can contact the authors by email at <info@habitatmap.org>
-*/
-package pl.llp.aircasting.model;
-
-import android.content.Context;
-import android.database.sqlite.SQLiteDatabase;
-import android.database.sqlite.SQLiteOpenHelper;
-
-/**
- * Created by IntelliJ IDEA.
- * User: obrok
- * Date: 10/5/11
- * Time: 2:51 PM
- */
-public class DBUtils extends SQLiteOpenHelper implements DBConstants {
- public DBUtils(Context context) {
- super(context, DB_NAME, null, DB_VERSION);
- }
-
- @Override
- public void onCreate(SQLiteDatabase sqLiteDatabase) {
- sqLiteDatabase.execSQL("create table " + SESSION_TABLE_NAME + " (" +
- SESSION_ID + " integer primary key" +
- ", " + SESSION_TITLE + " text" +
- ", " + SESSION_DESCRIPTION + " text" +
- ", " + SESSION_TAGS + " text" +
- ", " + SESSION_AVG + " real" +
- ", " + SESSION_PEAK + " real" +
- ", " + SESSION_START + " integer" +
- ", " + SESSION_END + " integer" +
- ", " + SESSION_UUID + " text" +
- ", " + SESSION_LOCATION + " text" +
- ", " + SESSION_CALIBRATION + " integer" +
- ", " + SESSION_CONTRIBUTE + " boolean" +
- ", " + SESSION_OS_VERSION + " text" +
- ", " + SESSION_PHONE_MODEL + " text" +
- ", " + SESSION_DATA_TYPE + " text" +
- ", " + SESSION_INSTRUMENT + " text" +
- ", " + SESSION_OFFSET_60_DB + " integer" +
- ", " + SESSION_MARKED_FOR_REMOVAL + " boolean" +
- ", " + SESSION_SUBMITTED_FOR_REMOVAL + " boolean" +
- ")"
- );
- sqLiteDatabase.execSQL("create table " + MEASUREMENT_TABLE_NAME + " (" +
- MEASUREMENT_SESSION_ID + " integer" +
- ", " + MEASUREMENT_ID + " integer primary key" +
- ", " + MEASUREMENT_LATITUDE + " real" +
- ", " + MEASUREMENT_LONGITUDE + " real" +
- ", " + MEASUREMENT_VALUE + " real" +
- ", " + MEASUREMENT_TIME + " integer" +
- ")"
- );
- sqLiteDatabase.execSQL("create table " + NOTE_TABLE_NAME + "(" +
- NOTE_SESSION_ID + " integer " +
- ", " + NOTE_LATITUDE + " real " +
- ", " + NOTE_LONGITUDE + " real " +
- ", " + NOTE_TEXT + " text " +
- ", " + NOTE_DATE + " integer " +
- ", " + NOTE_PHOTO + " text" +
- ", " + NOTE_NUMBER + " integer" +
- ")"
- );
- }
-
- @Override
- public void onUpgrade(SQLiteDatabase sqLiteDatabase, int oldVersion, int newVersion) {
- if (oldVersion < 19 && newVersion >= 19) {
- sqLiteDatabase.execSQL("alter table " + NOTE_TABLE_NAME + " " +
- "add column " + NOTE_PHOTO + " text"
- );
- }
- if (oldVersion < 20 && newVersion >= 20) {
- sqLiteDatabase.execSQL("alter table " + NOTE_TABLE_NAME + " " +
- "add column " + NOTE_NUMBER + " integer"
- );
- }
- if (oldVersion < 21 && newVersion >= 21) {
- sqLiteDatabase.execSQL("alter table " + SESSION_TABLE_NAME + " " +
- "add column " + SESSION_SUBMITTED_FOR_REMOVAL + " boolean"
- );
- }
- }
-}
Oops, something went wrong.

0 comments on commit 9e104ef

Please sign in to comment.