package model.daoModels;
import java.util.List;
import java.util.ArrayList;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteStatement;
import de.greenrobot.dao.AbstractDao;
import de.greenrobot.dao.Property;
import de.greenrobot.dao.internal.SqlUtils;
import de.greenrobot.dao.internal.DaoConfig;
import de.greenrobot.dao.query.Query;
import de.greenrobot.dao.query.QueryBuilder;
import model.daoModels.Verification;
// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/**
* DAO for table "VERIFICATION".
*/
public class VerificationDao extends AbstractDao<Verification, Long> {
public static final String TABLENAME = "VERIFICATION";
/**
* Properties of entity Verification.<br/>
* Can be used for QueryBuilder and for referencing column names.
*/
public static class Properties {
public final static Property Id = new Property(0, Long.class, "id", true, "_id");
public final static Property SigningInstitution = new Property(1, String.class, "signingInstitution", false, "SIGNING_INSTITUTION");
public final static Property Signature = new Property(2, String.class, "signature", false, "SIGNATURE");
public final static Property Status = new Property(3, Integer.class, "status", false, "STATUS");
public final static Property BookId = new Property(4, long.class, "bookId", false, "BOOK_ID");
public final static Property AudioChapterId = new Property(5, long.class, "audioChapterId", false, "AUDIO_CHAPTER_ID");
};
private DaoSession daoSession;
private Query<Verification> book_VerificationsQuery;
private Query<Verification> audioChapter_VerificationsQuery;
public VerificationDao(DaoConfig config) {
super(config);
}
public VerificationDao(DaoConfig config, DaoSession daoSession) {
super(config, daoSession);
this.daoSession = daoSession;
}
/** Creates the underlying database table. */
public static void createTable(SQLiteDatabase db, boolean ifNotExists) {
String constraint = ifNotExists? "IF NOT EXISTS ": "";
db.execSQL("CREATE TABLE " + constraint + "\"VERIFICATION\" (" + //
"\"_id\" INTEGER PRIMARY KEY ," + // 0: id
"\"SIGNING_INSTITUTION\" TEXT," + // 1: signingInstitution
"\"SIGNATURE\" TEXT," + // 2: signature
"\"STATUS\" INTEGER," + // 3: status
"\"BOOK_ID\" INTEGER NOT NULL ," + // 4: bookId
"\"AUDIO_CHAPTER_ID\" INTEGER NOT NULL );"); // 5: audioChapterId
}
/** Drops the underlying database table. */
public static void dropTable(SQLiteDatabase db, boolean ifExists) {
String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"VERIFICATION\"";
db.execSQL(sql);
}
/** @inheritdoc */
@Override
protected void bindValues(SQLiteStatement stmt, Verification entity) {
stmt.clearBindings();
Long id = entity.getId();
if (id != null) {
stmt.bindLong(1, id);
}
String signingInstitution = entity.getSigningInstitution();
if (signingInstitution != null) {
stmt.bindString(2, signingInstitution);
}
String signature = entity.getSignature();
if (signature != null) {
stmt.bindString(3, signature);
}
Integer status = entity.getStatus();
if (status != null) {
stmt.bindLong(4, status);
}
stmt.bindLong(5, entity.getBookId());
stmt.bindLong(6, entity.getAudioChapterId());
}
@Override
protected void attachEntity(Verification entity) {
super.attachEntity(entity);
entity.__setDaoSession(daoSession);
}
/** @inheritdoc */
@Override
public Long readKey(Cursor cursor, int offset) {
return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0);
}
/** @inheritdoc */
@Override
public Verification readEntity(Cursor cursor, int offset) {
Verification entity = new Verification( //
cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id
cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // signingInstitution
cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // signature
cursor.isNull(offset + 3) ? null : cursor.getInt(offset + 3), // status
cursor.getLong(offset + 4), // bookId
cursor.getLong(offset + 5) // audioChapterId
);
return entity;
}
/** @inheritdoc */
@Override
public void readEntity(Cursor cursor, Verification entity, int offset) {
entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
entity.setSigningInstitution(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
entity.setSignature(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
entity.setStatus(cursor.isNull(offset + 3) ? null : cursor.getInt(offset + 3));
entity.setBookId(cursor.getLong(offset + 4));
entity.setAudioChapterId(cursor.getLong(offset + 5));
}
/** @inheritdoc */
@Override
protected Long updateKeyAfterInsert(Verification entity, long rowId) {
entity.setId(rowId);
return rowId;
}
/** @inheritdoc */
@Override
public Long getKey(Verification entity) {
if(entity != null) {
return entity.getId();
} else {
return null;
}
}
/** @inheritdoc */
@Override
protected boolean isEntityUpdateable() {
return true;
}
/** Internal query to resolve the "verifications" to-many relationship of Book. */
public List<Verification> _queryBook_Verifications(long bookId) {
synchronized (this) {
if (book_VerificationsQuery == null) {
QueryBuilder<Verification> queryBuilder = queryBuilder();
queryBuilder.where(Properties.BookId.eq(null));
book_VerificationsQuery = queryBuilder.build();
}
}
Query<Verification> query = book_VerificationsQuery.forCurrentThread();
query.setParameter(0, bookId);
return query.list();
}
/** Internal query to resolve the "verifications" to-many relationship of AudioChapter. */
public List<Verification> _queryAudioChapter_Verifications(long audioChapterId) {
synchronized (this) {
if (audioChapter_VerificationsQuery == null) {
QueryBuilder<Verification> queryBuilder = queryBuilder();
queryBuilder.where(Properties.AudioChapterId.eq(null));
audioChapter_VerificationsQuery = queryBuilder.build();
}
}
Query<Verification> query = audioChapter_VerificationsQuery.forCurrentThread();
query.setParameter(0, audioChapterId);
return query.list();
}
private String selectDeep;
protected String getSelectDeep() {
if (selectDeep == null) {
StringBuilder builder = new StringBuilder("SELECT ");
SqlUtils.appendColumns(builder, "T", getAllColumns());
builder.append(',');
SqlUtils.appendColumns(builder, "T0", daoSession.getBookDao().getAllColumns());
builder.append(',');
SqlUtils.appendColumns(builder, "T1", daoSession.getAudioChapterDao().getAllColumns());
builder.append(" FROM VERIFICATION T");
builder.append(" LEFT JOIN BOOK T0 ON T.\"BOOK_ID\"=T0.\"_id\"");
builder.append(" LEFT JOIN AUDIO_CHAPTER T1 ON T.\"AUDIO_CHAPTER_ID\"=T1.\"_id\"");
builder.append(' ');
selectDeep = builder.toString();
}
return selectDeep;
}
protected Verification loadCurrentDeep(Cursor cursor, boolean lock) {
Verification entity = loadCurrent(cursor, 0, lock);
int offset = getAllColumns().length;
Book book = loadCurrentOther(daoSession.getBookDao(), cursor, offset);
if(book != null) {
entity.setBook(book);
}
offset += daoSession.getBookDao().getAllColumns().length;
AudioChapter audioChapter = loadCurrentOther(daoSession.getAudioChapterDao(), cursor, offset);
if(audioChapter != null) {
entity.setAudioChapter(audioChapter);
}
return entity;
}
public Verification loadDeep(Long key) {
assertSinglePk();
if (key == null) {
return null;
}
StringBuilder builder = new StringBuilder(getSelectDeep());
builder.append("WHERE ");
SqlUtils.appendColumnsEqValue(builder, "T", getPkColumns());
String sql = builder.toString();
String[] keyArray = new String[] { key.toString() };
Cursor cursor = db.rawQuery(sql, keyArray);
try {
boolean available = cursor.moveToFirst();
if (!available) {
return null;
} else if (!cursor.isLast()) {
throw new IllegalStateException("Expected unique result, but count was " + cursor.getCount());
}
return loadCurrentDeep(cursor, true);
} finally {
cursor.close();
}
}
/** Reads all available rows from the given cursor and returns a list of new ImageTO objects. */
public List<Verification> loadAllDeepFromCursor(Cursor cursor) {
int count = cursor.getCount();
List<Verification> list = new ArrayList<Verification>(count);
if (cursor.moveToFirst()) {
if (identityScope != null) {
identityScope.lock();
identityScope.reserveRoom(count);
}
try {
do {
list.add(loadCurrentDeep(cursor, false));
} while (cursor.moveToNext());
} finally {
if (identityScope != null) {
identityScope.unlock();
}
}
}
return list;
}
protected List<Verification> loadDeepAllAndCloseCursor(Cursor cursor) {
try {
return loadAllDeepFromCursor(cursor);
} finally {
cursor.close();
}
}
/** A raw-style query where you can pass any WHERE clause and arguments. */
public List<Verification> queryDeep(String where, String... selectionArg) {
Cursor cursor = db.rawQuery(getSelectDeep() + where, selectionArg);
return loadDeepAllAndCloseCursor(cursor);
}
}