251 lines
12 KiB
Plaintext
251 lines
12 KiB
Plaintext
package com.example.cuida.data;
|
|
|
|
import androidx.annotation.NonNull;
|
|
import androidx.room.DatabaseConfiguration;
|
|
import androidx.room.InvalidationTracker;
|
|
import androidx.room.RoomDatabase;
|
|
import androidx.room.RoomOpenHelper;
|
|
import androidx.room.migration.AutoMigrationSpec;
|
|
import androidx.room.migration.Migration;
|
|
import androidx.room.util.DBUtil;
|
|
import androidx.room.util.TableInfo;
|
|
import androidx.sqlite.db.SupportSQLiteDatabase;
|
|
import androidx.sqlite.db.SupportSQLiteOpenHelper;
|
|
import com.example.cuida.data.dao.AppointmentDao;
|
|
import com.example.cuida.data.dao.AppointmentDao_Impl;
|
|
import com.example.cuida.data.dao.MedicationDao;
|
|
import com.example.cuida.data.dao.MedicationDao_Impl;
|
|
import com.example.cuida.data.dao.UserDao;
|
|
import com.example.cuida.data.dao.UserDao_Impl;
|
|
import java.lang.Class;
|
|
import java.lang.Override;
|
|
import java.lang.String;
|
|
import java.lang.SuppressWarnings;
|
|
import java.util.ArrayList;
|
|
import java.util.HashMap;
|
|
import java.util.HashSet;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Set;
|
|
|
|
@SuppressWarnings({"unchecked", "deprecation"})
|
|
public final class AppDatabase_Impl extends AppDatabase {
|
|
private volatile UserDao _userDao;
|
|
|
|
private volatile AppointmentDao _appointmentDao;
|
|
|
|
private volatile MedicationDao _medicationDao;
|
|
|
|
@Override
|
|
@NonNull
|
|
protected SupportSQLiteOpenHelper createOpenHelper(@NonNull final DatabaseConfiguration config) {
|
|
final SupportSQLiteOpenHelper.Callback _openCallback = new RoomOpenHelper(config, new RoomOpenHelper.Delegate(3) {
|
|
@Override
|
|
public void createAllTables(@NonNull final SupportSQLiteDatabase db) {
|
|
db.execSQL("CREATE TABLE IF NOT EXISTS `users` (`uid` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `name` TEXT, `email` TEXT, `password` TEXT, `age` INTEGER NOT NULL, `utenteNumber` TEXT, `profilePictureUri` TEXT)");
|
|
db.execSQL("CREATE TABLE IF NOT EXISTS `appointments` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `type` TEXT, `date` TEXT, `time` TEXT, `reason` TEXT, `isPast` INTEGER NOT NULL)");
|
|
db.execSQL("CREATE TABLE IF NOT EXISTS `medications` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `name` TEXT, `time` TEXT, `dosage` TEXT, `notes` TEXT, `isTaken` INTEGER NOT NULL)");
|
|
db.execSQL("CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)");
|
|
db.execSQL("INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '2bfd7144258edb6d96f828b5b036c580')");
|
|
}
|
|
|
|
@Override
|
|
public void dropAllTables(@NonNull final SupportSQLiteDatabase db) {
|
|
db.execSQL("DROP TABLE IF EXISTS `users`");
|
|
db.execSQL("DROP TABLE IF EXISTS `appointments`");
|
|
db.execSQL("DROP TABLE IF EXISTS `medications`");
|
|
final List<? extends RoomDatabase.Callback> _callbacks = mCallbacks;
|
|
if (_callbacks != null) {
|
|
for (RoomDatabase.Callback _callback : _callbacks) {
|
|
_callback.onDestructiveMigration(db);
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void onCreate(@NonNull final SupportSQLiteDatabase db) {
|
|
final List<? extends RoomDatabase.Callback> _callbacks = mCallbacks;
|
|
if (_callbacks != null) {
|
|
for (RoomDatabase.Callback _callback : _callbacks) {
|
|
_callback.onCreate(db);
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void onOpen(@NonNull final SupportSQLiteDatabase db) {
|
|
mDatabase = db;
|
|
internalInitInvalidationTracker(db);
|
|
final List<? extends RoomDatabase.Callback> _callbacks = mCallbacks;
|
|
if (_callbacks != null) {
|
|
for (RoomDatabase.Callback _callback : _callbacks) {
|
|
_callback.onOpen(db);
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void onPreMigrate(@NonNull final SupportSQLiteDatabase db) {
|
|
DBUtil.dropFtsSyncTriggers(db);
|
|
}
|
|
|
|
@Override
|
|
public void onPostMigrate(@NonNull final SupportSQLiteDatabase db) {
|
|
}
|
|
|
|
@Override
|
|
@NonNull
|
|
public RoomOpenHelper.ValidationResult onValidateSchema(
|
|
@NonNull final SupportSQLiteDatabase db) {
|
|
final HashMap<String, TableInfo.Column> _columnsUsers = new HashMap<String, TableInfo.Column>(7);
|
|
_columnsUsers.put("uid", new TableInfo.Column("uid", "INTEGER", true, 1, null, TableInfo.CREATED_FROM_ENTITY));
|
|
_columnsUsers.put("name", new TableInfo.Column("name", "TEXT", false, 0, null, TableInfo.CREATED_FROM_ENTITY));
|
|
_columnsUsers.put("email", new TableInfo.Column("email", "TEXT", false, 0, null, TableInfo.CREATED_FROM_ENTITY));
|
|
_columnsUsers.put("password", new TableInfo.Column("password", "TEXT", false, 0, null, TableInfo.CREATED_FROM_ENTITY));
|
|
_columnsUsers.put("age", new TableInfo.Column("age", "INTEGER", true, 0, null, TableInfo.CREATED_FROM_ENTITY));
|
|
_columnsUsers.put("utenteNumber", new TableInfo.Column("utenteNumber", "TEXT", false, 0, null, TableInfo.CREATED_FROM_ENTITY));
|
|
_columnsUsers.put("profilePictureUri", new TableInfo.Column("profilePictureUri", "TEXT", false, 0, null, TableInfo.CREATED_FROM_ENTITY));
|
|
final HashSet<TableInfo.ForeignKey> _foreignKeysUsers = new HashSet<TableInfo.ForeignKey>(0);
|
|
final HashSet<TableInfo.Index> _indicesUsers = new HashSet<TableInfo.Index>(0);
|
|
final TableInfo _infoUsers = new TableInfo("users", _columnsUsers, _foreignKeysUsers, _indicesUsers);
|
|
final TableInfo _existingUsers = TableInfo.read(db, "users");
|
|
if (!_infoUsers.equals(_existingUsers)) {
|
|
return new RoomOpenHelper.ValidationResult(false, "users(com.example.cuida.data.model.User).\n"
|
|
+ " Expected:\n" + _infoUsers + "\n"
|
|
+ " Found:\n" + _existingUsers);
|
|
}
|
|
final HashMap<String, TableInfo.Column> _columnsAppointments = new HashMap<String, TableInfo.Column>(6);
|
|
_columnsAppointments.put("id", new TableInfo.Column("id", "INTEGER", true, 1, null, TableInfo.CREATED_FROM_ENTITY));
|
|
_columnsAppointments.put("type", new TableInfo.Column("type", "TEXT", false, 0, null, TableInfo.CREATED_FROM_ENTITY));
|
|
_columnsAppointments.put("date", new TableInfo.Column("date", "TEXT", false, 0, null, TableInfo.CREATED_FROM_ENTITY));
|
|
_columnsAppointments.put("time", new TableInfo.Column("time", "TEXT", false, 0, null, TableInfo.CREATED_FROM_ENTITY));
|
|
_columnsAppointments.put("reason", new TableInfo.Column("reason", "TEXT", false, 0, null, TableInfo.CREATED_FROM_ENTITY));
|
|
_columnsAppointments.put("isPast", new TableInfo.Column("isPast", "INTEGER", true, 0, null, TableInfo.CREATED_FROM_ENTITY));
|
|
final HashSet<TableInfo.ForeignKey> _foreignKeysAppointments = new HashSet<TableInfo.ForeignKey>(0);
|
|
final HashSet<TableInfo.Index> _indicesAppointments = new HashSet<TableInfo.Index>(0);
|
|
final TableInfo _infoAppointments = new TableInfo("appointments", _columnsAppointments, _foreignKeysAppointments, _indicesAppointments);
|
|
final TableInfo _existingAppointments = TableInfo.read(db, "appointments");
|
|
if (!_infoAppointments.equals(_existingAppointments)) {
|
|
return new RoomOpenHelper.ValidationResult(false, "appointments(com.example.cuida.data.model.Appointment).\n"
|
|
+ " Expected:\n" + _infoAppointments + "\n"
|
|
+ " Found:\n" + _existingAppointments);
|
|
}
|
|
final HashMap<String, TableInfo.Column> _columnsMedications = new HashMap<String, TableInfo.Column>(6);
|
|
_columnsMedications.put("id", new TableInfo.Column("id", "INTEGER", true, 1, null, TableInfo.CREATED_FROM_ENTITY));
|
|
_columnsMedications.put("name", new TableInfo.Column("name", "TEXT", false, 0, null, TableInfo.CREATED_FROM_ENTITY));
|
|
_columnsMedications.put("time", new TableInfo.Column("time", "TEXT", false, 0, null, TableInfo.CREATED_FROM_ENTITY));
|
|
_columnsMedications.put("dosage", new TableInfo.Column("dosage", "TEXT", false, 0, null, TableInfo.CREATED_FROM_ENTITY));
|
|
_columnsMedications.put("notes", new TableInfo.Column("notes", "TEXT", false, 0, null, TableInfo.CREATED_FROM_ENTITY));
|
|
_columnsMedications.put("isTaken", new TableInfo.Column("isTaken", "INTEGER", true, 0, null, TableInfo.CREATED_FROM_ENTITY));
|
|
final HashSet<TableInfo.ForeignKey> _foreignKeysMedications = new HashSet<TableInfo.ForeignKey>(0);
|
|
final HashSet<TableInfo.Index> _indicesMedications = new HashSet<TableInfo.Index>(0);
|
|
final TableInfo _infoMedications = new TableInfo("medications", _columnsMedications, _foreignKeysMedications, _indicesMedications);
|
|
final TableInfo _existingMedications = TableInfo.read(db, "medications");
|
|
if (!_infoMedications.equals(_existingMedications)) {
|
|
return new RoomOpenHelper.ValidationResult(false, "medications(com.example.cuida.data.model.Medication).\n"
|
|
+ " Expected:\n" + _infoMedications + "\n"
|
|
+ " Found:\n" + _existingMedications);
|
|
}
|
|
return new RoomOpenHelper.ValidationResult(true, null);
|
|
}
|
|
}, "2bfd7144258edb6d96f828b5b036c580", "54396701591a8f38f350a20a4d12755d");
|
|
final SupportSQLiteOpenHelper.Configuration _sqliteConfig = SupportSQLiteOpenHelper.Configuration.builder(config.context).name(config.name).callback(_openCallback).build();
|
|
final SupportSQLiteOpenHelper _helper = config.sqliteOpenHelperFactory.create(_sqliteConfig);
|
|
return _helper;
|
|
}
|
|
|
|
@Override
|
|
@NonNull
|
|
protected InvalidationTracker createInvalidationTracker() {
|
|
final HashMap<String, String> _shadowTablesMap = new HashMap<String, String>(0);
|
|
final HashMap<String, Set<String>> _viewTables = new HashMap<String, Set<String>>(0);
|
|
return new InvalidationTracker(this, _shadowTablesMap, _viewTables, "users","appointments","medications");
|
|
}
|
|
|
|
@Override
|
|
public void clearAllTables() {
|
|
super.assertNotMainThread();
|
|
final SupportSQLiteDatabase _db = super.getOpenHelper().getWritableDatabase();
|
|
try {
|
|
super.beginTransaction();
|
|
_db.execSQL("DELETE FROM `users`");
|
|
_db.execSQL("DELETE FROM `appointments`");
|
|
_db.execSQL("DELETE FROM `medications`");
|
|
super.setTransactionSuccessful();
|
|
} finally {
|
|
super.endTransaction();
|
|
_db.query("PRAGMA wal_checkpoint(FULL)").close();
|
|
if (!_db.inTransaction()) {
|
|
_db.execSQL("VACUUM");
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override
|
|
@NonNull
|
|
protected Map<Class<?>, List<Class<?>>> getRequiredTypeConverters() {
|
|
final HashMap<Class<?>, List<Class<?>>> _typeConvertersMap = new HashMap<Class<?>, List<Class<?>>>();
|
|
_typeConvertersMap.put(UserDao.class, UserDao_Impl.getRequiredConverters());
|
|
_typeConvertersMap.put(AppointmentDao.class, AppointmentDao_Impl.getRequiredConverters());
|
|
_typeConvertersMap.put(MedicationDao.class, MedicationDao_Impl.getRequiredConverters());
|
|
return _typeConvertersMap;
|
|
}
|
|
|
|
@Override
|
|
@NonNull
|
|
public Set<Class<? extends AutoMigrationSpec>> getRequiredAutoMigrationSpecs() {
|
|
final HashSet<Class<? extends AutoMigrationSpec>> _autoMigrationSpecsSet = new HashSet<Class<? extends AutoMigrationSpec>>();
|
|
return _autoMigrationSpecsSet;
|
|
}
|
|
|
|
@Override
|
|
@NonNull
|
|
public List<Migration> getAutoMigrations(
|
|
@NonNull final Map<Class<? extends AutoMigrationSpec>, AutoMigrationSpec> autoMigrationSpecs) {
|
|
final List<Migration> _autoMigrations = new ArrayList<Migration>();
|
|
return _autoMigrations;
|
|
}
|
|
|
|
@Override
|
|
public UserDao userDao() {
|
|
if (_userDao != null) {
|
|
return _userDao;
|
|
} else {
|
|
synchronized(this) {
|
|
if(_userDao == null) {
|
|
_userDao = new UserDao_Impl(this);
|
|
}
|
|
return _userDao;
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public AppointmentDao appointmentDao() {
|
|
if (_appointmentDao != null) {
|
|
return _appointmentDao;
|
|
} else {
|
|
synchronized(this) {
|
|
if(_appointmentDao == null) {
|
|
_appointmentDao = new AppointmentDao_Impl(this);
|
|
}
|
|
return _appointmentDao;
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public MedicationDao medicationDao() {
|
|
if (_medicationDao != null) {
|
|
return _medicationDao;
|
|
} else {
|
|
synchronized(this) {
|
|
if(_medicationDao == null) {
|
|
_medicationDao = new MedicationDao_Impl(this);
|
|
}
|
|
return _medicationDao;
|
|
}
|
|
}
|
|
}
|
|
}
|