Fix pairgoth import and EGF/FFG export missing flush

This commit is contained in:
Claude Brisson
2024-03-07 05:43:45 +01:00
parent 418aad891d
commit e4eff46750
4 changed files with 12 additions and 6 deletions

View File

@@ -92,11 +92,13 @@ object StandingsHandler: PairgothApiHandler {
val neededCriteria = ArrayList(tournament.pairing.placementParams.criteria) val neededCriteria = ArrayList(tournament.pairing.placementParams.criteria)
if (!neededCriteria.contains(NBW)) neededCriteria.add(NBW) if (!neededCriteria.contains(NBW)) neededCriteria.add(NBW)
exportToEGFFormat(tournament, sortedPairables, neededCriteria, writer) exportToEGFFormat(tournament, sortedPairables, neededCriteria, writer)
writer.flush()
return null return null
} }
"application/ffg" -> { "application/ffg" -> {
response.contentType = "text/plain;charset=${encoding}" response.contentType = "text/plain;charset=${encoding}"
exportToFFGFormat(tournament, sortedPairables, writer) exportToFFGFormat(tournament, sortedPairables, writer)
writer.flush()
return null return null
} }
else -> ApiHandler.badRequest("invalid Accept header: $accept") else -> ApiHandler.badRequest("invalid Accept header: $accept")

View File

@@ -27,7 +27,9 @@ class ImportServlet: HttpServlet() {
if (json == null || !json.isObject) { if (json == null || !json.isObject) {
resp.sendError(HttpServletResponse.SC_BAD_REQUEST) resp.sendError(HttpServletResponse.SC_BAD_REQUEST)
} else { } else {
apiResp = api.post("tour", json.asObject()) val filtered = Json.MutableObject(json.asObject())
filtered.remove("id")
apiResp = api.post("tour", filtered)
} }
} }
else { // xml ? else { // xml ?
@@ -55,8 +57,10 @@ class ImportServlet: HttpServlet() {
if (example == null || !example.isObject) { if (example == null || !example.isObject) {
response.sendError(HttpServletResponse.SC_BAD_REQUEST) response.sendError(HttpServletResponse.SC_BAD_REQUEST)
} else { } else {
val filtered = Json.MutableObject(example.asObject())
filtered.remove("id")
val api = ApiTool().apply { setRequest(request) } val api = ApiTool().apply { setRequest(request) }
val apiResp = api.post("tour", example) val apiResp = api.post("tour", filtered)
if (apiResp.isObject && apiResp.asObject().getBoolean("success") == true) { if (apiResp.isObject && apiResp.asObject().getBoolean("success") == true) {
response.contentType = "application/json; charset=UTF-8" response.contentType = "application/json; charset=UTF-8"
response.writer.println(apiResp.toString()) response.writer.println(apiResp.toString())

View File

@@ -31,7 +31,7 @@ Create Créer
Crit Crit Crit Crit
Ctr Pays Ctr Pays
Dates Dates Dates Dates
Delete Supprimer Delete Supprimer
Download Télécharger Download Télécharger
Download the standalone web interface module which suits your need, then follow Télécharger le module dinterface web qui correspond à vos besoins, puis suivez Download the standalone web interface module which suits your need, then follow Télécharger le module dinterface web qui correspond à vos besoins, puis suivez
Edit Éditer Edit Éditer
@@ -78,7 +78,7 @@ Nbw NbV
New Tournament Nouveau Tournoi New Tournament Nouveau Tournoi
New tournament Nouveau tournoi New tournament Nouveau tournoi
Next rounds seeding Méthode rondes suivantes Next rounds seeding Méthode rondes suivantes
OpenGotha file Fichier OpenGotha OpenGotha / Pairgoth file Fichier OpenGotha / Pairgoth
Pair Apparier Pair Apparier
Pair-go tournament Tournoi de pair-go Pair-go tournament Tournoi de pair-go
Pairing Appariements Pairing Appariements

View File

@@ -39,8 +39,8 @@
<form id="import-form" class="ui form"> <form id="import-form" class="ui form">
<div class="popup-content"> <div class="popup-content">
<div class="field"> <div class="field">
<label>OpenGotha file</label> <label>OpenGotha / Pairgoth file</label>
<input type="file" name="file" accept=".xml"/> <input type="file" name="file" accept=".tour,.xml"/>
</div> </div>
</div> </div>
<div class="popup-footer"> <div class="popup-footer">