Coverage Summary for Class: OrdersRoomDao_Impl (com.imecatro.demosales.data.sales.datasource)
| Class |
Method, %
|
Branch, %
|
Line, %
|
Instruction, %
|
| OrdersRoomDao_Impl |
0%
(0/21)
|
0%
(0/14)
|
0%
(0/161)
|
0%
(0/643)
|
| OrdersRoomDao_Impl$1 |
0%
(0/3)
|
|
0%
(0/9)
|
0%
(0/38)
|
| OrdersRoomDao_Impl$2 |
0%
(0/3)
|
|
0%
(0/10)
|
0%
(0/43)
|
| OrdersRoomDao_Impl$Companion |
0%
(0/1)
|
|
0%
(0/1)
|
0%
(0/1)
|
| Total |
0%
(0/28)
|
0%
(0/14)
|
0%
(0/181)
|
0%
(0/725)
|
package com.imecatro.demosales.`data`.sales.datasource
import androidx.room.EntityDeleteOrUpdateAdapter
import androidx.room.EntityInsertAdapter
import androidx.room.RoomDatabase
import androidx.room.coroutines.createFlow
import androidx.room.util.getColumnIndexOrThrow
import androidx.room.util.performBlocking
import androidx.room.util.performSuspending
import androidx.sqlite.SQLiteStatement
import com.imecatro.demosales.`data`.sales.model.OrderDataRoomModel
import javax.`annotation`.processing.Generated
import kotlin.Double
import kotlin.Float
import kotlin.Int
import kotlin.Long
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.List
import kotlin.collections.MutableList
import kotlin.collections.mutableListOf
import kotlin.reflect.KClass
import kotlinx.coroutines.flow.Flow
@Generated(value = ["androidx.room.RoomProcessor"])
@Suppress(names = ["UNCHECKED_CAST", "DEPRECATION", "REDUNDANT_PROJECTION", "REMOVAL"])
public class OrdersRoomDao_Impl(
__db: RoomDatabase,
) : OrdersRoomDao {
private val __db: RoomDatabase
private val __insertAdapterOfOrderDataRoomModel: EntityInsertAdapter<OrderDataRoomModel>
private val __updateAdapterOfOrderDataRoomModel: EntityDeleteOrUpdateAdapter<OrderDataRoomModel>
init {
this.__db = __db
this.__insertAdapterOfOrderDataRoomModel = object : EntityInsertAdapter<OrderDataRoomModel>() {
protected override fun createQuery(): String = "INSERT OR REPLACE INTO `order_table` (`id`,`sale_id`,`productId`,`productName`,`productPrice`,`qty`,`productImage`) VALUES (nullif(?, 0),?,?,?,?,?,?)"
protected override fun bind(statement: SQLiteStatement, entity: OrderDataRoomModel) {
statement.bindLong(1, entity.id)
statement.bindLong(2, entity.saleId)
statement.bindLong(3, entity.productId)
statement.bindText(4, entity.productName)
statement.bindDouble(5, entity.productPrice)
statement.bindDouble(6, entity.qty)
statement.bindText(7, entity.productImage)
}
}
this.__updateAdapterOfOrderDataRoomModel = object : EntityDeleteOrUpdateAdapter<OrderDataRoomModel>() {
protected override fun createQuery(): String = "UPDATE OR ABORT `order_table` SET `id` = ?,`sale_id` = ?,`productId` = ?,`productName` = ?,`productPrice` = ?,`qty` = ?,`productImage` = ? WHERE `id` = ?"
protected override fun bind(statement: SQLiteStatement, entity: OrderDataRoomModel) {
statement.bindLong(1, entity.id)
statement.bindLong(2, entity.saleId)
statement.bindLong(3, entity.productId)
statement.bindText(4, entity.productName)
statement.bindDouble(5, entity.productPrice)
statement.bindDouble(6, entity.qty)
statement.bindText(7, entity.productImage)
statement.bindLong(8, entity.id)
}
}
}
public override fun saveOrder(order: OrderDataRoomModel): Unit = performBlocking(__db, false, true) { _connection ->
__insertAdapterOfOrderDataRoomModel.insert(_connection, order)
}
public override suspend fun updateOrder(order: OrderDataRoomModel): Unit = performSuspending(__db, false, true) { _connection ->
__updateAdapterOfOrderDataRoomModel.handle(_connection, order)
}
public override fun getOrderById(id: Int): OrderDataRoomModel {
val _sql: String = "SELECT * FROM order_table WHERE id = ?"
return performBlocking(__db, true, false) { _connection ->
val _stmt: SQLiteStatement = _connection.prepare(_sql)
try {
var _argIndex: Int = 1
_stmt.bindLong(_argIndex, id.toLong())
val _columnIndexOfId: Int = getColumnIndexOrThrow(_stmt, "id")
val _columnIndexOfSaleId: Int = getColumnIndexOrThrow(_stmt, "sale_id")
val _columnIndexOfProductId: Int = getColumnIndexOrThrow(_stmt, "productId")
val _columnIndexOfProductName: Int = getColumnIndexOrThrow(_stmt, "productName")
val _columnIndexOfProductPrice: Int = getColumnIndexOrThrow(_stmt, "productPrice")
val _columnIndexOfQty: Int = getColumnIndexOrThrow(_stmt, "qty")
val _columnIndexOfProductImage: Int = getColumnIndexOrThrow(_stmt, "productImage")
val _result: OrderDataRoomModel
if (_stmt.step()) {
val _tmpId: Long
_tmpId = _stmt.getLong(_columnIndexOfId)
val _tmpSaleId: Long
_tmpSaleId = _stmt.getLong(_columnIndexOfSaleId)
val _tmpProductId: Long
_tmpProductId = _stmt.getLong(_columnIndexOfProductId)
val _tmpProductName: String
_tmpProductName = _stmt.getText(_columnIndexOfProductName)
val _tmpProductPrice: Double
_tmpProductPrice = _stmt.getDouble(_columnIndexOfProductPrice)
val _tmpQty: Double
_tmpQty = _stmt.getDouble(_columnIndexOfQty)
val _tmpProductImage: String
_tmpProductImage = _stmt.getText(_columnIndexOfProductImage)
_result = OrderDataRoomModel(_tmpId,_tmpSaleId,_tmpProductId,_tmpProductName,_tmpProductPrice,_tmpQty,_tmpProductImage)
} else {
error("The query result was empty, but expected a single row to return a NON-NULL object of type 'com.imecatro.demosales.`data`.sales.model.OrderDataRoomModel'.")
}
_result
} finally {
_stmt.close()
}
}
}
public override suspend fun getListOfProductsBySaleId(id: Long): List<OrderDataRoomModel> {
val _sql: String = "SELECT * FROM order_table WHERE sale_id = ?"
return performSuspending(__db, true, false) { _connection ->
val _stmt: SQLiteStatement = _connection.prepare(_sql)
try {
var _argIndex: Int = 1
_stmt.bindLong(_argIndex, id)
val _columnIndexOfId: Int = getColumnIndexOrThrow(_stmt, "id")
val _columnIndexOfSaleId: Int = getColumnIndexOrThrow(_stmt, "sale_id")
val _columnIndexOfProductId: Int = getColumnIndexOrThrow(_stmt, "productId")
val _columnIndexOfProductName: Int = getColumnIndexOrThrow(_stmt, "productName")
val _columnIndexOfProductPrice: Int = getColumnIndexOrThrow(_stmt, "productPrice")
val _columnIndexOfQty: Int = getColumnIndexOrThrow(_stmt, "qty")
val _columnIndexOfProductImage: Int = getColumnIndexOrThrow(_stmt, "productImage")
val _result: MutableList<OrderDataRoomModel> = mutableListOf()
while (_stmt.step()) {
val _item: OrderDataRoomModel
val _tmpId: Long
_tmpId = _stmt.getLong(_columnIndexOfId)
val _tmpSaleId: Long
_tmpSaleId = _stmt.getLong(_columnIndexOfSaleId)
val _tmpProductId: Long
_tmpProductId = _stmt.getLong(_columnIndexOfProductId)
val _tmpProductName: String
_tmpProductName = _stmt.getText(_columnIndexOfProductName)
val _tmpProductPrice: Double
_tmpProductPrice = _stmt.getDouble(_columnIndexOfProductPrice)
val _tmpQty: Double
_tmpQty = _stmt.getDouble(_columnIndexOfQty)
val _tmpProductImage: String
_tmpProductImage = _stmt.getText(_columnIndexOfProductImage)
_item = OrderDataRoomModel(_tmpId,_tmpSaleId,_tmpProductId,_tmpProductName,_tmpProductPrice,_tmpQty,_tmpProductImage)
_result.add(_item)
}
_result
} finally {
_stmt.close()
}
}
}
public override fun getListOfProductsOnSaleWithId(id: Long): Flow<List<OrderDataRoomModel>> {
val _sql: String = "SELECT * FROM order_table WHERE sale_id = ?"
return createFlow(__db, false, arrayOf("order_table")) { _connection ->
val _stmt: SQLiteStatement = _connection.prepare(_sql)
try {
var _argIndex: Int = 1
_stmt.bindLong(_argIndex, id)
val _columnIndexOfId: Int = getColumnIndexOrThrow(_stmt, "id")
val _columnIndexOfSaleId: Int = getColumnIndexOrThrow(_stmt, "sale_id")
val _columnIndexOfProductId: Int = getColumnIndexOrThrow(_stmt, "productId")
val _columnIndexOfProductName: Int = getColumnIndexOrThrow(_stmt, "productName")
val _columnIndexOfProductPrice: Int = getColumnIndexOrThrow(_stmt, "productPrice")
val _columnIndexOfQty: Int = getColumnIndexOrThrow(_stmt, "qty")
val _columnIndexOfProductImage: Int = getColumnIndexOrThrow(_stmt, "productImage")
val _result: MutableList<OrderDataRoomModel> = mutableListOf()
while (_stmt.step()) {
val _item: OrderDataRoomModel
val _tmpId: Long
_tmpId = _stmt.getLong(_columnIndexOfId)
val _tmpSaleId: Long
_tmpSaleId = _stmt.getLong(_columnIndexOfSaleId)
val _tmpProductId: Long
_tmpProductId = _stmt.getLong(_columnIndexOfProductId)
val _tmpProductName: String
_tmpProductName = _stmt.getText(_columnIndexOfProductName)
val _tmpProductPrice: Double
_tmpProductPrice = _stmt.getDouble(_columnIndexOfProductPrice)
val _tmpQty: Double
_tmpQty = _stmt.getDouble(_columnIndexOfQty)
val _tmpProductImage: String
_tmpProductImage = _stmt.getText(_columnIndexOfProductImage)
_item = OrderDataRoomModel(_tmpId,_tmpSaleId,_tmpProductId,_tmpProductName,_tmpProductPrice,_tmpQty,_tmpProductImage)
_result.add(_item)
}
_result
} finally {
_stmt.close()
}
}
}
public override fun calculateTotalForSale(saleId: Long): Double {
val _sql: String = "SELECT SUM(qty * productPrice) FROM order_table WHERE sale_id = ?"
return performBlocking(__db, true, false) { _connection ->
val _stmt: SQLiteStatement = _connection.prepare(_sql)
try {
var _argIndex: Int = 1
_stmt.bindLong(_argIndex, saleId)
val _result: Double
if (_stmt.step()) {
_result = _stmt.getDouble(0)
} else {
_result = 0.0
}
_result
} finally {
_stmt.close()
}
}
}
public override suspend fun getMostPopularProducts(n: Int): List<Long> {
val _sql: String = "SELECT productId FROM order_table GROUP BY productId ORDER BY COUNT(productId) DESC LIMIT ?"
return performSuspending(__db, true, false) { _connection ->
val _stmt: SQLiteStatement = _connection.prepare(_sql)
try {
var _argIndex: Int = 1
_stmt.bindLong(_argIndex, n.toLong())
val _result: MutableList<Long> = mutableListOf()
while (_stmt.step()) {
val _item: Long
_item = _stmt.getLong(0)
_result.add(_item)
}
_result
} finally {
_stmt.close()
}
}
}
public override suspend fun getSaleAmount(saleId: Long): Float? {
val _sql: String = """
|
| SELECT SUM(qty * productPrice)
| FROM order_table
| WHERE sale_id = ?
|""".trimMargin()
return performSuspending(__db, true, false) { _connection ->
val _stmt: SQLiteStatement = _connection.prepare(_sql)
try {
var _argIndex: Int = 1
_stmt.bindLong(_argIndex, saleId)
val _result: Float?
if (_stmt.step()) {
val _tmp: Float?
if (_stmt.isNull(0)) {
_tmp = null
} else {
_tmp = _stmt.getDouble(0).toFloat()
}
_result = _tmp
} else {
_result = null
}
_result
} finally {
_stmt.close()
}
}
}
public override suspend fun updateOrderQty(id: Long, newValue: Double) {
val _sql: String = "UPDATE order_table SET qty = ? WHERE id = ?"
return performSuspending(__db, false, true) { _connection ->
val _stmt: SQLiteStatement = _connection.prepare(_sql)
try {
var _argIndex: Int = 1
_stmt.bindDouble(_argIndex, newValue)
_argIndex = 2
_stmt.bindLong(_argIndex, id)
_stmt.step()
} finally {
_stmt.close()
}
}
}
public override suspend fun deleteOrderById(id: Long) {
val _sql: String = "DELETE FROM order_table WHERE id = ?"
return performSuspending(__db, false, true) { _connection ->
val _stmt: SQLiteStatement = _connection.prepare(_sql)
try {
var _argIndex: Int = 1
_stmt.bindLong(_argIndex, id)
_stmt.step()
} finally {
_stmt.close()
}
}
}
public companion object {
public fun getRequiredConverters(): List<KClass<*>> = emptyList()
}
}