Database revolution
- added in fitbitData an interface for keeping track of date - removed annoying IOException, now will write a LOG - same thing in sensor - fixed main and adapted to new Database system - Database now has Local or Remote (to implement)
This commit is contained in:
@@ -1,24 +0,0 @@
|
||||
package device.fitbitdata;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class Device {
|
||||
|
||||
public String lastSyncTime;
|
||||
|
||||
// @JsonProperty ("lastSyncTime")
|
||||
public String getLastSyncTime(List<Map<String,String>> sync){
|
||||
lastSyncTime = null;
|
||||
for(Map<String, String > d: sync) {
|
||||
String temp = d.get("lastSyncTime");
|
||||
if ((lastSyncTime == null) || (lastSyncTime.compareTo(temp) < 0))
|
||||
lastSyncTime = temp;
|
||||
}
|
||||
return lastSyncTime;
|
||||
}
|
||||
|
||||
}
|
||||
8
src/main/java/device/fitbitdata/FitbitData.java
Normal file
8
src/main/java/device/fitbitdata/FitbitData.java
Normal file
@@ -0,0 +1,8 @@
|
||||
package device.fitbitdata;
|
||||
|
||||
public abstract class FitbitData {
|
||||
private long millisec = 0;
|
||||
|
||||
public void setDate(long millisec) { this.millisec = millisec; }
|
||||
public long getDate() { return this.millisec; }
|
||||
}
|
||||
@@ -7,12 +7,10 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class HeartRate {
|
||||
public class HeartRate extends FitbitData {
|
||||
|
||||
private double average;
|
||||
|
||||
public double getAverage() { return average; }
|
||||
|
||||
@JsonProperty("activities-heart-intraday")
|
||||
public void setAverage(Map<String, Object> map) {
|
||||
List<Map> data = (List) map.get("dataset");
|
||||
@@ -25,4 +23,7 @@ public class HeartRate {
|
||||
if(data.size() == 0)
|
||||
average = 0;
|
||||
}
|
||||
|
||||
public void setAverage(double average) { this.average = average; }
|
||||
public double getAverage() { return average; }
|
||||
}
|
||||
|
||||
@@ -49,14 +49,12 @@ public class Sleep {
|
||||
}
|
||||
|
||||
public class SleepData {
|
||||
public final Timestamp start_date;
|
||||
public final long start_date;
|
||||
public final long duration;
|
||||
public final Timestamp end_date;
|
||||
|
||||
public SleepData(Date start_date, long duration) {
|
||||
this.start_date = new Timestamp(start_date.getTime());
|
||||
this.start_date = start_date.getTime();
|
||||
this.duration = duration;
|
||||
this.end_date = start_date!=null? new Timestamp(start_date.getTime() + duration):null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,9 +8,9 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class Steps {
|
||||
public class Steps extends FitbitData {
|
||||
|
||||
private int steps=0;
|
||||
private int steps = 0;
|
||||
|
||||
@JsonProperty("activities-steps")
|
||||
public void setSteps(Map<String, String>[] array) {
|
||||
@@ -22,7 +22,7 @@ public class Steps {
|
||||
if(map.get("dateTime").equals(strDate))
|
||||
steps = Integer.parseInt(map.get("value"));
|
||||
}
|
||||
|
||||
public int getSteps() { return steps; }
|
||||
|
||||
public void setSteps(int steps) { this.steps = steps; }
|
||||
public int getSteps() { return steps; }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user