Back to project page intelligent-lock-pattern.
The source code is released under:
GNU General Public License
If you think the Android project intelligent-lock-pattern listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package org.unioeste.ilp.models; /*w w w . j a v a2 s. co m*/ 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.DaoConfig; import de.greenrobot.dao.Property; import de.greenrobot.dao.SqlUtils; import de.greenrobot.dao.Query; import de.greenrobot.dao.QueryBuilder; import org.unioeste.ilp.models.Experience; // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. /** * DAO for table experiences. */ public class ExperienceDao extends AbstractDao<Experience, Long> { public static final String TABLENAME = "experiences"; /** * Properties of entity Experience.<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 Done = new Property(1, Boolean.class, "done", false, "DONE"); public final static Property User_id = new Property(2, Long.class, "user_id", false, "USER_ID"); public final static Property Pattern_id = new Property(3, Long.class, "pattern_id", false, "PATTERN_ID"); }; private DaoSession daoSession; private Query<Experience> user_ExperiencesQuery; private Query<Experience> pattern_ExperiencesQuery; public ExperienceDao(DaoConfig config) { super(config); } public ExperienceDao(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 + "'experiences' (" + // "'_id' INTEGER PRIMARY KEY ," + // 0: id "'DONE' INTEGER," + // 1: done "'USER_ID' INTEGER," + // 2: user_id "'PATTERN_ID' INTEGER);"); // 3: pattern_id } /** Drops the underlying database table. */ public static void dropTable(SQLiteDatabase db, boolean ifExists) { String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "'experiences'"; db.execSQL(sql); } /** @inheritdoc */ @Override protected void bindValues(SQLiteStatement stmt, Experience entity) { stmt.clearBindings(); Long id = entity.getId(); if (id != null) { stmt.bindLong(1, id); } Boolean done = entity.getDone(); if (done != null) { stmt.bindLong(2, done ? 1l: 0l); } Long user_id = entity.getUser_id(); if (user_id != null) { stmt.bindLong(3, user_id); } Long pattern_id = entity.getPattern_id(); if (pattern_id != null) { stmt.bindLong(4, pattern_id); } } @Override protected void attachEntity(Experience 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 Experience readEntity(Cursor cursor, int offset) { Experience entity = new Experience( // cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id cursor.isNull(offset + 1) ? null : cursor.getShort(offset + 1) != 0, // done cursor.isNull(offset + 2) ? null : cursor.getLong(offset + 2), // user_id cursor.isNull(offset + 3) ? null : cursor.getLong(offset + 3) // pattern_id ); return entity; } /** @inheritdoc */ @Override public void readEntity(Cursor cursor, Experience entity, int offset) { entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); entity.setDone(cursor.isNull(offset + 1) ? null : cursor.getShort(offset + 1) != 0); entity.setUser_id(cursor.isNull(offset + 2) ? null : cursor.getLong(offset + 2)); entity.setPattern_id(cursor.isNull(offset + 3) ? null : cursor.getLong(offset + 3)); } /** @inheritdoc */ @Override protected Long updateKeyAfterInsert(Experience entity, long rowId) { entity.setId(rowId); return rowId; } /** @inheritdoc */ @Override public Long getKey(Experience entity) { if(entity != null) { return entity.getId(); } else { return null; } } /** @inheritdoc */ @Override protected boolean isEntityUpdateable() { return true; } /** Internal query to resolve the "experiences" to-many relationship of User. */ public synchronized List<Experience> _queryUser_Experiences(Long user_id) { if (user_ExperiencesQuery == null) { QueryBuilder<Experience> queryBuilder = queryBuilder(); queryBuilder.where(Properties.User_id.eq(user_id)); user_ExperiencesQuery = queryBuilder.build(); } else { user_ExperiencesQuery.setParameter(0, user_id); } return user_ExperiencesQuery.list(); } /** Internal query to resolve the "experiences" to-many relationship of Pattern. */ public synchronized List<Experience> _queryPattern_Experiences(Long pattern_id) { if (pattern_ExperiencesQuery == null) { QueryBuilder<Experience> queryBuilder = queryBuilder(); queryBuilder.where(Properties.Pattern_id.eq(pattern_id)); pattern_ExperiencesQuery = queryBuilder.build(); } else { pattern_ExperiencesQuery.setParameter(0, pattern_id); } return pattern_ExperiencesQuery.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.getUserDao().getAllColumns()); builder.append(','); SqlUtils.appendColumns(builder, "T1", daoSession.getPatternDao().getAllColumns()); builder.append(" FROM experiences T"); builder.append(" LEFT JOIN users T0 ON T.'USER_ID'=T0.'_id'"); builder.append(" LEFT JOIN patterns T1 ON T.'PATTERN_ID'=T1.'_id'"); builder.append(' '); selectDeep = builder.toString(); } return selectDeep; } protected Experience loadCurrentDeep(Cursor cursor, boolean lock) { Experience entity = loadCurrent(cursor, 0, lock); int offset = getAllColumns().length; User user = loadCurrentOther(daoSession.getUserDao(), cursor, offset); entity.setUser(user); offset += daoSession.getUserDao().getAllColumns().length; Pattern pattern = loadCurrentOther(daoSession.getPatternDao(), cursor, offset); entity.setPattern(pattern); return entity; } public Experience 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<Experience> loadAllDeepFromCursor(Cursor cursor) { int count = cursor.getCount(); List<Experience> list = new ArrayList<Experience>(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<Experience> 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<Experience> queryDeep(String where, String... selectionArg) { Cursor cursor = db.rawQuery(getSelectDeep() + where, selectionArg); return loadDeepAllAndCloseCursor(cursor); } }