|
|
|
@ -36,9 +36,17 @@ import kotlin.collections.ArrayList |
|
|
|
sealed class QueryCondition : FilterElementRow { |
|
|
|
sealed class QueryCondition : FilterElementRow { |
|
|
|
|
|
|
|
|
|
|
|
companion object { |
|
|
|
companion object { |
|
|
|
inline fun < reified T:QueryCondition> more():T { return T::class.java.newInstance().apply { this.operator = Operator.MORE } } |
|
|
|
inline fun <reified T : QueryCondition> more(): T { |
|
|
|
inline fun < reified T:QueryCondition> less():T { return T::class.java.newInstance().apply { this.operator = Operator.LESS } } |
|
|
|
return T::class.java.newInstance().apply { this.operator = Operator.MORE } |
|
|
|
inline fun < reified T:QueryCondition> moreOrLess():ArrayList<T> { return arrayListOf(more(), less()) } |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline fun <reified T : QueryCondition> less(): T { |
|
|
|
|
|
|
|
return T::class.java.newInstance().apply { this.operator = Operator.LESS } |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline fun <reified T : QueryCondition> moreOrLess(): ArrayList<T> { |
|
|
|
|
|
|
|
return arrayListOf(more(), less()) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fun <T : QueryCondition> valueOf(name: String): T { |
|
|
|
fun <T : QueryCondition> valueOf(name: String): T { |
|
|
|
val kClass = Class.forName("${QueryCondition::class.qualifiedName}$$name").kotlin |
|
|
|
val kClass = Class.forName("${QueryCondition::class.qualifiedName}$$name").kotlin |
|
|
|
@ -94,7 +102,8 @@ sealed class QueryCondition : FilterElementRow { |
|
|
|
return baseId |
|
|
|
return baseId |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
val id: List<String> get() { |
|
|
|
val id: List<String> |
|
|
|
|
|
|
|
get() { |
|
|
|
when (this.operator) { |
|
|
|
when (this.operator) { |
|
|
|
Operator.MORE, Operator.LESS -> return listOf("$baseId+${this.operator.name}") |
|
|
|
Operator.MORE, Operator.LESS -> return listOf("$baseId+${this.operator.name}") |
|
|
|
} |
|
|
|
} |
|
|
|
@ -102,7 +111,9 @@ sealed class QueryCondition : FilterElementRow { |
|
|
|
return when (this) { |
|
|
|
return when (this) { |
|
|
|
is SingleValue<*> -> listOf(baseId) |
|
|
|
is SingleValue<*> -> listOf(baseId) |
|
|
|
is ListOfValues<*> -> { |
|
|
|
is ListOfValues<*> -> { |
|
|
|
if (listOfValues.isEmpty()) { return listOf(baseId) } |
|
|
|
if (listOfValues.isEmpty()) { |
|
|
|
|
|
|
|
return listOf(baseId) |
|
|
|
|
|
|
|
} |
|
|
|
this.listOfValues.map { "$baseId+$it" } |
|
|
|
this.listOfValues.map { "$baseId+$it" } |
|
|
|
} |
|
|
|
} |
|
|
|
else -> listOf(baseId) |
|
|
|
else -> listOf(baseId) |
|
|
|
@ -154,6 +165,7 @@ sealed class QueryCondition : FilterElementRow { |
|
|
|
super.updateValueBy(filterCondition) |
|
|
|
super.updateValueBy(filterCondition) |
|
|
|
listOfValues = filterCondition.getValues() |
|
|
|
listOfValues = filterCondition.getValues() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun labelForValue(value: Double, context: Context): String { |
|
|
|
override fun labelForValue(value: Double, context: Context): String { |
|
|
|
return value.toCurrency(UserDefaults.currency) |
|
|
|
return value.toCurrency(UserDefaults.currency) |
|
|
|
} |
|
|
|
} |
|
|
|
@ -166,6 +178,7 @@ sealed class QueryCondition : FilterElementRow { |
|
|
|
super.updateValueBy(filterCondition) |
|
|
|
super.updateValueBy(filterCondition) |
|
|
|
listOfValues = filterCondition.getValues() |
|
|
|
listOfValues = filterCondition.getValues() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun labelForValue(value: Int, context: Context): String { |
|
|
|
override fun labelForValue(value: Int, context: Context): String { |
|
|
|
return value.toString() |
|
|
|
return value.toString() |
|
|
|
} |
|
|
|
} |
|
|
|
@ -174,7 +187,10 @@ sealed class QueryCondition : FilterElementRow { |
|
|
|
abstract class ListOfString : ListOfValues<String>() { |
|
|
|
abstract class ListOfString : ListOfValues<String>() { |
|
|
|
override var operator: Operator = Operator.ANY |
|
|
|
override var operator: Operator = Operator.ANY |
|
|
|
override var listOfValues = ArrayList<String>() |
|
|
|
override var listOfValues = ArrayList<String>() |
|
|
|
override fun labelForValue(value: String, context: Context): String { return value } |
|
|
|
override fun labelForValue(value: String, context: Context): String { |
|
|
|
|
|
|
|
return value |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun updateValueBy(filterCondition: FilterCondition) { |
|
|
|
override fun updateValueBy(filterCondition: FilterCondition) { |
|
|
|
super.updateValueBy(filterCondition) |
|
|
|
super.updateValueBy(filterCondition) |
|
|
|
listOfValues = filterCondition.getValues() |
|
|
|
listOfValues = filterCondition.getValues() |
|
|
|
@ -189,7 +205,9 @@ sealed class QueryCondition : FilterElementRow { |
|
|
|
override var listOfValues = ArrayList<Date>() |
|
|
|
override var listOfValues = ArrayList<Date>() |
|
|
|
|
|
|
|
|
|
|
|
override var singleValue: Date? |
|
|
|
override var singleValue: Date? |
|
|
|
get() { return listOfValues.firstOrNull() } |
|
|
|
get() { |
|
|
|
|
|
|
|
return listOfValues.firstOrNull() |
|
|
|
|
|
|
|
} |
|
|
|
set(value) { |
|
|
|
set(value) { |
|
|
|
listOfValues.removeAll(this.listOfValues) |
|
|
|
listOfValues.removeAll(this.listOfValues) |
|
|
|
value?.let { listOfValues.add(it) } |
|
|
|
value?.let { listOfValues.add(it) } |
|
|
|
@ -207,7 +225,9 @@ sealed class QueryCondition : FilterElementRow { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override var singleValue: Int? |
|
|
|
override var singleValue: Int? |
|
|
|
get() { return listOfValues.firstOrNull() } |
|
|
|
get() { |
|
|
|
|
|
|
|
return listOfValues.firstOrNull() |
|
|
|
|
|
|
|
} |
|
|
|
set(value) { |
|
|
|
set(value) { |
|
|
|
listOfValues.removeAll(this.listOfValues) |
|
|
|
listOfValues.removeAll(this.listOfValues) |
|
|
|
value?.let { listOfValues.add(it) } |
|
|
|
value?.let { listOfValues.add(it) } |
|
|
|
@ -297,6 +317,7 @@ sealed class QueryCondition : FilterElementRow { |
|
|
|
|
|
|
|
|
|
|
|
class AnyBankroll() : QueryDataCondition<Bankroll>() { |
|
|
|
class AnyBankroll() : QueryDataCondition<Bankroll>() { |
|
|
|
override var entity: Class<Bankroll> = Bankroll::class.java |
|
|
|
override var entity: Class<Bankroll> = Bankroll::class.java |
|
|
|
|
|
|
|
|
|
|
|
constructor(bankroll: Bankroll) : this() { |
|
|
|
constructor(bankroll: Bankroll) : this() { |
|
|
|
this.setObject(bankroll) |
|
|
|
this.setObject(bankroll) |
|
|
|
} |
|
|
|
} |
|
|
|
@ -304,6 +325,7 @@ sealed class QueryCondition : FilterElementRow { |
|
|
|
|
|
|
|
|
|
|
|
class AnyGame() : QueryDataCondition<Game>() { |
|
|
|
class AnyGame() : QueryDataCondition<Game>() { |
|
|
|
override val entity: Class<Game> = Game::class.java |
|
|
|
override val entity: Class<Game> = Game::class.java |
|
|
|
|
|
|
|
|
|
|
|
constructor(game: Game) : this() { |
|
|
|
constructor(game: Game) : this() { |
|
|
|
this.setObject(game) |
|
|
|
this.setObject(game) |
|
|
|
} |
|
|
|
} |
|
|
|
@ -311,6 +333,7 @@ sealed class QueryCondition : FilterElementRow { |
|
|
|
|
|
|
|
|
|
|
|
class AnyTournamentName() : QueryDataCondition<TournamentName>() { |
|
|
|
class AnyTournamentName() : QueryDataCondition<TournamentName>() { |
|
|
|
override val entity: Class<TournamentName> = TournamentName::class.java |
|
|
|
override val entity: Class<TournamentName> = TournamentName::class.java |
|
|
|
|
|
|
|
|
|
|
|
constructor(tournamentName: TournamentName) : this() { |
|
|
|
constructor(tournamentName: TournamentName) : this() { |
|
|
|
this.setObject(tournamentName) |
|
|
|
this.setObject(tournamentName) |
|
|
|
} |
|
|
|
} |
|
|
|
@ -318,6 +341,7 @@ sealed class QueryCondition : FilterElementRow { |
|
|
|
|
|
|
|
|
|
|
|
class AnyTournamentFeature() : QueryDataCondition<TournamentFeature>() { |
|
|
|
class AnyTournamentFeature() : QueryDataCondition<TournamentFeature>() { |
|
|
|
override val entity: Class<TournamentFeature> = TournamentFeature::class.java |
|
|
|
override val entity: Class<TournamentFeature> = TournamentFeature::class.java |
|
|
|
|
|
|
|
|
|
|
|
constructor(tournamentFeature: TournamentFeature) : this() { |
|
|
|
constructor(tournamentFeature: TournamentFeature) : this() { |
|
|
|
this.setObject(tournamentFeature) |
|
|
|
this.setObject(tournamentFeature) |
|
|
|
} |
|
|
|
} |
|
|
|
@ -326,6 +350,7 @@ sealed class QueryCondition : FilterElementRow { |
|
|
|
class AllTournamentFeature() : QueryDataCondition<TournamentFeature>() { |
|
|
|
class AllTournamentFeature() : QueryDataCondition<TournamentFeature>() { |
|
|
|
override var operator = Operator.ALL |
|
|
|
override var operator = Operator.ALL |
|
|
|
override val entity: Class<TournamentFeature> = TournamentFeature::class.java |
|
|
|
override val entity: Class<TournamentFeature> = TournamentFeature::class.java |
|
|
|
|
|
|
|
|
|
|
|
constructor(tournamentFeature: TournamentFeature) : this() { |
|
|
|
constructor(tournamentFeature: TournamentFeature) : this() { |
|
|
|
this.setObject(tournamentFeature) |
|
|
|
this.setObject(tournamentFeature) |
|
|
|
} |
|
|
|
} |
|
|
|
@ -333,6 +358,7 @@ sealed class QueryCondition : FilterElementRow { |
|
|
|
|
|
|
|
|
|
|
|
class AnyLocation() : QueryDataCondition<Location>() { |
|
|
|
class AnyLocation() : QueryDataCondition<Location>() { |
|
|
|
override val entity: Class<Location> = Location::class.java |
|
|
|
override val entity: Class<Location> = Location::class.java |
|
|
|
|
|
|
|
|
|
|
|
constructor(location: Location) : this() { |
|
|
|
constructor(location: Location) : this() { |
|
|
|
this.setObject(location) |
|
|
|
this.setObject(location) |
|
|
|
} |
|
|
|
} |
|
|
|
@ -340,6 +366,7 @@ sealed class QueryCondition : FilterElementRow { |
|
|
|
|
|
|
|
|
|
|
|
class AnyTransactionType() : QueryDataCondition<TransactionType>() { |
|
|
|
class AnyTransactionType() : QueryDataCondition<TransactionType>() { |
|
|
|
override val entity: Class<TransactionType> = TransactionType::class.java |
|
|
|
override val entity: Class<TransactionType> = TransactionType::class.java |
|
|
|
|
|
|
|
|
|
|
|
constructor(transactionType: TransactionType) : this() { |
|
|
|
constructor(transactionType: TransactionType) : this() { |
|
|
|
this.setObject(transactionType) |
|
|
|
this.setObject(transactionType) |
|
|
|
} |
|
|
|
} |
|
|
|
@ -413,7 +440,9 @@ sealed class QueryCondition : FilterElementRow { |
|
|
|
open class NetAmount : ListOfDouble() |
|
|
|
open class NetAmount : ListOfDouble() |
|
|
|
|
|
|
|
|
|
|
|
class NetAmountWon : NetAmount() |
|
|
|
class NetAmountWon : NetAmount() |
|
|
|
class NetAmountLost: NetAmount() { override var sign: Int = -1 } |
|
|
|
class NetAmountLost : NetAmount() { |
|
|
|
|
|
|
|
override var sign: Int = -1 |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
class TournamentNumberOfPlayer : ListOfInt() { |
|
|
|
class TournamentNumberOfPlayer : ListOfInt() { |
|
|
|
override fun labelForValue(value: Int, context: Context): String { |
|
|
|
override fun labelForValue(value: Int, context: Context): String { |
|
|
|
@ -425,10 +454,21 @@ sealed class QueryCondition : FilterElementRow { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
class StartedFromDate: DateQuery() { override var operator = Operator.MORE } |
|
|
|
class StartedFromDate : DateQuery() { |
|
|
|
class StartedToDate: DateQuery() { override var operator = Operator.LESS } |
|
|
|
override var operator = Operator.MORE |
|
|
|
class EndedFromDate: DateQuery() { override var operator = Operator.MORE } |
|
|
|
} |
|
|
|
class EndedToDate: DateQuery() { override var operator = Operator.LESS } |
|
|
|
|
|
|
|
|
|
|
|
class StartedToDate : DateQuery() { |
|
|
|
|
|
|
|
override var operator = Operator.LESS |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class EndedFromDate : DateQuery() { |
|
|
|
|
|
|
|
override var operator = Operator.MORE |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class EndedToDate : DateQuery() { |
|
|
|
|
|
|
|
override var operator = Operator.LESS |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
class AnyDayOfWeek : ListOfInt() { |
|
|
|
class AnyDayOfWeek : ListOfInt() { |
|
|
|
override fun labelForValue(value: Int, context: Context): String { |
|
|
|
override fun labelForValue(value: Int, context: Context): String { |
|
|
|
@ -489,8 +529,12 @@ sealed class QueryCondition : FilterElementRow { |
|
|
|
class Duration : SingleInt() { |
|
|
|
class Duration : SingleInt() { |
|
|
|
override var operator = Operator.EQUALS |
|
|
|
override var operator = Operator.EQUALS |
|
|
|
var minutes: Int? |
|
|
|
var minutes: Int? |
|
|
|
get() { return singleValue } |
|
|
|
get() { |
|
|
|
set(value) { singleValue = value } |
|
|
|
return singleValue |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
set(value) { |
|
|
|
|
|
|
|
singleValue = value |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
val netDuration: Long? |
|
|
|
val netDuration: Long? |
|
|
|
get() { |
|
|
|
get() { |
|
|
|
@ -510,6 +554,7 @@ sealed class QueryCondition : FilterElementRow { |
|
|
|
|
|
|
|
|
|
|
|
class StartedFromTime() : TimeQuery() { |
|
|
|
class StartedFromTime() : TimeQuery() { |
|
|
|
override var operator = Operator.MORE |
|
|
|
override var operator = Operator.MORE |
|
|
|
|
|
|
|
|
|
|
|
constructor(date: Date) : this() { |
|
|
|
constructor(date: Date) : this() { |
|
|
|
singleValue = date |
|
|
|
singleValue = date |
|
|
|
} |
|
|
|
} |
|
|
|
@ -519,6 +564,7 @@ sealed class QueryCondition : FilterElementRow { |
|
|
|
|
|
|
|
|
|
|
|
class EndedToTime() : TimeQuery() { |
|
|
|
class EndedToTime() : TimeQuery() { |
|
|
|
override var operator = Operator.LESS |
|
|
|
override var operator = Operator.LESS |
|
|
|
|
|
|
|
|
|
|
|
constructor(date: Date) : this() { |
|
|
|
constructor(date: Date) : this() { |
|
|
|
singleValue = date |
|
|
|
singleValue = date |
|
|
|
} |
|
|
|
} |
|
|
|
@ -539,14 +585,17 @@ sealed class QueryCondition : FilterElementRow { |
|
|
|
|
|
|
|
|
|
|
|
class CustomFieldQuery() : QueryDataCondition<CustomField>() { |
|
|
|
class CustomFieldQuery() : QueryDataCondition<CustomField>() { |
|
|
|
override var entity: Class<CustomField> = CustomField::class.java |
|
|
|
override var entity: Class<CustomField> = CustomField::class.java |
|
|
|
|
|
|
|
|
|
|
|
constructor(customField: CustomField) : this() { |
|
|
|
constructor(customField: CustomField) : this() { |
|
|
|
this.setObject(customField) |
|
|
|
this.setObject(customField) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
open class CustomFieldNumberQuery() : ListOfDouble(), CustomFieldRelated { |
|
|
|
open class CustomFieldNumberQuery() : ListOfDouble(), CustomFieldRelated { |
|
|
|
|
|
|
|
|
|
|
|
override var customFieldId: String = "" |
|
|
|
override var customFieldId: String = "" |
|
|
|
override var operator: Operator = Operator.EQUALS |
|
|
|
override var operator: Operator = Operator.EQUALS |
|
|
|
|
|
|
|
|
|
|
|
constructor(customFieldId: String, value: Double) : this() { |
|
|
|
constructor(customFieldId: String, value: Double) : this() { |
|
|
|
this.listOfValues = arrayListOf(value) |
|
|
|
this.listOfValues = arrayListOf(value) |
|
|
|
this.customFieldId = customFieldId |
|
|
|
this.customFieldId = customFieldId |
|
|
|
@ -590,9 +639,11 @@ sealed class QueryCondition : FilterElementRow { |
|
|
|
class CustomFieldListQuery() : QueryDataCondition<CustomFieldEntry>(), CustomFieldRelated { |
|
|
|
class CustomFieldListQuery() : QueryDataCondition<CustomFieldEntry>(), CustomFieldRelated { |
|
|
|
override var entity: Class<CustomFieldEntry> = CustomFieldEntry::class.java |
|
|
|
override var entity: Class<CustomFieldEntry> = CustomFieldEntry::class.java |
|
|
|
override var customFieldId: String = "" |
|
|
|
override var customFieldId: String = "" |
|
|
|
|
|
|
|
|
|
|
|
constructor(customFieldEntry: CustomFieldEntry) : this() { |
|
|
|
constructor(customFieldEntry: CustomFieldEntry) : this() { |
|
|
|
this.setObject(customFieldEntry) |
|
|
|
this.setObject(customFieldEntry) |
|
|
|
this.customFieldId = customFieldEntry.customField?.id ?: throw PokerAnalyticsException.QueryValueMapUnexpectedValue |
|
|
|
this.customFieldId = |
|
|
|
|
|
|
|
customFieldEntry.customField?.id ?: throw PokerAnalyticsException.QueryValueMapUnexpectedValue |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun entityName(realm: Realm): String { |
|
|
|
override fun entityName(realm: Realm): String { |
|
|
|
@ -610,7 +661,10 @@ sealed class QueryCondition : FilterElementRow { |
|
|
|
* main method of the enum |
|
|
|
* main method of the enum |
|
|
|
* providing a base RealmQuery [realmQuery], the method is able to attached the corresponding query and returns the newly formed [RealmQuery] |
|
|
|
* providing a base RealmQuery [realmQuery], the method is able to attached the corresponding query and returns the newly formed [RealmQuery] |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
inline fun <reified T : Filterable> queryWith(realmQuery: RealmQuery<T>, otherQueryCondition:QueryCondition? = null): RealmQuery<T> { |
|
|
|
inline fun <reified T : Filterable> queryWith( |
|
|
|
|
|
|
|
realmQuery: RealmQuery<T>, |
|
|
|
|
|
|
|
otherQueryCondition: QueryCondition? = null |
|
|
|
|
|
|
|
): RealmQuery<T> { |
|
|
|
val fieldName = FilterHelper.fieldNameForQueryType<T>(this::class.java) |
|
|
|
val fieldName = FilterHelper.fieldNameForQueryType<T>(this::class.java) |
|
|
|
if (BuildConfig.DEBUG) { |
|
|
|
if (BuildConfig.DEBUG) { |
|
|
|
fieldName ?: throw PokerAnalyticsException.QueryValueMapUnknown |
|
|
|
fieldName ?: throw PokerAnalyticsException.QueryValueMapUnknown |
|
|
|
@ -633,20 +687,23 @@ sealed class QueryCondition : FilterElementRow { |
|
|
|
} |
|
|
|
} |
|
|
|
is IsToday -> { |
|
|
|
is IsToday -> { |
|
|
|
val startDate = Date() |
|
|
|
val startDate = Date() |
|
|
|
return realmQuery.greaterThanOrEqualTo(fieldName, startDate.startOfDay()).and().lessThanOrEqualTo(fieldName, startDate.endOfDay()) |
|
|
|
return realmQuery.greaterThanOrEqualTo(fieldName, startDate.startOfDay()).and() |
|
|
|
|
|
|
|
.lessThanOrEqualTo(fieldName, startDate.endOfDay()) |
|
|
|
} |
|
|
|
} |
|
|
|
is WasTodayAndYesterday -> { |
|
|
|
is WasTodayAndYesterday -> { |
|
|
|
val startDate = Date() |
|
|
|
val startDate = Date() |
|
|
|
val calendar = Calendar.getInstance() |
|
|
|
val calendar = Calendar.getInstance() |
|
|
|
calendar.time = startDate |
|
|
|
calendar.time = startDate |
|
|
|
calendar.add(Calendar.HOUR_OF_DAY, -24) |
|
|
|
calendar.add(Calendar.HOUR_OF_DAY, -24) |
|
|
|
return realmQuery.greaterThanOrEqualTo(fieldName, calendar.time.startOfDay()).and().lessThanOrEqualTo(fieldName, startDate.endOfDay()) |
|
|
|
return realmQuery.greaterThanOrEqualTo(fieldName, calendar.time.startOfDay()).and() |
|
|
|
|
|
|
|
.lessThanOrEqualTo(fieldName, startDate.endOfDay()) |
|
|
|
} |
|
|
|
} |
|
|
|
is WasYesterday -> { |
|
|
|
is WasYesterday -> { |
|
|
|
val calendar = Calendar.getInstance() |
|
|
|
val calendar = Calendar.getInstance() |
|
|
|
calendar.time = Date() |
|
|
|
calendar.time = Date() |
|
|
|
calendar.add(Calendar.HOUR_OF_DAY, -24) |
|
|
|
calendar.add(Calendar.HOUR_OF_DAY, -24) |
|
|
|
return realmQuery.greaterThanOrEqualTo(fieldName, calendar.time.startOfDay()).and().lessThanOrEqualTo(fieldName, calendar.time.endOfDay()) |
|
|
|
return realmQuery.greaterThanOrEqualTo(fieldName, calendar.time.startOfDay()).and() |
|
|
|
|
|
|
|
.lessThanOrEqualTo(fieldName, calendar.time.endOfDay()) |
|
|
|
} |
|
|
|
} |
|
|
|
is PastDay -> { |
|
|
|
is PastDay -> { |
|
|
|
singleValue?.let { |
|
|
|
singleValue?.let { |
|
|
|
@ -654,7 +711,8 @@ sealed class QueryCondition : FilterElementRow { |
|
|
|
val calendar = Calendar.getInstance() |
|
|
|
val calendar = Calendar.getInstance() |
|
|
|
calendar.time = startDate |
|
|
|
calendar.time = startDate |
|
|
|
calendar.add(Calendar.DAY_OF_YEAR, -it) |
|
|
|
calendar.add(Calendar.DAY_OF_YEAR, -it) |
|
|
|
return realmQuery.greaterThanOrEqualTo(fieldName, calendar.time.startOfDay()).and().lessThanOrEqualTo(fieldName, startDate.endOfDay()) |
|
|
|
return realmQuery.greaterThanOrEqualTo(fieldName, calendar.time.startOfDay()).and() |
|
|
|
|
|
|
|
.lessThanOrEqualTo(fieldName, startDate.endOfDay()) |
|
|
|
} |
|
|
|
} |
|
|
|
return realmQuery |
|
|
|
return realmQuery |
|
|
|
} |
|
|
|
} |
|
|
|
@ -663,21 +721,24 @@ sealed class QueryCondition : FilterElementRow { |
|
|
|
val calendar = Calendar.getInstance() |
|
|
|
val calendar = Calendar.getInstance() |
|
|
|
calendar.time = startDate |
|
|
|
calendar.time = startDate |
|
|
|
calendar.set(Calendar.DAY_OF_WEEK_IN_MONTH, Calendar.SUNDAY) |
|
|
|
calendar.set(Calendar.DAY_OF_WEEK_IN_MONTH, Calendar.SUNDAY) |
|
|
|
return realmQuery.greaterThanOrEqualTo(fieldName, calendar.time.startOfDay()).and().lessThanOrEqualTo(fieldName, startDate.endOfDay()) |
|
|
|
return realmQuery.greaterThanOrEqualTo(fieldName, calendar.time.startOfDay()).and() |
|
|
|
|
|
|
|
.lessThanOrEqualTo(fieldName, startDate.endOfDay()) |
|
|
|
} |
|
|
|
} |
|
|
|
is DuringThisMonth -> { |
|
|
|
is DuringThisMonth -> { |
|
|
|
val startDate = Date() |
|
|
|
val startDate = Date() |
|
|
|
val calendar = Calendar.getInstance() |
|
|
|
val calendar = Calendar.getInstance() |
|
|
|
calendar.time = startDate |
|
|
|
calendar.time = startDate |
|
|
|
calendar.set(Calendar.DAY_OF_MONTH, 1) |
|
|
|
calendar.set(Calendar.DAY_OF_MONTH, 1) |
|
|
|
return realmQuery.greaterThanOrEqualTo(fieldName, calendar.time.startOfDay()).and().lessThanOrEqualTo(fieldName, startDate.endOfDay()) |
|
|
|
return realmQuery.greaterThanOrEqualTo(fieldName, calendar.time.startOfDay()).and() |
|
|
|
|
|
|
|
.lessThanOrEqualTo(fieldName, startDate.endOfDay()) |
|
|
|
} |
|
|
|
} |
|
|
|
is DuringThisYear -> { |
|
|
|
is DuringThisYear -> { |
|
|
|
val startDate = Date() |
|
|
|
val startDate = Date() |
|
|
|
val calendar = Calendar.getInstance() |
|
|
|
val calendar = Calendar.getInstance() |
|
|
|
calendar.time = startDate |
|
|
|
calendar.time = startDate |
|
|
|
calendar.set(Calendar.DAY_OF_YEAR, 1) |
|
|
|
calendar.set(Calendar.DAY_OF_YEAR, 1) |
|
|
|
return realmQuery.greaterThanOrEqualTo(fieldName, calendar.time.startOfDay()).and().lessThanOrEqualTo(fieldName, startDate.endOfDay()) |
|
|
|
return realmQuery.greaterThanOrEqualTo(fieldName, calendar.time.startOfDay()).and() |
|
|
|
|
|
|
|
.lessThanOrEqualTo(fieldName, startDate.endOfDay()) |
|
|
|
} |
|
|
|
} |
|
|
|
is StartedFromTime -> { |
|
|
|
is StartedFromTime -> { |
|
|
|
val calendar = Calendar.getInstance() |
|
|
|
val calendar = Calendar.getInstance() |
|
|
|
@ -727,8 +788,14 @@ sealed class QueryCondition : FilterElementRow { |
|
|
|
return when (operator) { |
|
|
|
return when (operator) { |
|
|
|
Operator.EQUALS -> { |
|
|
|
Operator.EQUALS -> { |
|
|
|
when (this) { |
|
|
|
when (this) { |
|
|
|
is SingleDate -> realmQuery.equalTo(fieldName, singleValue?:throw PokerAnalyticsException.FilterElementExpectedValueMissing) |
|
|
|
is SingleDate -> realmQuery.equalTo( |
|
|
|
is SingleInt -> realmQuery.equalTo(fieldName, singleValue?:throw PokerAnalyticsException.FilterElementExpectedValueMissing) |
|
|
|
fieldName, |
|
|
|
|
|
|
|
singleValue ?: throw PokerAnalyticsException.FilterElementExpectedValueMissing |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
is SingleInt -> realmQuery.equalTo( |
|
|
|
|
|
|
|
fieldName, |
|
|
|
|
|
|
|
singleValue ?: throw PokerAnalyticsException.FilterElementExpectedValueMissing |
|
|
|
|
|
|
|
) |
|
|
|
is ListOfInt -> realmQuery.equalTo(fieldName, listOfValues.first()) |
|
|
|
is ListOfInt -> realmQuery.equalTo(fieldName, listOfValues.first()) |
|
|
|
is ListOfDouble -> realmQuery.equalTo(fieldName, listOfValues.first() * sign) |
|
|
|
is ListOfDouble -> realmQuery.equalTo(fieldName, listOfValues.first() * sign) |
|
|
|
is ListOfString -> realmQuery.equalTo(fieldName, listOfValues.first()) |
|
|
|
is ListOfString -> realmQuery.equalTo(fieldName, listOfValues.first()) |
|
|
|
@ -737,9 +804,18 @@ sealed class QueryCondition : FilterElementRow { |
|
|
|
} |
|
|
|
} |
|
|
|
Operator.MORE -> { |
|
|
|
Operator.MORE -> { |
|
|
|
when (this) { |
|
|
|
when (this) { |
|
|
|
is SingleDate -> realmQuery.greaterThanOrEqualTo(fieldName, singleValue?.startOfDay()?:throw PokerAnalyticsException.FilterElementExpectedValueMissing) |
|
|
|
is SingleDate -> realmQuery.greaterThanOrEqualTo( |
|
|
|
is Duration -> realmQuery.greaterThanOrEqualTo(fieldName, netDuration?:throw PokerAnalyticsException.FilterElementExpectedValueMissing) |
|
|
|
fieldName, |
|
|
|
is SingleInt -> realmQuery.greaterThanOrEqualTo(fieldName, singleValue?:throw PokerAnalyticsException.FilterElementExpectedValueMissing) |
|
|
|
singleValue?.startOfDay() ?: throw PokerAnalyticsException.FilterElementExpectedValueMissing |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
is Duration -> realmQuery.greaterThanOrEqualTo( |
|
|
|
|
|
|
|
fieldName, |
|
|
|
|
|
|
|
netDuration ?: throw PokerAnalyticsException.FilterElementExpectedValueMissing |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
is SingleInt -> realmQuery.greaterThanOrEqualTo( |
|
|
|
|
|
|
|
fieldName, |
|
|
|
|
|
|
|
singleValue ?: throw PokerAnalyticsException.FilterElementExpectedValueMissing |
|
|
|
|
|
|
|
) |
|
|
|
is ListOfInt -> realmQuery.greaterThanOrEqualTo(fieldName, listOfValues.first()) |
|
|
|
is ListOfInt -> realmQuery.greaterThanOrEqualTo(fieldName, listOfValues.first()) |
|
|
|
is NetAmountLost -> realmQuery.lessThanOrEqualTo(fieldName, listOfValues.first() * -1) |
|
|
|
is NetAmountLost -> realmQuery.lessThanOrEqualTo(fieldName, listOfValues.first() * -1) |
|
|
|
is ListOfDouble -> realmQuery.greaterThanOrEqualTo(fieldName, listOfValues.first() * sign) |
|
|
|
is ListOfDouble -> realmQuery.greaterThanOrEqualTo(fieldName, listOfValues.first() * sign) |
|
|
|
@ -748,9 +824,18 @@ sealed class QueryCondition : FilterElementRow { |
|
|
|
} |
|
|
|
} |
|
|
|
Operator.LESS -> { |
|
|
|
Operator.LESS -> { |
|
|
|
when (this) { |
|
|
|
when (this) { |
|
|
|
is SingleDate -> realmQuery.lessThanOrEqualTo(fieldName, singleValue?.endOfDay()?:throw PokerAnalyticsException.FilterElementExpectedValueMissing) |
|
|
|
is SingleDate -> realmQuery.lessThanOrEqualTo( |
|
|
|
is Duration -> realmQuery.lessThanOrEqualTo(fieldName, netDuration?:throw PokerAnalyticsException.FilterElementExpectedValueMissing) |
|
|
|
fieldName, |
|
|
|
is SingleInt -> realmQuery.lessThanOrEqualTo(fieldName, singleValue?:throw PokerAnalyticsException.FilterElementExpectedValueMissing) |
|
|
|
singleValue?.endOfDay() ?: throw PokerAnalyticsException.FilterElementExpectedValueMissing |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
is Duration -> realmQuery.lessThanOrEqualTo( |
|
|
|
|
|
|
|
fieldName, |
|
|
|
|
|
|
|
netDuration ?: throw PokerAnalyticsException.FilterElementExpectedValueMissing |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
is SingleInt -> realmQuery.lessThanOrEqualTo( |
|
|
|
|
|
|
|
fieldName, |
|
|
|
|
|
|
|
singleValue ?: throw PokerAnalyticsException.FilterElementExpectedValueMissing |
|
|
|
|
|
|
|
) |
|
|
|
is ListOfInt -> realmQuery.lessThanOrEqualTo(fieldName, listOfValues.first()) |
|
|
|
is ListOfInt -> realmQuery.lessThanOrEqualTo(fieldName, listOfValues.first()) |
|
|
|
is NetAmountLost -> { |
|
|
|
is NetAmountLost -> { |
|
|
|
realmQuery.greaterThanOrEqualTo(fieldName, listOfValues.first() * -1) |
|
|
|
realmQuery.greaterThanOrEqualTo(fieldName, listOfValues.first() * -1) |
|
|
|
|