From 2d57f8fbd702d38cf7691046e68a65b2d7d63244 Mon Sep 17 00:00:00 2001 From: Axel Uhl Date: Sun, 19 Jun 2011 23:51:01 +0200 Subject: [PATCH] avoid creation of a TrackedRace which may unnecessarily block, only to show the race in listevents --- .../com/sap/sailing/server/ModeratorApp.java | 31 ++++++++++--------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/java/com.sap.sailing.server/src/com/sap/sailing/server/ModeratorApp.java b/java/com.sap.sailing.server/src/com/sap/sailing/server/ModeratorApp.java index 2e3ffb2a01b..8fa04221d3e 100755 --- a/java/com.sap.sailing.server/src/com/sap/sailing/server/ModeratorApp.java +++ b/java/com.sap.sailing.server/src/com/sap/sailing/server/ModeratorApp.java @@ -375,21 +375,24 @@ public class ModeratorApp extends Servlet { jsonEvent.put("competitors", jsonCompetitors); JSONArray jsonRaces = new JSONArray(); for (RaceDefinition race : event.getAllRaces()) { - JSONObject jsonRace = new JSONObject(); - jsonRace.put("name", race.getName()); - jsonRace.put("boatclass", race.getBoatClass()==null?"":race.getBoatClass().getName()); - TrackedRace trackedRace = getService().getDomainFactory().getOrCreateTrackedEvent(event).getTrackedRace(race); - TimePoint start = trackedRace.getStart(); - jsonRace.put("start", start==null?Long.MAX_VALUE:start.asMillis()); - JSONArray jsonLegs = new JSONArray(); - for (Leg leg : race.getCourse().getLegs()) { - JSONObject jsonLeg = new JSONObject(); - jsonLeg.put("start", leg.getFrom().getName()); - jsonLeg.put("end", leg.getTo().getName()); - jsonLegs.add(jsonLeg); + // don't wait for the arrival of a tracked race; just ignore it if it's not currently being tracked + TrackedRace trackedRace = getService().getDomainFactory().getOrCreateTrackedEvent(event).getExistingTrackedRace(race); + if (trackedRace != null) { + JSONObject jsonRace = new JSONObject(); + jsonRace.put("name", race.getName()); + jsonRace.put("boatclass", race.getBoatClass() == null ? "" : race.getBoatClass().getName()); + TimePoint start = trackedRace.getStart(); + jsonRace.put("start", start == null ? Long.MAX_VALUE : start.asMillis()); + JSONArray jsonLegs = new JSONArray(); + for (Leg leg : race.getCourse().getLegs()) { + JSONObject jsonLeg = new JSONObject(); + jsonLeg.put("start", leg.getFrom().getName()); + jsonLeg.put("end", leg.getTo().getName()); + jsonLegs.add(jsonLeg); + } + jsonRace.put("legs", jsonLegs); + jsonRaces.add(jsonRace); } - jsonRace.put("legs", jsonLegs); - jsonRaces.add(jsonRace); } jsonEvent.put("races", jsonRaces); eventList.add(jsonEvent);