Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id D652A200B4D for ; Sun, 12 Jun 2016 08:24:05 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id D5844160A34; Sun, 12 Jun 2016 06:24:05 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 5EEBD160A5F for ; Sun, 12 Jun 2016 08:24:03 +0200 (CEST) Received: (qmail 85438 invoked by uid 500); 12 Jun 2016 06:24:02 -0000 Mailing-List: contact commits-help@zest.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@zest.apache.org Delivered-To: mailing list commits@zest.apache.org Received: (qmail 85417 invoked by uid 99); 12 Jun 2016 06:24:02 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 12 Jun 2016 06:24:02 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 2DF10ED30B; Sun, 12 Jun 2016 06:24:02 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: niclas@apache.org To: commits@zest.apache.org Date: Sun, 12 Jun 2016 06:24:03 -0000 Message-Id: In-Reply-To: <8b4aae01b1084ae388404c4f2fdf06cf@git.apache.org> References: <8b4aae01b1084ae388404c4f2fdf06cf@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [2/7] zest-java git commit: ZEST-124 - Replaced Joda Time API with Java Time API, and I also removed the java.util.Date support and all uses except where required when interfacing with other systems. archived-at: Sun, 12 Jun 2016 06:24:06 -0000 http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/web/booking/CargoListPage.java ---------------------------------------------------------------------- diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/web/booking/CargoListPage.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/web/booking/CargoListPage.java index 741a12d..1d6b887 100644 --- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/web/booking/CargoListPage.java +++ b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/web/booking/CargoListPage.java @@ -19,8 +19,8 @@ */ package org.apache.zest.sample.dcicargo.sample_b.communication.web.booking; +import java.time.LocalDate; import java.util.ArrayList; -import java.util.Date; import java.util.List; import org.apache.wicket.Session; import org.apache.wicket.devutils.stateless.StatelessComponent; @@ -40,6 +40,8 @@ import org.apache.zest.sample.dcicargo.sample_b.infrastructure.wicket.color.Erro import org.apache.zest.sample.dcicargo.sample_b.infrastructure.wicket.link.LinkPanel; import org.apache.zest.sample.dcicargo.sample_b.infrastructure.wicket.prevnext.PrevNext; +import static java.time.ZoneOffset.UTC; +import static java.util.Date.from; import static org.apache.zest.sample.dcicargo.sample_b.data.structure.delivery.TransportStatus.UNKNOWN; import static org.apache.zest.sample.dcicargo.sample_b.data.structure.handling.HandlingEventType.CUSTOMS; @@ -74,7 +76,7 @@ public class CargoListPage extends BookingBasePage // Route specification RouteSpecification routeSpec = cargo.routeSpecification().get(); String destination = routeSpec.destination().get().getCode(); - Date deadline = routeSpec.arrivalDeadline().get(); + LocalDate deadline = routeSpec.arrivalDeadline().get(); // Routing status Delivery delivery = cargo.delivery().get(); @@ -98,9 +100,11 @@ public class CargoListPage extends BookingBasePage item.add( new Label( "destination", destination ) ); - item.add( new Label( "deadline", new Model( deadline ) ) ); + item.add( new Label( "deadline", + new Model<>( from( deadline.atStartOfDay().plusDays( 1 ).toInstant( UTC ) ) ) ) ); - item.add( new Label( "routingStatus", routingStatus.toString() ).add( new ErrorColor( isMisrouted ) ) ); + item.add( new Label( "routingStatus", + routingStatus.toString() ).add( new ErrorColor( isMisrouted ) ) ); String customsLabel = transportStatus.name() + ( inCustoms ? " (CUSTOMS)" : "" ); item.add( new Label( "transportStatus", customsLabel ).add( new ErrorColor( isHiJacked ) ) ); http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/web/booking/RoutePanel.java ---------------------------------------------------------------------- diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/web/booking/RoutePanel.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/web/booking/RoutePanel.java index 13da654..0ed3bb7 100644 --- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/web/booking/RoutePanel.java +++ b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/web/booking/RoutePanel.java @@ -19,7 +19,6 @@ */ package org.apache.zest.sample.dcicargo.sample_b.communication.web.booking; -import java.util.Date; import java.util.List; import org.apache.wicket.ajax.AjaxRequestTarget; import org.apache.wicket.ajax.markup.html.form.AjaxFallbackButton; @@ -38,6 +37,9 @@ import org.apache.zest.sample.dcicargo.sample_b.context.interaction.booking.rout import org.apache.zest.sample.dcicargo.sample_b.data.structure.itinerary.Itinerary; import org.apache.zest.sample.dcicargo.sample_b.data.structure.itinerary.Leg; +import static java.time.ZoneOffset.UTC; +import static java.util.Date.from; + /** * Route Panel * @@ -81,9 +83,11 @@ public class RoutePanel extends Panel Leg leg = item.getModelObject(); item.add( new Label( "voyage", leg.voyage().get().toString() ), new Label( "loadLocation", leg.loadLocation().get().getCode() ), - new Label( "loadTime", new Model( leg.loadTime().get() ) ), + new Label( "loadDate", + new Model<>( from( leg.loadDate().get().atStartOfDay().toInstant( UTC ) ) ) ), new Label( "unloadLocation", leg.unloadLocation().get().getCode() ), - new Label( "unloadTime", new Model( leg.unloadTime().get() ) ) + new Label( "unloadDate", + new Model<>( from( leg.unloadDate().get().atStartOfDay().toInstant( UTC ) ) ) ) ); } } ); http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/web/handling/IncidentLoggingApplicationMockupPage.java ---------------------------------------------------------------------- diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/web/handling/IncidentLoggingApplicationMockupPage.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/web/handling/IncidentLoggingApplicationMockupPage.java index 63a2a1a..9d3d753 100644 --- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/web/handling/IncidentLoggingApplicationMockupPage.java +++ b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/web/handling/IncidentLoggingApplicationMockupPage.java @@ -19,8 +19,9 @@ */ package org.apache.zest.sample.dcicargo.sample_b.communication.web.handling; -import java.text.SimpleDateFormat; -import java.util.Date; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; import org.apache.wicket.ajax.AjaxRequestTarget; import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior; import org.apache.wicket.ajax.markup.html.form.AjaxFallbackButton; @@ -32,8 +33,6 @@ 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.joda.time.DateTime; -import org.joda.time.LocalDate; import org.apache.zest.sample.dcicargo.sample_b.communication.query.CommonQueries; import org.apache.zest.sample.dcicargo.sample_b.communication.query.HandlingQueries; import org.apache.zest.sample.dcicargo.sample_b.communication.web.BasePage; @@ -83,7 +82,7 @@ public class IncidentLoggingApplicationMockupPage extends BasePage FeedbackPanel feedback; // Form values - Date completion; + LocalDateTime completion; String trackingId, unLocode, voyageNumber, eventType; // Input @@ -102,7 +101,7 @@ public class IncidentLoggingApplicationMockupPage extends BasePage // Completion time final DateTextFieldWithPicker completionDateInput = new DateTextFieldWithPicker( "completion", "Completion", this ); - completionDateInput.earliestDate( new LocalDate() ); + completionDateInput.earliestDate( LocalDate.now() ); add( completionDateInput.setLabel( Model.of( "Completion" ) ) ); HandlingQueries fetch = new HandlingQueries(); @@ -200,12 +199,11 @@ public class IncidentLoggingApplicationMockupPage extends BasePage // We simulate receiving raw text data from incident logging applications // Add current time to date to have same-dates in processing order (would register full time in real app) - Date adjustedCompletion = new Date( completion.getTime() + new DateTime().getMillisOfDay() ); - String completionTimeString = new SimpleDateFormat( "yyyy-MM-dd HH:mm" ).format( adjustedCompletion ); + String completionDateString = DateTimeFormatter.ofPattern( "yyyy-MM-dd HH:mm" ).format( completion ); // Parse "incoming" data (step 1 of ProcessHandlingEvent use case) tbf.newTransient( ProcessHandlingEvent.class ).parse( - completionTimeString, trackingId, eventType, unLocode, voyageNumber ); + completionDateString, trackingId, eventType, unLocode, voyageNumber ); /** * We could redirect to Details, but it's more fun to update details in a separate http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/web/tracking/HandlingHistoryPanel.java ---------------------------------------------------------------------- diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/web/tracking/HandlingHistoryPanel.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/web/tracking/HandlingHistoryPanel.java index 9558713..55d8935 100644 --- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/web/tracking/HandlingHistoryPanel.java +++ b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/web/tracking/HandlingHistoryPanel.java @@ -19,7 +19,7 @@ */ package org.apache.zest.sample.dcicargo.sample_b.communication.web.tracking; -import java.util.Date; +import java.time.ZoneOffset; import java.util.List; import org.apache.wicket.behavior.AttributeAppender; import org.apache.wicket.devutils.stateless.StatelessComponent; @@ -37,6 +37,8 @@ import org.apache.zest.sample.dcicargo.sample_b.communication.query.dto.CargoDTO import org.apache.zest.sample.dcicargo.sample_b.communication.query.dto.HandlingEventDTO; import org.apache.zest.sample.dcicargo.sample_b.infrastructure.wicket.color.ErrorColor; +import static java.util.Date.from; + /** * Handling history * @@ -67,7 +69,9 @@ public class HandlingHistoryPanel extends Panel item.add( new WebMarkupContainer( "onTrackIcon" ).add( new AttributeAppender( "src", iconName, "" ) ) ); // Date - item.add( new Label( "completion", new Model( event.completionTime().get() ) ) ); + item.add( new Label( "completion", new Model<>( + from( event.completionDate().get().atStartOfDay().toInstant( ZoneOffset.UTC ) ) ) + )); // Event description (data substitution in strings from HandlingHistoryPanel.properties) ValueMap map = new ValueMap(); @@ -77,7 +81,7 @@ public class HandlingHistoryPanel extends Panel { map.put( "voyage", event.voyage().get().voyageNumber().get().number().get() ); } - IModel text = new StringResourceModel( "handlingEvent.${type}", this, new Model( map ) ); + 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/37910017/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/web/tracking/NextHandlingEventPanel.java ---------------------------------------------------------------------- diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/web/tracking/NextHandlingEventPanel.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/web/tracking/NextHandlingEventPanel.java index accb896..1bc8c13 100644 --- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/web/tracking/NextHandlingEventPanel.java +++ b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/web/tracking/NextHandlingEventPanel.java @@ -19,7 +19,6 @@ */ package org.apache.zest.sample.dcicargo.sample_b.communication.web.tracking; -import java.text.SimpleDateFormat; import org.apache.wicket.AttributeModifier; import org.apache.wicket.devutils.stateless.StatelessComponent; import org.apache.wicket.markup.html.basic.Label; @@ -88,9 +87,9 @@ public class NextHandlingEventPanel extends Panel map.put( "nextEvent", nextEvent.handlingEventType().get().name() ); map.put( "location", nextEvent.location().get().getString() ); - if( nextEvent.time() != null ) + if( nextEvent.date() != null ) { - map.put( "time", new SimpleDateFormat( "yyyy-MM-dd" ).format( nextEvent.time().get() ) ); + map.put( "time", nextEvent.date().get().toString() ); } if( nextEvent.voyage().get() != null ) http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/web/tracking/TrackCargoPage.java ---------------------------------------------------------------------- diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/web/tracking/TrackCargoPage.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/web/tracking/TrackCargoPage.java index 9cae3ac..26f3c11 100644 --- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/web/tracking/TrackCargoPage.java +++ b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/web/tracking/TrackCargoPage.java @@ -19,8 +19,7 @@ */ package org.apache.zest.sample.dcicargo.sample_b.communication.web.tracking; -import java.text.SimpleDateFormat; -import java.util.Date; +import java.time.LocalDate; import java.util.List; import org.apache.wicket.ajax.AjaxRequestTarget; import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior; @@ -170,8 +169,8 @@ public class TrackCargoPage extends BasePage // ETA ---------------------------------------------------------------------- String destination = cargo.routeSpecification().get().destination().get().getString(); - Date eta = cargo.delivery().get().eta().get(); - String etaString = eta == null ? "?" : new SimpleDateFormat( "yyyy-MM-dd" ).format( eta ); + 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 ) ) ) ); http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/interaction/booking/BookNewCargo.java ---------------------------------------------------------------------- diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/interaction/booking/BookNewCargo.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/interaction/booking/BookNewCargo.java index 961a72e..bdbfd39 100644 --- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/interaction/booking/BookNewCargo.java +++ b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/interaction/booking/BookNewCargo.java @@ -19,7 +19,8 @@ */ package org.apache.zest.sample.dcicargo.sample_b.context.interaction.booking; -import java.util.Date; +import java.time.Instant; +import java.time.LocalDate; import org.apache.zest.api.common.Optional; import org.apache.zest.api.injection.scope.Service; import org.apache.zest.api.injection.scope.This; @@ -57,9 +58,9 @@ public class BookNewCargo extends Context private Location origin; private Location destination; - private Date arrivalDeadline; + private LocalDate arrivalDeadline; - public BookNewCargo( CargoFactory cargoFactory, Location origin, Location destination, Date arrivalDeadline ) + public BookNewCargo( CargoFactory cargoFactory, Location origin, Location destination, LocalDate arrivalDeadline ) throws Exception { bookingSystem = rolePlayer( BookingSystemRole.class, cargoFactory ); @@ -68,7 +69,7 @@ public class BookNewCargo extends Context this.arrivalDeadline = arrivalDeadline; } - public BookNewCargo( String originId, String destinationId, Date deadline ) + public BookNewCargo( String originId, String destinationId, LocalDate deadline ) throws Exception { this( loadEntity( CargoAggregateRoot.class, CargoAggregateRoot.CARGOS_ID ), @@ -110,14 +111,14 @@ public class BookNewCargo extends Context public TrackingId createCargo( String trackingIdString ) throws Exception { - Date earliestDeparture = new Date(); + LocalDate earliestDeparture = LocalDate.now(); RouteSpecification routeSpec = routeSpecFactory.build( c.origin, c.destination, earliestDeparture, c.arrivalDeadline ); ValueBuilder delivery = vbf.newValueBuilder( Delivery.class ); - delivery.prototype().timestamp().set( new Date() ); + delivery.prototype().timestamp().set( Instant.now() ); delivery.prototype().transportStatus().set( TransportStatus.NOT_RECEIVED ); delivery.prototype().routingStatus().set( RoutingStatus.NOT_ROUTED ); http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/interaction/booking/routing/AssignCargoToRoute.java ---------------------------------------------------------------------- diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/interaction/booking/routing/AssignCargoToRoute.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/interaction/booking/routing/AssignCargoToRoute.java index 341f25d..e3fd181 100644 --- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/interaction/booking/routing/AssignCargoToRoute.java +++ b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/interaction/booking/routing/AssignCargoToRoute.java @@ -19,7 +19,9 @@ */ package org.apache.zest.sample.dcicargo.sample_b.context.interaction.booking.routing; -import java.util.Date; +import java.time.Duration; +import java.time.Instant; +import java.time.LocalDate; import org.apache.zest.api.injection.scope.This; import org.apache.zest.api.mixin.Mixins; import org.apache.zest.api.value.ValueBuilder; @@ -41,8 +43,12 @@ import org.apache.zest.sample.dcicargo.sample_b.infrastructure.dci.Context; import org.apache.zest.sample.dcicargo.sample_b.infrastructure.dci.RoleMixin; import static org.apache.zest.sample.dcicargo.sample_b.data.structure.delivery.RoutingStatus.ROUTED; -import static org.apache.zest.sample.dcicargo.sample_b.data.structure.delivery.TransportStatus.*; -import static org.apache.zest.sample.dcicargo.sample_b.data.structure.handling.HandlingEventType.*; +import static org.apache.zest.sample.dcicargo.sample_b.data.structure.delivery.TransportStatus.CLAIMED; +import static org.apache.zest.sample.dcicargo.sample_b.data.structure.delivery.TransportStatus.NOT_RECEIVED; +import static org.apache.zest.sample.dcicargo.sample_b.data.structure.delivery.TransportStatus.ONBOARD_CARRIER; +import static org.apache.zest.sample.dcicargo.sample_b.data.structure.handling.HandlingEventType.LOAD; +import static org.apache.zest.sample.dcicargo.sample_b.data.structure.handling.HandlingEventType.RECEIVE; +import static org.apache.zest.sample.dcicargo.sample_b.data.structure.handling.HandlingEventType.UNLOAD; /** * Assign Cargo to Route (subfunction use case) @@ -54,13 +60,13 @@ import static org.apache.zest.sample.dcicargo.sample_b.data.structure.handling.H */ public class AssignCargoToRoute extends Context { - CargoInspectorRole cargoInspector; + private CargoInspectorRole cargoInspector; - RouteSpecification routeSpecification; - TransportStatus transportStatus; - HandlingEvent lastHandlingEvent; + private RouteSpecification routeSpecification; + private TransportStatus transportStatus; + private HandlingEvent lastHandlingEvent; - Itinerary itinerary; + private Itinerary itinerary; public AssignCargoToRoute( Cargo cargo, Itinerary itinerary ) { @@ -151,21 +157,18 @@ public class AssignCargoToRoute extends Context .get() ); // Estimate carrier arrival time - Date estimatedArrivalDate = carrierMovement.arrivalTime().get(); - if( c.lastHandlingEvent.completionTime().get().after( carrierMovement.departureTime().get() ) ) + LocalDate estimatedArrivalDate = carrierMovement.arrivalDate().get(); + if( c.lastHandlingEvent.completionDate().get().isAfter( carrierMovement.departureDate().get() ) ) { - long start = carrierMovement.departureTime().get().getTime(); - long end = carrierMovement.arrivalTime().get().getTime(); - long duration = end - start; - estimatedArrivalDate = new Date( c.lastHandlingEvent - .completionTime() - .get() - .getTime() + duration ); + LocalDate start = carrierMovement.departureDate().get(); + LocalDate end = carrierMovement.arrivalDate().get(); + Duration duration = Duration.between( start, end ); + estimatedArrivalDate = c.lastHandlingEvent.completionDate().get().plus(duration); } nextHandlingEvent.handlingEventType().set( UNLOAD ); nextHandlingEvent.location().set( carrierMovement.arrivalLocation().get() ); - nextHandlingEvent.time().set( estimatedArrivalDate ); + nextHandlingEvent.date().set( estimatedArrivalDate ); nextHandlingEvent.voyage().set( c.lastHandlingEvent.voyage().get() ); } else // IN_PORT @@ -173,7 +176,7 @@ public class AssignCargoToRoute extends Context // Re-routed cargo in port is expected to be loaded onto first carrier of new itinerary. nextHandlingEvent.handlingEventType().set( LOAD ); nextHandlingEvent.location().set( c.itinerary.firstLeg().loadLocation().get() ); - nextHandlingEvent.time().set( c.itinerary.firstLeg().loadTime().get() ); + nextHandlingEvent.date().set( c.itinerary.firstLeg().loadDate().get() ); nextHandlingEvent.voyage().set( c.itinerary.firstLeg().voyage().get() ); } @@ -181,7 +184,7 @@ public class AssignCargoToRoute extends Context ValueBuilder deliveryBuilder = vbf.newValueBuilder( Delivery.class ); newDelivery = deliveryBuilder.prototype(); - newDelivery.timestamp().set( new Date() ); + newDelivery.timestamp().set( Instant.now() ); newDelivery.lastHandlingEvent().set( c.lastHandlingEvent ); newDelivery.transportStatus().set( c.transportStatus ); newDelivery.isUnloadedAtDestination().set( false ); http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/interaction/booking/specification/DeriveUpdatedRouteSpecification.java ---------------------------------------------------------------------- diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/interaction/booking/specification/DeriveUpdatedRouteSpecification.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/interaction/booking/specification/DeriveUpdatedRouteSpecification.java index 48fd9fe..36be860 100644 --- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/interaction/booking/specification/DeriveUpdatedRouteSpecification.java +++ b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/interaction/booking/specification/DeriveUpdatedRouteSpecification.java @@ -19,7 +19,7 @@ */ package org.apache.zest.sample.dcicargo.sample_b.context.interaction.booking.specification; -import java.util.Date; +import java.time.LocalDate; import org.apache.zest.api.injection.scope.Service; import org.apache.zest.api.injection.scope.This; import org.apache.zest.api.mixin.Mixins; @@ -36,7 +36,9 @@ import org.apache.zest.sample.dcicargo.sample_b.data.structure.voyage.Voyage; import org.apache.zest.sample.dcicargo.sample_b.infrastructure.dci.Context; import org.apache.zest.sample.dcicargo.sample_b.infrastructure.dci.RoleMixin; -import static org.apache.zest.sample.dcicargo.sample_b.data.structure.delivery.TransportStatus.*; +import static org.apache.zest.sample.dcicargo.sample_b.data.structure.delivery.TransportStatus.CLAIMED; +import static org.apache.zest.sample.dcicargo.sample_b.data.structure.delivery.TransportStatus.NOT_RECEIVED; +import static org.apache.zest.sample.dcicargo.sample_b.data.structure.delivery.TransportStatus.ONBOARD_CARRIER; /** * Derive Updated Route Specification (subfunction use case) @@ -108,8 +110,8 @@ public class DeriveUpdatedRouteSpecification extends Context Location newOrigin; Location newDestination; - Date newEarliestDeparture; - Date newArrivalDeadline; + LocalDate newEarliestDeparture; + LocalDate newArrivalDeadline; public RouteSpecification getUpdatedRouteSpecification() throws CannotCreateRouteSpecificationException, UnexpectedCarrierException @@ -137,12 +139,12 @@ public class DeriveUpdatedRouteSpecification extends Context } newOrigin = carrierMovement.arrivalLocation().get(); - newEarliestDeparture = carrierMovement.arrivalTime().get(); + newEarliestDeparture = carrierMovement.arrivalDate().get(); } else { newOrigin = c.lastHandlingEvent.location().get(); - newEarliestDeparture = c.lastHandlingEvent.completionTime().get(); + newEarliestDeparture = c.lastHandlingEvent.completionDate().get(); } // Step 3 - Build and return new route specification http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/interaction/handling/inspection/event/InspectArrivedCargo.java ---------------------------------------------------------------------- diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/interaction/handling/inspection/event/InspectArrivedCargo.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/interaction/handling/inspection/event/InspectArrivedCargo.java index ea06290..699ba57 100644 --- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/interaction/handling/inspection/event/InspectArrivedCargo.java +++ b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/interaction/handling/inspection/event/InspectArrivedCargo.java @@ -19,7 +19,7 @@ */ package org.apache.zest.sample.dcicargo.sample_b.context.interaction.handling.inspection.event; -import java.util.Date; +import java.time.Instant; import org.apache.zest.api.injection.scope.This; import org.apache.zest.api.mixin.Mixins; import org.apache.zest.api.value.ValueBuilder; @@ -36,7 +36,9 @@ import org.apache.zest.sample.dcicargo.sample_b.data.structure.location.Location import org.apache.zest.sample.dcicargo.sample_b.infrastructure.dci.Context; import org.apache.zest.sample.dcicargo.sample_b.infrastructure.dci.RoleMixin; -import static org.apache.zest.sample.dcicargo.sample_b.data.structure.delivery.RoutingStatus.*; +import static org.apache.zest.sample.dcicargo.sample_b.data.structure.delivery.RoutingStatus.MISROUTED; +import static org.apache.zest.sample.dcicargo.sample_b.data.structure.delivery.RoutingStatus.NOT_ROUTED; +import static org.apache.zest.sample.dcicargo.sample_b.data.structure.delivery.RoutingStatus.ROUTED; import static org.apache.zest.sample.dcicargo.sample_b.data.structure.delivery.TransportStatus.IN_PORT; import static org.apache.zest.sample.dcicargo.sample_b.data.structure.handling.HandlingEventType.CLAIM; import static org.apache.zest.sample.dcicargo.sample_b.data.structure.handling.HandlingEventType.UNLOAD; @@ -48,16 +50,16 @@ import static org.apache.zest.sample.dcicargo.sample_b.data.structure.handling.H */ public class InspectArrivedCargo extends Context { - DeliveryInspectorRole deliveryInspector; + private DeliveryInspectorRole deliveryInspector; - HandlingEvent arrivalEvent; - Location arrivalLocation; + private HandlingEvent arrivalEvent; + private Location arrivalLocation; - RouteSpecification routeSpecification; - Location destination; + private RouteSpecification routeSpecification; + private Location destination; - Itinerary itinerary; - Integer itineraryProgressIndex; + private Itinerary itinerary; + private Integer itineraryProgressIndex; public InspectArrivedCargo( Cargo cargo, HandlingEvent handlingEvent ) { @@ -112,7 +114,7 @@ public class InspectArrivedCargo extends Context ValueBuilder newDeliveryBuilder = vbf.newValueBuilder( Delivery.class ); newDelivery = newDeliveryBuilder.prototype(); - newDelivery.timestamp().set( new Date() ); + newDelivery.timestamp().set( Instant.now() ); newDelivery.lastHandlingEvent().set( c.arrivalEvent ); newDelivery.transportStatus().set( IN_PORT ); @@ -146,7 +148,7 @@ public class InspectArrivedCargo extends Context ValueBuilder nextHandlingEvent = vbf.newValueBuilder( NextHandlingEvent.class ); nextHandlingEvent.prototype().handlingEventType().set( CLAIM ); nextHandlingEvent.prototype().location().set( c.arrivalLocation ); - nextHandlingEvent.prototype().time().set( c.arrivalEvent.completionTime().get() ); + nextHandlingEvent.prototype().date().set( c.arrivalEvent.completionDate().get() ); nextHandlingEvent.prototype().voyage().set( null ); newDelivery.nextHandlingEvent().set( nextHandlingEvent.newInstance() ); http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/interaction/handling/inspection/event/InspectCargoInCustoms.java ---------------------------------------------------------------------- diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/interaction/handling/inspection/event/InspectCargoInCustoms.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/interaction/handling/inspection/event/InspectCargoInCustoms.java index fc52fe8..7e68fb8 100644 --- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/interaction/handling/inspection/event/InspectCargoInCustoms.java +++ b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/interaction/handling/inspection/event/InspectCargoInCustoms.java @@ -19,7 +19,7 @@ */ package org.apache.zest.sample.dcicargo.sample_b.context.interaction.handling.inspection.event; -import java.util.Date; +import java.time.Instant; import org.apache.zest.api.injection.scope.This; import org.apache.zest.api.mixin.Mixins; import org.apache.zest.api.value.ValueBuilder; @@ -119,7 +119,7 @@ public class InspectCargoInCustoms extends Context ValueBuilder newDeliveryBuilder = vbf.newValueBuilder( Delivery.class ); newDelivery = newDeliveryBuilder.prototype(); - newDelivery.timestamp().set( new Date() ); + newDelivery.timestamp().set( Instant.now() ); newDelivery.lastHandlingEvent().set( c.customsEvent ); newDelivery.transportStatus().set( IN_PORT ); newDelivery.isUnloadedAtDestination().set( false ); http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/interaction/handling/inspection/event/InspectClaimedCargo.java ---------------------------------------------------------------------- diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/interaction/handling/inspection/event/InspectClaimedCargo.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/interaction/handling/inspection/event/InspectClaimedCargo.java index 1b0a128..0c91f0f 100644 --- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/interaction/handling/inspection/event/InspectClaimedCargo.java +++ b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/interaction/handling/inspection/event/InspectClaimedCargo.java @@ -19,7 +19,7 @@ */ package org.apache.zest.sample.dcicargo.sample_b.context.interaction.handling.inspection.event; -import java.util.Date; +import java.time.Instant; import org.apache.zest.api.injection.scope.This; import org.apache.zest.api.mixin.Mixins; import org.apache.zest.api.value.ValueBuilder; @@ -34,7 +34,9 @@ import org.apache.zest.sample.dcicargo.sample_b.data.structure.location.Location import org.apache.zest.sample.dcicargo.sample_b.infrastructure.dci.Context; import org.apache.zest.sample.dcicargo.sample_b.infrastructure.dci.RoleMixin; -import static org.apache.zest.sample.dcicargo.sample_b.data.structure.delivery.RoutingStatus.*; +import static org.apache.zest.sample.dcicargo.sample_b.data.structure.delivery.RoutingStatus.MISROUTED; +import static org.apache.zest.sample.dcicargo.sample_b.data.structure.delivery.RoutingStatus.NOT_ROUTED; +import static org.apache.zest.sample.dcicargo.sample_b.data.structure.delivery.RoutingStatus.ROUTED; import static org.apache.zest.sample.dcicargo.sample_b.data.structure.delivery.TransportStatus.CLAIMED; import static org.apache.zest.sample.dcicargo.sample_b.data.structure.handling.HandlingEventType.CLAIM; @@ -108,7 +110,7 @@ public class InspectClaimedCargo extends Context ValueBuilder newDeliveryBuilder = vbf.newValueBuilder( Delivery.class ); newDelivery = newDeliveryBuilder.prototype(); - newDelivery.timestamp().set( new Date() ); + newDelivery.timestamp().set( Instant.now() ); newDelivery.lastHandlingEvent().set( c.claimEvent ); newDelivery.transportStatus().set( CLAIMED ); newDelivery.isUnloadedAtDestination().set( false ); // Why not true if claimed in final destination? http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/interaction/handling/inspection/event/InspectLoadedCargo.java ---------------------------------------------------------------------- diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/interaction/handling/inspection/event/InspectLoadedCargo.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/interaction/handling/inspection/event/InspectLoadedCargo.java index 24259e9..090066c 100644 --- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/interaction/handling/inspection/event/InspectLoadedCargo.java +++ b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/interaction/handling/inspection/event/InspectLoadedCargo.java @@ -19,7 +19,10 @@ */ package org.apache.zest.sample.dcicargo.sample_b.context.interaction.handling.inspection.event; -import java.util.Date; +import java.time.Duration; +import java.time.Instant; +import java.time.LocalDate; +import java.time.Period; import java.util.Random; import org.apache.zest.api.injection.scope.This; import org.apache.zest.api.mixin.Mixins; @@ -65,16 +68,16 @@ import static org.apache.zest.sample.dcicargo.sample_b.data.structure.handling.H */ public class InspectLoadedCargo extends Context { - DeliveryInspectorRole deliveryInspector; + private DeliveryInspectorRole deliveryInspector; - HandlingEvent loadEvent; - Location loadLocation; - Voyage voyage; + private HandlingEvent loadEvent; + private Location loadLocation; + private Voyage voyage; - RouteSpecification routeSpecification; - Itinerary itinerary; - Integer itineraryProgressIndex; - RoutingStatus oldRoutingStatus; + private RouteSpecification routeSpecification; + private Itinerary itinerary; + private Integer itineraryProgressIndex; + private RoutingStatus oldRoutingStatus; public InspectLoadedCargo( Cargo cargo, HandlingEvent handlingEvent ) { @@ -126,7 +129,7 @@ public class InspectLoadedCargo extends Context ValueBuilder newDeliveryBuilder = vbf.newValueBuilder( Delivery.class ); newDelivery = newDeliveryBuilder.prototype(); - newDelivery.timestamp().set( new Date() ); + newDelivery.timestamp().set( Instant.now() ); newDelivery.lastHandlingEvent().set( c.loadEvent ); newDelivery.transportStatus().set( ONBOARD_CARRIER ); newDelivery.isUnloadedAtDestination().set( false ); @@ -146,20 +149,20 @@ public class InspectLoadedCargo extends Context } // Estimate carrier arrival time - Date estimatedArrivalDate = carrierMovement.arrivalTime().get(); - if( c.loadEvent.completionTime().get().after( carrierMovement.departureTime().get() ) ) + LocalDate estimatedArrivalDate = carrierMovement.arrivalDate().get(); + if( c.loadEvent.completionDate().get().isAfter( carrierMovement.departureDate().get() ) ) { - long start = carrierMovement.departureTime().get().getTime(); - long end = carrierMovement.arrivalTime().get().getTime(); - long duration = end - start; - estimatedArrivalDate = new Date( c.loadEvent.completionTime().get().getTime() + duration ); + LocalDate start = carrierMovement.departureDate().get(); + LocalDate end = carrierMovement.arrivalDate().get(); + Period duration = Period.between( start, end ); + estimatedArrivalDate = c.loadEvent.completionDate().get().plus( duration ); // ... We could notify cargo owner if we already now know that we will miss the next ship } ValueBuilder nextHandlingEvent = vbf.newValueBuilder( NextHandlingEvent.class ); nextHandlingEvent.prototype().handlingEventType().set( UNLOAD ); nextHandlingEvent.prototype().location().set( carrierMovement.arrivalLocation().get() ); - nextHandlingEvent.prototype().time().set( estimatedArrivalDate ); + nextHandlingEvent.prototype().date().set( estimatedArrivalDate ); nextHandlingEvent.prototype().voyage().set( c.voyage ); newDelivery.nextHandlingEvent().set( nextHandlingEvent.newInstance() ); @@ -205,8 +208,8 @@ public class InspectLoadedCargo extends Context cargo.delivery().set( newDeliveryBuilder.newInstance() ); throw new CargoMisdirectedException( c.loadEvent, "Itinerary expected load in " + plannedCarrierMovement.loadLocation() - .get() - .getString() ); + .get() + .getString() ); } // Unexpected carrier @@ -222,14 +225,14 @@ public class InspectLoadedCargo extends Context { throw new CargoMisdirectedException( c.loadEvent, c.itinerary, "Cargo is heading to expected arrival location " + plannedCarrierMovement.unloadLocation() - .get() + " but on unexpected voyage " + .get() + " but on unexpected voyage " + c.voyage - .toString() + ". Notify shipper to unload unexpected cargo in next port." ); + .toString() + ". Notify shipper to unload unexpected cargo in next port." ); } throw new CargoMisdirectedException( c.loadEvent, c.itinerary, "Itinerary expected load onto voyage " + plannedCarrierMovement.voyage() - .get() ); + .get() ); } // Unexpected carrier destination @@ -239,7 +242,7 @@ public class InspectLoadedCargo extends Context cargo.delivery().set( newDeliveryBuilder.newInstance() ); throw new CargoMisdirectedException( c.loadEvent, "Itinerary expects voyage " + c.voyage.toString() + " to arrive in " + plannedCarrierMovement.unloadLocation() - .get() + " but carrier is now going to " + .get() + " but carrier is now going to " + carrierMovement.arrivalLocation().get() ); } http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/interaction/handling/inspection/event/InspectReceivedCargo.java ---------------------------------------------------------------------- diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/interaction/handling/inspection/event/InspectReceivedCargo.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/interaction/handling/inspection/event/InspectReceivedCargo.java index 3fec057..ad18b66 100644 --- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/interaction/handling/inspection/event/InspectReceivedCargo.java +++ b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/interaction/handling/inspection/event/InspectReceivedCargo.java @@ -19,7 +19,7 @@ */ package org.apache.zest.sample.dcicargo.sample_b.context.interaction.handling.inspection.event; -import java.util.Date; +import java.time.Instant; import org.apache.zest.api.injection.scope.This; import org.apache.zest.api.mixin.Mixins; import org.apache.zest.api.value.ValueBuilder; @@ -38,7 +38,9 @@ import org.apache.zest.sample.dcicargo.sample_b.data.structure.voyage.Voyage; import org.apache.zest.sample.dcicargo.sample_b.infrastructure.dci.Context; import org.apache.zest.sample.dcicargo.sample_b.infrastructure.dci.RoleMixin; -import static org.apache.zest.sample.dcicargo.sample_b.data.structure.delivery.RoutingStatus.*; +import static org.apache.zest.sample.dcicargo.sample_b.data.structure.delivery.RoutingStatus.MISROUTED; +import static org.apache.zest.sample.dcicargo.sample_b.data.structure.delivery.RoutingStatus.NOT_ROUTED; +import static org.apache.zest.sample.dcicargo.sample_b.data.structure.delivery.RoutingStatus.ROUTED; import static org.apache.zest.sample.dcicargo.sample_b.data.structure.delivery.TransportStatus.IN_PORT; import static org.apache.zest.sample.dcicargo.sample_b.data.structure.handling.HandlingEventType.LOAD; import static org.apache.zest.sample.dcicargo.sample_b.data.structure.handling.HandlingEventType.RECEIVE; @@ -52,17 +54,17 @@ import static org.apache.zest.sample.dcicargo.sample_b.data.structure.handling.H */ public class InspectReceivedCargo extends Context { - DeliveryInspectorRole deliveryInspector; + private DeliveryInspectorRole deliveryInspector; - HandlingEvent previousEvent; + private HandlingEvent previousEvent; - HandlingEvent receiveEvent; - Location receiveLocation; - Voyage voyage; + private HandlingEvent receiveEvent; + private Location receiveLocation; + private Voyage voyage; - RouteSpecification routeSpecification; - Itinerary itinerary; - Integer itineraryProgressIndex; + private RouteSpecification routeSpecification; + private Itinerary itinerary; + private Integer itineraryProgressIndex; public InspectReceivedCargo( Cargo cargo, HandlingEvent handlingEvent ) { @@ -123,7 +125,7 @@ public class InspectReceivedCargo extends Context ValueBuilder newDeliveryBuilder = vbf.newValueBuilder( Delivery.class ); newDelivery = newDeliveryBuilder.prototype(); - newDelivery.timestamp().set( new Date() ); + newDelivery.timestamp().set( Instant.now() ); newDelivery.lastHandlingEvent().set( c.receiveEvent ); newDelivery.transportStatus().set( IN_PORT ); newDelivery.isUnloadedAtDestination().set( false ); @@ -155,8 +157,8 @@ public class InspectReceivedCargo extends Context cargo.delivery().set( newDeliveryBuilder.newInstance() ); throw new CargoMisdirectedException( c.receiveEvent, "Itinerary expected receipt in " + firstLeg.loadLocation() - .get() - .getString() ); + .get() + .getString() ); } newDelivery.isMisdirected().set( false ); @@ -167,7 +169,7 @@ public class InspectReceivedCargo extends Context ValueBuilder nextHandlingEvent = vbf.newValueBuilder( NextHandlingEvent.class ); nextHandlingEvent.prototype().handlingEventType().set( LOAD ); nextHandlingEvent.prototype().location().set( firstLeg.loadLocation().get() ); - nextHandlingEvent.prototype().time().set( firstLeg.loadTime().get() ); + nextHandlingEvent.prototype().date().set( firstLeg.loadDate().get() ); nextHandlingEvent.prototype().voyage().set( firstLeg.voyage().get() ); newDelivery.nextHandlingEvent().set( nextHandlingEvent.newInstance() ); } http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/interaction/handling/inspection/event/InspectUnhandledCargo.java ---------------------------------------------------------------------- diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/interaction/handling/inspection/event/InspectUnhandledCargo.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/interaction/handling/inspection/event/InspectUnhandledCargo.java index 6ad722d..69d8312 100644 --- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/interaction/handling/inspection/event/InspectUnhandledCargo.java +++ b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/interaction/handling/inspection/event/InspectUnhandledCargo.java @@ -19,7 +19,7 @@ */ package org.apache.zest.sample.dcicargo.sample_b.context.interaction.handling.inspection.event; -import java.util.Date; +import java.time.Instant; import org.apache.zest.api.injection.scope.This; import org.apache.zest.api.mixin.Mixins; import org.apache.zest.api.value.ValueBuilder; @@ -100,7 +100,7 @@ public class InspectUnhandledCargo extends Context ValueBuilder newDeliveryBuilder = vbf.newValueBuilder( Delivery.class ); newDelivery = newDeliveryBuilder.prototype(); - newDelivery.timestamp().set( new Date() ); + newDelivery.timestamp().set( Instant.now() ); newDelivery.lastHandlingEvent().set( null ); newDelivery.transportStatus().set( NOT_RECEIVED ); newDelivery.isUnloadedAtDestination().set( false ); @@ -132,7 +132,7 @@ public class InspectUnhandledCargo extends Context ValueBuilder nextHandlingEvent = vbf.newValueBuilder( NextHandlingEvent.class ); nextHandlingEvent.prototype().handlingEventType().set( RECEIVE ); nextHandlingEvent.prototype().location().set( cargo.origin().get() ); - nextHandlingEvent.prototype().time().set( null ); + nextHandlingEvent.prototype().date().set( null ); nextHandlingEvent.prototype().voyage().set( null ); newDelivery.nextHandlingEvent().set( nextHandlingEvent.newInstance() ); http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/interaction/handling/inspection/event/InspectUnloadedCargo.java ---------------------------------------------------------------------- diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/interaction/handling/inspection/event/InspectUnloadedCargo.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/interaction/handling/inspection/event/InspectUnloadedCargo.java index 1e5c221..22f9311 100644 --- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/interaction/handling/inspection/event/InspectUnloadedCargo.java +++ b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/interaction/handling/inspection/event/InspectUnloadedCargo.java @@ -19,7 +19,7 @@ */ package org.apache.zest.sample.dcicargo.sample_b.context.interaction.handling.inspection.event; -import java.util.Date; +import java.time.Instant; import org.apache.zest.api.injection.scope.This; import org.apache.zest.api.mixin.Mixins; import org.apache.zest.api.value.ValueBuilder; @@ -40,7 +40,9 @@ import org.apache.zest.sample.dcicargo.sample_b.data.structure.voyage.Voyage; import org.apache.zest.sample.dcicargo.sample_b.infrastructure.dci.Context; import org.apache.zest.sample.dcicargo.sample_b.infrastructure.dci.RoleMixin; -import static org.apache.zest.sample.dcicargo.sample_b.data.structure.delivery.RoutingStatus.*; +import static org.apache.zest.sample.dcicargo.sample_b.data.structure.delivery.RoutingStatus.MISROUTED; +import static org.apache.zest.sample.dcicargo.sample_b.data.structure.delivery.RoutingStatus.NOT_ROUTED; +import static org.apache.zest.sample.dcicargo.sample_b.data.structure.delivery.RoutingStatus.ROUTED; import static org.apache.zest.sample.dcicargo.sample_b.data.structure.delivery.TransportStatus.IN_PORT; import static org.apache.zest.sample.dcicargo.sample_b.data.structure.handling.HandlingEventType.LOAD; import static org.apache.zest.sample.dcicargo.sample_b.data.structure.handling.HandlingEventType.UNLOAD; @@ -52,17 +54,17 @@ import static org.apache.zest.sample.dcicargo.sample_b.data.structure.handling.H */ public class InspectUnloadedCargo extends Context { - DeliveryInspectorRole deliveryInspector; + private DeliveryInspectorRole deliveryInspector; - HandlingEvent unloadEvent; - Location unloadLocation; - Voyage voyage; + private HandlingEvent unloadEvent; + private Location unloadLocation; + private Voyage voyage; - RouteSpecification routeSpecification; - Location destination; - Itinerary itinerary; - Integer itineraryProgressIndex; - boolean wasMisdirected; + private RouteSpecification routeSpecification; + private Location destination; + private Itinerary itinerary; + private Integer itineraryProgressIndex; + private boolean wasMisdirected; public InspectUnloadedCargo( Cargo cargo, HandlingEvent handlingEvent ) { @@ -119,7 +121,7 @@ public class InspectUnloadedCargo extends Context ValueBuilder newDeliveryBuilder = vbf.newValueBuilder( Delivery.class ); newDelivery = newDeliveryBuilder.prototype(); - newDelivery.timestamp().set( new Date() ); + newDelivery.timestamp().set( Instant.now() ); newDelivery.lastHandlingEvent().set( c.unloadEvent ); newDelivery.transportStatus().set( IN_PORT ); newDelivery.isUnloadedAtDestination().set( false ); @@ -203,7 +205,7 @@ public class InspectUnloadedCargo extends Context ValueBuilder nextHandlingEvent = vbf.newValueBuilder( NextHandlingEvent.class ); nextHandlingEvent.prototype().handlingEventType().set( LOAD ); nextHandlingEvent.prototype().location().set( nextCarrierMovement.loadLocation().get() ); - nextHandlingEvent.prototype().time().set( nextCarrierMovement.loadTime().get() ); + nextHandlingEvent.prototype().date().set( nextCarrierMovement.loadDate().get() ); nextHandlingEvent.prototype().voyage().set( nextCarrierMovement.voyage().get() ); newDelivery.nextHandlingEvent().set( nextHandlingEvent.newInstance() ); http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/interaction/handling/parsing/ParseHandlingEventData.java ---------------------------------------------------------------------- diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/interaction/handling/parsing/ParseHandlingEventData.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/interaction/handling/parsing/ParseHandlingEventData.java index d45b6dd..5274dfd 100644 --- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/interaction/handling/parsing/ParseHandlingEventData.java +++ b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/interaction/handling/parsing/ParseHandlingEventData.java @@ -19,9 +19,10 @@ */ package org.apache.zest.sample.dcicargo.sample_b.context.interaction.handling.parsing; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Date; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.time.format.DateTimeParseException; import org.apache.zest.api.common.Optional; import org.apache.zest.api.injection.scope.Structure; import org.apache.zest.api.mixin.Mixins; @@ -70,7 +71,7 @@ public interface ParseHandlingEventData static final String ISO_8601_FORMAT = "yyyy-MM-dd HH:mm"; - Date completionTime; + LocalDate completionDate; HandlingEventType handlingEventType; public ParsedHandlingEventData parse( String completionStr, @@ -85,9 +86,9 @@ public interface ParseHandlingEventData try { - completionTime = new SimpleDateFormat( ISO_8601_FORMAT ).parse( completionStr.trim() ); + completionDate = LocalDate.parse( completionStr.trim(), DateTimeFormatter.ISO_LOCAL_DATE ); } - catch( ParseException e ) + catch( DateTimeParseException e ) { throw new InvalidHandlingEventDataException( "Invalid date format: '" + completionStr + "' must be on ISO 8601 format " + ISO_8601_FORMAT ); @@ -105,8 +106,8 @@ public interface ParseHandlingEventData // Step 4 - Collect parsed handling event data ValueBuilder parsedData = vbf.newValueBuilder( ParsedHandlingEventData.class ); - parsedData.prototype().registrationTime().set( new Date() ); - parsedData.prototype().completionTime().set( completionTime ); + parsedData.prototype().registrationDate().set( LocalDate.now() ); + parsedData.prototype().completionDate().set( completionDate ); parsedData.prototype().trackingIdString().set( trackingIdStr ); parsedData.prototype().handlingEventType().set( handlingEventType ); parsedData.prototype().unLocodeString().set( unLocodeStr ); http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/interaction/handling/parsing/dto/ParsedHandlingEventData.java ---------------------------------------------------------------------- diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/interaction/handling/parsing/dto/ParsedHandlingEventData.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/interaction/handling/parsing/dto/ParsedHandlingEventData.java index 8da96cd..ff1ef7a 100644 --- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/interaction/handling/parsing/dto/ParsedHandlingEventData.java +++ b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/interaction/handling/parsing/dto/ParsedHandlingEventData.java @@ -19,8 +19,7 @@ */ package org.apache.zest.sample.dcicargo.sample_b.context.interaction.handling.parsing.dto; -import java.text.SimpleDateFormat; -import java.util.Date; +import java.time.LocalDate; import org.apache.zest.api.common.Optional; import org.apache.zest.api.mixin.Mixins; import org.apache.zest.api.property.Immutable; @@ -35,9 +34,9 @@ import org.apache.zest.sample.dcicargo.sample_b.infrastructure.conversion.DTO; @Mixins( ParsedHandlingEventData.Mixin.class ) public interface ParsedHandlingEventData extends DTO { - Property registrationTime(); + Property registrationDate(); - Property completionTime(); + Property completionDate(); Property trackingIdString(); @@ -61,18 +60,14 @@ public interface ParsedHandlingEventData extends DTO voyage = voyageNumberString().get(); } - SimpleDateFormat date = new SimpleDateFormat( "yyyy-MM-dd" ); - - StringBuilder builder = new StringBuilder( "\nPARSED HANDLING EVENT DATA -----------------" ). - append( "\n Tracking id string " ).append( trackingIdString().get() ). - append( "\n Handling Event Type string " ).append( handlingEventType().get().name() ). - append( "\n UnLocode string " ).append( unLocodeString().get() ). - append( "\n Completed string " ).append( date.format( completionTime().get() ) ). - append( "\n Registered string " ).append( date.format( registrationTime().get() ) ). - append( "\n Voyage string " ).append( voyage ). - append( "\n--------------------------------------------\n" ); - - return builder.toString(); + return "\nPARSED HANDLING EVENT DATA -----------------" + + "\n Tracking id string " + trackingIdString().get() + + "\n Handling Event Type string " + handlingEventType().get().name() + + "\n UnLocode string " + unLocodeString().get() + + "\n Completed string " + completionDate().get() + + "\n Registered string " + registrationDate().get() + + "\n Voyage string " + voyage + + "\n--------------------------------------------\n"; } } } http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/interaction/handling/registration/RegisterHandlingEvent.java ---------------------------------------------------------------------- diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/interaction/handling/registration/RegisterHandlingEvent.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/interaction/handling/registration/RegisterHandlingEvent.java index 179176e..da83223 100644 --- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/interaction/handling/registration/RegisterHandlingEvent.java +++ b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/interaction/handling/registration/RegisterHandlingEvent.java @@ -208,8 +208,8 @@ public class RegisterHandlingEvent extends Context try { - return eventFactory.createHandlingEvent( c.eventData.registrationTime().get(), - c.eventData.completionTime().get(), + return eventFactory.createHandlingEvent( c.eventData.registrationDate().get(), + c.eventData.completionDate().get(), trackingId, c.eventData.handlingEventType().get(), location, http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/interaction/handling/registration/exception/CannotRegisterHandlingEventException.java ---------------------------------------------------------------------- diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/interaction/handling/registration/exception/CannotRegisterHandlingEventException.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/interaction/handling/registration/exception/CannotRegisterHandlingEventException.java index d1a1c00..4a3d905 100644 --- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/interaction/handling/registration/exception/CannotRegisterHandlingEventException.java +++ b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/interaction/handling/registration/exception/CannotRegisterHandlingEventException.java @@ -19,8 +19,9 @@ */ package org.apache.zest.sample.dcicargo.sample_b.context.interaction.handling.registration.exception; -import java.text.SimpleDateFormat; -import java.util.Date; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; import org.apache.zest.sample.dcicargo.sample_b.context.interaction.handling.parsing.dto.ParsedHandlingEventData; import org.apache.zest.sample.dcicargo.sample_b.data.structure.handling.HandlingEvent; @@ -43,7 +44,7 @@ public class CannotRegisterHandlingEventException extends Exception super(); this.parsedHandlingEventData = parsedHandlingEventData; - time = parseDate( parsedHandlingEventData.completionTime().get() ); + time = parseDate( parsedHandlingEventData.completionDate().get() ); id = parse( parsedHandlingEventData.trackingIdString().get() ); type = parse( parsedHandlingEventData.handlingEventType().get().name() ); unloc = parse( parsedHandlingEventData.unLocodeString().get() ); @@ -60,8 +61,8 @@ public class CannotRegisterHandlingEventException extends Exception return str == null ? "null" : str; } - private String parseDate( Date date ) + private String parseDate( LocalDate date ) { - return date == null ? "null" : new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss" ).format( date ); + return date == null ? "null" : date.toString(); } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/interaction/handling/registration/exception/ChronologicalException.java ---------------------------------------------------------------------- diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/interaction/handling/registration/exception/ChronologicalException.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/interaction/handling/registration/exception/ChronologicalException.java index 49e323c..7aaaf2d 100644 --- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/interaction/handling/registration/exception/ChronologicalException.java +++ b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/interaction/handling/registration/exception/ChronologicalException.java @@ -19,7 +19,7 @@ */ package org.apache.zest.sample.dcicargo.sample_b.context.interaction.handling.registration.exception; -import java.util.Date; +import java.time.LocalDate; import org.apache.zest.sample.dcicargo.sample_b.context.interaction.handling.parsing.dto.ParsedHandlingEventData; /** @@ -27,9 +27,9 @@ import org.apache.zest.sample.dcicargo.sample_b.context.interaction.handling.par */ public final class ChronologicalException extends CannotRegisterHandlingEventException { - Date lastCompletionTime; + private LocalDate lastCompletionTime; - public ChronologicalException( ParsedHandlingEventData parsedHandlingEventData, Date lastCompletionTime ) + public ChronologicalException( ParsedHandlingEventData parsedHandlingEventData, LocalDate lastCompletionTime ) { super( parsedHandlingEventData ); this.lastCompletionTime = lastCompletionTime; http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/service/routing/RoutingService.java ---------------------------------------------------------------------- diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/service/routing/RoutingService.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/service/routing/RoutingService.java index c78b106..037f00c 100644 --- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/service/routing/RoutingService.java +++ b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/service/routing/RoutingService.java @@ -20,11 +20,10 @@ package org.apache.zest.sample.dcicargo.sample_b.context.service.routing; import java.rmi.RemoteException; +import java.time.LocalDate; import java.util.ArrayList; import java.util.Collections; -import java.util.Date; import java.util.List; -import org.joda.time.LocalDate; import org.apache.zest.api.injection.scope.Service; import org.apache.zest.api.injection.scope.Structure; import org.apache.zest.api.mixin.Mixins; @@ -80,7 +79,7 @@ public interface RoutingService public List fetchRoutesForSpecification( RouteSpecification routeSpecification ) throws FoundNoRoutesException { - final Date departureDate = routeSpecification.earliestDeparture().get(); + final LocalDate departureDate = routeSpecification.earliestDeparture().get(); final Location origin = routeSpecification.origin().get(); final Location destination = routeSpecification.destination().get(); @@ -113,7 +112,7 @@ public interface RoutingService if( itineraries.size() == 0 ) { throw new FoundNoRoutesException( destination.name().get(), - new LocalDate( routeSpecification.arrivalDeadline().get() ) ); + routeSpecification.arrivalDeadline().get()); } return itineraries; @@ -141,8 +140,8 @@ public interface RoutingService leg.prototype().voyage().set( uow.get( Voyage.class, edge.getVoyageNumber() ) ); leg.prototype().loadLocation().set( uow.get( Location.class, edge.getFromUnLocode() ) ); leg.prototype().unloadLocation().set( uow.get( Location.class, edge.getToUnLocode() ) ); - leg.prototype().loadTime().set( edge.getFromDate() ); - leg.prototype().unloadTime().set( edge.getToDate() ); + leg.prototype().loadDate().set( edge.getFromDate() ); + leg.prototype().unloadDate().set( edge.getToDate() ); return leg.newInstance(); } http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/service/routing/exception/FoundNoRoutesException.java ---------------------------------------------------------------------- diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/service/routing/exception/FoundNoRoutesException.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/service/routing/exception/FoundNoRoutesException.java index ec5546c..1293ffe 100644 --- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/service/routing/exception/FoundNoRoutesException.java +++ b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/service/routing/exception/FoundNoRoutesException.java @@ -19,7 +19,7 @@ */ package org.apache.zest.sample.dcicargo.sample_b.context.service.routing.exception; -import org.joda.time.LocalDate; +import java.time.LocalDate; /** * Custom messages when the arrival deadline is too close and we can't find a route. @@ -38,17 +38,17 @@ public class FoundNoRoutesException extends Exception @Override public String getMessage() { - if( deadline.isBefore( new LocalDate().plusDays( 2 ) ) ) + if( deadline.isBefore( LocalDate.now().plusDays( 2 ) ) ) { return "Impossible to get the cargo to " + city + " before " + deadline + "! Make a new booking with a deadline 2-3 weeks ahead in time."; } - else if( deadline.isBefore( new LocalDate().plusDays( 4 ) ) ) + else if( deadline.isBefore( LocalDate.now().plusDays( 4 ) ) ) { return "Couldn't find any routes arriving in " + city + " before " + deadline + ". Please try again or make a new booking with a deadline 2-3 weeks ahead in time."; } - else if( deadline.isBefore( new LocalDate().plusDays( 6 ) ) ) + else if( deadline.isBefore( LocalDate.now().plusDays( 6 ) ) ) { return "Sorry, our system couldn't immediately find a route arriving in " + city + " before " + deadline + ". Please try again, and we should hopefully be able to find a new route for you."; http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/data/factory/HandlingEventFactory.java ---------------------------------------------------------------------- diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/data/factory/HandlingEventFactory.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/data/factory/HandlingEventFactory.java index 6525fe9..9168d4f 100644 --- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/data/factory/HandlingEventFactory.java +++ b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/data/factory/HandlingEventFactory.java @@ -19,7 +19,7 @@ */ package org.apache.zest.sample.dcicargo.sample_b.data.factory; -import java.util.Date; +import java.time.LocalDate; import org.apache.zest.api.common.Optional; import org.apache.zest.api.entity.EntityBuilder; import org.apache.zest.api.injection.scope.Structure; @@ -46,8 +46,8 @@ import org.apache.zest.sample.dcicargo.sample_b.data.structure.voyage.Voyage; @Mixins( HandlingEventFactory.Mixin.class ) public interface HandlingEventFactory { - HandlingEvent createHandlingEvent( Date registrationTime, - Date completionTime, + HandlingEvent createHandlingEvent( LocalDate registrationDate, + LocalDate completionDate, TrackingId trackingId, HandlingEventType handlingEventType, Location location, @@ -61,8 +61,8 @@ public interface HandlingEventFactory @Structure UnitOfWorkFactory uowf; - public HandlingEvent createHandlingEvent( Date registrationTime, - Date completionTime, + public HandlingEvent createHandlingEvent( LocalDate registrationDate, + LocalDate completionDate, TrackingId trackingId, HandlingEventType handlingEventType, Location location, @@ -82,8 +82,8 @@ public interface HandlingEventFactory UnitOfWork uow = uowf.currentUnitOfWork(); EntityBuilder handlingEventBuilder = uow.newEntityBuilder( HandlingEvent.class ); - handlingEventBuilder.instance().registrationTime().set( registrationTime ); - handlingEventBuilder.instance().completionTime().set( completionTime ); + handlingEventBuilder.instance().registrationDate().set( registrationDate ); + handlingEventBuilder.instance().completionDate().set( completionDate ); handlingEventBuilder.instance().trackingId().set( trackingId ); handlingEventBuilder.instance().handlingEventType().set( handlingEventType ); handlingEventBuilder.instance().location().set( location ); http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/data/factory/RouteSpecificationFactoryService.java ---------------------------------------------------------------------- diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/data/factory/RouteSpecificationFactoryService.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/data/factory/RouteSpecificationFactoryService.java index c7a12e8..00511fe 100644 --- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/data/factory/RouteSpecificationFactoryService.java +++ b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/data/factory/RouteSpecificationFactoryService.java @@ -19,8 +19,7 @@ */ package org.apache.zest.sample.dcicargo.sample_b.data.factory; -import java.util.Date; -import org.joda.time.DateMidnight; +import java.time.LocalDate; import org.apache.zest.api.injection.scope.Structure; import org.apache.zest.api.mixin.Mixins; import org.apache.zest.api.service.ServiceComposite; @@ -44,7 +43,7 @@ import org.apache.zest.sample.dcicargo.sample_b.data.structure.location.Location public interface RouteSpecificationFactoryService extends ServiceComposite { - RouteSpecification build( Location origin, Location destination, Date earliestDeparture, Date deadline ) + RouteSpecification build( Location origin, Location destination, LocalDate earliestDeparture, LocalDate deadline ) throws CannotCreateRouteSpecificationException; abstract class Mixin @@ -53,7 +52,11 @@ public interface RouteSpecificationFactoryService @Structure ValueBuilderFactory vbf; - public RouteSpecification build( Location origin, Location destination, Date earliestDeparture, Date deadline ) + public RouteSpecification build( Location origin, + Location destination, + LocalDate earliestDeparture, + LocalDate deadline + ) throws CannotCreateRouteSpecificationException { if( origin == destination ) @@ -61,15 +64,15 @@ public interface RouteSpecificationFactoryService throw new CannotCreateRouteSpecificationException( "Origin location can't be same as destination location." ); } - Date endOfToday = new DateMidnight().plusDays( 1 ).toDate(); - if( deadline.before( endOfToday ) ) + if( !deadline.isAfter( LocalDate.now() ) ) { - throw new CannotCreateRouteSpecificationException( "Arrival deadline is in the past or Today." + - "\nDeadline " + deadline + - "\nToday (midnight) " + endOfToday ); + throw new CannotCreateRouteSpecificationException( + "Arrival deadline is in the past or Today." + + "\nDeadline " + deadline + + "\nToday (midnight) " + LocalDate.now().atStartOfDay().plusDays( 1 ) ); } - if( deadline.before( earliestDeparture ) ) + if( !deadline.isAfter( earliestDeparture ) ) { throw new CannotCreateRouteSpecificationException( "Deadline can't be before departure:" + "\nDeparture " + earliestDeparture + http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/data/structure/cargo/RouteSpecification.java ---------------------------------------------------------------------- diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/data/structure/cargo/RouteSpecification.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/data/structure/cargo/RouteSpecification.java index a78e7e4..38fdb2a 100644 --- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/data/structure/cargo/RouteSpecification.java +++ b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/data/structure/cargo/RouteSpecification.java @@ -19,8 +19,7 @@ */ package org.apache.zest.sample.dcicargo.sample_b.data.structure.cargo; -import java.text.SimpleDateFormat; -import java.util.Date; +import java.time.LocalDate; import org.apache.zest.api.association.Association; import org.apache.zest.api.mixin.Mixins; import org.apache.zest.api.property.Property; @@ -60,9 +59,9 @@ public interface RouteSpecification Association destination(); - Property earliestDeparture(); + Property earliestDeparture(); - Property arrivalDeadline(); + Property arrivalDeadline(); // Side-effects free and UI agnostic convenience methods boolean isSatisfiedBy( Itinerary itinerary ); @@ -77,25 +76,21 @@ public interface RouteSpecification return itinerary != null && !itinerary.legs().get().isEmpty() && origin().get().equals( itinerary.firstLeg().loadLocation().get() ) && - earliestDeparture().get().before( itinerary.firstLeg().loadTime().get() ) && + earliestDeparture().get().isBefore( itinerary.firstLeg().loadDate().get() ) && destination().get().equals( itinerary.lastLeg().unloadLocation().get() ) && - arrivalDeadline().get().after( itinerary.eta() ); + arrivalDeadline().get().isAfter( itinerary.eta() ); } public String print() { - StringBuilder sb = new StringBuilder( - "\nROUTE SPECIFICATION ------------" ). - append( "\n Origin " ).append( origin().get() ). - append( "\n Destination " ).append( destination().get() ). - append( "\n Earliest departure " ) - .append( new SimpleDateFormat( "yyyy-MM-dd" ).format( earliestDeparture().get() ) ) - . - append( "\n Arrival deadline " ) - .append( new SimpleDateFormat( "yyyy-MM-dd" ).format( arrivalDeadline().get() ) ) - . - append( "\n--------------------------------" ); - return sb.toString(); + return "\nROUTE SPECIFICATION ------------" + + "\n Origin " + origin().get() + + "\n Destination " + destination().get() + + "\n Earliest departure " + + earliestDeparture().get() + + "\n Arrival deadline " + + arrivalDeadline().get() + + "\n--------------------------------"; } } } http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/data/structure/delivery/Delivery.java ---------------------------------------------------------------------- diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/data/structure/delivery/Delivery.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/data/structure/delivery/Delivery.java index 947302c..b32f62c 100644 --- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/data/structure/delivery/Delivery.java +++ b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/data/structure/delivery/Delivery.java @@ -19,7 +19,8 @@ */ package org.apache.zest.sample.dcicargo.sample_b.data.structure.delivery; -import java.util.Date; +import java.time.Instant; +import java.time.LocalDate; import org.apache.zest.api.association.Association; import org.apache.zest.api.common.Optional; import org.apache.zest.api.common.UseDefaults; @@ -93,7 +94,7 @@ import org.apache.zest.sample.dcicargo.sample_b.data.structure.itinerary.Itinera public interface Delivery extends ValueComposite { - Property timestamp(); + Property timestamp(); /* (types:) * RECEIVE @@ -128,7 +129,7 @@ public interface Delivery Property isMisdirected(); @Optional - Property eta(); + Property eta(); // Index of earliest uncompleted Itinerary Leg - bumped up after each unload (except at destination) @UseDefaults http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/data/structure/delivery/NextHandlingEvent.java ---------------------------------------------------------------------- diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/data/structure/delivery/NextHandlingEvent.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/data/structure/delivery/NextHandlingEvent.java index b5819f2..703976f 100644 --- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/data/structure/delivery/NextHandlingEvent.java +++ b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/data/structure/delivery/NextHandlingEvent.java @@ -19,7 +19,7 @@ */ package org.apache.zest.sample.dcicargo.sample_b.data.structure.delivery; -import java.util.Date; +import java.time.LocalDate; import org.apache.zest.api.association.Association; import org.apache.zest.api.common.Optional; import org.apache.zest.api.property.Property; @@ -49,7 +49,7 @@ public interface NextHandlingEvent Association location(); @Optional - Property time(); + Property date(); @Optional Association voyage();