2016-03-27 22:13:06 +02:00
/ *
* Copyright ( C ) 2011 Markus Junginger , greenrobot ( http : //greenrobot.de)
*
* Licensed under the Apache License , Version 2 . 0 ( the " License " ) ;
* you may not use this file except in compliance with the License .
* You may obtain a copy of the License at
*
* http : //www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing , software
* distributed under the License is distributed on an " AS IS " BASIS ,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied .
* See the License for the specific language governing permissions and
* limitations under the License .
* /
package nodomain.freeyourgadget.gadgetbridge.daogen ;
import de.greenrobot.daogenerator.DaoGenerator ;
import de.greenrobot.daogenerator.Entity ;
2017-04-16 19:37:43 +02:00
import de.greenrobot.daogenerator.Index ;
2016-03-27 22:13:06 +02:00
import de.greenrobot.daogenerator.Property ;
import de.greenrobot.daogenerator.Schema ;
/ * *
* Generates entities and DAOs for the example project DaoExample .
* Automatically run during build .
* /
public class GBDaoGenerator {
2016-11-15 23:21:13 +01:00
private static final String VALID_FROM_UTC = " validFromUTC " ;
private static final String VALID_TO_UTC = " validToUTC " ;
2016-05-01 00:19:15 +02:00
private static final String MAIN_PACKAGE = " nodomain.freeyourgadget.gadgetbridge " ;
private static final String MODEL_PACKAGE = MAIN_PACKAGE + " .model " ;
2016-06-06 23:18:46 +02:00
private static final String VALID_BY_DATE = MODEL_PACKAGE + " .ValidByDate " ;
2017-10-19 21:52:38 +02:00
private static final String ACTIVITY_SUMMARY = MODEL_PACKAGE + " .ActivitySummary " ;
2016-08-27 21:17:34 +02:00
private static final String OVERRIDE = " @Override " ;
2016-11-15 23:21:13 +01:00
private static final String SAMPLE_RAW_INTENSITY = " rawIntensity " ;
private static final String SAMPLE_STEPS = " steps " ;
private static final String SAMPLE_RAW_KIND = " rawKind " ;
private static final String SAMPLE_HEART_RATE = " heartRate " ;
private static final String TIMESTAMP_FROM = " timestampFrom " ;
private static final String TIMESTAMP_TO = " timestampTo " ;
2016-03-27 22:13:06 +02:00
2017-04-16 19:37:43 +02:00
2016-03-27 22:13:06 +02:00
public static void main ( String [ ] args ) throws Exception {
2023-05-21 00:34:10 +02:00
final Schema schema = new Schema ( 47 , MAIN_PACKAGE + " .entities " ) ;
2016-03-27 22:13:06 +02:00
Entity userAttributes = addUserAttributes ( schema ) ;
Entity user = addUserInfo ( schema , userAttributes ) ;
Entity deviceAttributes = addDeviceAttributes ( schema ) ;
Entity device = addDevice ( schema , deviceAttributes ) ;
2016-11-27 09:49:28 +01:00
// yeah deep shit, has to be here (after device) for db upgrade and column order
// because addDevice adds a property to deviceAttributes also....
deviceAttributes . addStringProperty ( " volatileIdentifier " ) ;
2016-08-27 00:23:41 +02:00
Entity tag = addTag ( schema ) ;
Entity userDefinedActivityOverlay = addActivityDescription ( schema , tag , user ) ;
2016-03-27 22:13:06 +02:00
2019-10-03 11:52:46 +02:00
addMakibesHR3ActivitySample ( schema , user , device ) ;
2016-04-17 19:52:51 +02:00
addMiBandActivitySample ( schema , user , device ) ;
2022-09-10 15:22:46 +02:00
addHuamiExtendedActivitySample ( schema , user , device ) ;
2023-05-21 00:34:10 +02:00
addHuamiStressSample ( schema , user , device ) ;
addHuamiSpo2Sample ( schema , user , device ) ;
2016-07-30 23:22:27 +02:00
addPebbleHealthActivitySample ( schema , user , device ) ;
2016-08-08 09:01:36 +02:00
addPebbleHealthActivityKindOverlay ( schema , user , device ) ;
2016-07-25 22:19:39 +02:00
addPebbleMisfitActivitySample ( schema , user , device ) ;
2016-07-31 00:06:26 +02:00
addPebbleMorpheuzActivitySample ( schema , user , device ) ;
2017-01-02 01:58:37 +01:00
addHPlusHealthActivityKindOverlay ( schema , user , device ) ;
2016-12-21 13:51:25 +01:00
addHPlusHealthActivitySample ( schema , user , device ) ;
2017-09-03 20:08:31 +02:00
addNo1F1ActivitySample ( schema , user , device ) ;
2018-02-25 12:05:36 +01:00
addXWatchActivitySample ( schema , user , device ) ;
2018-06-27 09:01:26 +02:00
addZeTimeActivitySample ( schema , user , device ) ;
2018-07-29 18:49:45 +02:00
addID115ActivitySample ( schema , user , device ) ;
2018-09-27 00:05:40 +02:00
addJYouActivitySample ( schema , user , device ) ;
2019-10-27 18:04:38 +01:00
addWatchXPlusHealthActivitySample ( schema , user , device ) ;
2019-10-29 22:34:31 +01:00
addWatchXPlusHealthActivityKindOverlay ( schema , user , device ) ;
2020-07-01 18:54:31 +02:00
addTLW64ActivitySample ( schema , user , device ) ;
2020-10-05 11:13:22 +02:00
addLefunActivitySample ( schema , user , device ) ;
addLefunBiometricSample ( schema , user , device ) ;
addLefunSleepSample ( schema , user , device ) ;
2020-09-01 22:15:20 +02:00
addSonySWR12Sample ( schema , user , device ) ;
2020-12-04 16:14:00 +01:00
addBangleJSActivitySample ( schema , user , device ) ;
2020-12-20 00:22:35 +01:00
addCasioGBX100Sample ( schema , user , device ) ;
2021-09-21 16:37:19 +02:00
addFitProActivitySample ( schema , user , device ) ;
2021-12-11 21:19:05 +01:00
addPineTimeActivitySample ( schema , user , device ) ;
2016-03-27 22:13:06 +02:00
2020-04-20 00:11:45 +02:00
addHybridHRActivitySample ( schema , user , device ) ;
2017-04-16 19:37:43 +02:00
addCalendarSyncState ( schema , device ) ;
2018-11-24 12:16:47 +01:00
addAlarms ( schema , user , device ) ;
2021-12-04 16:55:09 +01:00
addReminders ( schema , user , device ) ;
2022-05-09 20:47:08 +02:00
addWorldClocks ( schema , user , device ) ;
2023-05-18 00:43:29 +02:00
addContacts ( schema , user , device ) ;
2017-04-16 19:37:43 +02:00
2018-12-03 09:45:43 +01:00
Entity notificationFilter = addNotificationFilters ( schema ) ;
addNotificationFilterEntry ( schema , notificationFilter ) ;
2020-08-07 23:12:29 +02:00
addActivitySummary ( schema , user , device ) ;
2021-01-31 11:10:03 +01:00
addBatteryLevel ( schema , device ) ;
2016-04-09 18:18:16 +02:00
new DaoGenerator ( ) . generateAll ( schema , " app/src/main/java " ) ;
2016-03-27 22:13:06 +02:00
}
2016-08-27 00:23:41 +02:00
private static Entity addTag ( Schema schema ) {
Entity tag = addEntity ( schema , " Tag " ) ;
tag . addIdProperty ( ) ;
tag . addStringProperty ( " name " ) . notNull ( ) ;
tag . addStringProperty ( " description " ) . javaDocGetterAndSetter ( " An optional description of this tag. " ) ;
2016-09-06 00:00:48 +02:00
tag . addLongProperty ( " userId " ) . notNull ( ) ;
2016-08-27 00:23:41 +02:00
return tag ;
}
private static Entity addActivityDescription ( Schema schema , Entity tag , Entity user ) {
Entity activityDesc = addEntity ( schema , " ActivityDescription " ) ;
activityDesc . setJavaDoc ( " A user may further specify his activity with a detailed description and the help of tags. \ nOne or more tags can be added to a given activity range. " ) ;
activityDesc . addIdProperty ( ) ;
2016-08-27 21:17:34 +02:00
activityDesc . addIntProperty ( TIMESTAMP_FROM ) . notNull ( ) ;
activityDesc . addIntProperty ( TIMESTAMP_TO ) . notNull ( ) ;
2016-08-27 00:23:41 +02:00
activityDesc . addStringProperty ( " details " ) . javaDocGetterAndSetter ( " An optional detailed description, specific to this very activity occurrence. " ) ;
Property userId = activityDesc . addLongProperty ( " userId " ) . notNull ( ) . getProperty ( ) ;
activityDesc . addToOne ( user , userId ) ;
Entity activityDescTagLink = addEntity ( schema , " ActivityDescTagLink " ) ;
activityDescTagLink . addIdProperty ( ) ;
Property sourceId = activityDescTagLink . addLongProperty ( " activityDescriptionId " ) . notNull ( ) . getProperty ( ) ;
Property targetId = activityDescTagLink . addLongProperty ( " tagId " ) . notNull ( ) . getProperty ( ) ;
activityDesc . addToMany ( tag , activityDescTagLink , sourceId , targetId ) ;
return activityDesc ;
2016-05-23 23:31:22 +02:00
}
2016-03-27 22:13:06 +02:00
private static Entity addUserInfo ( Schema schema , Entity userAttributes ) {
2016-05-01 00:19:15 +02:00
Entity user = addEntity ( schema , " User " ) ;
2016-03-27 22:13:06 +02:00
user . addIdProperty ( ) ;
user . addStringProperty ( " name " ) . notNull ( ) ;
user . addDateProperty ( " birthday " ) . notNull ( ) ;
2016-05-13 23:47:47 +02:00
user . addIntProperty ( " gender " ) . notNull ( ) ;
2016-03-27 22:13:06 +02:00
Property userId = userAttributes . addLongProperty ( " userId " ) . notNull ( ) . getProperty ( ) ;
2016-05-23 23:31:22 +02:00
// sorted by the from-date, newest first
Property userAttributesSortProperty = getPropertyByName ( userAttributes , VALID_FROM_UTC ) ;
user . addToMany ( userAttributes , userId ) . orderDesc ( userAttributesSortProperty ) ;
2016-03-27 22:13:06 +02:00
return user ;
}
2016-05-23 23:31:22 +02:00
private static Property getPropertyByName ( Entity entity , String propertyName ) {
for ( Property prop : entity . getProperties ( ) ) {
if ( propertyName . equals ( prop . getPropertyName ( ) ) ) {
return prop ;
}
}
throw new IllegalStateException ( " Could not find property " + propertyName + " in entity " + entity . getClassName ( ) ) ;
}
2016-03-27 22:13:06 +02:00
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
2016-05-01 00:19:15 +02:00
Entity userAttributes = addEntity ( schema , " UserAttributes " ) ;
2016-03-27 22:13:06 +02:00
userAttributes . addIdProperty ( ) ;
userAttributes . addIntProperty ( " heightCM " ) . notNull ( ) ;
userAttributes . addIntProperty ( " weightKG " ) . notNull ( ) ;
2016-08-24 22:54:32 +02:00
userAttributes . addIntProperty ( " sleepGoalHPD " ) . javaDocGetterAndSetter ( " Desired number of hours of sleep per day. " ) ;
userAttributes . addIntProperty ( " stepsGoalSPD " ) . javaDocGetterAndSetter ( " Desired number of steps per day. " ) ;
2016-06-06 23:18:46 +02:00
addDateValidityTo ( userAttributes ) ;
2016-03-27 22:13:06 +02:00
return userAttributes ;
}
2016-06-06 23:18:46 +02:00
private static void addDateValidityTo ( Entity entity ) {
2016-09-06 00:00:48 +02:00
entity . addDateProperty ( VALID_FROM_UTC ) . codeBeforeGetter ( OVERRIDE ) ;
entity . addDateProperty ( VALID_TO_UTC ) . codeBeforeGetter ( OVERRIDE ) ;
2016-06-06 23:18:46 +02:00
entity . implementsInterface ( VALID_BY_DATE ) ;
}
2016-03-27 22:13:06 +02:00
private static Entity addDevice ( Schema schema , Entity deviceAttributes ) {
2016-05-01 00:19:15 +02:00
Entity device = addEntity ( schema , " Device " ) ;
2016-03-27 22:13:06 +02:00
device . addIdProperty ( ) ;
device . addStringProperty ( " name " ) . notNull ( ) ;
device . addStringProperty ( " manufacturer " ) . notNull ( ) ;
2016-05-13 23:47:47 +02:00
device . addStringProperty ( " identifier " ) . notNull ( ) . unique ( ) . javaDocGetterAndSetter ( " The fixed identifier, i.e. MAC address of the device. " ) ;
2016-08-17 00:34:19 +02:00
device . addIntProperty ( " type " ) . notNull ( ) . javaDocGetterAndSetter ( " The DeviceType key, i.e. the GBDevice's type. " ) ;
2022-06-23 23:12:08 +02:00
device . addStringProperty ( " model " ) . javaDocGetterAndSetter ( " An optional model, further specifying the kind of device. " ) ;
2020-06-12 18:04:53 +02:00
device . addStringProperty ( " alias " ) ;
2022-06-23 23:12:08 +02:00
device . addStringProperty ( " parentFolder " ) . javaDocGetterAndSetter ( " Folder name containing this device. " ) ;
2016-03-27 22:13:06 +02:00
Property deviceId = deviceAttributes . addLongProperty ( " deviceId " ) . notNull ( ) . getProperty ( ) ;
2016-05-23 23:31:22 +02:00
// sorted by the from-date, newest first
Property deviceAttributesSortProperty = getPropertyByName ( deviceAttributes , VALID_FROM_UTC ) ;
device . addToMany ( deviceAttributes , deviceId ) . orderDesc ( deviceAttributesSortProperty ) ;
2016-03-27 22:13:06 +02:00
return device ;
}
private static Entity addDeviceAttributes ( Schema schema ) {
2016-05-01 00:19:15 +02:00
Entity deviceAttributes = addEntity ( schema , " DeviceAttributes " ) ;
2016-03-27 22:13:06 +02:00
deviceAttributes . addIdProperty ( ) ;
deviceAttributes . addStringProperty ( " firmwareVersion1 " ) . notNull ( ) ;
deviceAttributes . addStringProperty ( " firmwareVersion2 " ) ;
2016-06-06 23:18:46 +02:00
addDateValidityTo ( deviceAttributes ) ;
2016-03-27 22:13:06 +02:00
return deviceAttributes ;
}
2019-10-03 11:52:46 +02:00
private static Entity addMakibesHR3ActivitySample ( Schema schema , Entity user , Entity device ) {
Entity activitySample = addEntity ( schema , " MakibesHR3ActivitySample " ) ;
activitySample . implementsSerializable ( ) ;
addCommonActivitySampleProperties ( " AbstractActivitySample " , activitySample , user , device ) ;
activitySample . addIntProperty ( SAMPLE_STEPS ) . notNull ( ) . codeBeforeGetterAndSetter ( OVERRIDE ) ;
activitySample . addIntProperty ( SAMPLE_RAW_KIND ) . notNull ( ) . codeBeforeGetterAndSetter ( OVERRIDE ) ;
addHeartRateProperties ( activitySample ) ;
return activitySample ;
}
2016-04-17 19:52:51 +02:00
private static Entity addMiBandActivitySample ( Schema schema , Entity user , Entity device ) {
2016-05-01 00:19:15 +02:00
Entity activitySample = addEntity ( schema , " MiBandActivitySample " ) ;
2016-09-04 00:02:58 +02:00
activitySample . implementsSerializable ( ) ;
2016-07-25 22:19:39 +02:00
addCommonActivitySampleProperties ( " AbstractActivitySample " , activitySample , user , device ) ;
2016-08-27 21:17:34 +02:00
activitySample . addIntProperty ( SAMPLE_RAW_INTENSITY ) . notNull ( ) . codeBeforeGetterAndSetter ( OVERRIDE ) ;
activitySample . addIntProperty ( SAMPLE_STEPS ) . notNull ( ) . codeBeforeGetterAndSetter ( OVERRIDE ) ;
activitySample . addIntProperty ( SAMPLE_RAW_KIND ) . notNull ( ) . codeBeforeGetterAndSetter ( OVERRIDE ) ;
2016-05-13 23:47:47 +02:00
addHeartRateProperties ( activitySample ) ;
return activitySample ;
}
2022-09-10 15:22:46 +02:00
private static Entity addHuamiExtendedActivitySample ( Schema schema , Entity user , Entity device ) {
Entity activitySample = addEntity ( schema , " HuamiExtendedActivitySample " ) ;
addCommonActivitySampleProperties ( " MiBandActivitySample " , activitySample , user , device ) ;
activitySample . addIntProperty ( SAMPLE_RAW_INTENSITY ) . notNull ( ) . codeBeforeGetterAndSetter ( OVERRIDE ) ;
activitySample . addIntProperty ( SAMPLE_STEPS ) . notNull ( ) . codeBeforeGetterAndSetter ( OVERRIDE ) ;
activitySample . addIntProperty ( SAMPLE_RAW_KIND ) . notNull ( ) . codeBeforeGetterAndSetter ( OVERRIDE ) ;
addHeartRateProperties ( activitySample ) ;
activitySample . addIntProperty ( " unknown1 " ) ;
activitySample . addIntProperty ( " sleep " ) ;
activitySample . addIntProperty ( " deepSleep " ) ;
activitySample . addIntProperty ( " remSleep " ) ;
return activitySample ;
}
2023-05-21 00:34:10 +02:00
private static Entity addHuamiStressSample ( Schema schema , Entity user , Entity device ) {
Entity stressSample = addEntity ( schema , " HuamiStressSample " ) ;
addCommonTimeSampleProperties ( " AbstractStressSample " , stressSample , user , device ) ;
stressSample . addIntProperty ( " typeNum " ) . notNull ( ) . codeBeforeGetterAndSetter ( OVERRIDE ) ;
stressSample . addIntProperty ( " stress " ) . notNull ( ) . codeBeforeGetter ( OVERRIDE ) ;
return stressSample ;
}
private static Entity addHuamiSpo2Sample ( Schema schema , Entity user , Entity device ) {
Entity spo2sample = addEntity ( schema , " HuamiSpo2Sample " ) ;
addCommonTimeSampleProperties ( " AbstractSpo2Sample " , spo2sample , user , device ) ;
spo2sample . addIntProperty ( " typeNum " ) . notNull ( ) . codeBeforeGetterAndSetter ( OVERRIDE ) ;
spo2sample . addIntProperty ( " spo2 " ) . notNull ( ) . codeBeforeGetter ( OVERRIDE ) ;
return spo2sample ;
}
2016-05-13 23:47:47 +02:00
private static void addHeartRateProperties ( Entity activitySample ) {
2016-11-15 23:21:13 +01:00
activitySample . addIntProperty ( SAMPLE_HEART_RATE ) . notNull ( ) . codeBeforeGetterAndSetter ( OVERRIDE ) ;
2016-04-17 19:52:51 +02:00
}
2016-07-30 23:22:27 +02:00
private static Entity addPebbleHealthActivitySample ( Schema schema , Entity user , Entity device ) {
Entity activitySample = addEntity ( schema , " PebbleHealthActivitySample " ) ;
2016-08-10 23:06:07 +02:00
addCommonActivitySampleProperties ( " AbstractPebbleHealthActivitySample " , activitySample , user , device ) ;
2016-08-27 21:17:34 +02:00
activitySample . addByteArrayProperty ( " rawPebbleHealthData " ) . codeBeforeGetter ( OVERRIDE ) ;
activitySample . addIntProperty ( SAMPLE_RAW_INTENSITY ) . notNull ( ) . codeBeforeGetterAndSetter ( OVERRIDE ) ;
activitySample . addIntProperty ( SAMPLE_STEPS ) . notNull ( ) . codeBeforeGetterAndSetter ( OVERRIDE ) ;
2016-11-15 23:21:13 +01:00
addHeartRateProperties ( activitySample ) ;
2016-04-17 19:52:51 +02:00
return activitySample ;
}
2016-08-08 09:01:36 +02:00
private static Entity addPebbleHealthActivityKindOverlay ( Schema schema , Entity user , Entity device ) {
Entity activityOverlay = addEntity ( schema , " PebbleHealthActivityOverlay " ) ;
2016-08-27 21:17:34 +02:00
activityOverlay . addIntProperty ( TIMESTAMP_FROM ) . notNull ( ) . primaryKey ( ) ;
activityOverlay . addIntProperty ( TIMESTAMP_TO ) . notNull ( ) . primaryKey ( ) ;
activityOverlay . addIntProperty ( SAMPLE_RAW_KIND ) . notNull ( ) . primaryKey ( ) ;
2016-09-06 00:00:48 +02:00
Property deviceId = activityOverlay . addLongProperty ( " deviceId " ) . primaryKey ( ) . notNull ( ) . getProperty ( ) ;
2016-08-08 09:01:36 +02:00
activityOverlay . addToOne ( device , deviceId ) ;
2016-09-06 00:00:48 +02:00
Property userId = activityOverlay . addLongProperty ( " userId " ) . notNull ( ) . getProperty ( ) ;
2016-08-14 22:33:41 +02:00
activityOverlay . addToOne ( user , userId ) ;
2016-08-18 22:06:26 +02:00
activityOverlay . addByteArrayProperty ( " rawPebbleHealthData " ) ;
2016-08-10 23:26:25 +02:00
2016-08-08 09:01:36 +02:00
return activityOverlay ;
}
2016-07-25 22:19:39 +02:00
private static Entity addPebbleMisfitActivitySample ( Schema schema , Entity user , Entity device ) {
Entity activitySample = addEntity ( schema , " PebbleMisfitSample " ) ;
addCommonActivitySampleProperties ( " AbstractPebbleMisfitActivitySample " , activitySample , user , device ) ;
2016-08-27 21:17:34 +02:00
activitySample . addIntProperty ( " rawPebbleMisfitSample " ) . notNull ( ) . codeBeforeGetter ( OVERRIDE ) ;
2016-07-25 22:19:39 +02:00
return activitySample ;
}
2016-07-31 00:06:26 +02:00
private static Entity addPebbleMorpheuzActivitySample ( Schema schema , Entity user , Entity device ) {
Entity activitySample = addEntity ( schema , " PebbleMorpheuzSample " ) ;
2016-08-07 11:45:09 +02:00
addCommonActivitySampleProperties ( " AbstractPebbleMorpheuzActivitySample " , activitySample , user , device ) ;
2016-08-27 21:17:34 +02:00
activitySample . addIntProperty ( SAMPLE_RAW_INTENSITY ) . notNull ( ) . codeBeforeGetterAndSetter ( OVERRIDE ) ;
2016-07-31 00:06:26 +02:00
return activitySample ;
}
2016-12-21 13:51:25 +01:00
private static Entity addHPlusHealthActivitySample ( Schema schema , Entity user , Entity device ) {
Entity activitySample = addEntity ( schema , " HPlusHealthActivitySample " ) ;
2017-01-10 14:44:32 +01:00
activitySample . implementsSerializable ( ) ;
2016-12-21 13:51:25 +01:00
addCommonActivitySampleProperties ( " AbstractActivitySample " , activitySample , user , device ) ;
activitySample . addByteArrayProperty ( " rawHPlusHealthData " ) ;
2017-01-02 01:58:37 +01:00
activitySample . addIntProperty ( SAMPLE_RAW_KIND ) . notNull ( ) . primaryKey ( ) ;
2016-12-21 13:51:25 +01:00
activitySample . addIntProperty ( SAMPLE_RAW_INTENSITY ) . notNull ( ) . codeBeforeGetterAndSetter ( OVERRIDE ) ;
activitySample . addIntProperty ( SAMPLE_STEPS ) . notNull ( ) . codeBeforeGetterAndSetter ( OVERRIDE ) ;
addHeartRateProperties ( activitySample ) ;
2017-01-02 01:58:37 +01:00
activitySample . addIntProperty ( " distance " ) ;
activitySample . addIntProperty ( " calories " ) ;
2016-12-21 13:51:25 +01:00
return activitySample ;
}
2017-01-02 01:58:37 +01:00
private static Entity addHPlusHealthActivityKindOverlay ( Schema schema , Entity user , Entity device ) {
Entity activityOverlay = addEntity ( schema , " HPlusHealthActivityOverlay " ) ;
activityOverlay . addIntProperty ( TIMESTAMP_FROM ) . notNull ( ) . primaryKey ( ) ;
activityOverlay . addIntProperty ( TIMESTAMP_TO ) . notNull ( ) . primaryKey ( ) ;
activityOverlay . addIntProperty ( SAMPLE_RAW_KIND ) . notNull ( ) . primaryKey ( ) ;
Property deviceId = activityOverlay . addLongProperty ( " deviceId " ) . primaryKey ( ) . notNull ( ) . getProperty ( ) ;
activityOverlay . addToOne ( device , deviceId ) ;
Property userId = activityOverlay . addLongProperty ( " userId " ) . notNull ( ) . getProperty ( ) ;
activityOverlay . addToOne ( user , userId ) ;
activityOverlay . addByteArrayProperty ( " rawHPlusHealthData " ) ;
return activityOverlay ;
}
2017-09-03 20:08:31 +02:00
private static Entity addNo1F1ActivitySample ( Schema schema , Entity user , Entity device ) {
Entity activitySample = addEntity ( schema , " No1F1ActivitySample " ) ;
activitySample . implementsSerializable ( ) ;
addCommonActivitySampleProperties ( " AbstractActivitySample " , activitySample , user , device ) ;
activitySample . addIntProperty ( SAMPLE_STEPS ) . notNull ( ) . codeBeforeGetterAndSetter ( OVERRIDE ) ;
activitySample . addIntProperty ( SAMPLE_RAW_KIND ) . notNull ( ) . codeBeforeGetterAndSetter ( OVERRIDE ) ;
2017-09-04 13:05:41 +02:00
activitySample . addIntProperty ( SAMPLE_RAW_INTENSITY ) . notNull ( ) . codeBeforeGetterAndSetter ( OVERRIDE ) ;
2017-09-10 11:09:08 +02:00
addHeartRateProperties ( activitySample ) ;
2017-09-03 20:08:31 +02:00
return activitySample ;
}
2018-02-25 12:05:36 +01:00
private static Entity addXWatchActivitySample ( Schema schema , Entity user , Entity device ) {
Entity activitySample = addEntity ( schema , " XWatchActivitySample " ) ;
activitySample . implementsSerializable ( ) ;
addCommonActivitySampleProperties ( " AbstractActivitySample " , activitySample , user , device ) ;
activitySample . addIntProperty ( SAMPLE_STEPS ) . notNull ( ) . codeBeforeGetterAndSetter ( OVERRIDE ) ;
activitySample . addIntProperty ( SAMPLE_RAW_KIND ) . notNull ( ) . codeBeforeGetterAndSetter ( OVERRIDE ) ;
2018-06-29 10:43:11 +02:00
activitySample . addIntProperty ( SAMPLE_RAW_INTENSITY ) . notNull ( ) . codeBeforeGetterAndSetter ( OVERRIDE ) ;
addHeartRateProperties ( activitySample ) ;
return activitySample ;
}
2018-06-27 09:01:26 +02:00
private static Entity addZeTimeActivitySample ( Schema schema , Entity user , Entity device ) {
Entity activitySample = addEntity ( schema , " ZeTimeActivitySample " ) ;
activitySample . implementsSerializable ( ) ;
addCommonActivitySampleProperties ( " AbstractActivitySample " , activitySample , user , device ) ;
activitySample . addIntProperty ( SAMPLE_STEPS ) . notNull ( ) . codeBeforeGetterAndSetter ( OVERRIDE ) ;
activitySample . addIntProperty ( SAMPLE_RAW_KIND ) . notNull ( ) . codeBeforeGetterAndSetter ( OVERRIDE ) ;
activitySample . addIntProperty ( SAMPLE_RAW_INTENSITY ) . notNull ( ) . codeBeforeGetterAndSetter ( OVERRIDE ) ;
addHeartRateProperties ( activitySample ) ;
2018-07-06 21:59:30 +02:00
activitySample . addIntProperty ( " caloriesBurnt " ) ;
activitySample . addIntProperty ( " distanceMeters " ) ;
activitySample . addIntProperty ( " activeTimeMinutes " ) ;
2018-06-27 09:01:26 +02:00
return activitySample ;
}
2018-07-29 18:49:45 +02:00
private static Entity addID115ActivitySample ( Schema schema , Entity user , Entity device ) {
Entity activitySample = addEntity ( schema , " ID115ActivitySample " ) ;
activitySample . implementsSerializable ( ) ;
addCommonActivitySampleProperties ( " AbstractActivitySample " , activitySample , user , device ) ;
activitySample . addIntProperty ( SAMPLE_STEPS ) . notNull ( ) . codeBeforeGetterAndSetter ( OVERRIDE ) ;
activitySample . addIntProperty ( SAMPLE_RAW_KIND ) . notNull ( ) . codeBeforeGetterAndSetter ( OVERRIDE ) ;
activitySample . addIntProperty ( " caloriesBurnt " ) ;
activitySample . addIntProperty ( " distanceMeters " ) ;
activitySample . addIntProperty ( " activeTimeMinutes " ) ;
return activitySample ;
}
2018-09-27 00:05:40 +02:00
private static Entity addJYouActivitySample ( Schema schema , Entity user , Entity device ) {
Entity activitySample = addEntity ( schema , " JYouActivitySample " ) ;
activitySample . implementsSerializable ( ) ;
addCommonActivitySampleProperties ( " AbstractActivitySample " , activitySample , user , device ) ;
activitySample . addIntProperty ( SAMPLE_STEPS ) . notNull ( ) . codeBeforeGetterAndSetter ( OVERRIDE ) ;
activitySample . addIntProperty ( SAMPLE_RAW_KIND ) . notNull ( ) . codeBeforeGetterAndSetter ( OVERRIDE ) ;
activitySample . addIntProperty ( " caloriesBurnt " ) ;
activitySample . addIntProperty ( " distanceMeters " ) ;
activitySample . addIntProperty ( " activeTimeMinutes " ) ;
addHeartRateProperties ( activitySample ) ;
return activitySample ;
}
2020-04-20 00:11:45 +02:00
private static Entity addHybridHRActivitySample ( Schema schema , Entity user , Entity device ) {
Entity activitySample = addEntity ( schema , " HybridHRActivitySample " ) ;
activitySample . implementsSerializable ( ) ;
addCommonActivitySampleProperties ( " AbstractHybridHRActivitySample " , activitySample , user , device ) ;
activitySample . addIntProperty ( SAMPLE_STEPS ) . notNull ( ) . codeBeforeGetterAndSetter ( OVERRIDE ) ;
activitySample . addIntProperty ( " calories " ) . notNull ( ) ;
activitySample . addIntProperty ( " variability " ) . notNull ( ) ;
activitySample . addIntProperty ( " max_variability " ) . notNull ( ) ;
activitySample . addIntProperty ( " heartrate_quality " ) . notNull ( ) ;
activitySample . addBooleanProperty ( " active " ) . notNull ( ) ;
activitySample . addByteProperty ( " wear_type " ) . notNull ( ) ;
addHeartRateProperties ( activitySample ) ;
return activitySample ;
}
2019-10-27 18:04:38 +01:00
private static Entity addWatchXPlusHealthActivitySample ( Schema schema , Entity user , Entity device ) {
Entity activitySample = addEntity ( schema , " WatchXPlusActivitySample " ) ;
activitySample . implementsSerializable ( ) ;
addCommonActivitySampleProperties ( " AbstractActivitySample " , activitySample , user , device ) ;
activitySample . addByteArrayProperty ( " rawWatchXPlusHealthData " ) ;
activitySample . addIntProperty ( SAMPLE_RAW_KIND ) . notNull ( ) . primaryKey ( ) ;
2019-10-29 22:34:31 +01:00
activitySample . addIntProperty ( SAMPLE_RAW_INTENSITY ) . notNull ( ) . codeBeforeGetterAndSetter ( OVERRIDE ) ;
2019-10-27 18:04:38 +01:00
activitySample . addIntProperty ( SAMPLE_STEPS ) . notNull ( ) . codeBeforeGetterAndSetter ( OVERRIDE ) ;
addHeartRateProperties ( activitySample ) ;
activitySample . addIntProperty ( " distance " ) ;
activitySample . addIntProperty ( " calories " ) ;
return activitySample ;
}
2019-10-29 22:34:31 +01:00
private static Entity addWatchXPlusHealthActivityKindOverlay ( Schema schema , Entity user , Entity device ) {
Entity activityOverlay = addEntity ( schema , " WatchXPlusHealthActivityOverlay " ) ;
activityOverlay . addIntProperty ( TIMESTAMP_FROM ) . notNull ( ) . primaryKey ( ) ;
activityOverlay . addIntProperty ( TIMESTAMP_TO ) . notNull ( ) . primaryKey ( ) ;
activityOverlay . addIntProperty ( SAMPLE_RAW_KIND ) . notNull ( ) . primaryKey ( ) ;
Property deviceId = activityOverlay . addLongProperty ( " deviceId " ) . primaryKey ( ) . notNull ( ) . getProperty ( ) ;
activityOverlay . addToOne ( device , deviceId ) ;
Property userId = activityOverlay . addLongProperty ( " userId " ) . notNull ( ) . getProperty ( ) ;
activityOverlay . addToOne ( user , userId ) ;
activityOverlay . addByteArrayProperty ( " rawWatchXPlusHealthData " ) ;
return activityOverlay ;
}
2020-07-01 18:54:31 +02:00
private static Entity addTLW64ActivitySample ( Schema schema , Entity user , Entity device ) {
Entity activitySample = addEntity ( schema , " TLW64ActivitySample " ) ;
activitySample . implementsSerializable ( ) ;
addCommonActivitySampleProperties ( " AbstractActivitySample " , activitySample , user , device ) ;
activitySample . addIntProperty ( SAMPLE_STEPS ) . notNull ( ) . codeBeforeGetterAndSetter ( OVERRIDE ) ;
2020-09-01 22:15:20 +02:00
activitySample . addIntProperty ( SAMPLE_RAW_KIND ) . notNull ( ) . codeBeforeGetterAndSetter ( OVERRIDE ) ;
activitySample . addIntProperty ( SAMPLE_RAW_INTENSITY ) . notNull ( ) . codeBeforeGetterAndSetter ( OVERRIDE ) ;
return activitySample ;
}
private static Entity addSonySWR12Sample ( Schema schema , Entity user , Entity device ) {
Entity activitySample = addEntity ( schema , " SonySWR12Sample " ) ;
activitySample . implementsSerializable ( ) ;
addCommonActivitySampleProperties ( " AbstractActivitySample " , activitySample , user , device ) ;
addHeartRateProperties ( activitySample ) ;
activitySample . addIntProperty ( SAMPLE_STEPS ) . notNull ( ) . codeBeforeGetterAndSetter ( OVERRIDE ) ;
2020-07-01 18:54:31 +02:00
activitySample . addIntProperty ( SAMPLE_RAW_KIND ) . notNull ( ) . codeBeforeGetterAndSetter ( OVERRIDE ) ;
activitySample . addIntProperty ( SAMPLE_RAW_INTENSITY ) . notNull ( ) . codeBeforeGetterAndSetter ( OVERRIDE ) ;
return activitySample ;
}
2020-12-20 00:22:35 +01:00
private static Entity addCasioGBX100Sample ( Schema schema , Entity user , Entity device ) {
Entity activitySample = addEntity ( schema , " CasioGBX100ActivitySample " ) ;
activitySample . implementsSerializable ( ) ;
addCommonActivitySampleProperties ( " AbstractGBX100ActivitySample " , activitySample , user , device ) ;
activitySample . addIntProperty ( SAMPLE_RAW_KIND ) . notNull ( ) . codeBeforeGetterAndSetter ( OVERRIDE ) ;
activitySample . addIntProperty ( SAMPLE_STEPS ) . notNull ( ) . codeBeforeGetterAndSetter ( OVERRIDE ) ;
activitySample . addIntProperty ( " calories " ) . notNull ( ) ;
return activitySample ;
}
2020-10-05 11:13:22 +02:00
private static Entity addLefunActivitySample ( Schema schema , Entity user , Entity device ) {
Entity activitySample = addEntity ( schema , " LefunActivitySample " ) ;
activitySample . implementsSerializable ( ) ;
addCommonActivitySampleProperties ( " AbstractActivitySample " , activitySample , user , device ) ;
activitySample . addIntProperty ( SAMPLE_RAW_KIND ) . notNull ( ) . codeBeforeGetterAndSetter ( OVERRIDE ) ;
activitySample . addIntProperty ( SAMPLE_STEPS ) . notNull ( ) . codeBeforeGetterAndSetter ( OVERRIDE ) ;
activitySample . addIntProperty ( " distance " ) . notNull ( ) ;
activitySample . addIntProperty ( " calories " ) . notNull ( ) ;
addHeartRateProperties ( activitySample ) ;
return activitySample ;
}
private static Entity addLefunBiometricSample ( Schema schema , Entity user , Entity device ) {
Entity biometricSample = addEntity ( schema , " LefunBiometricSample " ) ;
biometricSample . implementsSerializable ( ) ;
biometricSample . addIntProperty ( " timestamp " ) . notNull ( ) . primaryKey ( ) ;
Property deviceId = biometricSample . addLongProperty ( " deviceId " ) . primaryKey ( ) . notNull ( ) . getProperty ( ) ;
biometricSample . addToOne ( device , deviceId ) ;
Property userId = biometricSample . addLongProperty ( " userId " ) . notNull ( ) . getProperty ( ) ;
biometricSample . addToOne ( user , userId ) ;
biometricSample . addIntProperty ( " type " ) . notNull ( ) ;
biometricSample . addIntProperty ( " value1 " ) . notNull ( ) ;
biometricSample . addIntProperty ( " value2 " ) ;
return biometricSample ;
}
private static Entity addLefunSleepSample ( Schema schema , Entity user , Entity device ) {
Entity sleepSample = addEntity ( schema , " LefunSleepSample " ) ;
sleepSample . implementsSerializable ( ) ;
sleepSample . addIntProperty ( " timestamp " ) . notNull ( ) . primaryKey ( ) ;
Property deviceId = sleepSample . addLongProperty ( " deviceId " ) . primaryKey ( ) . notNull ( ) . getProperty ( ) ;
sleepSample . addToOne ( device , deviceId ) ;
Property userId = sleepSample . addLongProperty ( " userId " ) . notNull ( ) . getProperty ( ) ;
sleepSample . addToOne ( user , userId ) ;
sleepSample . addIntProperty ( " type " ) . notNull ( ) ;
return sleepSample ;
}
2020-12-04 16:14:00 +01:00
private static Entity addBangleJSActivitySample ( Schema schema , Entity user , Entity device ) {
Entity activitySample = addEntity ( schema , " BangleJSActivitySample " ) ;
activitySample . implementsSerializable ( ) ;
addCommonActivitySampleProperties ( " AbstractActivitySample " , activitySample , user , device ) ;
activitySample . addIntProperty ( SAMPLE_STEPS ) . notNull ( ) . codeBeforeGetterAndSetter ( OVERRIDE ) ;
activitySample . addIntProperty ( SAMPLE_RAW_KIND ) . notNull ( ) . codeBeforeGetterAndSetter ( OVERRIDE ) ;
addHeartRateProperties ( activitySample ) ;
return activitySample ;
}
2016-07-25 22:19:39 +02:00
private static void addCommonActivitySampleProperties ( String superClass , Entity activitySample , Entity user , Entity device ) {
activitySample . setSuperclass ( superClass ) ;
2016-05-01 00:19:15 +02:00
activitySample . addImport ( MAIN_PACKAGE + " .devices.SampleProvider " ) ;
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}. " ) ;
2016-08-27 21:17:34 +02:00
activitySample . addIntProperty ( " timestamp " ) . notNull ( ) . codeBeforeGetterAndSetter ( OVERRIDE ) . primaryKey ( ) ;
2016-09-06 00:00:48 +02:00
Property deviceId = activitySample . addLongProperty ( " deviceId " ) . primaryKey ( ) . notNull ( ) . codeBeforeGetterAndSetter ( OVERRIDE ) . getProperty ( ) ;
2016-03-27 22:13:06 +02:00
activitySample . addToOne ( device , deviceId ) ;
2016-09-06 00:00:48 +02:00
Property userId = activitySample . addLongProperty ( " userId " ) . notNull ( ) . codeBeforeGetterAndSetter ( OVERRIDE ) . getProperty ( ) ;
2016-03-27 22:13:06 +02:00
activitySample . addToOne ( user , userId ) ;
}
2016-07-25 22:19:39 +02:00
2023-05-21 00:34:10 +02:00
private static void addCommonTimeSampleProperties ( String superClass , Entity timeSample , Entity user , Entity device ) {
timeSample . setSuperclass ( superClass ) ;
timeSample . addImport ( MAIN_PACKAGE + " .devices.TimeSampleProvider " ) ;
timeSample . setJavaDoc (
" This class represents a sample specific to the device. Values might be device specific, depending on the sample type. \ n " +
" Normalized values can be retrieved through the corresponding {@link TimeSampleProvider}. " ) ;
timeSample . addLongProperty ( " timestamp " ) . notNull ( ) . codeBeforeGetterAndSetter ( OVERRIDE ) . primaryKey ( ) ;
Property deviceId = timeSample . addLongProperty ( " deviceId " ) . primaryKey ( ) . notNull ( ) . codeBeforeGetterAndSetter ( OVERRIDE ) . getProperty ( ) ;
timeSample . addToOne ( device , deviceId ) ;
Property userId = timeSample . addLongProperty ( " userId " ) . notNull ( ) . codeBeforeGetterAndSetter ( OVERRIDE ) . getProperty ( ) ;
timeSample . addToOne ( user , userId ) ;
}
2017-04-16 19:37:43 +02:00
private static void addCalendarSyncState ( Schema schema , Entity device ) {
Entity calendarSyncState = addEntity ( schema , " CalendarSyncState " ) ;
2017-04-16 21:08:49 +02:00
calendarSyncState . addIdProperty ( ) ;
2017-04-16 19:37:43 +02:00
Property deviceId = calendarSyncState . addLongProperty ( " deviceId " ) . notNull ( ) . getProperty ( ) ;
Property calendarEntryId = calendarSyncState . addLongProperty ( " calendarEntryId " ) . notNull ( ) . getProperty ( ) ;
Index indexUnique = new Index ( ) ;
indexUnique . addProperty ( deviceId ) ;
indexUnique . addProperty ( calendarEntryId ) ;
indexUnique . makeUnique ( ) ;
calendarSyncState . addIndex ( indexUnique ) ;
calendarSyncState . addToOne ( device , deviceId ) ;
2017-04-19 14:52:07 +02:00
calendarSyncState . addIntProperty ( " hash " ) . notNull ( ) ;
2017-04-16 19:37:43 +02:00
}
2018-11-24 12:16:47 +01:00
private static void addAlarms ( Schema schema , Entity user , Entity device ) {
Entity alarm = addEntity ( schema , " Alarm " ) ;
2019-01-07 01:10:57 +01:00
alarm . implementsInterface ( " nodomain.freeyourgadget.gadgetbridge.model.Alarm " ) ;
2018-11-24 12:16:47 +01:00
Property deviceId = alarm . addLongProperty ( " deviceId " ) . notNull ( ) . getProperty ( ) ;
Property userId = alarm . addLongProperty ( " userId " ) . notNull ( ) . getProperty ( ) ;
Property position = alarm . addIntProperty ( " position " ) . notNull ( ) . getProperty ( ) ;
Index indexUnique = new Index ( ) ;
indexUnique . addProperty ( deviceId ) ;
indexUnique . addProperty ( userId ) ;
indexUnique . addProperty ( position ) ;
indexUnique . makeUnique ( ) ;
alarm . addIndex ( indexUnique ) ;
alarm . addBooleanProperty ( " enabled " ) . notNull ( ) ;
2019-01-07 01:10:57 +01:00
alarm . addBooleanProperty ( " smartWakeup " ) . notNull ( ) ;
2020-01-12 08:12:21 +01:00
alarm . addBooleanProperty ( " snooze " ) . notNull ( ) ;
2019-01-07 01:10:57 +01:00
alarm . addIntProperty ( " repetition " ) . notNull ( ) . codeBeforeGetter (
" public boolean isRepetitive() { return getRepetition() != ALARM_ONCE; } " +
2019-10-03 11:52:46 +02:00
" public boolean getRepetition(int dow) { return (this.repetition & dow) > 0; } "
2019-01-07 01:10:57 +01:00
) ;
2018-11-24 12:16:47 +01:00
alarm . addIntProperty ( " hour " ) . notNull ( ) ;
alarm . addIntProperty ( " minute " ) . notNull ( ) ;
2019-12-24 01:27:57 +01:00
alarm . addBooleanProperty ( " unused " ) . notNull ( ) ;
2020-04-24 00:31:04 +02:00
alarm . addStringProperty ( " title " ) ;
alarm . addStringProperty ( " description " ) ;
2018-11-24 12:16:47 +01:00
alarm . addToOne ( user , userId ) ;
alarm . addToOne ( device , deviceId ) ;
}
2021-12-04 16:55:09 +01:00
private static void addReminders ( Schema schema , Entity user , Entity device ) {
Entity reminder = addEntity ( schema , " Reminder " ) ;
reminder . implementsInterface ( " nodomain.freeyourgadget.gadgetbridge.model.Reminder " ) ;
Property deviceId = reminder . addLongProperty ( " deviceId " ) . notNull ( ) . getProperty ( ) ;
Property userId = reminder . addLongProperty ( " userId " ) . notNull ( ) . getProperty ( ) ;
Property reminderId = reminder . addStringProperty ( " reminderId " ) . notNull ( ) . primaryKey ( ) . getProperty ( ) ;
Index indexUnique = new Index ( ) ;
indexUnique . addProperty ( deviceId ) ;
indexUnique . addProperty ( userId ) ;
indexUnique . addProperty ( reminderId ) ;
indexUnique . makeUnique ( ) ;
reminder . addIndex ( indexUnique ) ;
reminder . addStringProperty ( " message " ) . notNull ( ) ;
reminder . addDateProperty ( " date " ) . notNull ( ) ;
reminder . addIntProperty ( " repetition " ) . notNull ( ) ;
reminder . addToOne ( user , userId ) ;
reminder . addToOne ( device , deviceId ) ;
}
2022-05-09 20:47:08 +02:00
private static void addWorldClocks ( Schema schema , Entity user , Entity device ) {
Entity worldClock = addEntity ( schema , " WorldClock " ) ;
worldClock . implementsInterface ( " nodomain.freeyourgadget.gadgetbridge.model.WorldClock " ) ;
Property deviceId = worldClock . addLongProperty ( " deviceId " ) . notNull ( ) . getProperty ( ) ;
Property userId = worldClock . addLongProperty ( " userId " ) . notNull ( ) . getProperty ( ) ;
Property worldClockId = worldClock . addStringProperty ( " worldClockId " ) . notNull ( ) . primaryKey ( ) . getProperty ( ) ;
Index indexUnique = new Index ( ) ;
indexUnique . addProperty ( deviceId ) ;
indexUnique . addProperty ( userId ) ;
indexUnique . addProperty ( worldClockId ) ;
indexUnique . makeUnique ( ) ;
worldClock . addIndex ( indexUnique ) ;
worldClock . addStringProperty ( " label " ) . notNull ( ) ;
2022-10-31 13:09:36 +01:00
worldClock . addBooleanProperty ( " enabled " ) ;
worldClock . addStringProperty ( " code " ) ;
2022-05-09 20:47:08 +02:00
worldClock . addStringProperty ( " timeZoneId " ) . notNull ( ) ;
worldClock . addToOne ( user , userId ) ;
worldClock . addToOne ( device , deviceId ) ;
}
2023-05-18 00:43:29 +02:00
private static void addContacts ( Schema schema , Entity user , Entity device ) {
Entity contact = addEntity ( schema , " Contact " ) ;
contact . implementsInterface ( " nodomain.freeyourgadget.gadgetbridge.model.Contact " ) ;
Property deviceId = contact . addLongProperty ( " deviceId " ) . notNull ( ) . getProperty ( ) ;
Property userId = contact . addLongProperty ( " userId " ) . notNull ( ) . getProperty ( ) ;
Property contactId = contact . addStringProperty ( " contactId " ) . notNull ( ) . primaryKey ( ) . getProperty ( ) ;
Index indexUnique = new Index ( ) ;
indexUnique . addProperty ( deviceId ) ;
indexUnique . addProperty ( userId ) ;
indexUnique . addProperty ( contactId ) ;
indexUnique . makeUnique ( ) ;
contact . addIndex ( indexUnique ) ;
contact . addStringProperty ( " name " ) . notNull ( ) ;
contact . addStringProperty ( " number " ) . notNull ( ) ;
contact . addToOne ( user , userId ) ;
contact . addToOne ( device , deviceId ) ;
}
2018-12-03 09:45:43 +01:00
private static void addNotificationFilterEntry ( Schema schema , Entity notificationFilterEntity ) {
Entity notificatonFilterEntry = addEntity ( schema , " NotificationFilterEntry " ) ;
notificatonFilterEntry . addIdProperty ( ) . autoincrement ( ) ;
Property notificationFilterId = notificatonFilterEntry . addLongProperty ( " notificationFilterId " ) . notNull ( ) . getProperty ( ) ;
notificatonFilterEntry . addStringProperty ( " notificationFilterContent " ) . notNull ( ) . getProperty ( ) ;
notificatonFilterEntry . addToOne ( notificationFilterEntity , notificationFilterId ) ;
}
private static Entity addNotificationFilters ( Schema schema ) {
Entity notificatonFilter = addEntity ( schema , " NotificationFilter " ) ;
Property appIdentifier = notificatonFilter . addStringProperty ( " appIdentifier " ) . notNull ( ) . getProperty ( ) ;
notificatonFilter . addIdProperty ( ) . autoincrement ( ) ;
Index indexUnique = new Index ( ) ;
indexUnique . addProperty ( appIdentifier ) ;
indexUnique . makeUnique ( ) ;
notificatonFilter . addIndex ( indexUnique ) ;
Property notificationFilterMode = notificatonFilter . addIntProperty ( " notificationFilterMode " ) . notNull ( ) . getProperty ( ) ;
Property notificationFilterSubMode = notificatonFilter . addIntProperty ( " notificationFilterSubMode " ) . notNull ( ) . getProperty ( ) ;
return notificatonFilter ;
}
2020-08-07 23:12:29 +02:00
private static void addActivitySummary ( Schema schema , Entity user , Entity device ) {
2017-10-19 21:52:38 +02:00
Entity summary = addEntity ( schema , " BaseActivitySummary " ) ;
summary . implementsInterface ( ACTIVITY_SUMMARY ) ;
summary . addIdProperty ( ) ;
summary . setJavaDoc (
" This class represents the summary of a user's activity event. I.e. a walk, hike, a bicycle tour, etc. " ) ;
summary . addStringProperty ( " name " ) . codeBeforeGetter ( OVERRIDE ) ;
summary . addDateProperty ( " startTime " ) . notNull ( ) . codeBeforeGetter ( OVERRIDE ) ;
summary . addDateProperty ( " endTime " ) . notNull ( ) . codeBeforeGetter ( OVERRIDE ) ;
summary . addIntProperty ( " activityKind " ) . notNull ( ) . codeBeforeGetter ( OVERRIDE ) ;
summary . addIntProperty ( " baseLongitude " ) . javaDocGetterAndSetter ( " Temporary, bip-specific " ) ;
summary . addIntProperty ( " baseLatitude " ) . javaDocGetterAndSetter ( " Temporary, bip-specific " ) ;
summary . addIntProperty ( " baseAltitude " ) . javaDocGetterAndSetter ( " Temporary, bip-specific " ) ;
summary . addStringProperty ( " gpxTrack " ) . codeBeforeGetter ( OVERRIDE ) ;
2022-09-18 13:19:23 +02:00
summary . addStringProperty ( " rawDetailsPath " ) ;
2017-10-19 21:52:38 +02:00
Property deviceId = summary . addLongProperty ( " deviceId " ) . notNull ( ) . codeBeforeGetter ( OVERRIDE ) . getProperty ( ) ;
summary . addToOne ( device , deviceId ) ;
Property userId = summary . addLongProperty ( " userId " ) . notNull ( ) . codeBeforeGetter ( OVERRIDE ) . getProperty ( ) ;
summary . addToOne ( user , userId ) ;
2020-08-07 23:12:29 +02:00
summary . addStringProperty ( " summaryData " ) ;
2020-08-16 22:50:03 +02:00
summary . addByteArrayProperty ( " rawSummaryData " ) ;
2017-10-19 21:52:38 +02:00
}
2016-07-28 22:12:20 +02:00
private static Property findProperty ( Entity entity , String propertyName ) {
for ( Property prop : entity . getProperties ( ) ) {
if ( propertyName . equals ( prop . getPropertyName ( ) ) ) {
return prop ;
}
}
throw new IllegalArgumentException ( " Property " + propertyName + " not found in Entity " + entity . getClassName ( ) ) ;
}
2016-05-01 00:19:15 +02:00
private static Entity addEntity ( Schema schema , String className ) {
Entity entity = schema . addEntity ( className ) ;
entity . addImport ( " de.greenrobot.dao.AbstractDao " ) ;
return entity ;
}
2021-01-31 11:10:03 +01:00
private static Entity addBatteryLevel ( Schema schema , Entity device ) {
Entity batteryLevel = addEntity ( schema , " BatteryLevel " ) ;
batteryLevel . implementsSerializable ( ) ;
batteryLevel . addIntProperty ( " timestamp " ) . notNull ( ) . primaryKey ( ) ;
Property deviceId = batteryLevel . addLongProperty ( " deviceId " ) . primaryKey ( ) . notNull ( ) . getProperty ( ) ;
batteryLevel . addToOne ( device , deviceId ) ;
batteryLevel . addIntProperty ( " level " ) . notNull ( ) ;
2021-10-16 22:40:30 +02:00
batteryLevel . addIntProperty ( " batteryIndex " ) . notNull ( ) . primaryKey ( ) ; ;
2021-01-31 11:10:03 +01:00
return batteryLevel ;
}
2021-09-21 16:37:19 +02:00
private static Entity addFitProActivitySample ( Schema schema , Entity user , Entity device ) {
Entity activitySample = addEntity ( schema , " FitProActivitySample " ) ;
activitySample . implementsSerializable ( ) ;
addCommonActivitySampleProperties ( " AbstractFitProActivitySample " , activitySample , user , device ) ;
activitySample . addIntProperty ( SAMPLE_STEPS ) . notNull ( ) . codeBeforeGetterAndSetter ( OVERRIDE ) ;
activitySample . addIntProperty ( SAMPLE_RAW_KIND ) . notNull ( ) . codeBeforeGetterAndSetter ( OVERRIDE ) ;
addHeartRateProperties ( activitySample ) ;
activitySample . addIntProperty ( " caloriesBurnt " ) ;
activitySample . addIntProperty ( " distanceMeters " ) ;
activitySample . addIntProperty ( " spo2Percent " ) ;
activitySample . addIntProperty ( " pressureLowMmHg " ) ;
activitySample . addIntProperty ( " pressureHighMmHg " ) ;
activitySample . addIntProperty ( " activeTimeMinutes " ) ;
return activitySample ;
}
2021-12-11 21:19:05 +01:00
private static Entity addPineTimeActivitySample ( Schema schema , Entity user , Entity device ) {
Entity activitySample = addEntity ( schema , " PineTimeActivitySample " ) ;
activitySample . implementsSerializable ( ) ;
addCommonActivitySampleProperties ( " AbstractActivitySample " , activitySample , user , device ) ;
activitySample . addIntProperty ( SAMPLE_RAW_KIND ) . notNull ( ) . codeBeforeGetterAndSetter ( OVERRIDE ) ;
activitySample . addIntProperty ( SAMPLE_STEPS ) . notNull ( ) . codeBeforeGetterAndSetter ( OVERRIDE ) ;
addHeartRateProperties ( activitySample ) ;
return activitySample ;
}
2016-03-27 22:13:06 +02:00
}