mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2025-01-10 17:11:56 +01:00
Some more WIP towards greendao. Note: does not compile atm.
This commit is contained in:
parent
fc89194396
commit
4744d8b59e
@ -28,9 +28,11 @@ public class GBDaoGenerator {
|
||||
|
||||
public static final String VALID_FROM_UTC = "validFromUTC";
|
||||
public static final String VALID_TO_UTC = "validToUTC";
|
||||
private static final String MAIN_PACKAGE = "nodomain.freeyourgadget.gadgetbridge";
|
||||
private static final String MODEL_PACKAGE = MAIN_PACKAGE + ".model";
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Schema schema = new Schema(7, "nodomain.freeyourgadget.gadgetbridge.entities");
|
||||
Schema schema = new Schema(7, MAIN_PACKAGE + ".entities");
|
||||
|
||||
Entity userAttributes = addUserAttributes(schema);
|
||||
Entity user = addUserInfo(schema, userAttributes);
|
||||
@ -45,7 +47,7 @@ public class GBDaoGenerator {
|
||||
}
|
||||
|
||||
private static Entity addUserInfo(Schema schema, Entity userAttributes) {
|
||||
Entity user = schema.addEntity("User");
|
||||
Entity user = addEntity(schema, "User");
|
||||
user.addIdProperty();
|
||||
user.addStringProperty("name").notNull();
|
||||
user.addDateProperty("birthday").notNull();
|
||||
@ -59,7 +61,7 @@ public class GBDaoGenerator {
|
||||
private static Entity addUserAttributes(Schema schema) {
|
||||
// additional properties of a user, which may change during the lifetime of a user
|
||||
// this allows changing attributes while preserving user identity
|
||||
Entity userAttributes = schema.addEntity("UserAttributes");
|
||||
Entity userAttributes = addEntity(schema, "UserAttributes");
|
||||
userAttributes.addIdProperty();
|
||||
userAttributes.addIntProperty("heightCM").notNull();
|
||||
userAttributes.addIntProperty("weightKG").notNull();
|
||||
@ -72,7 +74,7 @@ public class GBDaoGenerator {
|
||||
}
|
||||
|
||||
private static Entity addDevice(Schema schema, Entity deviceAttributes) {
|
||||
Entity device = schema.addEntity("Device");
|
||||
Entity device = addEntity(schema, "Device");
|
||||
device.addIdProperty();
|
||||
device.addStringProperty("name").notNull();
|
||||
device.addStringProperty("manufacturer").notNull();
|
||||
@ -84,7 +86,7 @@ public class GBDaoGenerator {
|
||||
}
|
||||
|
||||
private static Entity addDeviceAttributes(Schema schema) {
|
||||
Entity deviceAttributes = schema.addEntity("DeviceAttributes");
|
||||
Entity deviceAttributes = addEntity(schema, "DeviceAttributes");
|
||||
deviceAttributes.addIdProperty();
|
||||
deviceAttributes.addStringProperty("firmwareVersion1").notNull();
|
||||
deviceAttributes.addStringProperty("firmwareVersion2");
|
||||
@ -96,29 +98,44 @@ public class GBDaoGenerator {
|
||||
|
||||
private static Entity addMiBandActivitySample(Schema schema, Entity user, Entity device) {
|
||||
// public GBActivitySample(SampleProvider provider, int timestamp, int intensity, int steps, int type, int customValue) {
|
||||
Entity activitySample = schema.addEntity("MiBandActivitySample");
|
||||
Entity activitySample = addEntity(schema, "MiBandActivitySample");
|
||||
activitySample.addImport(MODEL_PACKAGE + ".HeartRateSample");
|
||||
activitySample.implementsInterface("HeartRateSample");
|
||||
addCommonAcivitySampleProperties(schema, activitySample, user, device);
|
||||
activitySample.addIntProperty("heartrate");
|
||||
activitySample.addIntProperty("heartRate");
|
||||
return activitySample;
|
||||
}
|
||||
|
||||
private static Entity addPebbleActivitySample(Schema schema, Entity user, Entity device) {
|
||||
// public GBActivitySample(SampleProvider provider, int timestamp, int intensity, int steps, int type, int customValue) {
|
||||
Entity activitySample = schema.addEntity("PebbleActivitySample");
|
||||
Entity activitySample = addEntity(schema, "PebbleActivitySample");
|
||||
addCommonAcivitySampleProperties(schema, activitySample, user, device);
|
||||
// activitySample.addIntProperty("heartrate").notNull();
|
||||
return activitySample;
|
||||
}
|
||||
|
||||
private static void addCommonAcivitySampleProperties(Schema schema, Entity activitySample, Entity user, Entity device) {
|
||||
activitySample.addImport(MODEL_PACKAGE + ".ActivitySample");
|
||||
activitySample.addImport(MAIN_PACKAGE + ".devices.SampleProvider");
|
||||
activitySample.implementsInterface("ActivitySample");
|
||||
activitySample.setJavaDoc(
|
||||
"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();
|
||||
activitySample.addIntProperty("intensity").notNull();
|
||||
activitySample.addIntProperty("rawIntensity").notNull();
|
||||
activitySample.addIntProperty("steps").notNull();
|
||||
activitySample.addIntProperty("type").notNull();
|
||||
activitySample.addIntProperty("rawKind").notNull();
|
||||
Property userId = activitySample.addLongProperty("userId").getProperty();
|
||||
activitySample.addToOne(user, userId);
|
||||
Property deviceId = activitySample.addLongProperty("deviceId").getProperty();
|
||||
activitySample.addToOne(device, deviceId);
|
||||
}
|
||||
|
||||
private static Entity addEntity(Schema schema, String className) {
|
||||
Entity entity = schema.addEntity(className);
|
||||
entity.addImport("de.greenrobot.dao.AbstractDao");
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
|
@ -2,45 +2,38 @@ package nodomain.freeyourgadget.gadgetbridge.model;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.SampleProvider;
|
||||
|
||||
public interface ActivitySample {
|
||||
/**
|
||||
* Returns the provider of the data.
|
||||
*
|
||||
* @return who created the sample data
|
||||
*/
|
||||
SampleProvider getProvider();
|
||||
|
||||
/**
|
||||
* Timestamp of the sample, resolution is seconds!
|
||||
*/
|
||||
int getTimestamp();
|
||||
public interface ActivitySample extends TimeStamped {
|
||||
// /**
|
||||
// * Returns the provider of the data.
|
||||
// *
|
||||
// * @return who created the sample data
|
||||
// */
|
||||
// SampleProvider getProvider();
|
||||
|
||||
/**
|
||||
* Returns the raw activity kind value as recorded by the SampleProvider
|
||||
*/
|
||||
int getRawKind();
|
||||
|
||||
/**
|
||||
* Returns the activity kind value as recorded by the SampleProvider
|
||||
*
|
||||
* @see ActivityKind
|
||||
*/
|
||||
int getKind();
|
||||
// /**
|
||||
// * Returns the activity kind value as recorded by the SampleProvider
|
||||
// *
|
||||
// * @see ActivityKind
|
||||
// */
|
||||
// int getKind();
|
||||
|
||||
/**
|
||||
* Returns the raw intensity value as recorded by the SampleProvider
|
||||
*/
|
||||
int getRawIntensity();
|
||||
|
||||
/**
|
||||
* Returns the normalized intensity value between 0 and 1
|
||||
*/
|
||||
float getIntensity();
|
||||
// /**
|
||||
// * Returns the normalized intensity value between 0 and 1
|
||||
// */
|
||||
// float getIntensity();
|
||||
|
||||
/**
|
||||
* Returns the number of steps performed during the period of this sample
|
||||
*/
|
||||
int getSteps();
|
||||
|
||||
int getCustomValue();
|
||||
}
|
||||
|
@ -0,0 +1,11 @@
|
||||
package nodomain.freeyourgadget.gadgetbridge.model;
|
||||
|
||||
public interface HeartRateSample extends TimeStamped {
|
||||
/**
|
||||
* Returns the heart rate measured at the corresponding timestamp.
|
||||
* The value is returned in heart beats per minute, in the range from
|
||||
* 0-255, where 255 is an illegal value (e.g. due to a bad measurement)
|
||||
* @return the heart rate value in beats per minute, or null if none
|
||||
*/
|
||||
Integer getHeartRate();
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
package nodomain.freeyourgadget.gadgetbridge.model;
|
||||
|
||||
public interface TimeStamped {
|
||||
/**
|
||||
* Timestamp of the sample, resolution is seconds!
|
||||
*/
|
||||
int getTimestamp();
|
||||
}
|
Loading…
Reference in New Issue
Block a user