コード例 #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));
 }
コード例 #2
0
        /// <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);
        }
コード例 #3
0
ファイル: Cargo.cs プロジェクト: bes-slim/dddsample.net
        /// <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;
        }
コード例 #4
0
ファイル: Cargo.cs プロジェクト: bes-slim/dddsample.net
        private bool SuccedsMostRecentActivity(HandlingActivity newHandlingActivity)
        {
            if (!Delivery.HasBeenHandled)
            {
                return(true);
            }

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

            return(!newHandlingActivity.sameValueAs(priorActivity));
        }
コード例 #5
0
ファイル: Cargo.cs プロジェクト: bes-slim/dddsample.net
        /// <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));
        }
コード例 #6
0
 public static LegActivityMatch NoMatch(HandlingActivity handlingActivity, Itinerary itinerary)
 {
     return(new LegActivityMatch(null, LegEnd.NoEnd, handlingActivity, itinerary));
 }
コード例 #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));
            }
        }
コード例 #8
0
 private LegActivityMatch(Leg leg, LegEnd legEnd, HandlingActivity handlingActivity, Itinerary itinerary)
 {
     Leg              = leg;
     LegEnd           = legEnd;
     HandlingActivity = handlingActivity;
     Itinerary        = itinerary;
 }
コード例 #9
0
 /// <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));
 }
コード例 #10
0
 public override bool isSatisfiedBy(Itinerary itinerary)
 {
     return(_parent.ArrivalDeadline > itinerary.FinalUnloadTime);
 }
コード例 #11
0
 public override bool isSatisfiedBy(Itinerary itinerary)
 {
     return(_parent.Destination.sameAs(itinerary.FinalUnloadLocation));
 }
コード例 #12
0
 public override bool isSatisfiedBy(Itinerary itinerary)
 {
     return(_parent.Origin.sameAs(itinerary.InitialLoadLocation));
 }
コード例 #13
0
 public override bool isSatisfiedBy(Itinerary itinerary)
 {
     return(itinerary != null);
 }
コード例 #14
0
ファイル: Delivery.cs プロジェクト: bes-slim/dddsample.net
 /// <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));
 }
コード例 #15
0
ファイル: Delivery.cs プロジェクト: bes-slim/dddsample.net
 /// <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));
 }