polygene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nic...@apache.org
Subject [18/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:59 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/bootstrap/assembly/Assembler.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/bootstrap/assembly/Assembler.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/bootstrap/assembly/Assembler.java
deleted file mode 100644
index 6572766..0000000
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/bootstrap/assembly/Assembler.java
+++ /dev/null
@@ -1,279 +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.bootstrap.assembly;
-
-import java.util.function.Function;
-import org.apache.zest.api.structure.Application;
-import org.apache.zest.api.structure.Module;
-import org.apache.zest.api.value.ValueSerialization;
-import org.apache.zest.bootstrap.ApplicationAssembler;
-import org.apache.zest.bootstrap.ApplicationAssembly;
-import org.apache.zest.bootstrap.ApplicationAssemblyFactory;
-import org.apache.zest.bootstrap.AssemblyException;
-import org.apache.zest.bootstrap.LayerAssembly;
-import org.apache.zest.bootstrap.ModuleAssembly;
-import org.apache.zest.entitystore.memory.MemoryEntityStoreService;
-import org.apache.zest.index.rdf.RdfIndexingEngineService;
-import org.apache.zest.library.rdf.entity.EntityStateSerializer;
-import org.apache.zest.library.rdf.entity.EntityTypeSerializer;
-import org.apache.zest.library.rdf.repository.MemoryRepositoryService;
-import org.apache.zest.sample.dcicargo.pathfinder_a.api.GraphTraversalService;
-import org.apache.zest.sample.dcicargo.pathfinder_a.internal.GraphDAO;
-import org.apache.zest.sample.dcicargo.pathfinder_a.internal.GraphTraversalServiceImpl;
-import org.apache.zest.sample.dcicargo.sample_a.bootstrap.DCISampleApplication_a;
-import org.apache.zest.sample.dcicargo.sample_a.bootstrap.sampledata.BaseDataService;
-import org.apache.zest.sample.dcicargo.sample_a.bootstrap.sampledata.SampleDataService;
-import org.apache.zest.sample.dcicargo.sample_a.communication.query.BookingQueries;
-import org.apache.zest.sample.dcicargo.sample_a.context.rolemap.CargoRoleMap;
-import org.apache.zest.sample.dcicargo.sample_a.context.rolemap.CargosRoleMap;
-import org.apache.zest.sample.dcicargo.sample_a.context.rolemap.HandlingEventRoleMap;
-import org.apache.zest.sample.dcicargo.sample_a.context.rolemap.HandlingEventsRoleMap;
-import org.apache.zest.sample.dcicargo.sample_a.context.rolemap.ItineraryRoleMap;
-import org.apache.zest.sample.dcicargo.sample_a.context.rolemap.RouteSpecificationRoleMap;
-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.context.support.RoutingService;
-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.delivery.Delivery;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.delivery.ExpectedHandlingEvent;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.handling.HandlingEvent;
-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.location.UnLocode;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.voyage.CarrierMovement;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.voyage.Schedule;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.voyage.Voyage;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.voyage.VoyageNumber;
-import org.apache.zest.spi.uuid.UuidIdentityGeneratorService;
-import org.apache.zest.valueserialization.orgjson.OrgJsonValueSerializationService;
-
-import static org.apache.zest.api.common.Visibility.application;
-import static org.apache.zest.api.structure.Application.Mode.development;
-
-/**
- * Zest assembly of the DCI Sample application (version A)
- *
- * A Zest application structure is declared by an assembly that defines which layers and modules
- * the application has and how they are allowed to depend on each other. Each layer could have it's
- * own assembly file in larger applications (read more at http://zest.apache.org/latest/core-bootstrap-assembly.html).
- *
- * The Zest assembly doesn't follow a strict 1-1 correlation between the directory hierarchy and
- * the assembly structures. An example is the Entities:
- *
- * Entities can be promoted to Role Players when they are needed to play a Role in a Context.
- * One Role Map is created for each Entity and it lists Roles in different Contexts that the Entity
- * can play. It hence has knowledge about the Context layer. If an Entity is in a Role Map it doesn't
- * get assembled as an Entity down in the Data layer but rather up in the CONTEXT-EntityRole module.
- * The Entities left behind without Roles could still have been assembled in a DATA-Entity module but
- * to avoid swapping Entities up and down between the Data and Context layers we have them all in the
- * Context layer. Note that there are still no "physical" upward dependencies from the Entities to
- * layers above.
- *
- * So dependency structure layers (ie. as shown by Structure101) are not the same as Zest layers.
- * See more at http://zest.apache.org/latest/core-bootstrap-assembly.html
- *
- * TRY THIS: Run VisualizeApplicationStructure to see a cool visualization of the assembly below!
- */
-@SuppressWarnings( "unchecked" )
-public class Assembler
-    implements ApplicationAssembler
-{
-    public ApplicationAssembly assemble( ApplicationAssemblyFactory applicationFactory )
-        throws AssemblyException
-    {
-        // Application assembly
-        ApplicationAssembly assembly = applicationFactory.newApplicationAssembly();
-        assembly.setName( "DCI Sample (version A)" );
-        assembly.setVersion( "A.1.0" );
-        assembly.setMode( development );
-
-        // Layers (adding bottom-up - will be assembled in this order)
-        LayerAssembly infrastructureLayer = assembly.layer( "INFRASTRUCTURE" );
-        LayerAssembly dataLayer = assembly.layer( "DATA" );
-        LayerAssembly contextLayer = assembly.layer( "CONTEXT" );
-        LayerAssembly communicationLayer = assembly.layer( "COMMUNICATION" );
-        LayerAssembly bootstrapLayer = assembly.layer( "BOOTSTRAP" );
-
-        // Layer dependencies
-        bootstrapLayer.uses(
-            communicationLayer,
-            contextLayer,
-            dataLayer,
-            infrastructureLayer );
-
-        communicationLayer.uses(
-            contextLayer,
-            dataLayer,
-            infrastructureLayer );
-
-        contextLayer.uses(
-            dataLayer,
-            infrastructureLayer );
-
-        dataLayer.uses(
-            infrastructureLayer
-        );
-
-        // Assemble
-        assembleBootstrapLayer( bootstrapLayer );
-        assembleCommunicationLayer( communicationLayer );
-        assembleContextLayer( contextLayer );
-        assembleDataLayer( dataLayer );
-        assembleInfrastructureLayer( infrastructureLayer );
-
-        return assembly;
-    }
-
-    private void assembleBootstrapLayer( LayerAssembly bootstrapLayer )
-        throws AssemblyException
-    {
-        ModuleAssembly bootstrapModule = bootstrapLayer.module( "BOOTSTRAP-Bootstrap" );
-        bootstrapModule
-            .objects(
-                DCISampleApplication_a.class );
-
-        // Load sample data on startup
-        bootstrapModule
-            .addServices(
-                BaseDataService.class )
-            .instantiateOnStartup();
-        bootstrapModule
-            .addServices(
-                SampleDataService.class )
-            .instantiateOnStartup();
-    }
-
-    private void assembleCommunicationLayer( LayerAssembly communicationLayer )
-        throws AssemblyException
-    {
-        ModuleAssembly queryModule = communicationLayer.module( "COMMUNICATION-Query" );
-        queryModule
-            .transients(
-                BookingQueries.class )
-            .visibleIn( application );
-
-        queryModule.services( UuidIdentityGeneratorService.class );
-
-        queryModule.values(
-            Cargo.class,
-            Location.class,
-            HandlingEvent.class,
-            Voyage.class
-        );
-    }
-
-    private void assembleContextLayer( LayerAssembly contextLayer )
-        throws AssemblyException
-    {
-        // Role-playing entities
-        ModuleAssembly entityRoleModule = contextLayer.module( "CONTEXT-EntityRole" );
-        entityRoleModule.entities( CargoRoleMap.class,
-                                   CargosRoleMap.class,
-                                   HandlingEventRoleMap.class,
-                                   HandlingEventsRoleMap.class )
-            .visibleIn( application );
-
-        // Non-role-playing entities
-        ModuleAssembly entityNonRoleModule = contextLayer.module( "CONTEXT-EntityNonRole" );
-        entityNonRoleModule
-            .entities(
-                Location.class,
-                Voyage.class )
-            .visibleIn( application );
-
-        // Role-playing values
-        ModuleAssembly valueRoleModule = contextLayer.module( "CONTEXT-ValueRole" );
-        valueRoleModule
-            .values(
-                ItineraryRoleMap.class,
-                RouteSpecificationRoleMap.class )
-            .visibleIn( application );
-
-        ModuleAssembly contextSupportModule = contextLayer.module( "CONTEXT-ContextSupport" );
-        contextSupportModule
-            .addServices(
-                RoutingService.class,
-                ApplicationEvents.class )
-            .visibleIn( application );
-
-        contextSupportModule
-            .values(
-                RegisterHandlingEventAttemptDTO.class )
-            .visibleIn( application );
-    }
-
-    private void assembleDataLayer( LayerAssembly dataLayer )
-        throws AssemblyException
-    {
-        // Non-role-playing values
-        ModuleAssembly dataModule = dataLayer.module( "DATA-Data" );
-        dataModule
-            .values(
-                TrackingId.class,
-                Delivery.class,
-                ExpectedHandlingEvent.class,
-                UnLocode.class,
-                Leg.class,
-                CarrierMovement.class,
-                Schedule.class,
-                VoyageNumber.class )
-            .visibleIn( application );
-    }
-
-    private void assembleInfrastructureLayer( LayerAssembly infrastructureLayer )
-        throws AssemblyException
-    {
-        ModuleAssembly serializationModule = infrastructureLayer.module( "INFRASTRUCTURE-Serialization" );
-        serializationModule
-            .services( OrgJsonValueSerializationService.class )
-            .taggedWith( ValueSerialization.Formats.JSON )
-            .setMetaInfo( (Function<Application, Module>) application1 -> application1.findModule( "CONTEXT", "CONTEXT-ContextSupport" ) )
-            .visibleIn( application );
-
-        ModuleAssembly indexingModule = infrastructureLayer.module( "INFRASTRUCTURE-Indexing" );
-        indexingModule
-            .objects(
-                EntityStateSerializer.class,
-                EntityTypeSerializer.class );
-
-        indexingModule
-            .addServices(
-                MemoryRepositoryService.class,
-                RdfIndexingEngineService.class )
-            .instantiateOnStartup()
-            .visibleIn( application );
-
-        ModuleAssembly entityStoreModule = infrastructureLayer.module( "INFRASTRUCTURE-EntityStore" );
-        entityStoreModule
-            .addServices(
-                MemoryEntityStoreService.class,
-                UuidIdentityGeneratorService.class )
-            .instantiateOnStartup()
-            .visibleIn( application );
-
-        ModuleAssembly externalServiceModule = infrastructureLayer.module( "INFRASTRUCTURE-ExternalService" );
-        externalServiceModule
-            .importedServices(
-                GraphTraversalService.class )
-            .setMetaInfo( new GraphTraversalServiceImpl( new GraphDAO() ) )
-            .visibleIn( application );
-    }
-}

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/bootstrap/sampledata/BaseData.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/bootstrap/sampledata/BaseData.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/bootstrap/sampledata/BaseData.java
deleted file mode 100644
index 8575a69..0000000
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/bootstrap/sampledata/BaseData.java
+++ /dev/null
@@ -1,122 +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.bootstrap.sampledata;
-
-import java.time.LocalDate;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import org.apache.zest.api.structure.Module;
-import org.apache.zest.api.value.ValueBuilder;
-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.location.UnLocode;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.voyage.CarrierMovement;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.voyage.Schedule;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.voyage.Voyage;
-
-/**
- * Test base class with shared Locations, Voyages etc.
- */
-public abstract class BaseData
-{
-    protected Module module;
-
-    protected static UnLocode AUMEL;
-    protected static UnLocode CNHGH;
-    protected static UnLocode CNHKG;
-    protected static UnLocode CNSHA;
-    protected static UnLocode DEHAM;
-    protected static UnLocode FIHEL;
-    protected static UnLocode JNTKO;
-    protected static UnLocode NLRTM;
-    protected static UnLocode SEGOT;
-    protected static UnLocode SESTO;
-    protected static UnLocode USCHI;
-    protected static UnLocode USDAL;
-    protected static UnLocode USNYC;
-
-    public BaseData( Module module )
-    {
-        this.module = module;
-    }
-
-    protected UnLocode unlocode( String unlocodeString )
-    {
-        ValueBuilder<UnLocode> unlocode = module.newValueBuilder( UnLocode.class );
-        unlocode.prototype().code().set( unlocodeString );
-        return unlocode.newInstance();
-    }
-
-    protected CarrierMovement carrierMovement( Location depLoc, Location arrLoc, LocalDate depDate, LocalDate arrDate )
-    {
-        ValueBuilder<CarrierMovement> carrierMovement = module.newValueBuilder( CarrierMovement.class );
-        carrierMovement.prototype().departureLocation().set( depLoc );
-        carrierMovement.prototype().arrivalLocation().set( arrLoc );
-        carrierMovement.prototype().departureDate().set( depDate );
-        carrierMovement.prototype().arrivalDate().set( arrDate );
-        return carrierMovement.newInstance();
-    }
-
-    protected Schedule schedule( CarrierMovement... carrierMovements )
-    {
-        ValueBuilder<Schedule> schedule = module.newValueBuilder( Schedule.class );
-        List<CarrierMovement> cm = new ArrayList<>();
-        cm.addAll( Arrays.asList( carrierMovements ) );
-        schedule.prototype().carrierMovements().set( cm );
-        return schedule.newInstance();
-    }
-
-    protected Leg leg( Voyage voyage, Location load, Location unload, LocalDate loadDate, LocalDate unloadDate )
-    {
-        ValueBuilder<Leg> leg = module.newValueBuilder( Leg.class );
-        leg.prototype().voyage().set( voyage );
-        leg.prototype().loadLocation().set( load );
-        leg.prototype().unloadLocation().set( unload );
-        leg.prototype().loadDate().set( loadDate );
-        leg.prototype().unloadDate().set( unloadDate );
-        return leg.newInstance();
-    }
-
-    protected Itinerary itinerary( Leg... legArray )
-    {
-        ValueBuilder<Itinerary> itinerary = module.newValueBuilder( Itinerary.class );
-        List<Leg> legs = new ArrayList<Leg>();
-        legs.addAll( Arrays.asList( legArray ) );
-        itinerary.prototype().legs().set( legs );
-        return itinerary.newInstance();
-    }
-
-    protected RouteSpecification routeSpecification( Location origin, Location destination, LocalDate deadline )
-    {
-        ValueBuilder<RouteSpecification> routeSpec = module.newValueBuilder( RouteSpecification.class );
-        routeSpec.prototype().origin().set( origin );
-        routeSpec.prototype().destination().set( destination );
-        routeSpec.prototype().arrivalDeadline().set( deadline );
-        return routeSpec.newInstance();
-    }
-
-    protected static LocalDate day( int days )
-    {
-        return LocalDate.now().plusDays( days );
-    }
-}

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/bootstrap/sampledata/BaseDataService.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/bootstrap/sampledata/BaseDataService.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/bootstrap/sampledata/BaseDataService.java
deleted file mode 100644
index f1d5291..0000000
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/bootstrap/sampledata/BaseDataService.java
+++ /dev/null
@@ -1,180 +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.bootstrap.sampledata;
-
-import org.apache.zest.api.activation.ActivatorAdapter;
-import org.apache.zest.api.activation.Activators;
-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.service.ServiceComposite;
-import org.apache.zest.api.service.ServiceReference;
-import org.apache.zest.api.structure.Module;
-import org.apache.zest.api.unitofwork.UnitOfWork;
-import org.apache.zest.api.value.ValueBuilder;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.cargo.Cargos;
-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.location.UnLocode;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.voyage.Schedule;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.voyage.Voyage;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.voyage.VoyageNumber;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import static org.apache.zest.api.usecase.UsecaseBuilder.newUsecase;
-
-/**
- * Create basic sample data
- */
-@Mixins( BaseDataService.Mixin.class )
-@Activators( BaseDataService.Activator.class )
-public interface BaseDataService
-    extends ServiceComposite
-{
-
-    void createBaseData()
-        throws Exception;
-
-    class Activator
-        extends ActivatorAdapter<ServiceReference<BaseDataService>>
-    {
-
-        @Override
-        public void afterActivation( ServiceReference<BaseDataService> activated )
-            throws Exception
-        {
-            activated.get().createBaseData();
-        }
-    }
-
-    public abstract class Mixin extends BaseData
-        implements BaseDataService
-    {
-        private static final Logger logger = LoggerFactory.getLogger( BaseDataService.class );
-
-        public Mixin( @Structure Module module )
-        {
-            super( module );
-        }
-
-        @Override
-        public void createBaseData()
-            throws Exception
-        {
-            logger.debug( "CREATING BASIC DATA..." );
-            UnitOfWork uow = module.unitOfWorkFactory().newUnitOfWork( newUsecase( "Open uow for " ) );
-            try
-            {
-                // UnLocode value objects
-                AUMEL = unlocode( "AUMEL" ); // Melbourne
-                CNHGH = unlocode( "CNHGH" ); // Hangzou
-                CNHKG = unlocode( "CNHKG" ); // Hong Kong
-                CNSHA = unlocode( "CNSHA" ); // Shanghai
-                DEHAM = unlocode( "DEHAM" ); // Hamburg
-                FIHEL = unlocode( "FIHEL" ); // Helsinki
-                JNTKO = unlocode( "JNTKO" ); // Tokyo
-                NLRTM = unlocode( "NLRTM" ); // Rotterdam
-                SEGOT = unlocode( "SEGOT" ); // Gothenburg
-                SESTO = unlocode( "SESTO" ); // Stockholm
-                USCHI = unlocode( "USCHI" ); // Chicago
-                USDAL = unlocode( "USDAL" ); // Dallas
-                USNYC = unlocode( "USNYC" ); // New York
-
-                // Location entity objects
-                Location MELBOURNE = location( AUMEL, "Melbourne" );
-                Location HANGZHOU = location( CNHGH, "Hangzhou" );
-                Location HONGKONG = location( CNHKG, "Hongkong" );
-                Location SHANGHAI = location( CNSHA, "Shanghai" );
-                Location HAMBURG = location( DEHAM, "Hamburg" );
-                Location HELSINKI = location( FIHEL, "Helsinki" );
-                Location TOKYO = location( JNTKO, "Tokyo" );
-                Location ROTTERDAM = location( NLRTM, "Rotterdam" );
-                Location GOTHENBURG = location( SEGOT, "Gothenburg" );
-                Location STOCKHOLM = location( SESTO, "Stockholm" );
-                Location CHICAGO = location( USCHI, "Chicago" );
-                Location DALLAS = location( USDAL, "Dallas" );
-                Location NEWYORK = location( USNYC, "New York" );
-
-                // Voyage entity objects
-                Voyage V100S = voyage( "V100S", schedule(
-                    carrierMovement( NEWYORK, CHICAGO, day( 1 ), day( 2 ) ),
-                    carrierMovement( CHICAGO, DALLAS, day( 8 ), day( 9 ) )
-                ) );
-                Voyage V200T = voyage( "V200T", schedule(
-                    carrierMovement( NEWYORK, CHICAGO, day( 7 ), day( 8 ) ),
-                    carrierMovement( CHICAGO, DALLAS, day( 8 ), day( 9 ) )
-                ) );
-                Voyage V300A = voyage( "V300A", schedule(
-                    carrierMovement( DALLAS, HAMBURG, day( 10 ), day( 14 ) ),
-                    carrierMovement( HAMBURG, STOCKHOLM, day( 15 ), day( 16 ) ),
-                    carrierMovement( STOCKHOLM, HELSINKI, day( 17 ), day( 18 ) )
-                ) );
-                Voyage V400S = voyage( "V400S", schedule(
-                    carrierMovement( TOKYO, ROTTERDAM, day( 9 ), day( 15 ) ),
-                    carrierMovement( ROTTERDAM, HAMBURG, day( 15 ), day( 16 ) ),
-                    carrierMovement( HAMBURG, MELBOURNE, day( 17 ), day( 26 ) ),
-                    carrierMovement( MELBOURNE, TOKYO, day( 27 ), day( 33 ) )
-                ) );
-                Voyage V500S = voyage( "V500S", schedule(
-                    carrierMovement( HAMBURG, STOCKHOLM, day( 17 ), day( 19 ) ),
-                    carrierMovement( STOCKHOLM, HELSINKI, day( 20 ), day( 21 ) )
-                ) );
-
-                // Cargo and HandlingEvent factories
-                Cargos CARGOS = uow.newEntity( Cargos.class, Cargos.CARGOS_ID );
-                uow.newEntity( HandlingEvents.class, HandlingEvents.HANDLING_EVENTS_ID );
-
-                logger.debug( "BASIC DATA CREATED" );
-                uow.complete();
-            }
-            catch( Exception e )
-            {
-                uow.discard();
-                logger.error( "CANNOT CREATE BASIC DATA" );
-                throw e;
-            }
-        }
-
-        private Location location( UnLocode unlocode, String locationStr )
-        {
-            UnitOfWork uow = module.unitOfWorkFactory().currentUnitOfWork();
-            EntityBuilder<Location> location = uow.newEntityBuilder( Location.class, unlocode.code().get() );
-            location.instance().unLocode().set( unlocode );
-            location.instance().name().set( locationStr );
-            return location.newInstance();
-        }
-
-        private Voyage voyage( String voyageNumberStr, Schedule schedule )
-        {
-            UnitOfWork uow = module.unitOfWorkFactory().currentUnitOfWork();
-            EntityBuilder<Voyage> voyage = uow.newEntityBuilder( Voyage.class, voyageNumberStr );
-
-            // VoyageNumber
-            ValueBuilder<VoyageNumber> voyageNumber = module.newValueBuilder( VoyageNumber.class );
-            voyageNumber.prototype().number().set( voyageNumberStr );
-            voyage.instance().voyageNumber().set( voyageNumber.newInstance() );
-
-            // Schedule
-            voyage.instance().schedule().set( schedule );
-            return voyage.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/bootstrap/sampledata/SampleDataService.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/bootstrap/sampledata/SampleDataService.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/bootstrap/sampledata/SampleDataService.java
deleted file mode 100644
index 98fcdd8..0000000
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/bootstrap/sampledata/SampleDataService.java
+++ /dev/null
@@ -1,318 +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.bootstrap.sampledata;
-
-import java.time.LocalDate;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Random;
-import java.util.UUID;
-import org.apache.zest.api.activation.ActivatorAdapter;
-import org.apache.zest.api.activation.Activators;
-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.query.Query;
-import org.apache.zest.api.query.QueryBuilder;
-import org.apache.zest.api.query.QueryBuilderFactory;
-import org.apache.zest.api.service.ServiceComposite;
-import org.apache.zest.api.service.ServiceReference;
-import org.apache.zest.api.unitofwork.UnitOfWork;
-import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
-import org.apache.zest.api.usecase.Usecase;
-import org.apache.zest.api.usecase.UsecaseBuilder;
-import org.apache.zest.sample.dcicargo.sample_a.context.shipping.booking.BookNewCargo;
-import org.apache.zest.sample.dcicargo.sample_a.context.shipping.handling.RegisterHandlingEvent;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.cargo.Cargo;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.cargo.Cargos;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.delivery.ExpectedHandlingEvent;
-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.location.Location;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import static org.apache.zest.api.usecase.UsecaseBuilder.newUsecase;
-import static org.apache.zest.sample.dcicargo.sample_a.infrastructure.dci.Context.prepareContextBaseClass;
-
-/**
- * Create sample Cargos in different delivery stages
- */
-@Mixins( SampleDataService.Mixin.class )
-@Activators( SampleDataService.Activator.class )
-public interface SampleDataService
-    extends ServiceComposite
-{
-
-    void insertSampleData()
-            throws Exception;
-
-    class Activator extends ActivatorAdapter<ServiceReference<SampleDataService>>
-    {
-
-        @Override
-        public void afterActivation( ServiceReference<SampleDataService> activated )
-                throws Exception
-        {
-            activated.get().insertSampleData();
-        }
-
-    }
-
-    abstract class Mixin
-        implements SampleDataService
-    {
-        @Structure
-        QueryBuilderFactory qbf;
-
-        @Structure
-        UnitOfWorkFactory uowf;
-
-        @Service // We depend on BaseData to be inserted
-        BaseDataService baseDataService;
-
-        private static final Logger logger = LoggerFactory.getLogger( SampleDataService.class );
-
-        @Override
-        public void insertSampleData()
-            throws Exception
-        {
-            prepareContextBaseClass( uowf );
-
-            logger.info( "######  CREATING SAMPLE DATA...  ##########################################" );
-
-            // Create cargos
-            populateRandomCargos( 15 );
-
-            // Handle cargos
-            UnitOfWork uow = uowf.newUnitOfWork( newUsecase( "### Create sample data" ) );
-            try
-            {
-                int i = 11; // starting at 11 for sortable tracking id prefix in lists
-                QueryBuilder<Cargo> qb = qbf.newQueryBuilder( Cargo.class );
-                for( Cargo cargo : uow.newQuery( qb ) )
-                {
-                    String trackingId = cargo.trackingId().get().id().get();
-                    ExpectedHandlingEvent nextEvent;
-                    LocalDate date;
-                    String port;
-                    String voyage;
-                    HandlingEventType type;
-
-                    // BOOK cargo with no handling (i == 11)
-
-                    // ROUTE
-                    if( i > 11 )
-                    {
-                        Itinerary itinerary = new BookNewCargo( cargo ).routeCandidates().get( 0 );
-                        new BookNewCargo( cargo, itinerary ).assignCargoToRoute();
-                    }
-
-                    // RECEIVE
-                    if( i > 12 )
-                    {
-                        nextEvent = cargo.delivery().get().nextExpectedHandlingEvent().get();
-                        port = nextEvent.location().get().getCode();
-                        LocalDate mockTime = LocalDate.now();
-                        new RegisterHandlingEvent( mockTime, mockTime, trackingId, "RECEIVE", port, null ).register();
-                    }
-
-                    // LOAD
-                    if( i > 13 )
-                    {
-                        nextEvent = cargo.delivery().get().nextExpectedHandlingEvent().get();
-                        date = nextEvent.date().get();
-                        port = nextEvent.location().get().getCode();
-                        voyage = nextEvent.voyage().get().voyageNumber().get().number().get();
-                        new RegisterHandlingEvent( date, date, trackingId, "LOAD", port, voyage ).register();
-                    }
-
-                    // UNLOAD
-                    if( i > 14 )
-                    {
-                        nextEvent = cargo.delivery().get().nextExpectedHandlingEvent().get();
-                        date = nextEvent.date().get();
-                        port = nextEvent.location().get().getCode();
-                        voyage = nextEvent.voyage().get().voyageNumber().get().number().get();
-                        new RegisterHandlingEvent( date, date, trackingId, "UNLOAD", port, voyage ).register();
-                    }
-
-                    // Cargo is now in port
-                    nextEvent = cargo.delivery().get().nextExpectedHandlingEvent().get();
-                    date = nextEvent.date().get();
-                    port = nextEvent.location().get().getCode();
-                    type = nextEvent.handlingEventType().get();
-
-                    // MISDIRECTED: Unexpected customs handling before reaching destination
-                    if( i == 16 )
-                    {
-                        new RegisterHandlingEvent( date, date, trackingId, "CUSTOMS", port, null ).register();
-                    }
-
-                    // MISDIRECTED: Unexpected claim before reaching destination
-                    if( i == 17 )
-                    {
-                        new RegisterHandlingEvent( date, date, trackingId, "CLAIM", port, null ).register();
-                    }
-
-                    // MISDIRECTED: LOAD in wrong port
-                    if( i == 18 )
-                    {
-                        String wrongPort = port.equals( "USDAL" ) ? "USCHI" : "USDAL";
-                        voyage = nextEvent.voyage().get().voyageNumber().get().number().get();
-                        new RegisterHandlingEvent( date, date, trackingId, "LOAD", wrongPort, voyage ).register();
-                    }
-
-                    // MISDIRECTED: LOAD onto wrong carrier
-                    if( i == 19 )
-                    {
-                        voyage = nextEvent.voyage().get().voyageNumber().get().number().get();
-                        String wrongVoyage = voyage.equals( "V100S" ) ? "V200T" : "V100S";
-                        new RegisterHandlingEvent( date, date, trackingId, "LOAD", port, wrongVoyage ).register();
-                    }
-
-                    // MISDIRECTED: LOAD onto wrong carrier in wrong port
-                    if( i == 20 )
-                    {
-                        String wrongPort = port.equals( "USDAL" ) ? "USCHI" : "USDAL";
-                        voyage = nextEvent.voyage().get().voyageNumber().get().number().get();
-                        String wrongVoyage = voyage.equals( "V100S" ) ? "V200T" : "V100S";
-                        new RegisterHandlingEvent( date, date, trackingId, "LOAD", wrongPort, wrongVoyage ).register();
-                    }
-
-                    // MISDIRECTED: UNLOAD in wrong port
-                    if( i == 21 )
-                    {
-                        String wrongPort = port.equals( "USDAL" ) ? "USCHI" : "USDAL";
-                        voyage = nextEvent.voyage().get().voyageNumber().get().number().get();
-                        new RegisterHandlingEvent( date, date, trackingId, "UNLOAD", wrongPort, voyage ).register();
-                    }
-
-                    // MISDIRECTED: UNLOAD from wrong carrier
-                    if( i == 22 )
-                    {
-                        voyage = nextEvent.voyage().get().voyageNumber().get().number().get();
-                        String wrongVoyage = voyage.equals( "V100S" ) ? "V200T" : "V100S";
-                        new RegisterHandlingEvent( date, date, trackingId, "UNLOAD", port, wrongVoyage ).register();
-                    }
-
-                    // MISDIRECTED: UNLOAD from wrong carrier in wrong port
-                    if( i == 23 )
-                    {
-                        String wrongPort = port.equals( "USDAL" ) ? "USCHI" : "USDAL";
-                        voyage = nextEvent.voyage().get().voyageNumber().get().number().get();
-                        String wrongVoyage = voyage.equals( "V100S" ) ? "V200T" : "V100S";
-                        new RegisterHandlingEvent( date, date, trackingId, "UNLOAD", wrongPort, wrongVoyage ).register();
-                    }
-
-                    // Complete all LOAD/UNLOADS
-                    if( i > 23 )
-                    {
-                        do
-                        {
-                            voyage = nextEvent.voyage().get().voyageNumber().get().number().get();
-                            new RegisterHandlingEvent( date, date, trackingId, type.name(), port, voyage ).register();
-
-                            nextEvent = cargo.delivery().get().nextExpectedHandlingEvent().get();
-                            date = nextEvent.date().get();
-                            port = nextEvent.location().get().getCode();
-                            type = nextEvent.handlingEventType().get();
-                        }
-                        while( type != HandlingEventType.CLAIM );
-                    }
-
-                    // CLAIM at destination - this ends the life cycle of the cargo delivery
-                    if( i == 25 )
-                    {
-                        new RegisterHandlingEvent( date, date, trackingId, "CLAIM", port, null ).register();
-                    }
-
-                    // Add more cases if needed...
-
-                    i++;
-                }
-
-                uow.complete();
-            }
-            catch( Exception e )
-            {
-                uow.discard();
-                logger.error( "Problem handling cargos: " + e.getMessage() );
-                throw e;
-            }
-
-            logger.info( "######  SAMPLE DATA CREATED  ##############################################" );
-        }
-
-        private void populateRandomCargos( int numberOfCargos )
-        {
-            Usecase usecase = UsecaseBuilder.newUsecase( "### Populate Random Cargos ###" );
-            UnitOfWork uow = uowf.newUnitOfWork( usecase );
-
-            Cargos cargos = uow.get( Cargos.class, Cargos.CARGOS_ID );
-
-            QueryBuilder<Location> qb = qbf.newQueryBuilder( Location.class );
-            Query<Location> allLocations = uow.newQuery( qb );
-            int locationSize = (int) allLocations.count();
-
-            // Make array for selection of location with random index
-            final List<Location> locationList = new ArrayList<>();
-            for( Location location : allLocations )
-            {
-                locationList.add( location );
-            }
-
-            Location origin;
-            Location destination;
-            Random random = new Random();
-            LocalDate deadline;
-            String uuid;
-            String id;
-            try
-            {
-                for( int i = 0; i < numberOfCargos; i++ )
-                {
-                    origin = locationList.get( random.nextInt( locationSize ) );
-
-                    // Find destination different from origin
-                    do
-                    {
-                        destination = locationList.get( random.nextInt( locationSize ) );
-                    }
-                    while( destination.equals( origin ) );
-
-                    deadline = LocalDate.now().plusDays( 15 + random.nextInt( 10 ) );
-
-                    // Build sortable random tracking ids
-                    uuid = UUID.randomUUID().toString().toUpperCase();
-                    id = ( i + 11 ) + "-" + uuid.substring( 0, uuid.indexOf( "-" ) );
-
-                    new BookNewCargo( cargos, origin, destination, deadline ).createCargo( id );
-                }
-                uow.complete();
-            }
-            catch( Exception e )
-            {
-                uow.discard();
-                logger.error( "Problem booking a new cargo: " + e.getMessage() );
-            }
-        }
-    }
-}

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/communication/query/BookingQueries.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/query/BookingQueries.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/query/BookingQueries.java
deleted file mode 100644
index 6d3b660..0000000
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/query/BookingQueries.java
+++ /dev/null
@@ -1,74 +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.communication.query;
-
-import java.util.ArrayList;
-import java.util.List;
-import org.apache.wicket.model.IModel;
-import org.apache.zest.api.composite.TransientComposite;
-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.unitofwork.UnitOfWorkFactory;
-import org.apache.zest.sample.dcicargo.sample_a.context.support.FoundNoRoutesException;
-import org.apache.zest.sample.dcicargo.sample_a.context.support.RoutingService;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.cargo.Cargo;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.itinerary.Itinerary;
-import org.apache.zest.sample.dcicargo.sample_a.infrastructure.model.JSONModel;
-
-/**
- * Booking queries
- *
- * This is in a Zest composite since we can then conveniently get the routing service injected.
- * We could choose to implement all query classes like this too.
- *
- * Used by the communication layer only. Can change according to ui needs.
- */
-@Mixins( BookingQueries.Mixin.class )
-public interface BookingQueries
-    extends TransientComposite
-{
-    List<IModel<Itinerary>> routeCandidates( String trackingIdString )
-        throws FoundNoRoutesException;
-
-    abstract class Mixin
-        implements BookingQueries
-    {
-        @Structure
-        UnitOfWorkFactory uowf;
-
-        @Service
-        RoutingService routingService;
-
-        public List<IModel<Itinerary>> routeCandidates( final String trackingIdString )
-            throws FoundNoRoutesException
-        {
-            Cargo cargo = uowf.currentUnitOfWork().get( Cargo.class, trackingIdString );
-            List<Itinerary> routes = routingService.fetchRoutesForSpecification( cargo.routeSpecification().get() );
-
-            List<IModel<Itinerary>> modelList = new ArrayList<IModel<Itinerary>>();
-            for( Itinerary itinerary : routes )
-            {
-                modelList.add( JSONModel.of( itinerary ) );
-            }
-            return modelList;
-        }
-    }
-}

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/communication/query/CommonQueries.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/query/CommonQueries.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/query/CommonQueries.java
deleted file mode 100644
index 94ed7ce..0000000
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/query/CommonQueries.java
+++ /dev/null
@@ -1,76 +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.communication.query;
-
-import java.util.ArrayList;
-import java.util.List;
-import org.apache.wicket.model.IModel;
-import org.apache.zest.api.query.Query;
-import org.apache.zest.api.query.QueryBuilder;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.cargo.Cargo;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.location.Location;
-import org.apache.zest.sample.dcicargo.sample_a.infrastructure.model.EntityModel;
-import org.apache.zest.sample.dcicargo.sample_a.infrastructure.model.Queries;
-import org.apache.zest.sample.dcicargo.sample_a.infrastructure.model.QueryModel;
-
-import static org.apache.zest.api.query.QueryExpressions.orderBy;
-import static org.apache.zest.api.query.QueryExpressions.templateFor;
-
-/**
- * Common queries
- *
- * Queries shared across packages.
- *
- * Used by the communication layer only. Can change according to ui needs.
- */
-public class CommonQueries extends Queries
-{
-    public IModel<Cargo> cargo( String trackingId )
-    {
-        return EntityModel.of( Cargo.class, trackingId, Cargo.class );
-    }
-
-    public IModel<List<Cargo>> cargoList()
-    {
-        return new QueryModel<Cargo>( Cargo.class )
-        {
-            public Query<Cargo> getQuery()
-            {
-                QueryBuilder<Cargo> qb = qbf.newQueryBuilder( Cargo.class );
-                return uowf.currentUnitOfWork().newQuery( qb )
-                    .orderBy( orderBy( templateFor( Cargo.class ).trackingId().get().id() ) );
-            }
-        };
-    }
-
-    public List<String> unLocodes()
-    {
-        QueryBuilder<Location> qb = qbf.newQueryBuilder( Location.class );
-        Query<Location> locations = uowf.currentUnitOfWork().newQuery( qb )
-            .orderBy( orderBy( templateFor( Location.class ).unLocode().get().code() ) );
-        List<String> unLocodeList = new ArrayList<String>();
-        for( Location location : locations )
-        {
-            unLocodeList.add( location.getCode() );
-        }
-
-        return unLocodeList;
-    }
-}
\ 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/communication/query/HandlingQueries.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/query/HandlingQueries.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/query/HandlingQueries.java
deleted file mode 100644
index 9e61655..0000000
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/query/HandlingQueries.java
+++ /dev/null
@@ -1,77 +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.communication.query;
-
-import java.util.ArrayList;
-import java.util.List;
-import org.apache.zest.api.query.Query;
-import org.apache.zest.api.query.QueryBuilder;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.cargo.Cargo;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.handling.HandlingEventType;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.voyage.Voyage;
-import org.apache.zest.sample.dcicargo.sample_a.infrastructure.model.Queries;
-
-import static org.apache.zest.api.query.QueryExpressions.orderBy;
-import static org.apache.zest.api.query.QueryExpressions.templateFor;
-
-/**
- * Handling queries
- *
- * Used by the communication layer only. Can change according to ui needs.
- */
-public class HandlingQueries extends Queries
-{
-    public List<String> voyages()
-    {
-        QueryBuilder<Voyage> qb = qbf.newQueryBuilder( Voyage.class );
-        Query<Voyage> voyages = uowf.currentUnitOfWork().newQuery( qb )
-            .orderBy( orderBy( templateFor( Voyage.class ).voyageNumber() ) );
-
-        List<String> voyageList = new ArrayList<String>();
-        for( Voyage voyage : voyages )
-        {
-            voyageList.add( voyage.voyageNumber().get().number().get() );
-        }
-        return voyageList;
-    }
-
-    public List<String> cargoIds()
-    {
-        QueryBuilder<Cargo> qb = qbf.newQueryBuilder( Cargo.class );
-        Query<Cargo> cargos = uowf.currentUnitOfWork().newQuery( qb )
-            .orderBy( orderBy( templateFor( Cargo.class ).trackingId().get().id() ) );
-        List<String> cargoList = new ArrayList<>();
-        for( Cargo cargo : cargos )
-        {
-            cargoList.add( cargo.trackingId().get().id().get() );
-        }
-        return cargoList;
-    }
-
-    public List<String> eventTypes()
-    {
-        List<String> eventTypes = new ArrayList<>();
-        for( HandlingEventType eventType : HandlingEventType.values() )
-        {
-            eventTypes.add( eventType.name() );
-        }
-        return eventTypes;
-    }
-}
\ 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/communication/query/TrackingQueries.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/query/TrackingQueries.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/query/TrackingQueries.java
deleted file mode 100644
index f7d2e49..0000000
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/query/TrackingQueries.java
+++ /dev/null
@@ -1,77 +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.communication.query;
-
-import java.util.ArrayList;
-import java.util.List;
-import org.apache.wicket.model.IModel;
-import org.apache.zest.api.query.Query;
-import org.apache.zest.api.query.QueryBuilder;
-import org.apache.zest.api.query.QueryExpressions;
-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.infrastructure.model.Queries;
-import org.apache.zest.sample.dcicargo.sample_a.infrastructure.model.QueryModel;
-
-import static org.apache.zest.api.query.QueryExpressions.*;
-
-/**
- * Tracking queries
- *
- * Used by the communication layer only. Can change according to ui needs.
- */
-public class TrackingQueries extends Queries
-{
-    public List<String> routedCargos()
-    {
-        Cargo cargoEntity = templateFor( Cargo.class );
-
-        QueryBuilder<Cargo> qb = qbf.newQueryBuilder( Cargo.class )
-            .where( isNotNull( cargoEntity.itinerary() ) );
-        Query<Cargo> cargos = uowf.currentUnitOfWork().newQuery( qb )
-            .orderBy( orderBy( cargoEntity.trackingId().get().id() ) );
-
-        List<String> cargoList = new ArrayList<String>();
-        for( Cargo cargo : cargos )
-        {
-            cargoList.add( cargo.trackingId().get().id().get() );
-        }
-
-        return cargoList;
-    }
-
-    public IModel<List<HandlingEvent>> events( final String trackingIdString )
-    {
-        return new QueryModel<HandlingEvent>( HandlingEvent.class )
-        {
-            public Query<HandlingEvent> getQuery()
-            {
-                HandlingEvent eventTemplate = templateFor( HandlingEvent.class );
-
-                QueryBuilder<HandlingEvent> qb = qbf.newQueryBuilder( HandlingEvent.class )
-                    .where( QueryExpressions.eq( eventTemplate.trackingId().get().id(), trackingIdString ) );
-                return uowf
-                    .currentUnitOfWork()
-                    .newQuery( qb )
-                    .orderBy( orderBy( eventTemplate.completionDate() ) );
-            }
-        };
-    }
-}
\ 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/communication/web/BasePage.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/web/BasePage.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/web/BasePage.java
deleted file mode 100644
index f9c9c16..0000000
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/web/BasePage.java
+++ /dev/null
@@ -1,77 +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.communication.web;
-
-import com.google.code.joliratools.StatelessAjaxFallbackLink;
-import org.apache.wicket.AttributeModifier;
-import org.apache.wicket.ajax.AjaxRequestTarget;
-import org.apache.wicket.markup.html.basic.Label;
-import org.apache.wicket.markup.html.link.Link;
-import org.apache.wicket.markup.html.panel.Fragment;
-import org.apache.wicket.model.Model;
-import org.apache.wicket.request.mapper.parameter.PageParameters;
-import org.apache.zest.sample.dcicargo.sample_a.infrastructure.WicketZestApplication;
-import org.apache.zest.sample.dcicargo.sample_a.infrastructure.wicket.page.BaseWebPage;
-import org.apache.zest.sample.dcicargo.sample_a.infrastructure.wicket.tabs.TabsPanel;
-
-/**
- * Base Wicket page of the DCI Sample application
- */
-public class BasePage extends BaseWebPage
-{
-    private final Link toggleLinks;
-    private static boolean showLInks = false;
-    private Fragment links = new Fragment( "links", "linksFragment", this );
-
-    public BasePage( String activeTab )
-    {
-        this( activeTab, null );
-    }
-
-    public BasePage( String activeTab, PageParameters pageParameters )
-    {
-        super( pageParameters );
-
-        toggleLinks = new StatelessAjaxFallbackLink<Void>( "toggleLinks" )
-        {
-            @Override
-            public void onClick( AjaxRequestTarget target )
-            {
-                // Open/close triangle of this toggle link
-                add( new AttributeModifier( "class", Model.of( showLInks ? "closed" : "open" ) ) );
-
-                // Show/hide links
-                links.setVisible( showLInks = !showLInks );
-
-                // Update with ajax if browser allows
-                if( target != null )
-                {
-                    target.add( links, toggleLinks );
-                }
-            }
-        };
-        add( toggleLinks );
-        add( links.setOutputMarkupPlaceholderTag( true ).setVisible( false ) );
-
-        add( new Label( "version", ( (WicketZestApplication) getApplication() ).appVersion() ) );
-
-        add( new TabsPanel( activeTab ) );
-    }
-}

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/communication/web/booking/BookNewCargoPage.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/web/booking/BookNewCargoPage.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/web/booking/BookNewCargoPage.java
deleted file mode 100644
index 20cc050..0000000
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/web/booking/BookNewCargoPage.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.communication.web.booking;
-
-import java.time.LocalDate;
-import java.time.LocalDateTime;
-import java.util.List;
-import org.apache.wicket.Session;
-import org.apache.wicket.ajax.AjaxRequestTarget;
-import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;
-import org.apache.wicket.ajax.markup.html.form.AjaxFallbackButton;
-import org.apache.wicket.markup.html.form.Form;
-import org.apache.wicket.markup.html.panel.ComponentFeedbackPanel;
-import org.apache.wicket.markup.html.panel.FeedbackPanel;
-import org.apache.wicket.request.mapper.parameter.PageParameters;
-import org.apache.zest.sample.dcicargo.sample_a.communication.query.CommonQueries;
-import org.apache.zest.sample.dcicargo.sample_a.context.shipping.booking.BookNewCargo;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.cargo.TrackingId;
-import org.apache.zest.sample.dcicargo.sample_a.infrastructure.wicket.form.AbstractForm;
-import org.apache.zest.sample.dcicargo.sample_a.infrastructure.wicket.form.DateTextFieldWithPicker;
-import org.apache.zest.sample.dcicargo.sample_a.infrastructure.wicket.form.SelectorInForm;
-import org.apache.zest.sample.dcicargo.sample_a.infrastructure.wicket.prevnext.PrevNext;
-
-/**
- * Book new cargo
- *
- * An example of UI validation:
- * - you can't choose equal locations
- * - earliest deadline you can choose from the date picker is tomorrow (we could set any date that the domain wants).
- *
- * More elaborate validation rules could be enforced in a real domain to avoid even touching
- * the backend with invalid data (of course we would still need backend validation).
- */
-public class BookNewCargoPage extends BookingBasePage
-{
-    public BookNewCargoPage()
-    {
-        add( new BookNewCargoForm() );
-        setVersioned( false );
-    }
-
-    private final class BookNewCargoForm extends AbstractForm<Void>
-    {
-        // Set by Wicket property resolvers:
-        private String origin, destination;
-        private LocalDate deadline;
-
-        public BookNewCargoForm()
-        {
-            List<String> locations = new CommonQueries().unLocodes();
-
-            final FeedbackPanel feedback = new FeedbackPanel( "feedback" );
-            add( feedback.setOutputMarkupId( true ) );
-
-            final SelectorInForm originSelector = new SelectorInForm(
-                "origin", "Origin", locations, this, "destination" );
-            originSelector.setRequired( true );
-
-            final ComponentFeedbackPanel originFeedback = new ComponentFeedbackPanel(
-                "originFeedback", originSelector );
-            add( originFeedback.setOutputMarkupId( true ) );
-
-            final SelectorInForm destinationSelector = new SelectorInForm(
-                "destination", "Destinatin", locations, this, "origin" );
-            destinationSelector.setRequired( true );
-
-            final ComponentFeedbackPanel destinationFeedback = new ComponentFeedbackPanel(
-                "destinationFeedback", destinationSelector );
-            add( destinationFeedback.setOutputMarkupId( true ) );
-
-            // Disable equal locations
-            originSelector.add( new AjaxFormComponentUpdatingBehavior( "onchange" )
-            {
-                @Override
-                protected void onUpdate( AjaxRequestTarget target )
-                {
-                    // Exclude origin in destination drop down
-                    target.add( originSelector, originFeedback, destinationSelector );
-                    focusFirstError( target );
-                }
-            } );
-
-            destinationSelector.add( new AjaxFormComponentUpdatingBehavior( "onchange" )
-            {
-                @Override
-                protected void onUpdate( AjaxRequestTarget target )
-                {
-                    // Exclude destination in origin drop down
-                    target.add( destinationSelector, destinationFeedback, originSelector );
-                    focusFirstError( target );
-                }
-            } );
-
-            // Deadline
-            final DateTextFieldWithPicker deadlineField = new DateTextFieldWithPicker( "deadline", "Arrival deadline", this );
-            deadlineField.earliestDate( LocalDate.now().plusDays( 1 ) );
-
-            final ComponentFeedbackPanel deadlineFeedback = new ComponentFeedbackPanel(
-                "deadlineFeedback", deadlineField );
-            add( deadlineFeedback.setOutputMarkupId( true ) );
-
-            add( originSelector, destinationSelector, deadlineField );
-
-            add( new AjaxFallbackButton( "book", this )
-            {
-                @Override
-                protected void onSubmit( AjaxRequestTarget target, Form<?> form )
-                {
-                    try
-                    {
-                        // Perform use case
-                        TrackingId trackingId = new BookNewCargo( origin, destination, deadline ).book();
-
-                        // Add new tracking id to list in session
-                        PrevNext.addId( Session.get(), trackingId.id().get() );
-
-                        // Show created cargo
-                        setResponsePage( CargoDetailsPage.class, new PageParameters().set( 0, trackingId.id().get() ) );
-                    }
-                    catch( Exception e )
-                    {
-                        logger.warn( "Problem booking a new cargo: " + e.getMessage() );
-                        feedback.error( e.getMessage() );
-                        target.add( feedback );
-                    }
-                }
-
-                @Override
-                protected void onError( final AjaxRequestTarget target, Form<?> form )
-                {
-                    target.add( originFeedback, destinationFeedback, deadlineFeedback );
-                    focusFirstError( target );
-                }
-            } );
-        }
-    }
-}
\ 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/communication/web/booking/BookingBasePage.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/web/booking/BookingBasePage.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/web/booking/BookingBasePage.java
deleted file mode 100644
index d91128b..0000000
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/web/booking/BookingBasePage.java
+++ /dev/null
@@ -1,39 +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.communication.web.booking;
-
-import org.apache.wicket.request.mapper.parameter.PageParameters;
-import org.apache.zest.sample.dcicargo.sample_a.communication.web.BasePage;
-
-/**
- * Booking base page - to control the selected tab
- */
-public class BookingBasePage extends BasePage
-{
-    public BookingBasePage()
-    {
-        super( "booking" );
-    }
-
-    public BookingBasePage( PageParameters pageParameters )
-    {
-        super( "booking", pageParameters );
-    }
-}
\ 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/communication/web/booking/CargoDetailsPage.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/web/booking/CargoDetailsPage.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/web/booking/CargoDetailsPage.java
deleted file mode 100644
index d1a36f1..0000000
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/web/booking/CargoDetailsPage.java
+++ /dev/null
@@ -1,180 +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.communication.web.booking;
-
-import java.util.List;
-import org.apache.wicket.AttributeModifier;
-import org.apache.wicket.devutils.stateless.StatelessComponent;
-import org.apache.wicket.markup.html.basic.Label;
-import org.apache.wicket.markup.html.basic.MultiLineLabel;
-import org.apache.wicket.markup.html.list.ListItem;
-import org.apache.wicket.markup.html.list.ListView;
-import org.apache.wicket.markup.html.panel.Fragment;
-import org.apache.wicket.model.IModel;
-import org.apache.wicket.model.LoadableDetachableModel;
-import org.apache.wicket.model.Model;
-import org.apache.wicket.request.mapper.parameter.PageParameters;
-import org.apache.zest.sample.dcicargo.sample_a.communication.query.CommonQueries;
-import org.apache.zest.sample.dcicargo.sample_a.communication.web.tracking.HandlingHistoryPanel;
-import org.apache.zest.sample.dcicargo.sample_a.communication.web.tracking.NextHandlingEventPanel;
-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.RoutingStatus;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.itinerary.Leg;
-import org.apache.zest.sample.dcicargo.sample_a.infrastructure.wicket.color.CorrectColor;
-import org.apache.zest.sample.dcicargo.sample_a.infrastructure.wicket.color.ErrorColor;
-import org.apache.zest.sample.dcicargo.sample_a.infrastructure.wicket.link.LinkPanel;
-import org.apache.zest.sample.dcicargo.sample_a.infrastructure.wicket.prevnext.PrevNext;
-
-import static java.time.ZoneOffset.UTC;
-import static java.util.Date.from;
-
-/**
- * Cargo details - an overview of all data available about a cargo.
- */
-@StatelessComponent
-public class CargoDetailsPage extends BookingBasePage
-{
-    public CargoDetailsPage( PageParameters parameters )
-    {
-        this( parameters.get( 0 ).toString() );
-    }
-
-    public CargoDetailsPage( String trackingId )
-    {
-        super( new PageParameters().set( 0, trackingId ) );
-
-        IModel<Cargo> cargoModel = new CommonQueries().cargo( trackingId );
-        Cargo cargo = cargoModel.getObject();
-        Delivery delivery = cargo.delivery().get();
-        RouteSpecification routeSpecification = cargo.routeSpecification().get();
-        final RoutingStatus routingStatus = delivery.routingStatus().get();
-        Boolean isMisrouted = routingStatus == RoutingStatus.MISROUTED;
-
-        add( new PrevNext( "prevNext", CargoDetailsPage.class, trackingId ) );
-
-        add( new Label( "trackingId", trackingId ) );
-        add( new Label( "origin", cargo.origin().get().getString() ) );
-        add( new Label( "destination", routeSpecification.destination()
-            .get()
-            .getString() ).add( new CorrectColor( isMisrouted ) ) );
-        add( new Label( "deadline", Model.of( routeSpecification.arrivalDeadline().get() ) ) );
-        add( new Label( "routingStatus", routingStatus.toString() ).add( new ErrorColor( isMisrouted ) ) );
-        add( new LinkPanel( "changeDestination", ChangeDestinationPage.class, trackingId, "Change destination" ) );
-
-        if( routingStatus == RoutingStatus.NOT_ROUTED )
-        {
-            add( new LinkPanel( "routingAction", RouteCargoPage.class, trackingId, "Route" ) );
-            add( new Label( "delivery" ) );
-            add( new Label( "itinerary" ) );
-        }
-        else if( routingStatus == RoutingStatus.ROUTED )
-        {
-            add( new LinkPanel( "routingAction", RouteCargoPage.class, trackingId, "Re-route" ) );
-            add( new DeliveryFragment( delivery ) );
-            add( new ItineraryFragment( cargoModel, routingStatus ) );
-        }
-        else if( routingStatus == RoutingStatus.MISROUTED )
-        {
-            add( new LinkPanel( "routingAction", RouteCargoPage.class, trackingId, "Re-route" ) );
-            add( new DeliveryFragment( delivery ) );
-            add( new ItineraryFragment( cargoModel, routingStatus ) );
-        }
-        else
-        {
-            throw new RuntimeException( "Unknown routing status." );
-        }
-
-        if( delivery.lastHandlingEvent().get() == null )
-        {
-            add( new Label( "handlingHistoryPanel" ) );
-        }
-        else
-        {
-            add( new HandlingHistoryPanel( "handlingHistoryPanel", cargoModel, trackingId ) );
-        }
-
-        add( new NextHandlingEventPanel( "nextHandlingEventPanel", cargoModel ) );
-    }
-//
-//    @Override
-//    public boolean isVersioned()
-//    {
-//        return false;
-//    }
-
-    private class ItineraryFragment extends Fragment
-    {
-        public ItineraryFragment( final IModel<Cargo> cargoModel, final RoutingStatus routingStatus )
-        {
-            super( "itinerary", "itineraryFragment", CargoDetailsPage.this );
-
-            IModel<List<Leg>> legListModel = new LoadableDetachableModel<List<Leg>>()
-            {
-                @Override
-                protected List<Leg> load()
-                {
-                    return cargoModel.getObject().itinerary().get().legs().get();
-                }
-            };
-
-            add( new ListView<Leg>( "legs", legListModel )
-            {
-                @Override
-                protected void populateItem( ListItem<Leg> item )
-                {
-                    Leg leg = item.getModelObject();
-
-                    item.add( new Label( "loadLocation", leg.loadLocation().get().getCode() ) );
-                    item.add( new Label( "loadDate", new Model<>( from( leg.loadDate().get().atStartOfDay().toInstant( UTC ) ) ) ) );
-                    item.add( new Label( "voyage", leg.voyage().get().voyageNumber().get().number().get() ) );
-
-                    Boolean isMisrouted = routingStatus == RoutingStatus.MISROUTED && item.getIndex() == ( getList().size() - 1 );
-                    item.add( new Label( "unloadLocation",
-                                         leg.unloadLocation().get().getCode() ).add( new ErrorColor( isMisrouted ) ) );
-
-                    item.add( new Label( "unloadDate",
-                                         new Model<>( from( leg.unloadDate().get().atStartOfDay().toInstant( UTC ) ) ) ) );
-                }
-            } );
-        }
-    }
-
-    private class DeliveryFragment extends Fragment
-    {
-        public DeliveryFragment( Delivery delivery )
-        {
-            super( "delivery", "deliveryFragment", CargoDetailsPage.this );
-
-            add( new Label( "transportStatus", delivery.transportStatus().get().toString() ) );
-
-            if( delivery.isMisdirected().get() )
-            {
-                String msg = "Cargo is misdirected. \nPlease reroute cargo.";
-                add( new MultiLineLabel( "deliveryStatus", msg ).add( new AttributeModifier( "class", "errorColor" ) ) );
-            }
-            else
-            {
-                add( new Label( "deliveryStatus", "On track" ) );
-            }
-        }
-    }
-}
\ 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/communication/web/booking/CargoListPage.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/web/booking/CargoListPage.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/web/booking/CargoListPage.java
deleted file mode 100644
index 25bc21e..0000000
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/web/booking/CargoListPage.java
+++ /dev/null
@@ -1,99 +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.communication.web.booking;
-
-import java.time.LocalDateTime;
-import java.time.ZoneOffset;
-import java.util.ArrayList;
-import java.util.List;
-import org.apache.wicket.Session;
-import org.apache.wicket.devutils.stateless.StatelessComponent;
-import org.apache.wicket.markup.html.basic.Label;
-import org.apache.wicket.markup.html.list.ListItem;
-import org.apache.wicket.markup.html.list.ListView;
-import org.apache.wicket.model.IModel;
-import org.apache.wicket.model.Model;
-import org.apache.zest.sample.dcicargo.sample_a.communication.query.CommonQueries;
-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.RoutingStatus;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.handling.HandlingEventType;
-import org.apache.zest.sample.dcicargo.sample_a.infrastructure.wicket.color.ErrorColor;
-import org.apache.zest.sample.dcicargo.sample_a.infrastructure.wicket.link.LinkPanel;
-import org.apache.zest.sample.dcicargo.sample_a.infrastructure.wicket.prevnext.PrevNext;
-
-import static java.util.Date.from;
-
-/**
- * List of Cargos
- */
-@StatelessComponent
-public class CargoListPage extends BookingBasePage
-{
-    public CargoListPage()
-    {
-        IModel<List<Cargo>> cargoList = new CommonQueries().cargoList();
-
-        // Save current trackingIds in session (for prev/next buttons on details page)
-        ArrayList<String> ids = new ArrayList<>();
-        for( Cargo cargo : cargoList.getObject() )
-        {
-            ids.add( cargo.trackingId().get().id().get() );
-        }
-        PrevNext.registerIds( Session.get(), ids );
-
-        add( new ListView<Cargo>( "list", cargoList )
-        {
-            @Override
-            protected void populateItem( ListItem<Cargo> item )
-            {
-                Cargo cargo = item.getModelObject();
-                String trackingId = cargo.trackingId().get().id().get();
-                Delivery delivery = cargo.delivery().get();
-                RoutingStatus routingStatus = cargo.delivery().get().routingStatus().get();
-
-                item.add( new LinkPanel( "trackingId", CargoDetailsPage.class, trackingId ) );
-
-                item.add( new Label( "origin", cargo.origin().get().getCode() ) );
-
-                RouteSpecification routeSpecification = cargo.routeSpecification().get();
-                item.add( new Label( "destination", routeSpecification.destination().get().getCode() ) );
-
-                LocalDateTime deadlineTime = routeSpecification.arrivalDeadline().get().atStartOfDay().plusDays( 1 );
-                item.add( new Label( "deadline", new Model<>( from( deadlineTime.toInstant( ZoneOffset.UTC ) ) ) ) );
-
-                item.add( new Label( "routingStatus", routingStatus.toString() ).add( new ErrorColor( routingStatus == RoutingStatus.MISROUTED ) ) );
-
-                Boolean inCustoms = delivery.lastHandlingEvent().get() != null
-                                    && delivery.lastHandlingEvent()
-                                           .get()
-                                           .handlingEventType()
-                                           .get() == HandlingEventType.CUSTOMS;
-                String customsLabel = delivery.transportStatus().get().name() + ( inCustoms ? " (CUSTOMS)" : "" );
-                item.add( new Label( "transportStatus", customsLabel ) );
-
-                IModel directed = new Model<>( delivery.isMisdirected().get() ? "Misdirected" : "On track" );
-                item.add( new Label( "deliveryStatus", directed ).add( new ErrorColor( delivery.isMisdirected()
-                                                                                           .get() ) ) );
-            }
-        } );
-    }
-}
\ No newline at end of file


Mime
View raw message