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.Version;
// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/**
* DAO for table "VERSION".
*/
public class VersionDao extends AbstractDao<Version, Long> {
public static final String TABLENAME = "VERSION";
/**
* Properties of entity Version.<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 UniqueSlug = new Property(1, String.class, "uniqueSlug", false, "UNIQUE_SLUG");
public final static Property Slug = new Property(2, String.class, "slug", false, "SLUG");
public final static Property Name = new Property(3, String.class, "name", false, "NAME");
public final static Property StatusCheckingEntity = new Property(4, String.class, "statusCheckingEntity", false, "STATUS_CHECKING_ENTITY");
public final static Property StatusCheckingLevel = new Property(5, String.class, "statusCheckingLevel", false, "STATUS_CHECKING_LEVEL");
public final static Property StatusComments = new Property(6, String.class, "statusComments", false, "STATUS_COMMENTS");
public final static Property StatusContributors = new Property(7, String.class, "statusContributors", false, "STATUS_CONTRIBUTORS");
public final static Property StatusPublishDate = new Property(8, String.class, "statusPublishDate", false, "STATUS_PUBLISH_DATE");
public final static Property StatusSourceText = new Property(9, String.class, "statusSourceText", false, "STATUS_SOURCE_TEXT");
public final static Property StatusSourceTextVersion = new Property(10, String.class, "statusSourceTextVersion", false, "STATUS_SOURCE_TEXT_VERSION");
public final static Property StatusVersion = new Property(11, String.class, "statusVersion", false, "STATUS_VERSION");
public final static Property Modified = new Property(12, java.util.Date.class, "modified", false, "MODIFIED");
public final static Property LanguageId = new Property(13, long.class, "languageId", false, "LANGUAGE_ID");
};
private DaoSession daoSession;
private Query<Version> language_VersionsQuery;
public VersionDao(DaoConfig config) {
super(config);
}
public VersionDao(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 + "\"VERSION\" (" + //
"\"_id\" INTEGER PRIMARY KEY ," + // 0: id
"\"UNIQUE_SLUG\" TEXT," + // 1: uniqueSlug
"\"SLUG\" TEXT," + // 2: slug
"\"NAME\" TEXT," + // 3: name
"\"STATUS_CHECKING_ENTITY\" TEXT," + // 4: statusCheckingEntity
"\"STATUS_CHECKING_LEVEL\" TEXT," + // 5: statusCheckingLevel
"\"STATUS_COMMENTS\" TEXT," + // 6: statusComments
"\"STATUS_CONTRIBUTORS\" TEXT," + // 7: statusContributors
"\"STATUS_PUBLISH_DATE\" TEXT," + // 8: statusPublishDate
"\"STATUS_SOURCE_TEXT\" TEXT," + // 9: statusSourceText
"\"STATUS_SOURCE_TEXT_VERSION\" TEXT," + // 10: statusSourceTextVersion
"\"STATUS_VERSION\" TEXT," + // 11: statusVersion
"\"MODIFIED\" INTEGER," + // 12: modified
"\"LANGUAGE_ID\" INTEGER NOT NULL );"); // 13: languageId
}
/** Drops the underlying database table. */
public static void dropTable(SQLiteDatabase db, boolean ifExists) {
String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"VERSION\"";
db.execSQL(sql);
}
/** @inheritdoc */
@Override
protected void bindValues(SQLiteStatement stmt, Version entity) {
stmt.clearBindings();
Long id = entity.getId();
if (id != null) {
stmt.bindLong(1, id);
}
String uniqueSlug = entity.getUniqueSlug();
if (uniqueSlug != null) {
stmt.bindString(2, uniqueSlug);
}
String slug = entity.getSlug();
if (slug != null) {
stmt.bindString(3, slug);
}
String name = entity.getName();
if (name != null) {
stmt.bindString(4, name);
}
String statusCheckingEntity = entity.getStatusCheckingEntity();
if (statusCheckingEntity != null) {
stmt.bindString(5, statusCheckingEntity);
}
String statusCheckingLevel = entity.getStatusCheckingLevel();
if (statusCheckingLevel != null) {
stmt.bindString(6, statusCheckingLevel);
}
String statusComments = entity.getStatusComments();
if (statusComments != null) {
stmt.bindString(7, statusComments);
}
String statusContributors = entity.getStatusContributors();
if (statusContributors != null) {
stmt.bindString(8, statusContributors);
}
String statusPublishDate = entity.getStatusPublishDate();
if (statusPublishDate != null) {
stmt.bindString(9, statusPublishDate);
}
String statusSourceText = entity.getStatusSourceText();
if (statusSourceText != null) {
stmt.bindString(10, statusSourceText);
}
String statusSourceTextVersion = entity.getStatusSourceTextVersion();
if (statusSourceTextVersion != null) {
stmt.bindString(11, statusSourceTextVersion);
}
String statusVersion = entity.getStatusVersion();
if (statusVersion != null) {
stmt.bindString(12, statusVersion);
}
java.util.Date modified = entity.getModified();
if (modified != null) {
stmt.bindLong(13, modified.getTime());
}
stmt.bindLong(14, entity.getLanguageId());
}
@Override
protected void attachEntity(Version 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 Version readEntity(Cursor cursor, int offset) {
Version entity = new Version( //
cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id
cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // uniqueSlug
cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // slug
cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // name
cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // statusCheckingEntity
cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // statusCheckingLevel
cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // statusComments
cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // statusContributors
cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // statusPublishDate
cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // statusSourceText
cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10), // statusSourceTextVersion
cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11), // statusVersion
cursor.isNull(offset + 12) ? null : new java.util.Date(cursor.getLong(offset + 12)), // modified
cursor.getLong(offset + 13) // languageId
);
return entity;
}
/** @inheritdoc */
@Override
public void readEntity(Cursor cursor, Version entity, int offset) {
entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
entity.setUniqueSlug(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
entity.setSlug(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
entity.setName(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
entity.setStatusCheckingEntity(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
entity.setStatusCheckingLevel(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5));
entity.setStatusComments(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6));
entity.setStatusContributors(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7));
entity.setStatusPublishDate(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8));
entity.setStatusSourceText(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9));
entity.setStatusSourceTextVersion(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10));
entity.setStatusVersion(cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11));
entity.setModified(cursor.isNull(offset + 12) ? null : new java.util.Date(cursor.getLong(offset + 12)));
entity.setLanguageId(cursor.getLong(offset + 13));
}
/** @inheritdoc */
@Override
protected Long updateKeyAfterInsert(Version entity, long rowId) {
entity.setId(rowId);
return rowId;
}
/** @inheritdoc */
@Override
public Long getKey(Version entity) {
if(entity != null) {
return entity.getId();
} else {
return null;
}
}
/** @inheritdoc */
@Override
protected boolean isEntityUpdateable() {
return true;
}
/** Internal query to resolve the "versions" to-many relationship of Language. */
public List<Version> _queryLanguage_Versions(long languageId) {
synchronized (this) {
if (language_VersionsQuery == null) {
QueryBuilder<Version> queryBuilder = queryBuilder();
queryBuilder.where(Properties.LanguageId.eq(null));
language_VersionsQuery = queryBuilder.build();
}
}
Query<Version> query = language_VersionsQuery.forCurrentThread();
query.setParameter(0, languageId);
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.getLanguageDao().getAllColumns());
builder.append(" FROM VERSION T");
builder.append(" LEFT JOIN LANGUAGE T0 ON T.\"LANGUAGE_ID\"=T0.\"_id\"");
builder.append(' ');
selectDeep = builder.toString();
}
return selectDeep;
}
protected Version loadCurrentDeep(Cursor cursor, boolean lock) {
Version entity = loadCurrent(cursor, 0, lock);
int offset = getAllColumns().length;
Language language = loadCurrentOther(daoSession.getLanguageDao(), cursor, offset);
if(language != null) {
entity.setLanguage(language);
}
return entity;
}
public Version 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<Version> loadAllDeepFromCursor(Cursor cursor) {
int count = cursor.getCount();
List<Version> list = new ArrayList<Version>(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<Version> 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<Version> queryDeep(String where, String... selectionArg) {
Cursor cursor = db.rawQuery(getSelectDeep() + where, selectionArg);
return loadDeepAllAndCloseCursor(cursor);
}
}