Clean up assigning sourcePlugin, filtered properties.

This commit is contained in:
Johannes Mockenhaupt 2018-06-23 01:05:53 +02:00
parent 940d58fc79
commit 906cc8a76a
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1
6 changed files with 8 additions and 4 deletions

View file

@ -71,7 +71,7 @@ public class SourceDexcomG5Plugin extends PluginBase implements BgSourceInterfac
bgReading.date = json.getLong("m_time") * 1000L; bgReading.date = json.getLong("m_time") * 1000L;
bgReading.raw = 0; bgReading.raw = 0;
bgReading.filtered = true; bgReading.filtered = true;
bgReading.sourcePlugin = SourceDexcomG5Plugin.getPlugin().getName(); bgReading.sourcePlugin = getName();
boolean isNew = MainApp.getDbHelper().createIfNotExists(bgReading, getName()); boolean isNew = MainApp.getDbHelper().createIfNotExists(bgReading, getName());
if (isNew) { if (isNew) {
bgReadings.add(bgReading); bgReadings.add(bgReading);

View file

@ -46,7 +46,7 @@ public class SourceGlimpPlugin extends PluginBase implements BgSourceInterface {
bgReading.date = bundle.getLong("myTimestamp"); bgReading.date = bundle.getLong("myTimestamp");
bgReading.raw = 0; bgReading.raw = 0;
bgReading.filtered = false; bgReading.filtered = false;
bgReading.sourcePlugin = SourceGlimpPlugin.getPlugin().getName(); bgReading.sourcePlugin = getName();
boolean isNew = MainApp.getDbHelper().createIfNotExists(bgReading, getName()); boolean isNew = MainApp.getDbHelper().createIfNotExists(bgReading, getName());
return isNew ? Lists.newArrayList(bgReading) : Collections.emptyList(); return isNew ? Lists.newArrayList(bgReading) : Collections.emptyList();

View file

@ -65,7 +65,7 @@ public class SourceMM640gPlugin extends PluginBase implements BgSourceInterface
bgReading.date = json_object.getLong("date"); bgReading.date = json_object.getLong("date");
bgReading.raw = json_object.getDouble("sgv"); bgReading.raw = json_object.getDouble("sgv");
bgReading.filtered = true; bgReading.filtered = true;
bgReading.sourcePlugin = SourceMM640gPlugin.getPlugin().getName(); bgReading.sourcePlugin = getName();
boolean isNew = MainApp.getDbHelper().createIfNotExists(bgReading, getName()); boolean isNew = MainApp.getDbHelper().createIfNotExists(bgReading, getName());
if (isNew) { if (isNew) {

View file

@ -65,6 +65,8 @@ public class SourceNSClientPlugin extends PluginBase implements BgSourceInterfac
for (int i = 0; i < jsonArray.length(); i++) { for (int i = 0; i < jsonArray.length(); i++) {
JSONObject sgvJson = jsonArray.getJSONObject(i); JSONObject sgvJson = jsonArray.getJSONObject(i);
BgReading bgReading = new BgReading(new NSSgv(sgvJson)); BgReading bgReading = new BgReading(new NSSgv(sgvJson));
bgReading.filtered = false;
bgReading.sourcePlugin = getName();
boolean isNew = MainApp.getDbHelper().createIfNotExists(bgReading, "NS"); boolean isNew = MainApp.getDbHelper().createIfNotExists(bgReading, "NS");
if (isNew) { if (isNew) {
sgvs.add(bgReading); sgvs.add(bgReading);

View file

@ -66,6 +66,8 @@ public class SourcePoctechPlugin extends PluginBase implements BgSourceInterface
bgReading.direction = json.getString("direction"); bgReading.direction = json.getString("direction");
bgReading.date = json.getLong("date"); bgReading.date = json.getLong("date");
bgReading.raw = json.getDouble("raw"); bgReading.raw = json.getDouble("raw");
bgReading.filtered = false;
bgReading.sourcePlugin = getName();
if (JsonHelper.safeGetString(json, "utils", Constants.MGDL).equals("mmol/L")) if (JsonHelper.safeGetString(json, "utils", Constants.MGDL).equals("mmol/L"))
bgReading.value = bgReading.value * Constants.MMOLL_TO_MGDL; bgReading.value = bgReading.value * Constants.MMOLL_TO_MGDL;
boolean isNew = MainApp.getDbHelper().createIfNotExists(bgReading, getName()); boolean isNew = MainApp.getDbHelper().createIfNotExists(bgReading, getName());

View file

@ -47,8 +47,8 @@ public class SourceXdripPlugin extends PluginBase implements BgSourceInterface {
bgReading.direction = bundle.getString(Intents.EXTRA_BG_SLOPE_NAME); bgReading.direction = bundle.getString(Intents.EXTRA_BG_SLOPE_NAME);
bgReading.date = bundle.getLong(Intents.EXTRA_TIMESTAMP); bgReading.date = bundle.getLong(Intents.EXTRA_TIMESTAMP);
bgReading.raw = bundle.getDouble(Intents.EXTRA_RAW); bgReading.raw = bundle.getDouble(Intents.EXTRA_RAW);
bgReading.sourcePlugin = SourceXdripPlugin.getPlugin().getName();
bgReading.filtered = Objects.equals(bundle.getString(Intents.XDRIP_DATA_SOURCE_DESCRIPTION), "G5 Native"); bgReading.filtered = Objects.equals(bundle.getString(Intents.XDRIP_DATA_SOURCE_DESCRIPTION), "G5 Native");
bgReading.sourcePlugin = getName();
boolean isNew = MainApp.getDbHelper().createIfNotExists(bgReading, getName()); boolean isNew = MainApp.getDbHelper().createIfNotExists(bgReading, getName());
return isNew ? Lists.newArrayList(bgReading) : Collections.emptyList(); return isNew ? Lists.newArrayList(bgReading) : Collections.emptyList();