|
|
|
|
@ -7,17 +7,16 @@ import net.pokeranalytics.android.model.filter.QueryType |
|
|
|
|
import net.pokeranalytics.android.ui.view.rowrepresentable.FilterElementRow |
|
|
|
|
import net.pokeranalytics.android.ui.view.rowrepresentable.FilterElementRow.* |
|
|
|
|
import java.util.* |
|
|
|
|
import kotlin.collections.ArrayList |
|
|
|
|
|
|
|
|
|
open class FilterElement() : RealmObject() { |
|
|
|
|
|
|
|
|
|
private constructor(filterName:String, sectionName:String) : this() { |
|
|
|
|
private constructor(filterName: String, sectionName: String) : this() { |
|
|
|
|
this.filterName = filterName |
|
|
|
|
this.sectionName = sectionName |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
constructor(filterElementRows: ArrayList<FilterElementRow>) : this(filterElementRows.first().filterName, filterElementRows.first().filterSectionRow.name) { |
|
|
|
|
val filterName : String = this.filterName ?: throw PokerAnalyticsException.FilterElementUnknownName |
|
|
|
|
val filterName: String = this.filterName ?: throw PokerAnalyticsException.FilterElementUnknownName |
|
|
|
|
this.stringValues = when (QueryType.valueOf(filterName)) { |
|
|
|
|
QueryType.GAME, QueryType.BANKROLL, QueryType.TOURNAMENT_NAME, QueryType.ALL_TOURNAMENT_FEATURES, QueryType.ANY_TOURNAMENT_FEATURES, QueryType.LOCATION -> { |
|
|
|
|
RealmList<String>().apply { |
|
|
|
|
@ -26,6 +25,13 @@ open class FilterElement() : RealmObject() { |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
QueryType.LIMIT, QueryType.TABLE_SIZE -> { |
|
|
|
|
RealmList<String>().apply { |
|
|
|
|
this.addAll(filterElementRows.map { |
|
|
|
|
(it as StaticDataFilterElementRow).id |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else -> null |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -80,31 +86,31 @@ open class FilterElement() : RealmObject() { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
constructor(filterElementRow:FilterElementRow) : this(arrayListOf(filterElementRow)) { |
|
|
|
|
constructor(filterElementRow: FilterElementRow) : this(arrayListOf(filterElementRow)) { |
|
|
|
|
when (filterElementRow) { |
|
|
|
|
is From -> dateValue = filterElementRow.date |
|
|
|
|
is To -> dateValue= filterElementRow.date |
|
|
|
|
is To -> dateValue = filterElementRow.date |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var filterName : String? = null |
|
|
|
|
var sectionName : String? = null |
|
|
|
|
var filterName: String? = null |
|
|
|
|
var sectionName: String? = null |
|
|
|
|
|
|
|
|
|
val queryType : QueryType |
|
|
|
|
val queryType: QueryType |
|
|
|
|
get() = QueryType.valueOf(this.filterName ?: throw PokerAnalyticsException.FilterElementUnknownName) |
|
|
|
|
.apply { |
|
|
|
|
this.updateValueMap(this@FilterElement) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private var numericValues: RealmList<Double>? = null |
|
|
|
|
private var dateValue : Date? = null |
|
|
|
|
private var stringValues : RealmList<String>? = null |
|
|
|
|
private var blindValues : RealmList<FilterElementBlind>? = null |
|
|
|
|
private var dateValue: Date? = null |
|
|
|
|
private var stringValues: RealmList<String>? = null |
|
|
|
|
private var blindValues: RealmList<FilterElementBlind>? = null |
|
|
|
|
|
|
|
|
|
val ids : Array<String> |
|
|
|
|
get() = stringValues?.toTypedArray()?: throw PokerAnalyticsException.FilterElementExpectedValueMissing |
|
|
|
|
val ids: Array<String> |
|
|
|
|
get() = stringValues?.toTypedArray() ?: throw PokerAnalyticsException.FilterElementExpectedValueMissing |
|
|
|
|
|
|
|
|
|
val blinds : RealmList<FilterElementBlind> |
|
|
|
|
val blinds: RealmList<FilterElementBlind> |
|
|
|
|
get() { |
|
|
|
|
blindValues?.let { |
|
|
|
|
if (it.isNotEmpty()) { |
|
|
|
|
@ -117,37 +123,37 @@ open class FilterElement() : RealmObject() { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val date : Date |
|
|
|
|
get() = dateValue?: throw PokerAnalyticsException.FilterElementExpectedValueMissing |
|
|
|
|
val date: Date |
|
|
|
|
get() = dateValue ?: throw PokerAnalyticsException.FilterElementExpectedValueMissing |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val values : Array<Int> |
|
|
|
|
val values: Array<Int> |
|
|
|
|
get() = numericValues?.map { |
|
|
|
|
it.toInt() |
|
|
|
|
}?.toTypedArray()?: throw PokerAnalyticsException.FilterElementExpectedValueMissing |
|
|
|
|
}?.toTypedArray() ?: throw PokerAnalyticsException.FilterElementExpectedValueMissing |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val value : Double |
|
|
|
|
get() = numericValues?.first()?: throw PokerAnalyticsException.FilterElementExpectedValueMissing |
|
|
|
|
val value: Double |
|
|
|
|
get() = numericValues?.first() ?: throw PokerAnalyticsException.FilterElementExpectedValueMissing |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val leftValue : Double |
|
|
|
|
get() = numericValues?.first()?: throw PokerAnalyticsException.FilterElementExpectedValueMissing |
|
|
|
|
val leftValue: Double |
|
|
|
|
get() = numericValues?.first() ?: throw PokerAnalyticsException.FilterElementExpectedValueMissing |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val rightValue : Double |
|
|
|
|
get() = numericValues?.last()?: throw PokerAnalyticsException.FilterElementExpectedValueMissing |
|
|
|
|
val rightValue: Double |
|
|
|
|
get() = numericValues?.last() ?: throw PokerAnalyticsException.FilterElementExpectedValueMissing |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val dayOfWeek : Int |
|
|
|
|
get() = numericValues?.first()?.toInt()?: throw PokerAnalyticsException.FilterElementExpectedValueMissing |
|
|
|
|
val dayOfWeek: Int |
|
|
|
|
get() = numericValues?.first()?.toInt() ?: throw PokerAnalyticsException.FilterElementExpectedValueMissing |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val month : Int |
|
|
|
|
get() = numericValues?.first()?.toInt()?: throw PokerAnalyticsException.FilterElementExpectedValueMissing |
|
|
|
|
val month: Int |
|
|
|
|
get() = numericValues?.first()?.toInt() ?: throw PokerAnalyticsException.FilterElementExpectedValueMissing |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val year : Int |
|
|
|
|
get() = numericValues?.first()?.toInt()?: throw PokerAnalyticsException.FilterElementExpectedValueMissing |
|
|
|
|
val year: Int |
|
|
|
|
get() = numericValues?.first()?.toInt() ?: throw PokerAnalyticsException.FilterElementExpectedValueMissing |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|