cs fix
This commit is contained in:
parent
8e4138e873
commit
d2ef844b4f
1 changed files with 33 additions and 33 deletions
|
@ -34,28 +34,28 @@ class RegisterRepository(
|
||||||
fun getStudents(): Single<List<Student>> {
|
fun getStudents(): Single<List<Student>> {
|
||||||
return getSymbols().flatMapObservable { Observable.fromIterable(it) }.flatMap { symbol ->
|
return getSymbols().flatMapObservable { Observable.fromIterable(it) }.flatMap { symbol ->
|
||||||
loginHelper.sendCertificate(symbol.second, symbol.second.action.replace(startSymbol, symbol.first))
|
loginHelper.sendCertificate(symbol.second, symbol.second.action.replace(startSymbol, symbol.first))
|
||||||
.onErrorResumeNext { t ->
|
.onErrorResumeNext { t ->
|
||||||
if (t is AccountPermissionException) Single.just(SendCertificateResponse())
|
if (t is AccountPermissionException) Single.just(SendCertificateResponse())
|
||||||
else Single.error(t)
|
else Single.error(t)
|
||||||
}
|
}
|
||||||
.flatMapObservable { Observable.fromIterable(if (useNewStudent) it.studentSchools else it.oldStudentSchools) }
|
.flatMapObservable { Observable.fromIterable(if (useNewStudent) it.studentSchools else it.oldStudentSchools) }
|
||||||
.flatMapSingle { schoolUrl ->
|
.flatMapSingle { schoolUrl ->
|
||||||
getLoginType(symbol.first).flatMap { loginType ->
|
getLoginType(symbol.first).flatMap { loginType ->
|
||||||
getStudents(symbol.first, schoolUrl).map {
|
getStudents(symbol.first, schoolUrl).map {
|
||||||
it.map { student ->
|
it.map { student ->
|
||||||
Student(
|
Student(
|
||||||
email = email,
|
email = email,
|
||||||
symbol = symbol.first,
|
symbol = symbol.first,
|
||||||
studentId = student.id,
|
studentId = student.id,
|
||||||
studentName = student.name,
|
studentName = student.name,
|
||||||
schoolSymbol = getExtractedSchoolSymbolFromUrl(schoolUrl),
|
schoolSymbol = getExtractedSchoolSymbolFromUrl(schoolUrl),
|
||||||
schoolName = student.description,
|
schoolName = student.description,
|
||||||
loginType = loginType
|
loginType = loginType
|
||||||
)
|
)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}.toList().map { it.flatten().distinctBy { pupil -> pupil.studentId to pupil.schoolSymbol } }
|
}.toList().map { it.flatten().distinctBy { pupil -> pupil.studentId to pupil.schoolSymbol } }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,18 +69,18 @@ class RegisterRepository(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else student.getSchoolInfo(url.generate(ServiceManager.UrlGenerator.Site.STUDENT) + "UczenDziennik.mvc/Get")
|
} else student.getSchoolInfo(url.generate(ServiceManager.UrlGenerator.Site.STUDENT) + "UczenDziennik.mvc/Get")
|
||||||
.map { diary -> diary.data?.distinctBy { it.studentId } }
|
.map { diary -> diary.data?.distinctBy { it.studentId } }
|
||||||
.flatMap { diaries ->
|
.flatMap { diaries ->
|
||||||
student.getStart(url.generate(ServiceManager.UrlGenerator.Site.STUDENT) + "Start").map { startPage ->
|
student.getStart(url.generate(ServiceManager.UrlGenerator.Site.STUDENT) + "Start").map { startPage ->
|
||||||
diaries.map {
|
diaries.map {
|
||||||
StudentAndParentResponse.Student().apply {
|
StudentAndParentResponse.Student().apply {
|
||||||
id = it.studentId
|
id = it.studentId
|
||||||
name = "${it.studentName} ${it.studentSurname}"
|
name = "${it.studentName} ${it.studentSurname}"
|
||||||
description = getScriptParam("organizationName", startPage, it.symbol + " " + (it.year - it.level + 1))
|
description = getScriptParam("organizationName", startPage, it.symbol + " " + (it.year - it.level + 1))
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getSymbols(): Single<List<Pair<String, CertificateResponse>>> {
|
private fun getSymbols(): Single<List<Pair<String, CertificateResponse>>> {
|
||||||
|
@ -89,11 +89,11 @@ class RegisterRepository(
|
||||||
}.flatMap { login ->
|
}.flatMap { login ->
|
||||||
login.sendCredentials(email, password).flatMap { Single.just(it) }.flatMap { cert ->
|
login.sendCredentials(email, password).flatMap { Single.just(it) }.flatMap { cert ->
|
||||||
Single.just(Jsoup.parse(cert.wresult.replace(":", ""), "", Parser.xmlParser())
|
Single.just(Jsoup.parse(cert.wresult.replace(":", ""), "", Parser.xmlParser())
|
||||||
.select("[AttributeName$=\"Instance\"] samlAttributeValue")
|
.select("[AttributeName$=\"Instance\"] samlAttributeValue")
|
||||||
.map { it.text().trim() }
|
.map { it.text().trim() }
|
||||||
.filter { it.matches("[a-zA-Z]*".toRegex()) } // early filter invalid symbols
|
.filter { it.matches("[a-zA-Z]*".toRegex()) } // early filter invalid symbols
|
||||||
.ifEmpty { listOf("opole", "gdansk", "tarnow", "rzeszow") } // fallback
|
.ifEmpty { listOf("opole", "gdansk", "tarnow", "rzeszow") } // fallback
|
||||||
.map { Pair(it, cert) }
|
.map { Pair(it, cert) }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue