|
|
|
|
@ -18,16 +18,24 @@ open class FilterCondition() : RealmObject() { |
|
|
|
|
constructor(filterElementRows: ArrayList<FilterElementRow>) : this(filterElementRows.first().filterName, filterElementRows.first().filterSectionRow.name) { |
|
|
|
|
val filterName : String = this.filterName ?: throw PokerAnalyticsException.FilterElementUnknownName |
|
|
|
|
this.stringValues = when (QueryCondition.valueOf(filterName)) { |
|
|
|
|
QueryCondition.GAME, QueryCondition.BANKROLL, QueryCondition.TOURNAMENT_NAME, QueryCondition.ALL_TOURNAMENT_FEATURES, QueryCondition.ANY_TOURNAMENT_FEATURES, QueryCondition.LOCATION -> { |
|
|
|
|
RealmList<String>().apply { |
|
|
|
|
this.addAll(filterElementRows.map { |
|
|
|
|
(it as DataFilterElementRow).id |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else -> null |
|
|
|
|
QueryCondition.GAME, QueryCondition.BANKROLL, QueryCondition.TOURNAMENT_NAME, QueryCondition.ALL_TOURNAMENT_FEATURES, QueryCondition.ANY_TOURNAMENT_FEATURES, QueryCondition.LOCATION -> { |
|
|
|
|
RealmList<String>().apply { |
|
|
|
|
this.addAll(filterElementRows.map { |
|
|
|
|
(it as DataFilterElementRow).id |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
QueryCondition.LIMIT, QueryCondition.TABLE_SIZE -> { |
|
|
|
|
RealmList<String>().apply { |
|
|
|
|
this.addAll(filterElementRows.map { |
|
|
|
|
(it as StaticDataFilterElementRow).id |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else -> null |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.numericValues = when (QueryCondition.valueOf(filterName)) { |
|
|
|
|
QueryCondition.LIMIT -> { |
|
|
|
|
RealmList<Double>().apply { |
|
|
|
|
@ -79,15 +87,15 @@ open class FilterCondition() : RealmObject() { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
constructor(filterElementRow:FilterElementRow) : this(arrayListOf(filterElementRow)) { |
|
|
|
|
when (filterElementRow) { |
|
|
|
|
is From -> dateValue = filterElementRow.date |
|
|
|
|
is To -> dateValue= filterElementRow.date |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
constructor(filterElementRow: FilterElementRow) : this(arrayListOf(filterElementRow)) { |
|
|
|
|
when (filterElementRow) { |
|
|
|
|
is From -> 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 queryCondition : QueryCondition |
|
|
|
|
get() = QueryCondition.valueOf(this.filterName ?: throw PokerAnalyticsException.FilterElementUnknownName) |
|
|
|
|
@ -95,58 +103,58 @@ open class FilterCondition() : RealmObject() { |
|
|
|
|
this.updateValueMap(this@FilterCondition) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private var numericValues: RealmList<Double>? = 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 blinds : RealmList<FilterElementBlind> |
|
|
|
|
get() { |
|
|
|
|
blindValues?.let { |
|
|
|
|
if (it.isNotEmpty()) { |
|
|
|
|
return it |
|
|
|
|
} else { |
|
|
|
|
throw PokerAnalyticsException.FilterElementExpectedValueMissing |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
throw PokerAnalyticsException.FilterElementExpectedValueMissing |
|
|
|
|
} |
|
|
|
|
private var numericValues: RealmList<Double>? = 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 blinds: RealmList<FilterElementBlind> |
|
|
|
|
get() { |
|
|
|
|
blindValues?.let { |
|
|
|
|
if (it.isNotEmpty()) { |
|
|
|
|
return it |
|
|
|
|
} else { |
|
|
|
|
throw PokerAnalyticsException.FilterElementExpectedValueMissing |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
throw PokerAnalyticsException.FilterElementExpectedValueMissing |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val date : Date |
|
|
|
|
get() = dateValue?: throw PokerAnalyticsException.FilterElementExpectedValueMissing |
|
|
|
|
val date: Date |
|
|
|
|
get() = dateValue ?: throw PokerAnalyticsException.FilterElementExpectedValueMissing |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val values : Array<Int> |
|
|
|
|
get() = numericValues?.map { |
|
|
|
|
it.toInt() |
|
|
|
|
}?.toTypedArray()?: throw PokerAnalyticsException.FilterElementExpectedValueMissing |
|
|
|
|
val values: Array<Int> |
|
|
|
|
get() = numericValues?.map { |
|
|
|
|
it.toInt() |
|
|
|
|
}?.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 |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|