mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2026-07-28 22:34:25 +02:00
Merge pull request 'reduce DAO related merge conflicts for new devices' (#6294)
Reviewed-on: https://codeberg.org/Freeyourgadget/Gadgetbridge/pulls/6294
This commit is contained in:
+40
-16
@@ -52,6 +52,7 @@ public class GBDaoGenerator {
|
||||
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_ENERGY = "energy";
|
||||
private static final String SAMPLE_HEART_RATE = "heartRate";
|
||||
private static final String SAMPLE_HRV_WEEKLY_AVERAGE = "weeklyAverage";
|
||||
private static final String SAMPLE_HRV_LAST_NIGHT_AVERAGE = "lastNightAverage";
|
||||
@@ -61,6 +62,8 @@ public class GBDaoGenerator {
|
||||
private static final String SAMPLE_HRV_BASELINE_BALANCED_UPPER = "baselineBalancedUpper";
|
||||
private static final String SAMPLE_HRV_STATUS_NUM = "statusNum";
|
||||
private static final String SAMPLE_HRV_VALUE = "value";
|
||||
private static final String SAMPLE_RESPIRATORY_RATE = "respiratoryRate";
|
||||
private static final String SAMPLE_SLEEP_SCORE = "sleepScore";
|
||||
private static final String SAMPLE_SPO2 = "spo2";
|
||||
private static final String SAMPLE_STRESS = "stress";
|
||||
private static final String SAMPLE_TEMPERATURE = "temperature";
|
||||
@@ -76,7 +79,7 @@ public class GBDaoGenerator {
|
||||
outputDir.mkdirs();
|
||||
}
|
||||
|
||||
final Schema schema = new Schema(131, MAIN_PACKAGE + ".entities");
|
||||
final Schema schema = new Schema(132, MAIN_PACKAGE + ".entities");
|
||||
|
||||
final List<Entity> sampleProvidersToGenerate = new LinkedList<>();
|
||||
|
||||
@@ -243,6 +246,7 @@ public class GBDaoGenerator {
|
||||
|
||||
sampleProvidersToGenerate.add(addGenericHeartRateSample(schema, user, device));
|
||||
sampleProvidersToGenerate.add(addGenericSpo2Sample(schema, user, device));
|
||||
sampleProvidersToGenerate.add(addGenericRespiratoryRateSample(schema, user, device));
|
||||
sampleProvidersToGenerate.add(addGenericStressSample(schema, user, device));
|
||||
sampleProvidersToGenerate.add(addGenericHrvValueSample(schema, user, device));
|
||||
addGenericTemperatureSample(schema, user, device);
|
||||
@@ -252,6 +256,8 @@ public class GBDaoGenerator {
|
||||
sampleProvidersToGenerate.add(addGenericWeightSample(schema, user, device));
|
||||
sampleProvidersToGenerate.add(addGlucoseSample(schema, user, device));
|
||||
addGenericMetricsSample(schema, user, device);
|
||||
sampleProvidersToGenerate.add(addGenericSleepScoreSample(schema, user, device));
|
||||
sampleProvidersToGenerate.add(addGenericBodyEnergySample(schema, user, device));
|
||||
|
||||
deleteOldFiles();
|
||||
|
||||
@@ -679,9 +685,9 @@ public class GBDaoGenerator {
|
||||
|
||||
private static Entity addCmfSleepStageSample(Schema schema, Entity user, Entity device) {
|
||||
Entity sleepStageSample = addEntity(schema, "CmfSleepStageSample");
|
||||
addCommonTimeSampleProperties("AbstractTimeSample", sleepStageSample, user, device);
|
||||
sleepStageSample.addIntProperty("duration").notNull();
|
||||
sleepStageSample.addIntProperty("stage").notNull();
|
||||
addCommonTimeSampleProperties("AbstractSleepStageSample", sleepStageSample, user, device);
|
||||
sleepStageSample.addIntProperty("duration").notNull().codeBeforeGetter(OVERRIDE);
|
||||
sleepStageSample.addIntProperty("stage").notNull().codeBeforeGetter(OVERRIDE);
|
||||
return sleepStageSample;
|
||||
}
|
||||
|
||||
@@ -743,9 +749,9 @@ public class GBDaoGenerator {
|
||||
|
||||
private static Entity addColmiSleepStageSample(Schema schema, Entity user, Entity device) {
|
||||
Entity sleepStageSample = addEntity(schema, "ColmiSleepStageSample");
|
||||
addCommonTimeSampleProperties("AbstractTimeSample", sleepStageSample, user, device);
|
||||
sleepStageSample.addIntProperty("duration").notNull();
|
||||
sleepStageSample.addIntProperty("stage").notNull();
|
||||
addCommonTimeSampleProperties("AbstractSleepStageSample", sleepStageSample, user, device);
|
||||
sleepStageSample.addIntProperty("duration").notNull().codeBeforeGetter(OVERRIDE);
|
||||
sleepStageSample.addIntProperty("stage").notNull().codeBeforeGetter(OVERRIDE);
|
||||
return sleepStageSample;
|
||||
}
|
||||
|
||||
@@ -1092,10 +1098,8 @@ public class GBDaoGenerator {
|
||||
|
||||
private static Entity addGarminSleepStatsSample(Schema schema, Entity user, Entity device) {
|
||||
Entity sample = addEntity(schema, "GarminSleepStatsSample");
|
||||
sample.addImport(MAIN_PACKAGE + ".model.SleepScoreSample");
|
||||
addCommonTimeSampleProperties("AbstractTimeSample", sample, user, device);
|
||||
sample.implementsInterface("SleepScoreSample");
|
||||
sample.addIntProperty("sleepScore").notNull().codeBeforeGetter(OVERRIDE);
|
||||
addCommonTimeSampleProperties("AbstractSleepScoreSample", sample, user, device);
|
||||
sample.addIntProperty(SAMPLE_SLEEP_SCORE).notNull().codeBeforeGetter(OVERRIDE);
|
||||
return sample;
|
||||
}
|
||||
|
||||
@@ -2264,6 +2268,13 @@ public class GBDaoGenerator {
|
||||
return spo2sample;
|
||||
}
|
||||
|
||||
private static Entity addGenericRespiratoryRateSample(Schema schema, Entity user, Entity device) {
|
||||
Entity sample = addEntity(schema, "GenericRespiratoryRateSample");
|
||||
addCommonTimeSampleProperties("AbstractRespiratoryRateSample", sample, user, device);
|
||||
sample.addFloatProperty(SAMPLE_RESPIRATORY_RATE).notNull().codeBeforeGetter(OVERRIDE);
|
||||
return sample;
|
||||
}
|
||||
|
||||
private static Entity addGenericStressSample(Schema schema, Entity user, Entity device) {
|
||||
Entity stressSample = addEntity(schema, "GenericStressSample");
|
||||
addCommonTimeSampleProperties("AbstractStressSample", stressSample, user, device);
|
||||
@@ -2282,9 +2293,9 @@ public class GBDaoGenerator {
|
||||
|
||||
private static Entity addGenericSleepStageSample(Schema schema, Entity user, Entity device) {
|
||||
Entity sleepStageSample = addEntity(schema, "GenericSleepStageSample");
|
||||
addCommonTimeSampleProperties("AbstractTimeSample", sleepStageSample, user, device);
|
||||
sleepStageSample.addIntProperty("duration").notNull();
|
||||
sleepStageSample.addIntProperty("stage").notNull();
|
||||
addCommonTimeSampleProperties("AbstractSleepStageSample", sleepStageSample, user, device);
|
||||
sleepStageSample.addIntProperty("duration").notNull().codeBeforeGetter(OVERRIDE);
|
||||
sleepStageSample.addIntProperty("stage").notNull().codeBeforeGetter(OVERRIDE);
|
||||
return sleepStageSample;
|
||||
}
|
||||
|
||||
@@ -2329,8 +2340,7 @@ public class GBDaoGenerator {
|
||||
|
||||
private static Entity addGenericMetricsSample(Schema schema, Entity user, Entity device) {
|
||||
Entity sample = addEntity(schema, "GenericMetricSample");
|
||||
sample.implementsInterface(MAIN_PACKAGE + ".model.MetricSample");
|
||||
addCommonTimeSampleProperties("AbstractTimeSample", sample, user, device);
|
||||
addCommonTimeSampleProperties("AbstractMetricSample", sample, user, device);
|
||||
sample.addIntProperty("metricType").notNull().primaryKey().codeBeforeGetterAndSetter(OVERRIDE);
|
||||
sample.addDoubleProperty("metricScore").notNull().codeBeforeGetterAndSetter(OVERRIDE);
|
||||
sample.addLongProperty("metricExtra").codeBeforeGetterAndSetter(OVERRIDE);
|
||||
@@ -2338,6 +2348,20 @@ public class GBDaoGenerator {
|
||||
return sample;
|
||||
}
|
||||
|
||||
private static Entity addGenericSleepScoreSample(Schema schema, Entity user, Entity device) {
|
||||
Entity sample = addEntity(schema, "GenericSleepScoreSample");
|
||||
addCommonTimeSampleProperties("AbstractSleepScoreSample", sample, user, device);
|
||||
sample.addIntProperty(SAMPLE_SLEEP_SCORE).notNull().codeBeforeGetter(OVERRIDE);
|
||||
return sample;
|
||||
}
|
||||
|
||||
private static Entity addGenericBodyEnergySample(Schema schema, Entity user, Entity device) {
|
||||
Entity sample = addEntity(schema, "GenericBodyEnergySample");
|
||||
addCommonTimeSampleProperties("AbstractBodyEnergySample", sample, user, device);
|
||||
sample.addIntProperty(SAMPLE_ENERGY).notNull().codeBeforeGetter(OVERRIDE);
|
||||
return sample;
|
||||
}
|
||||
|
||||
private static final String SAMPLE_PROVIDER_TEMPLATE = """
|
||||
/* Copyright (C) 2026 Freeyourgadget
|
||||
|
||||
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
/* Copyright (C) 2026 Thomas Kuehne
|
||||
|
||||
This file is part of Gadgetbridge.
|
||||
|
||||
Gadgetbridge is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published
|
||||
by the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Gadgetbridge 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 Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
package nodomain.freeyourgadget.gadgetbridge.entities;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.HrvValueSample;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.MetricSample;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.DateTimeUtils;
|
||||
|
||||
public abstract class AbstractMetricSample extends AbstractTimeSample implements MetricSample {
|
||||
@NonNull
|
||||
@Override
|
||||
public String toString() {
|
||||
return getClass().getSimpleName() + "{" +
|
||||
"timestamp=" + DateTimeUtils.formatDateTime(DateTimeUtils.parseTimestampMillis(getTimestamp())) +
|
||||
", metric=" + getMetric() +
|
||||
", metricScore=" + getMetricScore() +
|
||||
", metricExtra=" + getMetricExtra() +
|
||||
", userId=" + getUserId() +
|
||||
", deviceId=" + getDeviceId() +
|
||||
"}";
|
||||
}
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
/* Copyright (C) 2026 Thomas Kuehne
|
||||
|
||||
This file is part of Gadgetbridge.
|
||||
|
||||
Gadgetbridge is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published
|
||||
by the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Gadgetbridge 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 Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
package nodomain.freeyourgadget.gadgetbridge.entities;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.SleepScoreSample;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.DateTimeUtils;
|
||||
|
||||
public abstract class AbstractSleepScoreSample extends AbstractTimeSample implements SleepScoreSample {
|
||||
@NonNull
|
||||
@Override
|
||||
public String toString() {
|
||||
return getClass().getSimpleName() + "{" +
|
||||
"timestamp=" + DateTimeUtils.formatDateTime(DateTimeUtils.parseTimestampMillis(getTimestamp())) +
|
||||
", sleepScore(=" + getSleepScore() +
|
||||
", userId=" + getUserId() +
|
||||
", deviceId=" + getDeviceId() +
|
||||
"}";
|
||||
}
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
/* Copyright (C) 2026 Thomas Kuehne
|
||||
|
||||
This file is part of Gadgetbridge.
|
||||
|
||||
Gadgetbridge is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published
|
||||
by the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Gadgetbridge 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 Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
package nodomain.freeyourgadget.gadgetbridge.entities;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.SleepScoreSample;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.SleepStageSample;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.DateTimeUtils;
|
||||
|
||||
public abstract class AbstractSleepStageSample extends AbstractTimeSample implements SleepStageSample {
|
||||
@NonNull
|
||||
@Override
|
||||
public String toString() {
|
||||
return getClass().getSimpleName() + "{" +
|
||||
"timestamp=" + DateTimeUtils.formatDateTime(DateTimeUtils.parseTimestampMillis(getTimestamp())) +
|
||||
", duration=" + getDuration() +
|
||||
", stage=" + getStage() +
|
||||
", userId=" + getUserId() +
|
||||
", deviceId=" + getDeviceId() +
|
||||
"}";
|
||||
}
|
||||
}
|
||||
@@ -57,11 +57,11 @@ public interface MetricSample extends TimeSample {
|
||||
setMetricExtra(extra);
|
||||
}
|
||||
|
||||
@IntRange(from = 0, to = 12)
|
||||
@IntRange(from = 0, to = 18)
|
||||
int getMetricType();
|
||||
|
||||
/// use {@link #setMetric(Metric)} or {@link #setMetric(Metric, Double, Long)} instead
|
||||
void setMetricType(@IntRange(from = 1, to = 12) int type);
|
||||
/// use {@link #setMetric(Metric)} or {@link #setMetric(Metric, double, Long)} instead
|
||||
void setMetricType(@IntRange(from = 1, to = 18) int type);
|
||||
|
||||
double getMetricScore();
|
||||
|
||||
@@ -109,13 +109,31 @@ public interface MetricSample extends TimeSample {
|
||||
GENERIC_RESTING_METABOLIC_RATE(11, UNIT_KCAL_PER_DAY),
|
||||
/// @see FitPhysiologicalMetrics#getMetMax()
|
||||
GENERIC_MAXIMUM_OXYGEN_UPTAKE(12, UNIT_ML_KG_MIN),
|
||||
/// Composite 0-100 sleep-quality score (Watson 2015 + Ohayon 2017).
|
||||
/// metricScore: 0-100. metricExtra: total sleep duration seconds.
|
||||
GENERIC_SLEEP_SCORE(13, UNIT_NONE),
|
||||
/// Composite 0-100 readiness/recovery score (sleep + RHR + HRV deviations).
|
||||
/// metricScore: 0-100. metricExtra: unused.
|
||||
GENERIC_READINESS(14, UNIT_NONE),
|
||||
/// Composite 0-100 daily energy / recovered-capacity score.
|
||||
/// metricScore: 0-100. metricExtra: unused.
|
||||
GENERIC_ENERGY(15, UNIT_NONE),
|
||||
/// Running 0-100 body-battery / energy-reserve metric.
|
||||
/// metricScore: 0-100. metricExtra: unused.
|
||||
GENERIC_BODY_BATTERY(16, UNIT_NONE),
|
||||
/// Edwards Training Impulse (TRIMP) — cumulative cardiac strain.
|
||||
/// metricScore: TRIMP units. metricExtra: unused.
|
||||
GENERIC_CARDIAC_STRAIN(17, UNIT_NONE),
|
||||
/// Sleep Regularity Index (Phillips 2017) — 0-100, higher = more regular.
|
||||
/// metricScore: 0-100. metricExtra: number of nights compared.
|
||||
GENERIC_SLEEP_REGULARITY(18, UNIT_NONE),
|
||||
;
|
||||
|
||||
final public int dbId;
|
||||
public final int dbId;
|
||||
|
||||
/// @see nodomain.freeyourgadget.gadgetbridge.model.ActivitySummaryEntries
|
||||
/// @see ActivitySummaryEntries
|
||||
@NonNull
|
||||
final public String uomKey;
|
||||
public final String uomKey;
|
||||
|
||||
Metric(int dbId, @NonNull String uomKey) {
|
||||
this.dbId = dbId;
|
||||
@@ -131,5 +149,9 @@ public interface MetricSample extends TimeSample {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public int getDbId() {
|
||||
return dbId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
/* Copyright (C) 2026 Thomas Kuehne
|
||||
|
||||
This file is part of Gadgetbridge.
|
||||
|
||||
Gadgetbridge is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published
|
||||
by the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Gadgetbridge 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 Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
package nodomain.freeyourgadget.gadgetbridge.model;
|
||||
|
||||
public interface SleepStageSample extends TimeSample {
|
||||
int getDuration();
|
||||
int getStage();
|
||||
}
|
||||
Reference in New Issue
Block a user