_narrativeService.addMessage(instance, "cancelation");
}
}
private void handleMovement(TrainMovementMessage message) {
TrainMovementBody body = message.getBody();
_narrativeService.addMessage(
body.getTrainId().substring(2, 6),
Long.parseLong(message.getHeader().getMsgQueueTimestamp()),
"movement: trainId=" + body.getTrainId() + " stanox="
+ body.getLocStanox());
TrainInstance instance = getTrainInstanceForTrainId(message);
if (instance == null) {
_statisticsService.incrementUnknownTrainIdCount();
return;
}
Set<TrainInstance> instances = _trainsByShortId.get(instance.getTrainReportingNumber());
if (instances == null) {
instances = new HashSet<TrainInstance>();
_trainsByShortId.put(instance.getTrainReportingNumber(), instances);
}
instances.add(instance);
if (body.getLocStanox() == null) {
_statisticsService.incrementEmptyLocStanoxCount();
}
int stanox = Integer.parseInt(body.getLocStanox());
TimepointElement timepoint = null; // what?
if (timepoint == null) {
_statisticsService.incrementUnknownStanoxCount();
return;
}
if (body.getPlatform() != null) {
String platform = body.getPlatform().trim();
if (!platform.isEmpty() && !platform.equals(timepoint.getPlatform())) {
_statisticsService.incrementPlatformChange();
}
}
_narrativeService.addMessage(instance, "movement: stanox=" + stanox
+ " tiploc=" + timepoint.getTiploc());
if (body.getActualTimestamp().isEmpty()
|| body.getPlannedTimestamp().isEmpty()) {
return;
}
long actualTimestamp = Long.parseLong(body.getActualTimestamp());
long plannedTimestamp = Long.parseLong(body.getPlannedTimestamp());
int delay = (int) ((actualTimestamp - plannedTimestamp) / 1000);
StopTimeEvent.Builder departure = StopTimeEvent.newBuilder();
departure.setDelay(delay);