|
|
|
@ -8,6 +8,7 @@ import net.pokeranalytics.android.model.TableSize |
|
|
|
import net.pokeranalytics.android.model.TournamentType |
|
|
|
import net.pokeranalytics.android.model.TournamentType |
|
|
|
import net.pokeranalytics.android.model.realm.* |
|
|
|
import net.pokeranalytics.android.model.realm.* |
|
|
|
import net.pokeranalytics.android.model.utils.DataUtils |
|
|
|
import net.pokeranalytics.android.model.utils.DataUtils |
|
|
|
|
|
|
|
import net.pokeranalytics.android.util.extensions.count |
|
|
|
import net.pokeranalytics.android.util.extensions.getOrCreate |
|
|
|
import net.pokeranalytics.android.util.extensions.getOrCreate |
|
|
|
import net.pokeranalytics.android.util.extensions.setHourMinutes |
|
|
|
import net.pokeranalytics.android.util.extensions.setHourMinutes |
|
|
|
import org.apache.commons.csv.CSVRecord |
|
|
|
import org.apache.commons.csv.CSVRecord |
|
|
|
@ -22,6 +23,14 @@ abstract class PACSVDescriptor<T : Identifiable>(source: DataSource, |
|
|
|
vararg elements: CSVField) |
|
|
|
vararg elements: CSVField) |
|
|
|
: DataCSVDescriptor<T>(source, *elements) { |
|
|
|
: DataCSVDescriptor<T>(source, *elements) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var noSessionImport: Boolean = false |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
init { |
|
|
|
|
|
|
|
val realm = Realm.getDefaultInstance() |
|
|
|
|
|
|
|
this.noSessionImport = realm.count(Session::class.java) == 0L |
|
|
|
|
|
|
|
realm.close() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private var sameDaySessionCount: Int = 0 |
|
|
|
private var sameDaySessionCount: Int = 0 |
|
|
|
private var currentDay: String = "" |
|
|
|
private var currentDay: String = "" |
|
|
|
private var startInSeconds: Double = 20 * 3600.0 |
|
|
|
private var startInSeconds: Double = 20 * 3600.0 |
|
|
|
@ -177,6 +186,22 @@ abstract class PACSVDescriptor<T : Identifiable>(source: DataSource, |
|
|
|
session.cgBigBlind = bb |
|
|
|
session.cgBigBlind = bb |
|
|
|
} else {} |
|
|
|
} else {} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
is SessionField.Blinds -> { |
|
|
|
|
|
|
|
val blinds = value.split("/") |
|
|
|
|
|
|
|
when (blinds.size) { |
|
|
|
|
|
|
|
0 -> {} |
|
|
|
|
|
|
|
1 -> { |
|
|
|
|
|
|
|
session.cgBigBlind = field.parse(blinds.first()) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else -> { |
|
|
|
|
|
|
|
session.cgSmallBlind = field.parse(blinds[blinds.size - 2]) |
|
|
|
|
|
|
|
session.cgBigBlind = field.parse(blinds.last()) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
is SessionField.Ante -> { |
|
|
|
|
|
|
|
// unmanaged atm |
|
|
|
|
|
|
|
} |
|
|
|
is SessionField.TableSize -> session.tableSize = TableSize.valueForLabel(value) |
|
|
|
is SessionField.TableSize -> session.tableSize = TableSize.valueForLabel(value) |
|
|
|
is SessionField.TournamentPosition -> session.result?.tournamentFinalPosition = |
|
|
|
is SessionField.TournamentPosition -> session.result?.tournamentFinalPosition = |
|
|
|
field.parse(value) |
|
|
|
field.parse(value) |
|
|
|
@ -242,7 +267,7 @@ abstract class PACSVDescriptor<T : Identifiable>(source: DataSource, |
|
|
|
if (startDate != null && endDate != null && net != null) { // valid session |
|
|
|
if (startDate != null && endDate != null && net != null) { // valid session |
|
|
|
// session already in realm, we'd love not put it in Realm before doing the check |
|
|
|
// session already in realm, we'd love not put it in Realm before doing the check |
|
|
|
val count = DataUtils.sessionCount(realm, startDate!!, endDate!!, net) |
|
|
|
val count = DataUtils.sessionCount(realm, startDate!!, endDate!!, net) |
|
|
|
if (count == 0) { |
|
|
|
if (this.noSessionImport || count == 0) { |
|
|
|
|
|
|
|
|
|
|
|
val managedSession = realm.copyToRealm(session) |
|
|
|
val managedSession = realm.copyToRealm(session) |
|
|
|
managedSession.startDate = startDate |
|
|
|
managedSession.startDate = startDate |
|
|
|
|