private RoutingStatus calculateRoutingStatus( Itinerary itinerary, RouteSpecification routeSpecification) { if (itinerary == null) { return RoutingStatus.NOT_ROUTED; } else { if (routeSpecification.isSatisfiedBy(itinerary)) { return RoutingStatus.ROUTED; } else { return RoutingStatus.MISROUTED; } } }
private HandlingActivity calculateNextExpectedActivity( RouteSpecification routeSpecification, Itinerary itinerary) { if (!onTrack()) return NO_ACTIVITY; if (lastEvent == null) return new HandlingActivity(HandlingEvent.Type.RECEIVE, routeSpecification.getOrigin()); switch (lastEvent.getType()) { case LOAD: for (Leg leg : itinerary.getLegs()) { if (leg.getLoadLocation().equals(lastEvent.getLocation())) { return new HandlingActivity( HandlingEvent.Type.UNLOAD, leg.getUnloadLocation(), leg.getVoyage()); } } return NO_ACTIVITY; case UNLOAD: for (Iterator<Leg> it = itinerary.getLegs().iterator(); it.hasNext(); ) { final Leg leg = it.next(); if (leg.getUnloadLocation().equals(lastEvent.getLocation())) { if (it.hasNext()) { final Leg nextLeg = it.next(); return new HandlingActivity( HandlingEvent.Type.LOAD, nextLeg.getLoadLocation(), nextLeg.getVoyage()); } else { return new HandlingActivity(HandlingEvent.Type.CLAIM, leg.getUnloadLocation()); } } } return NO_ACTIVITY; case RECEIVE: final Leg firstLeg = itinerary.getLegs().iterator().next(); return new HandlingActivity( HandlingEvent.Type.LOAD, firstLeg.getLoadLocation(), firstLeg.getVoyage()); case CLAIM: default: return NO_ACTIVITY; } }
private boolean calculateUnloadedAtDestination(RouteSpecification routeSpecification) { return lastEvent != null && HandlingEvent.Type.UNLOAD.equals(lastEvent.getType()) && routeSpecification.getDestination().equals(lastEvent.getLocation()); }