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 D21FB200B4A for ; Sun, 12 Jun 2016 08:24:05 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id CFF0B160A60; 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 581D9160A56 for ; Sun, 12 Jun 2016 08:24:03 +0200 (CEST) Received: (qmail 85514 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 85436 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 3937DED30D; 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:05 -0000 Message-Id: <9f8cca622c8443d990425c687d65c910@git.apache.org> In-Reply-To: <8b4aae01b1084ae388404c4f2fdf06cf@git.apache.org> References: <8b4aae01b1084ae388404c4f2fdf06cf@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [4/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_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/bootstrap/DCISampleApplication_a.java ---------------------------------------------------------------------- diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/bootstrap/DCISampleApplication_a.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/bootstrap/DCISampleApplication_a.java index ca00646..acc980a 100644 --- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/bootstrap/DCISampleApplication_a.java +++ b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/bootstrap/DCISampleApplication_a.java @@ -19,7 +19,6 @@ */ package org.apache.zest.sample.dcicargo.sample_a.bootstrap; -import java.util.Date; import org.apache.wicket.ConverterLocator; import org.apache.wicket.Page; import org.apache.wicket.datetime.PatternDateConverter; @@ -44,20 +43,21 @@ public class DCISampleApplication_a { public void wicketInit() { - // Tabs and SEO urls + // Tabs and SEO urls. mountPages(); - // Show/hide Ajax debugging + // Show/hide Ajax debugging. getDebugSettings().setDevelopmentUtilitiesEnabled( true ); - // Check that components are stateless when required + // Check that components are stateless when required. getComponentPostOnBeforeRenderListeners().add( new StatelessChecker() ); - // Show/hide wicket tags in html code + // Show/hide wicket tags in html code. getMarkupSettings().setStripWicketTags( true ); // Default date format (we don't care for now about the hour of the day) - ( (ConverterLocator) getConverterLocator() ).set( Date.class, new PatternDateConverter( "yyyy-MM-dd", true ) ); + ( (ConverterLocator) getConverterLocator() ).set( java.util.Date.class, + new PatternDateConverter( "yyyy-MM-dd", true ) ); } private void mountPages() http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/bootstrap/sampledata/BaseData.java ---------------------------------------------------------------------- diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/bootstrap/sampledata/BaseData.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/bootstrap/sampledata/BaseData.java index 3e7daca..8575a69 100644 --- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/bootstrap/sampledata/BaseData.java +++ b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/bootstrap/sampledata/BaseData.java @@ -19,11 +19,10 @@ */ package org.apache.zest.sample.dcicargo.sample_a.bootstrap.sampledata; +import java.time.LocalDate; import java.util.ArrayList; import java.util.Arrays; -import java.util.Date; import java.util.List; -import org.joda.time.LocalDate; import org.apache.zest.api.structure.Module; import org.apache.zest.api.value.ValueBuilder; import org.apache.zest.sample.dcicargo.sample_a.data.shipping.cargo.RouteSpecification; @@ -68,33 +67,33 @@ public abstract class BaseData return unlocode.newInstance(); } - protected CarrierMovement carrierMovement( Location depLoc, Location arrLoc, Date depTime, Date arrTime ) + protected CarrierMovement carrierMovement( Location depLoc, Location arrLoc, LocalDate depDate, LocalDate arrDate ) { ValueBuilder carrierMovement = module.newValueBuilder( CarrierMovement.class ); carrierMovement.prototype().departureLocation().set( depLoc ); carrierMovement.prototype().arrivalLocation().set( arrLoc ); - carrierMovement.prototype().departureTime().set( depTime ); - carrierMovement.prototype().arrivalTime().set( arrTime ); + carrierMovement.prototype().departureDate().set( depDate ); + carrierMovement.prototype().arrivalDate().set( arrDate ); return carrierMovement.newInstance(); } protected Schedule schedule( CarrierMovement... carrierMovements ) { ValueBuilder schedule = module.newValueBuilder( Schedule.class ); - List cm = new ArrayList(); + List cm = new ArrayList<>(); cm.addAll( Arrays.asList( carrierMovements ) ); schedule.prototype().carrierMovements().set( cm ); return schedule.newInstance(); } - protected Leg leg( Voyage voyage, Location load, Location unload, Date loadTime, Date unloadTime ) + protected Leg leg( Voyage voyage, Location load, Location unload, LocalDate loadDate, LocalDate unloadDate ) { ValueBuilder leg = module.newValueBuilder( Leg.class ); leg.prototype().voyage().set( voyage ); leg.prototype().loadLocation().set( load ); leg.prototype().unloadLocation().set( unload ); - leg.prototype().loadTime().set( loadTime ); - leg.prototype().unloadTime().set( unloadTime ); + leg.prototype().loadDate().set( loadDate ); + leg.prototype().unloadDate().set( unloadDate ); return leg.newInstance(); } @@ -107,7 +106,7 @@ public abstract class BaseData return itinerary.newInstance(); } - protected RouteSpecification routeSpecification( Location origin, Location destination, Date deadline ) + protected RouteSpecification routeSpecification( Location origin, Location destination, LocalDate deadline ) { ValueBuilder routeSpec = module.newValueBuilder( RouteSpecification.class ); routeSpec.prototype().origin().set( origin ); @@ -116,8 +115,8 @@ public abstract class BaseData return routeSpec.newInstance(); } - protected static Date day( int days ) + protected static LocalDate day( int days ) { - return LocalDate.now().plusDays( days ).toDate(); + return LocalDate.now().plusDays( days ); } } http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/bootstrap/sampledata/BaseDataService.java ---------------------------------------------------------------------- diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/bootstrap/sampledata/BaseDataService.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/bootstrap/sampledata/BaseDataService.java index f8241fe..c4d6ede 100644 --- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/bootstrap/sampledata/BaseDataService.java +++ b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/bootstrap/sampledata/BaseDataService.java @@ -50,20 +50,19 @@ public interface BaseDataService extends ServiceComposite { - void createBaseData() - throws Exception; + void createBaseData() + throws Exception; class Activator - extends ActivatorAdapter> + extends ActivatorAdapter> { @Override public void afterActivation( ServiceReference activated ) - throws Exception + throws Exception { activated.get().createBaseData(); } - } public abstract class Mixin extends BaseData @@ -78,28 +77,28 @@ public interface BaseDataService @Override public void createBaseData() - throws Exception + throws Exception { logger.debug( "CREATING BASIC DATA..." ); UnitOfWork uow = module.unitOfWorkFactory().newUnitOfWork( newUsecase( "Open uow for " ) ); try { - // UnLocode value objects - AUMEL = unlocode( "AUMEL" ); // Melbourne - CNHGH = unlocode( "CNHGH" ); // Hangzou - CNHKG = unlocode( "CNHKG" ); // Hong Kong - CNSHA = unlocode( "CNSHA" ); // Shanghai - DEHAM = unlocode( "DEHAM" ); // Hamburg - FIHEL = unlocode( "FIHEL" ); // Helsinki - JNTKO = unlocode( "JNTKO" ); // Tokyo - NLRTM = unlocode( "NLRTM" ); // Rotterdam - SEGOT = unlocode( "SEGOT" ); // Gothenburg - SESTO = unlocode( "SESTO" ); // Stockholm - USCHI = unlocode( "USCHI" ); // Chicago - USDAL = unlocode( "USDAL" ); // Dallas - USNYC = unlocode( "USNYC" ); // New York - - // Location entity objects + // UnLocode value objects + AUMEL = unlocode( "AUMEL" ); // Melbourne + CNHGH = unlocode( "CNHGH" ); // Hangzou + CNHKG = unlocode( "CNHKG" ); // Hong Kong + CNSHA = unlocode( "CNSHA" ); // Shanghai + DEHAM = unlocode( "DEHAM" ); // Hamburg + FIHEL = unlocode( "FIHEL" ); // Helsinki + JNTKO = unlocode( "JNTKO" ); // Tokyo + NLRTM = unlocode( "NLRTM" ); // Rotterdam + SEGOT = unlocode( "SEGOT" ); // Gothenburg + SESTO = unlocode( "SESTO" ); // Stockholm + USCHI = unlocode( "USCHI" ); // Chicago + USDAL = unlocode( "USDAL" ); // Dallas + USNYC = unlocode( "USNYC" ); // New York + + // Location entity objects Location MELBOURNE = location( AUMEL, "Melbourne" ); Location HANGZHOU = location( CNHGH, "Hangzhou" ); Location HONGKONG = location( CNHKG, "Hongkong" ); @@ -114,43 +113,43 @@ public interface BaseDataService Location DALLAS = location( USDAL, "Dallas" ); Location NEWYORK = location( USNYC, "New York" ); - // Voyage entity objects + // Voyage entity objects Voyage V100S = voyage( "V100S", schedule( - carrierMovement( NEWYORK, CHICAGO, day( 1 ), day( 2 ) ), - carrierMovement( CHICAGO, DALLAS, day( 8 ), day( 9 ) ) - ) ); + carrierMovement( NEWYORK, CHICAGO, day( 1 ), day( 2 ) ), + carrierMovement( CHICAGO, DALLAS, day( 8 ), day( 9 ) ) + ) ); Voyage V200T = voyage( "V200T", schedule( - carrierMovement( NEWYORK, CHICAGO, day( 7 ), day( 8 ) ), - carrierMovement( CHICAGO, DALLAS, day( 8 ), day( 9 ) ) - ) ); + carrierMovement( NEWYORK, CHICAGO, day( 7 ), day( 8 ) ), + carrierMovement( CHICAGO, DALLAS, day( 8 ), day( 9 ) ) + ) ); Voyage V300A = voyage( "V300A", schedule( - carrierMovement( DALLAS, HAMBURG, day( 10 ), day( 14 ) ), - carrierMovement( HAMBURG, STOCKHOLM, day( 15 ), day( 16 ) ), - carrierMovement( STOCKHOLM, HELSINKI, day( 17 ), day( 18 ) ) - ) ); + carrierMovement( DALLAS, HAMBURG, day( 10 ), day( 14 ) ), + carrierMovement( HAMBURG, STOCKHOLM, day( 15 ), day( 16 ) ), + carrierMovement( STOCKHOLM, HELSINKI, day( 17 ), day( 18 ) ) + ) ); Voyage V400S = voyage( "V400S", schedule( - carrierMovement( TOKYO, ROTTERDAM, day( 9 ), day( 15 ) ), - carrierMovement( ROTTERDAM, HAMBURG, day( 15 ), day( 16 ) ), - carrierMovement( HAMBURG, MELBOURNE, day( 17 ), day( 26 ) ), - carrierMovement( MELBOURNE, TOKYO, day( 27 ), day( 33 ) ) - ) ); + carrierMovement( TOKYO, ROTTERDAM, day( 9 ), day( 15 ) ), + carrierMovement( ROTTERDAM, HAMBURG, day( 15 ), day( 16 ) ), + carrierMovement( HAMBURG, MELBOURNE, day( 17 ), day( 26 ) ), + carrierMovement( MELBOURNE, TOKYO, day( 27 ), day( 33 ) ) + ) ); Voyage V500S = voyage( "V500S", schedule( - carrierMovement( HAMBURG, STOCKHOLM, day( 17 ), day( 19 ) ), - carrierMovement( STOCKHOLM, HELSINKI, day( 20 ), day( 21 ) ) - ) ); + carrierMovement( HAMBURG, STOCKHOLM, day( 17 ), day( 19 ) ), + carrierMovement( STOCKHOLM, HELSINKI, day( 20 ), day( 21 ) ) + ) ); - // Cargo and HandlingEvent factories + // Cargo and HandlingEvent factories CargosEntity CARGOS = uow.newEntity( CargosEntity.class, CargosEntity.CARGOS_ID ); uow.newEntity( HandlingEventsEntity.class, HandlingEventsEntity.HANDLING_EVENTS_ID ); - - logger.debug( "BASIC DATA CREATED" ); - uow.complete(); + + logger.debug( "BASIC DATA CREATED" ); + uow.complete(); } - catch(Exception e) + catch( Exception e ) { - uow.discard(); - logger.error("CANNOT CREATE BASIC DATA"); - throw e; + uow.discard(); + logger.error( "CANNOT CREATE BASIC DATA" ); + throw e; } } @@ -177,6 +176,5 @@ public interface BaseDataService voyage.instance().schedule().set( schedule ); return voyage.newInstance(); } - } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/bootstrap/sampledata/SampleDataService.java ---------------------------------------------------------------------- diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/bootstrap/sampledata/SampleDataService.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/bootstrap/sampledata/SampleDataService.java index cfab52e..da00cea 100644 --- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/bootstrap/sampledata/SampleDataService.java +++ b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/bootstrap/sampledata/SampleDataService.java @@ -19,13 +19,12 @@ */ package org.apache.zest.sample.dcicargo.sample_a.bootstrap.sampledata; +import java.time.LocalDate; +import java.time.LocalDateTime; import java.util.ArrayList; -import java.util.Date; import java.util.List; import java.util.Random; import java.util.UUID; -import org.joda.time.LocalDate; -import org.joda.time.LocalTime; import org.apache.zest.api.activation.ActivatorAdapter; import org.apache.zest.api.activation.Activators; import org.apache.zest.api.injection.scope.Service; @@ -79,7 +78,7 @@ public interface SampleDataService } - public abstract class Mixin + abstract class Mixin implements SampleDataService { @Structure @@ -114,7 +113,7 @@ public interface SampleDataService { String trackingId = cargo.trackingId().get().id().get(); ExpectedHandlingEvent nextEvent; - Date time; + LocalDate date; String port; String voyage; HandlingEventType type; @@ -133,7 +132,7 @@ public interface SampleDataService { nextEvent = cargo.delivery().get().nextExpectedHandlingEvent().get(); port = nextEvent.location().get().getCode(); - Date mockTime = new Date(); + LocalDate mockTime = LocalDate.now(); new RegisterHandlingEvent( mockTime, mockTime, trackingId, "RECEIVE", port, null ).register(); } @@ -141,38 +140,38 @@ public interface SampleDataService if( i > 13 ) { nextEvent = cargo.delivery().get().nextExpectedHandlingEvent().get(); - time = nextEvent.time().get(); + date = nextEvent.date().get(); port = nextEvent.location().get().getCode(); voyage = nextEvent.voyage().get().voyageNumber().get().number().get(); - new RegisterHandlingEvent( time, time, trackingId, "LOAD", port, voyage ).register(); + new RegisterHandlingEvent( date, date, trackingId, "LOAD", port, voyage ).register(); } // UNLOAD if( i > 14 ) { nextEvent = cargo.delivery().get().nextExpectedHandlingEvent().get(); - time = nextEvent.time().get(); + date = nextEvent.date().get(); port = nextEvent.location().get().getCode(); voyage = nextEvent.voyage().get().voyageNumber().get().number().get(); - new RegisterHandlingEvent( time, time, trackingId, "UNLOAD", port, voyage ).register(); + new RegisterHandlingEvent( date, date, trackingId, "UNLOAD", port, voyage ).register(); } // Cargo is now in port nextEvent = cargo.delivery().get().nextExpectedHandlingEvent().get(); - time = nextEvent.time().get(); + date = nextEvent.date().get(); port = nextEvent.location().get().getCode(); type = nextEvent.handlingEventType().get(); // MISDIRECTED: Unexpected customs handling before reaching destination if( i == 16 ) { - new RegisterHandlingEvent( time, time, trackingId, "CUSTOMS", port, null ).register(); + new RegisterHandlingEvent( date, date, trackingId, "CUSTOMS", port, null ).register(); } // MISDIRECTED: Unexpected claim before reaching destination if( i == 17 ) { - new RegisterHandlingEvent( time, time, trackingId, "CLAIM", port, null ).register(); + new RegisterHandlingEvent( date, date, trackingId, "CLAIM", port, null ).register(); } // MISDIRECTED: LOAD in wrong port @@ -180,7 +179,7 @@ public interface SampleDataService { String wrongPort = port.equals( "USDAL" ) ? "USCHI" : "USDAL"; voyage = nextEvent.voyage().get().voyageNumber().get().number().get(); - new RegisterHandlingEvent( time, time, trackingId, "LOAD", wrongPort, voyage ).register(); + new RegisterHandlingEvent( date, date, trackingId, "LOAD", wrongPort, voyage ).register(); } // MISDIRECTED: LOAD onto wrong carrier @@ -188,7 +187,7 @@ public interface SampleDataService { voyage = nextEvent.voyage().get().voyageNumber().get().number().get(); String wrongVoyage = voyage.equals( "V100S" ) ? "V200T" : "V100S"; - new RegisterHandlingEvent( time, time, trackingId, "LOAD", port, wrongVoyage ).register(); + new RegisterHandlingEvent( date, date, trackingId, "LOAD", port, wrongVoyage ).register(); } // MISDIRECTED: LOAD onto wrong carrier in wrong port @@ -197,7 +196,7 @@ public interface SampleDataService String wrongPort = port.equals( "USDAL" ) ? "USCHI" : "USDAL"; voyage = nextEvent.voyage().get().voyageNumber().get().number().get(); String wrongVoyage = voyage.equals( "V100S" ) ? "V200T" : "V100S"; - new RegisterHandlingEvent( time, time, trackingId, "LOAD", wrongPort, wrongVoyage ).register(); + new RegisterHandlingEvent( date, date, trackingId, "LOAD", wrongPort, wrongVoyage ).register(); } // MISDIRECTED: UNLOAD in wrong port @@ -205,7 +204,7 @@ public interface SampleDataService { String wrongPort = port.equals( "USDAL" ) ? "USCHI" : "USDAL"; voyage = nextEvent.voyage().get().voyageNumber().get().number().get(); - new RegisterHandlingEvent( time, time, trackingId, "UNLOAD", wrongPort, voyage ).register(); + new RegisterHandlingEvent( date, date, trackingId, "UNLOAD", wrongPort, voyage ).register(); } // MISDIRECTED: UNLOAD from wrong carrier @@ -213,7 +212,7 @@ public interface SampleDataService { voyage = nextEvent.voyage().get().voyageNumber().get().number().get(); String wrongVoyage = voyage.equals( "V100S" ) ? "V200T" : "V100S"; - new RegisterHandlingEvent( time, time, trackingId, "UNLOAD", port, wrongVoyage ).register(); + new RegisterHandlingEvent( date, date, trackingId, "UNLOAD", port, wrongVoyage ).register(); } // MISDIRECTED: UNLOAD from wrong carrier in wrong port @@ -222,7 +221,7 @@ public interface SampleDataService String wrongPort = port.equals( "USDAL" ) ? "USCHI" : "USDAL"; voyage = nextEvent.voyage().get().voyageNumber().get().number().get(); String wrongVoyage = voyage.equals( "V100S" ) ? "V200T" : "V100S"; - new RegisterHandlingEvent( time, time, trackingId, "UNLOAD", wrongPort, wrongVoyage ).register(); + new RegisterHandlingEvent( date, date, trackingId, "UNLOAD", wrongPort, wrongVoyage ).register(); } // Complete all LOAD/UNLOADS @@ -231,10 +230,10 @@ public interface SampleDataService do { voyage = nextEvent.voyage().get().voyageNumber().get().number().get(); - new RegisterHandlingEvent( time, time, trackingId, type.name(), port, voyage ).register(); + new RegisterHandlingEvent( date, date, trackingId, type.name(), port, voyage ).register(); nextEvent = cargo.delivery().get().nextExpectedHandlingEvent().get(); - time = nextEvent.time().get(); + date = nextEvent.date().get(); port = nextEvent.location().get().getCode(); type = nextEvent.handlingEventType().get(); } @@ -244,7 +243,7 @@ public interface SampleDataService // CLAIM at destination - this ends the life cycle of the cargo delivery if( i == 25 ) { - new RegisterHandlingEvent( time, time, trackingId, "CLAIM", port, null ).register(); + new RegisterHandlingEvent( date, date, trackingId, "CLAIM", port, null ).register(); } // Add more cases if needed... @@ -285,7 +284,7 @@ public interface SampleDataService Location origin; Location destination; Random random = new Random(); - Date deadline; + LocalDate deadline; String uuid; String id; try @@ -301,9 +300,7 @@ public interface SampleDataService } while( destination.equals( origin ) ); - deadline = new LocalDate().plusDays( 15 + random.nextInt( 10 ) ) - .toDateTime( new LocalTime() ) - .toDate(); + deadline = LocalDate.now().plusDays( 15 + random.nextInt( 10 ) ); // Build sortable random tracking ids uuid = UUID.randomUUID().toString().toUpperCase(); http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/query/TrackingQueries.java ---------------------------------------------------------------------- diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/query/TrackingQueries.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/query/TrackingQueries.java index 8a88022..7685f77 100644 --- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/query/TrackingQueries.java +++ b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/query/TrackingQueries.java @@ -71,7 +71,7 @@ public class TrackingQueries extends Queries QueryBuilder qb = qbf.newQueryBuilder( HandlingEventEntity.class ) .where( QueryExpressions.eq( eventTemplate.trackingId().get().id(), trackingIdString ) ); return uowf.currentUnitOfWork().newQuery( qb ) - .orderBy( orderBy( eventTemplate.completionTime() ) ); + .orderBy( orderBy( eventTemplate.completionDate() ) ); } }; } http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/query/dto/HandlingEventDTO.java ---------------------------------------------------------------------- diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/query/dto/HandlingEventDTO.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/query/dto/HandlingEventDTO.java index 1501946..4b4c1ae 100644 --- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/query/dto/HandlingEventDTO.java +++ b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/query/dto/HandlingEventDTO.java @@ -19,7 +19,7 @@ */ package org.apache.zest.sample.dcicargo.sample_a.communication.query.dto; -import java.util.Date; +import java.time.LocalDate; import org.apache.zest.api.common.Optional; import org.apache.zest.api.property.Property; import org.apache.zest.library.conversion.values.Unqualified; @@ -38,7 +38,7 @@ import org.apache.zest.sample.dcicargo.sample_a.infrastructure.conversion.DTO; @Unqualified public interface HandlingEventDTO extends DTO { - Property completionTime(); + Property completionDate(); Property trackingId(); http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/web/booking/BookNewCargoPage.java ---------------------------------------------------------------------- diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/web/booking/BookNewCargoPage.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/web/booking/BookNewCargoPage.java index 5f60367..20cc050 100644 --- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/web/booking/BookNewCargoPage.java +++ b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/web/booking/BookNewCargoPage.java @@ -19,7 +19,8 @@ */ package org.apache.zest.sample.dcicargo.sample_a.communication.web.booking; -import java.util.Date; +import java.time.LocalDate; +import java.time.LocalDateTime; import java.util.List; import org.apache.wicket.Session; import org.apache.wicket.ajax.AjaxRequestTarget; @@ -29,7 +30,6 @@ 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.joda.time.LocalDate; import org.apache.zest.sample.dcicargo.sample_a.communication.query.CommonQueries; import org.apache.zest.sample.dcicargo.sample_a.context.shipping.booking.BookNewCargo; import org.apache.zest.sample.dcicargo.sample_a.data.shipping.cargo.TrackingId; @@ -60,7 +60,7 @@ public class BookNewCargoPage extends BookingBasePage { // Set by Wicket property resolvers: private String origin, destination; - private Date deadline; + private LocalDate deadline; public BookNewCargoForm() { @@ -110,7 +110,7 @@ public class BookNewCargoPage extends BookingBasePage // Deadline final DateTextFieldWithPicker deadlineField = new DateTextFieldWithPicker( "deadline", "Arrival deadline", this ); - deadlineField.earliestDate( new LocalDate().plusDays( 1 ) ); + deadlineField.earliestDate( LocalDate.now().plusDays( 1 ) ); final ComponentFeedbackPanel deadlineFeedback = new ComponentFeedbackPanel( "deadlineFeedback", deadlineField ); http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/web/booking/CargoDetailsPage.java ---------------------------------------------------------------------- diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/web/booking/CargoDetailsPage.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/web/booking/CargoDetailsPage.java index f9b86e2..0e07841 100644 --- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/web/booking/CargoDetailsPage.java +++ b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/web/booking/CargoDetailsPage.java @@ -19,7 +19,6 @@ */ package org.apache.zest.sample.dcicargo.sample_a.communication.web.booking; -import java.util.Date; import java.util.List; import org.apache.wicket.AttributeModifier; import org.apache.wicket.devutils.stateless.StatelessComponent; @@ -45,6 +44,9 @@ import org.apache.zest.sample.dcicargo.sample_a.infrastructure.wicket.color.Erro import org.apache.zest.sample.dcicargo.sample_a.infrastructure.wicket.link.LinkPanel; import org.apache.zest.sample.dcicargo.sample_a.infrastructure.wicket.prevnext.PrevNext; +import static java.time.ZoneOffset.UTC; +import static java.util.Date.from; + /** * Cargo details - an overview of all data available about a cargo. */ @@ -142,14 +144,15 @@ public class CargoDetailsPage extends BookingBasePage Leg leg = item.getModelObject(); item.add( new Label( "loadLocation", leg.loadLocation().get().getCode() ) ); - item.add( new Label( "loadTime", new Model( leg.loadTime().get() ) ) ); + item.add( new Label( "loadDate", new Model<>( from( leg.loadDate().get().atStartOfDay().toInstant( UTC ) ) ) ) ); item.add( new Label( "voyage", leg.voyage().get().voyageNumber().get().number().get() ) ); Boolean isMisrouted = routingStatus == RoutingStatus.MISROUTED && item.getIndex() == ( getList().size() - 1 ); - item.add( new Label( "unloadLocation", leg.unloadLocation().get().getCode() ) - .add( new ErrorColor( isMisrouted ) ) ); + item.add( new Label( "unloadLocation", + leg.unloadLocation().get().getCode() ).add( new ErrorColor( isMisrouted ) ) ); - item.add( new Label( "unloadTime", new Model( leg.unloadTime().get() ) ) ); + item.add( 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_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/web/booking/CargoListPage.java ---------------------------------------------------------------------- diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/web/booking/CargoListPage.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/web/booking/CargoListPage.java index 5b4422d..35e260f 100644 --- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/web/booking/CargoListPage.java +++ b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/web/booking/CargoListPage.java @@ -19,8 +19,9 @@ */ package org.apache.zest.sample.dcicargo.sample_a.communication.web.booking; +import java.time.LocalDateTime; +import java.time.ZoneOffset; import java.util.ArrayList; -import java.util.Date; import java.util.List; import org.apache.wicket.Session; import org.apache.wicket.devutils.stateless.StatelessComponent; @@ -31,6 +32,7 @@ import org.apache.wicket.model.IModel; import org.apache.wicket.model.Model; import org.apache.zest.sample.dcicargo.sample_a.communication.query.CommonQueries; import org.apache.zest.sample.dcicargo.sample_a.communication.query.dto.CargoDTO; +import org.apache.zest.sample.dcicargo.sample_a.data.shipping.cargo.RouteSpecification; import org.apache.zest.sample.dcicargo.sample_a.data.shipping.delivery.Delivery; import org.apache.zest.sample.dcicargo.sample_a.data.shipping.delivery.RoutingStatus; import org.apache.zest.sample.dcicargo.sample_a.data.shipping.handling.HandlingEventType; @@ -38,6 +40,8 @@ import org.apache.zest.sample.dcicargo.sample_a.infrastructure.wicket.color.Erro import org.apache.zest.sample.dcicargo.sample_a.infrastructure.wicket.link.LinkPanel; import org.apache.zest.sample.dcicargo.sample_a.infrastructure.wicket.prevnext.PrevNext; +import static java.util.Date.from; + /** * List of Cargos */ @@ -49,7 +53,7 @@ public class CargoListPage extends BookingBasePage IModel> cargoList = new CommonQueries().cargoList(); // Save current trackingIds in session (for prev/next buttons on details page) - ArrayList ids = new ArrayList(); + ArrayList ids = new ArrayList<>(); for( CargoDTO cargo : cargoList.getObject() ) { ids.add( cargo.trackingId().get().id().get() ); @@ -70,12 +74,11 @@ public class CargoListPage extends BookingBasePage item.add( new Label( "origin", cargo.origin().get().getCode() ) ); - item.add( new Label( "destination", cargo.routeSpecification().get().destination().get().getCode() ) ); + RouteSpecification routeSpecification = cargo.routeSpecification().get(); + item.add( new Label( "destination", routeSpecification.destination().get().getCode() ) ); - item.add( new Label( "deadline", new Model( cargo.routeSpecification() - .get() - .arrivalDeadline() - .get() ) ) ); + LocalDateTime deadlineTime = routeSpecification.arrivalDeadline().get().atStartOfDay().plusDays( 1 ); + item.add( new Label( "deadline", new Model<>( from( deadlineTime.toInstant( ZoneOffset.UTC ) ) ) ) ); item.add( new Label( "routingStatus", routingStatus.toString() ).add( new ErrorColor( routingStatus == RoutingStatus.MISROUTED ) ) ); @@ -87,7 +90,7 @@ public class CargoListPage extends BookingBasePage String customsLabel = delivery.transportStatus().get().name() + ( inCustoms ? " (CUSTOMS)" : "" ); item.add( new Label( "transportStatus", customsLabel ) ); - IModel directed = new Model( delivery.isMisdirected().get() ? "Misdirected" : "On track" ); + IModel directed = new Model<>( delivery.isMisdirected().get() ? "Misdirected" : "On track" ); item.add( new Label( "deliveryStatus", directed ).add( new ErrorColor( delivery.isMisdirected() .get() ) ) ); } http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/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 index 730b5a9..7ad9d14 100644 --- 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 @@ -19,7 +19,6 @@ */ package org.apache.zest.sample.dcicargo.sample_a.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; @@ -37,6 +36,9 @@ import org.apache.zest.sample.dcicargo.sample_a.context.shipping.booking.BookNew 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. * @@ -77,9 +79,9 @@ 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_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 index f751fe3..93cbab2 100644 --- 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 @@ -19,7 +19,8 @@ */ package org.apache.zest.sample.dcicargo.sample_a.communication.web.handling; -import java.util.Date; +import java.time.LocalDate; +import java.time.LocalDateTime; import org.apache.wicket.ajax.AjaxRequestTarget; import org.apache.wicket.ajax.markup.html.form.AjaxFallbackButton; import org.apache.wicket.markup.html.form.Form; @@ -27,7 +28,6 @@ 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.joda.time.LocalDate; 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; @@ -58,7 +58,7 @@ public class RegisterHandlingEventPage extends BasePage private final class RegisterHandlingEventForm extends AbstractForm { // Set by Wicket property resolvers: - private Date completion; + private LocalDate completionDate; private String trackingId, unLocode, voyageNumber, eventType; private String lastSubmittedData; @@ -68,8 +68,8 @@ public class RegisterHandlingEventPage extends BasePage final FeedbackPanel feedback = new FeedbackPanel( "feedback" ); add( feedback.setOutputMarkupId( true ) ); - final DateTextFieldWithPicker completionDateInput = new DateTextFieldWithPicker( "completion", "Completion", this ); - completionDateInput.earliestDate( new LocalDate() ); + final DateTextFieldWithPicker completionDateInput = new DateTextFieldWithPicker( "completionDate", "Completion", this ); + completionDateInput.earliestDate( LocalDate.now() ); HandlingQueries fetch = new HandlingQueries(); add( completionDateInput.setLabel( Model.of( "Completion" ) ) ); @@ -93,7 +93,7 @@ public class RegisterHandlingEventPage extends BasePage // Perform use case new RegisterHandlingEvent( - new Date(), completion, trackingId, eventType, unLocode, voyageNumber ).register(); + 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... @@ -131,7 +131,7 @@ public class RegisterHandlingEventPage extends BasePage private boolean sameDataIsSubmitted() { - String submittedData = completion.toString() + trackingId + unLocode + voyageNumber + eventType; + String submittedData = completionDate.toString() + trackingId + unLocode + voyageNumber + eventType; if( submittedData.equals( lastSubmittedData ) ) { http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/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 index 527a82b..d96bb39 100644 --- 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 @@ -19,7 +19,6 @@ */ package org.apache.zest.sample.dcicargo.sample_a.communication.web.tracking; -import java.util.Date; import java.util.List; import org.apache.wicket.behavior.AttributeAppender; import org.apache.wicket.devutils.stateless.StatelessComponent; @@ -65,7 +64,7 @@ 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<>( event.completionDate().get() ) ) ); // Event description (data substitution in strings from HandlingHistoryPanel.properties) ValueMap map = new ValueMap(); http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/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 index 62eeaeb..80f405c 100644 --- 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 @@ -19,7 +19,6 @@ */ package org.apache.zest.sample.dcicargo.sample_a.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( "expectedEvent", 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_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 index b0a4d9d..2f7f999 100644 --- 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 @@ -19,8 +19,7 @@ */ package org.apache.zest.sample.dcicargo.sample_a.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; @@ -62,7 +61,9 @@ public class TrackCargoPage extends BasePage private final class TrackingForm extends AbstractForm { private String trackingId; - private String selectedTrackingId; // Set by Wicket property resolver + + @SuppressWarnings( "unused" ) // Set by Wicket property resolver + private String selectedTrackingId; private TextField trackingIdInput; private SelectorInForm selectedTrackingIdSelector; @@ -73,7 +74,7 @@ public class TrackCargoPage extends BasePage private TrackingForm() { // Manual input - trackingIdInput = new TextField( "trackingId", new PropertyModel( this, "trackingId" ) ); + trackingIdInput = new TextField<>( "trackingId", new PropertyModel( this, "trackingId" ) ); add( trackingIdInput.setRequired( true ).setOutputMarkupId( true ) ); // Submit button @@ -134,7 +135,7 @@ public class TrackCargoPage extends BasePage private class StatusFragment extends Fragment { - public StatusFragment( IModel cargoModel, Boolean visible ) + StatusFragment( IModel cargoModel, Boolean visible ) { super( "status", "statusFragment", TrackingForm.this ); setVisible( visible ); @@ -164,12 +165,12 @@ public class TrackCargoPage extends BasePage map.put( "location", cargo.origin().get().getString() ); } add( new Label( "transportStatus", new StringResourceModel( - "transportStatus.${status}", this, new Model( map ) ) ) ); + "transportStatus.${status}", this, new Model<>( map ) ) ) ); // 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_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 index f962570..7a7ff72 100644 --- 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 @@ -19,9 +19,8 @@ */ package org.apache.zest.sample.dcicargo.sample_a.context.shipping.booking; -import java.util.Date; +import java.time.LocalDate; import java.util.List; -import org.joda.time.DateMidnight; import org.apache.zest.api.common.Optional; import org.apache.zest.api.injection.scope.Service; import org.apache.zest.api.injection.scope.This; @@ -57,7 +56,7 @@ public class BookNewCargo extends Context // Methodless Roles private Location origin; private Location destination; - private Date arrivalDeadline; + private LocalDate arrivalDeadline; private Itinerary itinerary; // CONTEXT CONSTRUCTORS ------------------------------------------------------ @@ -65,7 +64,7 @@ public class BookNewCargo extends Context public BookNewCargo( Cargos cargos, Location origin, Location destination, - Date arrivalDeadline + LocalDate arrivalDeadline ) throws Exception { @@ -88,7 +87,7 @@ public class BookNewCargo extends Context // Constructor proxies for communication layer - public BookNewCargo( String originId, String destinationId, Date deadline ) + public BookNewCargo( String originId, String destinationId, LocalDate deadline ) throws Exception { this( loadEntity( CargosEntity.class, CargosEntity.CARGOS_ID ), @@ -214,7 +213,7 @@ public class BookNewCargo extends Context public void changeDestination( Location newDestination ) { Location currentOrigin = cargo.routeSpecification().get().origin().get(); - Date currentDeadline = cargo.routeSpecification().get().arrivalDeadline().get(); + LocalDate currentDeadline = cargo.routeSpecification().get().arrivalDeadline().get(); RouteSpecification newRouteSpecification = context.buildRouteSpecification( vbf, currentOrigin, newDestination, currentDeadline ); @@ -228,7 +227,7 @@ public class BookNewCargo extends Context } public RouteSpecification buildRouteSpecification( - ValueBuilderFactory vbf, Location origin, Location destination, Date deadline + ValueBuilderFactory vbf, Location origin, Location destination, LocalDate deadline ) { if( origin == destination ) @@ -241,12 +240,11 @@ public class BookNewCargo extends Context throw new RouteException( "Arrival deadline cannot be null." ); } - Date endOfToday = new DateMidnight().plusDays( 1 ).toDate(); - if( deadline.before( endOfToday ) ) + if( !deadline.isAfter( LocalDate.now() ) ) { throw new RouteException( "Arrival deadline is in the past or Today." + - "\nDeadline " + deadline + - "\nToday (midnight) " + endOfToday ); + "\nDeadline " + deadline + + "\nToday (midnight) " + LocalDate.now().atStartOfDay().plusDays( 1 ) ); } ValueBuilder routeSpec = vbf.newValueBuilder( RouteSpecification.class ); http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/booking/BuildDeliverySnapshot.java ---------------------------------------------------------------------- diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/booking/BuildDeliverySnapshot.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/booking/BuildDeliverySnapshot.java index d886f53..c299b94 100644 --- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/booking/BuildDeliverySnapshot.java +++ b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/booking/BuildDeliverySnapshot.java @@ -19,7 +19,8 @@ */ package org.apache.zest.sample.dcicargo.sample_a.context.shipping.booking; -import java.util.Date; +import java.time.Instant; +import java.time.LocalDate; import java.util.Iterator; import org.apache.zest.api.injection.scope.This; import org.apache.zest.api.mixin.Mixins; @@ -73,7 +74,7 @@ public class BuildDeliverySnapshot extends Context // CONTEXT CONSTRUCTORS ------------------------------------------------------ - public BuildDeliverySnapshot( RouteSpecification routeSpecification ) + BuildDeliverySnapshot( RouteSpecification routeSpecification ) { // Deviation 2a if( routeSpecification.origin().get() == routeSpecification.destination().get() ) @@ -82,11 +83,11 @@ public class BuildDeliverySnapshot extends Context } // Deviation 2b - if( routeSpecification.arrivalDeadline().get().before( new Date() ) ) + if( !routeSpecification.arrivalDeadline().get().isAfter( LocalDate.now() ) ) { throw new RouteException( "Arrival deadline is in the past or Today." + "\nDeadline " + routeSpecification.arrivalDeadline().get() + - "\nToday " + new Date() ); + "\nToday " + LocalDate.now() ); } factory = rolePlayer( FactoryRole.class, routeSpecification ); @@ -94,7 +95,7 @@ public class BuildDeliverySnapshot extends Context handlingEvent = null; } - public BuildDeliverySnapshot( Cargo cargo ) + BuildDeliverySnapshot( Cargo cargo ) { factory = rolePlayer( FactoryRole.class, cargo.routeSpecification().get() ); itinerary = rolePlayer( ItineraryRole.class, cargo.itinerary().get() ); @@ -157,7 +158,7 @@ public class BuildDeliverySnapshot extends Context // Build delivery snapshot object deliveryBuilder = vbf.newValueBuilder( Delivery.class ); context.newDeliverySnapshot = deliveryBuilder.prototype(); - context.newDeliverySnapshot.timestamp().set( new Date() ); + context.newDeliverySnapshot.timestamp().set( Instant.now() ); // Deviation 2c: Cargo is not routed yet if( context.itinerary == null ) @@ -419,7 +420,7 @@ public class BuildDeliverySnapshot extends Context { void setContext( BuildDeliverySnapshot context ); - Date eta(); + LocalDate eta(); boolean expectsOrigin( Location location ); @@ -442,9 +443,9 @@ public class BuildDeliverySnapshot extends Context @This Itinerary itinerary; - public Date eta() + public LocalDate eta() { - return itinerary.lastLeg().unloadTime().get(); + return itinerary.lastLeg().unloadDate().get(); } // Route expectations ---------------------------------------------------- @@ -492,8 +493,10 @@ public class BuildDeliverySnapshot extends Context { // After RECEIVE, expect LOAD location and voyage of first itinerary leg final Leg firstLeg = itinerary.legs().get().iterator().next(); - return buildEvent( HandlingEventType.LOAD, firstLeg.loadLocation().get(), firstLeg.loadTime() - .get(), firstLeg.voyage().get() ); + return buildEvent( HandlingEventType.LOAD, + firstLeg.loadLocation().get(), + firstLeg.loadDate().get(), + firstLeg.voyage().get() ); } public ExpectedHandlingEvent expectedEventAfterLoadAt( Location lastLoadLocation ) @@ -503,8 +506,10 @@ public class BuildDeliverySnapshot extends Context { if( leg.loadLocation().get().equals( lastLoadLocation ) ) { - return buildEvent( HandlingEventType.UNLOAD, leg.unloadLocation().get(), leg.unloadTime() - .get(), leg.voyage().get() ); + return buildEvent( HandlingEventType.UNLOAD, + leg.unloadLocation().get(), + leg.unloadDate().get(), + leg.voyage().get() ); } } return null; @@ -525,14 +530,18 @@ public class BuildDeliverySnapshot extends Context // Cargo has not arrived yet (uncompleted legs in itinerary) // We expect it to be loaded onto some Carrier final Leg nextLeg = it.next(); - return buildEvent( HandlingEventType.LOAD, nextLeg.loadLocation().get(), nextLeg.loadTime() - .get(), nextLeg.voyage().get() ); + return buildEvent( + HandlingEventType.LOAD, + nextLeg.loadLocation().get(), + nextLeg.loadDate().get(), + nextLeg.voyage().get() + ); } else { // Cargo has arrived (no more legs in itinerary) // We expect it to be claimed by the customer - return buildEvent( HandlingEventType.CLAIM, leg.unloadLocation().get(), leg.unloadTime() + return buildEvent( HandlingEventType.CLAIM, leg.unloadLocation().get(), leg.unloadDate() .get(), null ); } } @@ -544,14 +553,14 @@ public class BuildDeliverySnapshot extends Context private ExpectedHandlingEvent buildEvent( HandlingEventType eventType, Location location, - Date time, + LocalDate date, Voyage voyage ) { ValueBuilder builder = vbf.newValueBuilder( ExpectedHandlingEvent.class ); builder.prototype().handlingEventType().set( eventType ); builder.prototype().location().set( location ); - builder.prototype().time().set( time ); + builder.prototype().date().set( date ); builder.prototype().voyage().set( voyage ); return builder.newInstance(); } http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/handling/RegisterHandlingEvent.java ---------------------------------------------------------------------- diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/handling/RegisterHandlingEvent.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/handling/RegisterHandlingEvent.java index 53c6c28..4388edf 100644 --- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/handling/RegisterHandlingEvent.java +++ b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/handling/RegisterHandlingEvent.java @@ -19,8 +19,9 @@ */ package org.apache.zest.sample.dcicargo.sample_a.context.shipping.handling; +import java.time.LocalDate; +import java.time.LocalDateTime; import java.util.Arrays; -import java.util.Date; import org.apache.zest.api.injection.scope.Service; import org.apache.zest.api.injection.scope.This; import org.apache.zest.api.mixin.Mixins; @@ -53,8 +54,8 @@ public class RegisterHandlingEvent extends Context private HandlingEventFactoryRole handlingEventFactory; - private Date registrationTime; - private Date completionTime; + private LocalDate registrationDate; + private LocalDate completionDate; private String trackingIdString; private String eventTypeString; private String unLocodeString; @@ -62,8 +63,8 @@ public class RegisterHandlingEvent extends Context // CONTEXT CONSTRUCTORS ------------------------------------------------------ - public RegisterHandlingEvent( Date registrationTime, - Date completionTime, + public RegisterHandlingEvent( LocalDate registrationDate, + LocalDate completionDate, String trackingIdString, String eventTypeString, String unLocodeString, @@ -72,8 +73,8 @@ public class RegisterHandlingEvent extends Context { handlingEventFactory = rolePlayer( HandlingEventFactoryRole.class, HandlingEventsEntity.class, HANDLING_EVENTS_ID ); - this.registrationTime = registrationTime; - this.completionTime = completionTime; + this.registrationDate = registrationDate; + this.completionDate = completionDate; this.trackingIdString = trackingIdString; this.eventTypeString = eventTypeString; this.unLocodeString = unLocodeString; @@ -119,7 +120,7 @@ public class RegisterHandlingEvent extends Context // Step 1: Publish event stating that registration attempt has been received. applicationEvents.receivedHandlingEventRegistrationAttempt( registrationAttempt ); - HandlingEvent handlingEvent = null; + HandlingEvent handlingEvent; try { // Step 2: Verify existing data @@ -130,7 +131,12 @@ public class RegisterHandlingEvent extends Context // Step 4: Create and save handling event handlingEvent = handlingEvents.createHandlingEvent( - context.registrationTime, context.completionTime, trackingId, handlingEventType, location, voyage ); + context.registrationDate, + context.completionDate, + trackingId, + handlingEventType, + location, + voyage ); } catch( IllegalArgumentException e ) { @@ -150,8 +156,8 @@ public class RegisterHandlingEvent extends Context { ValueBuilder builder = vbf.newValueBuilder( RegisterHandlingEventAttemptDTO.class ); - builder.prototype().registrationTime().set( context.registrationTime ); - builder.prototype().completionTime().set( context.completionTime ); + builder.prototype().registrationDate().set( context.registrationDate ); + builder.prototype().completionDate().set( context.completionDate ); builder.prototype().trackingIdString().set( context.trackingIdString ); builder.prototype().eventTypeString().set( context.eventTypeString ); builder.prototype().unLocodeString().set( context.unLocodeString ); @@ -161,11 +167,11 @@ public class RegisterHandlingEvent extends Context private void verifyExistingData() { - if( context.registrationTime == null ) + if( context.registrationDate == null ) { throw new IllegalArgumentException( "Registration time was null. All parameters have to be passed." ); } - if( context.completionTime == null ) + if( context.completionDate == null ) { throw new IllegalArgumentException( "Completion time was null. All parameters have to be passed." ); } http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/support/ApplicationEvents.java ---------------------------------------------------------------------- diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/support/ApplicationEvents.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/support/ApplicationEvents.java index 7c0deb5..5f29685 100644 --- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/support/ApplicationEvents.java +++ b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/support/ApplicationEvents.java @@ -19,8 +19,8 @@ */ package org.apache.zest.sample.dcicargo.sample_a.context.support; -import java.text.SimpleDateFormat; -import java.util.Date; +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; import org.apache.zest.api.mixin.Mixins; import org.apache.zest.api.service.ServiceComposite; import org.apache.zest.sample.dcicargo.sample_a.data.shipping.cargo.Cargo; @@ -85,7 +85,7 @@ public interface ApplicationEvents public void cargoWasHandled( HandlingEvent registeredHandlingEvent ) { id = registeredHandlingEvent.trackingId().get().id().get(); - time = parseDate( registeredHandlingEvent.completionTime().get() ); + time = parseDate( registeredHandlingEvent.completionDate().get() ); type = registeredHandlingEvent.handlingEventType().get().name(); unloc = registeredHandlingEvent.location().get().getCode(); loc = registeredHandlingEvent.location().get().name().get(); @@ -121,7 +121,7 @@ public interface ApplicationEvents public void receivedHandlingEventRegistrationAttempt( RegisterHandlingEventAttemptDTO attempt ) { - time = parseDate( attempt.completionTime().get() ); + time = parseDate( attempt.completionDate().get() ); id = parse( attempt.trackingIdString().get() ); type = parse( attempt.eventTypeString().get() ); unloc = parse( attempt.unLocodeString().get() ); @@ -146,9 +146,9 @@ public interface ApplicationEvents 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" : DateTimeFormatter.ISO_DATE.format( date ); } } } http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/support/FoundNoRoutesException.java ---------------------------------------------------------------------- diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/support/FoundNoRoutesException.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/support/FoundNoRoutesException.java index c8374c6..6a8d941 100644 --- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/support/FoundNoRoutesException.java +++ b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/support/FoundNoRoutesException.java @@ -19,7 +19,7 @@ */ package org.apache.zest.sample.dcicargo.sample_a.context.support; -import org.joda.time.LocalDate; +import java.time.LocalDate; /** * Custom messages when the 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_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/support/RegisterHandlingEventAttemptDTO.java ---------------------------------------------------------------------- diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/support/RegisterHandlingEventAttemptDTO.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/support/RegisterHandlingEventAttemptDTO.java index 453598d..5562fba 100644 --- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/support/RegisterHandlingEventAttemptDTO.java +++ b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/support/RegisterHandlingEventAttemptDTO.java @@ -19,7 +19,7 @@ */ package org.apache.zest.sample.dcicargo.sample_a.context.support; -import java.util.Date; +import java.time.LocalDate; import org.apache.zest.api.common.Optional; import org.apache.zest.api.property.Immutable; import org.apache.zest.api.property.Property; @@ -32,10 +32,10 @@ import org.apache.zest.sample.dcicargo.sample_a.infrastructure.conversion.DTO; public interface RegisterHandlingEventAttemptDTO extends DTO { @Optional - Property registrationTime(); + Property registrationDate(); @Optional - Property completionTime(); + Property completionDate(); @Optional Property trackingIdString(); http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/support/RoutingService.java ---------------------------------------------------------------------- diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/support/RoutingService.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/support/RoutingService.java index 9686c46..c2d0787 100644 --- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/support/RoutingService.java +++ b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/support/RoutingService.java @@ -23,7 +23,6 @@ import java.rmi.RemoteException; import java.util.ArrayList; import java.util.Collections; 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; @@ -119,7 +118,7 @@ public interface RoutingService if( itineraries.size() == 0 ) { throw new FoundNoRoutesException( destination.name().get(), - new LocalDate( routeSpecification.arrivalDeadline().get() ) ); + routeSpecification.arrivalDeadline().get() ); } return itineraries; @@ -147,8 +146,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_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/cargo/RouteSpecification.java ---------------------------------------------------------------------- diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/cargo/RouteSpecification.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/cargo/RouteSpecification.java index d856c32..a7c09c3 100644 --- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/cargo/RouteSpecification.java +++ b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/cargo/RouteSpecification.java @@ -19,7 +19,7 @@ */ package org.apache.zest.sample.dcicargo.sample_a.data.shipping.cargo; -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; @@ -53,7 +53,7 @@ public interface RouteSpecification Association destination(); - Property arrivalDeadline(); + Property arrivalDeadline(); // Can we accept to have this "intelligent" logic here? // DCI Data is supposed to be dumb, but it's really convenient to have this logic here, @@ -69,7 +69,7 @@ public interface RouteSpecification !itinerary.legs().get().isEmpty() && origin().get().equals( itinerary.firstLeg().loadLocation().get() ) && destination().get().equals( itinerary.lastLeg().unloadLocation().get() ) && - arrivalDeadline().get().after( itinerary.finalArrivalDate() ); + arrivalDeadline().get().isAfter( itinerary.finalArrivalDate() ); } } } http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/delivery/Delivery.java ---------------------------------------------------------------------- diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/delivery/Delivery.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/delivery/Delivery.java index 17e64bb..c12d495 100644 --- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/delivery/Delivery.java +++ b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/delivery/Delivery.java @@ -19,7 +19,8 @@ */ package org.apache.zest.sample.dcicargo.sample_a.data.shipping.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; @@ -78,7 +79,7 @@ import org.apache.zest.sample.dcicargo.sample_a.data.shipping.voyage.Voyage; public interface Delivery extends ValueComposite { - Property timestamp(); + Property timestamp(); /* * NOT_ROUTED @@ -122,7 +123,7 @@ public interface Delivery Association currentVoyage(); @Optional - Property eta(); + Property eta(); @UseDefaults Property isUnloadedAtDestination(); http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/delivery/ExpectedHandlingEvent.java ---------------------------------------------------------------------- diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/delivery/ExpectedHandlingEvent.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/delivery/ExpectedHandlingEvent.java index fcd2733..7969659 100644 --- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/delivery/ExpectedHandlingEvent.java +++ b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/delivery/ExpectedHandlingEvent.java @@ -19,7 +19,7 @@ */ package org.apache.zest.sample.dcicargo.sample_a.data.shipping.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; @@ -41,7 +41,7 @@ public interface ExpectedHandlingEvent // Added expected time for the event to happen (compared to the original DDD sample) @Optional - Property time(); + Property date(); @Optional Association voyage(); http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/handling/HandlingEvent.java ---------------------------------------------------------------------- diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/handling/HandlingEvent.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/handling/HandlingEvent.java index e0b9ff7..83a9ab5 100644 --- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/handling/HandlingEvent.java +++ b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/handling/HandlingEvent.java @@ -19,7 +19,7 @@ */ package org.apache.zest.sample.dcicargo.sample_a.data.shipping.handling; -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.common.UseDefaults; @@ -49,10 +49,10 @@ import org.apache.zest.sample.dcicargo.sample_a.data.shipping.voyage.Voyage; public interface HandlingEvent { @Immutable - Property registrationTime(); + Property registrationDate(); @Immutable - Property completionTime(); + Property completionDate(); @Immutable Property trackingId(); http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/handling/HandlingEvents.java ---------------------------------------------------------------------- diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/handling/HandlingEvents.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/handling/HandlingEvents.java index 3d83a69..578a54e 100644 --- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/handling/HandlingEvents.java +++ b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/handling/HandlingEvents.java @@ -19,7 +19,7 @@ */ package org.apache.zest.sample.dcicargo.sample_a.data.shipping.handling; -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; @@ -37,8 +37,8 @@ import org.apache.zest.sample.dcicargo.sample_a.data.shipping.voyage.Voyage; @Mixins( HandlingEvents.Mixin.class ) public interface HandlingEvents { - HandlingEvent createHandlingEvent( Date registrationTime, - Date completionTime, + HandlingEvent createHandlingEvent( LocalDate registrationDate, + LocalDate completionDate, TrackingId trackingId, HandlingEventType handlingEventType, Location location, @@ -52,8 +52,8 @@ public interface HandlingEvents @Structure UnitOfWorkFactory uowf; - public HandlingEvent createHandlingEvent( Date registrationTime, - Date completionTime, + public HandlingEvent createHandlingEvent( LocalDate registrationDate, + LocalDate completionDate, TrackingId trackingId, HandlingEventType handlingEventType, Location location, @@ -73,8 +73,8 @@ public interface HandlingEvents 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_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/itinerary/Itinerary.java ---------------------------------------------------------------------- diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/itinerary/Itinerary.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/itinerary/Itinerary.java index 617756a..90b4228 100644 --- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/itinerary/Itinerary.java +++ b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/itinerary/Itinerary.java @@ -19,14 +19,16 @@ */ package org.apache.zest.sample.dcicargo.sample_a.data.shipping.itinerary; -import java.util.Date; +import java.time.Duration; +import java.time.LocalDate; +import java.time.LocalDateTime; import java.util.List; -import org.joda.time.Days; -import org.joda.time.LocalDate; import org.apache.zest.api.mixin.Mixins; import org.apache.zest.api.property.Property; import org.apache.zest.library.constraints.annotation.NotEmpty; +import static java.time.ZoneOffset.UTC; + /** * An itinerary is a description of a planned route for a cargo. * @@ -46,9 +48,9 @@ public interface Itinerary Leg lastLeg(); - Date finalArrivalDate(); + LocalDate finalArrivalDate(); - int days(); + long days(); public abstract class Mixin implements Itinerary @@ -73,21 +75,21 @@ public interface Itinerary return legs().get().get( legs().get().size() - 1 ); } - public Date finalArrivalDate() + public LocalDate finalArrivalDate() { if( lastLeg() == null ) { - return new Date( new Date( Long.MAX_VALUE ).getTime() ); + return LocalDate.MAX; } - return new Date( lastLeg().unloadTime().get().getTime() ); + return lastLeg().unloadDate().get(); } - public int days() + public long days() { - Date dep = firstLeg().loadTime().get(); - Date arr = lastLeg().unloadTime().get(); - return Days.daysBetween( new LocalDate( dep ), new LocalDate( arr ) ).getDays(); + LocalDate dep = firstLeg().loadDate().get(); + LocalDate arr = lastLeg().unloadDate().get(); + return Duration.between(dep, arr).toDays(); } } } \ No newline at end of file