Example #1
0
 public static LegActivityMatch IfUnloadLocationSame(Leg leg,
                                                     HandlingActivity handlingActivity,
                                                     Itinerary itinerary)
 {
     return(leg.UnloadLocation.sameAs(handlingActivity.Location)
         ? new LegActivityMatch(leg, LegEnd.UnloadEnd, handlingActivity, itinerary)
         : NoMatch(handlingActivity, itinerary));
 }
        /// <summary>
        /// Routing status.
        /// </summary>
        /// <param name="itinerary">itinerary</param>
        /// <returns>Routing status.</returns>
        public virtual RoutingStatus StatusOf(Itinerary itinerary)
        {
            if (itinerary == null)
            {
                return(RoutingStatus.NOT_ROUTED);
            }

            return(IsSatisfiedBy(itinerary) ? RoutingStatus.ROUTED : RoutingStatus.MISROUTED);
        }
Example #3
0
        /// <summary>
        /// Attach a new itinerary to this cargo.
        /// </summary>
        /// <param name="itinerary">an itinerary. May not be null.</param>
        public virtual void AssignToRoute(Itinerary itinerary)
        {
            Validate.notNull(itinerary, "Itinerary is required");

            if (RoutingStatus != RoutingStatus.NOT_ROUTED)
            {
                Delivery = Delivery.OnRouting();
            }

            Itinerary = itinerary;
        }
Example #4
0
        private bool SuccedsMostRecentActivity(HandlingActivity newHandlingActivity)
        {
            if (!Delivery.HasBeenHandled)
            {
                return(true);
            }

            var mostRecentPhysicalHandlingActivity = Delivery.MostRecentPhysicalHandlingActivity;
            var priorActivity = Itinerary.StrictlyPriorOf(mostRecentPhysicalHandlingActivity, newHandlingActivity);

            return(!newHandlingActivity.sameValueAs(priorActivity));
        }
Example #5
0
        /// <summary>
        /// Merges the current <see cref="Freight.Itinerary"/> with the provided <see cref="Freight.Itinerary"/>
        /// </summary>
        /// <param name="other">itinerary</param>
        /// <returns>A merge between the current itinerary and the provided itinerary
        /// that describes a continuous route even if the cargo is currently misdirected.</returns>
        public virtual Itinerary ItineraryMergedWith(Itinerary other)
        {
            if (RoutingStatus == RoutingStatus.NOT_ROUTED)
            {
                return(other);
            }

            if (IsMisdirected && TransportStatus == TransportStatus.ONBOARD_CARRIER)
            {
                var currentLeg = Leg.DeriveLeg(CurrentVoyage, LastKnownLocation,
                                               CurrentVoyage.ArrivalLocationWhenDepartedFrom(LastKnownLocation));

                return(Itinerary.TruncatedAfter(LastKnownLocation).WithLeg(currentLeg).AppendBy(other));
            }

            return(Itinerary.TruncatedAfter(EarliestReroutingLocation).AppendBy(other));
        }
Example #6
0
 public static LegActivityMatch NoMatch(HandlingActivity handlingActivity, Itinerary itinerary)
 {
     return(new LegActivityMatch(null, LegEnd.NoEnd, handlingActivity, itinerary));
 }
Example #7
0
        public static LegActivityMatch Match(Leg leg, HandlingActivity handlingActivity, Itinerary itinerary)
        {
            switch (handlingActivity.Type)
            {
            case HandlingActivityType.RECEIVE:
            case HandlingActivityType.LOAD:
                return(new LegActivityMatch(leg, LegEnd.LoadEnd, handlingActivity, itinerary));

            case HandlingActivityType.UNLOAD:
            case HandlingActivityType.CLAIM:
            case HandlingActivityType.CUSTOMS:
                return(new LegActivityMatch(leg, LegEnd.UnloadEnd, handlingActivity, itinerary));

            default:
                return(NoMatch(handlingActivity, itinerary));
            }
        }
Example #8
0
 private LegActivityMatch(Leg leg, LegEnd legEnd, HandlingActivity handlingActivity, Itinerary itinerary)
 {
     Leg              = leg;
     LegEnd           = legEnd;
     HandlingActivity = handlingActivity;
     Itinerary        = itinerary;
 }
 /// <summary>
 /// Determines if the specified itinerary satisfies the routing specification.
 /// </summary>
 /// <param name="itinerary">itinerary</param>
 /// <returns>True if this route specification is satisfied by the itinerary,
 /// i.e. the cargo will be delivered according to requirements.</returns>
 public virtual bool IsSatisfiedBy(Itinerary itinerary)
 {
     return(_notNull.and(_sameOrigin).and(_sameDestination).and(_meetsDeadline).isSatisfiedBy(itinerary));
 }
 public override bool isSatisfiedBy(Itinerary itinerary)
 {
     return(_parent.ArrivalDeadline > itinerary.FinalUnloadTime);
 }
 public override bool isSatisfiedBy(Itinerary itinerary)
 {
     return(_parent.Destination.sameAs(itinerary.FinalUnloadLocation));
 }
 public override bool isSatisfiedBy(Itinerary itinerary)
 {
     return(_parent.Origin.sameAs(itinerary.InitialLoadLocation));
 }
 public override bool isSatisfiedBy(Itinerary itinerary)
 {
     return(itinerary != null);
 }
Example #14
0
 /// <summary>
 /// True if the cargo is routed and not misdirected
 /// </summary>
 /// <param name="itinerary">itinerary</param>
 /// <param name="routeSpecification">route specification</param>
 /// <returns>True if the cargo is routed and not misdirected</returns>
 internal bool IsOnRoute(Itinerary itinerary, RouteSpecification routeSpecification)
 {
     return(routeSpecification.StatusOf(itinerary) == RoutingStatus.ROUTED && !IsMisdirected(itinerary));
 }
Example #15
0
 /// <summary>
 /// Check if cargo is misdirected.
 /// </summary>
 /// <remarks>
 /// <list>
 /// <item>A cargo is misdirected if it is in a location that's not in the itinerary.</item>
 /// <item>A cargo with no itinerary can not be misdirected.</item>
 /// <item>A cargo that has received no handling events can not be misdirected.</item>
 /// </list>
 /// </remarks>
 /// <param name="itinerary">itinerary</param>
 /// <returns><code>true</code> if the cargo has been misdirected.</returns>
 internal bool IsMisdirected(Itinerary itinerary)
 {
     return(HasBeenHandled && !itinerary.IsExpectedActivity(MostRecentPhysicalHandlingActivity));
 }