use of androidx.room.RoomSQLiteQuery in project LearningApps by evitwilly.
the class NoteDao_Impl method notesByEditedDate.
@Override
public Object notesByEditedDate(final Continuation<? super List<NoteWithTags>> continuation) {
final String _sql = "select * from notes order by edited_date";
final RoomSQLiteQuery _statement = RoomSQLiteQuery.acquire(_sql, 0);
final CancellationSignal _cancellationSignal = DBUtil.createCancellationSignal();
return CoroutinesRoom.execute(__db, true, _cancellationSignal, new Callable<List<NoteWithTags>>() {
@Override
public List<NoteWithTags> call() throws Exception {
__db.beginTransaction();
try {
final Cursor _cursor = DBUtil.query(__db, _statement, true, null);
try {
final int _cursorIndexOfTitle = CursorUtil.getColumnIndexOrThrow(_cursor, "title");
final int _cursorIndexOfCreatedDate = CursorUtil.getColumnIndexOrThrow(_cursor, "created_date");
final int _cursorIndexOfEditedDate = CursorUtil.getColumnIndexOrThrow(_cursor, "edited_date");
final int _cursorIndexOfId = CursorUtil.getColumnIndexOrThrow(_cursor, "id");
final LongSparseArray<ArrayList<Tag>> _collectionTags = new LongSparseArray<ArrayList<Tag>>();
while (_cursor.moveToNext()) {
final long _tmpKey = _cursor.getLong(_cursorIndexOfId);
ArrayList<Tag> _tmpTagsCollection = _collectionTags.get(_tmpKey);
if (_tmpTagsCollection == null) {
_tmpTagsCollection = new ArrayList<Tag>();
_collectionTags.put(_tmpKey, _tmpTagsCollection);
}
}
_cursor.moveToPosition(-1);
__fetchRelationshiptagsAsruFreeitNotesDataDbEntityTag(_collectionTags);
final List<NoteWithTags> _result = new ArrayList<NoteWithTags>(_cursor.getCount());
while (_cursor.moveToNext()) {
final NoteWithTags _item;
final Note _tmpNote;
if (!(_cursor.isNull(_cursorIndexOfTitle) && _cursor.isNull(_cursorIndexOfCreatedDate) && _cursor.isNull(_cursorIndexOfEditedDate) && _cursor.isNull(_cursorIndexOfId))) {
final String _tmpTitle;
if (_cursor.isNull(_cursorIndexOfTitle)) {
_tmpTitle = null;
} else {
_tmpTitle = _cursor.getString(_cursorIndexOfTitle);
}
final long _tmpCreatedDate;
_tmpCreatedDate = _cursor.getLong(_cursorIndexOfCreatedDate);
final long _tmpEditedDate;
_tmpEditedDate = _cursor.getLong(_cursorIndexOfEditedDate);
final long _tmpId;
_tmpId = _cursor.getLong(_cursorIndexOfId);
_tmpNote = new Note(_tmpTitle, _tmpCreatedDate, _tmpEditedDate, _tmpId);
} else {
_tmpNote = null;
}
ArrayList<Tag> _tmpTagsCollection_1 = null;
final long _tmpKey_1 = _cursor.getLong(_cursorIndexOfId);
_tmpTagsCollection_1 = _collectionTags.get(_tmpKey_1);
if (_tmpTagsCollection_1 == null) {
_tmpTagsCollection_1 = new ArrayList<Tag>();
}
_item = new NoteWithTags(_tmpNote, _tmpTagsCollection_1);
_result.add(_item);
}
__db.setTransactionSuccessful();
return _result;
} finally {
_cursor.close();
_statement.release();
}
} finally {
__db.endTransaction();
}
}
}, continuation);
}
use of androidx.room.RoomSQLiteQuery in project LearningApps by evitwilly.
the class NoteDao_Impl method __fetchRelationshiptagsAsruFreeitNotesDataDbEntityTag.
private void __fetchRelationshiptagsAsruFreeitNotesDataDbEntityTag(final LongSparseArray<ArrayList<Tag>> _map) {
if (_map.isEmpty()) {
return;
}
// check if the size is too big, if so divide;
if (_map.size() > RoomDatabase.MAX_BIND_PARAMETER_CNT) {
LongSparseArray<ArrayList<Tag>> _tmpInnerMap = new LongSparseArray<ArrayList<Tag>>(androidx.room.RoomDatabase.MAX_BIND_PARAMETER_CNT);
int _tmpIndex = 0;
int _mapIndex = 0;
final int _limit = _map.size();
while (_mapIndex < _limit) {
_tmpInnerMap.put(_map.keyAt(_mapIndex), _map.valueAt(_mapIndex));
_mapIndex++;
_tmpIndex++;
if (_tmpIndex == RoomDatabase.MAX_BIND_PARAMETER_CNT) {
__fetchRelationshiptagsAsruFreeitNotesDataDbEntityTag(_tmpInnerMap);
_tmpInnerMap = new LongSparseArray<ArrayList<Tag>>(RoomDatabase.MAX_BIND_PARAMETER_CNT);
_tmpIndex = 0;
}
}
if (_tmpIndex > 0) {
__fetchRelationshiptagsAsruFreeitNotesDataDbEntityTag(_tmpInnerMap);
}
return;
}
StringBuilder _stringBuilder = StringUtil.newStringBuilder();
_stringBuilder.append("SELECT `title`,`note_id`,`id` FROM `tags` WHERE `note_id` IN (");
final int _inputSize = _map.size();
StringUtil.appendPlaceholders(_stringBuilder, _inputSize);
_stringBuilder.append(")");
final String _sql = _stringBuilder.toString();
final int _argCount = 0 + _inputSize;
final RoomSQLiteQuery _stmt = RoomSQLiteQuery.acquire(_sql, _argCount);
int _argIndex = 1;
for (int i = 0; i < _map.size(); i++) {
long _item = _map.keyAt(i);
_stmt.bindLong(_argIndex, _item);
_argIndex++;
}
final Cursor _cursor = DBUtil.query(__db, _stmt, false, null);
try {
final int _itemKeyIndex = CursorUtil.getColumnIndex(_cursor, "note_id");
if (_itemKeyIndex == -1) {
return;
}
final int _cursorIndexOfTitle = CursorUtil.getColumnIndexOrThrow(_cursor, "title");
final int _cursorIndexOfNoteId = CursorUtil.getColumnIndexOrThrow(_cursor, "note_id");
final int _cursorIndexOfId = CursorUtil.getColumnIndexOrThrow(_cursor, "id");
while (_cursor.moveToNext()) {
final long _tmpKey = _cursor.getLong(_itemKeyIndex);
ArrayList<Tag> _tmpRelation = _map.get(_tmpKey);
if (_tmpRelation != null) {
final Tag _item_1;
final String _tmpTitle;
if (_cursor.isNull(_cursorIndexOfTitle)) {
_tmpTitle = null;
} else {
_tmpTitle = _cursor.getString(_cursorIndexOfTitle);
}
final long _tmpNoteId;
_tmpNoteId = _cursor.getLong(_cursorIndexOfNoteId);
final long _tmpId;
_tmpId = _cursor.getLong(_cursorIndexOfId);
_item_1 = new Tag(_tmpTitle, _tmpNoteId, _tmpId);
_tmpRelation.add(_item_1);
}
}
} finally {
_cursor.close();
}
}
use of androidx.room.RoomSQLiteQuery in project LearningApps by evitwilly.
the class NoteDao_Impl method notesByTitle.
@Override
public Object notesByTitle(final Continuation<? super List<NoteWithTags>> continuation) {
final String _sql = "select * from notes order by title";
final RoomSQLiteQuery _statement = RoomSQLiteQuery.acquire(_sql, 0);
final CancellationSignal _cancellationSignal = DBUtil.createCancellationSignal();
return CoroutinesRoom.execute(__db, true, _cancellationSignal, new Callable<List<NoteWithTags>>() {
@Override
public List<NoteWithTags> call() throws Exception {
__db.beginTransaction();
try {
final Cursor _cursor = DBUtil.query(__db, _statement, true, null);
try {
final int _cursorIndexOfTitle = CursorUtil.getColumnIndexOrThrow(_cursor, "title");
final int _cursorIndexOfCreatedDate = CursorUtil.getColumnIndexOrThrow(_cursor, "created_date");
final int _cursorIndexOfEditedDate = CursorUtil.getColumnIndexOrThrow(_cursor, "edited_date");
final int _cursorIndexOfId = CursorUtil.getColumnIndexOrThrow(_cursor, "id");
final LongSparseArray<ArrayList<Tag>> _collectionTags = new LongSparseArray<ArrayList<Tag>>();
while (_cursor.moveToNext()) {
final long _tmpKey = _cursor.getLong(_cursorIndexOfId);
ArrayList<Tag> _tmpTagsCollection = _collectionTags.get(_tmpKey);
if (_tmpTagsCollection == null) {
_tmpTagsCollection = new ArrayList<Tag>();
_collectionTags.put(_tmpKey, _tmpTagsCollection);
}
}
_cursor.moveToPosition(-1);
__fetchRelationshiptagsAsruFreeitNotesDataDbEntityTag(_collectionTags);
final List<NoteWithTags> _result = new ArrayList<NoteWithTags>(_cursor.getCount());
while (_cursor.moveToNext()) {
final NoteWithTags _item;
final Note _tmpNote;
if (!(_cursor.isNull(_cursorIndexOfTitle) && _cursor.isNull(_cursorIndexOfCreatedDate) && _cursor.isNull(_cursorIndexOfEditedDate) && _cursor.isNull(_cursorIndexOfId))) {
final String _tmpTitle;
if (_cursor.isNull(_cursorIndexOfTitle)) {
_tmpTitle = null;
} else {
_tmpTitle = _cursor.getString(_cursorIndexOfTitle);
}
final long _tmpCreatedDate;
_tmpCreatedDate = _cursor.getLong(_cursorIndexOfCreatedDate);
final long _tmpEditedDate;
_tmpEditedDate = _cursor.getLong(_cursorIndexOfEditedDate);
final long _tmpId;
_tmpId = _cursor.getLong(_cursorIndexOfId);
_tmpNote = new Note(_tmpTitle, _tmpCreatedDate, _tmpEditedDate, _tmpId);
} else {
_tmpNote = null;
}
ArrayList<Tag> _tmpTagsCollection_1 = null;
final long _tmpKey_1 = _cursor.getLong(_cursorIndexOfId);
_tmpTagsCollection_1 = _collectionTags.get(_tmpKey_1);
if (_tmpTagsCollection_1 == null) {
_tmpTagsCollection_1 = new ArrayList<Tag>();
}
_item = new NoteWithTags(_tmpNote, _tmpTagsCollection_1);
_result.add(_item);
}
__db.setTransactionSuccessful();
return _result;
} finally {
_cursor.close();
_statement.release();
}
} finally {
__db.endTransaction();
}
}
}, continuation);
}
use of androidx.room.RoomSQLiteQuery in project LibChecker-Rules-Bundle by zhaobozhen.
the class RuleDao_Impl method getRegexRules.
@Override
public Object getRegexRules(final Continuation<? super List<RuleEntity>> continuation) {
final String _sql = "SELECT * from rules_table WHERE isRegexRule = 1";
final RoomSQLiteQuery _statement = RoomSQLiteQuery.acquire(_sql, 0);
final CancellationSignal _cancellationSignal = DBUtil.createCancellationSignal();
return CoroutinesRoom.execute(__db, false, _cancellationSignal, new Callable<List<RuleEntity>>() {
@Override
public List<RuleEntity> call() throws Exception {
final Cursor _cursor = DBUtil.query(__db, _statement, false, null);
try {
final int _cursorIndexOfId = CursorUtil.getColumnIndexOrThrow(_cursor, "_id");
final int _cursorIndexOfName = CursorUtil.getColumnIndexOrThrow(_cursor, "name");
final int _cursorIndexOfLabel = CursorUtil.getColumnIndexOrThrow(_cursor, "label");
final int _cursorIndexOfType = CursorUtil.getColumnIndexOrThrow(_cursor, "type");
final int _cursorIndexOfIconIndex = CursorUtil.getColumnIndexOrThrow(_cursor, "iconIndex");
final int _cursorIndexOfIsRegexRule = CursorUtil.getColumnIndexOrThrow(_cursor, "isRegexRule");
final int _cursorIndexOfRegexName = CursorUtil.getColumnIndexOrThrow(_cursor, "regexName");
final List<RuleEntity> _result = new ArrayList<RuleEntity>(_cursor.getCount());
while (_cursor.moveToNext()) {
final RuleEntity _item;
final int _tmpId;
_tmpId = _cursor.getInt(_cursorIndexOfId);
final String _tmpName;
if (_cursor.isNull(_cursorIndexOfName)) {
_tmpName = null;
} else {
_tmpName = _cursor.getString(_cursorIndexOfName);
}
final String _tmpLabel;
if (_cursor.isNull(_cursorIndexOfLabel)) {
_tmpLabel = null;
} else {
_tmpLabel = _cursor.getString(_cursorIndexOfLabel);
}
final int _tmpType;
_tmpType = _cursor.getInt(_cursorIndexOfType);
final int _tmpIconIndex;
_tmpIconIndex = _cursor.getInt(_cursorIndexOfIconIndex);
final boolean _tmpIsRegexRule;
final int _tmp;
_tmp = _cursor.getInt(_cursorIndexOfIsRegexRule);
_tmpIsRegexRule = _tmp != 0;
final String _tmpRegexName;
if (_cursor.isNull(_cursorIndexOfRegexName)) {
_tmpRegexName = null;
} else {
_tmpRegexName = _cursor.getString(_cursorIndexOfRegexName);
}
_item = new RuleEntity(_tmpId, _tmpName, _tmpLabel, _tmpType, _tmpIconIndex, _tmpIsRegexRule, _tmpRegexName);
_result.add(_item);
}
return _result;
} finally {
_cursor.close();
_statement.release();
}
}
}, continuation);
}
use of androidx.room.RoomSQLiteQuery in project LibChecker-Rules-Bundle by zhaobozhen.
the class RuleDao_Impl method getRule.
@Override
public Object getRule(final String name, final Continuation<? super RuleEntity> continuation) {
final String _sql = "SELECT * from rules_table WHERE name LIKE ?";
final RoomSQLiteQuery _statement = RoomSQLiteQuery.acquire(_sql, 1);
int _argIndex = 1;
if (name == null) {
_statement.bindNull(_argIndex);
} else {
_statement.bindString(_argIndex, name);
}
final CancellationSignal _cancellationSignal = DBUtil.createCancellationSignal();
return CoroutinesRoom.execute(__db, false, _cancellationSignal, new Callable<RuleEntity>() {
@Override
public RuleEntity call() throws Exception {
final Cursor _cursor = DBUtil.query(__db, _statement, false, null);
try {
final int _cursorIndexOfId = CursorUtil.getColumnIndexOrThrow(_cursor, "_id");
final int _cursorIndexOfName = CursorUtil.getColumnIndexOrThrow(_cursor, "name");
final int _cursorIndexOfLabel = CursorUtil.getColumnIndexOrThrow(_cursor, "label");
final int _cursorIndexOfType = CursorUtil.getColumnIndexOrThrow(_cursor, "type");
final int _cursorIndexOfIconIndex = CursorUtil.getColumnIndexOrThrow(_cursor, "iconIndex");
final int _cursorIndexOfIsRegexRule = CursorUtil.getColumnIndexOrThrow(_cursor, "isRegexRule");
final int _cursorIndexOfRegexName = CursorUtil.getColumnIndexOrThrow(_cursor, "regexName");
final RuleEntity _result;
if (_cursor.moveToFirst()) {
final int _tmpId;
_tmpId = _cursor.getInt(_cursorIndexOfId);
final String _tmpName;
if (_cursor.isNull(_cursorIndexOfName)) {
_tmpName = null;
} else {
_tmpName = _cursor.getString(_cursorIndexOfName);
}
final String _tmpLabel;
if (_cursor.isNull(_cursorIndexOfLabel)) {
_tmpLabel = null;
} else {
_tmpLabel = _cursor.getString(_cursorIndexOfLabel);
}
final int _tmpType;
_tmpType = _cursor.getInt(_cursorIndexOfType);
final int _tmpIconIndex;
_tmpIconIndex = _cursor.getInt(_cursorIndexOfIconIndex);
final boolean _tmpIsRegexRule;
final int _tmp;
_tmp = _cursor.getInt(_cursorIndexOfIsRegexRule);
_tmpIsRegexRule = _tmp != 0;
final String _tmpRegexName;
if (_cursor.isNull(_cursorIndexOfRegexName)) {
_tmpRegexName = null;
} else {
_tmpRegexName = _cursor.getString(_cursorIndexOfRegexName);
}
_result = new RuleEntity(_tmpId, _tmpName, _tmpLabel, _tmpType, _tmpIconIndex, _tmpIsRegexRule, _tmpRegexName);
} else {
_result = null;
}
return _result;
} finally {
_cursor.close();
_statement.release();
}
}
}, continuation);
}
Aggregations