polygene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nic...@apache.org
Subject [17/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:58 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/communication/web/booking/ChangeDestinationPage.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/web/booking/ChangeDestinationPage.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/web/booking/ChangeDestinationPage.java
deleted file mode 100644
index e435cdb..0000000
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/web/booking/ChangeDestinationPage.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.communication.web.booking;
-
-import java.util.List;
-import org.apache.wicket.ajax.AjaxRequestTarget;
-import org.apache.wicket.ajax.markup.html.form.AjaxFallbackButton;
-import org.apache.wicket.markup.html.basic.Label;
-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.Cargo;
-import org.apache.zest.sample.dcicargo.sample_a.infrastructure.wicket.form.AbstractForm;
-import org.apache.zest.sample.dcicargo.sample_a.infrastructure.wicket.form.SelectorInForm;
-
-/**
- * Change destination of Cargo
- */
-public class ChangeDestinationPage extends BookingBasePage
-{
-    public ChangeDestinationPage( PageParameters parameters )
-    {
-        String trackingId = parameters.get( 0 ).toString();
-        add( new Label( "trackingId", trackingId ) );
-        add( new CargoEditForm( trackingId ) );
-    }
-
-    private class CargoEditForm extends AbstractForm<Void>
-    {
-        private String trackingId; // Set by Wicket property resolver
-        private String origin, destination, oldDestination;
-
-        public CargoEditForm( final String trackingId )
-        {
-            CommonQueries fetch = new CommonQueries();
-            Cargo cargo = fetch.cargo( trackingId ).getObject();
-            List<String> locations = fetch.unLocodes();
-
-            origin = cargo.origin().get().getCode();
-            oldDestination = destination = cargo.routeSpecification().get().destination().get().getCode();
-
-            final FeedbackPanel feedback = new FeedbackPanel( "usecaseFeedback" );
-            final SelectorInForm destinationSelector = new SelectorInForm(
-                "destination", "Destination", locations, this, "origin" );
-            final ComponentFeedbackPanel destinationFeedback = new ComponentFeedbackPanel(
-                "destinationFeedback", destinationSelector.setRequired( true ) );
-
-            add( feedback.setOutputMarkupId( true ) );
-            add( new Label( "origin", origin ) );
-            add( new Label( "destination", destination ) );
-            add( destinationFeedback.setOutputMarkupId( true ) );
-            add( destinationSelector );
-            add( new AjaxFallbackButton( "submit", this )
-            {
-                @Override
-                protected void onSubmit( AjaxRequestTarget target, Form<?> form )
-                {
-                    try
-                    {
-                        if( oldDestination.equals( destination ) )
-                        {
-                            throw new IllegalArgumentException( "Please select a new destination." );
-                        }
-
-                        // Perform use case
-                        new BookNewCargo( trackingId ).changeDestination( destination );
-
-                        // Show updated cargo
-                        setResponsePage( CargoDetailsPage.class, new PageParameters().set( 0, trackingId ) );
-                    }
-                    catch( Exception e )
-                    {
-                        logger.warn( "Problem changing destination of cargo " + trackingId + ": " + e.getMessage() );
-                        feedback.error( e.getMessage() );
-                        target.add( feedback );
-                    }
-                }
-
-                @Override
-                protected void onError( final AjaxRequestTarget target, Form<?> form )
-                {
-                    target.add( destinationFeedback );
-                    target.focusComponent( destinationSelector );
-                }
-            } );
-        }
-    }
-}
\ 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/RouteCargoPage.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/web/booking/RouteCargoPage.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/web/booking/RouteCargoPage.java
deleted file mode 100644
index be29b41..0000000
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/web/booking/RouteCargoPage.java
+++ /dev/null
@@ -1,69 +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.markup.html.WebMarkupContainer;
-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.markup.html.panel.FeedbackPanel;
-import org.apache.wicket.model.IModel;
-import org.apache.wicket.request.mapper.parameter.PageParameters;
-import org.apache.zest.sample.dcicargo.sample_a.communication.query.BookingQueries;
-import org.apache.zest.sample.dcicargo.sample_a.context.support.FoundNoRoutesException;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.itinerary.Itinerary;
-
-/**
- * Re-route page - presents a list of possible routes a cargo can take that the user can choose from.
- *
- * Each route candidate is presented by a {@link RoutePanel}.
- */
-public class RouteCargoPage extends BookingBasePage
-{
-    private FeedbackPanel feedback = new FeedbackPanel( "feedback" );
-
-    public RouteCargoPage( PageParameters parameters )
-    {
-        final String trackingId = parameters.get( 0 ).toString();
-
-        add( new Label( "trackingId", trackingId ) );
-
-        add( new FeedbackPanel( "feedback" ) );
-
-//        List<IModel<Itinerary>> routes = null;
-        try
-        {
-            add( new ListView<IModel<Itinerary>>( "routes", query( BookingQueries.class ).routeCandidates( trackingId ) )
-            {
-                @Override
-                protected void populateItem( ListItem<IModel<Itinerary>> item )
-                {
-                    item.add( new RoutePanel( "route", trackingId, item.getModelObject(), item.getIndex() + 1 ) );
-                }
-            } );
-        }
-        catch( FoundNoRoutesException e )
-        {
-            error( e.getMessage() );
-
-            add( new WebMarkupContainer( "routes" ).add( new Label( "route" ) ) );
-        }
-    }
-}
\ 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/RoutePanel.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/web/booking/RoutePanel.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/web/booking/RoutePanel.java
deleted file mode 100644
index 7ad9d14..0000000
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/web/booking/RoutePanel.java
+++ /dev/null
@@ -1,118 +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.ajax.AjaxRequestTarget;
-import org.apache.wicket.ajax.markup.html.form.AjaxFallbackButton;
-import org.apache.wicket.markup.html.basic.Label;
-import org.apache.wicket.markup.html.form.Form;
-import org.apache.wicket.markup.html.list.ListItem;
-import org.apache.wicket.markup.html.list.ListView;
-import org.apache.wicket.markup.html.panel.FeedbackPanel;
-import org.apache.wicket.markup.html.panel.Panel;
-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.context.shipping.booking.BookNewCargo;
-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 static java.time.ZoneOffset.UTC;
-import static java.util.Date.from;
-
-/**
- * Route Panel - shows a suggested route a Cargo can take.
- *
- * If the user chooses this candidate route, all route data (a value object) is attached by the BookNewCargo context
- * as an Itinerary to the Cargo. To see the result, the user is then redirected to the details page of the cargo.
- */
-public class RoutePanel extends Panel
-{
-    public RoutePanel( String id,
-                       final String trackingIdString,
-                       final IModel<Itinerary> candidateRouteModel,
-                       int index
-    )
-    {
-        super( id, candidateRouteModel );
-        Itinerary itinerary = candidateRouteModel.getObject();
-
-        IModel<String> header = Model.of( "Route candidate " + index + " - duration: " + itinerary.days() + " days." );
-        add( new Label( "routeHeader", header ) );
-
-        final FeedbackPanel routeFeedback = new FeedbackPanel( "routeFeedback" );
-        add( routeFeedback.setOutputMarkupId( true ) );
-
-        IModel<List<Leg>> legListModel = new LoadableDetachableModel<List<Leg>>()
-        {
-            @Override
-            protected List<Leg> load()
-            {
-                return candidateRouteModel.getObject().legs().get();
-            }
-        };
-
-        add( new ListView<Leg>( "legs", legListModel )
-        {
-            @Override
-            protected void populateItem( ListItem<Leg> item )
-            {
-                Leg leg = item.getModelObject();
-                item.add( new Label( "voyage", leg.voyage().get().toString() ),
-                          new Label( "loadLocation", leg.loadLocation().get().getCode() ),
-                          new Label( "loadDate", new Model<>( from( leg.loadDate().get().atStartOfDay().toInstant( UTC ) ) ) ),
-                          new Label( "unloadLocation", leg.unloadLocation().get().getCode() ),
-                          new Label( "unloadDate", new Model<>( from( leg.unloadDate().get().atStartOfDay().toInstant( UTC ) ) ) )
-                );
-            }
-        } );
-
-        Form form = new Form<Void>( "form" );
-        form.add( new AjaxFallbackButton( "assign", form )
-        {
-            @Override
-            protected void onSubmit( AjaxRequestTarget target, Form<?> form )
-            {
-                try
-                {
-                    // The candidate route is sent as the chosen Itinerary
-                    new BookNewCargo( trackingIdString, candidateRouteModel.getObject() ).assignCargoToRoute();
-                    setResponsePage( CargoDetailsPage.class, new PageParameters().set( 0, trackingIdString ) );
-                }
-                catch( Exception e )
-                {
-                    String msg = "Problem assigning this route to cargo: " + e.getMessage();
-                    routeFeedback.error( msg );
-                    target.add( routeFeedback );
-                }
-            }
-
-            @Override
-            protected void onError( final AjaxRequestTarget target, Form<?> form )
-            {
-                routeFeedback.error( "Unexpected error - all routes are expected to be valid." );
-                target.add( routeFeedback );
-            }
-        } );
-        add( form );
-    }
-}
\ 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/handling/RegisterHandlingEventPage.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/web/handling/RegisterHandlingEventPage.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/web/handling/RegisterHandlingEventPage.java
deleted file mode 100644
index e522a93..0000000
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/web/handling/RegisterHandlingEventPage.java
+++ /dev/null
@@ -1,146 +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.handling;
-
-import java.time.LocalDate;
-import org.apache.wicket.ajax.AjaxRequestTarget;
-import org.apache.wicket.ajax.markup.html.form.AjaxFallbackButton;
-import org.apache.wicket.markup.html.form.Form;
-import org.apache.wicket.markup.html.panel.FeedbackPanel;
-import org.apache.wicket.model.Model;
-import org.apache.wicket.model.StringResourceModel;
-import org.apache.wicket.util.value.ValueMap;
-import org.apache.zest.sample.dcicargo.sample_a.communication.query.CommonQueries;
-import org.apache.zest.sample.dcicargo.sample_a.communication.query.HandlingQueries;
-import org.apache.zest.sample.dcicargo.sample_a.communication.web.BasePage;
-import org.apache.zest.sample.dcicargo.sample_a.context.shipping.handling.RegisterHandlingEvent;
-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;
-
-/**
- * Register Handling Events
- *
- * Interface used by various authorities to register handling events for cargos. This would be a
- * separate interface not coupled to the booking system, but for testing convenience it is integrated
- * with Booking and Tracking.
- *
- * Tip: try open the Event Registration window side-by-side to a Cargo details window for a specific cargo.
- * Then register events for that cargo and here and update the details window to see the progress. You can
- * also then in the details window see what event is expected next...
- */
-public class RegisterHandlingEventPage extends BasePage
-{
-    public RegisterHandlingEventPage()
-    {
-        super( "handling" ); // Selects the Event Registration tab
-        add( new RegisterHandlingEventForm() );
-    }
-
-    private final class RegisterHandlingEventForm extends AbstractForm<Void>
-    {
-        // Set by Wicket property resolvers:
-        private LocalDate completionDate;
-        private String trackingId, unLocode, voyageNumber, eventType;
-
-        private String lastSubmittedData;
-
-        public RegisterHandlingEventForm()
-        {
-            final FeedbackPanel feedback = new FeedbackPanel( "feedback" );
-            add( feedback.setOutputMarkupId( true ) );
-
-            final DateTextFieldWithPicker completionDateInput = new DateTextFieldWithPicker( "completionDate", "Completion", this );
-            completionDateInput.earliestDate( LocalDate.now() );
-
-            HandlingQueries fetch = new HandlingQueries();
-            add( completionDateInput.setLabel( Model.of( "Completion" ) ) );
-            add( new SelectorInForm( "trackingId", "Tracking Id", fetch.cargoIds(), this ).setRequired( true ) );
-            add( new SelectorInForm( "eventType", "Event Type", fetch.eventTypes(), this ).setRequired( true ) );
-            add( new SelectorInForm( "unLocode", "Location", new CommonQueries().unLocodes(), this ).setRequired( true ) );
-            add( new SelectorInForm( "voyageNumber", "Voyage number", fetch.voyages(), this ) );
-
-            add( new AjaxFallbackButton( "register", this )
-            {
-                @Override
-                protected void onSubmit( AjaxRequestTarget target, Form<?> form )
-                {
-                    try
-                    {
-                        // We want to allow making multiple _unique_ handling event registrations
-                        if( sameDataIsSubmitted() )
-                        {
-                            throw new Exception( "Can't re-submit the same data." );
-                        }
-
-                        // Perform use case
-                        new RegisterHandlingEvent(
-                            LocalDate.now(), completionDate, trackingId, eventType, unLocode, voyageNumber ).register();
-
-                        // We could redirect to Details, but it's more fun to update details in a separate
-                        // window to follow the successive handling event registrations you make...
-//                        setResponsePage( CargoDetails.class, new PageParameters().set( 0, trackingId ) );
-
-                        ValueMap map = new ValueMap();
-                        map.put( "type", eventType );
-                        map.put( "location", unLocode );
-                        if( voyageNumber != null )
-                        {
-                            map.put( "voyage", voyageNumber );
-                        }
-                        String msg = new StringResourceModel(
-                            "handlingEvent.${type}", this, new Model<>( map ) ).getObject();
-
-                        feedback.info( "Registered handling event for cargo '" + trackingId + "': " + msg );
-                        target.add( feedback );
-                    }
-                    catch( Exception e )
-                    {
-                        logger.warn( "Problem registering handling event: " + e.getMessage() );
-                        feedback.error( e.getMessage() );
-                        target.add( feedback );
-                    }
-                }
-
-                @Override
-                protected void onError( final AjaxRequestTarget target, Form<?> form )
-                {
-                    target.add( feedback );
-                    focusFirstError( target );
-                }
-            } );
-        }
-
-        private boolean sameDataIsSubmitted()
-        {
-            String submittedData = completionDate.toString() + trackingId + unLocode + voyageNumber + eventType;
-
-            if( submittedData.equals( lastSubmittedData ) )
-            {
-                return true;
-            }
-
-            // Valid new data submitted
-            lastSubmittedData = submittedData;
-
-            return false;
-        }
-    }
-}
\ 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/tracking/HandlingHistoryPanel.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/web/tracking/HandlingHistoryPanel.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/web/tracking/HandlingHistoryPanel.java
deleted file mode 100644
index 5aa441f..0000000
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/web/tracking/HandlingHistoryPanel.java
+++ /dev/null
@@ -1,85 +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.tracking;
-
-import java.util.List;
-import org.apache.wicket.behavior.AttributeAppender;
-import org.apache.wicket.devutils.stateless.StatelessComponent;
-import org.apache.wicket.markup.html.WebMarkupContainer;
-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.markup.html.panel.Panel;
-import org.apache.wicket.model.IModel;
-import org.apache.wicket.model.Model;
-import org.apache.wicket.model.StringResourceModel;
-import org.apache.wicket.util.value.ValueMap;
-import org.apache.zest.sample.dcicargo.sample_a.communication.query.TrackingQueries;
-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.wicket.color.ErrorColor;
-
-/**
- * Handling history - a table list of handling events
- *
- * A tracking id string is passed in to retrieve all events matching that cargo.
- */
-@StatelessComponent
-public class HandlingHistoryPanel extends Panel
-{
-    public HandlingHistoryPanel( String id, final IModel<Cargo> cargoModel, String trackingId )
-    {
-        super( id );
-
-        IModel<List<HandlingEvent>> handlingEventsModel = new TrackingQueries().events( trackingId );
-
-        add( new ListView<HandlingEvent>( "handlingEvents", handlingEventsModel )
-        {
-            @Override
-            protected void populateItem( ListItem<HandlingEvent> item )
-            {
-                HandlingEvent event = item.getModelObject();
-                Boolean isLast = item.getIndex() == getList().size() - 1;
-                Boolean isMisdirected = cargoModel.getObject().delivery().get().isMisdirected().get();
-
-                // Status icon
-                IModel iconName = Model.of( isLast && isMisdirected ? "cross.png" : "tick.png" );
-                item.add( new WebMarkupContainer( "onTrackIcon" ).add( new AttributeAppender( "src", iconName, "" ) ) );
-
-                // Date
-                item.add( new Label( "completion", new Model<>( event.completionDate().get() ) ) );
-
-                // Event description (data substitution in strings from HandlingHistoryPanel.properties)
-                ValueMap map = new ValueMap();
-                map.put( "type", event.handlingEventType().get().name() );
-                map.put( "location", event.location().get().getString() );
-                if( event.voyage().get() != null )
-                {
-                    map.put( "voyage", event.voyage().get().voyageNumber().get().number().get() );
-                }
-                IModel text = new StringResourceModel( "handlingEvent.${type}", this, new Model<>( map ) );
-                item.add( new Label( "event", text )
-                              .add( new ErrorColor( isLast && isMisdirected ) )
-                              .setEscapeModelStrings( false ) );
-            }
-        } );
-    }
-}
-

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/tracking/NextHandlingEventPanel.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/web/tracking/NextHandlingEventPanel.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/web/tracking/NextHandlingEventPanel.java
deleted file mode 100644
index 77091e4..0000000
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/web/tracking/NextHandlingEventPanel.java
+++ /dev/null
@@ -1,100 +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.tracking;
-
-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.panel.Panel;
-import org.apache.wicket.model.IModel;
-import org.apache.wicket.model.Model;
-import org.apache.wicket.model.StringResourceModel;
-import org.apache.wicket.util.value.ValueMap;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.cargo.Cargo;
-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.handling.HandlingEventType;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.location.Location;
-
-/**
- * Next expected handling event
- *
- * Quite some logic to render 1 line of information!
- */
-@StatelessComponent
-public class NextHandlingEventPanel extends Panel
-{
-    public NextHandlingEventPanel( String id, IModel<Cargo> cargoModel )
-    {
-        super( id );
-
-        ValueMap map = new ValueMap();
-        Label label = new Label( "text", new StringResourceModel(
-            "expectedEvent.${expectedEvent}", this, new Model<>( map ) ) );
-        add( label );
-
-        Cargo cargo = cargoModel.getObject();
-        Location destination = cargo.routeSpecification().get().destination().get();
-
-        if( cargo.itinerary().get() == null )
-        {
-            map.put( "expectedEvent", "ROUTE" );
-            return;
-        }
-
-        HandlingEvent previousEvent = cargo.delivery().get().lastHandlingEvent().get();
-        if( previousEvent == null )
-        {
-            map.put( "expectedEvent", "RECEIVE" );
-            map.put( "location", cargo.routeSpecification().get().origin().get().getString() );
-            return;
-        }
-
-        Location lastLocation = previousEvent.location().get();
-        if( previousEvent.handlingEventType().get() == HandlingEventType.CLAIM && lastLocation == destination )
-        {
-            map.put( "expectedEvent", "END_OF_CYCLE" );
-            map.put( "location", destination.getString() );
-            label.add( new AttributeModifier( "class", "correctColor" ) );
-            return;
-        }
-
-        ExpectedHandlingEvent nextEvent = cargo.delivery().get().nextExpectedHandlingEvent().get();
-        if( nextEvent == null )
-        {
-            map.put( "expectedEvent", "UNKNOWN" );
-            label.add( new AttributeModifier( "class", "errorColor" ) );
-            return;
-        }
-
-        map.put( "expectedEvent", nextEvent.handlingEventType().get().name() );
-        map.put( "location", nextEvent.location().get().getString() );
-
-        if( nextEvent.date() != null )
-        {
-            map.put( "time", nextEvent.date().get().toString() );
-        }
-
-        if( nextEvent.voyage().get() != null )
-        {
-            map.put( "voyage", nextEvent.voyage().get().voyageNumber().get().number().get() );
-        }
-    }
-}

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/tracking/TrackCargoPage.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/web/tracking/TrackCargoPage.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/web/tracking/TrackCargoPage.java
deleted file mode 100644
index e891be1..0000000
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/web/tracking/TrackCargoPage.java
+++ /dev/null
@@ -1,201 +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.tracking;
-
-import java.time.LocalDate;
-import java.util.List;
-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.WebMarkupContainer;
-import org.apache.wicket.markup.html.basic.Label;
-import org.apache.wicket.markup.html.form.Form;
-import org.apache.wicket.markup.html.form.TextField;
-import org.apache.wicket.markup.html.panel.FeedbackPanel;
-import org.apache.wicket.markup.html.panel.Fragment;
-import org.apache.wicket.model.IModel;
-import org.apache.wicket.model.Model;
-import org.apache.wicket.model.PropertyModel;
-import org.apache.wicket.model.StringResourceModel;
-import org.apache.wicket.util.value.ValueMap;
-import org.apache.zest.api.unitofwork.NoSuchEntityException;
-import org.apache.zest.sample.dcicargo.sample_a.communication.query.CommonQueries;
-import org.apache.zest.sample.dcicargo.sample_a.communication.query.TrackingQueries;
-import org.apache.zest.sample.dcicargo.sample_a.communication.web.BasePage;
-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.handling.HandlingEventType;
-import org.apache.zest.sample.dcicargo.sample_a.infrastructure.wicket.form.AbstractForm;
-import org.apache.zest.sample.dcicargo.sample_a.infrastructure.wicket.form.SelectorInForm;
-
-/**
- * Track a cargo
- *
- * For convenience during testing, routed (non-received) cargos can be chosen from the dropdown list.
- */
-public class TrackCargoPage extends BasePage
-{
-    public TrackCargoPage()
-    {
-        super( "tracking" ); // Selects the Tracking tab
-        add( new TrackingForm() );
-    }
-
-    private final class TrackingForm extends AbstractForm<Void>
-    {
-        private String trackingId;
-
-        @SuppressWarnings( "unused" )   // Set by Wicket property resolver
-        private String selectedTrackingId;
-
-        private TextField<String> trackingIdInput;
-        private SelectorInForm selectedTrackingIdSelector;
-
-        private FeedbackPanel feedback = new FeedbackPanel( "feedback" );
-        private Fragment statusFragment = new Fragment( "status", "statusFragment", new WebMarkupContainer( "mock" ) );
-
-        private TrackingForm()
-        {
-            // Manual input
-            trackingIdInput = new TextField<>( "trackingId", new PropertyModel<String>( this, "trackingId" ) );
-            add( trackingIdInput.setRequired( true ).setOutputMarkupId( true ) );
-
-            // Submit button
-            add( new AjaxFallbackButton( "track", this )
-            {
-                @Override
-                protected void onSubmit( AjaxRequestTarget target, Form<?> form )
-                {
-                    updateStatusFragment( target );
-                }
-
-                @Override
-                protected void onError( final AjaxRequestTarget target, Form<?> form )
-                {
-                    target.add( feedback, trackingIdInput, selectedTrackingIdSelector, statusFragment.setVisible( false ) );
-                }
-            } );
-
-            // Drop down selector (for convenience when testing)
-            List<String> cargoIds = new TrackingQueries().routedCargos();
-            add( selectedTrackingIdSelector = new SelectorInForm(
-                "selectedTrackingId", "Selected Tracking id", cargoIds, this ) );
-            selectedTrackingIdSelector.add( new AjaxFormComponentUpdatingBehavior( "onchange" )
-            {
-                @Override
-                protected void onUpdate( AjaxRequestTarget target )
-                {
-                    trackingId = selectedTrackingId;
-                    updateStatusFragment( target );
-                }
-            } );
-
-            add( feedback.setOutputMarkupId( true ) );
-            add( statusFragment.setOutputMarkupId( true ).setOutputMarkupPlaceholderTag( true ).setVisible( false ) );
-        }
-
-        private void updateStatusFragment( final AjaxRequestTarget target )
-        {
-            try
-            {
-                IModel<Cargo> cargoModel = new CommonQueries().cargo( trackingId );
-                statusFragment = (Fragment) statusFragment.replaceWith( new StatusFragment( cargoModel, false ) );
-                target.add( feedback, trackingIdInput, selectedTrackingIdSelector, statusFragment.setVisible( true ) );
-            }
-            catch( NoSuchEntityException e )
-            {
-                e.printStackTrace();
-                error( "Cargo '" + trackingId + "' wasn't found in the system. Please check the tracking number." );
-                target.add( feedback, trackingIdInput, selectedTrackingIdSelector, statusFragment.setVisible( false ) );
-            }
-            catch( Exception e )
-            {
-                e.printStackTrace();
-                error( "Problem retrieving status for cargo '" + trackingId + "': " + e.getMessage() );
-                target.add( feedback, trackingIdInput, selectedTrackingIdSelector, statusFragment.setVisible( false ) );
-            }
-        }
-
-        private class StatusFragment extends Fragment
-        {
-            StatusFragment( IModel<Cargo> cargoModel, Boolean visible )
-            {
-                super( "status", "statusFragment", TrackingForm.this );
-                setVisible( visible );
-
-                Cargo cargo = cargoModel.getObject();
-
-                // Status ----------------------------------------------------------------------
-                ValueMap map = new ValueMap();
-                map.put( "status", cargo.delivery().get().transportStatus().get().name() );
-                map.put( "trackingId", trackingId );
-                HandlingEvent lastEvent = cargo.delivery().get().lastHandlingEvent().get();
-                if( lastEvent != null )
-                {
-                    String voyageString = lastEvent.voyage().get() != null ?
-                                          lastEvent.voyage()
-                                              .get()
-                                              .voyageNumber()
-                                              .get()
-                                              .number()
-                                              .get() : "UNKNOWN_VOYAGE";
-                    map.put( "voyage", voyageString );
-                    map.put( "location", lastEvent.location().get().getString() );
-                }
-                else
-                {
-                    map.put( "voyage", "UNKNOWN_VOYAGE" );
-                    map.put( "location", cargo.origin().get().getString() );
-                }
-                add( new Label( "transportStatus", new StringResourceModel(
-                    "transportStatus.${status}", this, new Model<>( map ) ) ) );
-
-                // ETA ----------------------------------------------------------------------
-                String destination = cargo.routeSpecification().get().destination().get().getString();
-                LocalDate eta = cargo.delivery().get().eta().get();
-                String etaString = eta == null ? "?" : eta.toString();
-                add( new Label( "eta", new StringResourceModel(
-                    "eta", this, null, Model.of( destination ), Model.of( etaString ) ) ) );
-
-                // Warning/Notifier ----------------------------------------------------------------------
-                add( new WebMarkupContainer( "isMisdirected" ).setVisible( cargo.delivery()
-                                                                               .get()
-                                                                               .isMisdirected()
-                                                                               .get() ) );
-                add( new WebMarkupContainer( "isClaimed" ).setVisible(
-                    !cargo.delivery().get().isMisdirected().get()
-                    && cargo.delivery().get().isUnloadedAtDestination().get()
-                    && lastEvent != null
-                    && lastEvent.handlingEventType().get() == HandlingEventType.CLAIM
-                ) );
-
-                // Handling history ----------------------------------------------------------------------
-                if( cargo.delivery().get().lastHandlingEvent().get() == null )
-                {
-                    add( new Label( "handlingHistoryPanel" ) );
-                }
-                else
-                {
-                    add( new HandlingHistoryPanel( "handlingHistoryPanel", cargoModel, trackingId ) );
-                }
-            }
-        }
-    }
-}
\ 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/rolemap/CargoRoleMap.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/rolemap/CargoRoleMap.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/rolemap/CargoRoleMap.java
deleted file mode 100644
index 8f713f7..0000000
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/rolemap/CargoRoleMap.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.context.rolemap;
-
-import org.apache.zest.api.entity.EntityComposite;
-import org.apache.zest.sample.dcicargo.sample_a.context.shipping.booking.BookNewCargo;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.cargo.Cargo;
-
-/**
- * Cargo Role Map
- */
-public interface CargoRoleMap extends BookNewCargo.RoutingFacadeRole, EntityComposite, Cargo
-{
-}

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/rolemap/CargosRoleMap.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/rolemap/CargosRoleMap.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/rolemap/CargosRoleMap.java
deleted file mode 100644
index 51cdcd4..0000000
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/rolemap/CargosRoleMap.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.context.rolemap;
-
-import org.apache.zest.api.entity.EntityComposite;
-import org.apache.zest.sample.dcicargo.sample_a.context.shipping.booking.BookNewCargo;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.cargo.Cargos;
-
-/**
- * Cargos Role Map
- */
-public interface CargosRoleMap extends BookNewCargo.CargoFactoryRole, EntityComposite, Cargos
-{
-}

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/rolemap/HandlingEventRoleMap.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/rolemap/HandlingEventRoleMap.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/rolemap/HandlingEventRoleMap.java
deleted file mode 100644
index e88f204..0000000
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/rolemap/HandlingEventRoleMap.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.context.rolemap;
-
-import org.apache.zest.api.entity.EntityComposite;
-import org.apache.zest.sample.dcicargo.sample_a.context.shipping.booking.BuildDeliverySnapshot;
-import org.apache.zest.sample.dcicargo.sample_a.context.shipping.handling.InspectCargo;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.handling.HandlingEvent;
-
-/**
- * Handling Event Role Map
- */
-public interface HandlingEventRoleMap extends BuildDeliverySnapshot.HandlingEventRole,
-                                              InspectCargo.CargoInspectorRole,
-                                              EntityComposite, HandlingEvent
-{
-}

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/rolemap/HandlingEventsRoleMap.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/rolemap/HandlingEventsRoleMap.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/rolemap/HandlingEventsRoleMap.java
deleted file mode 100644
index 637c871..0000000
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/rolemap/HandlingEventsRoleMap.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.context.rolemap;
-
-import org.apache.zest.api.entity.EntityComposite;
-import org.apache.zest.sample.dcicargo.sample_a.context.shipping.handling.RegisterHandlingEvent;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.handling.HandlingEvents;
-
-/**
- * Handling Events Role Map
- */
-public interface HandlingEventsRoleMap extends RegisterHandlingEvent.HandlingEventFactoryRole,
-                                               EntityComposite, HandlingEvents
-{
-}

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/rolemap/ItineraryRoleMap.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/rolemap/ItineraryRoleMap.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/rolemap/ItineraryRoleMap.java
deleted file mode 100644
index 915aed8..0000000
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/rolemap/ItineraryRoleMap.java
+++ /dev/null
@@ -1,36 +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.rolemap;
-
-import org.apache.zest.api.value.ValueComposite;
-import org.apache.zest.sample.dcicargo.sample_a.context.shipping.booking.BuildDeliverySnapshot;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.itinerary.Itinerary;
-
-/**
- * Itinerary Role Map
- *
- * Note that this is a Value Composite (and not an entity) capable of playing different Roles.
- */
-public interface ItineraryRoleMap
-    extends ValueComposite,
-            Itinerary,
-            BuildDeliverySnapshot.ItineraryRole
-{
-}

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/rolemap/RouteSpecificationRoleMap.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/rolemap/RouteSpecificationRoleMap.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/rolemap/RouteSpecificationRoleMap.java
deleted file mode 100644
index e231fd1..0000000
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/rolemap/RouteSpecificationRoleMap.java
+++ /dev/null
@@ -1,36 +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.rolemap;
-
-import org.apache.zest.api.value.ValueComposite;
-import org.apache.zest.sample.dcicargo.sample_a.context.shipping.booking.BuildDeliverySnapshot;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.cargo.RouteSpecification;
-
-/**
- * Route Specification Role Map
- *
- * Note that this is a Value Composite (and not an entity) capable of playing different Roles.
- */
-public interface RouteSpecificationRoleMap
-    extends ValueComposite,
-            RouteSpecification,
-            BuildDeliverySnapshot.FactoryRole
-{
-}

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/BookNewCargo.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/booking/BookNewCargo.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/booking/BookNewCargo.java
deleted file mode 100644
index d57593d..0000000
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/booking/BookNewCargo.java
+++ /dev/null
@@ -1,253 +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.LocalDate;
-import java.util.List;
-import org.apache.zest.api.common.Optional;
-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.value.ValueBuilder;
-import org.apache.zest.api.value.ValueBuilderFactory;
-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.cargo.Cargos;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.cargo.RouteSpecification;
-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.itinerary.Itinerary;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.location.Location;
-import org.apache.zest.sample.dcicargo.sample_a.infrastructure.dci.Context;
-import org.apache.zest.sample.dcicargo.sample_a.infrastructure.dci.RoleMixin;
-
-/**
- * Book New Cargo use case
- */
-public class BookNewCargo extends Context
-{
-    // ROLES ---------------------------------------------------------------------
-
-    // Methodful Roles
-    private CargoFactoryRole cargoFactory;
-    private RoutingFacadeRole routingFacade;
-
-    // Methodless Roles
-    private Location origin;
-    private Location destination;
-    private LocalDate arrivalDeadline;
-    private Itinerary itinerary;
-
-    // CONTEXT CONSTRUCTORS ------------------------------------------------------
-
-    public BookNewCargo( Cargos cargos,
-                         Location origin,
-                         Location destination,
-                         LocalDate arrivalDeadline
-    )
-        throws Exception
-    {
-        cargoFactory = rolePlayer( CargoFactoryRole.class, cargos );
-        this.origin = origin;
-        this.destination = destination;
-        this.arrivalDeadline = arrivalDeadline;
-    }
-
-    public BookNewCargo( Cargo cargo )
-    {
-        routingFacade = rolePlayer( RoutingFacadeRole.class, cargo );
-    }
-
-    public BookNewCargo( Cargo cargo, Itinerary itinerary )
-    {
-        routingFacade = rolePlayer( RoutingFacadeRole.class, cargo );
-        this.itinerary = itinerary;
-    }
-
-    // Constructor proxies for communication layer
-
-    public BookNewCargo( String originId, String destinationId, LocalDate deadline )
-        throws Exception
-    {
-        this( loadEntity( Cargos.class, Cargos.CARGOS_ID ),
-              loadEntity( Location.class, originId ),
-              loadEntity( Location.class, destinationId ),
-              deadline );
-    }
-
-    public BookNewCargo( String trackingIdString )
-    {
-        this( loadEntity( Cargo.class, trackingIdString ) );
-    }
-
-    public BookNewCargo( String trackingIdString, Itinerary itinerary )
-    {
-        this( loadEntity( Cargo.class, trackingIdString ), itinerary );
-    }
-
-    // INTERACTIONS --------------------------------------------------------------
-
-    public TrackingId book()
-    {
-        return cargoFactory.createCargo( null );
-    }
-
-    public TrackingId createCargo( String trackingIdString )
-    {
-        return cargoFactory.createCargo( trackingIdString );
-    }
-
-    public void changeDestination( String destination )
-    {
-        routingFacade.changeDestination( loadEntity( Location.class, destination ) );
-    }
-
-    public List<Itinerary> routeCandidates()
-        throws FoundNoRoutesException
-    {
-        return routingFacade.routeCandidates();
-    }
-
-    public void assignCargoToRoute()
-    {
-        routingFacade.assignCargoToRoute();
-    }
-
-    // METHODFUL ROLE IMPLEMENTATIONS --------------------------------------------
-
-    @Mixins( CargoFactoryRole.Mixin.class )
-    public interface CargoFactoryRole
-    {
-        void setContext( BookNewCargo context );
-
-        TrackingId createCargo( @Optional String trackingIdString );
-
-        class Mixin
-            extends RoleMixin<BookNewCargo>
-            implements CargoFactoryRole
-        {
-            @This
-            Cargos cargos;
-
-            public TrackingId createCargo( String trackingIdString )
-            {
-                // New route specification
-                RouteSpecification routeSpec = context.buildRouteSpecification(
-                    vbf, context.origin, context.destination, context.arrivalDeadline );
-
-                // Build delivery snapshot from route specification
-                Delivery delivery = new BuildDeliverySnapshot( routeSpec ).get();
-
-                // Create cargo
-                Cargo cargo = cargos.createCargo( routeSpec, delivery, trackingIdString );
-
-                return cargo.trackingId().get();
-            }
-        }
-    }
-
-    @Mixins( RoutingFacadeRole.Mixin.class )
-    public interface RoutingFacadeRole
-    {
-        void setContext( BookNewCargo context );
-
-        List<Itinerary> routeCandidates()
-            throws FoundNoRoutesException;
-
-        void assignCargoToRoute();
-
-        void changeDestination( Location destination );
-
-        class Mixin
-            extends RoleMixin<BookNewCargo>
-            implements RoutingFacadeRole
-        {
-            @This
-            Cargo cargo;
-
-            @Service
-            RoutingService routingService;
-
-            // Use case step 3 - system calculates possible routes
-            public List<Itinerary> routeCandidates()
-                throws FoundNoRoutesException  // Deviation 3a
-            {
-                return routingService.fetchRoutesForSpecification( cargo.routeSpecification().get() );
-            }
-
-            public void assignCargoToRoute()
-            {
-                cargo.itinerary().set( context.itinerary );
-
-                if( cargo.delivery().get().lastHandlingEvent().get() != null )
-                {
-                    // We treat subsequent route assignments as reroutes of misdirected cargo
-                    cargo.delivery().get().lastHandlingEvent().get().wasUnexpected().set( true );
-                }
-
-                // Build delivery snapshot with updated itinerary
-                cargo.delivery().set( new BuildDeliverySnapshot( cargo ).get() );
-            }
-
-            public void changeDestination( Location newDestination )
-            {
-                Location currentOrigin = cargo.routeSpecification().get().origin().get();
-                LocalDate currentDeadline = cargo.routeSpecification().get().arrivalDeadline().get();
-
-                RouteSpecification newRouteSpecification =
-                    context.buildRouteSpecification( vbf, currentOrigin, newDestination, currentDeadline );
-
-                cargo.routeSpecification().set( newRouteSpecification );
-
-                // Build new delivery snapshot with updated route specification
-                cargo.delivery().set( new BuildDeliverySnapshot( cargo ).get() );
-            }
-        }
-    }
-
-    public RouteSpecification buildRouteSpecification(
-        ValueBuilderFactory vbf, Location origin, Location destination, LocalDate deadline
-    )
-    {
-        if( origin == destination )
-        {
-            throw new RouteException( "Origin location can't be same as destination location." );
-        }
-
-        if( deadline == null )
-        {
-            throw new RouteException( "Arrival deadline cannot be null." );
-        }
-
-        if( !deadline.isAfter( LocalDate.now() ) )
-        {
-            throw new RouteException( "Arrival deadline is in the past or Today." +
-                                      "\nDeadline           " + deadline +
-                                      "\nToday (midnight)   " + LocalDate.now().atStartOfDay().plusDays( 1 ) );
-        }
-
-        ValueBuilder<RouteSpecification> routeSpec = vbf.newValueBuilder( RouteSpecification.class );
-        routeSpec.prototype().origin().set( origin );
-        routeSpec.prototype().destination().set( destination );
-        routeSpec.prototype().arrivalDeadline().set( deadline );
-        return routeSpec.newInstance();
-    }
-}
\ No newline at end of file


Mime
View raw message