Search in sources :

Example 1 with NoteWithTags

use of ru.freeit.notes.data.db.entity.NoteWithTags in project LearningApps by evitwilly.

the class NoteDao_Impl method notesByCreatedDate.

@Override
public Object notesByCreatedDate(final Continuation<? super List<NoteWithTags>> continuation) {
    final String _sql = "select * from notes order by created_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);
}
Also used : LongSparseArray(androidx.collection.LongSparseArray) ArrayList(java.util.ArrayList) NoteWithTags(ru.freeit.notes.data.db.entity.NoteWithTags) String(java.lang.String) RoomSQLiteQuery(androidx.room.RoomSQLiteQuery) Cursor(android.database.Cursor) Exception(java.lang.Exception) Note(ru.freeit.notes.data.db.entity.Note) ArrayList(java.util.ArrayList) List(java.util.List) Tag(ru.freeit.notes.data.db.entity.Tag) CancellationSignal(android.os.CancellationSignal) Override(java.lang.Override) Override(java.lang.Override)

Example 2 with NoteWithTags

use of ru.freeit.notes.data.db.entity.NoteWithTags in project LearningApps by evitwilly.

the class NoteDao_Impl method notes.

@Override
public Object notes(final Continuation<? super List<NoteWithTags>> continuation) {
    final String _sql = "select * from notes";
    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);
}
Also used : LongSparseArray(androidx.collection.LongSparseArray) ArrayList(java.util.ArrayList) NoteWithTags(ru.freeit.notes.data.db.entity.NoteWithTags) String(java.lang.String) RoomSQLiteQuery(androidx.room.RoomSQLiteQuery) Cursor(android.database.Cursor) Exception(java.lang.Exception) Note(ru.freeit.notes.data.db.entity.Note) ArrayList(java.util.ArrayList) List(java.util.List) Tag(ru.freeit.notes.data.db.entity.Tag) CancellationSignal(android.os.CancellationSignal) Override(java.lang.Override) Override(java.lang.Override)

Example 3 with NoteWithTags

use of ru.freeit.notes.data.db.entity.NoteWithTags in project LearningApps by evitwilly.

the class NoteDao_Impl method noteBy.

@Override
public Object noteBy(final long id, final Continuation<? super NoteWithTags> continuation) {
    final String _sql = "select * from notes where id = ?";
    final RoomSQLiteQuery _statement = RoomSQLiteQuery.acquire(_sql, 1);
    int _argIndex = 1;
    _statement.bindLong(_argIndex, id);
    final CancellationSignal _cancellationSignal = DBUtil.createCancellationSignal();
    return CoroutinesRoom.execute(__db, true, _cancellationSignal, new Callable<NoteWithTags>() {

        @Override
        public 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 NoteWithTags _result;
                    if (_cursor.moveToFirst()) {
                        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>();
                        }
                        _result = new NoteWithTags(_tmpNote, _tmpTagsCollection_1);
                    } else {
                        _result = null;
                    }
                    __db.setTransactionSuccessful();
                    return _result;
                } finally {
                    _cursor.close();
                    _statement.release();
                }
            } finally {
                __db.endTransaction();
            }
        }
    }, continuation);
}
Also used : LongSparseArray(androidx.collection.LongSparseArray) ArrayList(java.util.ArrayList) NoteWithTags(ru.freeit.notes.data.db.entity.NoteWithTags) String(java.lang.String) RoomSQLiteQuery(androidx.room.RoomSQLiteQuery) Cursor(android.database.Cursor) Exception(java.lang.Exception) Note(ru.freeit.notes.data.db.entity.Note) Tag(ru.freeit.notes.data.db.entity.Tag) CancellationSignal(android.os.CancellationSignal) Override(java.lang.Override) Override(java.lang.Override)

Example 4 with NoteWithTags

use of ru.freeit.notes.data.db.entity.NoteWithTags 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);
}
Also used : LongSparseArray(androidx.collection.LongSparseArray) ArrayList(java.util.ArrayList) NoteWithTags(ru.freeit.notes.data.db.entity.NoteWithTags) String(java.lang.String) RoomSQLiteQuery(androidx.room.RoomSQLiteQuery) Cursor(android.database.Cursor) Exception(java.lang.Exception) Note(ru.freeit.notes.data.db.entity.Note) ArrayList(java.util.ArrayList) List(java.util.List) Tag(ru.freeit.notes.data.db.entity.Tag) CancellationSignal(android.os.CancellationSignal) Override(java.lang.Override) Override(java.lang.Override)

Example 5 with NoteWithTags

use of ru.freeit.notes.data.db.entity.NoteWithTags 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);
}
Also used : LongSparseArray(androidx.collection.LongSparseArray) ArrayList(java.util.ArrayList) NoteWithTags(ru.freeit.notes.data.db.entity.NoteWithTags) String(java.lang.String) RoomSQLiteQuery(androidx.room.RoomSQLiteQuery) Cursor(android.database.Cursor) Exception(java.lang.Exception) Note(ru.freeit.notes.data.db.entity.Note) ArrayList(java.util.ArrayList) List(java.util.List) Tag(ru.freeit.notes.data.db.entity.Tag) CancellationSignal(android.os.CancellationSignal) Override(java.lang.Override) Override(java.lang.Override)

Aggregations

Cursor (android.database.Cursor)5 CancellationSignal (android.os.CancellationSignal)5 LongSparseArray (androidx.collection.LongSparseArray)5 RoomSQLiteQuery (androidx.room.RoomSQLiteQuery)5 Exception (java.lang.Exception)5 Override (java.lang.Override)5 String (java.lang.String)5 ArrayList (java.util.ArrayList)5 Note (ru.freeit.notes.data.db.entity.Note)5 NoteWithTags (ru.freeit.notes.data.db.entity.NoteWithTags)5 Tag (ru.freeit.notes.data.db.entity.Tag)5 List (java.util.List)4