polygene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nic...@apache.org
Subject [16/28] zest-java git commit: ZEST-180, ZEST-186, ZEST-187, ZEST-188 Big Identity refactoring UnitOfWorkFactory is auto added to all modules that doesn't declare one IdentityGenerator is auto-added to all modules that deosn't declare one. Removed DCI/DDD
Date Sun, 23 Oct 2016 14:23:57 GMT
http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/booking/BuildDeliverySnapshot.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/booking/BuildDeliverySnapshot.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/booking/BuildDeliverySnapshot.java
deleted file mode 100644
index c299b94..0000000
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/booking/BuildDeliverySnapshot.java
+++ /dev/null
@@ -1,569 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *       http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *
- *
- */
-package org.apache.zest.sample.dcicargo.sample_a.context.shipping.booking;
-
-import java.time.Instant;
-import java.time.LocalDate;
-import java.util.Iterator;
-import org.apache.zest.api.injection.scope.This;
-import org.apache.zest.api.mixin.Mixins;
-import org.apache.zest.api.value.ValueBuilder;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.cargo.Cargo;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.cargo.RouteSpecification;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.delivery.Delivery;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.delivery.ExpectedHandlingEvent;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.delivery.RoutingStatus;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.delivery.TransportStatus;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.handling.HandlingEvent;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.handling.HandlingEventType;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.itinerary.Itinerary;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.itinerary.Leg;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.location.Location;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.voyage.Voyage;
-import org.apache.zest.sample.dcicargo.sample_a.infrastructure.dci.Context;
-import org.apache.zest.sample.dcicargo.sample_a.infrastructure.dci.RoleMixin;
-
-/**
- * Build Delivery Snapshot use case.
- *
- * This is a subfunction level use case (see Cockurn 2001) supporting user-goal level use cases
- * like {@link BookNewCargo} by returning a Delivery snapshot Value object.
- *
- * A Delivery snapshot describes all we know about the current shipping status of a Cargo. It's the
- * heart of the application domain knowledge.
- *
- * The Delivery snapshot is derived from one of the 3 overall stages a Cargo shipping can be in:
- * 1) Cargo is being created  (Route Specification is known)
- * 2) Cargo has been routed   (Route Specification + Itinerary is known)
- * 3) Cargo is in transit     (Route Specification + Itinerary + last Handling Event is known)
- *
- * Code is organized along the contours of the process flow of cargo shipping instead of the data
- * structures. This makes it easier to reason about a certain step in the shipping process (use case)
- * according to the intuitive understanding of the shipping domain.
- *
- * @see RouteSpecification  plays a (methodful) Role of a factory that coordinates the Delivery build.
- * @see HandlingEvent       plays a (methodful) Role that coordinates deriving data from the last Handling Event.
- * @see Itinerary           plays a (methodful) Role supporting the other two roles with Itinerary calculations.
- */
-public class BuildDeliverySnapshot extends Context
-{
-    // ROLES ---------------------------------------------------------------------
-
-    private FactoryRole factory;
-    private ItineraryRole itinerary;
-    private HandlingEventRole handlingEvent;
-
-    private Delivery newDeliverySnapshot;
-
-    // CONTEXT CONSTRUCTORS ------------------------------------------------------
-
-    BuildDeliverySnapshot( RouteSpecification routeSpecification )
-    {
-        // Deviation 2a
-        if( routeSpecification.origin().get() == routeSpecification.destination().get() )
-        {
-            throw new RouteException( "Route specification is invalid. Origin equals destination." );
-        }
-
-        // Deviation 2b
-        if( !routeSpecification.arrivalDeadline().get().isAfter( LocalDate.now() ) )
-        {
-            throw new RouteException( "Arrival deadline is in the past or Today." +
-                                        "\nDeadline " + routeSpecification.arrivalDeadline().get() +
-                                        "\nToday    " + LocalDate.now() );
-        }
-
-        factory = rolePlayer( FactoryRole.class, routeSpecification );
-        itinerary = null;
-        handlingEvent = null;
-    }
-
-    BuildDeliverySnapshot( Cargo cargo )
-    {
-        factory = rolePlayer( FactoryRole.class, cargo.routeSpecification().get() );
-        itinerary = rolePlayer( ItineraryRole.class, cargo.itinerary().get() );
-        handlingEvent = rolePlayer( HandlingEventRole.class, cargo.delivery().get().lastHandlingEvent().get() );
-    }
-
-    public BuildDeliverySnapshot( Cargo cargo, HandlingEvent registeredHandlingEvent )
-    {
-        factory = rolePlayer( FactoryRole.class, cargo.routeSpecification().get() );
-        itinerary = rolePlayer( ItineraryRole.class, cargo.itinerary().get() );
-        handlingEvent = rolePlayer( HandlingEventRole.class, registeredHandlingEvent );
-    }
-
-    // INTERACTIONS --------------------------------------------------------------
-
-    public Delivery get()
-    {
-        return factory.deriveDeliverySnapshot();
-    }
-
-    // METHODFUL ROLE IMPLEMENTATIONS --------------------------------------------
-
-    /**
-     * The FactoryRole coordinates the overall Delivery snapshot build.
-     *
-     * When the Cargo has a delivery history the FactoryRole delegates to the LastHandlingEventRole
-     * to derive data from the last HandlingEvent.
-     */
-    @Mixins( FactoryRole.Mixin.class )
-    public interface FactoryRole
-    {
-        void setContext( BuildDeliverySnapshot context );
-
-        Delivery deriveDeliverySnapshot();
-
-        class Mixin
-            extends RoleMixin<BuildDeliverySnapshot>
-            implements FactoryRole
-        {
-            @This
-            RouteSpecification routeSpecification;
-
-            ValueBuilder<Delivery> deliveryBuilder;
-
-            public Delivery deriveDeliverySnapshot()
-            {
-                /*
-               * Default values:
-               *
-               * isMisdirected = false
-               * nextExpectedHandlingEvent = null
-               * lastHandlingEvent = null
-               * lastKnownLocation = null
-               * currentVoyage = null
-               * eta = null
-               * isUnloadedAtDestination = false
-               *
-               * */
-
-                // Build delivery snapshot object
-                deliveryBuilder = vbf.newValueBuilder( Delivery.class );
-                context.newDeliverySnapshot = deliveryBuilder.prototype();
-                context.newDeliverySnapshot.timestamp().set( Instant.now() );
-
-                // Deviation 2c: Cargo is not routed yet
-                if( context.itinerary == null )
-                {
-                    return deriveWithRouteSpecification();
-                }
-
-                if( !routeSpecification.isSatisfiedBy( (Itinerary) context.itinerary ) )
-                {
-                    // Deviation 2d: Itinerary not satisfying
-                    context.newDeliverySnapshot.routingStatus().set( RoutingStatus.MISROUTED );
-                }
-                else
-                {
-                    // Step 2
-                    context.newDeliverySnapshot.routingStatus().set( RoutingStatus.ROUTED );
-                    context.newDeliverySnapshot.eta().set( context.itinerary.eta() );
-                }
-
-                // Deviation 3a: Cargo has no handling history yet
-                if( context.handlingEvent == null )
-                {
-                    return deriveWithItinerary();
-                }
-
-                // Step 4: Cargo has a handling history
-                context.handlingEvent.deriveWithHandlingEvent();
-
-                // Step 5: Return Delivery object
-                return deliveryBuilder.newInstance();
-            }
-
-            private Delivery deriveWithRouteSpecification()
-            {
-                // Deviation 2c
-                context.newDeliverySnapshot.routingStatus().set( RoutingStatus.NOT_ROUTED );
-                context.newDeliverySnapshot.transportStatus().set( TransportStatus.NOT_RECEIVED );
-                context.newDeliverySnapshot.nextExpectedHandlingEvent().set( buildExpectedReceiveEvent() );
-                return deliveryBuilder.newInstance();
-            }
-
-            private Delivery deriveWithItinerary()
-            {
-                context.newDeliverySnapshot.transportStatus().set( TransportStatus.NOT_RECEIVED );
-
-                // Deviation 3a.1.a
-                if( context.newDeliverySnapshot.routingStatus().get() == RoutingStatus.ROUTED )
-                {
-                    context.newDeliverySnapshot.nextExpectedHandlingEvent().set( buildExpectedReceiveEvent() );
-                }
-
-                return deliveryBuilder.newInstance();
-            }
-
-            private ExpectedHandlingEvent buildExpectedReceiveEvent()
-            {
-                ValueBuilder<ExpectedHandlingEvent> builder = vbf.newValueBuilder( ExpectedHandlingEvent.class );
-                builder.prototype().handlingEventType().set( HandlingEventType.RECEIVE );
-                builder.prototype().location().set( routeSpecification.origin().get() );
-                return builder.newInstance();
-            }
-        }
-    }
-
-    /**
-     * The HandlingEventRole derives data from the last Handling Event.
-     *
-     * This is where the core domain knowledge about the shipping flow is. Code is organized by the
-     * 6 different handling event types of a cargo:
-     * RECEIVE - LOAD - UNLOAD - CLAIM - CUSTOMS - (UNKNOWN)
-     *
-     * For each HandlingEventType we can reason about the status and what is expected next. This
-     * follows the real world shipping flow rather than data structures of the domain.
-     *
-     * The HandlingEventRole uses the ItineraryRole heavily to calculate values based on Itinerary data.
-     */
-    @Mixins( HandlingEventRole.Mixin.class )
-    public interface HandlingEventRole
-    {
-        void setContext( BuildDeliverySnapshot context );
-
-        void deriveWithHandlingEvent();
-
-        class Mixin
-            extends RoleMixin<BuildDeliverySnapshot>
-            implements HandlingEventRole
-        {
-            /*
-           * HandlingEvent can be from last Delivery snapshot (last expected HandlingEvent) or
-           * a new registered HandlingEvent.
-           * */
-            @This
-            HandlingEvent handlingEvent;
-
-            // Local convenience fields
-            Location lastKnownLocation;
-            Voyage currentVoyage;
-            Boolean cargoIsNotMisrouted;
-
-            // Flag for determining if we should wasUnexpected a former misdirected Handling Event after a reroute
-            Boolean cargoIsRerouted;
-
-            public void deriveWithHandlingEvent()
-            {
-                lastKnownLocation = handlingEvent.location().get();
-                currentVoyage = handlingEvent.voyage().get();
-                cargoIsNotMisrouted = context.newDeliverySnapshot.routingStatus().get() == RoutingStatus.ROUTED;
-
-                // Cargo has been rerouted when the last handling event is declared unexpected.
-                cargoIsRerouted = handlingEvent.wasUnexpected().get();
-
-                // Step 3
-                context.newDeliverySnapshot.lastHandlingEvent().set( handlingEvent );
-                context.newDeliverySnapshot.lastKnownLocation().set( lastKnownLocation );
-
-                // Step 4
-                switch( handlingEvent.handlingEventType().get() )
-                {
-                case RECEIVE:
-                    cargoReceived();        // Deviation 4a
-                    return;
-
-                case LOAD:
-                    cargoLoaded();          // Deviation 4b
-                    return;
-
-                case UNLOAD:
-                    cargoUnloaded();        // Deviation 4c
-                    return;
-
-                case CUSTOMS:
-                    cargoInCustoms();       // Deviation 4d
-                    return;
-
-                case CLAIM:
-                    cargoClaimed();         // Deviation 4e
-                    return;
-
-                default:
-                    unknownHandlingEvent(); // Deviation 4f
-                }
-            }
-
-            // Deviation 4a
-            private void cargoReceived()
-            {
-                context.newDeliverySnapshot.transportStatus().set( TransportStatus.IN_PORT );
-
-                if( !cargoIsRerouted && !context.itinerary.expectsOrigin( lastKnownLocation ) )
-                {
-                    context.newDeliverySnapshot.eta().set( null );
-                    context.newDeliverySnapshot.isMisdirected().set( true );
-                }
-                else if( cargoIsNotMisrouted )
-                {
-                    ExpectedHandlingEvent expectedEvent = context.itinerary.expectedEventAfterReceive();
-                    context.newDeliverySnapshot.nextExpectedHandlingEvent().set( expectedEvent );
-                }
-            }
-
-            // Deviation 4b
-            private void cargoLoaded()
-            {
-                context.newDeliverySnapshot.transportStatus().set( TransportStatus.ONBOARD_CARRIER );
-                context.newDeliverySnapshot.currentVoyage().set( currentVoyage );
-
-                if( cargoIsRerouted )
-                {
-                    // After a reroute following a load in an unexpected location, we expected the cargo to be
-                    // unloaded at the unload location of the first leg of the new itinerary.
-                    ExpectedHandlingEvent expectedEvent = context.itinerary
-                        .expectedEventAfterLoadAt( lastKnownLocation );
-                    context.newDeliverySnapshot.nextExpectedHandlingEvent().set( expectedEvent );
-                }
-                else if( !context.itinerary.expectsLoad( lastKnownLocation, currentVoyage ) )
-                {
-                    context.newDeliverySnapshot.eta().set( null );
-                    context.newDeliverySnapshot.isMisdirected().set( true );
-                }
-                else if( cargoIsNotMisrouted )
-                {
-                    ExpectedHandlingEvent expectedEvent = context.itinerary
-                        .expectedEventAfterLoadAt( lastKnownLocation );
-                    context.newDeliverySnapshot.nextExpectedHandlingEvent().set( expectedEvent );
-                }
-            }
-
-            // Deviation 4c
-            private void cargoUnloaded()
-            {
-                context.newDeliverySnapshot.transportStatus().set( TransportStatus.IN_PORT );
-
-                if( cargoIsRerouted )
-                {
-                    // After a reroute following an unload in an unexpected location, we expected the cargo
-                    // to be loaded onto a carrier at the first location of the new route specification.
-                    ExpectedHandlingEvent expectedEvent = context.itinerary.expectedEventAfterReceive();
-                    context.newDeliverySnapshot.nextExpectedHandlingEvent().set( expectedEvent );
-                }
-                else if( !context.itinerary.expectsUnload( lastKnownLocation, currentVoyage ) )
-                {
-                    context.newDeliverySnapshot.eta().set( null );
-                    context.newDeliverySnapshot.isMisdirected().set( true );
-                }
-                else if( cargoIsNotMisrouted )
-                {
-                    ExpectedHandlingEvent expectedEvent = context.itinerary
-                        .expectedEventAfterUnloadAt( lastKnownLocation );
-                    context.newDeliverySnapshot.nextExpectedHandlingEvent().set( expectedEvent );
-
-                    Location expectedDestination = ( (RouteSpecification) context.factory ).destination().get();
-                    context.newDeliverySnapshot
-                        .isUnloadedAtDestination()
-                        .set( lastKnownLocation.equals( expectedDestination ) );
-                }
-            }
-
-            // Deviation 4d
-            private void cargoInCustoms()
-            {
-                context.newDeliverySnapshot.transportStatus().set( TransportStatus.IN_PORT );
-
-                Location expectedDestination = ( (RouteSpecification) context.factory ).destination().get();
-                context.newDeliverySnapshot
-                    .isUnloadedAtDestination()
-                    .set( lastKnownLocation.equals( expectedDestination ) );
-            }
-
-            // Deviation 4e
-            private void cargoClaimed()
-            {
-                context.newDeliverySnapshot.transportStatus().set( TransportStatus.CLAIMED );
-
-                Location expectedDestination = ( (RouteSpecification) context.factory ).destination().get();
-                context.newDeliverySnapshot
-                    .isUnloadedAtDestination()
-                    .set( lastKnownLocation.equals( expectedDestination ) );
-
-                if( !context.itinerary.expectsDestination( lastKnownLocation ) )
-                {
-                    context.newDeliverySnapshot.eta().set( null );
-                    context.newDeliverySnapshot.isMisdirected().set( true );
-                }
-            }
-
-            // Deviation 4f
-            private void unknownHandlingEvent()
-            {
-                context.newDeliverySnapshot.transportStatus().set( TransportStatus.UNKNOWN );
-            }
-        }
-    }
-
-    /**
-     * The ItineraryRole supports the HandlingEventRole with calculated results derived from Itinerary Legs.
-     */
-    @Mixins( ItineraryRole.Mixin.class )
-    public interface ItineraryRole
-    {
-        void setContext( BuildDeliverySnapshot context );
-
-        LocalDate eta();
-
-        boolean expectsOrigin( Location location );
-
-        boolean expectsLoad( Location location, Voyage voyage );
-
-        boolean expectsUnload( Location location, Voyage voyage );
-
-        boolean expectsDestination( Location location );
-
-        ExpectedHandlingEvent expectedEventAfterReceive();
-
-        ExpectedHandlingEvent expectedEventAfterLoadAt( Location lastLoadLocation );
-
-        ExpectedHandlingEvent expectedEventAfterUnloadAt( Location lastUnloadLocation );
-
-        class Mixin
-            extends RoleMixin<BuildDeliverySnapshot>
-            implements ItineraryRole
-        {
-            @This
-            Itinerary itinerary;
-
-            public LocalDate eta()
-            {
-                return itinerary.lastLeg().unloadDate().get();
-            }
-
-            // Route expectations ----------------------------------------------------
-
-            public boolean expectsOrigin( Location location )
-            {
-                return itinerary.firstLeg().loadLocation().get().equals( location );
-            }
-
-            public boolean expectsLoad( Location location, Voyage voyage )
-            {
-                // One leg with same load location and voyage
-                for( Leg leg : itinerary.legs().get() )
-                {
-                    if( leg.loadLocation().get().equals( location ) && leg.voyage().get().equals( voyage ) )
-                    {
-                        return true;
-                    }
-                }
-                return false;
-            }
-
-            public boolean expectsUnload( Location location, Voyage voyage )
-            {
-                // One leg with same unload location and voyage
-                for( Leg leg : itinerary.legs().get() )
-                {
-                    if( leg.unloadLocation().get().equals( location ) && leg.voyage().get().equals( voyage ) )
-                    {
-                        return true;
-                    }
-                }
-                return false;
-            }
-
-            public boolean expectsDestination( Location location )
-            {
-                // Last leg destination matches
-                return ( itinerary.lastLeg().unloadLocation().get().equals( location ) );
-            }
-
-            // Next expected handling event ----------------------------------------------
-
-            public ExpectedHandlingEvent expectedEventAfterReceive()
-            {
-                // After RECEIVE, expect LOAD location and voyage of first itinerary leg
-                final Leg firstLeg = itinerary.legs().get().iterator().next();
-                return buildEvent( HandlingEventType.LOAD,
-                                   firstLeg.loadLocation().get(),
-                                   firstLeg.loadDate().get(),
-                                   firstLeg.voyage().get() );
-            }
-
-            public ExpectedHandlingEvent expectedEventAfterLoadAt( Location lastLoadLocation )
-            {
-                // After LOAD, expect UNLOAD location and voyage of same itinerary leg as LOAD
-                for( Leg leg : itinerary.legs().get() )
-                {
-                    if( leg.loadLocation().get().equals( lastLoadLocation ) )
-                    {
-                        return buildEvent( HandlingEventType.UNLOAD,
-                                           leg.unloadLocation().get(),
-                                           leg.unloadDate().get(),
-                                           leg.voyage().get() );
-                    }
-                }
-                return null;
-            }
-
-            public ExpectedHandlingEvent expectedEventAfterUnloadAt( Location lastUnloadLocation )
-            {
-                // After UNLOAD, expect LOAD location and voyage of following itinerary leg, or CLAIM if no more legs
-                for( Iterator<Leg> it = itinerary.legs().get().iterator(); it.hasNext(); )
-                {
-                    final Leg leg = it.next();
-                    if( leg.unloadLocation().get().equals( lastUnloadLocation ) )
-                    {
-                        // Cargo has a matching unload location in itinerary
-
-                        if( it.hasNext() )
-                        {
-                            // Cargo has not arrived yet (uncompleted legs in itinerary)
-                            // We expect it to be loaded onto some Carrier
-                            final Leg nextLeg = it.next();
-                            return buildEvent(
-                                HandlingEventType.LOAD,
-                                nextLeg.loadLocation().get(),
-                                nextLeg.loadDate().get(),
-                                nextLeg.voyage().get()
-                            );
-                        }
-                        else
-                        {
-                            // Cargo has arrived (no more legs in itinerary)
-                            // We expect it to be claimed by the customer
-                            return buildEvent( HandlingEventType.CLAIM, leg.unloadLocation().get(), leg.unloadDate()
-                                .get(), null );
-                        }
-                    }
-                }
-
-                // Itinerary doesn't recognize last unload location
-                return null;
-            }
-
-            private ExpectedHandlingEvent buildEvent( HandlingEventType eventType,
-                                                      Location location,
-                                                      LocalDate date,
-                                                      Voyage voyage
-            )
-            {
-                ValueBuilder<ExpectedHandlingEvent> builder = vbf.newValueBuilder( ExpectedHandlingEvent.class );
-                builder.prototype().handlingEventType().set( eventType );
-                builder.prototype().location().set( location );
-                builder.prototype().date().set( date );
-                builder.prototype().voyage().set( voyage );
-                return builder.newInstance();
-            }
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/booking/RouteException.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/booking/RouteException.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/booking/RouteException.java
deleted file mode 100644
index 1a6be9b..0000000
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/booking/RouteException.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *       http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *
- *
- */
-package org.apache.zest.sample.dcicargo.sample_a.context.shipping.booking;
-
-public class RouteException extends RuntimeException
-{
-    public RouteException( String message )
-    {
-        super(message);
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/handling/InspectCargo.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/handling/InspectCargo.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/handling/InspectCargo.java
deleted file mode 100644
index fa49db2..0000000
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/handling/InspectCargo.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *       http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *
- *
- */
-package org.apache.zest.sample.dcicargo.sample_a.context.shipping.handling;
-
-import org.apache.zest.api.injection.scope.Service;
-import org.apache.zest.api.injection.scope.This;
-import org.apache.zest.api.mixin.Mixins;
-import org.apache.zest.sample.dcicargo.sample_a.context.shipping.booking.BuildDeliverySnapshot;
-import org.apache.zest.sample.dcicargo.sample_a.context.support.ApplicationEvents;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.cargo.Cargo;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.delivery.Delivery;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.handling.HandlingEvent;
-import org.apache.zest.sample.dcicargo.sample_a.infrastructure.dci.Context;
-import org.apache.zest.sample.dcicargo.sample_a.infrastructure.dci.RoleMixin;
-
-/**
- * The Inspect Cargo use case updates the delivery history of the cargo and
- * determines if the registered handling event was expected.
- */
-public class InspectCargo extends Context
-{
-    // ROLES ---------------------------------------------------------------------
-
-    private CargoInspectorRole cargoInspector;
-
-    private Cargo cargo;
-    private Delivery delivery;
-
-    // CONTEXT CONSTRUCTORS ------------------------------------------------------
-
-    public InspectCargo( HandlingEvent registeredHandlingEvent )
-    {
-        cargoInspector = rolePlayer( CargoInspectorRole.class, registeredHandlingEvent );
-        cargo = loadEntity( Cargo.class, registeredHandlingEvent.trackingId().get().id().get() );
-        delivery = cargo.delivery().get();
-    }
-
-    // INTERACTIONS --------------------------------------------------------------
-
-    public void inspect()
-    {
-        cargoInspector.inspect();
-    }
-
-    // METHODFUL ROLE IMPLEMENTATIONS --------------------------------------------
-
-    /**
-     * Cargo handling role.
-     */
-    @Mixins( CargoInspectorRole.Mixin.class )
-    public interface CargoInspectorRole
-    {
-        void setContext( InspectCargo context );
-
-        void inspect();
-
-        class Mixin
-            extends RoleMixin<InspectCargo>
-            implements CargoInspectorRole
-        {
-            @This
-            HandlingEvent registeredHandlingEvent;
-
-            @Service
-            ApplicationEvents applicationEvents;
-
-            public void inspect()
-            {
-                // Step 1: Update delivery history of cargo.
-                context.delivery = new BuildDeliverySnapshot( context.cargo, registeredHandlingEvent ).get();
-
-                // Step 2: Replace updated delivery snapshot of cargo
-                context.cargo.delivery().set( context.delivery );
-
-                // Deviation 3a: Publish that cargo was misdirected
-                if( context.delivery.isMisdirected().get() )
-                {
-                    applicationEvents.cargoWasMisdirected( context.cargo );
-                }
-
-                // Deviation 3b: Publish that cargo has arrived
-                if( context.delivery.isUnloadedAtDestination().get() )
-                {
-                    applicationEvents.cargoHasArrived( context.cargo );
-                }
-
-                // Step 4: Updated cargo is saved when UnitOfWork completes.
-            }
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/handling/RegisterHandlingEvent.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/handling/RegisterHandlingEvent.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/handling/RegisterHandlingEvent.java
deleted file mode 100644
index aa73033..0000000
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/handling/RegisterHandlingEvent.java
+++ /dev/null
@@ -1,274 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *       http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *
- *
- */
-package org.apache.zest.sample.dcicargo.sample_a.context.shipping.handling;
-
-import java.time.LocalDate;
-import java.util.Arrays;
-import org.apache.zest.api.injection.scope.Service;
-import org.apache.zest.api.injection.scope.This;
-import org.apache.zest.api.mixin.Mixins;
-import org.apache.zest.api.unitofwork.NoSuchEntityException;
-import org.apache.zest.api.unitofwork.UnitOfWork;
-import org.apache.zest.api.value.ValueBuilder;
-import org.apache.zest.sample.dcicargo.sample_a.context.support.ApplicationEvents;
-import org.apache.zest.sample.dcicargo.sample_a.context.support.RegisterHandlingEventAttemptDTO;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.cargo.Cargo;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.cargo.TrackingId;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.handling.HandlingEvent;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.handling.HandlingEventType;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.handling.HandlingEvents;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.location.Location;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.voyage.Voyage;
-import org.apache.zest.sample.dcicargo.sample_a.infrastructure.dci.Context;
-import org.apache.zest.sample.dcicargo.sample_a.infrastructure.dci.RoleMixin;
-
-import static org.apache.zest.sample.dcicargo.sample_a.data.shipping.handling.HandlingEvents.HANDLING_EVENTS_ID;
-
-/**
- * Register new handling event use case.
- *
- * The Cargo is updated synchronously in this implementation.
- */
-public class RegisterHandlingEvent extends Context
-{
-    // ROLES ---------------------------------------------------------------------
-
-    private HandlingEventFactoryRole handlingEventFactory;
-
-    private LocalDate registrationDate;
-    private LocalDate completionDate;
-    private String trackingIdString;
-    private String eventTypeString;
-    private String unLocodeString;
-    private String voyageNumberString;
-
-    // CONTEXT CONSTRUCTORS ------------------------------------------------------
-
-    public RegisterHandlingEvent( LocalDate registrationDate,
-                                  LocalDate completionDate,
-                                  String trackingIdString,
-                                  String eventTypeString,
-                                  String unLocodeString,
-                                  String voyageNumberString
-    )
-    {
-        handlingEventFactory = rolePlayer( HandlingEventFactoryRole.class, HandlingEvents.class, HANDLING_EVENTS_ID );
-
-        this.registrationDate = registrationDate;
-        this.completionDate = completionDate;
-        this.trackingIdString = trackingIdString;
-        this.eventTypeString = eventTypeString;
-        this.unLocodeString = unLocodeString;
-        this.voyageNumberString = voyageNumberString;
-    }
-
-    // INTERACTIONS --------------------------------------------------------------
-
-    public void register()
-    {
-        handlingEventFactory.registerHandlingEvent();
-    }
-
-    // METHODFUL ROLE IMPLEMENTATIONS --------------------------------------------
-
-    @Mixins( HandlingEventFactoryRole.Mixin.class )
-    public interface HandlingEventFactoryRole
-    {
-        void setContext( RegisterHandlingEvent context );
-
-        void registerHandlingEvent();
-
-        class Mixin
-            extends RoleMixin<RegisterHandlingEvent>
-            implements HandlingEventFactoryRole
-        {
-            @Service
-            ApplicationEvents applicationEvents;
-
-            @This
-            HandlingEvents handlingEvents;
-
-            // Handling event properties
-            TrackingId trackingId;
-            HandlingEventType handlingEventType;
-            Location location;
-            Voyage voyage;
-
-            public void registerHandlingEvent()
-            {
-                RegisterHandlingEventAttemptDTO registrationAttempt = buildRegistrationAttempt();
-
-                // Step 1: Publish event stating that registration attempt has been received.
-                applicationEvents.receivedHandlingEventRegistrationAttempt( registrationAttempt );
-
-                HandlingEvent handlingEvent;
-                try
-                {
-                    // Step 2: Verify existing data
-                    verifyExistingData();
-
-                    // Step 3: Verify that received data can represent a valid handling event
-                    verifyValidData();
-
-                    // Step 4: Create and save handling event
-                    handlingEvent = handlingEvents.createHandlingEvent(
-                        context.registrationDate,
-                        context.completionDate,
-                        trackingId,
-                        handlingEventType,
-                        location,
-                        voyage );
-                }
-                catch( IllegalArgumentException e )
-                {
-                    // Deviation 2-5a: Publish event if registration is unsuccessful
-                    applicationEvents.unsuccessfulHandlingEventRegistration( registrationAttempt );
-                    throw e;
-                }
-
-                // Step 5: Inspect cargo
-                new InspectCargo( handlingEvent ).inspect();
-
-                // Step 6: Publish notification that cargo was successfully handled
-                applicationEvents.cargoWasHandled( handlingEvent );
-            }
-
-            private RegisterHandlingEventAttemptDTO buildRegistrationAttempt()
-            {
-                ValueBuilder<RegisterHandlingEventAttemptDTO> builder =
-                    vbf.newValueBuilder( RegisterHandlingEventAttemptDTO.class );
-                builder.prototype().registrationDate().set( context.registrationDate );
-                builder.prototype().completionDate().set( context.completionDate );
-                builder.prototype().trackingIdString().set( context.trackingIdString );
-                builder.prototype().eventTypeString().set( context.eventTypeString );
-                builder.prototype().unLocodeString().set( context.unLocodeString );
-                builder.prototype().voyageNumberString().set( context.voyageNumberString );
-                return builder.newInstance();
-            }
-
-            private void verifyExistingData()
-            {
-                if( context.registrationDate == null )
-                {
-                    throw new IllegalArgumentException( "Registration time was null. All parameters have to be passed." );
-                }
-                if( context.completionDate == null )
-                {
-                    throw new IllegalArgumentException( "Completion time was null. All parameters have to be passed." );
-                }
-
-                context.trackingIdString = getClean( "Tracking id", context.trackingIdString );
-                context.eventTypeString = getClean( "Event type", context.eventTypeString );
-                context.unLocodeString = getClean( "UnLocode", context.unLocodeString );
-
-                // Voyage is optional
-            }
-
-            private String getClean( String parameter, String value )
-            {
-                if( value == null )
-                {
-                    throw new IllegalArgumentException( parameter + " was null. All parameters have to be passed." );
-                }
-
-                if( value.trim().length() == 0 )
-                {
-                    throw new IllegalArgumentException( parameter + " cannot be empty." );
-                }
-
-                return value.trim();
-            }
-
-            private void verifyValidData()
-            {
-                // Deviation 3a
-                try
-                {
-                    handlingEventType = HandlingEventType.valueOf( context.eventTypeString );
-                }
-                catch( Exception e )
-                {
-                    throw new IllegalArgumentException(
-                        "'" + context.eventTypeString + "' is not a valid handling event type. Valid types are: "
-                        + Arrays.toString( HandlingEventType.values() ) );
-                }
-
-                // Verifications against data store
-                UnitOfWork uow = uowf.currentUnitOfWork();
-
-                // Deviation 3b
-                try
-                {
-                    // Will throw NoSuchEntityException if not found in store
-                    Cargo cargo = uow.get( Cargo.class, context.trackingIdString );
-                    trackingId = cargo.trackingId().get();
-
-                    // Deviation 3c
-                    if( cargo.itinerary().get() == null )
-                    {
-                        throw new IllegalArgumentException( "Can't create handling event for non-routed cargo '"
-                                                            + context.trackingIdString + "'." );
-                    }
-                }
-                catch( NoSuchEntityException e )
-                {
-                    throw new IllegalArgumentException( "Found no cargo with tracking id '" + context.trackingIdString + "'." );
-                }
-
-                // Deviation 3d
-                try
-                {
-                    location = uow.get( Location.class, context.unLocodeString );
-                }
-                catch( NoSuchEntityException e )
-                {
-                    throw new IllegalArgumentException( "Unknown location: " + context.unLocodeString );
-                }
-
-                // Deviation 3e
-                if( handlingEventType.requiresVoyage() )
-                {
-                    // Deviation 3e1a
-                    if( context.voyageNumberString == null )
-                    {
-                        throw new IllegalArgumentException( "Handling event " + handlingEventType.toString() +
-                                                            " requires a voyage. No voyage number submitted." );
-                    }
-
-                    // Deviation 3e1b
-                    try
-                    {
-                        voyage = uow.get( Voyage.class, context.voyageNumberString );
-                    }
-                    catch( NoSuchEntityException e )
-                    {
-                        throw new IllegalArgumentException(
-                            "Found no voyage with voyage number '" + context.voyageNumberString + "'." );
-                    }
-                }
-                else
-                {
-                    // Deviation 3f
-                    voyage = null;
-                }
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/support/ApplicationEvents.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/support/ApplicationEvents.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/support/ApplicationEvents.java
deleted file mode 100644
index 5f29685..0000000
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/support/ApplicationEvents.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *       http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *
- *
- */
-package org.apache.zest.sample.dcicargo.sample_a.context.support;
-
-import java.time.LocalDate;
-import java.time.format.DateTimeFormatter;
-import org.apache.zest.api.mixin.Mixins;
-import org.apache.zest.api.service.ServiceComposite;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.cargo.Cargo;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.handling.HandlingEvent;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.voyage.Voyage;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * "Messaging"
- *
- * This interface provides a way to let other parts of the system know about events that have occurred.
- * For now, no notifications are passed on but could be implemented here using for example JMS.
- */
-@Mixins( ApplicationEvents.SynchronousApplicationEventsStub.class )
-public interface ApplicationEvents
-    extends ServiceComposite
-{
-    /**
-     * A cargo has been handled.
-     *
-     * @param registeredHandlingEvent handling event
-     */
-    void cargoWasHandled( HandlingEvent registeredHandlingEvent );
-
-    /**
-     * A cargo has been misdirected.
-     *
-     * @param cargo cargo
-     */
-    void cargoWasMisdirected( Cargo cargo );
-
-    /**
-     * A cargo has arrived at its final destination.
-     *
-     * @param cargo cargo
-     */
-    void cargoHasArrived( Cargo cargo );
-
-    /**
-     * A handling event registration attempt is received.
-     *
-     * @param attempt Handling event registration attempt
-     */
-    void receivedHandlingEventRegistrationAttempt( RegisterHandlingEventAttemptDTO attempt );
-
-    void unsuccessfulHandlingEventRegistration( RegisterHandlingEventAttemptDTO attempt );
-
-    // Default implementation (could be substituted in assembly)
-    abstract class SynchronousApplicationEventsStub
-        implements ApplicationEvents
-    {
-        String id;
-        String time;
-        String type;
-        String unloc;
-        String loc;
-        String voyage;
-
-        Logger logger = LoggerFactory.getLogger( ApplicationEvents.class );
-
-        public void cargoWasHandled( HandlingEvent registeredHandlingEvent )
-        {
-            id = registeredHandlingEvent.trackingId().get().id().get();
-            time = parseDate( registeredHandlingEvent.completionDate().get() );
-            type = registeredHandlingEvent.handlingEventType().get().name();
-            unloc = registeredHandlingEvent.location().get().getCode();
-            loc = registeredHandlingEvent.location().get().name().get();
-            Voyage voy = registeredHandlingEvent.voyage().get();
-            voyage = voy != null ? ", voyage " + voy.voyageNumber().get().number().get() : "";
-
-            logger.info( "  Cargo '" + id + "' was handled " + time
-                         + " (" + type + " in " + loc + "/" + unloc + voyage + ")." );
-        }
-
-        public void cargoWasMisdirected( Cargo cargo )
-        {
-            id = cargo.trackingId().get().id().get();
-            loc = cargo.delivery().get().lastKnownLocation().get().name().get();
-            unloc = cargo.delivery().get().lastKnownLocation().get().toString();
-            type = cargo.delivery().get().lastHandlingEvent().get().handlingEventType().get().name();
-
-            logger.info( "  Unexpected " + type + " of cargo '" + id
-                         + "' in " + loc + "/" + unloc + "." );
-            logger.info( "  NOTIFICATION TO CUSTOMER: Please re-route misdirected cargo '"
-                         + id + "' (now in " + loc + ")." );
-        }
-
-        public void cargoHasArrived( Cargo cargo )
-        {
-            id = cargo.trackingId().get().id().get();
-            loc = cargo.delivery().get().lastKnownLocation().get().name().get();
-            unloc = cargo.delivery().get().lastKnownLocation().get().toString();
-
-            logger.info( "  Cargo '" + id + "' has arrived in " + loc + "/" + unloc + "." );
-            logger.info( "  NOTIFICATION TO CUSTOMER: Please claim cargo '" + id + "' in " + loc + "." );
-        }
-
-        public void receivedHandlingEventRegistrationAttempt( RegisterHandlingEventAttemptDTO attempt )
-        {
-            time = parseDate( attempt.completionDate().get() );
-            id = parse( attempt.trackingIdString().get() );
-            type = parse( attempt.eventTypeString().get() );
-            unloc = parse( attempt.unLocodeString().get() );
-            voyage = parse( attempt.voyageNumberString().get() );
-
-            logger.info( "  Handling registration attempt received ("
-                         + time + ", " + id + ", " + type + ", " + unloc + ", " + voyage + ")." );
-        }
-
-        public void unsuccessfulHandlingEventRegistration( RegisterHandlingEventAttemptDTO attempt )
-        {
-            id = attempt.trackingIdString().get();
-            type = attempt.eventTypeString().get();
-            unloc = attempt.unLocodeString().get();
-
-            logger.info( "  Unsuccessful handling event registration for cargo '"
-                         + id + "' (handling event '" + type + "' in '" + unloc + "')." );
-        }
-
-        private String parse( String str )
-        {
-            return str == null ? "null" : str;
-        }
-
-        private String parseDate( LocalDate date )
-        {
-            return date == null ? "null" : DateTimeFormatter.ISO_DATE.format( date );
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/support/FoundNoRoutesException.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/support/FoundNoRoutesException.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/support/FoundNoRoutesException.java
deleted file mode 100644
index 6a8d941..0000000
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/support/FoundNoRoutesException.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *       http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *
- *
- */
-package org.apache.zest.sample.dcicargo.sample_a.context.support;
-
-import java.time.LocalDate;
-
-/**
- * Custom messages when the deadline is too close and we can't find a route.
- */
-public class FoundNoRoutesException extends Exception
-{
-    private final String city;
-    private final LocalDate deadline;
-
-    public FoundNoRoutesException( String city, LocalDate deadline )
-    {
-        this.city = city;
-        this.deadline = deadline;
-    }
-
-    @Override
-    public String getMessage()
-    {
-        if( deadline.isBefore( LocalDate.now().plusDays( 2 ) ) )
-        {
-            return "Impossible to get the cargo to " + city + " before " + deadline
-                   + "! Make a new booking with a deadline 2-3 weeks ahead in time.";
-        }
-        else if( deadline.isBefore( LocalDate.now().plusDays( 4 ) ) )
-        {
-            return "Couldn't find any routes arriving in " + city + " before " + deadline
-                   + ". Please try again or make a new booking with a deadline 2-3 weeks ahead in time.";
-        }
-        else if( deadline.isBefore( LocalDate.now().plusDays( 6 ) ) )
-        {
-            return "Sorry, our system couldn't immediately find a route arriving in " + city + " before " + deadline
-                   + ". Please try again, and we should hopefully be able to find a new route for you.";
-        }
-
-        return "Couldn't find any route to " + city + " arriving before " + deadline
-               + ". We don't know why. Have a nice day.";
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/support/RegisterHandlingEventAttemptDTO.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/support/RegisterHandlingEventAttemptDTO.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/support/RegisterHandlingEventAttemptDTO.java
deleted file mode 100644
index 5562fba..0000000
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/support/RegisterHandlingEventAttemptDTO.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *       http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *
- *
- */
-package org.apache.zest.sample.dcicargo.sample_a.context.support;
-
-import java.time.LocalDate;
-import org.apache.zest.api.common.Optional;
-import org.apache.zest.api.property.Immutable;
-import org.apache.zest.api.property.Property;
-import org.apache.zest.sample.dcicargo.sample_a.infrastructure.conversion.DTO;
-
-/**
- * The RegisterHandlingEventAttemptDTO simply helps move event registration data around.
- */
-@Immutable
-public interface RegisterHandlingEventAttemptDTO extends DTO
-{
-    @Optional
-    Property<LocalDate> registrationDate();
-
-    @Optional
-    Property<LocalDate> completionDate();
-
-    @Optional
-    Property<String> trackingIdString();
-
-    @Optional
-    Property<String> eventTypeString();
-
-    @Optional
-    Property<String> unLocodeString();
-
-    @Optional
-    Property<String> voyageNumberString();
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/support/RoutingService.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/support/RoutingService.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/support/RoutingService.java
deleted file mode 100644
index c2d0787..0000000
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/support/RoutingService.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *       http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *
- *
- */
-package org.apache.zest.sample.dcicargo.sample_a.context.support;
-
-import java.rmi.RemoteException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import org.apache.zest.api.injection.scope.Service;
-import org.apache.zest.api.injection.scope.Structure;
-import org.apache.zest.api.mixin.Mixins;
-import org.apache.zest.api.service.ServiceComposite;
-import org.apache.zest.api.unitofwork.UnitOfWork;
-import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
-import org.apache.zest.api.value.ValueBuilder;
-import org.apache.zest.api.value.ValueBuilderFactory;
-import org.apache.zest.sample.dcicargo.pathfinder_a.api.GraphTraversalService;
-import org.apache.zest.sample.dcicargo.pathfinder_a.api.TransitEdge;
-import org.apache.zest.sample.dcicargo.pathfinder_a.api.TransitPath;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.cargo.RouteSpecification;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.itinerary.Itinerary;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.itinerary.Leg;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.location.Location;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.voyage.Voyage;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Routing service.
- *
- * Our end of the routing service. This is basically a data model
- * translation layer between our domain model and the API put forward
- * by the path finder team, which operates in a different context from us.
- */
-@Mixins( RoutingService.Mixin.class )
-public interface RoutingService
-    extends ServiceComposite
-{
-    /**
-     * @param routeSpecification route specification
-     *
-     * @return A list of itineraries that satisfy the specification. May be an empty list if no route is found.
-     */
-    List<Itinerary> fetchRoutesForSpecification( RouteSpecification routeSpecification )
-        throws FoundNoRoutesException;
-
-    abstract class Mixin
-        implements RoutingService
-    {
-        private static final Logger logger = LoggerFactory.getLogger( RoutingService.class );
-
-        @Structure
-        ValueBuilderFactory vbf;
-
-        @Structure
-        UnitOfWorkFactory uowf;
-
-        @Service
-        GraphTraversalService graphTraversalService;
-
-        final static int MAX_TRIES = 10;
-
-        public List<Itinerary> fetchRoutesForSpecification( RouteSpecification routeSpecification )
-            throws FoundNoRoutesException
-        {
-            final Location origin = routeSpecification.origin().get();
-            final Location destination = routeSpecification.destination().get();
-
-            List<TransitPath> transitPaths;
-            List<Itinerary> itineraries = new ArrayList<Itinerary>();
-
-            // Try a MAX_TRIES times to avoid empty results too often
-            int tries = 0;
-            do
-            {
-                try
-                {
-                    transitPaths = graphTraversalService.findShortestPath( origin.getCode(), destination.getCode() );
-                }
-                catch( RemoteException e )
-                {
-                    logger.error( e.getMessage(), e );
-                    return Collections.emptyList();
-                }
-
-                // The returned result is then translated back into our domain model.
-                for( TransitPath transitPath : transitPaths )
-                {
-                    final Itinerary itinerary = toItinerary( transitPath );
-
-                    // Use the specification to safe-guard against invalid itineraries
-                    // We can use the side-effects free method of the RouteSpecification data object
-                    if( routeSpecification.isSatisfiedBy( itinerary ) )
-                    {
-                        itineraries.add( itinerary );
-                    }
-                }
-            }
-            while( tries++ < MAX_TRIES && itineraries.size() == 0 );
-
-            if( itineraries.size() == 0 )
-            {
-                throw new FoundNoRoutesException( destination.name().get(),
-                                                  routeSpecification.arrivalDeadline().get() );
-            }
-
-            return itineraries;
-        }
-
-        private Itinerary toItinerary( TransitPath transitPath )
-        {
-            ValueBuilder<Itinerary> itinerary = vbf.newValueBuilder( Itinerary.class );
-            List<Leg> legs = new ArrayList<Leg>();
-            for( TransitEdge edge : transitPath.getTransitEdges() )
-            {
-                legs.add( toLeg( edge ) );
-            }
-            itinerary.prototype().legs().set( legs );
-
-            return itinerary.newInstance();
-        }
-
-        private Leg toLeg( TransitEdge edge )
-        {
-            UnitOfWork uow = uowf.currentUnitOfWork();
-
-            // Build Leg value object
-            ValueBuilder<Leg> leg = vbf.newValueBuilder( Leg.class );
-            leg.prototype().voyage().set( uow.get( Voyage.class, edge.getVoyageNumber() ) );
-            leg.prototype().loadLocation().set( uow.get( Location.class, edge.getFromUnLocode() ) );
-            leg.prototype().unloadLocation().set( uow.get( Location.class, edge.getToUnLocode() ) );
-            leg.prototype().loadDate().set( edge.getFromDate() );
-            leg.prototype().unloadDate().set( edge.getToDate() );
-
-            return leg.newInstance();
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/cargo/Cargo.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/cargo/Cargo.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/cargo/Cargo.java
deleted file mode 100644
index 1d6e78f..0000000
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/cargo/Cargo.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *       http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *
- *
- */
-package org.apache.zest.sample.dcicargo.sample_a.data.shipping.cargo;
-
-import org.apache.zest.api.association.Association;
-import org.apache.zest.api.common.Optional;
-import org.apache.zest.api.entity.Identity;
-import org.apache.zest.api.property.Immutable;
-import org.apache.zest.api.property.Property;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.delivery.Delivery;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.itinerary.Itinerary;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.location.Location;
-
-/**
- * Cargo data
- *
- * {@link TrackingId}           created automatically
- * {@link Location} origin      Specified upon creation (mandatory)
- * {@link RouteSpecification}   Specified upon creation (mandatory)
- * {@link Delivery}             A calculated snapshot of the current delivery status (created by system)
- * {@link Itinerary}            Description of chosen route (optional)
- */
-public interface Cargo extends Identity
-{
-    @Immutable
-    Property<TrackingId> trackingId();
-
-    @Immutable
-    Association<Location> origin();
-
-    Property<RouteSpecification> routeSpecification();
-
-    Property<Delivery> delivery();
-
-    @Optional
-    Property<Itinerary> itinerary();
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/cargo/Cargos.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/cargo/Cargos.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/cargo/Cargos.java
deleted file mode 100644
index 2165575..0000000
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/cargo/Cargos.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *       http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *
- *
- */
-package org.apache.zest.sample.dcicargo.sample_a.data.shipping.cargo;
-
-import java.util.UUID;
-import org.apache.zest.api.common.Optional;
-import org.apache.zest.api.entity.EntityBuilder;
-import org.apache.zest.api.injection.scope.Structure;
-import org.apache.zest.api.mixin.Mixins;
-import org.apache.zest.api.unitofwork.UnitOfWork;
-import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
-import org.apache.zest.api.value.ValueBuilder;
-import org.apache.zest.api.value.ValueBuilderFactory;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.delivery.Delivery;
-
-/**
- * Cargo "collection" - could have had a many-association to cargos if it was part of the domain model.
- */
-@Mixins( Cargos.Mixin.class )
-public interface Cargos
-{
-    String CARGOS_ID = "Cargos_id";
-
-    Cargo createCargo( RouteSpecification routeSpecification, Delivery delivery, @Optional String id );
-
-    class Mixin
-        implements Cargos
-    {
-        @Structure
-        UnitOfWorkFactory uowf;
-
-        @Structure
-        ValueBuilderFactory vbf;
-
-        public Cargo createCargo( RouteSpecification routeSpecification, Delivery delivery, String id )
-        {
-            TrackingId trackingId = buildTrackingId( id );
-
-            UnitOfWork uow = uowf.currentUnitOfWork();
-            EntityBuilder<Cargo> cargoBuilder = uow.newEntityBuilder( Cargo.class, trackingId.id().get() );
-            cargoBuilder.instance().trackingId().set( trackingId );
-            cargoBuilder.instance().origin().set( routeSpecification.origin().get() );
-            cargoBuilder.instance().routeSpecification().set( routeSpecification );
-            cargoBuilder.instance().delivery().set( delivery );
-
-            return cargoBuilder.newInstance();
-        }
-
-        private TrackingId buildTrackingId( String id )
-        {
-            if( id == null || id.trim().equals( "" ) )
-            {
-                // Build random tracking id
-                final String uuid = UUID.randomUUID().toString().toUpperCase();
-                id = uuid.substring( 0, uuid.indexOf( "-" ) );
-            }
-
-            ValueBuilder<TrackingId> trackingIdBuilder = vbf.newValueBuilder( TrackingId.class );
-            trackingIdBuilder.prototype().id().set( id );
-            return trackingIdBuilder.newInstance();
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/cargo/RouteSpecification.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/cargo/RouteSpecification.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/cargo/RouteSpecification.java
deleted file mode 100644
index a7c09c3..0000000
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/cargo/RouteSpecification.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *       http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *
- *
- */
-package org.apache.zest.sample.dcicargo.sample_a.data.shipping.cargo;
-
-import java.time.LocalDate;
-import org.apache.zest.api.association.Association;
-import org.apache.zest.api.mixin.Mixins;
-import org.apache.zest.api.property.Property;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.itinerary.Itinerary;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.location.Location;
-
-/**
- * A route specification describes:
- * - where a cargo is going from (origin)
- * - where a cargo is going to (destination)
- * - when a cargo is expected to arrive at the latest (deadline)
- *
- * If the route specification needs to change because of unexpected
- * handling events, it's replaced with a new one.
- *
- * A route specification "is satisfied" when an itinerary meets the requirements:
- * - First leg of itinerary has same location as origin in route specification
- * - Last leg of itinerary has same location as destination in route specification
- * - Arrival deadline is before deadline of route specification
- *
- * DCI Data is supposed to be dumb. Can we accept to have the specification
- * logic here?
- *
- * All properties are mandatory and immutable.
- * If the destination needs to change, a new RouteSpecification value object is created.
- */
-@Mixins( RouteSpecification.Mixin.class )
-public interface RouteSpecification
-{
-    Association<Location> origin();
-
-    Association<Location> destination();
-
-    Property<LocalDate> arrivalDeadline();
-
-    // Can we accept to have this "intelligent" logic here?
-    // DCI Data is supposed to be dumb, but it's really convenient to have this logic here,
-    // and there's no dependencies involved...
-    boolean isSatisfiedBy( Itinerary itinerary );
-
-    abstract class Mixin
-        implements RouteSpecification
-    {
-        public boolean isSatisfiedBy( Itinerary itinerary )
-        {
-            return itinerary != null &&
-                   !itinerary.legs().get().isEmpty() &&
-                   origin().get().equals( itinerary.firstLeg().loadLocation().get() ) &&
-                   destination().get().equals( itinerary.lastLeg().unloadLocation().get() ) &&
-                   arrivalDeadline().get().isAfter( itinerary.finalArrivalDate() );
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/cargo/TrackingId.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/cargo/TrackingId.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/cargo/TrackingId.java
deleted file mode 100644
index f2dd4cc..0000000
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/cargo/TrackingId.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *       http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *
- *
- */
-package org.apache.zest.sample.dcicargo.sample_a.data.shipping.cargo;
-
-import org.apache.zest.api.property.Property;
-import org.apache.zest.api.value.ValueComposite;
-import org.apache.zest.library.constraints.annotation.NotEmpty;
-
-/**
- * A TrackingId uniquely identifies a particular cargo.
- * Automatically generated by the application.
- */
-public interface TrackingId extends ValueComposite
-{
-    @NotEmpty
-    Property<String> id();
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/delivery/Delivery.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/delivery/Delivery.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/delivery/Delivery.java
deleted file mode 100644
index 759227a..0000000
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/delivery/Delivery.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *       http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *
- *
- */
-package org.apache.zest.sample.dcicargo.sample_a.data.shipping.delivery;
-
-import java.time.Instant;
-import java.time.LocalDate;
-import org.apache.zest.api.association.Association;
-import org.apache.zest.api.common.Optional;
-import org.apache.zest.api.common.UseDefaults;
-import org.apache.zest.api.property.Property;
-import org.apache.zest.api.value.ValueComposite;
-import org.apache.zest.sample.dcicargo.sample_a.context.support.ApplicationEvents;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.cargo.RouteSpecification;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.handling.HandlingEvent;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.itinerary.Itinerary;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.location.Location;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.voyage.Voyage;
-
-/**
- * The Delivery describes the actual transportation of the cargo, as opposed to
- * the customer requirement {@link RouteSpecification} and the plan {@link Itinerary}.
- *
- * Complex data of the shipping domain is captured here in a value object that is
- * re-created each time some delivery status changes.
- *
- * Booking
- * The life cycle of a cargo begins with the booking procedure. During a (short) period
- * of time, between booking and initial routing, the cargo has no itinerary and is therefore
- * not_routed.
- *
- * Routing
- * The booking clerk requests a list of possible routes, matching the route specification,
- * and assigns the cargo to one route. The route to which a cargo is assigned is described
- * by an itinerary. The cargo is now routed.
- *
- * Handling
- * Receipt of the cargo in the origin location marks the beginning of a series of handling
- * events that will eventually deliver the cargo at the destination. Handling events are
- * supposed to be registered by local authorities and sent asynchronously to the cargo system
- * which then re-calculate and replaces the delivery value object of the cargo.
- * (In this implementation the trigger is synchronous in {@link ApplicationEvents}
- * and the registration-ui is close to the booking and tracking interfaces for simplicity).
- *
- * Change of destination
- * It may also happen that a cargo is accidentally misrouted when a new destination is
- * selected in the middle of the voyage of the cargo. The cargo then becomes misrouted,
- * which should notify the proper personnel and also trigger a re-routing procedure.
- * In this implementation a synchronous message is sent to system output.
- *
- * Re-routing
- * A cargo can be re-routed during transport, on demand of the customer, in which case
- * a new route is specified for the cargo and a new route is requested. The old itinerary,
- * being a value object, is discarded and a new one is attached to the cargo.
- *
- * Customs
- * The cargo can be checked by the custom authorities anytime during the delivery. In that
- * case it's unknown what happens next so the cargo is then considered misdirected.
- *
- * Claim
- * The life cycle of a cargo ends when the cargo is claimed by the customer.
- */
-public interface Delivery
-{
-    Property<Instant> timestamp();
-
-    /*
-   * NOT_ROUTED
-   * ROUTED
-   * MISROUTED
-   * */
-    Property<RoutingStatus> routingStatus();
-
-    /*
-   * NOT_RECEIVED
-   * IN_PORT
-   * ONBOARD_CARRIER
-   * CLAIMED
-   * UNKNOWN
-   * */
-    Property<TransportStatus> transportStatus();
-
-    // Unexpected location of cargo according to itinerary
-    @UseDefaults
-    Property<Boolean> isMisdirected();
-
-    /**
-     * RECEIVE
-     * LOAD
-     * UNLOAD
-     * CUSTOMS
-     * CLAIM
-     *
-     * ("HandlingActivity" in DDD sample)
-     */
-    @Optional
-    Property<ExpectedHandlingEvent> nextExpectedHandlingEvent();
-
-    @Optional
-    Association<HandlingEvent> lastHandlingEvent();
-
-    @Optional
-    Association<Location> lastKnownLocation();
-
-    @Optional
-    Association<Voyage> currentVoyage();
-
-    @Optional
-    Property<LocalDate> eta();
-
-    @UseDefaults
-    Property<Boolean> isUnloadedAtDestination();
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/delivery/ExpectedHandlingEvent.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/delivery/ExpectedHandlingEvent.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/delivery/ExpectedHandlingEvent.java
deleted file mode 100644
index 063eb2b..0000000
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/delivery/ExpectedHandlingEvent.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *       http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *
- *
- */
-package org.apache.zest.sample.dcicargo.sample_a.data.shipping.delivery;
-
-import java.time.LocalDate;
-import org.apache.zest.api.association.Association;
-import org.apache.zest.api.common.Optional;
-import org.apache.zest.api.property.Property;
-import org.apache.zest.api.value.ValueComposite;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.handling.HandlingEventType;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.location.Location;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.voyage.Voyage;
-
-/**
- * An expected handling event (former "HandlingActivity") represents how and where a cargo
- * is expected to be handled next.
- */
-public interface ExpectedHandlingEvent
-{
-    Property<HandlingEventType> handlingEventType();
-
-    Association<Location> location();
-
-    // Added expected time for the event to happen (compared to the original DDD sample)
-    @Optional
-    Property<LocalDate> date();
-
-    @Optional
-    Association<Voyage> voyage();
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/delivery/RoutingStatus.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/delivery/RoutingStatus.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/delivery/RoutingStatus.java
deleted file mode 100644
index 3743520..0000000
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/delivery/RoutingStatus.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *       http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *
- *
- */
-package org.apache.zest.sample.dcicargo.sample_a.data.shipping.delivery;
-
-/**
- * A routing status indicates whether an itinerary is assigned to
- * a cargo and satisfying the route specification.
- */
-public enum RoutingStatus
-{
-    NOT_ROUTED,    // Itinerary has not been assigned to cargo yet
-    ROUTED,        // Itinerary is assigned to cargo
-    MISROUTED;     // RouteSpecification is not satisfied by Itinerary
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/delivery/TransportStatus.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/delivery/TransportStatus.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/delivery/TransportStatus.java
deleted file mode 100644
index 6162af6..0000000
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/delivery/TransportStatus.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *       http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *
- *
- */
-package org.apache.zest.sample.dcicargo.sample_a.data.shipping.delivery;
-
-/**
- * A transport status represents what transportation state a cargo is in.
- */
-public enum TransportStatus
-{
-    NOT_RECEIVED,
-    IN_PORT,
-    ONBOARD_CARRIER,
-    CLAIMED,
-    UNKNOWN
-}


Mime
View raw message