Back to project page guerrillaprose.
The source code is released under:
GNU General Public License
If you think the Android project guerrillaprose 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 de.handler.mobile.android.bachelorapp.app.database; //from w w w . java 2 s. c o m import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteStatement; import java.util.ArrayList; import java.util.List; import de.greenrobot.dao.AbstractDao; import de.greenrobot.dao.Property; import de.greenrobot.dao.internal.DaoConfig; import de.greenrobot.dao.internal.SqlUtils; import de.greenrobot.dao.query.Query; import de.greenrobot.dao.query.QueryBuilder; // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. /** * DAO for table GUERRILLA_PROSE. */ public class GuerrillaProseDao extends AbstractDao<GuerrillaProse, Long> { public static final String TABLENAME = "GUERRILLA_PROSE"; /** * Properties of entity GuerrillaProse.<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 Remote_id = new Property(1, Long.class, "remote_id", false, "REMOTE_ID"); public final static Property Title = new Property(2, String.class, "title", false, "TITLE"); public final static Property Text = new Property(3, String.class, "text", false, "TEXT"); public final static Property Tag = new Property(4, String.class, "tag", false, "TAG"); public final static Property Shared = new Property(5, Boolean.class, "shared", false, "SHARED"); public final static Property Remote_media_id = new Property(6, Long.class, "remote_media_id", false, "REMOTE_MEDIA_ID"); public final static Property Author = new Property(7, String.class, "author", false, "AUTHOR"); public final static Property User_id = new Property(8, Long.class, "user_id", false, "USER_ID"); public final static Property Media_id = new Property(9, Long.class, "media_id", false, "MEDIA_ID"); }; private DaoSession daoSession; private Query<GuerrillaProse> guerrilla_GuerrillaProseListQuery; private Query<GuerrillaProse> media_GuerrillaProseListQuery; public GuerrillaProseDao(DaoConfig config) { super(config); } public GuerrillaProseDao(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 + "'GUERRILLA_PROSE' (" + // "'_id' INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id "'REMOTE_ID' INTEGER," + // 1: remote_id "'TITLE' TEXT NOT NULL ," + // 2: title "'TEXT' TEXT NOT NULL ," + // 3: text "'TAG' TEXT NOT NULL ," + // 4: tag "'SHARED' INTEGER," + // 5: shared "'REMOTE_MEDIA_ID' INTEGER," + // 6: remote_media_id "'AUTHOR' TEXT," + // 7: author "'USER_ID' INTEGER," + // 8: user_id "'MEDIA_ID' INTEGER);"); // 9: media_id } /** Drops the underlying database table. */ public static void dropTable(SQLiteDatabase db, boolean ifExists) { String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "'GUERRILLA_PROSE'"; db.execSQL(sql); } /** @inheritdoc */ @Override protected void bindValues(SQLiteStatement stmt, GuerrillaProse entity) { stmt.clearBindings(); Long id = entity.getId(); if (id != null) { stmt.bindLong(1, id); } Long remote_id = entity.getRemote_id(); if (remote_id != null) { stmt.bindLong(2, remote_id); } stmt.bindString(3, entity.getTitle()); stmt.bindString(4, entity.getText()); stmt.bindString(5, entity.getTag()); Boolean shared = entity.getShared(); if (shared != null) { stmt.bindLong(6, shared ? 1l: 0l); } Long remote_media_id = entity.getRemote_media_id(); if (remote_media_id != null) { stmt.bindLong(7, remote_media_id); } String author = entity.getAuthor(); if (author != null) { stmt.bindString(8, author); } Long user_id = entity.getUser_id(); if (user_id != null) { stmt.bindLong(9, user_id); } Long media_id = entity.getMedia_id(); if (media_id != null) { stmt.bindLong(10, media_id); } } @Override protected void attachEntity(GuerrillaProse 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 GuerrillaProse readEntity(Cursor cursor, int offset) { GuerrillaProse entity = new GuerrillaProse( // cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id cursor.isNull(offset + 1) ? null : cursor.getLong(offset + 1), // remote_id cursor.getString(offset + 2), // title cursor.getString(offset + 3), // text cursor.getString(offset + 4), // tag cursor.isNull(offset + 5) ? null : cursor.getShort(offset + 5) != 0, // shared cursor.isNull(offset + 6) ? null : cursor.getLong(offset + 6), // remote_media_id cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // author cursor.isNull(offset + 8) ? null : cursor.getLong(offset + 8), // user_id cursor.isNull(offset + 9) ? null : cursor.getLong(offset + 9) // media_id ); return entity; } /** @inheritdoc */ @Override public void readEntity(Cursor cursor, GuerrillaProse entity, int offset) { entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); entity.setRemote_id(cursor.isNull(offset + 1) ? null : cursor.getLong(offset + 1)); entity.setTitle(cursor.getString(offset + 2)); entity.setText(cursor.getString(offset + 3)); entity.setTag(cursor.getString(offset + 4)); entity.setShared(cursor.isNull(offset + 5) ? null : cursor.getShort(offset + 5) != 0); entity.setRemote_media_id(cursor.isNull(offset + 6) ? null : cursor.getLong(offset + 6)); entity.setAuthor(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); entity.setUser_id(cursor.isNull(offset + 8) ? null : cursor.getLong(offset + 8)); entity.setMedia_id(cursor.isNull(offset + 9) ? null : cursor.getLong(offset + 9)); } /** @inheritdoc */ @Override protected Long updateKeyAfterInsert(GuerrillaProse entity, long rowId) { entity.setId(rowId); return rowId; } /** @inheritdoc */ @Override public Long getKey(GuerrillaProse entity) { if(entity != null) { return entity.getId(); } else { return null; } } /** @inheritdoc */ @Override protected boolean isEntityUpdateable() { return true; } /** Internal query to resolve the "guerrillaProseList" to-many relationship of Guerrilla. */ public List<GuerrillaProse> _queryGuerrilla_GuerrillaProseList(Long user_id) { synchronized (this) { if (guerrilla_GuerrillaProseListQuery == null) { QueryBuilder<GuerrillaProse> queryBuilder = queryBuilder(); queryBuilder.where(Properties.User_id.eq(null)); guerrilla_GuerrillaProseListQuery = queryBuilder.build(); } } Query<GuerrillaProse> query = guerrilla_GuerrillaProseListQuery.forCurrentThread(); query.setParameter(0, user_id); return query.list(); } /** Internal query to resolve the "guerrillaProseList" to-many relationship of Media. */ public List<GuerrillaProse> _queryMedia_GuerrillaProseList(Long media_id) { synchronized (this) { if (media_GuerrillaProseListQuery == null) { QueryBuilder<GuerrillaProse> queryBuilder = queryBuilder(); queryBuilder.where(Properties.Media_id.eq(null)); media_GuerrillaProseListQuery = queryBuilder.build(); } } Query<GuerrillaProse> query = media_GuerrillaProseListQuery.forCurrentThread(); query.setParameter(0, media_id); 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.getGuerrillaDao().getAllColumns()); builder.append(','); SqlUtils.appendColumns(builder, "T1", daoSession.getMediaDao().getAllColumns()); builder.append(" FROM GUERRILLA_PROSE T"); builder.append(" LEFT JOIN GUERRILLA T0 ON T.'USER_ID'=T0.'_id'"); builder.append(" LEFT JOIN MEDIA T1 ON T.'MEDIA_ID'=T1.'_id'"); builder.append(' '); selectDeep = builder.toString(); } return selectDeep; } protected GuerrillaProse loadCurrentDeep(Cursor cursor, boolean lock) { GuerrillaProse entity = loadCurrent(cursor, 0, lock); int offset = getAllColumns().length; Guerrilla guerrilla = loadCurrentOther(daoSession.getGuerrillaDao(), cursor, offset); entity.setGuerrilla(guerrilla); offset += daoSession.getGuerrillaDao().getAllColumns().length; Media media = loadCurrentOther(daoSession.getMediaDao(), cursor, offset); entity.setMedia(media); return entity; } public GuerrillaProse 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<GuerrillaProse> loadAllDeepFromCursor(Cursor cursor) { int count = cursor.getCount(); List<GuerrillaProse> list = new ArrayList<GuerrillaProse>(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<GuerrillaProse> 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<GuerrillaProse> queryDeep(String where, String... selectionArg) { Cursor cursor = db.rawQuery(getSelectDeep() + where, selectionArg); return loadDeepAllAndCloseCursor(cursor); } }