mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2025-01-10 17:11:56 +01:00
Merge branch 'composite-key-dao'
This commit is contained in:
commit
ce8af615d1
@ -7,7 +7,8 @@ archivesBaseName = 'gadgetbridge-daogenerator'
|
||||
|
||||
dependencies {
|
||||
// compile 'org.greenrobot:greendao-generator:2.2.0'
|
||||
compile 'com.github.freeyourgadget:greendao:c3830951e5dd3d1e63d7bac600d5f773b81df363'
|
||||
// compile project(":DaoGenerator")
|
||||
compile 'com.github.freeyourgadget:greendao:1998d7cd2d21f662c6044f6ccf3b3a251bbad341'
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
|
@ -34,7 +34,7 @@ public class GBDaoGenerator {
|
||||
private static final String VALID_BY_DATE = MODEL_PACKAGE + ".ValidByDate";
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Schema schema = new Schema(12, MAIN_PACKAGE + ".entities");
|
||||
Schema schema = new Schema(13, MAIN_PACKAGE + ".entities");
|
||||
|
||||
addActivityDescription(schema);
|
||||
|
||||
@ -137,7 +137,6 @@ public class GBDaoGenerator {
|
||||
activitySample.addIntProperty("rawIntensity").notNull();
|
||||
activitySample.addIntProperty("steps").notNull();
|
||||
activitySample.addIntProperty("rawKind").notNull();
|
||||
addCommonActivitySampleProperties2(activitySample, user, device);
|
||||
addHeartRateProperties(activitySample);
|
||||
return activitySample;
|
||||
}
|
||||
@ -149,7 +148,6 @@ public class GBDaoGenerator {
|
||||
private static Entity addPebbleHealthActivitySample(Schema schema, Entity user, Entity device) {
|
||||
Entity activitySample = addEntity(schema, "PebbleHealthActivitySample");
|
||||
addCommonActivitySampleProperties("AbstractPebbleHealthActivitySample", activitySample, user, device);
|
||||
addCommonActivitySampleProperties2(activitySample, user, device);
|
||||
activitySample.addByteArrayProperty("rawPebbleHealthData");
|
||||
activitySample.addIntProperty("rawIntensity").notNull();
|
||||
activitySample.addIntProperty("steps").notNull();
|
||||
@ -158,31 +156,22 @@ public class GBDaoGenerator {
|
||||
|
||||
private static Entity addPebbleHealthActivityKindOverlay(Schema schema, Entity user, Entity device) {
|
||||
Entity activityOverlay = addEntity(schema, "PebbleHealthActivityOverlay");
|
||||
activityOverlay.addIdProperty();
|
||||
|
||||
activityOverlay.addIntProperty("timestampFrom").notNull().primaryKey();
|
||||
activityOverlay.addIntProperty("timestampTo").notNull().primaryKey();
|
||||
Property deviceId = activityOverlay.addLongProperty("deviceId").primaryKey().getProperty();
|
||||
activityOverlay.addToOne(device, deviceId);
|
||||
|
||||
Property userId = activityOverlay.addLongProperty("userId").getProperty();
|
||||
activityOverlay.addToOne(user, userId);
|
||||
Property deviceId = activityOverlay.addLongProperty("deviceId").getProperty();
|
||||
activityOverlay.addToOne(device, deviceId);
|
||||
|
||||
Property timestampFrom = activityOverlay.addIntProperty("timestampFrom").notNull().getProperty();
|
||||
Property timestampTo = activityOverlay.addIntProperty("timestampTo").notNull().getProperty();
|
||||
activityOverlay.addIntProperty("rawKind").notNull();
|
||||
|
||||
Index indexUnique = new Index();
|
||||
indexUnique.addProperty(deviceId);
|
||||
indexUnique.addProperty(timestampFrom);
|
||||
indexUnique.addProperty(timestampTo);
|
||||
indexUnique.makeUnique();
|
||||
activityOverlay.addIndex(indexUnique);
|
||||
|
||||
return activityOverlay;
|
||||
}
|
||||
|
||||
private static Entity addPebbleMisfitActivitySample(Schema schema, Entity user, Entity device) {
|
||||
Entity activitySample = addEntity(schema, "PebbleMisfitSample");
|
||||
addCommonActivitySampleProperties("AbstractPebbleMisfitActivitySample", activitySample, user, device);
|
||||
addCommonActivitySampleProperties2(activitySample, user, device);
|
||||
activitySample.addIntProperty("rawPebbleMisfitSample").notNull();
|
||||
return activitySample;
|
||||
}
|
||||
@ -190,7 +179,6 @@ public class GBDaoGenerator {
|
||||
private static Entity addPebbleMorpheuzActivitySample(Schema schema, Entity user, Entity device) {
|
||||
Entity activitySample = addEntity(schema, "PebbleMorpheuzSample");
|
||||
addCommonActivitySampleProperties("AbstractPebbleMorpheuzActivitySample", activitySample, user, device);
|
||||
addCommonActivitySampleProperties2(activitySample, user, device);
|
||||
activitySample.addIntProperty("rawIntensity").notNull();
|
||||
return activitySample;
|
||||
}
|
||||
@ -202,21 +190,11 @@ public class GBDaoGenerator {
|
||||
"This class represents a sample specific to the device. Values like activity kind or\n" +
|
||||
"intensity, are device specific. Normalized values can be retrieved through the\n" +
|
||||
"corresponding {@link SampleProvider}.");
|
||||
activitySample.addIdProperty();
|
||||
activitySample.addIntProperty("timestamp").notNull();
|
||||
}
|
||||
|
||||
private static void addCommonActivitySampleProperties2(Entity activitySample, Entity user, Entity device) {
|
||||
activitySample.addIntProperty("timestamp").notNull().primaryKey();
|
||||
Property deviceId = activitySample.addLongProperty("deviceId").primaryKey().getProperty();
|
||||
activitySample.addToOne(device, deviceId);
|
||||
Property userId = activitySample.addLongProperty("userId").getProperty();
|
||||
activitySample.addToOne(user, userId);
|
||||
Property deviceId = activitySample.addLongProperty("deviceId").getProperty();
|
||||
activitySample.addToOne(device, deviceId);
|
||||
|
||||
Index indexUnique = new Index();
|
||||
indexUnique.addProperty(findProperty(activitySample, "timestamp"));
|
||||
indexUnique.addProperty(deviceId);
|
||||
indexUnique.makeUnique();
|
||||
activitySample.addIndex(indexUnique);
|
||||
}
|
||||
|
||||
private static Property findProperty(Entity entity, String propertyName) {
|
||||
|
@ -59,8 +59,10 @@ dependencies {
|
||||
compile 'com.github.pfichtner:durationformatter:0.1.1'
|
||||
compile 'de.cketti.library.changelog:ckchangelog:1.2.2'
|
||||
compile 'net.e175.klaus:solarpositioning:0.0.9'
|
||||
compile 'com.github.freeyourgadget:greendao:c3830951e5dd3d1e63d7bac600d5f773b81df363'
|
||||
compile 'com.github.freeyourgadget:greendao:1998d7cd2d21f662c6044f6ccf3b3a251bbad341'
|
||||
compile 'com.github.woxthebox:draglistview:1.2.6'
|
||||
|
||||
// compile project(":DaoCore")
|
||||
}
|
||||
|
||||
preBuild.dependsOn(":GBDaoGenerator:genSources")
|
||||
|
@ -146,8 +146,7 @@ public class GBApplication extends Application {
|
||||
}
|
||||
|
||||
static void setupDatabase(Context context) {
|
||||
// DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(this, "test-db", null);
|
||||
DBOpenHelper helper = new DBOpenHelper(context, "test-db4", null);
|
||||
DBOpenHelper helper = new DBOpenHelper(context, "test-db5", null);
|
||||
SQLiteDatabase db = helper.getWritableDatabase();
|
||||
DaoMaster daoMaster = new DaoMaster(db);
|
||||
if (lockHandler == null) {
|
||||
|
@ -328,13 +328,12 @@ public class FetchActivityOperation extends AbstractMiBandOperation {
|
||||
}
|
||||
|
||||
samples[minutes] = new MiBandActivitySample(
|
||||
null,
|
||||
timestampInSeconds,
|
||||
deviceId,
|
||||
userId,
|
||||
intensity & 0xff,
|
||||
steps & 0xff,
|
||||
category & 0xff,
|
||||
userId,
|
||||
deviceId,
|
||||
heartrate & 0xff);
|
||||
samples[minutes].setProvider(provider);
|
||||
|
||||
|
@ -83,7 +83,7 @@ public class AppMessageHandlerMisfit extends AppMessageHandler {
|
||||
Long deviceId = DBHelper.getDevice(getDevice(), db.getDaoSession()).getId();
|
||||
for (int i = 0; i < samples; i++) {
|
||||
short sample = buf.getShort();
|
||||
misfitSamples[i] = new PebbleMisfitSample(null, timestamp + i * 60, userId, deviceId, sample & 0xffff);
|
||||
misfitSamples[i] = new PebbleMisfitSample(timestamp + i * 60, userId, deviceId, sample & 0xffff);
|
||||
misfitSamples[i].setProvider(sampleProvider);
|
||||
int steps = misfitSamples[i].getSteps();
|
||||
totalSteps += steps;
|
||||
|
@ -114,7 +114,7 @@ public class AppMessageHandlerMorpheuz extends AppMessageHandler {
|
||||
Long userId = DBHelper.getUser(db.getDaoSession()).getId();
|
||||
Long deviceId = DBHelper.getDevice(getDevice(), db.getDaoSession()).getId();
|
||||
PebbleMorpheuzSampleProvider sampleProvider = new PebbleMorpheuzSampleProvider(getDevice(), db.getDaoSession());
|
||||
PebbleMorpheuzSample sample = new PebbleMorpheuzSample(null, recording_base_timestamp + index * 600, userId, deviceId, intensity);
|
||||
PebbleMorpheuzSample sample = new PebbleMorpheuzSample(recording_base_timestamp + index * 600, userId, deviceId, intensity);
|
||||
sample.setProvider(sampleProvider);
|
||||
sampleProvider.addGBActivitySample(sample);
|
||||
} catch (Exception e) {
|
||||
|
@ -72,7 +72,7 @@ class DatalogSessionHealthOverlayData extends DatalogSessionPebbleHealth {
|
||||
|
||||
List<PebbleHealthActivityOverlay> overlayList = new ArrayList<>();
|
||||
for (OverlayRecord overlayRecord : overlayRecords) {
|
||||
overlayList.add(new PebbleHealthActivityOverlay(null, userId, deviceId, overlayRecord.timestampStart, overlayRecord.timestampStart + overlayRecord.durationSeconds - 1, overlayRecord.type)); //TODO: consider if "-1" is what we really want
|
||||
overlayList.add(new PebbleHealthActivityOverlay(overlayRecord.timestampStart, overlayRecord.timestampStart + overlayRecord.durationSeconds - 1, deviceId, userId, overlayRecord.type)); //TODO: consider if "-1" is what we really want
|
||||
}
|
||||
overlayDao.insertOrReplaceInTx(overlayList);
|
||||
} catch (Exception ex) {
|
||||
|
@ -71,7 +71,7 @@ class DatalogSessionHealthSleep extends DatalogSessionPebbleHealth {
|
||||
|
||||
List<PebbleHealthActivityOverlay> overlayList = new ArrayList<>();
|
||||
for (SleepRecord sleepRecord : sleepRecords) {
|
||||
overlayList.add(new PebbleHealthActivityOverlay(null, userId, deviceId, sleepRecord.bedTimeStart, sleepRecord.bedTimeEnd - 1, sleepRecord.type)); //TODO: consider if "-1" is what we really want
|
||||
overlayList.add(new PebbleHealthActivityOverlay(sleepRecord.bedTimeStart, sleepRecord.bedTimeEnd - 1, deviceId, userId, sleepRecord.type)); //TODO: consider if "-1" is what we really want
|
||||
}
|
||||
overlayDao.insertOrReplaceInTx(overlayList);
|
||||
} catch (Exception ex) {
|
||||
|
@ -82,7 +82,6 @@ public class DatalogSessionHealthSteps extends DatalogSessionPebbleHealth {
|
||||
for (int j = 0; j < stepsRecords.length; j++) {
|
||||
StepsRecord stepsRecord = stepsRecords[j];
|
||||
samples[j] = new PebbleHealthActivitySample(
|
||||
null,
|
||||
stepsRecord.timestamp,
|
||||
userId, deviceId,
|
||||
null, // raw data here
|
||||
|
Loading…
Reference in New Issue
Block a user