2020-05-09 10:52:20 +02:00
|
|
|
package info.nightscout.androidaps.db;
|
|
|
|
|
|
|
|
import com.j256.ormlite.dao.CloseableIterator;
|
|
|
|
|
|
|
|
import org.jetbrains.annotations.NotNull;
|
2020-08-28 01:18:32 +02:00
|
|
|
import org.jetbrains.annotations.Nullable;
|
2020-05-09 10:52:20 +02:00
|
|
|
|
|
|
|
import java.sql.SQLException;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import javax.inject.Inject;
|
|
|
|
import javax.inject.Singleton;
|
|
|
|
|
|
|
|
import info.nightscout.androidaps.MainApp;
|
|
|
|
import info.nightscout.androidaps.interfaces.DatabaseHelperInterface;
|
|
|
|
|
|
|
|
@Singleton
|
|
|
|
public class DatabaseHelperProvider implements DatabaseHelperInterface {
|
|
|
|
|
2020-08-17 19:53:43 +02:00
|
|
|
@Inject DatabaseHelperProvider() {
|
|
|
|
}
|
2020-05-09 10:52:20 +02:00
|
|
|
|
|
|
|
@NotNull @Override public List<BgReading> getAllBgreadingsDataFromTime(long mills, boolean ascending) {
|
|
|
|
return MainApp.getDbHelper().getAllBgreadingsDataFromTime(mills, ascending);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override public void createOrUpdate(@NotNull CareportalEvent careportalEvent) {
|
|
|
|
MainApp.getDbHelper().createOrUpdate(careportalEvent);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override public void createOrUpdate(@NotNull DanaRHistoryRecord record) {
|
|
|
|
MainApp.getDbHelper().createOrUpdate(record);
|
|
|
|
}
|
|
|
|
|
2020-08-17 19:53:43 +02:00
|
|
|
@Override public void createOrUpdate(@NotNull OmnipodHistoryRecord record) {
|
|
|
|
MainApp.getDbHelper().createOrUpdate(record);
|
|
|
|
}
|
|
|
|
|
2020-05-09 10:52:20 +02:00
|
|
|
@NotNull @Override public List<DanaRHistoryRecord> getDanaRHistoryRecordsByType(byte type) {
|
|
|
|
return MainApp.getDbHelper().getDanaRHistoryRecordsByType(type);
|
|
|
|
}
|
|
|
|
|
|
|
|
@NotNull @Override public List<TDD> getTDDs() {
|
|
|
|
return MainApp.getDbHelper().getTDDs();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override public long size(@NotNull String table) {
|
|
|
|
return MainApp.getDbHelper().size(table);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override public void create(@NotNull DbRequest record) {
|
|
|
|
try {
|
|
|
|
MainApp.getDbHelper().create(record);
|
|
|
|
} catch (SQLException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override public void deleteAllDbRequests() {
|
|
|
|
MainApp.getDbHelper().deleteAllDbRequests();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override public int deleteDbRequest(@NotNull String id) {
|
|
|
|
return MainApp.getDbHelper().deleteDbRequest(id);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override public void deleteDbRequestbyMongoId(@NotNull String action, @NotNull String _id) {
|
|
|
|
MainApp.getDbHelper().deleteDbRequestbyMongoId(action, _id);
|
|
|
|
}
|
|
|
|
|
|
|
|
@NotNull @Override public CloseableIterator<DbRequest> getDbRequestInterator() {
|
|
|
|
return MainApp.getDbHelper().getDbRequestInterator();
|
|
|
|
}
|
2020-05-12 14:33:47 +02:00
|
|
|
|
|
|
|
@Override public long roundDateToSec(long date) {
|
|
|
|
return MainApp.getDbHelper().roundDateToSec(date);
|
|
|
|
}
|
2020-07-12 21:15:11 +02:00
|
|
|
|
|
|
|
@Override public void createOrUpdateTDD(@NotNull TDD record) {
|
|
|
|
MainApp.getDbHelper().createOrUpdateTDD(record);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override public void createOrUpdate(@NotNull TemporaryBasal tempBasal) {
|
|
|
|
MainApp.getDbHelper().createOrUpdate(tempBasal);
|
|
|
|
}
|
|
|
|
|
|
|
|
@NotNull @Override public TemporaryBasal findTempBasalByPumpId(long id) {
|
|
|
|
return MainApp.getDbHelper().findTempBasalByPumpId(id);
|
|
|
|
}
|
|
|
|
|
|
|
|
@NotNull @Override public List<TemporaryBasal> getTemporaryBasalsDataFromTime(long mills, boolean ascending) {
|
|
|
|
return MainApp.getDbHelper().getTemporaryBasalsDataFromTime(mills, ascending);
|
|
|
|
}
|
|
|
|
|
2020-08-17 19:53:43 +02:00
|
|
|
@Override public CareportalEvent getCareportalEventFromTimestamp(long timestamp) {
|
2020-07-12 21:15:11 +02:00
|
|
|
return MainApp.getDbHelper().getCareportalEventFromTimestamp(timestamp);
|
|
|
|
}
|
|
|
|
|
2020-08-17 19:53:43 +02:00
|
|
|
@NotNull @Override public List<OmnipodHistoryRecord> getAllOmnipodHistoryRecordsFromTimestamp(long timestamp, boolean ascending) {
|
|
|
|
return MainApp.getDbHelper().getAllOmnipodHistoryRecordsFromTimeStamp(timestamp, ascending);
|
|
|
|
}
|
|
|
|
|
2020-08-28 01:18:32 +02:00
|
|
|
@Nullable @Override public OmnipodHistoryRecord findOmnipodHistoryRecordByPumpId(long pumpId) {
|
|
|
|
return MainApp.getDbHelper().findOmnipodHistoryRecordByPumpId(pumpId);
|
|
|
|
}
|
|
|
|
|
2020-07-12 21:15:11 +02:00
|
|
|
@NotNull @Override public List<TDD> getTDDsForLastXDays(int days) {
|
|
|
|
return MainApp.getDbHelper().getTDDsForLastXDays(days);
|
|
|
|
}
|
2020-07-12 21:21:03 +02:00
|
|
|
|
2020-06-22 22:55:50 +02:00
|
|
|
@NotNull @Override public List<ProfileSwitch> getProfileSwitchData(long from, boolean ascending) {
|
|
|
|
return MainApp.getDbHelper().getProfileSwitchData(from, ascending);
|
|
|
|
}
|
2020-07-12 21:21:03 +02:00
|
|
|
|
2020-05-09 10:52:20 +02:00
|
|
|
}
|