BgReading: add sourcePlugin and filtered fields.
This commit is contained in:
parent
4efb115209
commit
98c933af57
|
@ -38,6 +38,10 @@ public class BgReading implements DataPointWithLabelInterface {
|
|||
public String direction;
|
||||
@DatabaseField
|
||||
public double raw;
|
||||
@DatabaseField
|
||||
public boolean filtered;
|
||||
@DatabaseField
|
||||
public String sourcePlugin;
|
||||
|
||||
@DatabaseField
|
||||
public int source = Source.NONE;
|
||||
|
@ -120,19 +124,11 @@ public class BgReading implements DataPointWithLabelInterface {
|
|||
", value=" + value +
|
||||
", direction=" + direction +
|
||||
", raw=" + raw +
|
||||
", filtered=" + filtered +
|
||||
", sourcePlugin=" + sourcePlugin +
|
||||
'}';
|
||||
}
|
||||
|
||||
public boolean isDataChanging(BgReading other) {
|
||||
if (date != other.date) {
|
||||
log.error("Comparing different");
|
||||
return false;
|
||||
}
|
||||
if (value != other.value)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isEqual(BgReading other) {
|
||||
if (date != other.date) {
|
||||
log.error("Comparing different");
|
||||
|
@ -158,6 +154,8 @@ public class BgReading implements DataPointWithLabelInterface {
|
|||
raw = other.raw;
|
||||
direction = other.direction;
|
||||
_id = other._id;
|
||||
sourcePlugin = other.sourcePlugin;
|
||||
filtered = other.filtered;
|
||||
}
|
||||
|
||||
// ------------------ DataPointWithLabelInterface ------------------
|
||||
|
|
|
@ -117,12 +117,27 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
|||
TableUtils.createTableIfNotExists(connectionSource, CareportalEvent.class);
|
||||
TableUtils.createTableIfNotExists(connectionSource, ProfileSwitch.class);
|
||||
TableUtils.createTableIfNotExists(connectionSource, TDD.class);
|
||||
|
||||
// soft migration without changing DB version
|
||||
createRowIfNotExists(getDaoBgReadings(), DatabaseHelper.DATABASE_BGREADINGS,
|
||||
"filtered", "integer");
|
||||
createRowIfNotExists(getDaoBgReadings(), DatabaseHelper.DATABASE_BGREADINGS,
|
||||
"sourcePlugin", "integer");
|
||||
|
||||
} catch (SQLException e) {
|
||||
log.error("Can't create database", e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void createRowIfNotExists(Dao dao, String table, String name, String type) {
|
||||
try {
|
||||
dao.executeRaw("ALTER TABLE `" + table + "` ADD CoLUMN `" + name + " " + type);
|
||||
} catch (SQLException e) {
|
||||
// row already exists
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpgrade(SQLiteDatabase database, ConnectionSource connectionSource, int oldVersion, int newVersion) {
|
||||
try {
|
||||
|
|
Loading…
Reference in a new issue