You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@polygene.apache.org by ni...@apache.org on 2016/08/19 12:18:35 UTC
[01/25] 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.
Repository: zest-java
Updated Branches:
refs/heads/ValueSerializationCleaning [created] 301f837df
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/data/structure/handling/HandlingEvent.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/data/structure/handling/HandlingEvent.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/data/structure/handling/HandlingEvent.java
index 5e6bae8..a905caf 100644
--- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/data/structure/handling/HandlingEvent.java
+++ b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/data/structure/handling/HandlingEvent.java
@@ -19,8 +19,7 @@
*/
package org.apache.zest.sample.dcicargo.sample_b.data.structure.handling;
-import java.text.SimpleDateFormat;
-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.mixin.Mixins;
@@ -57,9 +56,9 @@ import org.apache.zest.sample.dcicargo.sample_b.data.structure.voyage.Voyage;
@Mixins( HandlingEvent.Mixin.class )
public interface HandlingEvent
{
- Property<Date> registrationTime();
+ Property<LocalDate> registrationDate();
- Property<Date> completionTime();
+ Property<LocalDate> completionDate();
Property<TrackingId> trackingId();
@@ -83,18 +82,14 @@ public interface HandlingEvent
voyage = voyage().get().voyageNumber().get().number().get();
}
- SimpleDateFormat date = new SimpleDateFormat( "yyyy-MM-dd" );
-
- StringBuilder builder = new StringBuilder( "\nHANDLING EVENT -----------------" ).
- append( "\n Cargo " ).append( trackingId().get().id().get() ).
- append( "\n Type " ).append( handlingEventType().get().name() ).
- append( "\n Location " ).append( location().get().getString() ).
- append( "\n Completed " ).append( date.format( completionTime().get() ) ).
- append( "\n Registered " ).append( date.format( registrationTime().get() ) ).
- append( "\n Voyage " ).append( voyage ).
- append( "\n--------------------------------\n" );
-
- return builder.toString();
+ return "\nHANDLING EVENT -----------------" +
+ "\n Cargo " + trackingId().get().id().get() +
+ "\n Type " + handlingEventType().get().name() +
+ "\n Location " + location().get().getString() +
+ "\n Completed " + completionDate().get() +
+ "\n Registered " + registrationDate().get() +
+ "\n Voyage " + voyage +
+ "\n--------------------------------\n";
}
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/data/structure/itinerary/Itinerary.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/data/structure/itinerary/Itinerary.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/data/structure/itinerary/Itinerary.java
index ccfd39a..b40fb60 100644
--- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/data/structure/itinerary/Itinerary.java
+++ b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/data/structure/itinerary/Itinerary.java
@@ -19,11 +19,9 @@
*/
package org.apache.zest.sample.dcicargo.sample_b.data.structure.itinerary;
-import java.text.SimpleDateFormat;
-import java.util.Date;
+import java.time.Duration;
+import java.time.LocalDate;
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.api.value.ValueComposite;
@@ -51,9 +49,9 @@ public interface Itinerary
Leg lastLeg();
- Date eta();
+ LocalDate eta();
- int days();
+ long days();
String print();
@@ -80,16 +78,16 @@ public interface Itinerary
return legs().get().get( legs().get().size() - 1 );
}
- public Date eta()
+ public LocalDate eta()
{
- return lastLeg().unloadTime().get();
+ 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();
}
public String print()
@@ -106,11 +104,11 @@ public interface Itinerary
{
sb.append( "\n Leg " ).append( i );
sb.append( " Load " );
- sb.append( new SimpleDateFormat( "yyyy-MM-dd" ).format( leg.loadTime().get() ) );
+ sb.append( leg.loadDate().get() );
sb.append( " " ).append( leg.loadLocation().get() );
sb.append( " " ).append( leg.voyage().get() );
sb.append( " Unload " );
- sb.append( new SimpleDateFormat( "yyyy-MM-dd" ).format( leg.unloadTime().get() ) );
+ sb.append( leg.unloadDate().get() );
sb.append( " " ).append( leg.unloadLocation().get() );
}
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/data/structure/itinerary/Leg.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/data/structure/itinerary/Leg.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/data/structure/itinerary/Leg.java
index 38526de..7aeb47c 100644
--- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/data/structure/itinerary/Leg.java
+++ b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/data/structure/itinerary/Leg.java
@@ -19,7 +19,7 @@
*/
package org.apache.zest.sample.dcicargo.sample_b.data.structure.itinerary;
-import java.util.Date;
+import java.time.LocalDate;
import org.apache.zest.api.association.Association;
import org.apache.zest.api.property.Property;
import org.apache.zest.api.value.ValueComposite;
@@ -38,11 +38,11 @@ public interface Leg
{
Association<Location> loadLocation();
- Property<Date> loadTime();
+ Property<LocalDate> loadDate();
Association<Voyage> voyage();
- Property<Date> unloadTime();
+ Property<LocalDate> unloadDate();
Association<Location> unloadLocation();
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/data/structure/voyage/CarrierMovement.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/data/structure/voyage/CarrierMovement.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/data/structure/voyage/CarrierMovement.java
index 3835c79..af399a9 100644
--- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/data/structure/voyage/CarrierMovement.java
+++ b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/data/structure/voyage/CarrierMovement.java
@@ -19,7 +19,7 @@
*/
package org.apache.zest.sample.dcicargo.sample_b.data.structure.voyage;
-import java.util.Date;
+import java.time.LocalDate;
import org.apache.zest.api.association.Association;
import org.apache.zest.api.property.Property;
import org.apache.zest.api.value.ValueComposite;
@@ -39,7 +39,7 @@ public interface CarrierMovement
Association<Location> arrivalLocation();
- Property<Date> departureTime();
+ Property<LocalDate> departureDate();
- Property<Date> arrivalTime();
+ Property<LocalDate> arrivalDate();
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/data/structure/voyage/Voyage.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/data/structure/voyage/Voyage.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/data/structure/voyage/Voyage.java
index e0fe06a..8304001 100644
--- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/data/structure/voyage/Voyage.java
+++ b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/data/structure/voyage/Voyage.java
@@ -19,7 +19,6 @@
*/
package org.apache.zest.sample.dcicargo.sample_b.data.structure.voyage;
-import java.text.SimpleDateFormat;
import org.apache.zest.api.mixin.Mixins;
import org.apache.zest.api.property.Property;
import org.apache.zest.sample.dcicargo.sample_b.data.structure.location.Location;
@@ -80,10 +79,10 @@ public interface Voyage
{
sb.append( "\n (Leg " ).append( i ).append( ")" );
sb.append( " Departure " );
- sb.append( new SimpleDateFormat( "yyyy-MM-dd" ).format( carrierMovement.departureTime().get() ) );
+ sb.append( carrierMovement.departureDate().get() );
sb.append( " " ).append( carrierMovement.departureLocation().get() );
sb.append( " Arrival " );
- sb.append( new SimpleDateFormat( "yyyy-MM-dd" ).format( carrierMovement.arrivalTime().get() ) );
+ sb.append( carrierMovement.arrivalDate().get() );
sb.append( " " ).append( carrierMovement.arrivalLocation().get() );
}
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/infrastructure/wicket/form/DateTextFieldWithPicker.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/infrastructure/wicket/form/DateTextFieldWithPicker.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/infrastructure/wicket/form/DateTextFieldWithPicker.java
index e602a5b..2983e03 100644
--- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/infrastructure/wicket/form/DateTextFieldWithPicker.java
+++ b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/infrastructure/wicket/form/DateTextFieldWithPicker.java
@@ -20,7 +20,10 @@
package org.apache.zest.sample.dcicargo.sample_b.infrastructure.wicket.form;
import com.google.code.joliratools.StatelessAjaxEventBehavior;
-import java.util.Date;
+import java.time.LocalDate;
+import java.time.LocalTime;
+import java.time.ZoneOffset;
+import java.time.format.DateTimeFormatter;
import java.util.Map;
import org.apache.wicket.Component;
import org.apache.wicket.ajax.AjaxRequestTarget;
@@ -35,9 +38,8 @@ import org.apache.wicket.model.Model;
import org.apache.wicket.model.PropertyModel;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.apache.wicket.validation.validator.DateValidator;
-import org.joda.time.DateTime;
-import org.joda.time.LocalDate;
-import org.joda.time.LocalTime;
+
+import static java.util.Date.from;
/**
* DateTextFieldWithPicker
@@ -50,18 +52,18 @@ public class DateTextFieldWithPicker extends DateTextField
DatePicker datePicker;
// Configurable widget options
- LocalDate earliestDate;
- LocalDate selectedDate;
+ private LocalDate earliestDate;
+ private LocalDate selectedDate;
- final static String YUI_DATE_FORMAT = "MM/dd/yyyy";
+ private final static DateTimeFormatter YUI_DATE_FORMAT = DateTimeFormatter.ofPattern( "MM/dd/yyyy" );
public DateTextFieldWithPicker( String id, String label, Component model )
{
// this( id, new PropertyModel<Date>( model, id ), new StyleDateConverter( "S-", true ) );
- this( id, label, new PropertyModel<Date>( model, id ), new PatternDateConverter( "yyyy-MM-dd", true ) );
+ this( id, label, new PropertyModel<>( model, id ), new PatternDateConverter( "yyyy-MM-dd", true ) );
}
- public DateTextFieldWithPicker( String id, String label, IModel<Date> model, DateConverter converter )
+ public DateTextFieldWithPicker( String id, String label, IModel<java.util.Date> model, DateConverter converter )
{
super( id, model, converter );
@@ -189,8 +191,7 @@ public class DateTextFieldWithPicker extends DateTextField
// Input field validation - date should be _after_ minimumDate (not the same)
LocalDate minimumDate = newEarliestDate.minusDays( 1 );
- Date convertedMinimumDate = new DateTime( minimumDate.toDateTime( new LocalTime() ) ).toDate();
- add( DateValidator.minimum( convertedMinimumDate ) );
+ add( DateValidator.minimum( from( minimumDate.atTime( LocalTime.now() ).toInstant( ZoneOffset.UTC ) ) ) );
return this;
}
@@ -213,17 +214,17 @@ public class DateTextFieldWithPicker extends DateTextField
{
if( selectedDate != null )
{
- return selectedDate.toString( YUI_DATE_FORMAT );
+ return YUI_DATE_FORMAT.format( selectedDate );
}
// Select today or earliest date (if later) as default
return earliestDate == null ?
- new LocalDate().toString( YUI_DATE_FORMAT ) :
- earliestDate.toString( YUI_DATE_FORMAT );
+ YUI_DATE_FORMAT.format( LocalDate.now() ) :
+ YUI_DATE_FORMAT.format( earliestDate );
}
private String getEarliestDateStr()
{
- return earliestDate == null ? "" : earliestDate.toString( YUI_DATE_FORMAT );
+ return earliestDate == null ? "" : YUI_DATE_FORMAT.format( earliestDate );
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/samples/dci-cargo/dcisample_b/src/main/resources/org/apache/zest/sample/dcicargo/sample_b/communication/web/booking/CargoDetailsPage.html
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/main/resources/org/apache/zest/sample/dcicargo/sample_b/communication/web/booking/CargoDetailsPage.html b/samples/dci-cargo/dcisample_b/src/main/resources/org/apache/zest/sample/dcicargo/sample_b/communication/web/booking/CargoDetailsPage.html
index 37b4a32..0146e20 100644
--- a/samples/dci-cargo/dcisample_b/src/main/resources/org/apache/zest/sample/dcicargo/sample_b/communication/web/booking/CargoDetailsPage.html
+++ b/samples/dci-cargo/dcisample_b/src/main/resources/org/apache/zest/sample/dcicargo/sample_b/communication/web/booking/CargoDetailsPage.html
@@ -114,9 +114,9 @@
<tr wicket:id="legs">
<td wicket:id="voyage"></td>
<td wicket:id="loadLocation"></td>
- <td wicket:id="loadTime"></td>
+ <td wicket:id="loadDate"></td>
<td wicket:id="unloadLocation"></td>
- <td wicket:id="unloadTime"></td>
+ <td wicket:id="unloadDate"></td>
</tr>
</tbody>
</table>
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/samples/dci-cargo/dcisample_b/src/main/resources/org/apache/zest/sample/dcicargo/sample_b/communication/web/booking/RoutePanel.html
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/main/resources/org/apache/zest/sample/dcicargo/sample_b/communication/web/booking/RoutePanel.html b/samples/dci-cargo/dcisample_b/src/main/resources/org/apache/zest/sample/dcicargo/sample_b/communication/web/booking/RoutePanel.html
index fc3ea2e..3cf259f 100644
--- a/samples/dci-cargo/dcisample_b/src/main/resources/org/apache/zest/sample/dcicargo/sample_b/communication/web/booking/RoutePanel.html
+++ b/samples/dci-cargo/dcisample_b/src/main/resources/org/apache/zest/sample/dcicargo/sample_b/communication/web/booking/RoutePanel.html
@@ -51,9 +51,9 @@
<tr wicket:id="legs">
<td wicket:id="voyage"></td>
<td wicket:id="loadLocation"></td>
- <td wicket:id="loadTime"></td>
+ <td wicket:id="loadDate"></td>
<td wicket:id="unloadLocation"></td>
- <td wicket:id="unloadTime"></td>
+ <td wicket:id="unloadDate"></td>
</tr>
</tbody>
</table>
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/bootstrap/test/TestApplication.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/bootstrap/test/TestApplication.java b/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/bootstrap/test/TestApplication.java
index e9f1c4f..9690fd7 100644
--- a/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/bootstrap/test/TestApplication.java
+++ b/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/bootstrap/test/TestApplication.java
@@ -19,22 +19,16 @@
*/
package org.apache.zest.sample.dcicargo.sample_b.bootstrap.test;
-import java.text.SimpleDateFormat;
-import java.util.Date;
+import java.time.LocalDate;
+import java.time.format.DateTimeFormatter;
+import org.apache.zest.api.entity.EntityBuilder;
import org.apache.zest.api.query.QueryBuilderFactory;
import org.apache.zest.api.service.ServiceFinder;
-import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Rule;
-import org.junit.rules.TestName;
-import org.apache.zest.api.entity.EntityBuilder;
import org.apache.zest.api.service.ServiceReference;
import org.apache.zest.api.structure.Application;
import org.apache.zest.api.structure.Module;
import org.apache.zest.api.unitofwork.UnitOfWork;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
import org.apache.zest.api.usecase.Usecase;
import org.apache.zest.api.usecase.UsecaseBuilder;
import org.apache.zest.api.value.ValueBuilder;
@@ -57,12 +51,19 @@ import org.apache.zest.sample.dcicargo.sample_b.data.structure.voyage.Voyage;
import org.apache.zest.sample.dcicargo.sample_b.data.structure.voyage.VoyageNumber;
import org.apache.zest.sample.dcicargo.sample_b.infrastructure.dci.Context;
import org.apache.zest.sample.dcicargo.sample_b.infrastructure.testing.ExpectedException;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Rule;
+import org.junit.rules.TestName;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
/**
* Base class for testing Context Interactions
@@ -81,32 +82,32 @@ public class TestApplication
protected static RouteSpecificationFactoryService routeSpecFactory;
- final protected static Date TODAY = new Date();
- final protected static Date DAY1 = day( 1 );
- final protected static Date DAY2 = day( 2 );
- final protected static Date DAY3 = day( 3 );
- final protected static Date DAY4 = day( 4 );
- final protected static Date DAY5 = day( 5 );
- final protected static Date DAY6 = day( 6 );
- final protected static Date DAY7 = day( 7 );
- final protected static Date DAY8 = day( 8 );
- final protected static Date DAY9 = day( 9 );
- final protected static Date DAY10 = day( 10 );
- final protected static Date DAY11 = day( 11 );
- final protected static Date DAY12 = day( 12 );
- final protected static Date DAY13 = day( 13 );
- final protected static Date DAY14 = day( 14 );
- final protected static Date DAY15 = day( 15 );
- final protected static Date DAY16 = day( 16 );
- final protected static Date DAY17 = day( 17 );
- final protected static Date DAY18 = day( 18 );
- final protected static Date DAY19 = day( 19 );
- final protected static Date DAY20 = day( 20 );
- final protected static Date DAY21 = day( 21 );
- final protected static Date DAY22 = day( 22 );
- final protected static Date DAY23 = day( 23 );
- final protected static Date DAY24 = day( 24 );
- final protected static Date DAY25 = day( 25 );
+ final protected static LocalDate TODAY = LocalDate.now();
+ final protected static LocalDate DAY1 = day( 1 );
+ final protected static LocalDate DAY2 = day( 2 );
+ final protected static LocalDate DAY3 = day( 3 );
+ final protected static LocalDate DAY4 = day( 4 );
+ final protected static LocalDate DAY5 = day( 5 );
+ final protected static LocalDate DAY6 = day( 6 );
+ final protected static LocalDate DAY7 = day( 7 );
+ final protected static LocalDate DAY8 = day( 8 );
+ final protected static LocalDate DAY9 = day( 9 );
+ final protected static LocalDate DAY10 = day( 10 );
+ final protected static LocalDate DAY11 = day( 11 );
+ final protected static LocalDate DAY12 = day( 12 );
+ final protected static LocalDate DAY13 = day( 13 );
+ final protected static LocalDate DAY14 = day( 14 );
+ final protected static LocalDate DAY15 = day( 15 );
+ final protected static LocalDate DAY16 = day( 16 );
+ final protected static LocalDate DAY17 = day( 17 );
+ final protected static LocalDate DAY18 = day( 18 );
+ final protected static LocalDate DAY19 = day( 19 );
+ final protected static LocalDate DAY20 = day( 20 );
+ final protected static LocalDate DAY21 = day( 21 );
+ final protected static LocalDate DAY22 = day( 22 );
+ final protected static LocalDate DAY23 = day( 23 );
+ final protected static LocalDate DAY24 = day( 24 );
+ final protected static LocalDate DAY25 = day( 25 );
protected static Voyage V201;
protected static Voyage V202;
@@ -119,8 +120,8 @@ public class TestApplication
final protected static boolean arrived = true;
final protected static boolean directed = false;
final protected static boolean misdirected = true;
- final protected static Date unknownETA = null;
- final protected static Date noSpecificDate = null;
+ final protected static LocalDate unknownETA = null;
+ final protected static LocalDate noSpecificDate = null;
final protected static Integer leg1 = 0;
final protected static Integer leg2 = 1;
final protected static Integer leg3 = 2;
@@ -129,8 +130,8 @@ public class TestApplication
final protected static Integer unknownLeg = 0;
final protected static NextHandlingEvent unknownNextHandlingEvent = null;
- protected Date deadline;
- protected Date arrival;
+ protected LocalDate deadline;
+ protected LocalDate arrival;
protected RouteSpecification routeSpec;
protected RouteSpecification newRouteSpec;
protected Delivery delivery;
@@ -327,7 +328,7 @@ public class TestApplication
public void assertDelivery( HandlingEventType handlingEventType,
Location location,
- Date completion,
+ LocalDate completionDate,
Voyage voyage,
TransportStatus transportStatus,
@@ -335,12 +336,12 @@ public class TestApplication
RoutingStatus routingStatus,
Boolean isMisdirected,
- Date eta,
+ LocalDate eta,
Integer itineraryProgress,
HandlingEventType nextHandlingEventType,
Location nextLocation,
- Date nextTime,
+ LocalDate nextTime,
Voyage nextVoyage
) throws Exception
{
@@ -348,14 +349,14 @@ public class TestApplication
// Last handling event
if (delivery.lastHandlingEvent().get() != null
- || handlingEventType != null || location != null || completion != null || voyage != null)
+ || handlingEventType != null || location != null || completionDate != null || voyage != null)
{
assertThat( "lastHandlingEvent - handlingEventType",
delivery.lastHandlingEvent().get().handlingEventType().get(), is( equalTo( handlingEventType ) ) );
assertThat( "lastHandlingEvent - location",
delivery.lastHandlingEvent().get().location().get(), is( equalTo( location ) ) );
- assertThat( "lastHandlingEvent - completionTime",
- delivery.lastHandlingEvent().get().completionTime().get(), is( equalTo( completion ) ) );
+ assertThat( "lastHandlingEvent - completionDate",
+ delivery.lastHandlingEvent().get().completionDate().get(), is( equalTo( completionDate ) ) );
assertThat( "lastHandlingEvent - voyage",
delivery.lastHandlingEvent().get().voyage().get(), is( equalTo( voyage ) ) );
}
@@ -392,17 +393,16 @@ public class TestApplication
delivery.nextHandlingEvent().get().location().get(), is( equalTo( nextLocation ) ) );
- if (delivery.nextHandlingEvent().get().time().get() != null)
+ if ( delivery.nextHandlingEvent().get().date().get() != null)
{
// Estimating a new carrier arrival time might be calculated a second
// after initial dates are set, so we skip the seconds
- SimpleDateFormat parser = new SimpleDateFormat( "yyyy-MM-dd HH:mm" );
- String calculatedTime = parser.format( delivery.nextHandlingEvent().get().time().get() );
- String expectedTime = parser.format( nextTime );
+ String calculatedTime = delivery.nextHandlingEvent().get().date().get().toString();
+ String expectedTime = nextTime.toString();
assertThat( "nextHandlingEvent - time", calculatedTime, is( equalTo( expectedTime ) ) );
}
else
- assertThat( "nextHandlingEvent - time", delivery.nextHandlingEvent().get().time().get(), is( equalTo( nextTime ) ) );
+ assertThat( "nextHandlingEvent - time", delivery.nextHandlingEvent().get().date().get(), is( equalTo( nextTime ) ) );
assertThat( "nextHandlingEvent - voyage",
delivery.nextHandlingEvent().get().voyage().get(), is( equalTo( nextVoyage ) ) );
@@ -412,7 +412,7 @@ public class TestApplication
public void assertDelivery( HandlingEventType handlingEventType,
Location location,
- Date completion,
+ LocalDate completionDate,
Voyage voyage,
TransportStatus transportStatus,
@@ -420,18 +420,18 @@ public class TestApplication
RoutingStatus routingStatus,
Boolean isMisdirected,
- Date eta,
+ LocalDate eta,
Integer itineraryProgress,
NextHandlingEvent noNextHandlingEvent
) throws Exception
{
- assertDelivery( handlingEventType, location, completion, voyage,
+ assertDelivery( handlingEventType, location, completionDate, voyage,
transportStatus, isUnloadedAtDestination, routingStatus, isMisdirected, eta,
itineraryProgress, null, null, null, null );
}
- public void assertRouteSpec( Location origin, Location destination, Date earliestDeparture, Date deadline )
+ public void assertRouteSpec( Location origin, Location destination, LocalDate earliestDeparture, LocalDate deadline )
{
newRouteSpec = cargo.routeSpecification().get();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/booking/routing/AssignCargoToRouteTest.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/booking/routing/AssignCargoToRouteTest.java b/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/booking/routing/AssignCargoToRouteTest.java
index 13a976b..9c38ae6 100644
--- a/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/booking/routing/AssignCargoToRouteTest.java
+++ b/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/booking/routing/AssignCargoToRouteTest.java
@@ -19,7 +19,7 @@
*/
package org.apache.zest.sample.dcicargo.sample_b.context.test.booking.routing;
-import java.util.Date;
+import java.time.LocalDate;
import org.junit.Before;
import org.junit.Test;
import org.apache.zest.api.unitofwork.UnitOfWork;
@@ -49,7 +49,7 @@ import static org.apache.zest.sample.dcicargo.sample_b.data.structure.handling.H
*/
public class AssignCargoToRouteTest extends TestApplication
{
- static Itinerary itinerary2;
+ private static Itinerary itinerary2;
private HandlingEventAggregateRoot HANDLING_EVENTS;
@Before
@@ -62,7 +62,7 @@ public class AssignCargoToRouteTest extends TestApplication
CargoAggregateRoot CARGOS = uow.get( CargoAggregateRoot.class, CargoAggregateRoot.CARGOS_ID );
// Create new cargo
- routeSpec = routeSpecFactory.build( HONGKONG, STOCKHOLM, new Date(), deadline = DAY24 );
+ routeSpec = routeSpecFactory.build( HONGKONG, STOCKHOLM, LocalDate.now(), deadline = DAY24 );
delivery = delivery( TODAY, NOT_RECEIVED, NOT_ROUTED, unknownLeg );
cargo = CARGOS.createCargo( routeSpec, delivery, "ABC" );
trackingId = cargo.trackingId().get();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectArrivedCargoTest.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectArrivedCargoTest.java b/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectArrivedCargoTest.java
index 03e70c7..1661406 100644
--- a/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectArrivedCargoTest.java
+++ b/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectArrivedCargoTest.java
@@ -19,7 +19,7 @@
*/
package org.apache.zest.sample.dcicargo.sample_b.context.test.handling.inspection.event;
-import java.util.Date;
+import java.time.LocalDate;
import org.junit.Before;
import org.junit.Test;
import org.apache.zest.api.unitofwork.UnitOfWork;
@@ -55,7 +55,7 @@ public class InspectArrivedCargoTest extends TestApplication
CargoAggregateRoot CARGOS = uow.get( CargoAggregateRoot.class, CargoAggregateRoot.CARGOS_ID );
// Create new cargo
- routeSpec = routeSpecFactory.build( HONGKONG, STOCKHOLM, new Date(), deadline = DAY24 );
+ routeSpec = routeSpecFactory.build( HONGKONG, STOCKHOLM, LocalDate.now(), deadline = DAY24 );
delivery = delivery( TODAY, IN_PORT, ROUTED, leg5 );
cargo = CARGOS.createCargo( routeSpec, delivery, "Arrived_CARGO" );
trackingId = cargo.trackingId().get();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectCargoInCustomsTest.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectCargoInCustomsTest.java b/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectCargoInCustomsTest.java
index 4b6fe7c..44c931e 100644
--- a/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectCargoInCustomsTest.java
+++ b/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectCargoInCustomsTest.java
@@ -19,7 +19,7 @@
*/
package org.apache.zest.sample.dcicargo.sample_b.context.test.handling.inspection.event;
-import java.util.Date;
+import java.time.LocalDate;
import org.junit.Before;
import org.junit.Test;
import org.apache.zest.api.unitofwork.UnitOfWork;
@@ -54,7 +54,7 @@ public class InspectCargoInCustomsTest extends TestApplication
CargoAggregateRoot CARGOS = uow.get( CargoAggregateRoot.class, CargoAggregateRoot.CARGOS_ID );
// Create new cargo
- routeSpec = routeSpecFactory.build( HONGKONG, STOCKHOLM, new Date(), deadline = DAY24 );
+ routeSpec = routeSpecFactory.build( HONGKONG, STOCKHOLM, LocalDate.now(), deadline = DAY24 );
delivery = delivery( TODAY, IN_PORT, ROUTED, leg1 );
cargo = CARGOS.createCargo( routeSpec, delivery, "CARGO_in_customs" );
trackingId = cargo.trackingId().get();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectClaimedCargoTest.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectClaimedCargoTest.java b/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectClaimedCargoTest.java
index 81a0218..570b3f7 100644
--- a/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectClaimedCargoTest.java
+++ b/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectClaimedCargoTest.java
@@ -19,14 +19,14 @@
*/
package org.apache.zest.sample.dcicargo.sample_b.context.test.handling.inspection.event;
-import java.util.Date;
-import org.junit.Before;
-import org.junit.Test;
+import java.time.LocalDate;
import org.apache.zest.api.unitofwork.UnitOfWork;
import org.apache.zest.sample.dcicargo.sample_b.bootstrap.test.TestApplication;
import org.apache.zest.sample.dcicargo.sample_b.context.interaction.handling.inspection.event.InspectClaimedCargo;
import org.apache.zest.sample.dcicargo.sample_b.data.aggregateroot.CargoAggregateRoot;
import org.apache.zest.sample.dcicargo.sample_b.data.aggregateroot.HandlingEventAggregateRoot;
+import org.junit.Before;
+import org.junit.Test;
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;
@@ -52,7 +52,7 @@ public class InspectClaimedCargoTest extends TestApplication
CargoAggregateRoot CARGOS = uow.get( CargoAggregateRoot.class, CargoAggregateRoot.CARGOS_ID );
// Create new cargo
- routeSpec = routeSpecFactory.build( HONGKONG, STOCKHOLM, new Date(), deadline = DAY24 );
+ routeSpec = routeSpecFactory.build( HONGKONG, STOCKHOLM, LocalDate.now(),deadline = DAY24 );
delivery = delivery( TODAY, IN_PORT, ROUTED, leg1 );
cargo = CARGOS.createCargo( routeSpec, delivery, "Claimed_CARGO" );
trackingId = cargo.trackingId().get();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectLoadedCargoTest.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectLoadedCargoTest.java b/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectLoadedCargoTest.java
index 09cc757..2dd657a 100644
--- a/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectLoadedCargoTest.java
+++ b/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectLoadedCargoTest.java
@@ -19,7 +19,7 @@
*/
package org.apache.zest.sample.dcicargo.sample_b.context.test.handling.inspection.event;
-import java.util.Date;
+import java.time.LocalDate;
import org.junit.Before;
import org.junit.Test;
import org.apache.zest.api.unitofwork.UnitOfWork;
@@ -430,7 +430,7 @@ public class InspectLoadedCargoTest extends TestApplication
Leg currentCarrierMovement = itinerary.leg( delivery.itineraryProgressIndex().get() );
assertThat( currentCarrierMovement.unloadLocation().get(), is( equalTo( DALLAS ) ) );
- assertThat( currentCarrierMovement.unloadTime().get(), is( equalTo( DAY8 ) ) );
+ assertThat( currentCarrierMovement.unloadDate().get(), is( equalTo( DAY8 ) ) );
assertThat( currentCarrierMovement.voyage().get(), is( equalTo( V202 ) ) );
assertDelivery( LOAD, NEWYORK, DAY7, V202,
@@ -446,7 +446,7 @@ public class InspectLoadedCargoTest extends TestApplication
success_Load();
// Risk zone destination
- routeSpec = routeSpecFactory.build( HANGZHOU, ROTTERDAM, new Date(), deadline = DAY24 );
+ routeSpec = routeSpecFactory.build( HANGZHOU, ROTTERDAM, LocalDate.now(),deadline = DAY24 );
delivery = delivery( TODAY, ONBOARD_CARRIER, ROUTED, leg1 );
cargo = CARGOS.createCargo( routeSpec, delivery, "Naive" );
trackingId = cargo.trackingId().get();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectReceivedCargoTest.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectReceivedCargoTest.java b/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectReceivedCargoTest.java
index 3ea6dfe..1d7b2d8 100644
--- a/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectReceivedCargoTest.java
+++ b/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectReceivedCargoTest.java
@@ -275,7 +275,7 @@ public class InspectReceivedCargoTest extends TestApplication
// Itinerary calculations
NextHandlingEvent nextLoad = cargo.delivery().get().nextHandlingEvent().get();
assertThat( nextLoad.location().get(), is( equalTo( itinerary.firstLeg().loadLocation().get() ) ) );
- assertThat( nextLoad.time().get(), is( equalTo( itinerary.firstLeg().loadTime().get() ) ) );
+ assertThat( nextLoad.date().get(), is( equalTo( itinerary.firstLeg().loadDate().get() ) ) );
assertThat( nextLoad.voyage().get(), is( equalTo( itinerary.firstLeg().voyage().get() ) ) );
assertDelivery( RECEIVE, HONGKONG, DAY1, noVoyage,
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectUnhandledCargoTest.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectUnhandledCargoTest.java b/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectUnhandledCargoTest.java
index 30fb843..2697b36 100644
--- a/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectUnhandledCargoTest.java
+++ b/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectUnhandledCargoTest.java
@@ -19,7 +19,7 @@
*/
package org.apache.zest.sample.dcicargo.sample_b.context.test.handling.inspection.event;
-import java.util.Date;
+import java.time.LocalDate;
import org.junit.Before;
import org.junit.Test;
import org.apache.zest.api.unitofwork.UnitOfWork;
@@ -54,7 +54,7 @@ public class InspectUnhandledCargoTest extends TestApplication
CargoAggregateRoot CARGOS = uow.get( CargoAggregateRoot.class, CargoAggregateRoot.CARGOS_ID );
// Create new cargo
- routeSpec = routeSpecFactory.build( HONGKONG, STOCKHOLM, new Date(), deadline = DAY24 );
+ routeSpec = routeSpecFactory.build( HONGKONG, STOCKHOLM, LocalDate.now(), deadline = DAY24 );
delivery = delivery( TODAY, NOT_RECEIVED, NOT_ROUTED, leg1 );
cargo = CARGOS.createCargo( routeSpec, delivery, "Claimed_CARGO" );
trackingId = cargo.trackingId().get();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectUnloadedCargoTest.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectUnloadedCargoTest.java b/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectUnloadedCargoTest.java
index c05b5cd..3c7d7a0 100644
--- a/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectUnloadedCargoTest.java
+++ b/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/inspection/event/InspectUnloadedCargoTest.java
@@ -19,7 +19,7 @@
*/
package org.apache.zest.sample.dcicargo.sample_b.context.test.handling.inspection.event;
-import java.util.Date;
+import java.time.LocalDate;
import org.junit.Before;
import org.junit.Test;
import org.apache.zest.api.unitofwork.UnitOfWork;
@@ -62,7 +62,7 @@ public class InspectUnloadedCargoTest extends TestApplication
CargoAggregateRoot CARGOS = uow.get( CargoAggregateRoot.class, CargoAggregateRoot.CARGOS_ID );
// Create new cargo
- routeSpec = routeSpecFactory.build( HONGKONG, STOCKHOLM, new Date(), deadline = DAY24 );
+ routeSpec = routeSpecFactory.build( HONGKONG, STOCKHOLM, LocalDate.now(), deadline = DAY24 );
delivery = delivery( TODAY, ONBOARD_CARRIER, ROUTED, leg1 );
cargo = CARGOS.createCargo( routeSpec, delivery, "Unloaded_CARGO" );
trackingId = cargo.trackingId().get();
@@ -334,7 +334,7 @@ public class InspectUnloadedCargoTest extends TestApplication
// Itinerary should have progressed to leg 5
Leg nextCarrierMovement = itinerary.leg( cargo.delivery().get().itineraryProgressIndex().get() );
assertThat( nextCarrierMovement.loadLocation().get(), is( equalTo( ROTTERDAM ) ) );
- assertThat( nextCarrierMovement.loadTime().get(), is( equalTo( DAY20 ) ) );
+ assertThat( nextCarrierMovement.loadDate().get(), is( equalTo( DAY20 ) ) );
assertThat( nextCarrierMovement.voyage().get(), is( equalTo( V203 ) ) );
assertDelivery( UNLOAD, ROTTERDAM, DAY17, V202,
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/parsing/ParseHandlingEventDataTest.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/parsing/ParseHandlingEventDataTest.java b/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/parsing/ParseHandlingEventDataTest.java
index 0c0c574..751bd11 100644
--- a/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/parsing/ParseHandlingEventDataTest.java
+++ b/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/parsing/ParseHandlingEventDataTest.java
@@ -19,8 +19,8 @@
*/
package org.apache.zest.sample.dcicargo.sample_b.context.test.handling.parsing;
-import java.text.SimpleDateFormat;
-import java.util.Date;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
import org.junit.Before;
import org.junit.Test;
import org.apache.zest.api.constraint.ConstraintViolationException;
@@ -39,8 +39,8 @@ import static org.apache.zest.sample.dcicargo.sample_b.data.structure.delivery.T
*/
public class ParseHandlingEventDataTest extends TestApplication
{
- static ParseHandlingEventData handlingEventParser;
- static String completionTime;
+ private static ParseHandlingEventData handlingEventParser;
+ private static String completionDate;
@Before
public void prepareTest()
@@ -52,13 +52,13 @@ public class ParseHandlingEventDataTest extends TestApplication
CargoAggregateRoot CARGOS = uow.get( CargoAggregateRoot.class, CargoAggregateRoot.CARGOS_ID );
// Create new cargo
- routeSpec = routeSpecFactory.build( HONGKONG, STOCKHOLM, new Date(), deadline = DAY24 );
+ routeSpec = routeSpecFactory.build( HONGKONG, STOCKHOLM, LocalDate.now(), deadline = DAY24 );
delivery = delivery( TODAY, NOT_RECEIVED, ROUTED, unknownLeg );
cargo = CARGOS.createCargo( routeSpec, delivery, "ABC" );
trackingId = cargo.trackingId().get();
trackingIdString = trackingId.id().get();
cargo.itinerary().set( itinerary );
- completionTime = new SimpleDateFormat( "yyyy-MM-dd HH:mm" ).format( new Date() );
+ completionDate = LocalDate.now().toString();
// Start ParseHandlingEventData service
ServiceReference<ParseHandlingEventData> ParseHandlingEventDataRef =
@@ -81,7 +81,7 @@ public class ParseHandlingEventDataTest extends TestApplication
throws Exception
{
thrown.expect( ConstraintViolationException.class, "constraint \"not optional(param2)\", for value 'null'" );
- handlingEventParser.parse( completionTime, null, "RECEIVE", "CNHKG", null );
+ handlingEventParser.parse( completionDate, null, "RECEIVE", "CNHKG", null );
}
// etc...
@@ -91,7 +91,7 @@ public class ParseHandlingEventDataTest extends TestApplication
throws Exception
{
// No voyage number string is ok
- handlingEventParser.parse( completionTime, trackingIdString, "RECEIVE", "CNHKG", null );
+ handlingEventParser.parse( completionDate, trackingIdString, "RECEIVE", "CNHKG", null );
}
// Empty
@@ -109,7 +109,7 @@ public class ParseHandlingEventDataTest extends TestApplication
throws Exception
{
// Empty voyage number string is ok
- handlingEventParser.parse( completionTime, trackingIdString, "RECEIVE", "CNHKG", " " );
+ handlingEventParser.parse( completionDate, trackingIdString, "RECEIVE", "CNHKG", " " );
}
// Basic type conversion
@@ -128,7 +128,7 @@ public class ParseHandlingEventDataTest extends TestApplication
throws Exception
{
thrown.expect( InvalidHandlingEventDataException.class, "No enum const" );
- handlingEventParser.parse( completionTime, trackingIdString, "HAND_OVER", "CNHKG", null );
+ handlingEventParser.parse( completionDate, trackingIdString, "HAND_OVER", "CNHKG", null );
}
// Successful parsing
@@ -137,6 +137,6 @@ public class ParseHandlingEventDataTest extends TestApplication
public void success_Parsing()
throws Exception
{
- handlingEventParser.parse( completionTime, trackingIdString, "RECEIVE", "CNHKG", null );
+ handlingEventParser.parse( completionDate, trackingIdString, "RECEIVE", "CNHKG", null );
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/registration/RegisterHandlingEventTest.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/registration/RegisterHandlingEventTest.java b/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/registration/RegisterHandlingEventTest.java
index f496136..acf47e6 100644
--- a/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/registration/RegisterHandlingEventTest.java
+++ b/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/registration/RegisterHandlingEventTest.java
@@ -19,9 +19,7 @@
*/
package org.apache.zest.sample.dcicargo.sample_b.context.test.handling.registration;
-import java.util.Date;
-import org.junit.Before;
-import org.junit.Test;
+import java.time.LocalDate;
import org.apache.zest.api.query.Query;
import org.apache.zest.api.unitofwork.UnitOfWork;
import org.apache.zest.sample.dcicargo.sample_b.bootstrap.test.TestApplication;
@@ -37,6 +35,8 @@ import org.apache.zest.sample.dcicargo.sample_b.data.aggregateroot.CargoAggregat
import org.apache.zest.sample.dcicargo.sample_b.data.aggregateroot.HandlingEventAggregateRoot;
import org.apache.zest.sample.dcicargo.sample_b.data.entity.HandlingEventEntity;
import org.apache.zest.sample.dcicargo.sample_b.data.structure.handling.HandlingEvent;
+import org.junit.Before;
+import org.junit.Test;
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;
@@ -67,7 +67,7 @@ public class RegisterHandlingEventTest extends TestApplication
CargoAggregateRoot CARGOS = uow.get( CargoAggregateRoot.class, CargoAggregateRoot.CARGOS_ID );
// Create new cargo
- routeSpec = routeSpecFactory.build( HONGKONG, STOCKHOLM, new Date(), deadline = DAY24 );
+ routeSpec = routeSpecFactory.build( HONGKONG, STOCKHOLM, LocalDate.now(), deadline = DAY24 );
delivery = delivery( TODAY, NOT_RECEIVED, ROUTED, unknownLeg );
cargo = CARGOS.createCargo( routeSpec, delivery, "ABC" );
cargo.itinerary().set( itinerary );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/samples/forum/src/main/java/org/apache/zest/sample/forum/context/view/ViewPost.java
----------------------------------------------------------------------
diff --git a/samples/forum/src/main/java/org/apache/zest/sample/forum/context/view/ViewPost.java b/samples/forum/src/main/java/org/apache/zest/sample/forum/context/view/ViewPost.java
index 203bae6..7480607 100644
--- a/samples/forum/src/main/java/org/apache/zest/sample/forum/context/view/ViewPost.java
+++ b/samples/forum/src/main/java/org/apache/zest/sample/forum/context/view/ViewPost.java
@@ -19,7 +19,7 @@
*/
package org.apache.zest.sample.forum.context.view;
-import java.util.Date;
+import java.time.Instant;
import org.apache.zest.api.injection.scope.Structure;
import org.apache.zest.api.injection.scope.Uses;
import org.apache.zest.api.property.Numbers;
@@ -33,12 +33,12 @@ import org.apache.zest.sample.forum.data.entity.User;
/**
* TODO
*/
-public class ViewPost
+class ViewPost
implements ResourceIndex<Post>
{
- PostView viewPost = new PostView();
- ReplyTopic replyTopic = new ReplyTopic();
- Poster poster = new Poster();
+ private PostView viewPost = new PostView();
+ private ReplyTopic replyTopic = new ReplyTopic();
+ private Poster poster = new Poster();
public ViewPost bind( @Uses Topic topic, @Uses Post post, @Uses User user )
{
@@ -59,18 +59,18 @@ public class ViewPost
return replyTopic.reply( message, viewPost );
}
- protected class ReplyTopic
+ private class ReplyTopic
extends Role<Topic>
{
@Structure
UnitOfWorkFactory uowf;
- public Post reply( String message, PostView viewPost )
+ Post reply( String message, PostView viewPost )
{
Post post = uowf.currentUnitOfWork().newEntity( Post.class );
post.message().set( message );
post.createdBy().set( poster.self() );
- post.createdOn().set( new Date( uowf.currentUnitOfWork().currentTime() ) );
+ post.createdOn().set( Instant.ofEpochMilli( uowf.currentUnitOfWork().currentTime()) );
post.replyTo().set( viewPost.self() );
self().lastPost().set( post );
@@ -80,12 +80,12 @@ public class ViewPost
}
}
- protected class PostView
+ private class PostView
extends Role<Post>
{
}
- protected class Poster
+ private class Poster
extends Role<User>
{
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/samples/forum/src/main/java/org/apache/zest/sample/forum/data/entity/Post.java
----------------------------------------------------------------------
diff --git a/samples/forum/src/main/java/org/apache/zest/sample/forum/data/entity/Post.java b/samples/forum/src/main/java/org/apache/zest/sample/forum/data/entity/Post.java
index dc1bee1..67a56b4 100644
--- a/samples/forum/src/main/java/org/apache/zest/sample/forum/data/entity/Post.java
+++ b/samples/forum/src/main/java/org/apache/zest/sample/forum/data/entity/Post.java
@@ -19,7 +19,7 @@
*/
package org.apache.zest.sample.forum.data.entity;
-import java.util.Date;
+import java.time.Instant;
import org.apache.zest.api.association.Association;
import org.apache.zest.api.common.Optional;
import org.apache.zest.api.entity.EntityComposite;
@@ -50,5 +50,5 @@ public interface Post
Property<User> createdBy();
- Property<Date> createdOn();
+ Property<Instant> createdOn();
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/samples/rental/src/main/java/org/apache/zest/sample/rental/domain/Booking.java
----------------------------------------------------------------------
diff --git a/samples/rental/src/main/java/org/apache/zest/sample/rental/domain/Booking.java b/samples/rental/src/main/java/org/apache/zest/sample/rental/domain/Booking.java
index 11cd3cd..4499171 100644
--- a/samples/rental/src/main/java/org/apache/zest/sample/rental/domain/Booking.java
+++ b/samples/rental/src/main/java/org/apache/zest/sample/rental/domain/Booking.java
@@ -20,7 +20,7 @@
package org.apache.zest.sample.rental.domain;
-import java.util.Date;
+import java.time.Instant;
import org.apache.zest.api.association.Association;
import org.apache.zest.api.common.Optional;
import org.apache.zest.api.entity.EntityComposite;
@@ -39,9 +39,9 @@ public interface Booking
@Optional
// if not set, the pickup has not occurred yet.
- Property<Date> pickedupTime();
+ Property<Instant> pickedupTime();
@Optional
// if not set, the return has not occurred yet.
- Property<Date> returnedTime();
+ Property<Instant> returnedTime();
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/samples/rental/src/main/java/org/apache/zest/sample/rental/domain/Car.java
----------------------------------------------------------------------
diff --git a/samples/rental/src/main/java/org/apache/zest/sample/rental/domain/Car.java b/samples/rental/src/main/java/org/apache/zest/sample/rental/domain/Car.java
index 7eea948..a0faa04 100644
--- a/samples/rental/src/main/java/org/apache/zest/sample/rental/domain/Car.java
+++ b/samples/rental/src/main/java/org/apache/zest/sample/rental/domain/Car.java
@@ -20,7 +20,7 @@
package org.apache.zest.sample.rental.domain;
-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.entity.EntityComposite;
@@ -39,10 +39,10 @@ public interface Car
Association<CarCategory> category();
@Optional
- Property<Date> purchasedDate();
+ Property<LocalDate> purchasedDate();
@Optional
- Property<Date> soldDate();
+ Property<LocalDate> soldDate();
Booking currentBooking();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/samples/rental/src/main/java/org/apache/zest/sample/rental/domain/Period.java
----------------------------------------------------------------------
diff --git a/samples/rental/src/main/java/org/apache/zest/sample/rental/domain/Period.java b/samples/rental/src/main/java/org/apache/zest/sample/rental/domain/Period.java
index 308f1f3..bff5564 100644
--- a/samples/rental/src/main/java/org/apache/zest/sample/rental/domain/Period.java
+++ b/samples/rental/src/main/java/org/apache/zest/sample/rental/domain/Period.java
@@ -20,14 +20,14 @@
package org.apache.zest.sample.rental.domain;
-import java.util.Date;
+import java.time.LocalDate;
import org.apache.zest.api.property.Property;
import org.apache.zest.api.value.ValueComposite;
public interface Period
extends ValueComposite
{
- Property<Date> startOfPeriod();
+ Property<LocalDate> startOfPeriod();
- Property<Date> endOfPeriod();
+ Property<LocalDate> endOfPeriod();
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/samples/rental/src/main/java/org/apache/zest/sample/rental/domain/RentalShop.java
----------------------------------------------------------------------
diff --git a/samples/rental/src/main/java/org/apache/zest/sample/rental/domain/RentalShop.java b/samples/rental/src/main/java/org/apache/zest/sample/rental/domain/RentalShop.java
index d8a75e9..def525e 100644
--- a/samples/rental/src/main/java/org/apache/zest/sample/rental/domain/RentalShop.java
+++ b/samples/rental/src/main/java/org/apache/zest/sample/rental/domain/RentalShop.java
@@ -22,10 +22,12 @@ package org.apache.zest.sample.rental.domain;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
-import java.util.Date;
+import java.time.Instant;
+import java.time.LocalDate;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
+import java.util.stream.Collectors;
import org.apache.zest.api.association.ManyAssociation;
import org.apache.zest.api.entity.EntityBuilder;
import org.apache.zest.api.entity.EntityComposite;
@@ -55,13 +57,13 @@ public interface RentalShop
Booking book( Customer customer, Car car, Period plannedPeriod );
- void pickup( Booking booking, Date time );
+ void pickup( Booking booking, Instant time );
- void returned( Booking booking, Date time );
+ void returned( Booking booking, Instant time );
- void boughtCar( Car car, Date purchasedate );
+ void boughtCar( Car car, LocalDate purchasedate );
- void soldCar( Car car, Date soldDate );
+ void soldCar( Car car, LocalDate soldDate );
Car createCar( String category, String modelName, String licensePlate );
@@ -143,12 +145,11 @@ public interface RentalShop
public Set<String> findAllCarModels()
{
- HashSet<String> result = new HashSet<String>();
- for( Car car : state.carsOwned().toList() )
- {
- result.add( car.model().get() );
- }
- return result;
+ return state.carsOwned()
+ .toList()
+ .stream()
+ .map( car -> car.model().get() )
+ .collect( Collectors.toSet() );
}
public Booking book( Customer customer, Car car, Period plannedPeriod )
@@ -161,7 +162,7 @@ public interface RentalShop
MessageDigest md;
md = MessageDigest.getInstance( "MD5" );
md.update( instance.identity().get().getBytes() );
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
byte[] data = md.digest();
for( int i = 0; i < 4; i++ )
{
@@ -192,23 +193,23 @@ public interface RentalShop
return booking;
}
- public void pickup( Booking booking, Date time )
+ public void pickup( Booking booking, Instant time )
{
booking.pickedupTime().set( time );
}
- public void returned( Booking booking, Date time )
+ public void returned( Booking booking, Instant time )
{
booking.returnedTime().set( time );
}
- public void boughtCar( Car car, Date purchaseDate )
+ public void boughtCar( Car car, LocalDate purchaseDate )
{
state.carsOwned().add( car );
car.purchasedDate().set( purchaseDate );
}
- public void soldCar( Car car, Date soldDate )
+ public void soldCar( Car car, LocalDate soldDate )
{
state.carsOwned().remove( car );
car.soldDate().set( soldDate );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/samples/rental/src/main/java/org/apache/zest/sample/rental/domain/dev/InitialData.java
----------------------------------------------------------------------
diff --git a/samples/rental/src/main/java/org/apache/zest/sample/rental/domain/dev/InitialData.java b/samples/rental/src/main/java/org/apache/zest/sample/rental/domain/dev/InitialData.java
index 2ef7738..37ce428 100644
--- a/samples/rental/src/main/java/org/apache/zest/sample/rental/domain/dev/InitialData.java
+++ b/samples/rental/src/main/java/org/apache/zest/sample/rental/domain/dev/InitialData.java
@@ -20,9 +20,9 @@
package org.apache.zest.sample.rental.domain.dev;
+import java.time.LocalDate;
import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Date;
+import java.util.Random;
import org.apache.zest.api.composite.TransientComposite;
import org.apache.zest.api.injection.scope.Structure;
import org.apache.zest.api.mixin.Mixins;
@@ -44,12 +44,16 @@ public interface InitialData
abstract class Mixin
implements DataInitializer
{
+ private static final Random random = new Random();
+
@Structure
UnitOfWorkFactory uowf;
+
@Structure
ValueBuilderFactory vbf;
- private ArrayList<Customer> customers = new ArrayList<Customer>();
- private ArrayList<Car> cars = new ArrayList<Car>();
+
+ private ArrayList<Customer> customers = new ArrayList<>();
+ private ArrayList<Car> cars = new ArrayList<>();
public void initialize()
throws Exception
@@ -108,22 +112,12 @@ public interface InitialData
private Period createRandomPeriod()
{
- Calendar cal = Calendar.getInstance();
- cal.setTime( new Date() );
- cal.add( Calendar.DATE, Math.abs( (int) ( Math.random() * 5.0 ) ) );
- cal.set( Calendar.HOUR_OF_DAY, 15 );
- cal.set( Calendar.MINUTE, 0 );
- cal.set( Calendar.SECOND, 0 );
- Date earliestPickup = cal.getTime();
-
- cal.add( Calendar.DATE, Math.abs( (int) ( Math.random() * 30.0 ) ) );
- cal.set( Calendar.HOUR_OF_DAY, 12 );
- cal.set( Calendar.MINUTE, 0 );
- cal.set( Calendar.SECOND, 0 );
- Date latestReturn = cal.getTime();
+ LocalDate start = LocalDate.now().plusDays( random.nextInt( 5));
+ LocalDate end = start.plusDays( random.nextInt(30));
+
ValueBuilder<Period> builder = vbf.newValueBuilder( Period.class );
- builder.prototype().startOfPeriod().set( earliestPickup );
- builder.prototype().endOfPeriod().set( latestReturn );
+ builder.prototype().startOfPeriod().set( start );
+ builder.prototype().endOfPeriod().set( end );
return builder.newInstance();
}
@@ -143,58 +137,63 @@ public interface InitialData
{
Car car;
car = shop.createCar( "SUV", "Volvo XC90", "WHO 7878" );
- shop.boughtCar( car, new Date() );
+ shop.boughtCar( car, randomPastDate() );
cars.add( car );
car = shop.createCar( "SUV", "BMW X5", "WIT 23" );
- shop.boughtCar( car, new Date() );
+ shop.boughtCar( car, randomPastDate() );
cars.add( car );
car = shop.createCar( "SUV", "Volvo XC90", "WHO 7879" );
- shop.boughtCar( car, new Date() );
+ shop.boughtCar( car, randomPastDate() );
cars.add( car );
car = shop.createCar( "SUV", "Volvo XC90", "WHO 7880" );
- shop.boughtCar( car, new Date() );
+ shop.boughtCar( car, randomPastDate() );
cars.add( car );
car = shop.createCar( "SUV", "BMW X5", "WIT 24" );
- shop.boughtCar( car, new Date() );
+ shop.boughtCar( car, randomPastDate() );
cars.add( car );
car = shop.createCar( "SUV", "BMW X5", "WIT 25" );
- shop.boughtCar( car, new Date() );
+ shop.boughtCar( car, randomPastDate() );
cars.add( car );
car = shop.createCar( "SUV", "BMW X5", "WIT 26" );
- shop.boughtCar( car, new Date() );
+ shop.boughtCar( car, randomPastDate() );
cars.add( car );
car = shop.createCar( "SUV", "BMW X5", "WIT 27" );
- shop.boughtCar( car, new Date() );
+ shop.boughtCar( car, randomPastDate() );
cars.add( car );
car = shop.createCar( "Compact", "Mini Cooper S", "WMY 40" );
- shop.boughtCar( car, new Date() );
+ shop.boughtCar( car, randomPastDate() );
cars.add( car );
car = shop.createCar( "Compact", "Mini Cooper S", "WMY 41" );
- shop.boughtCar( car, new Date() );
+ shop.boughtCar( car, randomPastDate() );
cars.add( car );
car = shop.createCar( "Compact", "Mini Cooper S", "WMY 42" );
- shop.boughtCar( car, new Date() );
+ shop.boughtCar( car, randomPastDate() );
cars.add( car );
car = shop.createCar( "Compact", "Mini Cooper S", "WMY 43" );
- shop.boughtCar( car, new Date() );
+ shop.boughtCar( car, randomPastDate() );
cars.add( car );
car = shop.createCar( "Compact", "Mini Cooper S", "WMY 44" );
- shop.boughtCar( car, new Date() );
+ shop.boughtCar( car, randomPastDate() );
cars.add( car );
car = shop.createCar( "Compact", "Mini Cooper S", "WMY 45" );
- shop.boughtCar( car, new Date() );
+ shop.boughtCar( car, randomPastDate() );
cars.add( car );
car = shop.createCar( "Sedan", "BMW 318i", "WRY 900" );
- shop.boughtCar( car, new Date() );
+ shop.boughtCar( car, randomPastDate() );
cars.add( car );
car = shop.createCar( "Sedan", "BMW 318i", "WRY 901" );
- shop.boughtCar( car, new Date() );
+ shop.boughtCar( car, randomPastDate() );
cars.add( car );
car = shop.createCar( "Sedan", "BMW 318i", "WRY 902" );
- shop.boughtCar( car, new Date() );
+ shop.boughtCar( car, randomPastDate() );
cars.add( car );
}
+ private LocalDate randomPastDate()
+ {
+ return LocalDate.now().minusDays( random.nextInt( 700 ) );
+ }
+
private RentalShop createShop( UnitOfWork uow )
throws UnitOfWorkCompletionException
{
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/samples/rental/src/main/java/org/apache/zest/sample/rental/web/MainPage.java
----------------------------------------------------------------------
diff --git a/samples/rental/src/main/java/org/apache/zest/sample/rental/web/MainPage.java b/samples/rental/src/main/java/org/apache/zest/sample/rental/web/MainPage.java
index 5a9aeb3..3e4efee 100644
--- a/samples/rental/src/main/java/org/apache/zest/sample/rental/web/MainPage.java
+++ b/samples/rental/src/main/java/org/apache/zest/sample/rental/web/MainPage.java
@@ -21,7 +21,7 @@
package org.apache.zest.sample.rental.web;
import java.text.MessageFormat;
-import java.text.SimpleDateFormat;
+import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import org.apache.zest.api.injection.scope.Service;
import org.apache.zest.api.injection.scope.Structure;
@@ -44,7 +44,7 @@ public interface MainPage
abstract class BodyContributorMixin
implements MainPage
{
- private SimpleDateFormat sdf = new SimpleDateFormat( "yyyy-MM-dd HH:mm" );
+ private DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern( "yyyy-MM-dd HH:mm" );
@Service
BookingPage bookingPage;
@@ -90,9 +90,9 @@ public interface MainPage
{
return " / " +
- sdf.format( period.startOfPeriod().get() ) +
+ dateTimeFormatter.format( period.startOfPeriod().get() ) +
" - " +
- sdf.format( period.endOfPeriod().get() );
+ dateTimeFormatter.format( period.endOfPeriod().get() );
}
private Element createElement( Document dom, String element )
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/tools/shell/src/dist/bin/zest-boot
----------------------------------------------------------------------
diff --git a/tools/shell/src/dist/bin/zest-boot b/tools/shell/src/dist/bin/zest-boot
index 2706289..cc1aaf2 100644
--- a/tools/shell/src/dist/bin/zest-boot
+++ b/tools/shell/src/dist/bin/zest-boot
@@ -75,3 +75,5 @@ else
java -Dzest.home=$ZESTPATH -jar $ZESTPATH/$JARFILE "$@"
fi
+
+
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/tutorials/introduction/thirtyminutes/src/main/java/org/apache/zest/demo/thirtyminutes/ThirtyMinutesDocs.java
----------------------------------------------------------------------
diff --git a/tutorials/introduction/thirtyminutes/src/main/java/org/apache/zest/demo/thirtyminutes/ThirtyMinutesDocs.java b/tutorials/introduction/thirtyminutes/src/main/java/org/apache/zest/demo/thirtyminutes/ThirtyMinutesDocs.java
index db7269c..109eed4 100644
--- a/tutorials/introduction/thirtyminutes/src/main/java/org/apache/zest/demo/thirtyminutes/ThirtyMinutesDocs.java
+++ b/tutorials/introduction/thirtyminutes/src/main/java/org/apache/zest/demo/thirtyminutes/ThirtyMinutesDocs.java
@@ -21,8 +21,8 @@ package org.apache.zest.demo.thirtyminutes;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
+import java.time.LocalDate;
import java.util.Calendar;
-import java.util.Date;
import java.util.Iterator;
import java.util.List;
import org.apache.zest.api.common.Optional;
@@ -103,10 +103,7 @@ public class ThirtyMinutesDocs
// START SNIPPET: 7
QueryBuilder<Order> builder = queryBuilderFactory.newQueryBuilder( Order.class );
- Calendar cal = Calendar.getInstance();
- cal.setTime( new Date() );
- cal.roll( Calendar.DAY_OF_MONTH, -90 );
- Date last90days = cal.getTime();
+ LocalDate last90days = LocalDate.now().minusDays( 90 );
Order template = templateFor( Order.class );
builder.where( gt( template.createdDate(), last90days ) );
Query<Order> query = uow.newQuery(builder);
@@ -125,10 +122,7 @@ public class ThirtyMinutesDocs
// START SNIPPET: 8
QueryBuilder<HasCustomer> builder = queryBuilderFactory.newQueryBuilder( HasCustomer.class );
- Calendar cal = Calendar.getInstance();
- cal.setTime( new Date() );
- cal.roll( Calendar.MONTH, -1 );
- Date lastMonth = cal.getTime();
+ LocalDate lastMonth = LocalDate.now().minusMonths( 1 );
Order template1 = templateFor( Order.class );
builder.where( gt( template1.createdDate(), lastMonth ) );
Query<HasCustomer> query = uow.newQuery(builder);
@@ -149,7 +143,7 @@ public class ThirtyMinutesDocs
void completed();
- Property<Date> createdDate();
+ Property<LocalDate> createdDate();
}
[20/25] zest-java git commit: ZEST-156 - removed Scheduler Library,
due to serious bug that is nearly impossible to fix.
Posted by ni...@apache.org.
ZEST-156 - removed Scheduler Library, due to serious bug that is nearly impossible to fix.
Project: http://git-wip-us.apache.org/repos/asf/zest-java/repo
Commit: http://git-wip-us.apache.org/repos/asf/zest-java/commit/8915dfaa
Tree: http://git-wip-us.apache.org/repos/asf/zest-java/tree/8915dfaa
Diff: http://git-wip-us.apache.org/repos/asf/zest-java/diff/8915dfaa
Branch: refs/heads/ValueSerializationCleaning
Commit: 8915dfaab1b703eb868815f212d745d52ed8d1c0
Parents: ab96cf4
Author: Niclas Hedhman <ni...@hedhman.org>
Authored: Thu Jun 16 10:29:58 2016 +0800
Committer: Niclas Hedhman <ni...@hedhman.org>
Committed: Thu Jun 16 10:29:58 2016 +0800
----------------------------------------------------------------------
libraries/scheduler/build.gradle | 38 ---
libraries/scheduler/dev-status.xml | 38 ---
libraries/scheduler/src/docs/scheduler.txt | 195 -------------
.../zest/library/scheduler/CronSchedule.java | 121 --------
.../zest/library/scheduler/OnceSchedule.java | 69 -----
.../apache/zest/library/scheduler/Schedule.java | 131 ---------
.../zest/library/scheduler/ScheduleFactory.java | 41 ---
.../zest/library/scheduler/Scheduler.java | 138 ----------
.../scheduler/SchedulerConfiguration.java | 47 ----
.../library/scheduler/SchedulerService.java | 33 ---
.../library/scheduler/SchedulesHandler.java | 88 ------
.../org/apache/zest/library/scheduler/Task.java | 78 ------
.../scheduler/bootstrap/SchedulerAssembler.java | 118 --------
.../library/scheduler/bootstrap/package.html | 24 --
.../defaults/DefaultRejectionHandler.java | 39 ---
.../defaults/DefaultScheduleFactoryMixin.java | 91 ------
.../defaults/DefaultThreadFactory.java | 57 ----
.../library/scheduler/defaults/package.html | 24 --
.../library/scheduler/internal/Execution.java | 276 -------------------
.../scheduler/internal/ScheduleTime.java | 62 -----
.../scheduler/internal/SchedulerMixin.java | 194 -------------
.../library/scheduler/internal/Schedules.java | 28 --
.../library/scheduler/internal/TaskRunner.java | 115 --------
.../library/scheduler/internal/package.html | 24 --
.../apache/zest/library/scheduler/package.html | 24 --
.../library/scheduler/schedule/package.html | 24 --
.../library/scheduler/timeline/Timeline.java | 75 -----
.../timeline/TimelineForScheduleConcern.java | 93 -------
.../scheduler/timeline/TimelineRecord.java | 81 ------
.../scheduler/timeline/TimelineRecordStep.java | 28 --
.../timeline/TimelineScheduleMixin.java | 141 ----------
.../timeline/TimelineScheduleState.java | 30 --
.../timeline/TimelineSchedulerServiceMixin.java | 110 --------
.../library/scheduler/timeline/package.html | 24 --
.../scheduler/AbstractSchedulerTest.java | 76 -----
.../zest/library/scheduler/Constants.java | 27 --
.../library/scheduler/CronScheduleTest.java | 78 ------
.../apache/zest/library/scheduler/FooTask.java | 77 ------
.../zest/library/scheduler/SchedulerTest.java | 206 --------------
.../scheduler/docsupport/SchedulerDocs.java | 99 -------
.../src/test/resources/logback-test.xml | 35 ---
libraries/scheduler/test-repeatedly.sh | 35 ---
manual/src/docs/userguide/libraries.txt | 4 -
settings.gradle | 1 -
44 files changed, 3337 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/zest-java/blob/8915dfaa/libraries/scheduler/build.gradle
----------------------------------------------------------------------
diff --git a/libraries/scheduler/build.gradle b/libraries/scheduler/build.gradle
deleted file mode 100644
index 520d01f..0000000
--- a/libraries/scheduler/build.gradle
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-
-description = "Apache Zest\u2122 Schduler Library for long term timing functionalities."
-
-jar { manifest { name = "Apache Zest\u2122 Library - Scheduler" }}
-
-
-dependencies {
- compile project( ":org.apache.zest.core:org.apache.zest.core.bootstrap" )
- compile project( ':org.apache.zest.libraries:org.apache.zest.library.constraints' )
- compile libraries.sked
- compile libraries.slf4j_api
-
- testCompile project( ":org.apache.zest.core:org.apache.zest.core.testsupport" )
- testCompile project( ":org.apache.zest.extensions:org.apache.zest.extension.indexing-rdf" )
- testCompile libraries.awaitility
-
- testRuntime project( ":org.apache.zest.core:org.apache.zest.core.runtime" )
- testRuntime libraries.logback
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/8915dfaa/libraries/scheduler/dev-status.xml
----------------------------------------------------------------------
diff --git a/libraries/scheduler/dev-status.xml b/libraries/scheduler/dev-status.xml
deleted file mode 100644
index 55032e6..0000000
--- a/libraries/scheduler/dev-status.xml
+++ /dev/null
@@ -1,38 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one
- ~ or more contributor license agreements. See the NOTICE file
- ~ distributed with this work for additional information
- ~ regarding copyright ownership. The ASF licenses this file
- ~ to you under the Apache License, Version 2.0 (the
- ~ "License"); you may not use this file except in compliance
- ~ with the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- ~
- ~
- -->
-<module xmlns="http://zest.apache.org/schemas/2008/dev-status/1"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://zest.apache.org/schemas/2008/dev-status/1
- http://zest.apache.org/schemas/2008/dev-status/1/dev-status.xsd">
- <status>
- <!--none,early,beta,stable,mature-->
- <codebase>early</codebase>
-
- <!-- none, brief, good, complete -->
- <documentation>good</documentation>
-
- <!-- none, some, good, complete -->
- <unittests>good</unittests>
- </status>
- <licenses>
- <license>ALv2</license>
- </licenses>
-</module>
http://git-wip-us.apache.org/repos/asf/zest-java/blob/8915dfaa/libraries/scheduler/src/docs/scheduler.txt
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/docs/scheduler.txt b/libraries/scheduler/src/docs/scheduler.txt
deleted file mode 100644
index a5ab18d..0000000
--- a/libraries/scheduler/src/docs/scheduler.txt
+++ /dev/null
@@ -1,195 +0,0 @@
-///////////////////////////////////////////////////////////////
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
-///////////////////////////////////////////////////////////////
-
-[[library-scheduler,Scheduler Library]]
-= Scheduler =
-
-[devstatus]
---------------
-source=libraries/scheduler/dev-status.xml
---------------
-
-The Scheduler library provides an easy way to schedule tasks either for one time execution, CRON expression intervals or a custom algorithm.
-
-An optional Timeline allows you to browse past and future task runs.
-
-include::../../build/docs/buildinfo/artifact.txt[]
-
-== Logging ==
-
-The SLF4J Logger used by this library is named "org.apache.zest.library.scheduler".
-
-== Assembly ==
-
-Use SchedulerAssembler to add the Scheduler service to your Application. This
-Assembler provide a fluent api to programmatically configure configuration defaults and activate the
-Timeline service assembly that allow browsing of past and future Task runs.
-
-Here is a full example:
-
-[snippet,java]
-----
-source=libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/SchedulerTest.java
-tag=assembly
-----
-
-== Configuration ==
-
-SchedulerConfiguration defines configuration properties details:
-
-[snippet,java]
-----
-source=libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/SchedulerConfiguration.java
-tag=configuration
-----
-
-== Writing Tasks ==
-
-To write a schedulable Task, compose an Entity with the Task type to be able to schedule it.
-
-The Task contract is quite simple:
-
-[snippet,java]
-----
-source=libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/Task.java
-tag=task
-----
-
-Tasks have a mandatory name property and an optional tags property. These properties get copied in
-each TimelineRecord created when the Timeline feature is activated.
-
-The run() method of Tasks is wrapped in a UnitOfWork when called by the Scheduler.
-Thanks to the UnitOfWork handling in Zest, you can split the work done in your Tasks in
-several UnitOfWorks. See UnitOfWork strategy below.
-
-Here is a simple example:
-
-[snippet,java]
------------
-source=libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/docsupport/SchedulerDocs.java
-tag=1
------------
-
-== Scheduling Tasks ==
-
-Tasks are scheduled using the Scheduler service. This creates a Schedule associated to
-the Task that allows you to know if it is running, to change it's cron expression and set it's
-durability.
-
-All Schedules are durable. In other words, it will survive an Application restart, and your application should
-not schedule it again, as the Schedules are when the SchedulerService is activated after bootstrap.
-
-There are three ways to schedule a Task using the Scheduler service: once or with a cron
-expression or providing your own Schedule instance.
-
-=== Scheduling once ===
-
-This is the easiest way to run a background Task once after a given initial delay in seconds.
-
-[snippet,java]
------------
-source=libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/docsupport/SchedulerDocs.java
-tag=2
------------
-
-Since all Schedules are durable, this "once" can be far into the future, and still be executed if the application
-has been restarted.
-
-
-=== Scheduling using a cron expression ===
-
-Cron expression parsing is based on the GNU crontab manpage that can be found here:
-http://unixhelp.ed.ac.uk/CGI/man-cgi?crontab+5 .
-
-The following extensions are used:
-
-- a mandatory field is added at the begining: seconds.
-- a special string is added: @minutely
-- a special character is added: ? to choose between dayOfMonth and dayOfWeek
-
-The ? special char has the same behavior as in the Quartz Scheduler expression. The wikipedia page
-http://en.wikipedia.org/wiki/CRON_expression
-explains Quartz Scheduler expression, not simple cron expressions. You'll find there about the ? special
-char and maybe that some other extensions you would like to use are missing in this project.
-
-To sum up, cron expressions used here have a precision of one second. The following special strings can be used:
-
-- @minutely
-- @hourly
-- @midnight or @daily
-- @weekly
-- @monthly
-- @annualy or @yearly
-
-
-== Overrun ==
-If the Schedule is running when it is time to be executed, then the execution will be skipped. This means that
-the Task must complete within its period, or executions will be skipped. The sideeffect of that is that this
-reduces thread exhaustion.
-
-When the Task execution is skipped, the overrun() property on the Schedule is incremented by 1.
-
-== Durability ==
-All Schedules are durable and the Task must be an Entity Composite. It also means that Tasks should be schedule
-once and not on each reboot. The SchedulerService will load all Schedules on activation.
-
-While the Task is running, the Schedule will be held in the UnitOfWork of the TaskRunner. This means that IF the
-Schedule is updated, i.e. cancelled or directly manipulating Schedule properties, the UnitOfWork.complete() will fail.
-And if the Task is executing within the same UnitOfWork, any changes made will not take place.
-
-== UnitOfWork strategy ==
-The TaskRunner creates a UnitOfWork and the Task is excuted within that UnitOfWork. This may be very convenient, but
-as noted in Durability above, that UnitOfWork will fail if Schedule properties are updated while the Task is
-running. To avoid that the Task's operations suffers from this, OR if the Task wants a Retry/DiscardOn strategy
-different from the default one, then the Task can simply declare its own. such as;
-
-[snippet,java]
------------
-source=libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/docsupport/SchedulerDocs.java
-tag=strategy
------------
-
-== Custom Schedules ==
-It is possible to implement Schedule directly. It must be declared as an EntityComposite in the assembly, and be
-visible from the SchedulerService. No other considerations should be necessary.
-
-== Observing the Timeline ==
-
-Timeline allow to browse in past and future Task runs. This feature is available only if you activate
-the Timeline assembly in the SchedulerAssembler}, see above.
-
-Once activated, Task success and failures are recorded. Then, the Timeline
-service allow to browse in past (recorded) and in anticipated (future) Task runs.
-
-Use the following in your code to get a Timeline Service injected:
-
-[snippet,java]
------------
-source=libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/docsupport/SchedulerDocs.java
-tag=timeline
------------
-
-Here is the actual Timeline contract:
-
-[snippet,java]
-----
-source=libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/Timeline.java
-tag=timeline
-----
-
http://git-wip-us.apache.org/repos/asf/zest-java/blob/8915dfaa/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/CronSchedule.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/CronSchedule.java b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/CronSchedule.java
deleted file mode 100644
index 5270da0..0000000
--- a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/CronSchedule.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-package org.apache.zest.library.scheduler;
-
-import java.lang.annotation.Retention;
-import java.time.Instant;
-import org.apache.zest.api.constraint.Constraint;
-import org.apache.zest.api.constraint.ConstraintDeclaration;
-import org.apache.zest.api.constraint.Constraints;
-import org.apache.zest.api.mixin.Mixins;
-import org.apache.zest.api.property.Immutable;
-import org.apache.zest.api.property.Property;
-import org.apache.zest.library.constraints.annotation.InstanceOf;
-import org.apache.zest.library.constraints.annotation.NotEmpty;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-@Mixins( CronSchedule.CronScheduleMixin.class )
-public interface CronSchedule
- extends Schedule
-{
- /**
- * The Cron expression indicating when the Schedule is to be run.
- * The Schedule can NOT be changed once it is set. If this is needed, delete this Schedule and attach the Task
- * to a new Schedule.
- *
- * @return The cron expression that will be used on {@link org.apache.zest.api.unitofwork.UnitOfWork} completion to compute next run
- */
- @CronExpression
- @Immutable
- Property<String> cronExpression();
-
- abstract class CronScheduleMixin
- implements CronSchedule
- {
- private static final Logger LOGGER = LoggerFactory.getLogger( Schedule.class );
-
- @Override
- public void taskStarting()
- {
- }
-
- @Override
- public void taskCompletedSuccessfully()
- {
- }
-
- @Override
- public void taskCompletedWithException( Throwable ex )
- {
- }
-
- @Override
- public String presentationString()
- {
- return cronExpression().get();
- }
-
- @Override
- public Instant nextRun( Instant from )
- {
- Instant actualFrom = from;
- Instant firstRun = start().get();
- if( firstRun.isAfter(from ))
- {
- actualFrom = firstRun;
- }
- // TODO:PM cron "next run" handling mismatch with the underlying cron library
- Instant nextRun = Instant.ofEpochMilli(
- createCron().firstRunAfter( actualFrom.plusSeconds( 1 ).toEpochMilli())
- );
- LOGGER.info( "CronSchedule::nextRun({}) is {}", from, firstRun );
- return nextRun;
- }
-
- private org.codeartisans.sked.cron.CronSchedule createCron()
- {
- return new org.codeartisans.sked.cron.CronSchedule( cronExpression().get() );
- }
- }
-
- @ConstraintDeclaration
- @Retention( RUNTIME )
- @NotEmpty
- @InstanceOf( String.class )
- @Constraints( CronExpressionConstraint.class )
- @interface CronExpression
- {
- }
-
- class CronExpressionConstraint
- implements Constraint<CronExpression, String>
- {
- private static final long serialVersionUID = 1L;
-
- @Override
- public boolean isValid( CronExpression annotation, String cronExpression )
- {
- return org.codeartisans.sked.cron.CronSchedule.isExpressionValid( cronExpression );
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/8915dfaa/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/OnceSchedule.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/OnceSchedule.java b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/OnceSchedule.java
deleted file mode 100644
index 7421882..0000000
--- a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/OnceSchedule.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-package org.apache.zest.library.scheduler;
-
-import java.time.Instant;
-import org.apache.zest.api.mixin.Mixins;
-
-@Mixins( OnceSchedule.OnceScheduleMixin.class )
-public interface OnceSchedule
- extends Schedule
-{
- abstract class OnceScheduleMixin
- implements OnceSchedule
- {
- @Override
- public void taskStarting()
- {
- }
-
- @Override
- public void taskCompletedSuccessfully()
- {
- }
-
- @Override
- public void taskCompletedWithException( Throwable ex )
- {
- }
-
- @Override
- public Instant nextRun( Instant from )
- {
- if( done().get() )
- {
- return Instant.MIN;
- }
- done().set( true );
- Instant runAt = start().get();
- if( runAt.isAfter( from ) )
- {
- return runAt;
- }
- return from;
- }
-
- @Override
- public String presentationString()
- {
- return start().get().toString();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/8915dfaa/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/Schedule.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/Schedule.java b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/Schedule.java
deleted file mode 100644
index 6d7191d..0000000
--- a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/Schedule.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-package org.apache.zest.library.scheduler;
-
-import java.time.Instant;
-import java.time.ZonedDateTime;
-import org.apache.zest.api.association.Association;
-import org.apache.zest.api.common.UseDefaults;
-import org.apache.zest.api.entity.EntityComposite;
-import org.apache.zest.api.property.Immutable;
-import org.apache.zest.api.property.Property;
-
-/**
- * Represent the scheduling of a {@link Task}.
- */
-public interface Schedule extends EntityComposite
-{
- /**
- * @return The Association to the Task to be executed when it is time.
- */
- Association<Task> task();
-
- /** The first run of this Schedule.
- *
- * @return The property containing the first time this Schedule will be run.
- */
- @Immutable
- Property<Instant> start();
-
- /** Returns true if the Schedule has been cancelled.
- *
- * @return true if the Schedule has been cancelled.
- */
- @UseDefaults
- Property<Boolean> cancelled();
-
- /** Returns true if the Schedule is currently running.
- *
- * @return true if the Schedule is currently running.
- */
- @UseDefaults
- Property<Boolean> running();
-
- /** Returns the number of times the {@link Task} has been executed.
- * <p>
- * Each time the {@link Task#run} method completes, with or without an {@link Exception}, this
- * counter is incremented by 1.
- * </p>
- *
- * @return true the number of Exception that has occurred when running the {@link Task}.
- */
- @UseDefaults
- Property<Long> executionCounter();
-
- /** Returns the number of Exception that has occurred when running the {@link Task}.
- * <p>
- * Each time the {@link Task#run} method throws a {@link RuntimeException}, this property
- * is incremenented by 1,
- * </p>
- *
- * @return true the number of Exception that has occurred when running the {@link Task}.
- */
- @UseDefaults
- Property<Long> exceptionCounter();
-
- /** Returns true if the Schedule is done and will not be executed any more times.
- *
- * @return true if the Schedule is done and will not be executed any more times.
- */
- @UseDefaults
- Property<Boolean> done();
-
- /** Returns the number of times the Schedule has been skipped, due to the Task was still running.
- *
- * @return the number of times the Schedule has been skipped, due to the Task was still running.
- */
- @UseDefaults
- Property<Long> overrun();
-
- /**
- * Called just before the {@link org.apache.zest.library.scheduler.Task#run()} method is called.
- */
- void taskStarting();
-
- /**
- * Called directly after the {@link org.apache.zest.library.scheduler.Task#run()} method has been completed and
- * returned from the method normally.
- */
- void taskCompletedSuccessfully();
-
- /**
- * Called directly after the {@link org.apache.zest.library.scheduler.Task#run()} method has been completed but
- * threw a RuntimeException.
- * @param ex The execption that was thrown in the Task. If the thrown Exception was an
- * {@link java.lang.reflect.UndeclaredThrowableException} then the underlying exception is passed here.
- */
- void taskCompletedWithException( Throwable ex );
-
- /**
- * Compute the next time this schedule is to be run.
- *
- * @param from The starting time when to look for the next time it will run.
- *
- * @return The exact absolute time when this Schedule is to be run next time, or -1 if never
- */
- Instant nextRun( Instant from );
-
- /**
- * Return a representation of the Schedule in a human understandable format.
- *
- * @return A String representing this schedule.
- */
- String presentationString();
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/8915dfaa/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/ScheduleFactory.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/ScheduleFactory.java b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/ScheduleFactory.java
deleted file mode 100644
index c5fdd81..0000000
--- a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/ScheduleFactory.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-package org.apache.zest.library.scheduler;
-
-import java.time.Instant;
-import java.time.ZonedDateTime;
-import org.apache.zest.api.concern.Concerns;
-import org.apache.zest.api.unitofwork.concern.UnitOfWorkConcern;
-import org.apache.zest.api.unitofwork.concern.UnitOfWorkPropagation;
-import org.apache.zest.library.scheduler.defaults.DefaultScheduleFactoryMixin;
-import org.apache.zest.api.mixin.Mixins;
-
-import static org.apache.zest.api.unitofwork.concern.UnitOfWorkPropagation.Propagation.MANDATORY;
-
-@Mixins( DefaultScheduleFactoryMixin.class )
-@Concerns( UnitOfWorkConcern.class )
-public interface ScheduleFactory
-{
- @UnitOfWorkPropagation( MANDATORY)
- Schedule newCronSchedule( Task task, String cronExpression, Instant start );
-
- @UnitOfWorkPropagation( MANDATORY)
- Schedule newOnceSchedule( Task task, Instant runAt );
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/8915dfaa/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/Scheduler.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/Scheduler.java b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/Scheduler.java
deleted file mode 100644
index ac081d6..0000000
--- a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/Scheduler.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-package org.apache.zest.library.scheduler;
-
-import java.time.Instant;
-import org.apache.zest.library.scheduler.internal.Schedules;
-import org.apache.zest.api.concern.Concerns;
-import org.apache.zest.api.structure.Application;
-import org.apache.zest.api.unitofwork.concern.UnitOfWorkConcern;
-import org.apache.zest.api.unitofwork.concern.UnitOfWorkPropagation;
-import org.apache.zest.library.scheduler.bootstrap.SchedulerAssembler;
-import org.apache.zest.library.scheduler.timeline.Timeline;
-
-import static org.apache.zest.api.unitofwork.concern.UnitOfWorkPropagation.Propagation.MANDATORY;
-
-/**
- * Scheduler.
- * <p>
- * This is the only interface you should use in your application for scheduling tasks.
- * </p>
- * <p>
- * See {@link SchedulerConfiguration} for configuration properties.
- * </p>
- * <p>
- * See in {@link SchedulerAssembler} how to assemble a {@link Scheduler} and optional {@link Timeline}.
- * </p>
- * <p>
- * By default, a {@link Schedule} is not durable. In other words, it do not survive an {@link Application} restart.
- * </p>
- * <p>
- * All {@link Schedule}s are durable and stored in the visible {@link org.apache.zest.spi.entitystore.EntityStore} like
- * any ordinary {@link org.apache.zest.api.entity.EntityComposite}. There is also a {@link Schedules}
- * entity composite that has Associations to all active, completed and cancelled schedules.
- * </p>
- */
-@Concerns( UnitOfWorkConcern.class )
-public interface Scheduler
-{
- /**
- * Schedule a Task to be run after a given initial delay in seconds.
- *
- * @param task Task to be scheduled once
- * @param initialSecondsDelay Initial delay the Task will be run after, in seconds
- *
- * @return The newly created Schedule
- */
- @UnitOfWorkPropagation( MANDATORY )
- Schedule scheduleOnce( Task task, int initialSecondsDelay );
-
- /**
- * Schedule a Task to be run after a given initial delay in seconds.
- *
- * @param task Task to be scheduled once
- * @param runAt The future point in time when the Schedule will be run.
- *
- * @return The newly created Schedule
- */
- @UnitOfWorkPropagation( MANDATORY )
- Schedule scheduleOnce( Task task, Instant runAt );
-
- /**
- * Schedule a Task using a CronExpression.
- *
- * @param task Task to be scheduled once
- * @param cronExpression CronExpression for creating the Schedule for the given Task
- *
- * @return The newly created Schedule
- */
- @UnitOfWorkPropagation( MANDATORY )
- Schedule scheduleCron( Task task, @CronSchedule.CronExpression String cronExpression );
-
- /**
- * Schedule a Task using a CronExpression with a given initial delay in milliseconds.
- *
- * @param task Task to be scheduled once
- * @param cronExpression CronExpression for creating the Schedule for the given Task
- * @param initialDelay Initial delay the Schedule will be active after, in milliseconds
- *
- * @return The newly created Schedule
- */
- @UnitOfWorkPropagation( MANDATORY )
- Schedule scheduleCron( Task task, @CronSchedule.CronExpression String cronExpression, long initialDelay );
-
- /**
- * Schedule a Task using a CronExpression starting at a given date.
- *
- * @param task Task to be scheduled once
- * @param cronExpression CronExpression for creating the Schedule for the given Task
- * @param start Date from which the Schedule will become active
- *
- * @return The newly created Schedule
- */
- @UnitOfWorkPropagation( MANDATORY )
- Schedule scheduleCron( Task task, @CronSchedule.CronExpression String cronExpression, Instant start );
-
- /** Schedules a custom Schedule.
- *
- *
- * @param schedule The Schedule instance to be scheduled.
- */
- @UnitOfWorkPropagation( MANDATORY )
- void scheduleCron( Schedule schedule );
-
- /** Cancels a Schedule.
- * Reads the Schedule from the EntityStore and calls {@link #cancelSchedule(Schedule)}.
- *
- * @param scheduleId The identity of the Schedule to be cancelled.
- */
- @UnitOfWorkPropagation( MANDATORY )
- void cancelSchedule( String scheduleId );
-
- /** Cancels the provided Schedule.
- *
- * Cancellation can be done before, while and after execution of the Schedule. If the execution
- * is in progress, it will not be interrupted.
- *
- * @param schedule The schedule to be cancelled.
- */
- @UnitOfWorkPropagation( MANDATORY )
- public void cancelSchedule( Schedule schedule );
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/zest-java/blob/8915dfaa/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/SchedulerConfiguration.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/SchedulerConfiguration.java b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/SchedulerConfiguration.java
deleted file mode 100644
index 73fbb84..0000000
--- a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/SchedulerConfiguration.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-package org.apache.zest.library.scheduler;
-
-import org.apache.zest.api.common.Optional;
-import org.apache.zest.api.common.UseDefaults;
-import org.apache.zest.api.property.Property;
-
-/**
- * Configuration for the {@link Scheduler}.
- *
- * Every property has a default value, you can use a {@link Scheduler} without providing any.
- */
-public interface SchedulerConfiguration
-{
-// START SNIPPET: configuration
- /**
- * @return Number of worker threads, optional and defaults to the number of available cores.
- */
- @Optional @UseDefaults
- Property<Integer> workersCount();
-
- /**
- * @return Size of the queue to use for holding tasks before they are run, optional and defaults to 10.
- */
- @Optional @UseDefaults
- Property<Integer> workQueueSize();
-
-// END SNIPPET: configuration
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/8915dfaa/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/SchedulerService.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/SchedulerService.java b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/SchedulerService.java
deleted file mode 100644
index c71717c..0000000
--- a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/SchedulerService.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-package org.apache.zest.library.scheduler;
-
-import org.apache.zest.api.entity.Identity;
-import org.apache.zest.api.mixin.Mixins;
-import org.apache.zest.api.service.ServiceActivation;
-import org.apache.zest.library.scheduler.defaults.DefaultRejectionHandler;
-import org.apache.zest.library.scheduler.defaults.DefaultThreadFactory;
-import org.apache.zest.library.scheduler.internal.SchedulerMixin;
-
-@Mixins( { SchedulerMixin.class, DefaultThreadFactory.class, DefaultRejectionHandler.class } )
-public interface SchedulerService
- extends Scheduler, ServiceActivation, Identity
-{
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/8915dfaa/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/SchedulesHandler.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/SchedulesHandler.java b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/SchedulesHandler.java
deleted file mode 100644
index a9b4602..0000000
--- a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/SchedulesHandler.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-
-package org.apache.zest.library.scheduler;
-
-import org.apache.zest.api.entity.Identity;
-import org.apache.zest.api.injection.scope.Structure;
-import org.apache.zest.api.injection.scope.This;
-import org.apache.zest.api.mixin.Mixins;
-import org.apache.zest.api.unitofwork.NoSuchEntityException;
-import org.apache.zest.api.unitofwork.UnitOfWork;
-import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
-import org.apache.zest.api.unitofwork.concern.UnitOfWorkPropagation;
-import org.apache.zest.library.scheduler.internal.Schedules;
-
-@Mixins( SchedulesHandler.SchedulesHandlerMixin.class )
-public interface SchedulesHandler
-{
- @UnitOfWorkPropagation( UnitOfWorkPropagation.Propagation.MANDATORY )
- Schedules getActiveSchedules();
-
- @UnitOfWorkPropagation( UnitOfWorkPropagation.Propagation.MANDATORY )
- Schedules getCancelledSchedules();
-
- class SchedulesHandlerMixin implements SchedulesHandler
- {
- @This
- private Identity me;
-
- @Structure
- private UnitOfWorkFactory module;
-
- @Override
- public Schedules getActiveSchedules()
- {
- return getOrCreateSchedules( getActiveSchedulesIdentity() );
- }
-
- @Override
- public Schedules getCancelledSchedules()
- {
- return getOrCreateSchedules( getCancelledSchedulesIdentity() );
- }
-
- public String getActiveSchedulesIdentity()
- {
- return "Schedules-Active:" + me.identity().get();
- }
-
- public String getCancelledSchedulesIdentity()
- {
- return "Schedules-Cancelled:" + me.identity().get();
- }
-
- private Schedules getOrCreateSchedules( String identity )
- {
- UnitOfWork uow = module.currentUnitOfWork();
- Schedules schedules;
- try
- {
- schedules = uow.get( Schedules.class, identity );
- }
- catch( NoSuchEntityException e )
- {
- // Create a new Schedules entity for keeping track of them all.
- schedules = uow.newEntity( Schedules.class, identity );
- }
- return schedules;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/8915dfaa/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/Task.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/Task.java b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/Task.java
deleted file mode 100644
index edd67ba..0000000
--- a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/Task.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-package org.apache.zest.library.scheduler;
-
-import java.util.List;
-import org.apache.zest.api.common.UseDefaults;
-import org.apache.zest.api.concern.Concerns;
-import org.apache.zest.api.property.Property;
-import org.apache.zest.api.unitofwork.UnitOfWork;
-import org.apache.zest.api.unitofwork.concern.UnitOfWorkConcern;
-import org.apache.zest.api.unitofwork.concern.UnitOfWorkPropagation;
-
-/**
- * Compose an Entity using this type to be able to Schedule it.
- *<p>
- * A Task is associated from a {@link Schedule}, and upon time to execute
- * the SchedulerService will dispatch a TaskRunner in a new thread, and establish a UnitOfWork (Usecase name of "Task Runner").
- *</p>
- *<p>
- * The {@code Task} type declares the {@link UnitOfWorkConcern} and therefor the {@code Task} implementation may
- * declare the {@link UnitOfWorkPropagation} annotation with the
- * {@link org.apache.zest.api.unitofwork.concern.UnitOfWorkPropagation.Propagation#REQUIRES_NEW} and a different
- * {@link UnitOfWork} strategy, such as {@code Retries} and {@code DiscardOn}.
- *
- *</p>
- *
- * Here is a simple example:
- * <pre><code>
- * interface MyTask
- * extends Task
- * {
- * Property<String customState();
- * Association<AnotherEntity> anotherEntity();
- * }
- *
- * class MyTaskMixin
- * implements Runnable
- * {
- * @This MyTaskEntity me;
- *
- * public void run()
- * {
- * me.customState().set( me.anotherEntity().get().doSomeStuff( me.customState().get() ) );
- * }
- * }
- * </code></pre>
- *
- * Finaly, {@literal MyTask} must be assembled into an {@literal EntityComposite}.
- */
-// START SNIPPET: task
-@Concerns( UnitOfWorkConcern.class )
-public interface Task
- extends Runnable
-{
- Property<String> name();
-
- @UseDefaults
- Property<List<String>> tags();
-
-}
-// END SNIPPET: task
http://git-wip-us.apache.org/repos/asf/zest-java/blob/8915dfaa/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/bootstrap/SchedulerAssembler.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/bootstrap/SchedulerAssembler.java b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/bootstrap/SchedulerAssembler.java
deleted file mode 100644
index 7ff8d93..0000000
--- a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/bootstrap/SchedulerAssembler.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-package org.apache.zest.library.scheduler.bootstrap;
-
-import org.apache.zest.api.unitofwork.concern.UnitOfWorkConcern;
-import org.apache.zest.bootstrap.Assemblers;
-import org.apache.zest.bootstrap.AssemblyException;
-import org.apache.zest.bootstrap.EntityDeclaration;
-import org.apache.zest.bootstrap.ModuleAssembly;
-import org.apache.zest.bootstrap.ServiceDeclaration;
-import org.apache.zest.bootstrap.ValueDeclaration;
-import org.apache.zest.library.scheduler.SchedulerConfiguration;
-import org.apache.zest.library.scheduler.SchedulerService;
-import org.apache.zest.library.scheduler.internal.TaskRunner;
-import org.apache.zest.library.scheduler.ScheduleFactory;
-import org.apache.zest.library.scheduler.internal.Schedules;
-import org.apache.zest.library.scheduler.CronSchedule;
-import org.apache.zest.library.scheduler.OnceSchedule;
-import org.apache.zest.library.scheduler.timeline.Timeline;
-import org.apache.zest.library.scheduler.timeline.TimelineForScheduleConcern;
-import org.apache.zest.library.scheduler.timeline.TimelineRecord;
-import org.apache.zest.library.scheduler.timeline.TimelineScheduleMixin;
-import org.apache.zest.library.scheduler.timeline.TimelineSchedulerServiceMixin;
-
-/**
- * Assembler for Scheduler.
- *
- * Use this Assembler to add the Scheduler service to your application.
- * This Assembler provide a fluent api to programmatically configure configuration defaults and
- * activate the Timeline service assembly that allow to browse in past and future Task runs.
- *
- * Here is a full example:
- * <pre>
- * new SchedulerAssembler().
- * visibleIn( Visibility.layer ).
- * withConfig( configModuleAssembly, Visibility.application ).
- * withTimeline().
- * assemble( module );
- * </pre>
- */
-public class SchedulerAssembler
- extends Assemblers.VisibilityConfig<SchedulerAssembler>
-{
-
- private static final int DEFAULT_WORKERS_COUNT = Runtime.getRuntime().availableProcessors() + 1;
- private static final int DEFAULT_WORKQUEUE_SIZE = 10;
-
- private boolean timeline;
-
- /**
- * Activate the assembly of Timeline related services.
- *
- * @return SchedulerAssembler
- */
- public SchedulerAssembler withTimeline()
- {
- timeline = true;
- return this;
- }
-
- @Override
- public void assemble( ModuleAssembly assembly )
- throws AssemblyException
- {
- assembly.services( ScheduleFactory.class );
- assembly.entities( Schedules.class );
- EntityDeclaration scheduleEntities = assembly.entities( CronSchedule.class, OnceSchedule.class );
-
- ValueDeclaration scheduleValues = assembly.values( CronSchedule.class, OnceSchedule.class );
-
- ServiceDeclaration schedulerDeclaration = assembly.services( SchedulerService.class )
- .visibleIn( visibility() )
- .instantiateOnStartup();
-
- assembly.transients( Runnable.class ).withMixins( TaskRunner.class ).withConcerns( UnitOfWorkConcern.class );
-
- if( timeline )
- {
- scheduleEntities.withTypes( Timeline.class )
- .withMixins( TimelineScheduleMixin.class )
- .withConcerns( TimelineForScheduleConcern.class );
-
- scheduleValues.withTypes( Timeline.class )
- .withMixins( TimelineScheduleMixin.class )
- .withConcerns( TimelineForScheduleConcern.class );
-
- // Internal
- assembly.values( TimelineRecord.class );
- schedulerDeclaration.withTypes( Timeline.class ).withMixins( TimelineSchedulerServiceMixin.class );
- }
-
- if( hasConfig() )
- {
- configModule().entities( SchedulerConfiguration.class )
- .visibleIn( configVisibility() );
- SchedulerConfiguration defaults = assembly.forMixin( SchedulerConfiguration.class ).declareDefaults();
- defaults.workersCount().set( DEFAULT_WORKERS_COUNT );
- defaults.workQueueSize().set( DEFAULT_WORKQUEUE_SIZE );
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/8915dfaa/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/bootstrap/package.html
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/bootstrap/package.html b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/bootstrap/package.html
deleted file mode 100644
index 6466780..0000000
--- a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/bootstrap/package.html
+++ /dev/null
@@ -1,24 +0,0 @@
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one
- ~ or more contributor license agreements. See the NOTICE file
- ~ distributed with this work for additional information
- ~ regarding copyright ownership. The ASF licenses this file
- ~ to you under the Apache License, Version 2.0 (the
- ~ "License"); you may not use this file except in compliance
- ~ with the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- ~
- ~
- -->
-<html>
- <body>
- <h2>Scheduler Assembly.</h2>
- </body>
-</html>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/zest-java/blob/8915dfaa/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/defaults/DefaultRejectionHandler.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/defaults/DefaultRejectionHandler.java b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/defaults/DefaultRejectionHandler.java
deleted file mode 100644
index 2b5b2e3..0000000
--- a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/defaults/DefaultRejectionHandler.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-
-package org.apache.zest.library.scheduler.defaults;
-
-import java.util.concurrent.RejectedExecutionHandler;
-import java.util.concurrent.ThreadPoolExecutor;
-import org.apache.zest.library.scheduler.SchedulerService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class DefaultRejectionHandler
- implements RejectedExecutionHandler
-{
- private static final Logger LOGGER = LoggerFactory.getLogger( SchedulerService.class );
-
- @Override
- public void rejectedExecution( Runnable r, ThreadPoolExecutor executor )
- {
- LOGGER.error( "Runnable [" + r + "] was rejected by executor [" + executor + "]" );
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/8915dfaa/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/defaults/DefaultScheduleFactoryMixin.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/defaults/DefaultScheduleFactoryMixin.java b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/defaults/DefaultScheduleFactoryMixin.java
deleted file mode 100644
index 2d21e27..0000000
--- a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/defaults/DefaultScheduleFactoryMixin.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-
-package org.apache.zest.library.scheduler.defaults;
-
-import java.time.Instant;
-import org.apache.zest.api.entity.EntityBuilder;
-import org.apache.zest.api.injection.scope.Service;
-import org.apache.zest.api.injection.scope.Structure;
-import org.apache.zest.api.unitofwork.UnitOfWork;
-import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
-import org.apache.zest.library.scheduler.CronSchedule;
-import org.apache.zest.library.scheduler.OnceSchedule;
-import org.apache.zest.library.scheduler.Schedule;
-import org.apache.zest.library.scheduler.ScheduleFactory;
-import org.apache.zest.library.scheduler.SchedulerService;
-import org.apache.zest.library.scheduler.Task;
-import org.apache.zest.spi.uuid.UuidIdentityGeneratorService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class DefaultScheduleFactoryMixin
- implements ScheduleFactory
-{
- private static final Logger logger = LoggerFactory.getLogger( ScheduleFactory.class );
-
- @Structure
- private UnitOfWorkFactory uowf;
-
- @Service
- private SchedulerService scheduler;
-
- @Service
- private UuidIdentityGeneratorService uuid;
-
- @Override
- public CronSchedule newCronSchedule( Task task, String cronExpression, Instant start )
- {
- return newPersistentCronSchedule( task, cronExpression, start );
- }
-
- @Override
- public Schedule newOnceSchedule( Task task, Instant runAt )
- {
- return newPersistentOnceSchedule( task, runAt );
- }
-
- private CronSchedule newPersistentCronSchedule( Task task, String cronExpression, Instant start )
- {
- UnitOfWork uow = uowf.currentUnitOfWork();
- EntityBuilder<CronSchedule> builder = uow.newEntityBuilder( CronSchedule.class );
- CronSchedule instance = builder.instance();
- instance.task().set( task );
- instance.start().set( start );
- instance.identity().set( uuid.generate( CronSchedule.class ) );
- instance.cronExpression().set( cronExpression );
- CronSchedule schedule = builder.newInstance();
- logger.info( "Schedule {} created: {}", schedule.presentationString(), schedule.identity().get() );
- return schedule;
- }
-
- private Schedule newPersistentOnceSchedule( Task task, Instant runAt )
- {
- UnitOfWork uow = uowf.currentUnitOfWork();
- EntityBuilder<OnceSchedule> builder = uow.newEntityBuilder( OnceSchedule.class );
- OnceSchedule builderInstance = builder.instance();
- builderInstance.task().set( task );
- builderInstance.start().set( runAt );
- builderInstance.identity().set( uuid.generate( OnceSchedule.class ) );
- OnceSchedule schedule = builder.newInstance();
- logger.info( "Schedule {} created: {}", schedule.presentationString(), schedule.identity().get() );
- return schedule;
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/8915dfaa/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/defaults/DefaultThreadFactory.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/defaults/DefaultThreadFactory.java b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/defaults/DefaultThreadFactory.java
deleted file mode 100644
index 85d137c..0000000
--- a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/defaults/DefaultThreadFactory.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-
-package org.apache.zest.library.scheduler.defaults;
-
-import java.util.concurrent.atomic.AtomicInteger;
-import org.apache.zest.api.injection.scope.This;
-import org.apache.zest.library.scheduler.internal.Execution;
-import org.apache.zest.library.scheduler.SchedulerService;
-
-public class DefaultThreadFactory
- implements java.util.concurrent.ThreadFactory
-{
- private static final AtomicInteger POOL_NUMBER = new AtomicInteger( 1 );
- private final ThreadGroup group;
- private final AtomicInteger threadNumber = new AtomicInteger( 1 );
- private final String namePrefix;
-
- protected DefaultThreadFactory( @This SchedulerService me )
- {
- SecurityManager sm = System.getSecurityManager();
- group = ( sm != null ) ? sm.getThreadGroup() : Execution.ExecutionMixin.TG;
- namePrefix = me.identity().get() + "-P" + POOL_NUMBER.getAndIncrement() + "W";
- }
-
- @Override
- public Thread newThread( Runnable runnable )
- {
- Thread thread = new Thread( group, runnable, namePrefix + threadNumber.getAndIncrement(), 0 );
- if( thread.isDaemon() )
- {
- thread.setDaemon( false );
- }
- if( thread.getPriority() != Thread.NORM_PRIORITY )
- {
- thread.setPriority( Thread.NORM_PRIORITY );
- }
- return thread;
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/8915dfaa/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/defaults/package.html
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/defaults/package.html b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/defaults/package.html
deleted file mode 100644
index 86177ff..0000000
--- a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/defaults/package.html
+++ /dev/null
@@ -1,24 +0,0 @@
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one
- ~ or more contributor license agreements. See the NOTICE file
- ~ distributed with this work for additional information
- ~ regarding copyright ownership. The ASF licenses this file
- ~ to you under the Apache License, Version 2.0 (the
- ~ "License"); you may not use this file except in compliance
- ~ with the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- ~
- ~
- -->
-<html>
- <body>
- <h2>Scheduler Defaults.</h2>
- </body>
-</html>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/zest-java/blob/8915dfaa/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/Execution.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/Execution.java b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/Execution.java
deleted file mode 100644
index 6ca01af..0000000
--- a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/Execution.java
+++ /dev/null
@@ -1,276 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-
-package org.apache.zest.library.scheduler.internal;
-
-import java.time.Duration;
-import java.time.Instant;
-import java.util.SortedSet;
-import java.util.TreeSet;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.RejectedExecutionHandler;
-import java.util.concurrent.ThreadFactory;
-import java.util.concurrent.ThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
-import org.apache.zest.api.composite.TransientBuilderFactory;
-import org.apache.zest.api.configuration.Configuration;
-import org.apache.zest.api.injection.scope.Structure;
-import org.apache.zest.api.injection.scope.This;
-import org.apache.zest.api.mixin.Mixins;
-import org.apache.zest.api.unitofwork.NoSuchEntityException;
-import org.apache.zest.api.unitofwork.UnitOfWork;
-import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
-import org.apache.zest.library.scheduler.Schedule;
-import org.apache.zest.library.scheduler.Scheduler;
-import org.apache.zest.library.scheduler.SchedulerConfiguration;
-
-/**
- * This composite handles the Execution of Schedules.
- *
- * The composite is internal and should never be used by clients.
- */
-@Mixins( Execution.ExecutionMixin.class )
-public interface Execution
-{
- void dispatchForExecution( Schedule schedule );
-
- void start()
- throws Exception;
-
- void stop()
- throws Exception;
-
- void updateNextTime( ScheduleTime schedule ); // This method is public, only because the UnitOfWorkConcern is wanted.
-
- class ExecutionMixin
- implements Execution, Runnable
- {
- public static final ThreadGroup TG = new ThreadGroup( "Zest Scheduling" );
-
- private final Object lock = new Object();
-
- @Structure
- private UnitOfWorkFactory uowf;
-
- @Structure
- private TransientBuilderFactory tbf;
-
- @This
- private Scheduler scheduler;
-
- @This
- private Configuration<SchedulerConfiguration> config;
-
- @This
- private ThreadFactory threadFactory;
-
- @This
- private RejectedExecutionHandler rejectionHandler;
-
- private final SortedSet<ScheduleTime> timingQueue = new TreeSet<>();
- private volatile boolean running;
- private ThreadPoolExecutor taskExecutor;
- private volatile Thread scheduleThread;
-
- @Override
- public void run()
- {
- running = true;
- while( running )
- {
- try
- {
- ScheduleTime scheduleTime = timing();
- if( scheduleTime != null )
- {
- waitFor( scheduleTime );
-
- if( isTime( scheduleTime ) ) // We might have been awakened to reschedule
- {
- updateNextTime( scheduleTime );
- }
- }
- else
- {
- waitFor( 100 );
- }
- }
- catch( Throwable e )
- {
- e.printStackTrace();
- }
- }
- }
-
- private ScheduleTime timing()
- {
- synchronized( lock )
- {
- if( timingQueue.size() == 0 )
- {
- return null;
- }
- return timingQueue.first();
- }
- }
-
- private boolean isTime( ScheduleTime scheduleTime )
- {
- return scheduleTime.nextTime().isBefore( Instant.now() );
- }
-
- private void waitFor( ScheduleTime scheduleTime )
- throws InterruptedException
- {
- Duration waitingTime = Duration.between( Instant.now(), scheduleTime.nextTime() );
- waitFor( waitingTime.toMillis() );
- }
-
- private void waitFor( long waitingTime )
- {
- if( waitingTime > 0 )
- {
- synchronized( lock )
- {
- try
- {
- lock.wait( waitingTime );
- }
- catch( InterruptedException e )
- {
- // should be ignored.
- }
- }
- }
- }
-
- @Override
- public void updateNextTime( ScheduleTime oldScheduleTime )
- {
- try (UnitOfWork uow = uowf.newUnitOfWork()) // This will discard() the UoW when block is exited. We are only doing reads, so fine.
- {
- submitTaskForExecution( oldScheduleTime );
- Schedule schedule = uow.get( Schedule.class, oldScheduleTime.scheduleIdentity() );
- Instant nextTime = schedule.nextRun( Instant.now() );
- if( nextTime.isAfter( Instant.MIN ) )
- {
- ScheduleTime newScheduleTime = new ScheduleTime( oldScheduleTime.scheduleIdentity(), nextTime );
- synchronized( lock )
- {
- // Re-add to the Timing Queue, to re-position the sorting.
- timingQueue.remove( oldScheduleTime );
- timingQueue.add( newScheduleTime );
- }
- }
- else
- {
- synchronized( lock )
- {
- timingQueue.remove( oldScheduleTime );
- }
- }
- }
- catch( NoSuchEntityException e )
- {
- e.printStackTrace();
-// scheduler.cancelSchedule( oldScheduleTime.scheduleIdentity() );
- }
- }
-
- private void submitTaskForExecution( ScheduleTime scheduleTime )
- {
- Runnable taskRunner = tbf.newTransient( Runnable.class, scheduleTime );
- this.taskExecutor.submit( taskRunner );
- }
-
- @Override
- public void dispatchForExecution( Schedule schedule )
- {
- Instant nextRun = schedule.nextRun( Instant.now() );
- if( nextRun.equals( Instant.MIN ) )
- {
- return;
- }
- synchronized( lock )
- {
- timingQueue.add( new ScheduleTime( schedule.identity().get(), nextRun ) );
- lock.notifyAll();
- }
- }
-
- @Override
- public void start()
- throws Exception
- {
- SchedulerConfiguration configuration = config.get();
- Integer workersCount = configuration.workersCount().get();
- Integer workQueueSize = configuration.workQueueSize().get();
- createThreadPoolExecutor( workersCount, workQueueSize );
- taskExecutor.prestartAllCoreThreads();
-
- SecurityManager sm = System.getSecurityManager();
- ThreadGroup threadGroup = sm != null ? sm.getThreadGroup() : TG;
- scheduleThread = new Thread( threadGroup, this, "Scheduler" );
- scheduleThread.start();
- }
-
- private void createThreadPoolExecutor( Integer workersCount, Integer workQueueSize )
- {
- int corePoolSize = 2;
- if( workersCount > 4 )
- {
- corePoolSize = workersCount / 4 + 1;
- }
- if( corePoolSize > 50 )
- {
- corePoolSize = 20;
- }
- if( workersCount > 200 )
- {
- workersCount = 200;
- }
- taskExecutor = new ThreadPoolExecutor( corePoolSize, workersCount,
- 0, TimeUnit.MILLISECONDS,
- new LinkedBlockingQueue<>( workQueueSize ),
- threadFactory, rejectionHandler );
- }
-
- @Override
- public void stop()
- throws Exception
- {
- running = false;
- synchronized( this )
- {
- scheduleThread.interrupt();
- }
- taskExecutor.shutdown();
- try
- {
- taskExecutor.awaitTermination( 5, TimeUnit.SECONDS );
- }
- catch( InterruptedException e )
- {
- e.printStackTrace();
- }
- taskExecutor.shutdownNow();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/8915dfaa/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/ScheduleTime.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/ScheduleTime.java b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/ScheduleTime.java
deleted file mode 100644
index caf9a75..0000000
--- a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/ScheduleTime.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-package org.apache.zest.library.scheduler.internal;
-
-import java.time.Instant;
-import org.apache.zest.api.util.NullArgumentException;
-
-public final class ScheduleTime
- implements Comparable<ScheduleTime>
-{
- private final String scheduleIdentity;
- private final Instant nextTime;
-
- public ScheduleTime( String scheduleIdentity, Instant nextTime )
- {
- NullArgumentException.validateNotEmpty( "scheduleIdentity", scheduleIdentity );
- this.scheduleIdentity = scheduleIdentity;
- this.nextTime = nextTime;
- }
-
- public Instant nextTime()
- {
- return nextTime;
- }
-
- public String scheduleIdentity()
- {
- return scheduleIdentity;
- }
-
- @Override
- public int compareTo( ScheduleTime another )
- {
- if( this.scheduleIdentity.equals( another.scheduleIdentity ) )
- {
- return 0;
- }
-
- if( this.nextTime.isBefore(another.nextTime) )
- {
- return -1;
- }
- return 1;
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/8915dfaa/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/SchedulerMixin.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/SchedulerMixin.java b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/SchedulerMixin.java
deleted file mode 100644
index 43dc826..0000000
--- a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/SchedulerMixin.java
+++ /dev/null
@@ -1,194 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-package org.apache.zest.library.scheduler.internal;
-
-import java.time.Instant;
-import org.apache.zest.api.configuration.Configuration;
-import org.apache.zest.api.injection.scope.Service;
-import org.apache.zest.api.injection.scope.Structure;
-import org.apache.zest.api.injection.scope.This;
-import org.apache.zest.api.service.ServiceActivation;
-import org.apache.zest.api.unitofwork.NoSuchEntityException;
-import org.apache.zest.api.unitofwork.UnitOfWork;
-import org.apache.zest.api.unitofwork.UnitOfWorkCompletionException;
-import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
-import org.apache.zest.api.usecase.UsecaseBuilder;
-import org.apache.zest.library.scheduler.CronSchedule;
-import org.apache.zest.library.scheduler.Schedule;
-import org.apache.zest.library.scheduler.ScheduleFactory;
-import org.apache.zest.library.scheduler.Scheduler;
-import org.apache.zest.library.scheduler.SchedulerConfiguration;
-import org.apache.zest.library.scheduler.SchedulerService;
-import org.apache.zest.library.scheduler.SchedulesHandler;
-import org.apache.zest.library.scheduler.Task;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class SchedulerMixin
- implements Scheduler, ServiceActivation
-{
- private static final Logger LOGGER = LoggerFactory.getLogger( Scheduler.class );
-
- @Service
- private ScheduleFactory scheduleFactory;
-
- @Structure
- private UnitOfWorkFactory uowf;
-
- @This
- private SchedulerService me;
-
- @This
- private SchedulesHandler schedulesHandler;
-
- @This
- private Execution execution;
-
- @This
- private Configuration<SchedulerConfiguration> config;
-
- @Override
- public Schedule scheduleOnce( Task task, int initialSecondsDelay )
- {
- Schedule schedule = scheduleFactory.newOnceSchedule( task, Instant.now().plusSeconds( initialSecondsDelay ) );
- saveAndDispatch( schedule );
- return schedule;
- }
-
- @Override
- public Schedule scheduleOnce( Task task, Instant runAt )
- {
- Schedule schedule = scheduleFactory.newOnceSchedule( task, runAt );
- saveAndDispatch( schedule );
- return schedule;
- }
-
- @Override
- public Schedule scheduleCron( Task task, String cronExpression )
- {
- Schedule schedule = scheduleFactory.newCronSchedule( task, cronExpression, Instant.now() );
- saveAndDispatch( schedule );
- return schedule;
- }
-
- @Override
- public Schedule scheduleCron( Task task, @CronSchedule.CronExpression String cronExpression, Instant start )
- {
- Schedule schedule = scheduleFactory.newCronSchedule( task, cronExpression, start );
- saveAndDispatch( schedule );
- return schedule;
- }
-
- @Override
- public void scheduleCron( Schedule schedule )
- {
- saveAndDispatch( schedule );
- }
-
- @Override
- public Schedule scheduleCron( Task task, String cronExpression, long initialDelay )
- {
- Instant start = Instant.now().plusMillis( initialDelay );
- Schedule schedule = scheduleFactory.newCronSchedule( task, cronExpression, start );
- saveAndDispatch( schedule );
- return schedule;
- }
-
- @Override
- public void cancelSchedule( String scheduleId )
- {
- UnitOfWork uow = uowf.currentUnitOfWork();
- Schedule schedule;
- try
- {
- schedule = uow.get( Schedule.class, scheduleId );
- }
- catch( NoSuchEntityException e )
- {
- return;
- }
- cancelSchedule( schedule );
- }
-
- @Override
- public void cancelSchedule( Schedule schedule )
- {
- Schedules active = schedulesHandler.getActiveSchedules();
- if( active.schedules().remove( schedule ) )
- {
- schedule.cancelled().set( true );
- }
- }
-
- private void saveAndDispatch( Schedule schedule )
- {
- Schedules schedules = schedulesHandler.getActiveSchedules();
- schedules.schedules().add( schedule );
- execution.dispatchForExecution( schedule );
- }
-
- private void loadSchedules()
- throws UnitOfWorkCompletionException
- {
- try (UnitOfWork ignored = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Initialize Schedules" ) ))
- {
- Schedules schedules = schedulesHandler.getActiveSchedules();
- for( Schedule schedule : schedules.schedules() )
- {
- dispatch( schedule );
- }
- }
- }
-
- private void dispatch( Schedule schedule )
- {
- try
- {
- if( !schedule.cancelled().get() && !schedule.done().get() )
- {
- execution.dispatchForExecution( schedule );
- }
- }
- catch( Exception e )
- {
- e.printStackTrace();
- }
- }
-
- @Override
- public void activateService()
- throws Exception
- {
- // Throws IllegalArgument if corePoolSize or keepAliveTime less than zero,
- // or if workersCount less than or equal to zero,
- // or if corePoolSize greater than workersCount.
- execution.start();
- loadSchedules();
- LOGGER.debug( "Activated" );
- }
-
- @Override
- public void passivateService()
- throws Exception
- {
- execution.stop();
- LOGGER.debug( "Passivated" );
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/8915dfaa/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/Schedules.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/Schedules.java b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/Schedules.java
deleted file mode 100644
index 8aa567a..0000000
--- a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/Schedules.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-package org.apache.zest.library.scheduler.internal;
-
-import org.apache.zest.api.association.ManyAssociation;
-import org.apache.zest.library.scheduler.Schedule;
-
-public interface Schedules
-{
- ManyAssociation<Schedule> schedules();
-}
[14/25] zest-java git commit: ZEST-151 : Ooops,
there were dependencies. Took the time to refactor some of the DCI
Cargo demo code in the process. Tests passes,
but somehow I doubt that it still works in actual runtime. Need to spend time
on that later.
Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/query/dto/LocationDTO.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/query/dto/LocationDTO.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/query/dto/LocationDTO.java
deleted file mode 100644
index 3a29269..0000000
--- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/query/dto/LocationDTO.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-package org.apache.zest.sample.dcicargo.sample_b.communication.query.dto;
-
-import org.apache.zest.sample.dcicargo.sample_b.data.structure.location.Location;
-import org.apache.zest.sample.dcicargo.sample_b.infrastructure.conversion.DTO;
-
-/**
- * Location DTO
- *
- * Since all properties of Location are immutable, we can simply re-use the same interface.
- * We need the Location as a DTO when we do entity to value conversions.
- */
-public interface LocationDTO extends Location, DTO
-{
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/query/dto/VoyageDTO.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/query/dto/VoyageDTO.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/query/dto/VoyageDTO.java
deleted file mode 100644
index 1635577..0000000
--- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/query/dto/VoyageDTO.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-package org.apache.zest.sample.dcicargo.sample_b.communication.query.dto;
-
-import org.apache.zest.sample.dcicargo.sample_b.data.structure.voyage.Voyage;
-import org.apache.zest.sample.dcicargo.sample_b.infrastructure.conversion.DTO;
-
-/**
- * Voyage DTO
- *
- * Since all properties of Voyage are immutable, we can simply re-use the same interface.
- * We need the Voyage as a DTO when we do entity to value conversions.
- */
-public interface VoyageDTO extends Voyage, DTO
-{
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/web/booking/CargoDetailsPage.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/web/booking/CargoDetailsPage.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/web/booking/CargoDetailsPage.java
index 65f568f..4840154 100644
--- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/web/booking/CargoDetailsPage.java
+++ b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/web/booking/CargoDetailsPage.java
@@ -33,9 +33,9 @@ import org.apache.wicket.model.LoadableDetachableModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.apache.zest.sample.dcicargo.sample_b.communication.query.CommonQueries;
-import org.apache.zest.sample.dcicargo.sample_b.communication.query.dto.CargoDTO;
import org.apache.zest.sample.dcicargo.sample_b.communication.web.tracking.HandlingHistoryPanel;
import org.apache.zest.sample.dcicargo.sample_b.communication.web.tracking.NextHandlingEventPanel;
+import org.apache.zest.sample.dcicargo.sample_b.data.structure.cargo.Cargo;
import org.apache.zest.sample.dcicargo.sample_b.data.structure.cargo.RouteSpecification;
import org.apache.zest.sample.dcicargo.sample_b.data.structure.delivery.Delivery;
import org.apache.zest.sample.dcicargo.sample_b.data.structure.delivery.RoutingStatus;
@@ -72,8 +72,8 @@ public class CargoDetailsPage extends BookingBasePage
{
super( new PageParameters().set( 0, trackingId ) );
- IModel<CargoDTO> cargoModel = new CommonQueries().cargo( trackingId );
- CargoDTO cargo = cargoModel.getObject();
+ IModel<Cargo> cargoModel = new CommonQueries().cargo( trackingId );
+ Cargo cargo = cargoModel.getObject();
Delivery delivery = cargo.delivery().get();
TransportStatus transportStatus = delivery.transportStatus().get();
RouteSpecification routeSpecification = cargo.routeSpecification().get();
@@ -144,7 +144,7 @@ public class CargoDetailsPage extends BookingBasePage
private class ItineraryFragment extends Fragment
{
- public ItineraryFragment( final IModel<CargoDTO> cargoModel, final RoutingStatus routingStatus )
+ public ItineraryFragment( final IModel<Cargo> cargoModel, final RoutingStatus routingStatus )
{
super( "itinerary", "itineraryFragment", CargoDetailsPage.this );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/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 1d6b887..4b17a9f 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
@@ -30,7 +30,7 @@ import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
import org.apache.zest.sample.dcicargo.sample_b.communication.query.CommonQueries;
-import org.apache.zest.sample.dcicargo.sample_b.communication.query.dto.CargoDTO;
+import org.apache.zest.sample.dcicargo.sample_b.data.structure.cargo.Cargo;
import org.apache.zest.sample.dcicargo.sample_b.data.structure.cargo.RouteSpecification;
import org.apache.zest.sample.dcicargo.sample_b.data.structure.delivery.Delivery;
import org.apache.zest.sample.dcicargo.sample_b.data.structure.delivery.RoutingStatus;
@@ -53,23 +53,23 @@ public class CargoListPage extends BookingBasePage
{
public CargoListPage()
{
- IModel<List<CargoDTO>> cargoList = new CommonQueries().cargoList();
+ IModel<List<Cargo>> cargoList = new CommonQueries().cargoList();
// Save current trackingIds in session (for prev/next buttons on details page)
ArrayList<String> ids = new ArrayList<String>();
- for( CargoDTO cargo : cargoList.getObject() )
+ for( Cargo cargo : cargoList.getObject() )
{
ids.add( cargo.trackingId().get().id().get() );
}
PrevNext.registerIds( Session.get(), ids );
- add( new ListView<CargoDTO>( "list", cargoList )
+ add( new ListView<Cargo>( "list", cargoList )
{
@Override
- protected void populateItem( ListItem<CargoDTO> item )
+ protected void populateItem( ListItem<Cargo> item )
{
// Cargo
- CargoDTO cargo = item.getModelObject();
+ Cargo cargo = item.getModelObject();
String trackingId = cargo.trackingId().get().id().get();
String origin = cargo.origin().get().getCode();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/web/booking/ChangeDestinationPage.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/web/booking/ChangeDestinationPage.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/web/booking/ChangeDestinationPage.java
index 956ec78..3dd9fe1 100644
--- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/web/booking/ChangeDestinationPage.java
+++ b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/web/booking/ChangeDestinationPage.java
@@ -28,9 +28,9 @@ import org.apache.wicket.markup.html.panel.ComponentFeedbackPanel;
import org.apache.wicket.markup.html.panel.FeedbackPanel;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.apache.zest.sample.dcicargo.sample_b.communication.query.CommonQueries;
-import org.apache.zest.sample.dcicargo.sample_b.communication.query.dto.CargoDTO;
import org.apache.zest.sample.dcicargo.sample_b.context.interaction.booking.routing.RegisterNewDestination;
import org.apache.zest.sample.dcicargo.sample_b.context.interaction.handling.inspection.exception.CargoMisroutedException;
+import org.apache.zest.sample.dcicargo.sample_b.data.structure.cargo.Cargo;
import org.apache.zest.sample.dcicargo.sample_b.infrastructure.wicket.form.AbstractForm;
import org.apache.zest.sample.dcicargo.sample_b.infrastructure.wicket.form.SelectorInForm;
@@ -54,7 +54,7 @@ public class ChangeDestinationPage extends BookingBasePage
public CargoEditForm( final String trackingId )
{
CommonQueries fetch = new CommonQueries();
- CargoDTO cargo = fetch.cargo( trackingId ).getObject();
+ Cargo cargo = fetch.cargo( trackingId ).getObject();
List<String> locations = fetch.unLocodes();
origin = cargo.routeSpecification().get().origin().get().getCode();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/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 55d8935..6b672c1 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
@@ -33,8 +33,8 @@ import org.apache.wicket.model.Model;
import org.apache.wicket.model.StringResourceModel;
import org.apache.wicket.util.value.ValueMap;
import org.apache.zest.sample.dcicargo.sample_b.communication.query.TrackingQueries;
-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.data.structure.cargo.Cargo;
+import org.apache.zest.sample.dcicargo.sample_b.data.structure.handling.HandlingEvent;
import org.apache.zest.sample.dcicargo.sample_b.infrastructure.wicket.color.ErrorColor;
import static java.util.Date.from;
@@ -49,18 +49,18 @@ import static java.util.Date.from;
@StatelessComponent
public class HandlingHistoryPanel extends Panel
{
- public HandlingHistoryPanel( String id, final IModel<CargoDTO> cargoModel, String trackingId )
+ public HandlingHistoryPanel( String id, final IModel<Cargo> cargoModel, String trackingId )
{
super( id );
- IModel<List<HandlingEventDTO>> handlingEventsModel = new TrackingQueries().events( trackingId );
+ IModel<List<HandlingEvent>> handlingEventsModel = new TrackingQueries().events( trackingId );
- add( new ListView<HandlingEventDTO>( "handlingEvents", handlingEventsModel )
+ add( new ListView<HandlingEvent>( "handlingEvents", handlingEventsModel )
{
@Override
- protected void populateItem( ListItem<HandlingEventDTO> item )
+ protected void populateItem( ListItem<HandlingEvent> item )
{
- HandlingEventDTO event = item.getModelObject();
+ HandlingEvent event = item.getModelObject();
Boolean isLast = item.getIndex() == getList().size() - 1;
Boolean isMisdirected = cargoModel.getObject().delivery().get().isMisdirected().get();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/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 1bc8c13..0b7d701 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
@@ -27,7 +27,7 @@ import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.model.StringResourceModel;
import org.apache.wicket.util.value.ValueMap;
-import org.apache.zest.sample.dcicargo.sample_b.communication.query.dto.CargoDTO;
+import org.apache.zest.sample.dcicargo.sample_b.data.structure.cargo.Cargo;
import org.apache.zest.sample.dcicargo.sample_b.data.structure.delivery.NextHandlingEvent;
import org.apache.zest.sample.dcicargo.sample_b.data.structure.handling.HandlingEvent;
import org.apache.zest.sample.dcicargo.sample_b.data.structure.handling.HandlingEventType;
@@ -41,7 +41,7 @@ import org.apache.zest.sample.dcicargo.sample_b.data.structure.location.Location
@StatelessComponent
public class NextHandlingEventPanel extends Panel
{
- public NextHandlingEventPanel( String id, IModel<CargoDTO> cargoModel )
+ public NextHandlingEventPanel( String id, IModel<Cargo> cargoModel )
{
super( id );
@@ -50,7 +50,7 @@ public class NextHandlingEventPanel extends Panel
"nextEvent.${nextEvent}", this, new Model<ValueMap>( map ) ) );
add( label );
- CargoDTO cargo = cargoModel.getObject();
+ Cargo cargo = cargoModel.getObject();
Location destination = cargo.routeSpecification().get().destination().get();
if( cargo.itinerary().get() == null )
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/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 26f3c11..f810d8d 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
@@ -38,8 +38,8 @@ import org.apache.wicket.util.value.ValueMap;
import org.apache.zest.api.unitofwork.NoSuchEntityException;
import org.apache.zest.sample.dcicargo.sample_b.communication.query.CommonQueries;
import org.apache.zest.sample.dcicargo.sample_b.communication.query.TrackingQueries;
-import org.apache.zest.sample.dcicargo.sample_b.communication.query.dto.CargoDTO;
import org.apache.zest.sample.dcicargo.sample_b.communication.web.BasePage;
+import org.apache.zest.sample.dcicargo.sample_b.data.structure.cargo.Cargo;
import org.apache.zest.sample.dcicargo.sample_b.data.structure.handling.HandlingEvent;
import org.apache.zest.sample.dcicargo.sample_b.data.structure.handling.HandlingEventType;
import org.apache.zest.sample.dcicargo.sample_b.infrastructure.wicket.form.AbstractForm;
@@ -114,7 +114,7 @@ public class TrackCargoPage extends BasePage
{
try
{
- IModel<CargoDTO> cargoModel = new CommonQueries().cargo( trackingId );
+ IModel<Cargo> cargoModel = new CommonQueries().cargo( trackingId );
statusFragment = (Fragment) statusFragment.replaceWith( new StatusFragment( cargoModel, false ) );
target.add( feedback, trackingIdInput, selectedTrackingIdSelector, statusFragment.setVisible( true ) );
}
@@ -135,12 +135,12 @@ public class TrackCargoPage extends BasePage
private class StatusFragment extends Fragment
{
- public StatusFragment( IModel<CargoDTO> cargoModel, Boolean visible )
+ public StatusFragment( IModel<Cargo> cargoModel, Boolean visible )
{
super( "status", "statusFragment", TrackingForm.this );
setVisible( visible );
- CargoDTO cargo = cargoModel.getObject();
+ Cargo cargo = cargoModel.getObject();
// Status ----------------------------------------------------------------------
ValueMap map = new ValueMap();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/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 36be860..f6a201c 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
@@ -51,12 +51,12 @@ import static org.apache.zest.sample.dcicargo.sample_b.data.structure.delivery.T
*/
public class DeriveUpdatedRouteSpecification extends Context
{
- CargoInspectorRole cargoInspector;
+ private CargoInspectorRole cargoInspector;
- RouteSpecification routeSpecification;
- TransportStatus transportStatus;
- HandlingEvent lastHandlingEvent;
- Location newDestination;
+ private RouteSpecification routeSpecification;
+ private TransportStatus transportStatus;
+ private HandlingEvent lastHandlingEvent;
+ private Location newDestination;
public DeriveUpdatedRouteSpecification( Cargo cargo )
{
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/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 7e68fb8..421e634 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
@@ -55,14 +55,14 @@ import static org.apache.zest.sample.dcicargo.sample_b.data.structure.handling.H
*/
public class InspectCargoInCustoms extends Context
{
- DeliveryInspectorRole deliveryInspector;
+ private DeliveryInspectorRole deliveryInspector;
- HandlingEvent customsEvent;
+ private HandlingEvent customsEvent;
- RouteSpecification routeSpecification;
- Itinerary itinerary;
- Integer itineraryProgressIndex;
- TransportStatus transportStatus;
+ private RouteSpecification routeSpecification;
+ private Itinerary itinerary;
+ private Integer itineraryProgressIndex;
+ private TransportStatus transportStatus;
public InspectCargoInCustoms( Cargo cargo, HandlingEvent handlingEvent )
{
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/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 0c91f0f..5f93b13 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
@@ -51,14 +51,14 @@ import static org.apache.zest.sample.dcicargo.sample_b.data.structure.handling.H
*/
public class InspectClaimedCargo extends Context
{
- DeliveryInspectorRole deliveryInspector;
+ private DeliveryInspectorRole deliveryInspector;
- HandlingEvent claimEvent;
- Location claimLocation;
+ private HandlingEvent claimEvent;
+ private Location claimLocation;
- RouteSpecification routeSpecification;
- Itinerary itinerary;
- Integer itineraryProgressIndex;
+ private RouteSpecification routeSpecification;
+ private Itinerary itinerary;
+ private Integer itineraryProgressIndex;
public InspectClaimedCargo( Cargo cargo, HandlingEvent handlingEvent )
{
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/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 69d8312..2694e55 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
@@ -34,7 +34,9 @@ import org.apache.zest.sample.dcicargo.sample_b.data.structure.itinerary.Itinera
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.NOT_RECEIVED;
import static org.apache.zest.sample.dcicargo.sample_b.data.structure.handling.HandlingEventType.RECEIVE;
@@ -47,12 +49,13 @@ import static org.apache.zest.sample.dcicargo.sample_b.data.structure.handling.H
*/
public class InspectUnhandledCargo extends Context
{
- DeliveryInspectorRole deliveryInspector;
+ private DeliveryInspectorRole deliveryInspector;
- HandlingEvent noEvent;
+ private HandlingEvent noEvent;
- RouteSpecification routeSpecification;
- Itinerary itinerary;
+ private RouteSpecification routeSpecification;
+
+ private Itinerary itinerary;
public InspectUnhandledCargo( Cargo cargo )
{
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/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 ff1ef7a..d1909d9 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
@@ -32,7 +32,7 @@ import org.apache.zest.sample.dcicargo.sample_b.infrastructure.conversion.DTO;
*/
@Immutable
@Mixins( ParsedHandlingEventData.Mixin.class )
-public interface ParsedHandlingEventData extends DTO
+public interface ParsedHandlingEventData
{
Property<LocalDate> registrationDate();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/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 da83223..17e159b 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
@@ -35,7 +35,6 @@ import org.apache.zest.sample.dcicargo.sample_b.context.interaction.handling.reg
import org.apache.zest.sample.dcicargo.sample_b.context.interaction.handling.registration.exception.UnknownLocationException;
import org.apache.zest.sample.dcicargo.sample_b.context.interaction.handling.registration.exception.UnknownVoyageException;
import org.apache.zest.sample.dcicargo.sample_b.data.aggregateroot.HandlingEventAggregateRoot;
-import org.apache.zest.sample.dcicargo.sample_b.data.entity.HandlingEventEntity;
import org.apache.zest.sample.dcicargo.sample_b.data.factory.HandlingEventFactory;
import org.apache.zest.sample.dcicargo.sample_b.data.factory.exception.CannotCreateHandlingEventException;
import org.apache.zest.sample.dcicargo.sample_b.data.structure.cargo.Cargo;
@@ -79,13 +78,13 @@ import static org.apache.zest.sample.dcicargo.sample_b.data.structure.handling.H
*/
public class RegisterHandlingEvent extends Context
{
- EventRegistrarRole eventRegistrar;
+ private EventRegistrarRole eventRegistrar;
- ParsedHandlingEventData eventData;
- HandlingEventType eventType;
- String trackingIdString;
- String unLocodeString;
- String voyageNumberString;
+ private ParsedHandlingEventData eventData;
+ private HandlingEventType eventType;
+ private String trackingIdString;
+ private String unLocodeString;
+ private String voyageNumberString;
public RegisterHandlingEvent( ParsedHandlingEventData parsedEventData )
{
@@ -171,14 +170,14 @@ public class RegisterHandlingEvent extends Context
if( c.eventType.equals( RECEIVE ) || c.eventType.equals( CUSTOMS ) || c.eventType.equals( CLAIM ) )
{
- QueryBuilder<HandlingEventEntity> qb = qbf.newQueryBuilder( HandlingEventEntity.class )
+ QueryBuilder<HandlingEvent> qb = qbf.newQueryBuilder( HandlingEvent.class )
.where(
and(
eq( templateFor( HandlingEvent.class ).trackingId().get().id(), c.trackingIdString ),
eq( templateFor( HandlingEvent.class ).handlingEventType(), c.eventType )
)
);
- Query<HandlingEventEntity> duplicates = uowf.currentUnitOfWork().newQuery( qb );
+ Query<HandlingEvent> duplicates = uowf.currentUnitOfWork().newQuery( qb );
if( duplicates.count() > 0 )
{
throw new DuplicateEventException( c.eventData );
@@ -190,14 +189,14 @@ public class RegisterHandlingEvent extends Context
if( !c.eventType.equals( CLAIM ) )
{
HandlingEvent eventTemplate = templateFor( HandlingEvent.class );
- QueryBuilder<HandlingEventEntity> qb = qbf.newQueryBuilder( HandlingEventEntity.class )
+ QueryBuilder<HandlingEvent> qb = qbf.newQueryBuilder( HandlingEvent.class )
.where(
and(
eq( eventTemplate.trackingId().get().id(), c.trackingIdString ),
eq( eventTemplate.handlingEventType(), CLAIM )
)
);
- Query<HandlingEventEntity> alreadyClaimed = uowf.currentUnitOfWork().newQuery( qb );
+ Query<HandlingEvent> alreadyClaimed = uowf.currentUnitOfWork().newQuery( qb );
if( alreadyClaimed.count() > 0 )
{
throw new AlreadyClaimedException( c.eventData );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/rolemap/CargoRoleMap.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/rolemap/CargoRoleMap.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/rolemap/CargoRoleMap.java
index aa61125..c56addb 100644
--- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/rolemap/CargoRoleMap.java
+++ b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/context/rolemap/CargoRoleMap.java
@@ -19,6 +19,7 @@
*/
package org.apache.zest.sample.dcicargo.sample_b.context.rolemap;
+import org.apache.zest.api.entity.EntityComposite;
import org.apache.zest.sample.dcicargo.sample_b.context.interaction.booking.routing.AssignCargoToRoute;
import org.apache.zest.sample.dcicargo.sample_b.context.interaction.booking.routing.RegisterNewDestination;
import org.apache.zest.sample.dcicargo.sample_b.context.interaction.booking.specification.DeriveUpdatedRouteSpecification;
@@ -30,7 +31,7 @@ import org.apache.zest.sample.dcicargo.sample_b.context.interaction.handling.ins
import org.apache.zest.sample.dcicargo.sample_b.context.interaction.handling.inspection.event.InspectReceivedCargo;
import org.apache.zest.sample.dcicargo.sample_b.context.interaction.handling.inspection.event.InspectUnhandledCargo;
import org.apache.zest.sample.dcicargo.sample_b.context.interaction.handling.inspection.event.InspectUnloadedCargo;
-import org.apache.zest.sample.dcicargo.sample_b.data.entity.CargoEntity;
+import org.apache.zest.sample.dcicargo.sample_b.data.structure.cargo.Cargo;
/**
* Cargo Role Map
@@ -40,20 +41,20 @@ import org.apache.zest.sample.dcicargo.sample_b.data.entity.CargoEntity;
* Note that the CargoEntity knows nothing about this map (and that Cargo (Data) knows nothing about CargoEntity).
*/
public interface CargoRoleMap
- extends CargoEntity,
+ extends
- RegisterNewDestination.CargoInspectorRole,
- AssignCargoToRoute.CargoInspectorRole,
- DeriveUpdatedRouteSpecification.CargoInspectorRole,
+ RegisterNewDestination.CargoInspectorRole,
+ AssignCargoToRoute.CargoInspectorRole,
+ DeriveUpdatedRouteSpecification.CargoInspectorRole,
- InspectCargoDeliveryStatus.DeliveryInspectorRole,
+ InspectCargoDeliveryStatus.DeliveryInspectorRole,
- InspectUnhandledCargo.DeliveryInspectorRole,
- InspectReceivedCargo.DeliveryInspectorRole,
- InspectLoadedCargo.DeliveryInspectorRole,
- InspectUnloadedCargo.DeliveryInspectorRole,
- InspectArrivedCargo.DeliveryInspectorRole,
- InspectCargoInCustoms.DeliveryInspectorRole,
- InspectClaimedCargo.DeliveryInspectorRole
+ InspectUnhandledCargo.DeliveryInspectorRole,
+ InspectReceivedCargo.DeliveryInspectorRole,
+ InspectLoadedCargo.DeliveryInspectorRole,
+ InspectUnloadedCargo.DeliveryInspectorRole,
+ InspectArrivedCargo.DeliveryInspectorRole,
+ InspectCargoInCustoms.DeliveryInspectorRole,
+ InspectClaimedCargo.DeliveryInspectorRole, EntityComposite, Cargo
{
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/data/entity/CargoEntity.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/data/entity/CargoEntity.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/data/entity/CargoEntity.java
deleted file mode 100644
index 86175ae..0000000
--- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/data/entity/CargoEntity.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-package org.apache.zest.sample.dcicargo.sample_b.data.entity;
-
-import org.apache.zest.api.entity.EntityComposite;
-import org.apache.zest.sample.dcicargo.sample_b.data.structure.cargo.Cargo;
-
-/**
- * Cargo entity
- */
-public interface CargoEntity
- extends EntityComposite,
-
- Cargo
-{
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/data/entity/HandlingEventEntity.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/data/entity/HandlingEventEntity.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/data/entity/HandlingEventEntity.java
deleted file mode 100644
index 187506e..0000000
--- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/data/entity/HandlingEventEntity.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-package org.apache.zest.sample.dcicargo.sample_b.data.entity;
-
-import org.apache.zest.api.entity.EntityComposite;
-import org.apache.zest.sample.dcicargo.sample_b.data.structure.handling.HandlingEvent;
-
-/**
- * Handling Event entity
- */
-public interface HandlingEventEntity
- extends EntityComposite,
-
- HandlingEvent
-{
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/data/entity/LocationEntity.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/data/entity/LocationEntity.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/data/entity/LocationEntity.java
deleted file mode 100644
index 2c2d680..0000000
--- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/data/entity/LocationEntity.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-package org.apache.zest.sample.dcicargo.sample_b.data.entity;
-
-import org.apache.zest.api.entity.EntityComposite;
-import org.apache.zest.sample.dcicargo.sample_b.data.structure.location.Location;
-
-/**
- * Location entity
- *
- * Locations have been created outside the shipping application context so we don't have any
- * separate aggregate root to create those from.
- */
-public interface LocationEntity
- extends EntityComposite,
-
- Location
-{
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/data/entity/VoyageEntity.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/data/entity/VoyageEntity.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/data/entity/VoyageEntity.java
deleted file mode 100644
index 842cf41..0000000
--- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/data/entity/VoyageEntity.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-package org.apache.zest.sample.dcicargo.sample_b.data.entity;
-
-import org.apache.zest.api.entity.EntityComposite;
-import org.apache.zest.sample.dcicargo.sample_b.data.structure.voyage.Voyage;
-
-/**
- * Voyage entity
- *
- * Voyages have been created outside the shipping application context so we don't have any
- * separate aggregate root to create those from.
- */
-public interface VoyageEntity
- extends EntityComposite,
-
- Voyage
-{
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/data/structure/cargo/Cargo.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/data/structure/cargo/Cargo.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/data/structure/cargo/Cargo.java
index 69a13ef..86efe72 100644
--- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/data/structure/cargo/Cargo.java
+++ b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/data/structure/cargo/Cargo.java
@@ -21,6 +21,7 @@ package org.apache.zest.sample.dcicargo.sample_b.data.structure.cargo;
import org.apache.zest.api.association.Association;
import org.apache.zest.api.common.Optional;
+import org.apache.zest.api.entity.Identity;
import org.apache.zest.api.property.Immutable;
import org.apache.zest.api.property.Property;
import org.apache.zest.sample.dcicargo.sample_b.data.structure.delivery.Delivery;
@@ -39,7 +40,7 @@ import org.apache.zest.sample.dcicargo.sample_b.data.structure.tracking.Tracking
* {@link Itinerary} Description of chosen route (optional)
* {@link Delivery} Snapshot of the current delivery status (automatically created by the system)
*/
-public interface Cargo
+public interface Cargo extends Identity
{
@Immutable
Property<TrackingId> trackingId();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/data/structure/handling/HandlingEvent.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/data/structure/handling/HandlingEvent.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/data/structure/handling/HandlingEvent.java
index a905caf..35f84b8 100644
--- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/data/structure/handling/HandlingEvent.java
+++ b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/data/structure/handling/HandlingEvent.java
@@ -22,6 +22,7 @@ package org.apache.zest.sample.dcicargo.sample_b.data.structure.handling;
import java.time.LocalDate;
import org.apache.zest.api.association.Association;
import org.apache.zest.api.common.Optional;
+import org.apache.zest.api.entity.Identity;
import org.apache.zest.api.mixin.Mixins;
import org.apache.zest.api.property.Immutable;
import org.apache.zest.api.property.Property;
@@ -54,13 +55,13 @@ import org.apache.zest.sample.dcicargo.sample_b.data.structure.voyage.Voyage;
*/
@Immutable
@Mixins( HandlingEvent.Mixin.class )
-public interface HandlingEvent
+public interface HandlingEvent extends Identity
{
- Property<LocalDate> registrationDate();
+ Property<TrackingId> trackingId();
Property<LocalDate> completionDate();
- Property<TrackingId> trackingId();
+ Property<LocalDate> registrationDate();
Property<HandlingEventType> handlingEventType();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/infrastructure/WicketZestApplication.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/infrastructure/WicketZestApplication.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/infrastructure/WicketZestApplication.java
index 73c6fbf..c6c5281 100644
--- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/infrastructure/WicketZestApplication.java
+++ b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/infrastructure/WicketZestApplication.java
@@ -38,7 +38,6 @@ import org.apache.zest.api.usecase.UsecaseBuilder;
import org.apache.zest.api.value.ValueBuilderFactory;
import org.apache.zest.bootstrap.ApplicationAssembler;
import org.apache.zest.bootstrap.Energy4Java;
-import org.apache.zest.sample.dcicargo.sample_b.infrastructure.conversion.EntityToDTOService;
import org.apache.zest.sample.dcicargo.sample_b.infrastructure.dci.Context;
import org.apache.zest.sample.dcicargo.sample_b.infrastructure.model.Queries;
import org.apache.zest.sample.dcicargo.sample_b.infrastructure.model.ReadOnlyModel;
@@ -74,9 +73,6 @@ public class WicketZestApplication
@Structure
protected ZestAPI api;
- @Service
- protected EntityToDTOService valueConverter;
-
/**
* Zest Assembler
*
@@ -135,7 +131,7 @@ public class WicketZestApplication
Context.prepareContextBaseClass( uowf, vbf );
BaseWebPage.prepareBaseWebPageClass( tbf );
- ReadOnlyModel.prepareModelBaseClass( zestModule, api, valueConverter );
+ ReadOnlyModel.prepareModelBaseClass( zestModule, api);
Queries.prepareQueriesBaseClass( uowf, qbf );
wicketInit();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/infrastructure/conversion/DTO.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/infrastructure/conversion/DTO.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/infrastructure/conversion/DTO.java
index ddd84c1..511f346 100644
--- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/infrastructure/conversion/DTO.java
+++ b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/infrastructure/conversion/DTO.java
@@ -19,6 +19,7 @@
*/
package org.apache.zest.sample.dcicargo.sample_b.infrastructure.conversion;
+import org.apache.zest.api.entity.Identity;
import org.apache.zest.api.property.Immutable;
import org.apache.zest.api.value.ValueComposite;
@@ -32,6 +33,6 @@ import org.apache.zest.api.value.ValueComposite;
* assigned in the EntityToDTOService.
*/
@Immutable
-public interface DTO extends ValueComposite
+public interface DTO extends ValueComposite, Identity
{
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/infrastructure/conversion/EntityToDTOService.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/infrastructure/conversion/EntityToDTOService.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/infrastructure/conversion/EntityToDTOService.java
deleted file mode 100644
index 88089a9..0000000
--- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/infrastructure/conversion/EntityToDTOService.java
+++ /dev/null
@@ -1,335 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-package org.apache.zest.sample.dcicargo.sample_b.infrastructure.conversion;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.function.Function;
-import java.util.stream.Collectors;
-import org.apache.zest.api.association.AssociationDescriptor;
-import org.apache.zest.api.association.AssociationStateHolder;
-import org.apache.zest.api.association.ManyAssociation;
-import org.apache.zest.api.entity.EntityComposite;
-import org.apache.zest.api.entity.EntityDescriptor;
-import org.apache.zest.api.entity.EntityReference;
-import org.apache.zest.api.entity.Identity;
-import org.apache.zest.api.injection.scope.Structure;
-import org.apache.zest.api.mixin.Mixins;
-import org.apache.zest.api.property.PropertyDescriptor;
-import org.apache.zest.api.service.ServiceComposite;
-import org.apache.zest.api.structure.ModuleDescriptor;
-import org.apache.zest.api.type.CollectionType;
-import org.apache.zest.api.value.NoSuchValueException;
-import org.apache.zest.api.value.ValueBuilder;
-import org.apache.zest.api.value.ValueBuilderFactory;
-import org.apache.zest.api.value.ValueDescriptor;
-import org.apache.zest.functional.Iterables;
-import org.apache.zest.library.conversion.values.Unqualified;
-import org.apache.zest.spi.ZestSPI;
-
-/**
- * Conversion of Entity objects to DTO's
- *
- * Value composites that extend {@link DTO} will have association properties converted recursively.
- *
- * Modification of {org.apache.zest.library.conversion.values.EntityToValue}
- * WARN No support of NamedAssociations
- */
-@SuppressWarnings( "unchecked" )
-@Mixins( EntityToDTOService.Mixin.class )
-public interface EntityToDTOService
- extends ServiceComposite
-{
- <T> T convert( Class<T> valueType, Object entity );
-
- static abstract class Mixin
- implements EntityToDTOService
- {
- @Structure
- private ValueBuilderFactory vbf;
-
- @Structure
- private ZestSPI spi;
-
- @Structure
- private ModuleDescriptor module;
-
- @Override
- public <T> T convert( final Class<T> valueType, Object entity )
- {
- ValueDescriptor valueDescriptor = module.valueDescriptor( valueType.getName() );
- if( valueDescriptor == null )
- {
- throw new NoSuchValueException( valueType.getName(), module.name(), module.typeLookup() );
- }
- Unqualified unqualified = valueDescriptor.metaInfo( Unqualified.class );
- final EntityComposite composite = (EntityComposite) entity;
- final EntityDescriptor entityDescriptor = spi.entityDescriptorFor( composite );
- final AssociationStateHolder associationState = spi.stateOf( composite );
- ValueBuilder<?> builder;
-
- if( unqualified == null || !unqualified.value() )
- {
- // Copy state using qualified names
- builder = vbf.newValueBuilderWithState( valueType, new Function<PropertyDescriptor, Object>()
- {
- @Override
- public Object apply( PropertyDescriptor descriptor )
- {
- try
- {
- return associationState.propertyFor( descriptor.accessor() ).get();
- }
- catch( IllegalArgumentException e )
- {
- if( descriptor.valueType().mainType().equals( String.class ) )
- {
- // Find Association and convert to string
- AssociationDescriptor associationDescriptor;
- try
- {
- associationDescriptor = entityDescriptor.state()
- .getAssociationByName( descriptor.qualifiedName().name() );
- }
- catch( IllegalArgumentException e1 )
- {
- return null;
- }
- Object entity = associationState.associationFor( associationDescriptor.accessor() )
- .get();
- if( entity != null )
- {
- return ( (Identity) entity ).identity().get();
- }
- else
- {
- return null;
- }
- }
- else if( descriptor.valueType() instanceof CollectionType
- && ( (CollectionType) descriptor.valueType() ).collectedType()
- .mainType()
- .equals( String.class ) )
- {
- AssociationDescriptor associationDescriptor;
- try
- {
- associationDescriptor = entityDescriptor.state()
- .getManyAssociationByName( descriptor.qualifiedName().name() );
- }
- catch( IllegalArgumentException e1 )
- {
- return Collections.emptyList();
- }
-
- ManyAssociation<?> state = associationState.manyAssociationFor( associationDescriptor.accessor() );
- List<String> entities = new ArrayList<>( state.count() );
- for( Object entity : state )
- {
- entities.add( ( (Identity) entity ).identity().get() );
- }
- return entities;
- }
-
- // No NamedAssociation support
-
- return null;
- }
- }
- }, new Function<AssociationDescriptor, EntityReference>()
- {
- @Override
- public EntityReference apply( AssociationDescriptor associationDescriptor )
- {
- return EntityReference.entityReferenceFor(
- associationState.associationFor( associationDescriptor.accessor() ).get() );
- }
- }, new Function<AssociationDescriptor, Iterable<EntityReference>>()
- {
- @Override
- public Iterable<EntityReference> apply( AssociationDescriptor associationDescriptor )
- {
- ManyAssociation<?> state = associationState.manyAssociationFor( associationDescriptor.accessor() );
- List<EntityReference> refs = new ArrayList<>( state.count() );
- for( Object entity : state )
- {
- refs.add( EntityReference.entityReferenceFor( entity ) );
- }
- return refs;
- }
- }, new Function<AssociationDescriptor, Map<String, EntityReference>>()
- {
- @Override
- public Map<String, EntityReference> apply( AssociationDescriptor from )
- {
- throw new UnsupportedOperationException( "NamedAssociations are not supported." );
- }
- } );
- }
- else
- {
- builder = vbf.newValueBuilderWithState( valueType, new Function<PropertyDescriptor, Object>()
- {
- @Override
- public Object apply( PropertyDescriptor descriptor )
- {
- try
- {
- PropertyDescriptor propertyDescriptor = entityDescriptor.state()
- .findPropertyModelByName( descriptor.qualifiedName().name() );
- return associationState.propertyFor( propertyDescriptor.accessor() ).get();
- }
- catch( IllegalArgumentException e )
- {
- if( descriptor.valueType().mainType().equals( String.class ) )
- {
- // Find Association and convert to string
- AssociationDescriptor associationDescriptor;
- try
- {
- associationDescriptor = entityDescriptor.state()
- .getAssociationByName( descriptor.qualifiedName().name() );
- }
- catch( IllegalArgumentException e1 )
- {
- return null;
- }
-
- Object entity = associationState.associationFor( associationDescriptor.accessor() )
- .get();
- if( entity != null )
- {
- return ( (Identity) entity ).identity().get();
- }
- return null;
- }
- else if( descriptor.valueType() instanceof CollectionType
- && ( (CollectionType) descriptor.valueType() ).collectedType()
- .mainType()
- .equals( String.class ) )
- {
- AssociationDescriptor associationDescriptor;
- try
- {
- associationDescriptor = entityDescriptor.state()
- .getManyAssociationByName( descriptor.qualifiedName().name() );
- }
- catch( IllegalArgumentException e1 )
- {
- return null;
- }
-
- ManyAssociation<?> state = associationState.manyAssociationFor( associationDescriptor.accessor() );
- List<String> entities = new ArrayList<>( state.count() );
- for( Object entity : state )
- {
- entities.add( ( (Identity) entity ).identity().get() );
- }
- return entities;
- }
-
- // No NamedAssociation support
-
- // DTO
- Class<?> type = descriptor.valueType().mainType();
- if( DTO.class.isAssignableFrom( type ) )
- {
- AssociationDescriptor associationDescriptor;
- try
- {
- associationDescriptor = entityDescriptor.state()
- .getAssociationByName( descriptor.qualifiedName().name() );
- }
- catch( IllegalArgumentException e1 )
- {
- return null;
- }
-
- Object entity = associationState.associationFor( associationDescriptor.accessor() )
- .get();
- if( entity != null )
- {
- return convert( type, entity );
- }
- }
-
- return null;
- }
- }
- }, new Function<AssociationDescriptor, EntityReference>()
- {
- @Override
- public EntityReference apply( AssociationDescriptor descriptor )
- {
- AssociationDescriptor associationDescriptor;
- try
- {
- associationDescriptor = entityDescriptor.state()
- .getAssociationByName( descriptor.qualifiedName().name() );
- }
- catch( IllegalArgumentException e )
- {
- return null;
- }
-
- return EntityReference.entityReferenceFor( associationState
- .associationFor( associationDescriptor.accessor() )
- .get() );
- }
- }, new Function<AssociationDescriptor, Iterable<EntityReference>>()
- {
- @Override
- public Iterable<EntityReference> apply( AssociationDescriptor descriptor )
- {
- AssociationDescriptor associationDescriptor;
- try
- {
- associationDescriptor = entityDescriptor.state()
- .getManyAssociationByName( descriptor.qualifiedName().name() );
- }
- catch( IllegalArgumentException e )
- {
- return Iterables.empty();
- }
-
- ManyAssociation<?> state = associationState.manyAssociationFor( associationDescriptor.accessor() );
- List<EntityReference> refs = new ArrayList<>( state.count() );
- for( Object entity : state )
- {
- refs.add( EntityReference.entityReferenceFor( entity ) );
- }
- return refs;
- }
- }, new Function<AssociationDescriptor, Map<String, EntityReference>>()
- {
- @Override
- public Map<String, EntityReference> apply( AssociationDescriptor from )
- {
- throw new UnsupportedOperationException( "NamedAssociations are not supported." );
- }
- } );
- }
-
- return (T) builder.newInstance();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/infrastructure/model/EntityModel.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/infrastructure/model/EntityModel.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/infrastructure/model/EntityModel.java
index e15e921..4191630 100644
--- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/infrastructure/model/EntityModel.java
+++ b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/infrastructure/model/EntityModel.java
@@ -22,6 +22,7 @@ package org.apache.zest.sample.dcicargo.sample_b.infrastructure.model;
import org.apache.wicket.model.IModel;
import org.apache.zest.api.entity.EntityComposite;
import org.apache.zest.api.entity.EntityReference;
+import org.apache.zest.api.entity.Identity;
import org.apache.zest.api.unitofwork.NoSuchEntityException;
import org.apache.zest.api.usecase.Usecase;
import org.apache.zest.sample.dcicargo.sample_b.infrastructure.conversion.DTO;
@@ -35,34 +36,34 @@ import org.apache.zest.sample.dcicargo.sample_b.infrastructure.conversion.DTO;
* Zest entities are therefore lazy loaded with a class and identity through our UnitOfWork
* and then converted to a DTO ValueComposite.
*/
-public class EntityModel<T extends DTO, U extends EntityComposite>
+public class EntityModel<T extends Identity>
extends ReadOnlyModel<T>
{
- private Class<U> entityClass;
+ private Class<T> entityClass;
private String identity;
private Class<T> dtoClass;
private transient T dtoComposite;
- public EntityModel( Class<U> entityClass, String identity, Class<T> dtoClass )
+ public EntityModel( Class<T> entityClass, String identity, Class<T> dtoClass )
{
this.entityClass = entityClass;
this.identity = identity;
this.dtoClass = dtoClass;
}
- public static <T extends DTO, U extends EntityComposite> IModel<T> of(
- Class<U> entityClass, String identity, Class<T> dtoClass
+ public static <T extends Identity> IModel<T> of(
+ Class<T> entityClass, String identity, Class<T> dtoClass
)
{
- return new EntityModel<T, U>( entityClass, identity, dtoClass );
+ return new EntityModel<T>( entityClass, identity, dtoClass );
}
public T getObject()
{
if( dtoComposite == null && identity != null )
{
- dtoComposite = valueConverter.convert( dtoClass, loadEntity() );
+ dtoComposite = uowf.currentUnitOfWork().toValue( dtoClass, loadEntity() );
}
return dtoComposite;
}
@@ -72,9 +73,9 @@ public class EntityModel<T extends DTO, U extends EntityComposite>
dtoComposite = null;
}
- private U loadEntity()
+ private T loadEntity()
{
- U entity = uowf.currentUnitOfWork().get( entityClass, identity );
+ T entity = uowf.currentUnitOfWork().get( entityClass, identity );
if( entity == null )
{
Usecase usecase = uowf.currentUnitOfWork().usecase();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/infrastructure/model/QueryModel.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/infrastructure/model/QueryModel.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/infrastructure/model/QueryModel.java
index f320893..96a132d 100644
--- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/infrastructure/model/QueryModel.java
+++ b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/infrastructure/model/QueryModel.java
@@ -21,7 +21,7 @@ package org.apache.zest.sample.dcicargo.sample_b.infrastructure.model;
import java.util.ArrayList;
import java.util.List;
-import org.apache.zest.api.entity.EntityComposite;
+import org.apache.zest.api.entity.Identity;
import org.apache.zest.api.query.Query;
/**
@@ -30,7 +30,7 @@ import org.apache.zest.api.query.Query;
* Callback Wicket model that holds a Zest Query object that can be called when needed to
* retrieve fresh data.
*/
-public abstract class QueryModel<T, U extends EntityComposite>
+public abstract class QueryModel<T extends Identity>
extends ReadOnlyModel<List<T>>
{
private Class<T> dtoClass;
@@ -49,7 +49,7 @@ public abstract class QueryModel<T, U extends EntityComposite>
}
dtoList = new ArrayList<T>();
- for( U entity : getQuery() )
+ for( T entity : getQuery() )
{
dtoList.add( getValue( entity ) );
}
@@ -58,11 +58,12 @@ public abstract class QueryModel<T, U extends EntityComposite>
}
// Callback to retrieve the (unserializable) Zest Query object
- public abstract Query<U> getQuery();
+ public abstract Query<T> getQuery();
- public T getValue( U entity )
+ public T getValue( T entity )
{
- return valueConverter.convert( dtoClass, entity );
+ Class<T> dtoClass = this.dtoClass;
+ return uowf.currentUnitOfWork().toValue( dtoClass, entity );
}
public void detach()
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/infrastructure/model/ReadOnlyModel.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/infrastructure/model/ReadOnlyModel.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/infrastructure/model/ReadOnlyModel.java
index 7e0bf8c..bbb0d1f 100644
--- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/infrastructure/model/ReadOnlyModel.java
+++ b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/infrastructure/model/ReadOnlyModel.java
@@ -25,7 +25,6 @@ import org.apache.zest.api.service.ServiceFinder;
import org.apache.zest.api.structure.Module;
import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
import org.apache.zest.api.value.ValueBuilderFactory;
-import org.apache.zest.sample.dcicargo.sample_b.infrastructure.conversion.EntityToDTOService;
/**
* ReadOnlyModel
@@ -37,7 +36,6 @@ public abstract class ReadOnlyModel<T>
{
private static final long serialVersionUID = 1L;
- static protected EntityToDTOService valueConverter;
static protected ZestAPI api;
static protected ServiceFinder serviceFinder;
static protected UnitOfWorkFactory uowf;
@@ -67,14 +65,12 @@ public abstract class ReadOnlyModel<T>
}
public static void prepareModelBaseClass( Module m,
- ZestAPI api,
- EntityToDTOService entityToDTO
+ ZestAPI api
)
{
uowf = m.unitOfWorkFactory();
serviceFinder = m;
vbf = m;
ReadOnlyModel.api = api;
- valueConverter = entityToDTO;
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/bootstrap/test/TestAssembler.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/bootstrap/test/TestAssembler.java b/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/bootstrap/test/TestAssembler.java
index 17097d3..bf33911 100644
--- a/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/bootstrap/test/TestAssembler.java
+++ b/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/bootstrap/test/TestAssembler.java
@@ -45,19 +45,19 @@ import org.apache.zest.sample.dcicargo.sample_b.context.rolemap.CargoRoleMap;
import org.apache.zest.sample.dcicargo.sample_b.context.rolemap.CargosRoleMap;
import org.apache.zest.sample.dcicargo.sample_b.context.rolemap.HandlingEventsRoleMap;
import org.apache.zest.sample.dcicargo.sample_b.context.service.routing.RoutingService;
-import org.apache.zest.sample.dcicargo.sample_b.data.entity.HandlingEventEntity;
-import org.apache.zest.sample.dcicargo.sample_b.data.entity.LocationEntity;
-import org.apache.zest.sample.dcicargo.sample_b.data.entity.VoyageEntity;
import org.apache.zest.sample.dcicargo.sample_b.data.factory.RouteSpecificationFactoryService;
import org.apache.zest.sample.dcicargo.sample_b.data.structure.cargo.RouteSpecification;
import org.apache.zest.sample.dcicargo.sample_b.data.structure.delivery.Delivery;
import org.apache.zest.sample.dcicargo.sample_b.data.structure.delivery.NextHandlingEvent;
+import org.apache.zest.sample.dcicargo.sample_b.data.structure.handling.HandlingEvent;
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 org.apache.zest.sample.dcicargo.sample_b.data.structure.location.Location;
import org.apache.zest.sample.dcicargo.sample_b.data.structure.location.UnLocode;
import org.apache.zest.sample.dcicargo.sample_b.data.structure.tracking.TrackingId;
import org.apache.zest.sample.dcicargo.sample_b.data.structure.voyage.CarrierMovement;
import org.apache.zest.sample.dcicargo.sample_b.data.structure.voyage.Schedule;
+import org.apache.zest.sample.dcicargo.sample_b.data.structure.voyage.Voyage;
import org.apache.zest.sample.dcicargo.sample_b.data.structure.voyage.VoyageNumber;
import org.apache.zest.spi.uuid.UuidIdentityGeneratorService;
import org.apache.zest.valueserialization.orgjson.OrgJsonValueSerializationService;
@@ -140,9 +140,9 @@ public class TestAssembler
// Non-role-playing entities
roleMapModule
.entities(
- HandlingEventEntity.class,
- LocationEntity.class,
- VoyageEntity.class )
+ HandlingEvent.class,
+ Location.class,
+ Voyage.class )
.visibleIn( application );
ModuleAssembly interactionModule = contextLayer.module( "CONTEXT-Interaction" ).withDefaultUnitOfWorkFactory();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/booking/BookNewCargoTest.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/booking/BookNewCargoTest.java b/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/booking/BookNewCargoTest.java
index 38f5687..58c8e42 100644
--- a/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/booking/BookNewCargoTest.java
+++ b/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/booking/BookNewCargoTest.java
@@ -19,6 +19,7 @@
*/
package org.apache.zest.sample.dcicargo.sample_b.context.test.booking;
+import org.apache.zest.sample.dcicargo.sample_b.data.structure.cargo.Cargo;
import org.junit.Before;
import org.junit.Test;
import org.apache.zest.api.constraint.ConstraintViolationException;
@@ -26,7 +27,6 @@ import org.apache.zest.api.unitofwork.UnitOfWork;
import org.apache.zest.sample.dcicargo.sample_b.bootstrap.test.TestApplication;
import org.apache.zest.sample.dcicargo.sample_b.context.interaction.booking.BookNewCargo;
import org.apache.zest.sample.dcicargo.sample_b.data.aggregateroot.CargoAggregateRoot;
-import org.apache.zest.sample.dcicargo.sample_b.data.entity.CargoEntity;
import org.apache.zest.sample.dcicargo.sample_b.data.factory.exception.CannotCreateCargoException;
import org.apache.zest.sample.dcicargo.sample_b.data.factory.exception.CannotCreateRouteSpecificationException;
@@ -105,7 +105,7 @@ public class BookNewCargoTest extends TestApplication
deviation_2b_DeadlineTomorrowIsOkay();
UnitOfWork uow = uowf.currentUnitOfWork();
trackingId = new BookNewCargo( CARGOS, HONGKONG, STOCKHOLM, DAY24 ).getTrackingId();
- cargo = uow.get( CargoEntity.class, trackingId.id().get() );
+ cargo = uow.get( Cargo.class, trackingId.id().get() );
assertThat( cargo.routeSpecification().get().origin().get(), is( equalTo( HONGKONG ) ) );
assertThat( cargo.routeSpecification().get().destination().get(), is( equalTo( STOCKHOLM ) ) );
assertThat( cargo.routeSpecification().get().arrivalDeadline().get(), is( equalTo( DAY24 ) ) );
@@ -118,7 +118,7 @@ public class BookNewCargoTest extends TestApplication
step_2_CanCreateRouteSpecification();
UnitOfWork uow = uowf.currentUnitOfWork();
trackingId = new BookNewCargo( CARGOS, HONGKONG, STOCKHOLM, DAY24 ).getTrackingId();
- cargo = uow.get( CargoEntity.class, trackingId.id().get() );
+ cargo = uow.get( Cargo.class, trackingId.id().get() );
assertDelivery( null, null, null, null,
NOT_RECEIVED, notArrived,
NOT_ROUTED, directed, unknownETA, unknownLeg,
@@ -141,7 +141,7 @@ public class BookNewCargoTest extends TestApplication
deviation_4a_TrackingIdTooShort();
UnitOfWork uow = uowf.currentUnitOfWork();
trackingId = new BookNewCargo( CARGOS, HONGKONG, STOCKHOLM, DAY24 ).withTrackingId( "yes" );
- cargo = uow.get( CargoEntity.class, trackingId.id().get() );
+ cargo = uow.get( Cargo.class, trackingId.id().get() );
assertThat( cargo.trackingId().get().id().get(), is( equalTo( "yes" ) ) );
}
@@ -161,7 +161,7 @@ public class BookNewCargoTest extends TestApplication
deviation_4a_TrackingIdTooLong();
UnitOfWork uow = uowf.currentUnitOfWork();
trackingId = new BookNewCargo( CARGOS, HONGKONG, STOCKHOLM, DAY24 ).withTrackingId( "123456789012345678901234567890" );
- cargo = uow.get( CargoEntity.class, trackingId.id().get() );
+ cargo = uow.get( Cargo.class, trackingId.id().get() );
assertThat( cargo.trackingId().get().id().get(), is( equalTo( "123456789012345678901234567890" ) ) );
}
@@ -206,7 +206,7 @@ public class BookNewCargoTest extends TestApplication
step_4_CanAutoCreateTrackingIdFromNull();
UnitOfWork uow = uowf.currentUnitOfWork();
trackingId = new BookNewCargo( CARGOS, HONGKONG, STOCKHOLM, DAY24 ).withTrackingId( "ABC" );
- cargo = uow.get( CargoEntity.class, trackingId.id().get() );
+ cargo = uow.get( Cargo.class, trackingId.id().get() );
assertThat( cargo.trackingId().get(), is( equalTo( trackingId ) ) );
assertThat( cargo.trackingId().get().id().get(), is( equalTo( "ABC" ) ) );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/registration/RegisterHandlingEventTest.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/registration/RegisterHandlingEventTest.java b/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/registration/RegisterHandlingEventTest.java
index acf47e6..394c418 100644
--- a/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/registration/RegisterHandlingEventTest.java
+++ b/samples/dci-cargo/dcisample_b/src/test/java/org/apache/zest/sample/dcicargo/sample_b/context/test/handling/registration/RegisterHandlingEventTest.java
@@ -33,7 +33,6 @@ import org.apache.zest.sample.dcicargo.sample_b.context.interaction.handling.reg
import org.apache.zest.sample.dcicargo.sample_b.context.interaction.handling.registration.exception.UnknownVoyageException;
import org.apache.zest.sample.dcicargo.sample_b.data.aggregateroot.CargoAggregateRoot;
import org.apache.zest.sample.dcicargo.sample_b.data.aggregateroot.HandlingEventAggregateRoot;
-import org.apache.zest.sample.dcicargo.sample_b.data.entity.HandlingEventEntity;
import org.apache.zest.sample.dcicargo.sample_b.data.structure.handling.HandlingEvent;
import org.junit.Before;
import org.junit.Test;
@@ -203,7 +202,7 @@ public class RegisterHandlingEventTest extends TestApplication
// Delete handling events from memory
tempUow = uowf.newUnitOfWork();
- Query<HandlingEventEntity> events = tempUow.newQuery( qbf.newQueryBuilder( HandlingEventEntity.class ) );
+ Query<HandlingEvent> events = tempUow.newQuery( qbf.newQueryBuilder( HandlingEvent.class ) );
for( HandlingEvent event : events )
{
tempUow.remove( event );
[06/25] 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.
Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/core/testsupport/src/main/java/org/apache/zest/test/value/AbstractValueCompositeSerializationTest.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/value/AbstractValueCompositeSerializationTest.java b/core/testsupport/src/main/java/org/apache/zest/test/value/AbstractValueCompositeSerializationTest.java
index 3a08c81..ce9d361 100644
--- a/core/testsupport/src/main/java/org/apache/zest/test/value/AbstractValueCompositeSerializationTest.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/value/AbstractValueCompositeSerializationTest.java
@@ -21,16 +21,16 @@ package org.apache.zest.test.value;
import java.io.ByteArrayOutputStream;
import java.io.Serializable;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.time.OffsetDateTime;
+import java.time.ZoneOffset;
import java.util.ArrayList;
-import java.util.Date;
import java.util.List;
import java.util.Map;
import org.apache.zest.api.injection.scope.Structure;
import org.apache.zest.api.structure.Module;
-import org.joda.time.DateTime;
-import org.joda.time.DateTimeZone;
-import org.joda.time.LocalDate;
-import org.joda.time.LocalDateTime;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TestName;
@@ -92,8 +92,7 @@ public abstract class AbstractValueCompositeSerializationTest
public void givenValueCompositeWhenSerializingAndDeserializingExpectEquals()
throws Exception
{
- UnitOfWork uow = unitOfWorkFactory.newUnitOfWork();
- try
+ try(UnitOfWork uow = unitOfWorkFactory.newUnitOfWork())
{
SomeValue some = buildSomeValue();
@@ -103,25 +102,18 @@ public abstract class AbstractValueCompositeSerializationTest
String stateString = output.toString( "UTF-8" );
// Deserialize using Module API
+ System.out.println(stateString);
SomeValue some2 = moduleInstance.newValueFromSerializedState( SomeValue.class, stateString );
- assertThat( "Same value toString", some.toString(), equalTo( some2.toString() ) );
+ assertThat( "String Integer Map", some2.stringIntMap().get().get( "foo" ), equalTo( 42 ) );
+ assertThat( "String Value Map", some2.stringValueMap().get().get( "foo" ).internalVal(), equalTo( "Bar" ) );
+ assertThat( "Nested Entities", some2.barAssociation().get().cathedral().get(), equalTo( "bazar in barAssociation" ) );
+
assertThat( "Same value", some, equalTo( some2 ) );
assertThat( "Same JSON value toString", stateString, equalTo( some2.toString() ) );
assertThat( "Same JSON value", some.customFoo().get() instanceof CustomFooValue, is( true ) );
assertThat( "Same JSON value explicit", some.customFooValue().get() instanceof CustomFooValue, is( true ) );
-
- assertThat( "String Integer Map", some2.stringIntMap().get().get( "foo" ), equalTo( 42 ) );
- assertThat( "String Value Map", some2.stringValueMap().get().get( "foo" ).internalVal(), equalTo( "Bar" ) );
- assertThat( "Nested Entities", some2.barAssociation().get().cathedral().get(), equalTo( "bazar in barAssociation" ) );
- }
- catch( Exception ex )
- {
- throw ex;
- }
- finally
- {
- uow.discard();
+ assertThat( "Same value toString", some.toString(), equalTo( some2.toString() ) );
}
}
@@ -151,13 +143,11 @@ public abstract class AbstractValueCompositeSerializationTest
// proto.string().set( "Foo\"Bar\"\nTest\f\t\b" );
proto.string().set( "Foo\"Bar\"\nTest\t" );
proto.string2().set( "/Foo/bar" );
- proto.number().set( 42L );
- proto.date().set( new Date() );
- // We specify the TimeZone explicitely here so that serialized/deserialized is equals
- // See https://github.com/JodaOrg/joda-time/issues/106
- proto.dateTime().set( new DateTime( "2020-03-04T13:24:35", DateTimeZone.forOffsetHours( 1 ) ) );
- proto.localDate().set( new LocalDate() );
- proto.localDateTime().set( new LocalDateTime() );
+ proto.number().set( 43L );
+ proto.localTime().set( LocalTime.now() );
+ proto.dateTime().set( OffsetDateTime.of( 2020, 3, 4, 13, 24, 35, 0, ZoneOffset.ofHours( 1 ) ) );
+ proto.localDate().set( LocalDate.now() );
+ proto.localDateTime().set( LocalDateTime.now() );
proto.entityReference().set( EntityReference.parseEntityReference( "12345" ) );
proto.stringIntMap().get().put( "foo", 42 );
@@ -240,9 +230,9 @@ public abstract class AbstractValueCompositeSerializationTest
@UseDefaults
Property<Long> number();
- Property<Date> date();
+ Property<LocalTime> localTime();
- Property<DateTime> dateTime();
+ Property<OffsetDateTime> dateTime();
Property<LocalDate> localDate();
@@ -437,3 +427,5 @@ public abstract class AbstractValueCompositeSerializationTest
}
}
}
+
+
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/def.xml
----------------------------------------------------------------------
diff --git a/def.xml b/def.xml
new file mode 100644
index 0000000..5a64c0b
--- /dev/null
+++ b/def.xml
@@ -0,0 +1,334 @@
+<?xml version='1.1' encoding='utf-8'?>
+<object>
+ <field>
+ <name>number</name>
+ <value>43</value>
+ </field>
+ <field>
+ <name>foo</name>
+ <value>
+ <object>
+ <field>
+ <name>_type</name>
+ <value>org.apache.zest.test.value.AbstractValueCompositeSerializationTest$FooValue</value>
+ </field>
+ <field>
+ <name>bar</name>
+ <value></value>
+ </field>
+ </object>
+ </value>
+ </field>
+ <field>
+ <name>nullString</name>
+ <value>
+ <null/>
+ </value>
+ </field>
+ <field>
+ <name>anotherNull</name>
+ <value>
+ <null/>
+ </value>
+ </field>
+ <field>
+ <name>emptyString</name>
+ <value></value>
+ </field>
+ <field>
+ <name>testEnum</name>
+ <value>somevalue</value>
+ </field>
+ <field>
+ <name>stringList</name>
+ <value>
+ <array/>
+ </value>
+ </field>
+ <field>
+ <name>anotherListNull</name>
+ <value>
+ <null/>
+ </value>
+ </field>
+ <field>
+ <name>anotherListEmpty</name>
+ <value>
+ <array/>
+ </value>
+ </field>
+ <field>
+ <name>string</name>
+ <value>Foo&quot;Bar&quot;
+ Test
+ </value>
+ </field>
+ <field>
+ <name>stringIntMap</name>
+ <value>
+ <array>
+ <object>
+ <field>
+ <name>key</name>
+ <value>foo</value>
+ </field>
+ <field>
+ <name>value</name>
+ <value>42</value>
+ </field>
+ </object>
+ </array>
+ </value>
+ </field>
+ <field>
+ <name>stringValueMap</name>
+ <value>
+ <array>
+ <object>
+ <field>
+ <name>key</name>
+ <value>foo</value>
+ </field>
+ <field>
+ <name>value</name>
+ <value>
+ <object>
+ <field>
+ <name>_type</name>
+ <value>org.apache.zest.test.value.AbstractValueCompositeSerializationTest$AnotherValue</value>
+ </field>
+ <field>
+ <name>val1</name>
+ <value>Foo</value>
+ </field>
+ <field>
+ <name>val2</name>
+ <value>Bar</value>
+ </field>
+ </object>
+ </value>
+ </field>
+ </object>
+ </array>
+ </value>
+ </field>
+ <field>
+ <name>customFoo</name>
+ <value>
+ <object>
+ <field>
+ <name>_type</name>
+ <value>org.apache.zest.test.value.AbstractValueCompositeSerializationTest$CustomFooValue</value>
+ </field>
+ <field>
+ <name>custom</name>
+ <value></value>
+ </field>
+ <field>
+ <name>bar</name>
+ <value></value>
+ </field>
+ </object>
+ </value>
+ </field>
+ <field>
+ <name>customFooValue</name>
+ <value>
+ <object>
+ <field>
+ <name>_type</name>
+ <value>org.apache.zest.test.value.AbstractValueCompositeSerializationTest$CustomFooValue</value>
+ </field>
+ <field>
+ <name>custom</name>
+ <value></value>
+ </field>
+ <field>
+ <name>bar</name>
+ <value></value>
+ </field>
+ </object>
+ </value>
+ </field>
+ <field>
+ <name>anotherList</name>
+ <value>
+ <array>
+ <value>
+ <object>
+ <field>
+ <name>_type</name>
+ <value>org.apache.zest.test.value.AbstractValueCompositeSerializationTest$AnotherValue</value>
+ </field>
+ <field>
+ <name>val1</name>
+ <value></value>
+ </field>
+ <field>
+ <name>val2</name>
+ <value></value>
+ </field>
+ </object>
+ </value>
+ </array>
+ </value>
+ </field>
+ <field>
+ <name>specificCollection</name>
+ <value>
+ <object>
+ <field>
+ <name>_type</name>
+ <value>org.apache.zest.test.value.AbstractValueCompositeSerializationTest$SpecificCollection</value>
+ </field>
+ <field>
+ <name>genericList</name>
+ <value>
+ <array>
+ <value>Some</value>
+ <value>String</value>
+ </array>
+ </value>
+ </field>
+ </object>
+ </value>
+ </field>
+ <field>
+ <name>string2</name>
+ <value>/Foo/bar</value>
+ </field>
+ <field>
+ <name>localTime</name>
+ <value>17:24:12.627</value>
+ </field>
+ <field>
+ <name>dateTime</name>
+ <value>2020-03-04T13:24:35+01:00</value>
+ </field>
+ <field>
+ <name>localDate</name>
+ <value>2016-06-11</value>
+ </field>
+ <field>
+ <name>localDateTime</name>
+ <value>2016-06-11T17:24:12.627</value>
+ </field>
+ <field>
+ <name>entityReference</name>
+ <value>12345</value>
+ </field>
+ <field>
+ <name>another</name>
+ <value>
+ <object>
+ <field>
+ <name>_type</name>
+ <value>org.apache.zest.test.value.AbstractValueCompositeSerializationTest$AnotherValue</value>
+ </field>
+ <field>
+ <name>val1</name>
+ <value>Foo</value>
+ </field>
+ <field>
+ <name>val2</name>
+ <value>Bar</value>
+ </field>
+ </object>
+ </value>
+ </field>
+ <field>
+ <name>serializable</name>
+ <value>
+ rO0ABXNyAFVvcmcuYXBhY2hlLnplc3QudGVzdC52YWx1ZS5BYnN0cmFjdFZhbHVlQ29tcG9zaXRlU2VyaWFsaXphdGlvblRlc3QkU2VyaWFsaXphYmxlT2JqZWN0AAAAAAAAAAECAAJJAAN2YWxMAANmb290ABJMamF2YS9sYW5nL1N0cmluZzt4cAAAACN0AANGb28=
+ </value>
+ </field>
+ <field>
+ <name>fooValue</name>
+ <value>
+ <object>
+ <field>
+ <name>_type</name>
+ <value>org.apache.zest.test.value.AbstractValueCompositeSerializationTest$FooValue</value>
+ </field>
+ <field>
+ <name>bar</name>
+ <value></value>
+ </field>
+ </object>
+ </value>
+ </field>
+ <field>
+ <name>barAssociationOptional</name>
+ <value>
+ <null/>
+ </value>
+ </field>
+ <field>
+ <name>barAssociation</name>
+ <value>8e813879-6aac-463a-bacf-cb2b5ab2e79e-0</value>
+ </field>
+ <field>
+ <name>barEntityAssociation</name>
+ <value>8e813879-6aac-463a-bacf-cb2b5ab2e79e-1</value>
+ </field>
+ <field>
+ <name>barManyAssociationEmpty</name>
+ <value>
+ <array/>
+ </value>
+ </field>
+ <field>
+ <name>barManyAssociation</name>
+ <value>
+ <array>
+ <value>8e813879-6aac-463a-bacf-cb2b5ab2e79e-2</value>
+ <value>8e813879-6aac-463a-bacf-cb2b5ab2e79e-3</value>
+ </array>
+ </value>
+ </field>
+ <field>
+ <name>barEntityManyAssociation</name>
+ <value>
+ <array>
+ <value>8e813879-6aac-463a-bacf-cb2b5ab2e79e-4</value>
+ <value>8e813879-6aac-463a-bacf-cb2b5ab2e79e-5</value>
+ </array>
+ </value>
+ </field>
+ <field>
+ <name>barNamedAssociationEmpty</name>
+ <value>
+ <object/>
+ </value>
+ </field>
+ <field>
+ <name>barNamedAssociation</name>
+ <value>
+ <object>
+ <field>
+ <name>bazar</name>
+ <value>8e813879-6aac-463a-bacf-cb2b5ab2e79e-6</value>
+ </field>
+ <field>
+ <name>cathedral</name>
+ <value>8e813879-6aac-463a-bacf-cb2b5ab2e79e-7</value>
+ </field>
+ </object>
+ </value>
+ </field>
+ <field>
+ <name>barEntityNamedAssociation</name>
+ <value>
+ <object>
+ <field>
+ <name>bazar</name>
+ <value>8e813879-6aac-463a-bacf-cb2b5ab2e79e-8</value>
+ </field>
+ <field>
+ <name>cathedral</name>
+ <value>8e813879-6aac-463a-bacf-cb2b5ab2e79e-9</value>
+ </field>
+ </object>
+ </value>
+ </field>
+</object>
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/extensions/indexing-rdf/src/main/java/org/apache/zest/index/rdf/query/internal/RdfQueryParserImpl.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-rdf/src/main/java/org/apache/zest/index/rdf/query/internal/RdfQueryParserImpl.java b/extensions/indexing-rdf/src/main/java/org/apache/zest/index/rdf/query/internal/RdfQueryParserImpl.java
index 4da0b31..0932df0 100644
--- a/extensions/indexing-rdf/src/main/java/org/apache/zest/index/rdf/query/internal/RdfQueryParserImpl.java
+++ b/extensions/indexing-rdf/src/main/java/org/apache/zest/index/rdf/query/internal/RdfQueryParserImpl.java
@@ -23,7 +23,6 @@ import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Collection;
-import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
@@ -70,17 +69,6 @@ import static java.lang.String.format;
public class RdfQueryParserImpl
implements RdfQueryParser
{
- private static final ThreadLocal<DateFormat> ISO8601_UTC = new ThreadLocal<DateFormat>()
- {
- @Override
- protected DateFormat initialValue()
- {
- SimpleDateFormat dateFormat = new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'" );
- dateFormat.setTimeZone( TimeZone.getTimeZone( "UTC" ) );
- return dateFormat;
- }
- };
-
private static final Map<Class<? extends ComparisonPredicate>, String> OPERATORS;
private static final Set<Character> RESERVED_CHARS;
@@ -555,16 +543,11 @@ public class RdfQueryParserImpl
{
return null;
}
-
- if( value instanceof Date )
- {
- return ISO8601_UTC.get().format( (Date) value );
- }
- else if( value instanceof EntityComposite )
+ if( value instanceof EntityComposite )
{
return "urn:zest:entity:" + value.toString();
}
- else if( value instanceof Variable )
+ if( value instanceof Variable )
{
Object realValue = variables.get( ( (Variable) value ).variableName() );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/extensions/indexing-solr/src/main/java/org/apache/zest/index/solr/internal/SolrEntityIndexerMixin.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-solr/src/main/java/org/apache/zest/index/solr/internal/SolrEntityIndexerMixin.java b/extensions/indexing-solr/src/main/java/org/apache/zest/index/solr/internal/SolrEntityIndexerMixin.java
index 7a7bbb9..c34ff0b 100644
--- a/extensions/indexing-solr/src/main/java/org/apache/zest/index/solr/internal/SolrEntityIndexerMixin.java
+++ b/extensions/indexing-solr/src/main/java/org/apache/zest/index/solr/internal/SolrEntityIndexerMixin.java
@@ -22,7 +22,6 @@ package org.apache.zest.index.solr.internal;
import java.io.IOException;
import java.util.ArrayList;
-import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -149,7 +148,7 @@ public abstract class SolrEntityIndexerMixin
SolrInputDocument input = new SolrInputDocument();
input.addField( "id", entityState.identity().identity() );
input.addField( "type", entityState.entityDescriptor().types().findFirst().get().getName() );
- input.addField( "lastModified", new Date( entityState.lastModified() ) );
+ input.addField( "lastModified", entityState.lastModified() );
for( Statement statement : graph )
{
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/extensions/indexing-sql/src/main/java/org/apache/zest/index/sql/support/common/QNameInfo.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-sql/src/main/java/org/apache/zest/index/sql/support/common/QNameInfo.java b/extensions/indexing-sql/src/main/java/org/apache/zest/index/sql/support/common/QNameInfo.java
index 807cea6..8f6d029 100644
--- a/extensions/indexing-sql/src/main/java/org/apache/zest/index/sql/support/common/QNameInfo.java
+++ b/extensions/indexing-sql/src/main/java/org/apache/zest/index/sql/support/common/QNameInfo.java
@@ -21,9 +21,16 @@ package org.apache.zest.index.sql.support.common;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
+import java.time.Duration;
+import java.time.Instant;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.time.OffsetDateTime;
+import java.time.Period;
+import java.time.ZonedDateTime;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Date;
import java.util.List;
import org.apache.zest.api.association.AssociationDescriptor;
import org.apache.zest.api.common.QualifiedName;
@@ -109,7 +116,14 @@ public final class QNameInfo
Number.class.isAssignableFrom( finalClass )//
|| Boolean.class.isAssignableFrom( finalClass ) //
|| Character.class.isAssignableFrom( finalClass ) //
- || Date.class.isAssignableFrom( finalClass ) //
+ || LocalDate.class.isAssignableFrom( finalClass ) //
+ || LocalTime.class.isAssignableFrom( finalClass ) //
+ || LocalDateTime.class.isAssignableFrom( finalClass ) //
+ || ZonedDateTime.class.isAssignableFrom( finalClass ) //
+ || OffsetDateTime.class.isAssignableFrom( finalClass ) //
+ || Instant.class.isAssignableFrom( finalClass ) //
+ || Duration.class.isAssignableFrom( finalClass ) //
+ || Period.class.isAssignableFrom( finalClass ) //
|| Enum.class.isAssignableFrom( finalClass ) //
|| String.class.isAssignableFrom( finalClass )//
;
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/extensions/indexing-sql/src/main/java/org/apache/zest/index/sql/support/postgresql/PostgreSQLTypeHelper.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-sql/src/main/java/org/apache/zest/index/sql/support/postgresql/PostgreSQLTypeHelper.java b/extensions/indexing-sql/src/main/java/org/apache/zest/index/sql/support/postgresql/PostgreSQLTypeHelper.java
index fb58c78..4f82bec 100644
--- a/extensions/indexing-sql/src/main/java/org/apache/zest/index/sql/support/postgresql/PostgreSQLTypeHelper.java
+++ b/extensions/indexing-sql/src/main/java/org/apache/zest/index/sql/support/postgresql/PostgreSQLTypeHelper.java
@@ -24,7 +24,6 @@ import java.lang.reflect.Type;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Timestamp;
-import java.util.Date;
import org.apache.zest.api.common.Optional;
import org.apache.zest.api.injection.scope.This;
import org.apache.zest.api.mixin.Mixins;
@@ -72,10 +71,10 @@ public interface PostgreSQLTypeHelper
(Character) primitive
}, 0 );
}
- else if( primitive instanceof Date )
- {
- primitive = new Timestamp( ( (Date) primitive ).getTime() );
- }
+// else if( primitive instanceof Date )
+// {
+// primitive = new Timestamp( ( (Date) primitive ).getTime() );
+// }
else if( primitive instanceof Byte )
{
primitive = (short) (Byte) primitive;
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/extensions/indexing-sql/src/main/java/org/apache/zest/index/sql/support/skeletons/AbstractSQLStartup.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-sql/src/main/java/org/apache/zest/index/sql/support/skeletons/AbstractSQLStartup.java b/extensions/indexing-sql/src/main/java/org/apache/zest/index/sql/support/skeletons/AbstractSQLStartup.java
index bd69d6c..a733f36 100644
--- a/extensions/indexing-sql/src/main/java/org/apache/zest/index/sql/support/skeletons/AbstractSQLStartup.java
+++ b/extensions/indexing-sql/src/main/java/org/apache/zest/index/sql/support/skeletons/AbstractSQLStartup.java
@@ -29,9 +29,16 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Types;
+import java.time.Duration;
+import java.time.Instant;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.time.OffsetDateTime;
+import java.time.Period;
+import java.time.ZonedDateTime;
import java.util.ArrayDeque;
import java.util.ArrayList;
-import java.util.Date;
import java.util.Deque;
import java.util.HashMap;
import java.util.HashSet;
@@ -291,7 +298,12 @@ public abstract class AbstractSQLStartup
this._primitiveTypes.put( Long.class, dt.bigInt() );
this._primitiveTypes.put( Float.class, dt.real() );
this._primitiveTypes.put( Double.class, dt.doublePrecision() );
- this._primitiveTypes.put( Date.class, dt.timeStamp( true ) );
+ this._primitiveTypes.put( LocalDate.class, dt.timeStamp( false ) );
+ this._primitiveTypes.put( LocalTime.class, dt.timeStamp( false ) );
+ this._primitiveTypes.put( LocalDateTime.class, dt.timeStamp( false ) );
+ this._primitiveTypes.put( ZonedDateTime.class, dt.timeStamp( true ) );
+ this._primitiveTypes.put( OffsetDateTime.class, dt.timeStamp( true ) );
+ this._primitiveTypes.put( Instant.class, dt.timeStamp( true ) );
this._primitiveTypes.put( Character.class, dt.integer() );
this._primitiveTypes.put( String.class, dt.sqlVarChar( 5000 ) );
this._primitiveTypes.put( BigInteger.class, dt.decimal() );
@@ -305,7 +317,13 @@ public abstract class AbstractSQLStartup
jdbcTypes.put( Long.class, Types.BIGINT );
jdbcTypes.put( Float.class, Types.REAL );
jdbcTypes.put( Double.class, Types.DOUBLE );
- jdbcTypes.put( Date.class, Types.TIMESTAMP );
+ jdbcTypes.put( Instant.class, Types.TIMESTAMP );
+ jdbcTypes.put( LocalDate.class, Types.DATE );
+ jdbcTypes.put( LocalTime.class, Types.TIME );
+ jdbcTypes.put( ZonedDateTime.class, Types.TIMESTAMP_WITH_TIMEZONE );
+ jdbcTypes.put( OffsetDateTime.class, Types.TIMESTAMP_WITH_TIMEZONE );
+ jdbcTypes.put( Duration.class, Types.VARCHAR);
+ jdbcTypes.put( Period.class, Types.VARCHAR);
jdbcTypes.put( Character.class, Types.INTEGER );
jdbcTypes.put( String.class, Types.VARCHAR );
jdbcTypes.put( BigInteger.class, Types.NUMERIC );
@@ -533,7 +551,7 @@ public abstract class AbstractSQLStartup
.addTableElement( d.createColumnDefinition( ENTITY_TABLE_IDENTITY_COLUMN_NAME, this._primitiveTypes
.get( String.class ), false ) )
.addTableElement( d.createColumnDefinition( ENTITY_TABLE_MODIFIED_COLUMN_NAME, this._primitiveTypes
- .get( Date.class ), false ) )
+ .get( Instant.class ), false ) )
.addTableElement( d.createColumnDefinition( ENTITY_TABLE_VERSION_COLUMN_NAME, this._primitiveTypes
.get( String.class ), false ) )
.addTableElement( d.createColumnDefinition( ENTITY_TABLE_APPLICATION_VERSION_COLUMN_NAME, this._primitiveTypes
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/extensions/valueserialization-jackson/src/main/java/org/apache/zest/valueserialization/jackson/JacksonValueDeserializer.java
----------------------------------------------------------------------
diff --git a/extensions/valueserialization-jackson/src/main/java/org/apache/zest/valueserialization/jackson/JacksonValueDeserializer.java b/extensions/valueserialization-jackson/src/main/java/org/apache/zest/valueserialization/jackson/JacksonValueDeserializer.java
index a916a6a..5589467 100644
--- a/extensions/valueserialization-jackson/src/main/java/org/apache/zest/valueserialization/jackson/JacksonValueDeserializer.java
+++ b/extensions/valueserialization-jackson/src/main/java/org/apache/zest/valueserialization/jackson/JacksonValueDeserializer.java
@@ -207,8 +207,8 @@ public class JacksonValueDeserializer
}
if( token != JsonToken.START_OBJECT )
{
- throw new ValueSerializationException( "Expected an object start at "
- + input.getCurrentLocation().toString() );
+ String message = "Expected an object start at " + input.getCurrentLocation().toString();
+ throw new ValueSerializationException( message );
}
return (ObjectNode) input.readValueAsTree();
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/libraries.gradle
----------------------------------------------------------------------
diff --git a/libraries.gradle b/libraries.gradle
index 0dfe3fc..a185e61 100644
--- a/libraries.gradle
+++ b/libraries.gradle
@@ -42,7 +42,6 @@ def jedisVersion = '2.7.2'
def jettyVersion = '9.2.11.v20150529' // 9.3.x Tests fail!
def jgoodiesLooksVersion = '2.5.3'
def jodaMoneyVersion = '0.10.0'
-def jodaTimeVersion = '2.8.1'
def jtaVersion = '1.1'
def leveldbVersion = '0.7'
def leveldbJniVersion = '1.8'
@@ -192,7 +191,6 @@ rootProject.ext {
// Library & Extension dependencies
jackson_mapper: "com.fasterxml.jackson.core:jackson-databind:$jacksonVersion",
jodamoney: "org.joda:joda-money:$jodaMoneyVersion",
- jodatime: "joda-time:joda-time:$jodaTimeVersion",
ehcache: "net.sf.ehcache:ehcache:$ehcacheVersion",
elasticsearch: "org.elasticsearch:elasticsearch:$elasticsearchVersion",
h2: "com.h2database:h2:$h2Version",
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/libraries/alarm/src/main/java/org/apache/zest/library/alarm/AlarmEvent.java
----------------------------------------------------------------------
diff --git a/libraries/alarm/src/main/java/org/apache/zest/library/alarm/AlarmEvent.java b/libraries/alarm/src/main/java/org/apache/zest/library/alarm/AlarmEvent.java
index 2b387e4..b531efe 100644
--- a/libraries/alarm/src/main/java/org/apache/zest/library/alarm/AlarmEvent.java
+++ b/libraries/alarm/src/main/java/org/apache/zest/library/alarm/AlarmEvent.java
@@ -20,7 +20,7 @@
package org.apache.zest.library.alarm;
-import java.util.Date;
+import java.time.Instant;
import java.util.Locale;
import java.util.ResourceBundle;
import org.apache.zest.api.injection.scope.Service;
@@ -64,7 +64,7 @@ public interface AlarmEvent
*
* @return the timestamp when this event occurred.
*/
- Property<Date> eventTime();
+ Property<Instant> eventTime();
/**
* Returns the Name of the event.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/libraries/alarm/src/main/java/org/apache/zest/library/alarm/AlarmStatus.java
----------------------------------------------------------------------
diff --git a/libraries/alarm/src/main/java/org/apache/zest/library/alarm/AlarmStatus.java b/libraries/alarm/src/main/java/org/apache/zest/library/alarm/AlarmStatus.java
index b370702..a4f9ee9 100644
--- a/libraries/alarm/src/main/java/org/apache/zest/library/alarm/AlarmStatus.java
+++ b/libraries/alarm/src/main/java/org/apache/zest/library/alarm/AlarmStatus.java
@@ -20,7 +20,7 @@
package org.apache.zest.library.alarm;
-import java.util.Date;
+import java.time.Instant;
import java.util.Locale;
import java.util.ResourceBundle;
import org.apache.zest.api.common.Optional;
@@ -62,7 +62,7 @@ public interface AlarmStatus extends ValueComposite
* @return the timestamp of when the state was created.
*/
@Optional
- Property<Date> creationDate();
+ Property<Instant> creationDate();
/**
* Returns the Name of the AlarmStatus.
@@ -103,7 +103,7 @@ public interface AlarmStatus extends ValueComposite
{
if( state.creationDate().get() == null )
{
- state.creationDate().set( new Date() );
+ state.creationDate().set( Instant.now() );
}
}
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/libraries/alarm/src/main/java/org/apache/zest/library/alarm/AlarmSystem.java
----------------------------------------------------------------------
diff --git a/libraries/alarm/src/main/java/org/apache/zest/library/alarm/AlarmSystem.java b/libraries/alarm/src/main/java/org/apache/zest/library/alarm/AlarmSystem.java
index e6a950b..b848c6a 100644
--- a/libraries/alarm/src/main/java/org/apache/zest/library/alarm/AlarmSystem.java
+++ b/libraries/alarm/src/main/java/org/apache/zest/library/alarm/AlarmSystem.java
@@ -20,8 +20,8 @@
package org.apache.zest.library.alarm;
+import java.time.Instant;
import java.util.ArrayList;
-import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
@@ -226,7 +226,7 @@ public interface AlarmSystem
ValueBuilder<AlarmStatus> builder = vbf.newValueBuilder( AlarmStatus.class );
AlarmStatus.State statePrototype = builder.prototypeFor( AlarmStatus.State.class );
statePrototype.name().set( status );
- statePrototype.creationDate().set( new Date() );
+ statePrototype.creationDate().set( Instant.now() );
return builder.newInstance();
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/libraries/alarm/src/main/java/org/apache/zest/library/alarm/ExtendedAlarmModelService.java
----------------------------------------------------------------------
diff --git a/libraries/alarm/src/main/java/org/apache/zest/library/alarm/ExtendedAlarmModelService.java b/libraries/alarm/src/main/java/org/apache/zest/library/alarm/ExtendedAlarmModelService.java
index 853391e..3bd5c3a 100644
--- a/libraries/alarm/src/main/java/org/apache/zest/library/alarm/ExtendedAlarmModelService.java
+++ b/libraries/alarm/src/main/java/org/apache/zest/library/alarm/ExtendedAlarmModelService.java
@@ -19,9 +19,9 @@
*/
package org.apache.zest.library.alarm;
+import java.time.Instant;
import java.util.ArrayList;
import java.util.Collections;
-import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.ResourceBundle;
@@ -408,7 +408,7 @@ public interface ExtendedAlarmModelService
ValueBuilder<AlarmStatus> builder = vbf.newValueBuilder( AlarmStatus.class );
AlarmStatus.State prototype = builder.prototypeFor(AlarmStatus.State.class);
prototype.name().set( status );
- prototype.creationDate().set( new Date() );
+ prototype.creationDate().set( Instant.now() );
return builder.newInstance();
}
@@ -421,7 +421,7 @@ public interface ExtendedAlarmModelService
ValueBuilder<AlarmEvent> builder = vbf.newValueBuilder( AlarmEvent.class );
AlarmEvent prototype = builder.prototype();
prototype.alarmIdentity().set( alarmId.identity().get() );
- prototype.eventTime().set( new Date() );
+ prototype.eventTime().set( Instant.now() );
prototype.newStatus().set( newStatus );
prototype.oldStatus().set( oldStatus );
prototype.systemName().set( eventSystemName );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/libraries/alarm/src/main/java/org/apache/zest/library/alarm/SimpleAlarmModelService.java
----------------------------------------------------------------------
diff --git a/libraries/alarm/src/main/java/org/apache/zest/library/alarm/SimpleAlarmModelService.java b/libraries/alarm/src/main/java/org/apache/zest/library/alarm/SimpleAlarmModelService.java
index 004e541..8f9e7dc 100644
--- a/libraries/alarm/src/main/java/org/apache/zest/library/alarm/SimpleAlarmModelService.java
+++ b/libraries/alarm/src/main/java/org/apache/zest/library/alarm/SimpleAlarmModelService.java
@@ -19,9 +19,9 @@
*/
package org.apache.zest.library.alarm;
+import java.time.Instant;
import java.util.ArrayList;
import java.util.Collections;
-import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.ResourceBundle;
@@ -231,7 +231,7 @@ public interface SimpleAlarmModelService extends AlarmModel, ServiceComposite
ValueBuilder<AlarmStatus> builder = vbf.newValueBuilder( AlarmStatus.class );
AlarmStatus.State prototype = builder.prototypeFor(AlarmStatus.State.class);
prototype.name().set( status );
- prototype.creationDate().set( new Date() );
+ prototype.creationDate().set( Instant.now() );
return builder.newInstance();
}
@@ -243,7 +243,7 @@ public interface SimpleAlarmModelService extends AlarmModel, ServiceComposite
ValueBuilder<AlarmEvent> builder = vbf.newValueBuilder( AlarmEvent.class );
AlarmEvent prototype = builder.prototype();
prototype.alarmIdentity().set( alarmId.identity().get() );
- prototype.eventTime().set( new Date() );
+ prototype.eventTime().set( Instant.now() );
prototype.newStatus().set( newStatus );
prototype.oldStatus().set( oldStatus );
prototype.systemName().set( eventSystemName );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/libraries/alarm/src/main/java/org/apache/zest/library/alarm/StandardAlarmModelService.java
----------------------------------------------------------------------
diff --git a/libraries/alarm/src/main/java/org/apache/zest/library/alarm/StandardAlarmModelService.java b/libraries/alarm/src/main/java/org/apache/zest/library/alarm/StandardAlarmModelService.java
index be5b9c2..91a28aa 100644
--- a/libraries/alarm/src/main/java/org/apache/zest/library/alarm/StandardAlarmModelService.java
+++ b/libraries/alarm/src/main/java/org/apache/zest/library/alarm/StandardAlarmModelService.java
@@ -19,9 +19,9 @@
*/
package org.apache.zest.library.alarm;
+import java.time.Instant;
import java.util.ArrayList;
import java.util.Collections;
-import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.ResourceBundle;
@@ -276,7 +276,7 @@ public interface StandardAlarmModelService extends AlarmModel, ServiceComposite
ValueBuilder<AlarmStatus> builder = vbf.newValueBuilder( AlarmStatus.class );
AlarmStatus.State prototype = builder.prototypeFor( AlarmStatus.State.class );
prototype.name().set( status );
- prototype.creationDate().set( new Date() );
+ prototype.creationDate().set( Instant.now() );
return builder.newInstance();
}
@@ -289,7 +289,7 @@ public interface StandardAlarmModelService extends AlarmModel, ServiceComposite
ValueBuilder<AlarmEvent> builder = vbf.newValueBuilder( AlarmEvent.class );
AlarmEvent prototype = builder.prototype();
prototype.alarmIdentity().set( alarmId.identity().get() );
- prototype.eventTime().set( new Date() );
+ prototype.eventTime().set( Instant.now() );
prototype.newStatus().set( newStatus );
prototype.oldStatus().set( oldStatus );
prototype.systemName().set( eventSystemName );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/libraries/alarm/src/test/java/org/apache/zest/library/alarm/ExtendedAlarmModelTest.java
----------------------------------------------------------------------
diff --git a/libraries/alarm/src/test/java/org/apache/zest/library/alarm/ExtendedAlarmModelTest.java b/libraries/alarm/src/test/java/org/apache/zest/library/alarm/ExtendedAlarmModelTest.java
index 6a05ad9..4fd6599 100644
--- a/libraries/alarm/src/test/java/org/apache/zest/library/alarm/ExtendedAlarmModelTest.java
+++ b/libraries/alarm/src/test/java/org/apache/zest/library/alarm/ExtendedAlarmModelTest.java
@@ -19,7 +19,7 @@
*/
package org.apache.zest.library.alarm;
-import java.util.Date;
+import java.time.Instant;
import java.util.List;
import java.util.Locale;
import org.junit.Test;
@@ -972,7 +972,7 @@ public class ExtendedAlarmModelTest
ValueBuilder<AlarmStatus> builder = valueBuilderFactory.newValueBuilder( AlarmStatus.class );
AlarmStatus.State statePrototype = builder.prototypeFor( AlarmStatus.State.class );
statePrototype.name().set( status );
- statePrototype.creationDate().set( new Date() );
+ statePrototype.creationDate().set( Instant.now() );
return builder.newInstance();
}
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/libraries/alarm/src/test/java/org/apache/zest/library/alarm/SimpleAlarmModelTest.java
----------------------------------------------------------------------
diff --git a/libraries/alarm/src/test/java/org/apache/zest/library/alarm/SimpleAlarmModelTest.java b/libraries/alarm/src/test/java/org/apache/zest/library/alarm/SimpleAlarmModelTest.java
index da8cac1..ae68817 100644
--- a/libraries/alarm/src/test/java/org/apache/zest/library/alarm/SimpleAlarmModelTest.java
+++ b/libraries/alarm/src/test/java/org/apache/zest/library/alarm/SimpleAlarmModelTest.java
@@ -19,7 +19,7 @@
*/
package org.apache.zest.library.alarm;
-import java.util.Date;
+import java.time.Instant;
import java.util.List;
import java.util.Locale;
import org.junit.Test;
@@ -357,7 +357,7 @@ public class SimpleAlarmModelTest
ValueBuilder<AlarmStatus> builder = valueBuilderFactory.newValueBuilder( AlarmStatus.class );
AlarmStatus.State statePrototype = builder.prototypeFor( AlarmStatus.State.class );
statePrototype.name().set( status );
- statePrototype.creationDate().set( new Date() );
+ statePrototype.creationDate().set( Instant.now() );
return builder.newInstance();
}
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/libraries/alarm/src/test/java/org/apache/zest/library/alarm/StandardAlarmModelTest.java
----------------------------------------------------------------------
diff --git a/libraries/alarm/src/test/java/org/apache/zest/library/alarm/StandardAlarmModelTest.java b/libraries/alarm/src/test/java/org/apache/zest/library/alarm/StandardAlarmModelTest.java
index 1fd8379..0fc022a 100644
--- a/libraries/alarm/src/test/java/org/apache/zest/library/alarm/StandardAlarmModelTest.java
+++ b/libraries/alarm/src/test/java/org/apache/zest/library/alarm/StandardAlarmModelTest.java
@@ -20,7 +20,7 @@
package org.apache.zest.library.alarm;
-import java.util.Date;
+import java.time.Instant;
import java.util.List;
import java.util.Locale;
import org.junit.Assert;
@@ -484,7 +484,7 @@ public class StandardAlarmModelTest
ValueBuilder<AlarmStatus> builder = valueBuilderFactory.newValueBuilder( AlarmStatus.class );
AlarmStatus.State statePrototype = builder.prototypeFor( AlarmStatus.State.class );
statePrototype.name().set( status );
- statePrototype.creationDate().set( new Date() );
+ statePrototype.creationDate().set( Instant.now() );
return builder.newInstance();
}
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/libraries/appbrowser/src/test/java/org/apache/zest/library/appbrowser/AppBrowserTest.java
----------------------------------------------------------------------
diff --git a/libraries/appbrowser/src/test/java/org/apache/zest/library/appbrowser/AppBrowserTest.java b/libraries/appbrowser/src/test/java/org/apache/zest/library/appbrowser/AppBrowserTest.java
index 0cbb157..34fc11c 100644
--- a/libraries/appbrowser/src/test/java/org/apache/zest/library/appbrowser/AppBrowserTest.java
+++ b/libraries/appbrowser/src/test/java/org/apache/zest/library/appbrowser/AppBrowserTest.java
@@ -20,7 +20,6 @@ package org.apache.zest.library.appbrowser;
import java.io.StringWriter;
import java.io.Writer;
-import org.joda.time.DateTime;
import org.junit.Test;
import org.apache.zest.api.association.Association;
import org.apache.zest.api.association.ManyAssociation;
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/libraries/circuitbreaker/src/main/java/org/apache/zest/library/circuitbreaker/CircuitBreaker.java
----------------------------------------------------------------------
diff --git a/libraries/circuitbreaker/src/main/java/org/apache/zest/library/circuitbreaker/CircuitBreaker.java b/libraries/circuitbreaker/src/main/java/org/apache/zest/library/circuitbreaker/CircuitBreaker.java
index befc099..abe761a 100644
--- a/libraries/circuitbreaker/src/main/java/org/apache/zest/library/circuitbreaker/CircuitBreaker.java
+++ b/libraries/circuitbreaker/src/main/java/org/apache/zest/library/circuitbreaker/CircuitBreaker.java
@@ -24,7 +24,7 @@ import java.beans.PropertyChangeSupport;
import java.beans.PropertyVetoException;
import java.beans.VetoableChangeListener;
import java.beans.VetoableChangeSupport;
-import java.util.Date;
+import java.time.Instant;
import java.util.function.Predicate;
/**
@@ -43,8 +43,8 @@ public class CircuitBreaker
private Predicate<Throwable> allowedThrowables;
private int countDown;
- private long trippedOn = -1;
- private long enableOn = -1;
+ private Instant trippedOn;
+ private Instant enableOn;
private Status status = Status.on;
@@ -86,8 +86,8 @@ public class CircuitBreaker
status = Status.off;
pcs.firePropertyChange( "status", Status.on, Status.off );
- trippedOn = System.currentTimeMillis();
- enableOn = trippedOn + timeout;
+ trippedOn = Instant.now();
+ enableOn = trippedOn.plusMillis( timeout );
}
}
@@ -101,8 +101,8 @@ public class CircuitBreaker
vcs.fireVetoableChange( "status", Status.off, Status.on );
status = Status.on;
countDown = threshold;
- trippedOn = -1;
- enableOn = -1;
+ trippedOn = null;
+ enableOn = null;
lastThrowable = null;
pcs.firePropertyChange( "status", Status.off, Status.on );
@@ -110,7 +110,7 @@ public class CircuitBreaker
catch( PropertyVetoException e )
{
// Reset timeout
- enableOn = System.currentTimeMillis() + timeout;
+ enableOn = Instant.now().plusMillis( timeout );
if( e.getCause() != null )
{
@@ -144,7 +144,7 @@ public class CircuitBreaker
{
if( status == Status.off )
{
- if( System.currentTimeMillis() > enableOn )
+ if( Instant.now().isAfter( enableOn ) )
{
try
{
@@ -167,14 +167,14 @@ public class CircuitBreaker
return status;
}
- public Date trippedOn()
+ public Instant trippedOn()
{
- return trippedOn == -1 ? null : new Date( trippedOn );
+ return trippedOn;
}
- public Date enabledOn()
+ public Instant enabledOn()
{
- return enableOn == -1 ? null : new Date( enableOn );
+ return enableOn;
}
public boolean isOn()
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/libraries/circuitbreaker/src/main/java/org/apache/zest/library/circuitbreaker/jmx/CircuitBreakerJMX.java
----------------------------------------------------------------------
diff --git a/libraries/circuitbreaker/src/main/java/org/apache/zest/library/circuitbreaker/jmx/CircuitBreakerJMX.java b/libraries/circuitbreaker/src/main/java/org/apache/zest/library/circuitbreaker/jmx/CircuitBreakerJMX.java
index 8fabe2a..32d7473 100644
--- a/libraries/circuitbreaker/src/main/java/org/apache/zest/library/circuitbreaker/jmx/CircuitBreakerJMX.java
+++ b/libraries/circuitbreaker/src/main/java/org/apache/zest/library/circuitbreaker/jmx/CircuitBreakerJMX.java
@@ -23,8 +23,7 @@ package org.apache.zest.library.circuitbreaker.jmx;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.beans.PropertyVetoException;
-import java.text.DateFormat;
-import java.util.Date;
+import java.time.Instant;
import javax.management.MBeanNotificationInfo;
import javax.management.Notification;
import javax.management.NotificationBroadcasterSupport;
@@ -98,15 +97,15 @@ public class CircuitBreakerJMX
@Override
public String getTrippedOn()
{
- Date trippedOn = circuitBreaker.trippedOn();
- return trippedOn == null ? "" : DateFormat.getDateTimeInstance().format(trippedOn);
+ Instant trippedOn = circuitBreaker.trippedOn();
+ return trippedOn == null ? "" : trippedOn.toString();
}
@Override
public String getEnableOn()
{
- Date trippedOn = circuitBreaker.enabledOn();
- return trippedOn == null ? "" : DateFormat.getDateTimeInstance().format(trippedOn);
+ Instant trippedOn = circuitBreaker.enabledOn();
+ return trippedOn == null ? "" : trippedOn.toString();
}
@Override
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/EntityToValueTest.java
----------------------------------------------------------------------
diff --git a/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/EntityToValueTest.java b/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/EntityToValueTest.java
index 53e5c14..13c1868 100644
--- a/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/EntityToValueTest.java
+++ b/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/EntityToValueTest.java
@@ -19,7 +19,8 @@
*/
package org.apache.zest.library.conversion.values;
-import java.util.Date;
+import java.time.Instant;
+import java.time.LocalDate;
import java.util.function.Function;
import org.junit.Test;
import org.apache.zest.api.constraint.ConstraintViolationException;
@@ -209,7 +210,7 @@ public class EntityToValueTest
{
String firstName = "Niclas";
String lastName = "Hedhman";
- Date birthTime = createBirthDate( 1964, 9, 25 );
+ LocalDate birthTime = createBirthDate( 1964, 9, 25 );
return createPerson( uow, firstName, lastName, birthTime );
}
@@ -217,7 +218,7 @@ public class EntityToValueTest
{
String firstName = "Lis";
String lastName = "Gazi";
- Date birthTime = createBirthDate( 1976, 2, 19 );
+ LocalDate birthTime = createBirthDate( 1976, 2, 19 );
return createPerson( uow, firstName, lastName, birthTime );
}
@@ -225,7 +226,7 @@ public class EntityToValueTest
{
String firstName = "Eric";
String lastName = "Hedman";
- Date birthTime = createBirthDate( 2004, 4, 8 );
+ LocalDate birthTime = createBirthDate( 2004, 4, 8 );
return createPerson( uow, firstName, lastName, birthTime );
}
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/TestModel.java
----------------------------------------------------------------------
diff --git a/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/TestModel.java b/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/TestModel.java
index 1a1ec60..54fe910 100644
--- a/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/TestModel.java
+++ b/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/TestModel.java
@@ -19,10 +19,12 @@
*/
package org.apache.zest.library.conversion.values;
-import java.util.Calendar;
-import java.util.Date;
+import java.time.Duration;
+import java.time.Instant;
+import java.time.LocalDate;
+import java.time.ZoneId;
+import java.time.ZonedDateTime;
import java.util.List;
-import java.util.TimeZone;
import org.apache.zest.api.association.Association;
import org.apache.zest.api.association.ManyAssociation;
import org.apache.zest.api.common.Optional;
@@ -34,27 +36,26 @@ import org.apache.zest.api.property.Property;
import org.apache.zest.api.unitofwork.UnitOfWork;
import org.apache.zest.api.value.ValueComposite;
+import static java.time.ZoneOffset.UTC;
+
/**
* Test Model.
*/
final class TestModel
{
- static PersonEntity createPerson( UnitOfWork uow, String firstName, String lastName, Date birthTime )
+ static PersonEntity createPerson( UnitOfWork uow, String firstName, String lastName, LocalDate birthDate )
{
EntityBuilder<PersonEntity> builder = uow.newEntityBuilder( PersonEntity.class, "id:" + firstName );
PersonState state = builder.instanceFor( PersonState.class );
state.firstName().set( firstName );
state.lastName().set( lastName );
- state.dateOfBirth().set( birthTime );
+ state.dateOfBirth().set( birthDate );
return builder.newInstance();
}
- static Date createBirthDate( int year, int month, int day )
+ static LocalDate createBirthDate( int year, int month, int day )
{
- Calendar calendar = Calendar.getInstance();
- calendar.setTimeZone( TimeZone.getTimeZone( "UTC" ) );
- calendar.set( year, month - 1, day, 12, 0, 0 );
- return calendar.getTime();
+ return LocalDate.of( year, month, day);
}
// START SNIPPET: state
@@ -65,7 +66,7 @@ final class TestModel
Property<String> lastName();
- Property<Date> dateOfBirth();
+ Property<LocalDate> dateOfBirth();
}
// END SNIPPET: state
@@ -128,9 +129,8 @@ final class TestModel
@Override
public Integer age()
{
- long now = System.currentTimeMillis();
- long birthdate = state.dateOfBirth().get().getTime();
- return (int) ( ( now - birthdate ) / 1000 / 3600 / 24 / 365.25 );
+ Duration age = Duration.between( state.dateOfBirth().get(), Instant.now() );
+ return (int) age.toDays()/365;
}
// START SNIPPET: entity
@@ -147,7 +147,7 @@ final class TestModel
Property<String> lastName();
- Property<Date> dateOfBirth();
+ Property<LocalDate> dateOfBirth();
@Optional
Property<String> spouse();
@@ -167,7 +167,7 @@ final class TestModel
Property<String> lastName();
- Property<Date> dateOfBirth();
+ Property<LocalDate> dateOfBirth();
@Optional
Property<String> spouse();
@@ -186,7 +186,7 @@ final class TestModel
Property<String> lastName();
- Property<Date> dateOfBirth();
+ Property<LocalDate> dateOfBirth();
@Optional
Property<String> spouse();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/ValueToEntityTest.java
----------------------------------------------------------------------
diff --git a/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/ValueToEntityTest.java b/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/ValueToEntityTest.java
index d88f33f..c0f8eea 100644
--- a/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/ValueToEntityTest.java
+++ b/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/ValueToEntityTest.java
@@ -19,8 +19,8 @@
*/
package org.apache.zest.library.conversion.values;
+import java.time.LocalDate;
import java.util.Arrays;
-import java.util.Date;
import java.util.function.Predicate;
import org.junit.Before;
import org.junit.Test;
@@ -69,7 +69,7 @@ public class ValueToEntityTest
module.values( PersonValue4.class );
}
- private Date someBirthDate;
+ private LocalDate someBirthDate;
private String ednaIdentity;
private String zekeIdentity;
private String fredIdentity;
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/libraries/eventsourcing-rest/src/main/java/org/apache/zest/library/eventsourcing/domain/rest/server/DomainEventSourceResource.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing-rest/src/main/java/org/apache/zest/library/eventsourcing/domain/rest/server/DomainEventSourceResource.java b/libraries/eventsourcing-rest/src/main/java/org/apache/zest/library/eventsourcing/domain/rest/server/DomainEventSourceResource.java
index 7098e83..cdd435e 100644
--- a/libraries/eventsourcing-rest/src/main/java/org/apache/zest/library/eventsourcing/domain/rest/server/DomainEventSourceResource.java
+++ b/libraries/eventsourcing-rest/src/main/java/org/apache/zest/library/eventsourcing/domain/rest/server/DomainEventSourceResource.java
@@ -23,7 +23,6 @@ package org.apache.zest.library.eventsourcing.domain.rest.server;
import java.io.IOException;
import java.io.Writer;
import java.util.ArrayList;
-import java.util.Date;
import java.util.List;
import org.apache.zest.api.injection.scope.Service;
import org.apache.zest.api.service.qualifier.Tagged;
@@ -38,11 +37,17 @@ import org.restlet.data.CharacterSet;
import org.restlet.data.MediaType;
import org.restlet.data.Reference;
import org.restlet.data.Status;
-import org.restlet.ext.atom.*;
+import org.restlet.ext.atom.Content;
+import org.restlet.ext.atom.Entry;
+import org.restlet.ext.atom.Feed;
+import org.restlet.ext.atom.Link;
+import org.restlet.ext.atom.Relation;
+import org.restlet.ext.atom.Text;
import org.restlet.representation.StringRepresentation;
import org.restlet.representation.WriterRepresentation;
import org.restlet.resource.ResourceException;
+import static java.util.Date.from;
import static org.apache.zest.functional.Iterables.iterable;
/**
@@ -187,13 +192,14 @@ public class DomainEventSourceResource
}
*/
- Date lastModified = null;
+ java.util.Date lastModified = null;
for (UnitOfWorkDomainEventsValue eventsValue : eventsValues)
{
Entry entry = new Entry();
entry.setTitle( new Text( eventsValue.usecase().get() + "(" + eventsValue.user().get() + ")" ) );
- entry.setPublished( new Date( eventsValue.timestamp().get() ) );
- entry.setModificationDate( lastModified = new Date( eventsValue.timestamp().get() ) );
+ entry.setPublished( from( eventsValue.timestamp().get() ) );
+ lastModified = from( eventsValue.timestamp().get() );
+ entry.setModificationDate( lastModified );
entry.setId( Long.toString( startEvent + 1 ) );
startEvent++;
Content content = new Content();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/api/ApplicationEvent.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/api/ApplicationEvent.java b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/api/ApplicationEvent.java
index 6aabfb2..979761a 100644
--- a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/api/ApplicationEvent.java
+++ b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/api/ApplicationEvent.java
@@ -20,7 +20,7 @@
package org.apache.zest.library.eventsourcing.application.api;
-import java.util.Date;
+import java.time.Instant;
import org.apache.zest.api.entity.Identity;
import org.apache.zest.api.property.Property;
import org.apache.zest.api.value.ValueComposite;
@@ -50,7 +50,7 @@ public interface ApplicationEvent
Property<String> name();
// When the event was created
- Property<Date> on();
+ Property<Instant> on();
// Method parameters as JSON
Property<String> parameters();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/factory/ApplicationEventFactoryService.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/factory/ApplicationEventFactoryService.java b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/factory/ApplicationEventFactoryService.java
index 183af70..ae83019 100644
--- a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/factory/ApplicationEventFactoryService.java
+++ b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/factory/ApplicationEventFactoryService.java
@@ -20,6 +20,7 @@
package org.apache.zest.library.eventsourcing.application.factory;
+import java.time.Instant;
import org.json.JSONException;
import org.json.JSONObject;
import org.json.JSONStringer;
@@ -38,8 +39,6 @@ import org.apache.zest.api.value.ValueBuilderFactory;
import org.apache.zest.library.eventsourcing.application.api.ApplicationEvent;
import org.apache.zest.library.eventsourcing.domain.spi.CurrentUser;
-import java.util.Date;
-
/**
* DomainEventValue factory
*/
@@ -77,7 +76,7 @@ public interface ApplicationEventFactoryService
ApplicationEvent prototype = builder.prototype();
prototype.name().set( name );
- prototype.on().set( new Date() );
+ prototype.on().set( Instant.now() );
prototype.identity().set( idGenerator.generate( ApplicationEvent.class ) );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/replay/ApplicationEventPlayerService.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/replay/ApplicationEventPlayerService.java b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/replay/ApplicationEventPlayerService.java
index 8a8e1ce..cca1d01 100644
--- a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/replay/ApplicationEventPlayerService.java
+++ b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/replay/ApplicationEventPlayerService.java
@@ -22,10 +22,8 @@ package org.apache.zest.library.eventsourcing.application.replay;
import java.lang.reflect.Method;
import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import org.json.JSONObject;
-import org.json.JSONTokener;
+import java.time.Instant;
+import java.time.format.DateTimeFormatter;
import org.apache.zest.api.ZestAPI;
import org.apache.zest.api.injection.scope.Structure;
import org.apache.zest.api.mixin.Mixins;
@@ -35,6 +33,8 @@ import org.apache.zest.api.unitofwork.UnitOfWork;
import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
import org.apache.zest.api.value.ValueComposite;
import org.apache.zest.library.eventsourcing.application.api.ApplicationEvent;
+import org.json.JSONObject;
+import org.json.JSONTokener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -58,7 +58,7 @@ public interface ApplicationEventPlayerService
@Structure
ZestAPI api;
- SimpleDateFormat dateFormat = new SimpleDateFormat( "EEE MMM dd HH:mm:ss zzz yyyy" );
+ DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern( "EEE MMM dd HH:mm:ss zzz yyyy" );
@Override
public void playEvent( ApplicationEvent applicationEvent, Object object )
@@ -122,7 +122,7 @@ public interface ApplicationEventPlayerService
} else if (parameterType.equals( Integer.class ) || parameterType.equals( Integer.TYPE ))
{
return ((Number) value).intValue();
- } else if (parameterType.equals( Date.class ))
+ } else if (parameterType.equals( Instant.class ))
{
return dateFormat.parse( (String) value );
} else if (ValueComposite.class.isAssignableFrom( parameterType ))
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/source/helper/ApplicationEvents.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/source/helper/ApplicationEvents.java b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/source/helper/ApplicationEvents.java
index 7c79395..edd5c8f 100644
--- a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/source/helper/ApplicationEvents.java
+++ b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/source/helper/ApplicationEvents.java
@@ -21,10 +21,9 @@
package org.apache.zest.library.eventsourcing.application.source.helper;
import java.lang.reflect.Method;
+import java.time.Instant;
import java.util.ArrayList;
-import java.util.Date;
import java.util.List;
-import java.util.function.Function;
import java.util.function.Predicate;
import org.apache.zest.api.util.Methods;
import org.apache.zest.functional.Iterables;
@@ -43,14 +42,14 @@ public class ApplicationEvents
{
public static Iterable<ApplicationEvent> events( Iterable<TransactionApplicationEvents> transactions )
{
- List<Iterable<ApplicationEvent>> events = new ArrayList<Iterable<ApplicationEvent>>();
+ List<Iterable<ApplicationEvent>> events = new ArrayList<>();
for (TransactionApplicationEvents transactionDomain : transactions)
{
events.add( transactionDomain.events().get() );
}
Iterable<ApplicationEvent>[] iterables = (Iterable<ApplicationEvent>[]) new Iterable[events.size()];
- return Iterables.flatten( events.<Iterable<ApplicationEvent>>toArray( iterables ) );
+ return Iterables.flatten( events.toArray( iterables ) );
}
public static Iterable<ApplicationEvent> events( TransactionApplicationEvents... transactionDomains )
@@ -120,57 +119,31 @@ public class ApplicationEvents
// }, Iterables.toList( Methods.METHODS_OF.apply( eventClass ) ) ));
}
- public static Predicate<ApplicationEvent> afterDate( final Date afterDate )
+ public static Predicate<ApplicationEvent> afterDate( final Instant afterDate )
{
- return new Predicate<ApplicationEvent>()
- {
- @Override
- public boolean test( ApplicationEvent event )
- {
- return event.on().get().after( afterDate );
- }
- };
+ return event -> event.on().get().isAfter( afterDate );
}
- public static Predicate<ApplicationEvent> beforeDate( final Date beforeDate )
+ public static Predicate<ApplicationEvent> beforeDate( final Instant beforeDate )
{
- return new Predicate<ApplicationEvent>()
- {
- @Override
- public boolean test( ApplicationEvent event )
- {
- return event.on().get().before( beforeDate );
- }
- };
+ return event -> event.on().get().isBefore( beforeDate );
}
public static Predicate<ApplicationEvent> withUsecases( final String... names )
{
- return new Predicate<ApplicationEvent>()
- {
- @Override
- public boolean test( ApplicationEvent event )
+ return event -> {
+ for (String name : names)
{
- for (String name : names)
- {
- if (event.usecase().get().equals( name ))
- return true;
- }
- return false;
+ if (event.usecase().get().equals( name ))
+ return true;
}
+ return false;
};
}
public static Predicate<ApplicationEvent> paramIs( final String name, final String value )
{
- return new Predicate<ApplicationEvent>()
- {
- @Override
- public boolean test( ApplicationEvent event )
- {
- return ApplicationEventParameters.getParameter( event, name ).equals( value );
- }
- };
+ return event -> ApplicationEventParameters.getParameter( event, name ).equals( value );
}
public static Output<TransactionApplicationEvents, ApplicationEventReplayException> playEvents( final ApplicationEventPlayer player, final Object eventHandler )
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/api/UnitOfWorkDomainEventsValue.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/api/UnitOfWorkDomainEventsValue.java b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/api/UnitOfWorkDomainEventsValue.java
index 72aa6b3..4cec265 100644
--- a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/api/UnitOfWorkDomainEventsValue.java
+++ b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/api/UnitOfWorkDomainEventsValue.java
@@ -20,6 +20,7 @@
package org.apache.zest.library.eventsourcing.domain.api;
+import java.time.Instant;
import java.util.List;
import org.apache.zest.api.common.Optional;
import org.apache.zest.api.common.UseDefaults;
@@ -44,7 +45,7 @@ public interface UnitOfWorkDomainEventsValue
Property<String> usecase();
// When the event occurred
- Property<Long> timestamp();
+ Property<Instant> timestamp();
// Who performed the event. Taken from CurrentUser service.
@Optional
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/factory/UnitOfWorkNotificationConcern.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/factory/UnitOfWorkNotificationConcern.java b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/factory/UnitOfWorkNotificationConcern.java
index f4b4f5f..7ac8f2a 100644
--- a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/factory/UnitOfWorkNotificationConcern.java
+++ b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/factory/UnitOfWorkNotificationConcern.java
@@ -21,6 +21,7 @@
package org.apache.zest.library.eventsourcing.domain.factory;
import java.io.IOException;
+import java.time.Instant;
import org.apache.zest.api.ZestAPI;
import org.apache.zest.api.concern.ConcernOf;
import org.apache.zest.api.entity.EntityComposite;
@@ -114,7 +115,7 @@ public class UnitOfWorkNotificationConcern
ValueBuilder<UnitOfWorkDomainEventsValue> builder = vbf.newValueBuilder( UnitOfWorkDomainEventsValue.class );
builder.prototype().user().set( user );
- builder.prototype().timestamp().set( System.currentTimeMillis() );
+ builder.prototype().timestamp().set( Instant.now() );
builder.prototype().usecase().set( unitOfWork.usecase().name() );
builder.prototype().version().set( version );
builder.prototype().events().get().addAll( events.getEventValues() );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/replay/DomainEventPlayerService.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/replay/DomainEventPlayerService.java b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/replay/DomainEventPlayerService.java
index 79d017b..890fea9 100644
--- a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/replay/DomainEventPlayerService.java
+++ b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/replay/DomainEventPlayerService.java
@@ -22,10 +22,8 @@ package org.apache.zest.library.eventsourcing.domain.replay;
import java.lang.reflect.Method;
import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import org.json.JSONObject;
-import org.json.JSONTokener;
+import java.time.Instant;
+import java.time.format.DateTimeFormatter;
import org.apache.zest.api.entity.EntityComposite;
import org.apache.zest.api.injection.scope.Structure;
import org.apache.zest.api.mixin.Mixins;
@@ -40,18 +38,20 @@ import org.apache.zest.library.eventsourcing.domain.api.DomainEventValue;
import org.apache.zest.library.eventsourcing.domain.api.UnitOfWorkDomainEventsValue;
import org.apache.zest.spi.ZestSPI;
import org.apache.zest.spi.entity.EntityState;
+import org.json.JSONObject;
+import org.json.JSONTokener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* DomainEventValue player
*/
-@Mixins(DomainEventPlayerService.Mixin.class)
+@Mixins( DomainEventPlayerService.Mixin.class )
public interface DomainEventPlayerService
- extends DomainEventPlayer, ServiceComposite
+ extends DomainEventPlayer, ServiceComposite
{
class Mixin
- implements DomainEventPlayer
+ implements DomainEventPlayer
{
final Logger logger = LoggerFactory.getLogger( DomainEventPlayer.class );
@@ -64,27 +64,30 @@ public interface DomainEventPlayerService
@Structure
ZestSPI spi;
- SimpleDateFormat dateFormat = new SimpleDateFormat( "EEE MMM dd HH:mm:ss zzz yyyy" );
+ DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern( "EEE MMM dd HH:mm:ss zzz yyyy" );
@Override
public void playTransaction( UnitOfWorkDomainEventsValue unitOfWorkDomainValue )
- throws EventReplayException
+ throws EventReplayException
{
UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Event replay" ) );
DomainEventValue currentEventValue = null;
try
{
- for (DomainEventValue domainEventValue : unitOfWorkDomainValue.events().get())
+ for( DomainEventValue domainEventValue : unitOfWorkDomainValue.events().get() )
{
currentEventValue = domainEventValue;
// Get the entity
- Class entityType = module.descriptor().classLoader().loadClass( domainEventValue.entityType().get() );
+ Class entityType = module.descriptor()
+ .classLoader()
+ .loadClass( domainEventValue.entityType().get() );
String id = domainEventValue.entityId().get();
Object entity = null;
try
{
entity = uow.get( entityType, id );
- } catch( NoSuchEntityException e )
+ }
+ catch( NoSuchEntityException e )
{
// Event to play for an entity that doesn't yet exist - create a default instance
entity = uow.newEntity( entityType, id );
@@ -92,7 +95,7 @@ public interface DomainEventPlayerService
// check if the event has already occured
EntityState state = spi.entityStateOf( (EntityComposite) entity );
- if (state.lastModified() > unitOfWorkDomainValue.timestamp().get())
+ if( state.lastModified() > unitOfWorkDomainValue.timestamp().get().toEpochMilli() )
{
break; // don't rerun event in this unitOfWorkDomainValue
}
@@ -100,19 +103,24 @@ public interface DomainEventPlayerService
playEvent( domainEventValue, entity );
}
uow.complete();
- } catch (Exception e)
+ }
+ catch( Exception e )
{
uow.discard();
- if (e instanceof EventReplayException)
- throw ((EventReplayException) e);
+ if( e instanceof EventReplayException )
+ {
+ throw ( (EventReplayException) e );
+ }
else
+ {
throw new EventReplayException( currentEventValue, e );
+ }
}
}
@Override
public void playEvent( DomainEventValue domainEventValue, Object object )
- throws EventReplayException
+ throws EventReplayException
{
UnitOfWork uow = uowf.currentUnitOfWork();
Class entityType = object.getClass();
@@ -120,9 +128,10 @@ public interface DomainEventPlayerService
// Get method
Method eventMethod = getEventMethod( entityType, domainEventValue.name().get() );
- if (eventMethod == null)
+ if( eventMethod == null )
{
- logger.warn( "Could not find event method " + domainEventValue.name().get() + " in entity of type " + entityType.getName() );
+ logger.warn( "Could not find event method " + domainEventValue.name()
+ .get() + " in entity of type " + entityType.getName() );
return;
}
@@ -131,60 +140,68 @@ public interface DomainEventPlayerService
{
String jsonParameters = domainEventValue.parameters().get();
JSONObject parameters = (JSONObject) new JSONTokener( jsonParameters ).nextValue();
- Object[] args = new Object[eventMethod.getParameterTypes().length];
- for (int i = 1; i < eventMethod.getParameterTypes().length; i++)
+ Object[] args = new Object[ eventMethod.getParameterTypes().length ];
+ for( int i = 1; i < eventMethod.getParameterTypes().length; i++ )
{
- Class<?> parameterType = eventMethod.getParameterTypes()[i];
-
+ Class<?> parameterType = eventMethod.getParameterTypes()[ i ];
String paramName = "param" + i;
-
Object value = parameters.get( paramName );
-
- args[i] = getParameterArgument( parameterType, value, uow );
+ args[ i ] = getParameterArgument( parameterType, value, uow );
}
-
- args[0] = domainEventValue;
+ args[ 0 ] = domainEventValue;
// Invoke method
logger.debug( "Replay:" + domainEventValue + " on:" + object );
eventMethod.invoke( object, args );
- } catch (Exception e)
+ }
+ catch( Exception e )
{
throw new EventReplayException( domainEventValue, e );
}
}
- private Object getParameterArgument( Class<?> parameterType, Object value, UnitOfWork uow ) throws ParseException
+ private Object getParameterArgument( Class<?> parameterType, Object value, UnitOfWork uow )
+ throws ParseException
{
- if (value.equals( JSONObject.NULL ))
+ if( value.equals( JSONObject.NULL ) )
+ {
return null;
+ }
- if (parameterType.equals( String.class ))
+ if( parameterType.equals( String.class ) )
{
return (String) value;
- } else if (parameterType.equals( Boolean.class ) || parameterType.equals( Boolean.TYPE ))
+ }
+ else if( parameterType.equals( Boolean.class ) || parameterType.equals( Boolean.TYPE ) )
{
return (Boolean) value;
- } else if (parameterType.equals( Long.class ) || parameterType.equals( Long.TYPE ))
+ }
+ else if( parameterType.equals( Long.class ) || parameterType.equals( Long.TYPE ) )
{
- return ((Number) value).longValue();
- } else if (parameterType.equals( Integer.class ) || parameterType.equals( Integer.TYPE ))
+ return ( (Number) value ).longValue();
+ }
+ else if( parameterType.equals( Integer.class ) || parameterType.equals( Integer.TYPE ) )
{
- return ((Number) value).intValue();
- } else if (parameterType.equals( Date.class ))
+ return ( (Number) value ).intValue();
+ }
+ else if( parameterType.equals( Instant.class ) )
{
return dateFormat.parse( (String) value );
- } else if (ValueComposite.class.isAssignableFrom( parameterType ))
+ }
+ else if( ValueComposite.class.isAssignableFrom( parameterType ) )
{
return module.newValueFromSerializedState( parameterType, (String) value );
- } else if (parameterType.isInterface())
+ }
+ else if( parameterType.isInterface() )
{
return uow.get( parameterType, (String) value );
- } else if (parameterType.isEnum())
+ }
+ else if( parameterType.isEnum() )
{
return Enum.valueOf( (Class<? extends Enum>) parameterType, value.toString() );
- } else
+ }
+ else
{
throw new IllegalArgumentException( "Unknown parameter type:" + parameterType.getName() );
}
@@ -192,13 +209,15 @@ public interface DomainEventPlayerService
private Method getEventMethod( Class<?> aClass, String eventName )
{
- for (Method method : aClass.getMethods())
+ for( Method method : aClass.getMethods() )
{
- if (method.getName().equals( eventName ))
+ if( method.getName().equals( eventName ) )
{
Class[] parameterTypes = method.getParameterTypes();
- if (parameterTypes.length > 0 && parameterTypes[0].equals( DomainEventValue.class ))
+ if( parameterTypes.length > 0 && parameterTypes[ 0 ].equals( DomainEventValue.class ) )
+ {
return method;
+ }
}
}
return null;
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/helper/Events.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/helper/Events.java b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/helper/Events.java
index 42cd9d1..6662621 100644
--- a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/helper/Events.java
+++ b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/helper/Events.java
@@ -21,7 +21,6 @@
package org.apache.zest.library.eventsourcing.domain.source.helper;
import java.lang.reflect.Method;
-import java.util.Date;
import java.util.function.Function;
import java.util.function.Predicate;
import org.apache.zest.api.util.Methods;
@@ -51,17 +50,6 @@ public class Events
return events( Iterables.iterable( unitOfWorkDomainValues ) );
}
- // Common specifications
- public static Predicate<UnitOfWorkDomainEventsValue> afterDate( final Date afterDate )
- {
- return eventValue -> eventValue.timestamp().get() > afterDate.getTime();
- }
-
- public static Predicate<UnitOfWorkDomainEventsValue> beforeDate( final Date afterDate )
- {
- return eventValue -> eventValue.timestamp().get() < afterDate.getTime();
- }
-
public static Predicate<UnitOfWorkDomainEventsValue> withUsecases( final String... names )
{
return eventValue -> {
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/EventRouterTest.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/EventRouterTest.java b/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/EventRouterTest.java
index 6610af4..e85b5a4 100644
--- a/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/EventRouterTest.java
+++ b/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/EventRouterTest.java
@@ -20,6 +20,7 @@
package org.apache.zest.library.eventsourcing.domain.source.helper;
import java.io.IOException;
+import java.time.Instant;
import java.util.ArrayList;
import java.util.List;
import org.apache.zest.bootstrap.unitofwork.DefaultUnitOfWorkAssembler;
@@ -67,7 +68,7 @@ public class EventRouterTest
builder.prototype().events().get().add( newDomainEvent( assembler, "Test2" ) );
builder.prototype().events().get().add( newDomainEvent( assembler, "Test3" ) );
builder.prototype().version().set( "1.0" );
- builder.prototype().timestamp().set( System.currentTimeMillis() );
+ builder.prototype().timestamp().set( Instant.now() );
builder.prototype().usecase().set( "Test" );
list.add( builder.newInstance() );
}
@@ -77,7 +78,7 @@ public class EventRouterTest
builder.prototype().events().get().add( newDomainEvent( assembler, "Test5" ) );
builder.prototype().events().get().add( newDomainEvent( assembler, "Test6" ) );
builder.prototype().version().set( "1.0" );
- builder.prototype().timestamp().set( System.currentTimeMillis() );
+ builder.prototype().timestamp().set( Instant.now() );
builder.prototype().usecase().set( "Test2" );
list.add( builder.newInstance() );
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/EventsTest.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/EventsTest.java b/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/EventsTest.java
index eed1376..a466f83 100644
--- a/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/EventsTest.java
+++ b/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/EventsTest.java
@@ -19,6 +19,7 @@
*/
package org.apache.zest.library.eventsourcing.domain.source.helper;
+import java.time.Instant;
import org.apache.zest.bootstrap.unitofwork.DefaultUnitOfWorkAssembler;
import org.apache.zest.valueserialization.orgjson.OrgJsonValueSerializationService;
import org.junit.Before;
@@ -70,7 +71,7 @@ public class EventsTest
builder.prototype().events().get().add( newDomainEvent( assembler, "Test2" ) );
builder.prototype().events().get().add( newDomainEvent( assembler, "Test3" ) );
builder.prototype().version().set( "1.0" );
- builder.prototype().timestamp().set( System.currentTimeMillis() );
+ builder.prototype().timestamp().set( Instant.now() );
builder.prototype().usecase().set( "Test" );
list.add( builder.newInstance() );
}
@@ -80,7 +81,7 @@ public class EventsTest
builder.prototype().events().get().add( newDomainEvent( assembler, "Test5" ) );
builder.prototype().events().get().add( newDomainEvent( assembler, "Test6" ) );
builder.prototype().version().set( "1.0" );
- builder.prototype().timestamp().set( System.currentTimeMillis() );
+ builder.prototype().timestamp().set( Instant.now() );
builder.prototype().usecase().set( "Test2" );
list.add( builder.newInstance() );
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/UnitOfWorkRouterTest.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/UnitOfWorkRouterTest.java b/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/UnitOfWorkRouterTest.java
index 76d66a6..2ade4ce 100644
--- a/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/UnitOfWorkRouterTest.java
+++ b/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/UnitOfWorkRouterTest.java
@@ -19,6 +19,7 @@
*/
package org.apache.zest.library.eventsourcing.domain.source.helper;
+import java.time.Instant;
import org.apache.zest.bootstrap.unitofwork.DefaultUnitOfWorkAssembler;
import org.apache.zest.valueserialization.orgjson.OrgJsonValueSerializationService;
import org.hamcrest.CoreMatchers;
@@ -68,7 +69,7 @@ public class UnitOfWorkRouterTest
builder.prototype().events().get().add( newDomainEvent( assembler, "Test2" ));
builder.prototype().events().get().add( newDomainEvent( assembler, "Test3" ));
builder.prototype().version().set( "1.0" );
- builder.prototype().timestamp().set( System.currentTimeMillis() );
+ builder.prototype().timestamp().set( Instant.now() );
builder.prototype().usecase().set( "Test" );
list.add( builder.newInstance() );
}
@@ -78,7 +79,7 @@ public class UnitOfWorkRouterTest
builder.prototype().events().get().add( newDomainEvent( assembler, "Test5" ));
builder.prototype().events().get().add( newDomainEvent( assembler, "Test6" ));
builder.prototype().version().set( "1.0" );
- builder.prototype().timestamp().set( System.currentTimeMillis() );
+ builder.prototype().timestamp().set( Instant.now() );
builder.prototype().usecase().set( "Test2" );
list.add( builder.newInstance() );
}
[05/25] 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.
Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/libraries/rdf/src/main/java/org/apache/zest/library/rdf/entity/EntityTypeSerializer.java
----------------------------------------------------------------------
diff --git a/libraries/rdf/src/main/java/org/apache/zest/library/rdf/entity/EntityTypeSerializer.java b/libraries/rdf/src/main/java/org/apache/zest/library/rdf/entity/EntityTypeSerializer.java
index 4c3078d..81268ef 100644
--- a/libraries/rdf/src/main/java/org/apache/zest/library/rdf/entity/EntityTypeSerializer.java
+++ b/libraries/rdf/src/main/java/org/apache/zest/library/rdf/entity/EntityTypeSerializer.java
@@ -21,16 +21,20 @@
package org.apache.zest.library.rdf.entity;
import java.math.BigDecimal;
-import java.util.Date;
+import java.time.Duration;
+import java.time.Instant;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.time.OffsetDateTime;
+import java.time.Period;
+import java.time.ZonedDateTime;
import java.util.HashMap;
import java.util.Map;
import org.apache.zest.api.entity.EntityDescriptor;
import org.apache.zest.api.util.Classes;
import org.apache.zest.library.rdf.Rdfs;
import org.apache.zest.library.rdf.ZestEntityType;
-import org.joda.time.DateTime;
-import org.joda.time.LocalDate;
-import org.joda.time.LocalDateTime;
import org.openrdf.model.Graph;
import org.openrdf.model.Statement;
import org.openrdf.model.URI;
@@ -58,10 +62,14 @@ public class EntityTypeSerializer
dataTypes.put( Double.class.getName(), XMLSchema.DOUBLE );
dataTypes.put( Long.class.getName(), XMLSchema.LONG );
dataTypes.put( Short.class.getName(), XMLSchema.SHORT );
- dataTypes.put( Date.class.getName(), XMLSchema.DATETIME );
- dataTypes.put( DateTime.class.getName(), XMLSchema.DATETIME );
+ dataTypes.put( Instant.class.getName(), XMLSchema.LONG );
+ dataTypes.put( OffsetDateTime.class.getName(), XMLSchema.DATETIME );
+ dataTypes.put( ZonedDateTime.class.getName(), XMLSchema.DATETIME );
dataTypes.put( LocalDateTime.class.getName(), XMLSchema.DATETIME );
dataTypes.put( LocalDate.class.getName(), XMLSchema.DATE );
+ dataTypes.put( LocalTime.class.getName(), XMLSchema.TIME );
+ dataTypes.put( Duration.class.getName(), XMLSchema.DURATION );
+ dataTypes.put( Period.class.getName(), XMLSchema.DURATION );
}
public Iterable<Statement> serialize( final EntityDescriptor entityDescriptor )
@@ -73,10 +81,10 @@ public class EntityTypeSerializer
graph.add( entityTypeUri, Rdfs.TYPE, Rdfs.CLASS );
graph.add( entityTypeUri, Rdfs.TYPE, OWL.CLASS );
- graph.add( entityTypeUri, ZestEntityType.TYPE, values.createLiteral( entityDescriptor.types()
- .findFirst()
- .get()
- .toString() ) );
+ graph.add( entityTypeUri,
+ ZestEntityType.TYPE,
+ values.createLiteral( entityDescriptor.types().findFirst().get().toString() )
+ );
graph.add( entityTypeUri, ZestEntityType.QUERYABLE, values.createLiteral( entityDescriptor.queryable() ) );
serializeMixinTypes( entityDescriptor, graph, entityTypeUri );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/libraries/rest-client/src/main/java/org/apache/zest/library/rest/client/ClientCache.java
----------------------------------------------------------------------
diff --git a/libraries/rest-client/src/main/java/org/apache/zest/library/rest/client/ClientCache.java b/libraries/rest-client/src/main/java/org/apache/zest/library/rest/client/ClientCache.java
index 6b3a21e..300ca20 100644
--- a/libraries/rest-client/src/main/java/org/apache/zest/library/rest/client/ClientCache.java
+++ b/libraries/rest-client/src/main/java/org/apache/zest/library/rest/client/ClientCache.java
@@ -20,7 +20,7 @@
package org.apache.zest.library.rest.client;
-import java.util.Date;
+import java.time.Instant;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
@@ -30,123 +30,120 @@ import org.restlet.data.Method;
import org.restlet.data.Reference;
import org.restlet.data.Tag;
+import static java.util.Date.from;
+
/**
* Cache for the ContextResourceClient. This is primarily used to keep track of ETags and lastmodified timestamps for now.
*/
public class ClientCache
{
- Map<String, CacheInfo> identityToTimestamp = new HashMap<String, CacheInfo>( );
- Map<String, String> pathToIdentity = new HashMap<String, String>( );
-
- public void updateCache( Response response)
- {
- if (response.getRequest().getMethod().equals( Method.DELETE ))
- {
- String path = getIdentityPath( response.getRequest().getResourceRef() );
- String id = pathToIdentity.get( path );
- if (id != null)
- {
- // Clear anything related to this id from cache
- identityToTimestamp.remove( id );
- Iterator<Map.Entry<String, String>> paths = pathToIdentity.entrySet().iterator();
- while (paths.hasNext())
+ private Map<String, CacheInfo> identityToTimestamp = new HashMap<>();
+ private Map<String, String> pathToIdentity = new HashMap<>();
+
+ public void updateCache( Response response )
+ {
+ if( response.getRequest().getMethod().equals( Method.DELETE ) )
+ {
+ String path = getIdentityPath( response.getRequest().getResourceRef() );
+ String id = pathToIdentity.get( path );
+ if( id != null )
{
- Map.Entry<String, String> entry = paths.next();
- if (entry.getValue().equals( id ))
- paths.remove();
+ // Clear anything related to this id from cache
+ identityToTimestamp.remove( id );
+ Iterator<Map.Entry<String, String>> paths = pathToIdentity.entrySet().iterator();
+ while( paths.hasNext() )
+ {
+ Map.Entry<String, String> entry = paths.next();
+ if( entry.getValue().equals( id ) )
+ {
+ paths.remove();
+ }
+ }
}
- }
- } else if (response.getRequest().getMethod().equals( Method.PUT ) || response.getRequest().getMethod().equals( Method.POST ))
- {
- Tag tag = response.getEntity().getTag();
- if (tag != null)
- {
- Reference ref = response.getRequest().getResourceRef().clone();
+ }
+ else if( response.getRequest().getMethod().equals( Method.PUT ) || response.getRequest()
+ .getMethod()
+ .equals( Method.POST ) )
+ {
+ Tag tag = response.getEntity().getTag();
+ if( tag != null )
+ {
+ Reference ref = response.getRequest().getResourceRef().clone();
- CacheInfo value = new CacheInfo( response.getEntity().getModificationDate(), tag, ref );
- identityToTimestamp.put( value.getEntity(), value );
+ CacheInfo value = new CacheInfo( response.getEntity().getModificationDate().toInstant(), tag);
+ identityToTimestamp.put( value.getEntity(), value );
- String path = getIdentityPath( ref );
+ String path = getIdentityPath( ref );
- pathToIdentity.put( path, value.getEntity() );
+ pathToIdentity.put( path, value.getEntity() );
// LoggerFactory.getLogger( ClientCache.class ).info( "Update:"+value.getEntity()+" ("+ref.toString()+") -> "+value.getLastModified() );
- }
- } else
- {
- // TODO GET caching goes here
- }
- }
-
- public void updateQueryConditions( Request request)
- {
- String identity = pathToIdentity.get( getIdentityPath( request.getResourceRef() ));
- if (identity != null)
- {
- CacheInfo cacheInfo = identityToTimestamp.get( identity );
- if (cacheInfo != null)
- {
+ }
+ }
+ else
+ {
+ // TODO GET caching goes here
+ System.out.println("Caching of GET is not implemented...");
+ }
+ }
+
+ public void updateQueryConditions( Request request )
+ {
+ String identity = pathToIdentity.get( getIdentityPath( request.getResourceRef() ) );
+ if( identity != null )
+ {
+ CacheInfo cacheInfo = identityToTimestamp.get( identity );
+ if( cacheInfo != null )
+ {
// LoggerFactory.getLogger( ClientCache.class ).info( "Send: "+cacheInfo.getEntity()+" ("+request.getMethod().getName()+":"+request.getResourceRef()+") -> "+cacheInfo.getLastModified() );
- request.getConditions().setModifiedSince( cacheInfo.getLastModified() );
- }
- }
- }
-
- public void updateCommandConditions( Request request)
- {
- String identity = pathToIdentity.get( getIdentityPath( request.getResourceRef() ));
- if (identity != null)
- {
- CacheInfo cacheInfo = identityToTimestamp.get( identity );
- if (cacheInfo != null)
- {
+ request.getConditions().setModifiedSince( from( cacheInfo.getLastModified() ) );
+ }
+ }
+ }
+
+ public void updateCommandConditions( Request request )
+ {
+ String identity = pathToIdentity.get( getIdentityPath( request.getResourceRef() ) );
+ if( identity != null )
+ {
+ CacheInfo cacheInfo = identityToTimestamp.get( identity );
+ if( cacheInfo != null )
+ {
// LoggerFactory.getLogger( ClientCache.class ).info( "Send: "+cacheInfo.getEntity()+" ("+request.getMethod().getName()+":"+request.getResourceRef()+") -> "+cacheInfo.getLastModified() );
- request.getConditions().setUnmodifiedSince( cacheInfo.getLastModified() );
- }
- }
- }
-
- private String getIdentityPath( Reference ref )
- {
- String path = ref.getPath();
- if (!path.endsWith( "/" ))
- path = path.substring( 0, path.lastIndexOf('/' )+1);
- return path;
- }
-
- static class CacheInfo
- {
- private Reference ref;
- private Date lastModified;
- private Tag tag;
- private String entity;
-
- CacheInfo( Date lastModified, Tag tag, Reference ref )
- {
- this.lastModified = lastModified;
- this.tag = tag;
- this.ref = ref;
- entity = tag.getName().split( "/" )[0];
- }
-
- public Reference getRef()
- {
- return ref;
- }
-
- public Date getLastModified()
- {
- return lastModified;
- }
-
- public Tag getTag()
- {
- return tag;
- }
-
- public String getEntity()
- {
- return entity;
- }
- }
+ request.getConditions().setUnmodifiedSince( from( cacheInfo.getLastModified() ) );
+ }
+ }
+ }
+
+ private String getIdentityPath( Reference ref )
+ {
+ String path = ref.getPath();
+ if( !path.endsWith( "/" ) )
+ {
+ path = path.substring( 0, path.lastIndexOf( '/' ) + 1 );
+ }
+ return path;
+ }
+
+ private static class CacheInfo
+ {
+ private Instant lastModified;
+ private String entity;
+
+ CacheInfo( Instant lastModified, Tag tag )
+ {
+ this.lastModified = lastModified;
+ entity = tag.getName().split( "/" )[ 0 ];
+ }
+
+ Instant getLastModified()
+ {
+ return lastModified;
+ }
+
+ String getEntity()
+ {
+ return entity;
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/libraries/rest-client/src/main/java/org/apache/zest/library/rest/client/responsereader/TableResponseReader.java
----------------------------------------------------------------------
diff --git a/libraries/rest-client/src/main/java/org/apache/zest/library/rest/client/responsereader/TableResponseReader.java b/libraries/rest-client/src/main/java/org/apache/zest/library/rest/client/responsereader/TableResponseReader.java
index 46d7b79..a34b635 100644
--- a/libraries/rest-client/src/main/java/org/apache/zest/library/rest/client/responsereader/TableResponseReader.java
+++ b/libraries/rest-client/src/main/java/org/apache/zest/library/rest/client/responsereader/TableResponseReader.java
@@ -20,17 +20,17 @@
package org.apache.zest.library.rest.client.responsereader;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
+import java.time.ZonedDateTime;
+import java.time.format.DateTimeFormatter;
+import java.time.format.DateTimeParseException;
import org.apache.zest.api.injection.scope.Structure;
import org.apache.zest.api.structure.Module;
-import org.apache.zest.api.util.Dates;
import org.apache.zest.library.rest.client.spi.ResponseReader;
import org.apache.zest.library.rest.common.table.Table;
import org.apache.zest.library.rest.common.table.TableBuilder;
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
import org.restlet.Response;
import org.restlet.data.MediaType;
import org.restlet.data.Status;
@@ -78,20 +78,20 @@ public class TableResponseReader
String formatted = cell.optString("f");
if (cols.getJSONObject( j ).getString( "type" ).equals("datetime") && value != null)
- value = Dates.fromString( value.toString() );
+ value = ZonedDateTime.parse( value.toString() );
else if (cols.getJSONObject( j ).getString( "type" ).equals("date") && value != null)
try
{
- value = new SimpleDateFormat( "yyyy-MM-dd").parse( value.toString() );
- } catch (ParseException e)
+ value = DateTimeFormatter.ofPattern( "yyyy-MM-dd").parse( value.toString() );
+ } catch (DateTimeParseException e)
{
throw new ResourceException(e);
}
else if (cols.getJSONObject( j ).getString( "type" ).equals("timeofday") && value != null)
try
{
- value = new SimpleDateFormat( "HH:mm:ss").parse( value.toString() );
- } catch (ParseException e)
+ value = DateTimeFormatter.ofPattern( "HH:mm:ss").parse( value.toString() );
+ } catch (DateTimeParseException e)
{
throw new ResourceException(e);
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/libraries/rest-common/src/main/java/org/apache/zest/library/rest/common/table/TableBuilder.java
----------------------------------------------------------------------
diff --git a/libraries/rest-common/src/main/java/org/apache/zest/library/rest/common/table/TableBuilder.java b/libraries/rest-common/src/main/java/org/apache/zest/library/rest/common/table/TableBuilder.java
index 885a2c0..2143c6d 100644
--- a/libraries/rest-common/src/main/java/org/apache/zest/library/rest/common/table/TableBuilder.java
+++ b/libraries/rest-common/src/main/java/org/apache/zest/library/rest/common/table/TableBuilder.java
@@ -19,14 +19,11 @@
*/
package org.apache.zest.library.rest.common.table;
-import java.text.SimpleDateFormat;
import java.util.Collections;
import java.util.Comparator;
-import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
-import org.apache.zest.api.util.Dates;
import org.apache.zest.api.value.ValueBuilder;
import org.apache.zest.api.value.ValueBuilderFactory;
@@ -37,191 +34,215 @@ import static java.util.Collections.reverseOrder;
*/
public class TableBuilder
{
- protected ValueBuilderFactory vbf;
- private Map<String, TableBuilderFactory.Column> columns;
- private TableQuery tableQuery;
-
- protected ValueBuilder<Table> tableBuilder;
-
- protected ValueBuilder<Row> rowBuilder;
-
- public TableBuilder(ValueBuilderFactory vbf)
- {
- this.vbf = vbf;
-
- tableBuilder = vbf.newValueBuilder(Table.class);
- }
-
- public TableBuilder(ValueBuilderFactory vbf, Map<String, TableBuilderFactory.Column> columns, TableQuery tableQuery)
- {
- this.vbf = vbf;
- this.columns = columns;
- this.tableQuery = tableQuery;
-
- tableBuilder = vbf.newValueBuilder(Table.class);
-
- if (tableQuery.select().equals("*"))
- {
- for (TableBuilderFactory.Column column : columns.values())
- {
- column(column.getId(), column.getLabel(), column.getType());
- }
- } else
- {
- for (String columnName : tableQuery.select().split("[, ]"))
- {
- TableBuilderFactory.Column column = columns.get(columnName.trim());
- if (column != null)
- column(column.getId(), column.getLabel(), column.getType());
- }
- }
- }
-
- public TableBuilder column(String id, String label, String type)
- {
- ValueBuilder<Column> builder = vbf.newValueBuilder(Column.class);
- builder.prototype().id().set(id);
-
- if (tableQuery != null && tableQuery.label() != null)
- {
- // TODO Fix label selection
- }
-
- builder.prototype().label().set(label);
- builder.prototype().columnType().set(type);
- tableBuilder.prototype().cols().get().add(builder.newInstance());
- return this;
- }
-
- public TableBuilder rows(Iterable<?> rowObjects)
- {
- boolean no_format = false;
- boolean no_values = false;
- if (tableQuery != null && tableQuery.options() != null)
- {
- if (tableQuery.options().contains("no_format"))
- no_format = true;
- if (tableQuery != null && tableQuery.options().contains("no_values"))
- no_values = true;
- }
-
- for (Object rowObject : rowObjects)
- {
- row();
- for (Column column : tableBuilder.prototype().cols().get())
- {
- Object v = null;
- String f = null;
- Function valueFunction = columns.get( column.id().get()).getValueFunction();
- if (!no_values && valueFunction != null)
- v = valueFunction.apply( rowObject );
- Function formattedFunction = columns.get( column.id().get()).getFormattedFunction();
- if (!no_format && formattedFunction != null)
- f = (String) formattedFunction.apply(rowObject);
- else if (v != null)
+ protected ValueBuilderFactory vbf;
+ private Map<String, TableBuilderFactory.Column> columns;
+ private TableQuery tableQuery;
+
+ protected ValueBuilder<Table> tableBuilder;
+
+ protected ValueBuilder<Row> rowBuilder;
+
+ public TableBuilder( ValueBuilderFactory vbf )
+ {
+ this.vbf = vbf;
+
+ tableBuilder = vbf.newValueBuilder( Table.class );
+ }
+
+ public TableBuilder( ValueBuilderFactory vbf,
+ Map<String, TableBuilderFactory.Column> columns,
+ TableQuery tableQuery
+ )
+ {
+ this.vbf = vbf;
+ this.columns = columns;
+ this.tableQuery = tableQuery;
+
+ tableBuilder = vbf.newValueBuilder( Table.class );
+
+ if( tableQuery.select().equals( "*" ) )
+ {
+ for( TableBuilderFactory.Column column : columns.values() )
{
- if ( column.columnType().get().equals( Table.DATETIME))
- f = Dates.toUtcString( (Date) v );
- else if ( column.columnType().get().equals( Table.DATE))
- f = new SimpleDateFormat( "yyyy-MM-dd").format((Date) v);
- else if ( column.columnType().get().equals( Table.TIME_OF_DAY))
- f = new SimpleDateFormat( "HH:mm:ss").format((Date) v);
- else
- f = v.toString();
+ column( column.getId(), column.getLabel(), column.getType() );
}
-
- cell(v, f);
- }
- endRow();
- }
-
- return this;
- }
-
- public TableBuilder row()
- {
- if (rowBuilder != null)
- endRow();
-
- rowBuilder = vbf.newValueBuilder(Row.class);
- return this;
- }
-
- public TableBuilder endRow()
- {
- tableBuilder.prototype().rows().get().add(rowBuilder.newInstance());
- rowBuilder = null;
- return this;
- }
-
- public TableBuilder cell(Object v, String f)
- {
- ValueBuilder<Cell> cellBuilder = vbf.newValueBuilder(Cell.class);
- cellBuilder.prototype().v().set(v);
- cellBuilder.prototype().f().set(f);
- rowBuilder.prototype().c().get().add(cellBuilder.newInstance());
- return this;
- }
-
- public TableBuilder orderBy()
- {
- if (tableQuery.orderBy() != null)
- {
- // Sort table
- // Find sort column index
-
- String[] orderBy = tableQuery.orderBy().split(" ");
- boolean descending = orderBy.length == 2 && orderBy[1].equals("desc");
-
- int sortIndex = -1;
- List<Column> columns = tableBuilder.prototype().cols().get();
- for (int i = 0; i < columns.size(); i++)
- {
- Column column = columns.get(i);
- if ( column.id().get().equals(orderBy[0]))
+ }
+ else
+ {
+ for( String columnName : tableQuery.select().split( "[, ]" ) )
{
- sortIndex = i;
- break;
+ TableBuilderFactory.Column column = columns.get( columnName.trim() );
+ if( column != null )
+ {
+ column( column.getId(), column.getLabel(), column.getType() );
+ }
}
+ }
+ }
+
+ public TableBuilder column( String id, String label, String type )
+ {
+ ValueBuilder<Column> builder = vbf.newValueBuilder( Column.class );
+ builder.prototype().id().set( id );
+
+ if( tableQuery != null && tableQuery.label() != null )
+ {
+ // TODO Fix label selection
+ }
+
+ builder.prototype().label().set( label );
+ builder.prototype().columnType().set( type );
+ tableBuilder.prototype().cols().get().add( builder.newInstance() );
+ return this;
+ }
+
+ public TableBuilder rows( Iterable<?> rowObjects )
+ {
+ boolean no_format = false;
+ boolean no_values = false;
+ if( tableQuery != null && tableQuery.options() != null )
+ {
+ if( tableQuery.options().contains( "no_format" ) )
+ {
+ no_format = true;
+ }
+ if( tableQuery != null && tableQuery.options().contains( "no_values" ) )
+ {
+ no_values = true;
+ }
+ }
- }
-
- if (sortIndex != -1)
- {
- final int idx = sortIndex;
- Comparator<Row> comparator = new Comparator<Row>()
+ for( Object rowObject : rowObjects )
+ {
+ row();
+ for( Column column : tableBuilder.prototype().cols().get() )
{
- @Override
- public int compare(Row o1, Row o2)
- {
- Object o = o1.c().get().get(idx).v().get();
-
- if (o != null && o instanceof Comparable)
- {
- Comparable c1 = (Comparable) o;
- Comparable c2 = (Comparable) o2.c().get().get(idx).v().get();
- return c1.compareTo(c2);
- } else
- {
- String f1 = o1.c().get().get(idx).f().get();
- String f2 = o2.c().get().get(idx).f().get();
- return f1.compareTo(f2);
- }
- }
- };
-
- if (descending)
+ Object v = null;
+ String f = null;
+ Function valueFunction = columns.get( column.id().get() ).getValueFunction();
+ if( !no_values && valueFunction != null )
+ {
+ v = valueFunction.apply( rowObject );
+ }
+ Function formattedFunction = columns.get( column.id().get() ).getFormattedFunction();
+ if( !no_format && formattedFunction != null )
+ {
+ f = (String) formattedFunction.apply( rowObject );
+ }
+ else if( v != null )
+ {
+ if( column.columnType().get().equals( Table.DATETIME ) )
+ {
+ f = v.toString();
+ }
+ else if( column.columnType().get().equals( Table.DATE ) )
+ {
+ f = v.toString();
+ }
+ else if( column.columnType().get().equals( Table.TIME_OF_DAY ) )
+ {
+ f = v.toString();
+ }
+ else
+ {
+ f = v.toString();
+ }
+ }
+
+ cell( v, f );
+ }
+ endRow();
+ }
+
+ return this;
+ }
+
+ public TableBuilder row()
+ {
+ if( rowBuilder != null )
+ {
+ endRow();
+ }
+
+ rowBuilder = vbf.newValueBuilder( Row.class );
+ return this;
+ }
+
+ public TableBuilder endRow()
+ {
+ tableBuilder.prototype().rows().get().add( rowBuilder.newInstance() );
+ rowBuilder = null;
+ return this;
+ }
+
+ public TableBuilder cell( Object v, String f )
+ {
+ ValueBuilder<Cell> cellBuilder = vbf.newValueBuilder( Cell.class );
+ cellBuilder.prototype().v().set( v );
+ cellBuilder.prototype().f().set( f );
+ rowBuilder.prototype().c().get().add( cellBuilder.newInstance() );
+ return this;
+ }
+
+ public TableBuilder orderBy()
+ {
+ if( tableQuery.orderBy() != null )
+ {
+ // Sort table
+ // Find sort column index
+
+ String[] orderBy = tableQuery.orderBy().split( " " );
+ boolean descending = orderBy.length == 2 && orderBy[ 1 ].equals( "desc" );
+
+ int sortIndex = -1;
+ List<Column> columns = tableBuilder.prototype().cols().get();
+ for( int i = 0; i < columns.size(); i++ )
{
- // Flip it
- comparator = reverseOrder(comparator);
+ Column column = columns.get( i );
+ if( column.id().get().equals( orderBy[ 0 ] ) )
+ {
+ sortIndex = i;
+ break;
+ }
}
- Collections.sort(tableBuilder.prototype().rows().get(), comparator);
- }
- }
+ if( sortIndex != -1 )
+ {
+ final int idx = sortIndex;
+ Comparator<Row> comparator = new Comparator<Row>()
+ {
+ @Override
+ public int compare( Row o1, Row o2 )
+ {
+ Object o = o1.c().get().get( idx ).v().get();
+
+ if( o != null && o instanceof Comparable )
+ {
+ Comparable c1 = (Comparable) o;
+ Comparable c2 = (Comparable) o2.c().get().get( idx ).v().get();
+ return c1.compareTo( c2 );
+ }
+ else
+ {
+ String f1 = o1.c().get().get( idx ).f().get();
+ String f2 = o2.c().get().get( idx ).f().get();
+ return f1.compareTo( f2 );
+ }
+ }
+ };
+
+ if( descending )
+ {
+ // Flip it
+ comparator = reverseOrder( comparator );
+ }
+
+ Collections.sort( tableBuilder.prototype().rows().get(), comparator );
+ }
+ }
- return this;
- }
+ return this;
+ }
// public TableBuilder orderBy()
// {
@@ -272,33 +293,40 @@ public class TableBuilder
// return this;
// }
- public TableBuilder paging()
- {
- // Paging
- int start = 0;
- int end = tableBuilder.prototype().rows().get().size();
- if (tableQuery.offset() != null)
- start = Integer.parseInt(tableQuery.offset());
- if (tableQuery.limit() != null)
- end = Math.min(end, start + Integer.parseInt(tableQuery.limit()));
-
- if (!(start == 0 && end == tableBuilder.prototype().rows().get().size()))
- tableBuilder.prototype().rows().set(tableBuilder.prototype().rows().get().subList(start, end));
-
- return this;
-
- }
-
- public Table newTable()
- {
- if (rowBuilder != null)
- endRow();
-
- return tableBuilder.newInstance();
- }
-
- public void abortRow()
- {
- rowBuilder = null;
- }
+ public TableBuilder paging()
+ {
+ // Paging
+ int start = 0;
+ int end = tableBuilder.prototype().rows().get().size();
+ if( tableQuery.offset() != null )
+ {
+ start = Integer.parseInt( tableQuery.offset() );
+ }
+ if( tableQuery.limit() != null )
+ {
+ end = Math.min( end, start + Integer.parseInt( tableQuery.limit() ) );
+ }
+
+ if( !( start == 0 && end == tableBuilder.prototype().rows().get().size() ) )
+ {
+ tableBuilder.prototype().rows().set( tableBuilder.prototype().rows().get().subList( start, end ) );
+ }
+
+ return this;
+ }
+
+ public Table newTable()
+ {
+ if( rowBuilder != null )
+ {
+ endRow();
+ }
+
+ return tableBuilder.newInstance();
+ }
+
+ public void abortRow()
+ {
+ rowBuilder = null;
+ }
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/api/ResourceValidity.java
----------------------------------------------------------------------
diff --git a/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/api/ResourceValidity.java b/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/api/ResourceValidity.java
index 5b3ca7e..e92338b 100644
--- a/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/api/ResourceValidity.java
+++ b/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/api/ResourceValidity.java
@@ -20,7 +20,7 @@
package org.apache.zest.library.rest.server.api;
-import java.util.Date;
+import java.time.Instant;
import org.apache.zest.api.entity.EntityComposite;
import org.apache.zest.api.unitofwork.NoSuchEntityException;
import org.apache.zest.api.unitofwork.UnitOfWork;
@@ -35,20 +35,20 @@ import org.restlet.resource.ResourceException;
/**
* JAVADOC
*/
-public class ResourceValidity
+class ResourceValidity
{
- EntityComposite entity;
+ private EntityComposite entity;
private final ZestSPI spi;
private Request request;
- public ResourceValidity( EntityComposite entity, ZestSPI spi, Request request )
+ ResourceValidity( EntityComposite entity, ZestSPI spi, Request request )
{
this.entity = entity;
this.spi = spi;
this.request = request;
}
- public void updateEntity( UnitOfWork current )
+ void updateEntity( UnitOfWork current )
{
try
{
@@ -61,43 +61,45 @@ public class ResourceValidity
}
}
- public void updateResponse( Response response )
+ void updateResponse( Response response )
{
if( entity != null )
{
EntityState state = spi.entityStateOf( entity );
- Date lastModified = new Date( state.lastModified() );
Tag tag = new Tag( state.identity().identity() + "/" + state.version() );
- response.getEntity().setModificationDate( lastModified );
+ response.getEntity().setModificationDate( new java.util.Date( state.lastModified() ) );
response.getEntity().setTag( tag );
}
}
- public void checkRequest()
+ void checkRequest()
throws ResourceException
{
// Check command rules
- Date modificationDate = request.getConditions().getUnmodifiedSince();
- if( modificationDate != null )
+ Instant unmodifiedSince = request.getConditions().getUnmodifiedSince().toInstant();
+ EntityState state = spi.entityStateOf( entity );
+ Instant lastModified = cutoffMillis( state.lastModified() );
+ if( unmodifiedSince != null )
{
- EntityState state = spi.entityStateOf( entity );
- Date lastModified = new Date( ( state.lastModified() / 1000 ) * 1000 ); // Cut off milliseconds
- if( lastModified.after( modificationDate ) )
+ if( lastModified.isAfter( unmodifiedSince ) )
{
throw new ResourceException( Status.CLIENT_ERROR_CONFLICT );
}
}
// Check query rules
- modificationDate = request.getConditions().getModifiedSince();
- if( modificationDate != null )
+ Instant modifiedSince = request.getConditions().getModifiedSince().toInstant();
+ if( modifiedSince != null )
{
- EntityState state = spi.entityStateOf( entity );
- Date lastModified = new Date( ( state.lastModified() / 1000 ) * 1000 ); // Cut off milliseconds
- if( !lastModified.after( modificationDate ) )
+ if( !lastModified.isAfter( modifiedSince ) )
{
throw new ResourceException( Status.REDIRECTION_NOT_MODIFIED );
}
}
}
+
+ private Instant cutoffMillis( long time )
+ {
+ return Instant.ofEpochMilli( time / 1000 * 1000 );
+ }
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/restlet/requestreader/DefaultRequestReader.java
----------------------------------------------------------------------
diff --git a/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/restlet/requestreader/DefaultRequestReader.java b/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/restlet/requestreader/DefaultRequestReader.java
index a5c0fa3..6d4af64 100644
--- a/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/restlet/requestreader/DefaultRequestReader.java
+++ b/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/restlet/requestreader/DefaultRequestReader.java
@@ -21,8 +21,14 @@ package org.apache.zest.library.rest.server.restlet.requestreader;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
+import java.time.Duration;
+import java.time.Instant;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.OffsetDateTime;
+import java.time.Period;
+import java.time.ZonedDateTime;
import java.util.Collections;
-import java.util.Date;
import java.util.Map;
import java.util.function.Function;
import org.apache.zest.api.association.AssociationDescriptor;
@@ -35,7 +41,6 @@ import org.apache.zest.api.property.PropertyDescriptor;
import org.apache.zest.api.service.qualifier.Tagged;
import org.apache.zest.api.structure.ModuleDescriptor;
import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
-import org.apache.zest.api.util.Dates;
import org.apache.zest.api.value.ValueBuilder;
import org.apache.zest.api.value.ValueBuilderFactory;
import org.apache.zest.api.value.ValueComposite;
@@ -455,9 +460,33 @@ public class DefaultRequestReader
arg = Boolean.valueOf( argString );
}
}
- else if( Date.class.isAssignableFrom( parameterType ) )
+ else if( LocalDate.class.isAssignableFrom( parameterType ) )
{
- arg = Dates.fromString( argString );
+ arg = LocalDate.parse( argString );
+ }
+ else if( LocalDateTime.class.isAssignableFrom( parameterType ) )
+ {
+ arg = LocalDateTime.parse( argString );
+ }
+ else if( ZonedDateTime.class.isAssignableFrom( parameterType ) )
+ {
+ arg = ZonedDateTime.parse( argString );
+ }
+ else if( OffsetDateTime.class.isAssignableFrom( parameterType ) )
+ {
+ arg = OffsetDateTime.parse( argString );
+ }
+ else if( Instant.class.isAssignableFrom( parameterType ) )
+ {
+ arg = Instant.parse( argString );
+ }
+ else if( Duration.class.isAssignableFrom( parameterType ) )
+ {
+ arg = Duration.parse( argString );
+ }
+ else if( Period.class.isAssignableFrom( parameterType ) )
+ {
+ arg = Period.parse( argString );
}
else if( parameterType.isInterface() )
{
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/restlet/responsewriter/TableResponseWriter.java
----------------------------------------------------------------------
diff --git a/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/restlet/responsewriter/TableResponseWriter.java b/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/restlet/responsewriter/TableResponseWriter.java
index 5f74b26..b33ae46 100644
--- a/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/restlet/responsewriter/TableResponseWriter.java
+++ b/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/restlet/responsewriter/TableResponseWriter.java
@@ -24,20 +24,17 @@ import freemarker.template.Configuration;
import freemarker.template.TemplateException;
import java.io.IOException;
import java.io.Writer;
-import java.text.SimpleDateFormat;
import java.util.Arrays;
-import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import org.json.JSONException;
-import org.json.JSONWriter;
import org.apache.zest.api.injection.scope.Service;
-import org.apache.zest.api.util.Dates;
import org.apache.zest.library.rest.common.table.Cell;
import org.apache.zest.library.rest.common.table.Column;
import org.apache.zest.library.rest.common.table.Row;
import org.apache.zest.library.rest.common.table.Table;
+import org.json.JSONException;
+import org.json.JSONWriter;
import org.restlet.Response;
import org.restlet.data.CharacterSet;
import org.restlet.data.MediaType;
@@ -129,21 +126,21 @@ public class TableResponseWriter extends AbstractResponseWriter
.get()
.equals( Table.DATETIME ) && value != null )
{
- value = Dates.toUtcString( (Date) value );
+ value = value.toString();
}
else if( columnList.get( idx )
.columnType()
.get()
.equals( Table.DATE ) && value != null )
{
- value = new SimpleDateFormat( "yyyy-MM-dd" ).format( (Date) value );
+ value = value.toString();
}
else if( columnList.get( idx )
.columnType()
.get()
.equals( Table.TIME_OF_DAY ) && value != null )
{
- value = new SimpleDateFormat( "HH:mm:ss" ).format( (Date) value );
+ value = value.toString();
}
if( value != null )
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/libraries/rest/src/main/java/org/apache/zest/library/rest/admin/EntityResource.java
----------------------------------------------------------------------
diff --git a/libraries/rest/src/main/java/org/apache/zest/library/rest/admin/EntityResource.java b/libraries/rest/src/main/java/org/apache/zest/library/rest/admin/EntityResource.java
index 65fae4d..cff150b 100755
--- a/libraries/rest/src/main/java/org/apache/zest/library/rest/admin/EntityResource.java
+++ b/libraries/rest/src/main/java/org/apache/zest/library/rest/admin/EntityResource.java
@@ -25,9 +25,9 @@ import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringReader;
import java.io.Writer;
+import java.time.Instant;
import java.util.Arrays;
import java.util.Collections;
-import java.util.Date;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
@@ -69,6 +69,8 @@ import org.restlet.representation.WriterRepresentation;
import org.restlet.resource.ResourceException;
import org.restlet.resource.ServerResource;
+import static java.time.Instant.ofEpochMilli;
+
public class EntityResource
extends ServerResource
{
@@ -84,6 +86,7 @@ public class EntityResource
@Uses
private EntityStateSerializer entitySerializer;
+
private String identity;
public EntityResource()
@@ -140,10 +143,10 @@ public class EntityResource
EntityState entityState = getEntityState( uow );
// Check modification date
- Date lastModified = getRequest().getConditions().getModifiedSince();
+ java.util.Date lastModified = getRequest().getConditions().getModifiedSince();
if( lastModified != null )
{
- if( lastModified.getTime() / 1000 == entityState.lastModified() / 1000 )
+ if( lastModified.toInstant().getEpochSecond() == ofEpochMilli( entityState.lastModified()).getEpochSecond() )
{
throw new ResourceException( Status.REDIRECTION_NOT_MODIFIED );
}
@@ -190,7 +193,7 @@ public class EntityResource
private Representation entityHeaders( Representation representation, EntityState entityState )
{
- representation.setModificationDate( new Date( entityState.lastModified() ) );
+ representation.setModificationDate( new java.util.Date( entityState.lastModified() ) );
representation.setTag( new Tag( "" + entityState.version() ) );
representation.setCharacterSet( CharacterSet.UTF_8 );
representation.setLanguages( Collections.singletonList( Language.ENGLISH ) );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/libraries/rest/src/test/java/org/apache/zest/library/rest/admin/RestTest.java
----------------------------------------------------------------------
diff --git a/libraries/rest/src/test/java/org/apache/zest/library/rest/admin/RestTest.java b/libraries/rest/src/test/java/org/apache/zest/library/rest/admin/RestTest.java
index dc7f925..0d4013d 100644
--- a/libraries/rest/src/test/java/org/apache/zest/library/rest/admin/RestTest.java
+++ b/libraries/rest/src/test/java/org/apache/zest/library/rest/admin/RestTest.java
@@ -57,8 +57,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
-public class RestTest
- extends AbstractZestTest
+public class RestTest extends AbstractZestTest
{
@Override
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/libraries/scheduler/dev-status.xml
----------------------------------------------------------------------
diff --git a/libraries/scheduler/dev-status.xml b/libraries/scheduler/dev-status.xml
index d43c910..55032e6 100644
--- a/libraries/scheduler/dev-status.xml
+++ b/libraries/scheduler/dev-status.xml
@@ -24,7 +24,7 @@
http://zest.apache.org/schemas/2008/dev-status/1/dev-status.xsd">
<status>
<!--none,early,beta,stable,mature-->
- <codebase>beta</codebase>
+ <codebase>early</codebase>
<!-- none, brief, good, complete -->
<documentation>good</documentation>
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/CronSchedule.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/CronSchedule.java b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/CronSchedule.java
index ceeac11..5270da0 100644
--- a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/CronSchedule.java
+++ b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/CronSchedule.java
@@ -20,6 +20,7 @@
package org.apache.zest.library.scheduler;
import java.lang.annotation.Retention;
+import java.time.Instant;
import org.apache.zest.api.constraint.Constraint;
import org.apache.zest.api.constraint.ConstraintDeclaration;
import org.apache.zest.api.constraint.Constraints;
@@ -75,16 +76,18 @@ public interface CronSchedule
}
@Override
- public long nextRun( long from )
+ public Instant nextRun( Instant from )
{
- long actualFrom = from;
- long firstRun = start().get().getMillis();
- if( firstRun > from )
+ Instant actualFrom = from;
+ Instant firstRun = start().get();
+ if( firstRun.isAfter(from ))
{
actualFrom = firstRun;
}
// TODO:PM cron "next run" handling mismatch with the underlying cron library
- Long nextRun = createCron().firstRunAfter( actualFrom + 1000 );
+ Instant nextRun = Instant.ofEpochMilli(
+ createCron().firstRunAfter( actualFrom.plusSeconds( 1 ).toEpochMilli())
+ );
LOGGER.info( "CronSchedule::nextRun({}) is {}", from, firstRun );
return nextRun;
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/OnceSchedule.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/OnceSchedule.java b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/OnceSchedule.java
index 2fcc5c3..7421882 100644
--- a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/OnceSchedule.java
+++ b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/OnceSchedule.java
@@ -19,6 +19,7 @@
*/
package org.apache.zest.library.scheduler;
+import java.time.Instant;
import org.apache.zest.api.mixin.Mixins;
@Mixins( OnceSchedule.OnceScheduleMixin.class )
@@ -44,15 +45,15 @@ public interface OnceSchedule
}
@Override
- public long nextRun( long from )
+ public Instant nextRun( Instant from )
{
if( done().get() )
{
- return Long.MIN_VALUE;
+ return Instant.MIN;
}
done().set( true );
- long runAt = start().get().getMillis();
- if( runAt >= from )
+ Instant runAt = start().get();
+ if( runAt.isAfter( from ) )
{
return runAt;
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/Schedule.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/Schedule.java b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/Schedule.java
index b9dae0f..6d7191d 100644
--- a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/Schedule.java
+++ b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/Schedule.java
@@ -19,13 +19,13 @@
*/
package org.apache.zest.library.scheduler;
+import java.time.Instant;
+import java.time.ZonedDateTime;
import org.apache.zest.api.association.Association;
import org.apache.zest.api.common.UseDefaults;
import org.apache.zest.api.entity.EntityComposite;
import org.apache.zest.api.property.Immutable;
import org.apache.zest.api.property.Property;
-import org.apache.zest.library.scheduler.Task;
-import org.joda.time.DateTime;
/**
* Represent the scheduling of a {@link Task}.
@@ -42,7 +42,7 @@ public interface Schedule extends EntityComposite
* @return The property containing the first time this Schedule will be run.
*/
@Immutable
- Property<DateTime> start();
+ Property<Instant> start();
/** Returns true if the Schedule has been cancelled.
*
@@ -120,7 +120,7 @@ public interface Schedule extends EntityComposite
*
* @return The exact absolute time when this Schedule is to be run next time, or -1 if never
*/
- long nextRun( long from );
+ Instant nextRun( Instant from );
/**
* Return a representation of the Schedule in a human understandable format.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/ScheduleFactory.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/ScheduleFactory.java b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/ScheduleFactory.java
index feba8c4..c5fdd81 100644
--- a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/ScheduleFactory.java
+++ b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/ScheduleFactory.java
@@ -19,11 +19,12 @@
*/
package org.apache.zest.library.scheduler;
+import java.time.Instant;
+import java.time.ZonedDateTime;
import org.apache.zest.api.concern.Concerns;
import org.apache.zest.api.unitofwork.concern.UnitOfWorkConcern;
import org.apache.zest.api.unitofwork.concern.UnitOfWorkPropagation;
import org.apache.zest.library.scheduler.defaults.DefaultScheduleFactoryMixin;
-import org.joda.time.DateTime;
import org.apache.zest.api.mixin.Mixins;
import static org.apache.zest.api.unitofwork.concern.UnitOfWorkPropagation.Propagation.MANDATORY;
@@ -33,8 +34,8 @@ import static org.apache.zest.api.unitofwork.concern.UnitOfWorkPropagation.Propa
public interface ScheduleFactory
{
@UnitOfWorkPropagation( MANDATORY)
- Schedule newCronSchedule( Task task, String cronExpression, DateTime start );
+ Schedule newCronSchedule( Task task, String cronExpression, Instant start );
@UnitOfWorkPropagation( MANDATORY)
- Schedule newOnceSchedule( Task task, DateTime runAt );
+ Schedule newOnceSchedule( Task task, Instant runAt );
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/Scheduler.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/Scheduler.java b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/Scheduler.java
index 6699e44..ac081d6 100644
--- a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/Scheduler.java
+++ b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/Scheduler.java
@@ -19,8 +19,8 @@
*/
package org.apache.zest.library.scheduler;
+import java.time.Instant;
import org.apache.zest.library.scheduler.internal.Schedules;
-import org.joda.time.DateTime;
import org.apache.zest.api.concern.Concerns;
import org.apache.zest.api.structure.Application;
import org.apache.zest.api.unitofwork.concern.UnitOfWorkConcern;
@@ -73,7 +73,7 @@ public interface Scheduler
* @return The newly created Schedule
*/
@UnitOfWorkPropagation( MANDATORY )
- Schedule scheduleOnce( Task task, DateTime runAt );
+ Schedule scheduleOnce( Task task, Instant runAt );
/**
* Schedule a Task using a CronExpression.
@@ -108,7 +108,7 @@ public interface Scheduler
* @return The newly created Schedule
*/
@UnitOfWorkPropagation( MANDATORY )
- Schedule scheduleCron( Task task, @CronSchedule.CronExpression String cronExpression, DateTime start );
+ Schedule scheduleCron( Task task, @CronSchedule.CronExpression String cronExpression, Instant start );
/** Schedules a custom Schedule.
*
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/defaults/DefaultScheduleFactoryMixin.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/defaults/DefaultScheduleFactoryMixin.java b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/defaults/DefaultScheduleFactoryMixin.java
index 73775c4..2d21e27 100644
--- a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/defaults/DefaultScheduleFactoryMixin.java
+++ b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/defaults/DefaultScheduleFactoryMixin.java
@@ -20,6 +20,7 @@
package org.apache.zest.library.scheduler.defaults;
+import java.time.Instant;
import org.apache.zest.api.entity.EntityBuilder;
import org.apache.zest.api.injection.scope.Service;
import org.apache.zest.api.injection.scope.Structure;
@@ -32,7 +33,6 @@ import org.apache.zest.library.scheduler.ScheduleFactory;
import org.apache.zest.library.scheduler.SchedulerService;
import org.apache.zest.library.scheduler.Task;
import org.apache.zest.spi.uuid.UuidIdentityGeneratorService;
-import org.joda.time.DateTime;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -51,18 +51,18 @@ public class DefaultScheduleFactoryMixin
private UuidIdentityGeneratorService uuid;
@Override
- public CronSchedule newCronSchedule( Task task, String cronExpression, DateTime start )
+ public CronSchedule newCronSchedule( Task task, String cronExpression, Instant start )
{
return newPersistentCronSchedule( task, cronExpression, start );
}
@Override
- public Schedule newOnceSchedule( Task task, DateTime runAt )
+ public Schedule newOnceSchedule( Task task, Instant runAt )
{
return newPersistentOnceSchedule( task, runAt );
}
- private CronSchedule newPersistentCronSchedule( Task task, String cronExpression, DateTime start )
+ private CronSchedule newPersistentCronSchedule( Task task, String cronExpression, Instant start )
{
UnitOfWork uow = uowf.currentUnitOfWork();
EntityBuilder<CronSchedule> builder = uow.newEntityBuilder( CronSchedule.class );
@@ -76,7 +76,7 @@ public class DefaultScheduleFactoryMixin
return schedule;
}
- private Schedule newPersistentOnceSchedule( Task task, DateTime runAt )
+ private Schedule newPersistentOnceSchedule( Task task, Instant runAt )
{
UnitOfWork uow = uowf.currentUnitOfWork();
EntityBuilder<OnceSchedule> builder = uow.newEntityBuilder( OnceSchedule.class );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/Execution.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/Execution.java b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/Execution.java
index 589a5a0..6ca01af 100644
--- a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/Execution.java
+++ b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/Execution.java
@@ -20,6 +20,8 @@
package org.apache.zest.library.scheduler.internal;
+import java.time.Duration;
+import java.time.Instant;
import java.util.SortedSet;
import java.util.TreeSet;
import java.util.concurrent.LinkedBlockingQueue;
@@ -131,16 +133,14 @@ public interface Execution
private boolean isTime( ScheduleTime scheduleTime )
{
- long now = System.currentTimeMillis();
- return scheduleTime.nextTime() <= now;
+ return scheduleTime.nextTime().isBefore( Instant.now() );
}
private void waitFor( ScheduleTime scheduleTime )
throws InterruptedException
{
- long now = System.currentTimeMillis();
- long waitingTime = scheduleTime.nextTime() - now;
- waitFor( waitingTime );
+ Duration waitingTime = Duration.between( Instant.now(), scheduleTime.nextTime() );
+ waitFor( waitingTime.toMillis() );
}
private void waitFor( long waitingTime )
@@ -164,14 +164,12 @@ public interface Execution
@Override
public void updateNextTime( ScheduleTime oldScheduleTime )
{
- long now = System.currentTimeMillis();
-
try (UnitOfWork uow = uowf.newUnitOfWork()) // This will discard() the UoW when block is exited. We are only doing reads, so fine.
{
submitTaskForExecution( oldScheduleTime );
Schedule schedule = uow.get( Schedule.class, oldScheduleTime.scheduleIdentity() );
- long nextTime = schedule.nextRun( now );
- if( nextTime != Long.MIN_VALUE )
+ Instant nextTime = schedule.nextRun( Instant.now() );
+ if( nextTime.isAfter( Instant.MIN ) )
{
ScheduleTime newScheduleTime = new ScheduleTime( oldScheduleTime.scheduleIdentity(), nextTime );
synchronized( lock )
@@ -205,15 +203,15 @@ public interface Execution
@Override
public void dispatchForExecution( Schedule schedule )
{
- long now = System.currentTimeMillis();
- long nextRun = schedule.nextRun( now );
- if( nextRun > 0 )
+ Instant nextRun = schedule.nextRun( Instant.now() );
+ if( nextRun.equals( Instant.MIN ) )
{
- synchronized( lock )
- {
- timingQueue.add( new ScheduleTime( schedule.identity().get(), nextRun ) );
- lock.notifyAll();
- }
+ return;
+ }
+ synchronized( lock )
+ {
+ timingQueue.add( new ScheduleTime( schedule.identity().get(), nextRun ) );
+ lock.notifyAll();
}
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/ScheduleTime.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/ScheduleTime.java b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/ScheduleTime.java
index 5236282..caf9a75 100644
--- a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/ScheduleTime.java
+++ b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/ScheduleTime.java
@@ -19,22 +19,23 @@
*/
package org.apache.zest.library.scheduler.internal;
+import java.time.Instant;
import org.apache.zest.api.util.NullArgumentException;
public final class ScheduleTime
implements Comparable<ScheduleTime>
{
private final String scheduleIdentity;
- private final long nextTime;
+ private final Instant nextTime;
- public ScheduleTime( String scheduleIdentity, long nextTime )
+ public ScheduleTime( String scheduleIdentity, Instant nextTime )
{
NullArgumentException.validateNotEmpty( "scheduleIdentity", scheduleIdentity );
this.scheduleIdentity = scheduleIdentity;
this.nextTime = nextTime;
}
- public long nextTime()
+ public Instant nextTime()
{
return nextTime;
}
@@ -52,7 +53,7 @@ public final class ScheduleTime
return 0;
}
- if( this.nextTime < another.nextTime )
+ if( this.nextTime.isBefore(another.nextTime) )
{
return -1;
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/SchedulerMixin.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/SchedulerMixin.java b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/SchedulerMixin.java
index ab6ed40..43dc826 100644
--- a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/SchedulerMixin.java
+++ b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/SchedulerMixin.java
@@ -19,6 +19,7 @@
*/
package org.apache.zest.library.scheduler.internal;
+import java.time.Instant;
import org.apache.zest.api.configuration.Configuration;
import org.apache.zest.api.injection.scope.Service;
import org.apache.zest.api.injection.scope.Structure;
@@ -29,15 +30,14 @@ import org.apache.zest.api.unitofwork.UnitOfWork;
import org.apache.zest.api.unitofwork.UnitOfWorkCompletionException;
import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
import org.apache.zest.api.usecase.UsecaseBuilder;
+import org.apache.zest.library.scheduler.CronSchedule;
+import org.apache.zest.library.scheduler.Schedule;
+import org.apache.zest.library.scheduler.ScheduleFactory;
import org.apache.zest.library.scheduler.Scheduler;
import org.apache.zest.library.scheduler.SchedulerConfiguration;
import org.apache.zest.library.scheduler.SchedulerService;
import org.apache.zest.library.scheduler.SchedulesHandler;
import org.apache.zest.library.scheduler.Task;
-import org.apache.zest.library.scheduler.CronSchedule;
-import org.apache.zest.library.scheduler.Schedule;
-import org.apache.zest.library.scheduler.ScheduleFactory;
-import org.joda.time.DateTime;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -64,21 +64,16 @@ public class SchedulerMixin
@This
private Configuration<SchedulerConfiguration> config;
- public SchedulerMixin()
- {
- }
-
@Override
public Schedule scheduleOnce( Task task, int initialSecondsDelay )
{
- long now = System.currentTimeMillis();
- Schedule schedule = scheduleFactory.newOnceSchedule( task, new DateTime( now + initialSecondsDelay * 1000 ) );
+ Schedule schedule = scheduleFactory.newOnceSchedule( task, Instant.now().plusSeconds( initialSecondsDelay ) );
saveAndDispatch( schedule );
return schedule;
}
@Override
- public Schedule scheduleOnce( Task task, DateTime runAt )
+ public Schedule scheduleOnce( Task task, Instant runAt )
{
Schedule schedule = scheduleFactory.newOnceSchedule( task, runAt );
saveAndDispatch( schedule );
@@ -88,14 +83,13 @@ public class SchedulerMixin
@Override
public Schedule scheduleCron( Task task, String cronExpression )
{
- DateTime now = new DateTime();
- Schedule schedule = scheduleFactory.newCronSchedule( task, cronExpression, now );
+ Schedule schedule = scheduleFactory.newCronSchedule( task, cronExpression, Instant.now() );
saveAndDispatch( schedule );
return schedule;
}
@Override
- public Schedule scheduleCron( Task task, @CronSchedule.CronExpression String cronExpression, DateTime start )
+ public Schedule scheduleCron( Task task, @CronSchedule.CronExpression String cronExpression, Instant start )
{
Schedule schedule = scheduleFactory.newCronSchedule( task, cronExpression, start );
saveAndDispatch( schedule );
@@ -111,7 +105,7 @@ public class SchedulerMixin
@Override
public Schedule scheduleCron( Task task, String cronExpression, long initialDelay )
{
- DateTime start = new DateTime( System.currentTimeMillis() + initialDelay );
+ Instant start = Instant.now().plusMillis( initialDelay );
Schedule schedule = scheduleFactory.newCronSchedule( task, cronExpression, start );
saveAndDispatch( schedule );
return schedule;
@@ -171,7 +165,8 @@ public class SchedulerMixin
{
execution.dispatchForExecution( schedule );
}
- } catch( Exception e )
+ }
+ catch( Exception e )
{
e.printStackTrace();
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/Timeline.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/Timeline.java b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/Timeline.java
index d708703..fac381d 100644
--- a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/Timeline.java
+++ b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/Timeline.java
@@ -19,6 +19,7 @@
*/
package org.apache.zest.library.scheduler.timeline;
+import java.time.Instant;
import java.time.ZonedDateTime;
import org.apache.zest.api.unitofwork.concern.UnitOfWorkPropagation;
@@ -69,6 +70,6 @@ public interface Timeline
*/
@UnitOfWorkPropagation( UnitOfWorkPropagation.Propagation.MANDATORY )
// START SNIPPET: timeline
- Iterable<TimelineRecord> getRecords( long from, long to );
+ Iterable<TimelineRecord> getRecords( Instant from, Instant to );
}
// END SNIPPET: timeline
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/TimelineForScheduleConcern.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/TimelineForScheduleConcern.java b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/TimelineForScheduleConcern.java
index a35a6a8..6c50651 100644
--- a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/TimelineForScheduleConcern.java
+++ b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/TimelineForScheduleConcern.java
@@ -22,6 +22,7 @@ package org.apache.zest.library.scheduler.timeline;
import java.io.BufferedOutputStream;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
+import java.time.Instant;
import java.util.List;
import org.apache.zest.api.concern.ConcernOf;
import org.apache.zest.api.injection.scope.Structure;
@@ -71,7 +72,7 @@ public abstract class TimelineForScheduleConcern
prototype.taskName().set( task().get().name().get() );
List<String> tags = task().get().tags().get();
prototype.taskTags().set( tags );
- prototype.timestamp().set( System.currentTimeMillis() );
+ prototype.timestamp().set( Instant.now() );
prototype.scheduleIdentity().set( this.identity().get() );
prototype.details().set( details );
TimelineRecord record = builder.newInstance();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/TimelineRecord.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/TimelineRecord.java b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/TimelineRecord.java
index 5bfd1d5..39108a9 100644
--- a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/TimelineRecord.java
+++ b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/TimelineRecord.java
@@ -19,6 +19,7 @@
*/
package org.apache.zest.library.scheduler.timeline;
+import java.time.Instant;
import java.util.List;
import org.apache.zest.api.common.UseDefaults;
import org.apache.zest.api.entity.Queryable;
@@ -44,7 +45,7 @@ public interface TimelineRecord
/**
* @return Timestamp of this record
*/
- Property<Long> timestamp();
+ Property<Instant> timestamp();
/**
* @return Name of the associated {@link org.apache.zest.library.scheduler.Task}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/TimelineScheduleMixin.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/TimelineScheduleMixin.java b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/TimelineScheduleMixin.java
index bf89862..9143bcf 100644
--- a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/TimelineScheduleMixin.java
+++ b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/TimelineScheduleMixin.java
@@ -19,6 +19,7 @@
*/
package org.apache.zest.library.scheduler.timeline;
+import java.time.Instant;
import java.time.ZonedDateTime;
import java.util.Collection;
import java.util.Collections;
@@ -64,7 +65,7 @@ public class TimelineScheduleMixin
public Iterable<TimelineRecord> getNextRecords( int maxResults )
{
SortedSet<TimelineRecord> result = new TreeSet<>();
- long time = System.currentTimeMillis();
+ Instant time = Instant.now();
for( int i = 0; i < maxResults; i++ )
{
time = me.nextRun( time );
@@ -76,27 +77,27 @@ public class TimelineScheduleMixin
@Override
public Iterable<TimelineRecord> getRecords( ZonedDateTime from, ZonedDateTime to )
{
- return getRecords( from.toInstant().toEpochMilli(), to.toInstant().toEpochMilli() );
+ return getRecords( from.toInstant(), to.toInstant() );
}
@Override
- public Iterable<TimelineRecord> getRecords( long from, long to )
+ public Iterable<TimelineRecord> getRecords( Instant from, Instant to )
{
- long now = System.currentTimeMillis();
+ Instant now = Instant.now();
SortedSet<TimelineRecord> result = new TreeSet<>();
result.addAll( getPastRecords( from ) );
result.addAll( getFutureRecords( now, to ) );
return result;
}
- private Collection<? extends TimelineRecord> getPastRecords( long from )
+ private Collection<? extends TimelineRecord> getPastRecords( Instant from )
{
SortedSet<TimelineRecord> result = new TreeSet<>();
List<TimelineRecord> timelineRecords = state.history().get();
for( TimelineRecord record : timelineRecords )
{
- Long timestamp = record.timestamp().get();
- if( timestamp >= from )
+ Instant timestamp = record.timestamp().get();
+ if( timestamp.isAfter( from ) )
{
result.add( record );
}
@@ -104,19 +105,19 @@ public class TimelineScheduleMixin
return result;
}
- private Collection<? extends TimelineRecord> getFutureRecords( long now, long to )
+ private Collection<? extends TimelineRecord> getFutureRecords( Instant now, Instant to )
{
- if( now > to )
+ if( now.isAfter( to ) )
{
return Collections.emptyList();
}
SortedSet<TimelineRecord> result = new TreeSet<>();
- long time = now;
- while( time <= to )
+ Instant time = Instant.now();
+ while( time.isBefore(to) )
{
time = me.nextRun( time );
- if( time <= to )
+ if( time.isBefore( to ) )
{
result.add( createFutureRecord( time ) );
}
@@ -124,7 +125,7 @@ public class TimelineScheduleMixin
return result;
}
- private TimelineRecord createFutureRecord( long when )
+ private TimelineRecord createFutureRecord( Instant when )
{
ValueBuilder<TimelineRecord> builder = module.newValueBuilder( TimelineRecord.class );
TimelineRecord prototype = builder.prototype();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/TimelineSchedulerServiceMixin.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/TimelineSchedulerServiceMixin.java b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/TimelineSchedulerServiceMixin.java
index e4bc43d..41d5a98 100644
--- a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/TimelineSchedulerServiceMixin.java
+++ b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/TimelineSchedulerServiceMixin.java
@@ -19,6 +19,7 @@
*/
package org.apache.zest.library.scheduler.timeline;
+import java.time.Instant;
import java.time.ZonedDateTime;
import java.util.SortedSet;
import java.util.TreeSet;
@@ -93,7 +94,7 @@ public abstract class TimelineSchedulerServiceMixin
}
@Override
- public Iterable<TimelineRecord> getRecords( long from, long to )
+ public Iterable<TimelineRecord> getRecords( Instant from, Instant to )
{
SortedSet<TimelineRecord> result = new TreeSet<>();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/CronScheduleTest.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/CronScheduleTest.java b/libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/CronScheduleTest.java
index b62e552..a346f83 100644
--- a/libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/CronScheduleTest.java
+++ b/libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/CronScheduleTest.java
@@ -20,16 +20,16 @@
package org.apache.zest.library.scheduler;
+import java.time.Instant;
import org.apache.zest.api.entity.EntityBuilder;
import org.apache.zest.api.unitofwork.UnitOfWork;
import org.apache.zest.bootstrap.AssemblyException;
import org.apache.zest.bootstrap.ModuleAssembly;
import org.apache.zest.test.AbstractZestTest;
import org.apache.zest.test.EntityTestAssembler;
-import org.joda.time.DateTime;
import org.junit.Test;
-import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsEqual.equalTo;
import static org.junit.Assert.assertThat;
public class CronScheduleTest extends AbstractZestTest
@@ -53,16 +53,16 @@ public class CronScheduleTest extends AbstractZestTest
builder1.instance().name().set( "abc" );
Task task = builder1.newInstance();
EntityBuilder<CronSchedule> builder = work.newEntityBuilder( CronSchedule.class );
- builder.instance().start().set( DateTime.now() );
+ builder.instance().start().set( Instant.now() );
builder.instance().task().set( task );
builder.instance().cronExpression().set( "*/15 * * * * *" );
CronSchedule schedule = builder.newInstance();
- long nextRun = schedule.nextRun( System.currentTimeMillis() );
+ Instant nextRun = schedule.nextRun( Instant.now());
for( int i = 0; i < 1000; i++ )
{
- long previousRun = nextRun;
+ Instant previousRun = nextRun;
nextRun = schedule.nextRun( previousRun );
- assertThat( "nextRun( previousRun + 1s ) @" + i, nextRun, is( previousRun + 15000 ) );
+ assertThat( "nextRun( previousRun + 1s ) @" + i, nextRun, equalTo( previousRun.plusSeconds( 15 )) );
}
work.discard();
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/SchedulerTest.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/SchedulerTest.java b/libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/SchedulerTest.java
index 38b41bf..9f3eae6 100644
--- a/libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/SchedulerTest.java
+++ b/libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/SchedulerTest.java
@@ -19,6 +19,8 @@
*/
package org.apache.zest.library.scheduler;
+import java.time.Duration;
+import java.time.ZonedDateTime;
import java.util.concurrent.Callable;
import org.apache.zest.api.common.Visibility;
import org.apache.zest.api.unitofwork.UnitOfWork;
@@ -29,8 +31,6 @@ import org.apache.zest.bootstrap.AssemblyException;
import org.apache.zest.bootstrap.ModuleAssembly;
import org.apache.zest.library.scheduler.bootstrap.SchedulerAssembler;
import org.apache.zest.library.scheduler.timeline.Timeline;
-import org.joda.time.DateTime;
-import org.joda.time.Interval;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -94,7 +94,7 @@ public class SchedulerTest
throws UnitOfWorkCompletionException
{
Usecase usecase = UsecaseBuilder.newUsecase( "TestMinutely" );
- DateTime start = new DateTime();
+ ZonedDateTime start = ZonedDateTime.now();
String taskIdentity;
long sleepMillis;
try( UnitOfWork uow = unitOfWorkFactory.newUnitOfWork( usecase ) )
@@ -104,13 +104,13 @@ public class SchedulerTest
FooTask task = createFooTask( uow, usecase.name(), BAZAR );
taskIdentity = task.identity().get();
- DateTime expectedRun = start.withMillisOfSecond( 0 ).withSecondOfMinute( 0 ).plusMinutes( 1 );
+ ZonedDateTime expectedRun = start.withNano( 0 ).withSecond( 0 ).plusMinutes( 1 );
scheduler.scheduleCron( task, "@minutely" );
uow.complete();
- sleepMillis = new Interval( start, expectedRun ).toDurationMillis();
- LOGGER.info( "Task scheduled on {} to be run at {}", start.getMillis(), expectedRun.getMillis() );
+ sleepMillis = Duration.between( start, expectedRun ).toMillis();
+ LOGGER.info( "Task scheduled on {} to be run at {}", start.toLocalTime(), expectedRun.toLocalTime() );
}
await( usecase.name() )
@@ -121,22 +121,22 @@ public class SchedulerTest
try( UnitOfWork uow = unitOfWorkFactory.newUnitOfWork( usecase ) )
{
Timeline timeline = serviceFinder.findService( Timeline.class ).get();
- DateTime now = new DateTime();
+ ZonedDateTime now = ZonedDateTime.now();
// Queries returning past records
assertThat( count( timeline.getLastRecords( 5 ) ),
is( 2L ) );
- assertThat( count( timeline.getRecords( start.getMillis(), now.getMillis() ) ),
+ assertThat( count( timeline.getRecords( start.toInstant(), now.toInstant() ) ),
is( 2L ) );
// Queries returning future records
assertThat( count( timeline.getNextRecords( 4 ) ),
is( 4L ) );
- assertThat( count( timeline.getRecords( now.getMillis() + 100, now.plusMinutes( 5 ).getMillis() ) ),
+ assertThat( count( timeline.getRecords( now.plusNanos( 100000000L ), now.plusMinutes( 5 )) ),
is( 5L ) );
// Queries returning mixed past and future records
- assertThat( count( timeline.getRecords( start.getMillis(), now.plusMinutes( 5 ).getMillis() ) ),
+ assertThat( count( timeline.getRecords( start, now.plusMinutes( 5 ) ) ),
is( 7L ) );
}
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/manual/src/main/java/org/apache/zest/manual/recipes/createEntity/Accident.java
----------------------------------------------------------------------
diff --git a/manual/src/main/java/org/apache/zest/manual/recipes/createEntity/Accident.java b/manual/src/main/java/org/apache/zest/manual/recipes/createEntity/Accident.java
index 820f2a6..77d93f6 100644
--- a/manual/src/main/java/org/apache/zest/manual/recipes/createEntity/Accident.java
+++ b/manual/src/main/java/org/apache/zest/manual/recipes/createEntity/Accident.java
@@ -19,15 +19,15 @@
*/
package org.apache.zest.manual.recipes.createEntity;
+import java.time.LocalDate;
import org.apache.zest.api.property.Property;
-import java.util.Date;
// START SNIPPET: entity
public interface Accident
{
Property<String> description();
- Property<Date> occured();
- Property<Date> repaired();
+ Property<LocalDate> occured();
+ Property<LocalDate> repaired();
}
// END SNIPPET: entity
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_a/api/TransitEdge.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_a/api/TransitEdge.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_a/api/TransitEdge.java
index 37abf10..f2a6adc 100644
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_a/api/TransitEdge.java
+++ b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_a/api/TransitEdge.java
@@ -20,7 +20,7 @@
package org.apache.zest.sample.dcicargo.pathfinder_a.api;
import java.io.Serializable;
-import java.util.Date;
+import java.time.LocalDate;
/**
* Represents an edge in a path through a graph,
@@ -32,8 +32,8 @@ public final class TransitEdge implements Serializable
private final String voyageNumber;
private final String fromUnLocode;
private final String toUnLocode;
- private final Date fromDate;
- private final Date toDate;
+ private final LocalDate fromDate;
+ private final LocalDate toDate;
/**
* Constructor.
@@ -47,8 +47,8 @@ public final class TransitEdge implements Serializable
public TransitEdge( final String voyageNumber,
final String fromUnLocode,
final String toUnLocode,
- final Date fromDate,
- final Date toDate
+ final LocalDate fromDate,
+ final LocalDate toDate
)
{
this.voyageNumber = voyageNumber;
@@ -73,12 +73,12 @@ public final class TransitEdge implements Serializable
return toUnLocode;
}
- public Date getFromDate()
+ public LocalDate getFromDate()
{
return fromDate;
}
- public Date getToDate()
+ public LocalDate getToDate()
{
return toDate;
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_a/internal/GraphTraversalServiceImpl.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_a/internal/GraphTraversalServiceImpl.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_a/internal/GraphTraversalServiceImpl.java
index f5540e8..8d6de22 100644
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_a/internal/GraphTraversalServiceImpl.java
+++ b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_a/internal/GraphTraversalServiceImpl.java
@@ -19,9 +19,9 @@
*/
package org.apache.zest.sample.dcicargo.pathfinder_a.internal;
+import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Collections;
-import java.util.Date;
import java.util.List;
import java.util.Random;
import org.apache.zest.sample.dcicargo.pathfinder_a.api.GraphTraversalService;
@@ -33,8 +33,6 @@ public class GraphTraversalServiceImpl
{
private GraphDAO dao;
private Random random;
- private static final long ONE_MIN_MS = 1000 * 60;
- private static final long ONE_DAY_MS = ONE_MIN_MS * 60 * 24;
public GraphTraversalServiceImpl( GraphDAO dao )
{
@@ -44,23 +42,23 @@ public class GraphTraversalServiceImpl
public List<TransitPath> findShortestPath( String originUnLocode, String destinationUnLocode )
{
- Date date = nextDate( new Date() );
+ LocalDate date = nextDate( LocalDate.now());
List<String> allVertices = dao.listLocations();
allVertices.remove( originUnLocode );
allVertices.remove( destinationUnLocode );
final int candidateCount = getRandomNumberOfCandidates();
- final List<TransitPath> candidates = new ArrayList<TransitPath>( candidateCount );
+ final List<TransitPath> candidates = new ArrayList<>( candidateCount );
for( int i = 0; i < candidateCount; i++ )
{
allVertices = getRandomChunkOfLocations( allVertices );
- final List<TransitEdge> transitEdges = new ArrayList<TransitEdge>( allVertices.size() - 1 );
+ final List<TransitEdge> transitEdges = new ArrayList<>( allVertices.size() - 1 );
final String firstLegTo = allVertices.get( 0 );
- Date fromDate = nextDate( date );
- Date toDate = nextDate( fromDate );
+ LocalDate fromDate = nextDate( date );
+ LocalDate toDate = nextDate( fromDate );
date = nextDate( toDate );
transitEdges.add( new TransitEdge(
@@ -90,9 +88,9 @@ public class GraphTraversalServiceImpl
return candidates;
}
- private Date nextDate( Date date )
+ private LocalDate nextDate( LocalDate date )
{
- return new Date( date.getTime() + ONE_DAY_MS + ( random.nextInt( 1000 ) - 500 ) * ONE_MIN_MS );
+ return date.plusDays( 1 );
}
private int getRandomNumberOfCandidates()
[22/25] zest-java git commit: ZEST-158 : Removed support for legacy
Map serialization format.
Posted by ni...@apache.org.
ZEST-158 : Removed support for legacy Map serialization format.
Project: http://git-wip-us.apache.org/repos/asf/zest-java/repo
Commit: http://git-wip-us.apache.org/repos/asf/zest-java/commit/65c7df37
Tree: http://git-wip-us.apache.org/repos/asf/zest-java/tree/65c7df37
Diff: http://git-wip-us.apache.org/repos/asf/zest-java/diff/65c7df37
Branch: refs/heads/ValueSerializationCleaning
Commit: 65c7df37108e7d94a432aefc34d9aca020f64baf
Parents: 93b6d03
Author: Niclas Hedhman <ni...@hedhman.org>
Authored: Thu Jun 16 14:02:05 2016 +0800
Committer: Niclas Hedhman <ni...@hedhman.org>
Committed: Thu Jun 16 14:02:05 2016 +0800
----------------------------------------------------------------------
.../zest/api/property/IllegalTypeException.java | 77 ++++++++++
.../java/org/apache/zest/api/type/MapType.java | 17 ---
.../org/apache/zest/api/type/Serialization.java | 62 --------
.../apache/zest/api/value/ValueSerializer.java | 12 --
.../runtime/composite/CompositeMethodModel.java | 31 +++-
.../zest/runtime/property/PropertyModel.java | 28 ++--
.../zest/runtime/types/ValueTypeFactory.java | 20 ++-
.../apache/zest/bootstrap/InvalidTypesTest.java | 141 +++++++++++++++++++
.../spi/value/ValueDeserializerAdapter.java | 44 ++----
.../zest/spi/value/ValueSerializerAdapter.java | 50 ++-----
.../orgjson/OrgJsonValueDeserializer.java | 37 -----
.../jackson/JacksonValueDeserializer.java | 35 -----
.../stax/StaxValueDeserializer.java | 29 ----
.../serialization/JsonRepresentation.java | 2 +-
14 files changed, 288 insertions(+), 297 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/zest-java/blob/65c7df37/core/api/src/main/java/org/apache/zest/api/property/IllegalTypeException.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/property/IllegalTypeException.java b/core/api/src/main/java/org/apache/zest/api/property/IllegalTypeException.java
new file mode 100644
index 0000000..cf811a1
--- /dev/null
+++ b/core/api/src/main/java/org/apache/zest/api/property/IllegalTypeException.java
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ */
+
+package org.apache.zest.api.property;
+
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+
+/**
+ * Some known types are prohibited from use in Apache Zest.
+ *
+ * This exception is thrown when you try to use any of the prohibited types.
+ * The types are;
+ * <ul>
+ * <li>java.util.Date</li>
+ * <li>java.util.Calendar</li>
+ * <li>java.util.DateFormatter</li>
+ * <li>java.util.SimpleDateFormatter</li>
+ * <li>java.sql.Date</li>
+ * <li>java.sql.Time</li>
+ * <li>org.joda.time.*</li>
+ * </ul>
+ *
+ * This exception may be thrown either when a Property type is declared with any
+ * of these, or if a method under Zest control is called containing any of these
+ * types.
+ *
+ * If the system property zest.types.allow.prohibited=true, then the check is disabled
+ * and those types are allowed. Use with extreme care.
+ */
+public class IllegalTypeException extends RuntimeException
+{
+ public IllegalTypeException( String message )
+ {
+ super( message );
+ }
+
+
+ public static boolean checkProhibited( Type type )
+ {
+ if( type instanceof ParameterizedType )
+ {
+ // raw type is the container, e.g. Collection in Collection<String>
+ type = ( (ParameterizedType) type ).getRawType();
+ }
+ if( type instanceof Class )
+ {
+ String typeName = ( (Class) type ).getName();
+ return typeName.equals( "java.util.Date" )
+ || typeName.equals( "java.util.Calendar" )
+ || typeName.equals( "java.text.DateFormat" )
+ || typeName.equals( "java.text.SimpleDateFormat" )
+ || typeName.equals( "java.sql.Date" )
+ || typeName.equals( "java.sql.Time" )
+ || typeName.startsWith( "org.joda.time." );
+ }
+ return false;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/65c7df37/core/api/src/main/java/org/apache/zest/api/type/MapType.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/type/MapType.java b/core/api/src/main/java/org/apache/zest/api/type/MapType.java
index 2fc6893..c76fd60 100644
--- a/core/api/src/main/java/org/apache/zest/api/type/MapType.java
+++ b/core/api/src/main/java/org/apache/zest/api/type/MapType.java
@@ -33,7 +33,6 @@ public final class MapType
private ValueType keyType;
private ValueType valueType;
- private final Serialization.Variant variant;
public static boolean isMap( Type type )
{
@@ -46,22 +45,11 @@ public final class MapType
return new MapType( Map.class, ValueType.of( keyType ), ValueType.of( valueType ) );
}
- public static MapType of( Class<?> keyType, Class<?> valueType, Serialization.Variant variant )
- {
- return new MapType( Map.class, ValueType.of( keyType ), ValueType.of( valueType ), variant );
- }
-
public MapType( Class<?> type, ValueType keyType, ValueType valueType )
{
- this( type, keyType, valueType, Serialization.Variant.entry );
- }
-
- public MapType( Class<?> type, ValueType keyType, ValueType valueType, Serialization.Variant variant )
- {
super( type );
this.keyType = keyType;
this.valueType = valueType;
- this.variant = variant;
if( !isMap( type ) )
{
throw new IllegalArgumentException( type + " is not a Map." );
@@ -78,11 +66,6 @@ public final class MapType
return valueType;
}
- public Serialization.Variant variant()
- {
- return variant;
- }
-
@Override
public String toString()
{
http://git-wip-us.apache.org/repos/asf/zest-java/blob/65c7df37/core/api/src/main/java/org/apache/zest/api/type/Serialization.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/type/Serialization.java b/core/api/src/main/java/org/apache/zest/api/type/Serialization.java
deleted file mode 100644
index 81a0188..0000000
--- a/core/api/src/main/java/org/apache/zest/api/type/Serialization.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-package org.apache.zest.api.type;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Serialization options for Property intstances.
- * <p>
- * The {@code entry} type represents the explicit key=keyValue, value=valueValue. For JSON serialization;
- * </p>
- * <pre>
- * [
- * { "key1" : "value1" },
- * { "key2" : "value2" }
- * ]
- * </pre>
- * <p>
- * For XML serialization;
- * </p>
- * <pre>
- * <object>
- * <
- * </object>
- * </pre>
- * <p>
- * The {@code object} type represents the explicit keyValue=valueValue.
- * </p>
- */
-@Retention( RetentionPolicy.RUNTIME )
-@Target( { ElementType.TYPE, ElementType.METHOD } )
-@Documented
-public @interface Serialization
-{
- Variant value();
-
- enum Variant
- {
- entry, object
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/65c7df37/core/api/src/main/java/org/apache/zest/api/value/ValueSerializer.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/value/ValueSerializer.java b/core/api/src/main/java/org/apache/zest/api/value/ValueSerializer.java
index 6ab536e..249b78f 100644
--- a/core/api/src/main/java/org/apache/zest/api/value/ValueSerializer.java
+++ b/core/api/src/main/java/org/apache/zest/api/value/ValueSerializer.java
@@ -178,7 +178,6 @@ public interface ValueSerializer
* Default to TRUE.
*/
public static final String INCLUDE_TYPE_INFO = "includeTypeInfo";
- public static final String MAP_ENTRIES_AS_OBJECTS = "mapentriesasobjects";
private final Map<String, String> options = new HashMap<>();
/**
@@ -187,7 +186,6 @@ public interface ValueSerializer
public Options()
{
this.options.put( INCLUDE_TYPE_INFO, "true" );
- this.options.put( MAP_ENTRIES_AS_OBJECTS, "true" );
}
/**
@@ -208,16 +206,6 @@ public interface ValueSerializer
return put( INCLUDE_TYPE_INFO, false );
}
- public Options withMapEntriesAsObjects()
- {
- return put( MAP_ENTRIES_AS_OBJECTS, true );
- }
-
- public Options withMapEntriesAsKeyValuePairs()
- {
- return put( MAP_ENTRIES_AS_OBJECTS, false );
- }
-
/**
* Get Boolean option value.
* @param option The option
http://git-wip-us.apache.org/repos/asf/zest-java/blob/65c7df37/core/runtime/src/main/java/org/apache/zest/runtime/composite/CompositeMethodModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/composite/CompositeMethodModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/composite/CompositeMethodModel.java
index 237b023..03d8868 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/composite/CompositeMethodModel.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/composite/CompositeMethodModel.java
@@ -28,17 +28,20 @@ import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.apache.zest.api.common.ConstructionException;
import org.apache.zest.api.composite.MethodDescriptor;
+import org.apache.zest.api.property.IllegalTypeException;
import org.apache.zest.api.structure.ModuleDescriptor;
import org.apache.zest.api.util.NullArgumentException;
import org.apache.zest.functional.HierarchicalVisitor;
import org.apache.zest.functional.VisitableHierarchy;
import org.apache.zest.runtime.injection.Dependencies;
import org.apache.zest.runtime.injection.DependencyModel;
-import org.apache.zest.spi.module.ModuleSpi;
+
+import static org.apache.zest.api.property.IllegalTypeException.checkProhibited;
/**
* JAVADOC
@@ -67,6 +70,7 @@ public final class CompositeMethodModel
MixinsModel mixinsModel
)
{
+ validateMethod( method );
this.method = method;
mixins = mixinsModel;
concerns = concernsModel;
@@ -83,6 +87,20 @@ public final class CompositeMethodModel
// instancePool = new SynchronizedCompositeMethodInstancePool();
}
+ private void validateMethod( Method method )
+ {
+ Class<?>[] parameterTypes = method.getParameterTypes();
+ for( Class type : parameterTypes )
+ {
+ if( checkProhibited( type ) )
+ {
+ throw new IllegalTypeException( "In method " + method.getName() + " of " + mixins + " has a argument type " + type
+ .getName() + ". This is a prohibited type in Apache Zest." );
+ }
+ }
+ }
+
+
// Model
@Override
@@ -100,7 +118,16 @@ public final class CompositeMethodModel
@SuppressWarnings( "unchecked" )
public Stream<DependencyModel> dependencies()
{
- return Stream.of( concerns, sideEffects ).filter( e -> e != null ).flatMap( Dependencies::dependencies );
+ return Stream.of( concerns, sideEffects )
+ .filter( e -> e != null )
+ .flatMap( new Function<Dependencies, Stream<DependencyModel>>()
+ {
+ @Override
+ public Stream<DependencyModel> apply( Dependencies dependencies )
+ {
+ return dependencies.dependencies();
+ }
+ } );
// return flattenIterables( filter( notNull(), iterable( concerns != null ? concerns.dependencies() : null,
// sideEffects != null ? sideEffects.dependencies() : null ) ) );
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/65c7df37/core/runtime/src/main/java/org/apache/zest/runtime/property/PropertyModel.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/property/PropertyModel.java b/core/runtime/src/main/java/org/apache/zest/runtime/property/PropertyModel.java
index 807194f..c140850 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/property/PropertyModel.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/property/PropertyModel.java
@@ -35,12 +35,12 @@ import org.apache.zest.api.constraint.ConstraintViolationException;
import org.apache.zest.api.entity.Queryable;
import org.apache.zest.api.property.DefaultValues;
import org.apache.zest.api.property.GenericPropertyInfo;
+import org.apache.zest.api.property.IllegalTypeException;
import org.apache.zest.api.property.InvalidPropertyTypeException;
import org.apache.zest.api.property.Property;
import org.apache.zest.api.property.PropertyDescriptor;
import org.apache.zest.api.service.NoSuchServiceException;
import org.apache.zest.api.structure.ModuleDescriptor;
-import org.apache.zest.api.type.Serialization;
import org.apache.zest.api.type.ValueCompositeType;
import org.apache.zest.api.type.ValueType;
import org.apache.zest.api.util.Classes;
@@ -54,6 +54,8 @@ import org.apache.zest.runtime.model.Binder;
import org.apache.zest.runtime.model.Resolution;
import org.apache.zest.runtime.types.ValueTypeFactory;
+import static org.apache.zest.api.property.IllegalTypeException.checkProhibited;
+
//import static org.apache.zest.functional.Iterables.empty;
//import static org.apache.zest.functional.Iterables.first;
@@ -65,6 +67,8 @@ import org.apache.zest.runtime.types.ValueTypeFactory;
public class PropertyModel
implements PropertyDescriptor, PropertyInfo, Binder, Visitable<PropertyModel>
{
+ private static boolean disallowProhibited = Boolean.getBoolean("zest.property.types.allow.prohibited");
+
private Type type;
private transient AccessibleObject accessor; // Interface accessor
@@ -106,6 +110,10 @@ public class PropertyModel
this.immutable = immutable;
this.metaInfo = metaInfo;
type = GenericPropertyInfo.propertyTypeOf( accessor );
+ if( PropertyModel.disallowProhibited && checkProhibited(type) )
+ {
+ throw new IllegalTypeException( type + "is not allowed as a Property type" );
+ }
this.accessor = accessor;
qualifiedName = QualifiedName.fromAccessor( accessor );
@@ -226,8 +234,7 @@ public class PropertyModel
ValueTypeFactory factory = ValueTypeFactory.instance();
Class<?> declaringClass = ( (Member) accessor() ).getDeclaringClass();
Class<?> mainType = resolution.model().types().findFirst().orElse( null );
- Serialization.Variant variant = findVariant();
- valueType = factory.newValueType( type(), declaringClass, mainType, resolution.layer(), resolution.module(), variant );
+ valueType = factory.newValueType( type(), declaringClass, mainType, resolution.layer(), resolution.module());
builderInfo = new BuilderPropertyInfo();
if( type instanceof TypeVariable )
{
@@ -235,21 +242,6 @@ public class PropertyModel
}
}
- private Serialization.Variant findVariant()
- {
- Serialization serialization = metaInfo.get( Serialization.class );
- Serialization.Variant variant = null;
- if( serialization != null )
- {
- variant = serialization.value();
- }
- if( variant == null )
- {
- variant = Serialization.Variant.entry;
- }
- return variant;
- }
-
@Override
public <ThrowableType extends Throwable> boolean accept( Visitor<? super PropertyModel, ThrowableType> visitor )
throws ThrowableType
http://git-wip-us.apache.org/repos/asf/zest-java/blob/65c7df37/core/runtime/src/main/java/org/apache/zest/runtime/types/ValueTypeFactory.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/types/ValueTypeFactory.java b/core/runtime/src/main/java/org/apache/zest/runtime/types/ValueTypeFactory.java
index 427ce43..f19d618 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/types/ValueTypeFactory.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/types/ValueTypeFactory.java
@@ -31,7 +31,6 @@ import org.apache.zest.api.common.Visibility;
import org.apache.zest.api.type.CollectionType;
import org.apache.zest.api.type.EnumType;
import org.apache.zest.api.type.MapType;
-import org.apache.zest.api.type.Serialization;
import org.apache.zest.api.type.ValueCompositeType;
import org.apache.zest.api.type.ValueType;
import org.apache.zest.api.util.Classes;
@@ -64,8 +63,7 @@ public class ValueTypeFactory
Class declaringClass,
Class compositeType,
LayerModel layer,
- ModuleModel module,
- Serialization.Variant variant
+ ModuleModel module
)
{
ValueType valueType;
@@ -80,12 +78,12 @@ public class ValueTypeFactory
TypeVariable collectionTypeVariable = (TypeVariable) collectionType;
collectionType = Classes.resolveTypeVariable( collectionTypeVariable, declaringClass, compositeType );
}
- ValueType collectedType = newValueType( collectionType, declaringClass, compositeType, layer, module, variant );
+ ValueType collectedType = newValueType( collectionType, declaringClass, compositeType, layer, module );
valueType = new CollectionType( Classes.RAW_CLASS.apply( type ), collectedType );
}
else
{
- ValueType collectedType = newValueType( Object.class, declaringClass, compositeType, layer, module, variant );
+ ValueType collectedType = newValueType( Object.class, declaringClass, compositeType, layer, module );
valueType = new CollectionType( Classes.RAW_CLASS.apply( type ), collectedType );
}
}
@@ -100,21 +98,21 @@ public class ValueTypeFactory
TypeVariable keyTypeVariable = (TypeVariable) keyType;
keyType = Classes.resolveTypeVariable( keyTypeVariable, declaringClass, compositeType );
}
- ValueType keyedType = newValueType( keyType, declaringClass, compositeType, layer, module, variant );
+ ValueType keyedType = newValueType( keyType, declaringClass, compositeType, layer, module );
Type valType = pt.getActualTypeArguments()[ 1 ];
if( valType instanceof TypeVariable )
{
TypeVariable valueTypeVariable = (TypeVariable) valType;
valType = Classes.resolveTypeVariable( valueTypeVariable, declaringClass, compositeType );
}
- ValueType valuedType = newValueType( valType, declaringClass, compositeType, layer, module, variant );
- valueType = new MapType( Classes.RAW_CLASS.apply( type ), keyedType, valuedType, variant );
+ ValueType valuedType = newValueType( valType, declaringClass, compositeType, layer, module );
+ valueType = new MapType( Classes.RAW_CLASS.apply( type ), keyedType, valuedType );
}
else
{
- ValueType keyType = newValueType( Object.class, declaringClass, compositeType, layer, module, variant );
- ValueType valuesType = newValueType( Object.class, declaringClass, compositeType, layer, module, variant );
- valueType = new MapType( Classes.RAW_CLASS.apply( type ), keyType, valuesType, variant );
+ ValueType keyType = newValueType( Object.class, declaringClass, compositeType, layer, module );
+ ValueType valuesType = newValueType( Object.class, declaringClass, compositeType, layer, module );
+ valueType = new MapType( Classes.RAW_CLASS.apply( type ), keyType, valuesType );
}
}
else if( ValueCompositeType.isValueComposite( type ) )
http://git-wip-us.apache.org/repos/asf/zest-java/blob/65c7df37/core/runtime/src/test/java/org/apache/zest/bootstrap/InvalidTypesTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/bootstrap/InvalidTypesTest.java b/core/runtime/src/test/java/org/apache/zest/bootstrap/InvalidTypesTest.java
new file mode 100644
index 0000000..103e182
--- /dev/null
+++ b/core/runtime/src/test/java/org/apache/zest/bootstrap/InvalidTypesTest.java
@@ -0,0 +1,141 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ */
+
+package org.apache.zest.bootstrap;
+
+import org.apache.zest.api.activation.ActivationException;
+import org.apache.zest.api.common.InvalidApplicationException;
+import org.apache.zest.api.mixin.NoopMixin;
+import org.apache.zest.api.property.IllegalTypeException;
+import org.junit.Test;
+
+public class InvalidTypesTest
+{
+ public void givenMethodWithStringWhenDeclaringExpectOk()
+ throws Throwable
+ {
+ bootWith( Interface0.class );
+ }
+
+ @Test( expected = IllegalTypeException.class )
+ public void givenMethodWithJavaUtilDateWhenDeclaringExpectException()
+ throws Throwable
+ {
+ bootWith( Interface1.class );
+ }
+
+ @Test( expected = IllegalTypeException.class )
+ public void givenMethodWithJavaUtilCalendarWhenDeclaringExpectException()
+ throws Throwable
+ {
+ bootWith( Interface2.class );
+ }
+
+ @Test( expected = IllegalTypeException.class )
+ public void givenMethodWithJavaSqlTimeWhenDeclaringExpectException()
+ throws Throwable
+ {
+ bootWith( Interface3.class );
+ }
+
+ @Test( expected = IllegalTypeException.class )
+ public void givenMethodWithJavaSqlDateWhenDeclaringExpectException()
+ throws Throwable
+ {
+ bootWith( Interface4.class );
+ }
+
+ @Test( expected = IllegalTypeException.class )
+ public void givenMethodWithJavaTextDateFormatWhenDeclaringExpectException()
+ throws Throwable
+ {
+ bootWith( Interface5.class );
+ }
+
+ @Test( expected = IllegalTypeException.class )
+ public void givenMethodWithJavaTextSimpleDateFormatWhenDeclaringExpectException()
+ throws Throwable
+ {
+ bootWith( Interface6.class );
+ }
+
+ private void bootWith( Class<?> type )
+ throws Throwable
+ {
+ try
+ {
+ new SingletonAssembler()
+ {
+
+ @Override
+ public void assemble( ModuleAssembly module )
+ throws AssemblyException
+ {
+ module.values( type ).withMixins( NoopMixin.class );
+ }
+ };
+ }
+ catch( AssemblyException | ActivationException e )
+ {
+ Throwable cause = e.getCause();
+ if( cause instanceof InvalidApplicationException )
+ {
+ throw cause.getCause();
+ }
+
+ }
+ }
+
+ interface Interface0
+ {
+ void doSomething( String abc );
+ }
+
+ interface Interface1
+ {
+ void doSomething( java.util.Date arg1 );
+ }
+
+ interface Interface2
+ {
+ void doSomething( String abc, java.util.Calendar arg1 );
+ }
+
+ interface Interface3
+ {
+ void doSomething( String abc, java.sql.Time arg1 );
+ }
+
+ interface Interface4
+ {
+ void doSomething( String abc, java.sql.Date arg1 );
+ }
+
+ interface Interface5
+ {
+ void doSomething( String abc, java.text.DateFormat arg1 );
+ }
+
+ interface Interface6
+ {
+ void doSomething( String abc, java.text.SimpleDateFormat arg1 );
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/65c7df37/core/spi/src/main/java/org/apache/zest/spi/value/ValueDeserializerAdapter.java
----------------------------------------------------------------------
diff --git a/core/spi/src/main/java/org/apache/zest/spi/value/ValueDeserializerAdapter.java b/core/spi/src/main/java/org/apache/zest/spi/value/ValueDeserializerAdapter.java
index 93a8d7e..e9c8c75 100644
--- a/core/spi/src/main/java/org/apache/zest/spi/value/ValueDeserializerAdapter.java
+++ b/core/spi/src/main/java/org/apache/zest/spi/value/ValueDeserializerAdapter.java
@@ -48,7 +48,6 @@ import org.apache.zest.api.structure.ModuleDescriptor;
import org.apache.zest.api.type.CollectionType;
import org.apache.zest.api.type.EnumType;
import org.apache.zest.api.type.MapType;
-import org.apache.zest.api.type.Serialization;
import org.apache.zest.api.type.ValueCompositeType;
import org.apache.zest.api.type.ValueType;
import org.apache.zest.api.value.ValueBuilder;
@@ -81,10 +80,13 @@ import static org.apache.zest.functional.Iterables.empty;
* </p>
* <ul>
* <li>BigInteger and BigDecimal depends on {@link org.apache.zest.api.value.ValueSerializer.Options};</li>
- * <li>Date as String in ISO-8601, {@literal @millis@} or {@literal /Date(..)} Microsoft format;</li>
- * <li>DateTime (JodaTime) as a ISO-8601 String with optional timezone offset;</li>
- * <li>LocalDateTime (JodaTime) as whatever {@link LocalDateTime#parse} accept as {@literal instant};</li>
- * <li>LocalDate (JodaTime) as whatever {@link LocalDate#parse} accept as {@literal instant};</li>
+ * <li>ZonedDateTime as a ISO-8601 String with optional timezone name;</li>
+ * <li>OffsetDateTime as a ISO-8601 String with optional timezone offset;</li>
+ * <li>LocalDateTime as whatever {@link LocalDateTime#parse} accept as {@literal instant};</li>
+ * <li>LocalDate as whatever {@link LocalDate#parse} accept as {@literal instant};</li>
+ * <li>LocalTime as whatever {@link LocalTime#parse} accept as {@literal instant};</li>
+ * <li>Duration as a ISO-8601 String representing a {@link java.time.Duration}</li>
+ * <li>Period as a ISO-8601 String representing a {@link java.time.Period}</li>
* </ul>
*
* @param <InputType> Implementor pull-parser type
@@ -552,7 +554,7 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType>
module,
inputNode,
namedAssociationName,
- buildDeserializeInputNodeFunction( module, MapType.of( String.class, EntityReference.class, Serialization.Variant.object ) ) );
+ buildDeserializeInputNodeFunction( module, MapType.of( String.class, EntityReference.class ) ) );
stateMap.put( namedAssociationName, value );
}
}
@@ -620,15 +622,7 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType>
else // Explicit Map
if( MapType.class.isAssignableFrom( valueType.getClass() ) )
{
- MapType mapType = (MapType) valueType;
- if( mapType.variant().equals( Serialization.Variant.entry ) )
- {
- return (T) deserializeNodeEntryMap( module, (MapType) valueType, inputNode );
- }
- else
- {
- return (T) deserializeNodeObjectMap( module, (MapType) valueType, inputNode );
- }
+ return (T) deserializeNodeObjectMap( module, (MapType) valueType, inputNode );
}
else // Enum
if( EnumType.class.isAssignableFrom( valueType.getClass() ) || type.isEnum() )
@@ -715,18 +709,6 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType>
return collection;
}
- private <K, V> Map<K, V> deserializeNodeEntryMap( ModuleDescriptor module, MapType mapType, InputNodeType inputNode )
- throws Exception
- {
- Map<K, V> map = new HashMap<>();
- putArrayNodeInMap( module,
- inputNode,
- this.<K>buildDeserializeInputNodeFunction( module, mapType.keyType() ),
- this.<V>buildDeserializeInputNodeFunction( module, mapType.valueType() ),
- map );
- return map;
- }
-
private <V> Map<String, V> deserializeNodeObjectMap( ModuleDescriptor module, MapType mapType, InputNodeType inputNode )
throws Exception
{
@@ -966,14 +948,6 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType>
)
throws Exception;
- protected abstract <K, V> void putArrayNodeInMap( ModuleDescriptor module,
- InputNodeType inputNode,
- Function<InputNodeType, K> keyDeserializer,
- Function<InputNodeType, V> valueDeserializer,
- Map<K, V> map
- )
- throws Exception;
-
protected abstract <V> void putObjectNodeInMap( ModuleDescriptor module,
InputNodeType inputNode,
Function<InputNodeType, V> valueDeserializer,
http://git-wip-us.apache.org/repos/asf/zest-java/blob/65c7df37/core/spi/src/main/java/org/apache/zest/spi/value/ValueSerializerAdapter.java
----------------------------------------------------------------------
diff --git a/core/spi/src/main/java/org/apache/zest/spi/value/ValueSerializerAdapter.java b/core/spi/src/main/java/org/apache/zest/spi/value/ValueSerializerAdapter.java
index e428f4e..8a223e5 100644
--- a/core/spi/src/main/java/org/apache/zest/spi/value/ValueSerializerAdapter.java
+++ b/core/spi/src/main/java/org/apache/zest/spi/value/ValueSerializerAdapter.java
@@ -86,7 +86,7 @@ public abstract class ValueSerializerAdapter<OutputType>
implements ValueSerializer
{
- public interface ComplexSerializer<T, OutputType>
+ interface ComplexSerializer<T, OutputType>
{
void serialize( Options options, T object, OutputType output )
throws Exception;
@@ -349,7 +349,7 @@ public abstract class ValueSerializerAdapter<OutputType>
{
onFieldStart( output, "_type" );
onValueStart( output );
- onValue( output, descriptor.valueType().types().findFirst().get().getName());
+ onValue( output, descriptor.valueType().types().findFirst().get().getName() );
onValueEnd( output );
onFieldEnd( output );
}
@@ -369,7 +369,7 @@ public abstract class ValueSerializerAdapter<OutputType>
throw new ValueSerializationException( "Unable to serialize property " + persistentProperty, e );
}
} );
- descriptor.valueType().associations().forEach(associationDescriptor -> {
+ descriptor.valueType().associations().forEach( associationDescriptor -> {
Association<?> association = state.associationFor( associationDescriptor.accessor() );
try
{
@@ -413,7 +413,7 @@ public abstract class ValueSerializerAdapter<OutputType>
{
throw new ValueSerializationException( "Unable to serialize manyassociation " + associationDescriptor, e );
}
- });
+ } );
descriptor.valueType().namedAssociations().forEach( associationDescriptor -> {
NamedAssociation<?> namedAssociation = state.namedAssociationFor( associationDescriptor.accessor() );
try
@@ -470,42 +470,16 @@ public abstract class ValueSerializerAdapter<OutputType>
@SuppressWarnings( "unchecked" )
Map<Object, Object> map = (Map<Object, Object>) object;
//noinspection ConstantConditions
- if( options.getBoolean( Options.MAP_ENTRIES_AS_OBJECTS ) )
- {
- onObjectStart( output );
- for( Map.Entry<Object, Object> entry : map.entrySet() )
- {
- onFieldStart( output, entry.getKey().toString() );
- onValueStart( output );
- doSerialize( options, entry.getValue(), output, false );
- onValueEnd( output );
- onFieldEnd( output );
- }
- onObjectEnd( output );
- }
- else
+ onObjectStart( output );
+ for( Map.Entry<Object, Object> entry : map.entrySet() )
{
- onArrayStart( output );
- for( Map.Entry<Object, Object> entry : map.entrySet() )
- {
- onObjectStart( output );
-
- onFieldStart( output, "key" );
- onValueStart( output );
- onValue( output, entry.getKey().toString() );
- onValueEnd( output );
- onFieldEnd( output );
-
- onFieldStart( output, "value" );
- onValueStart( output );
- doSerialize( options, entry.getValue(), output, false );
- onValueEnd( output );
- onFieldEnd( output );
-
- onObjectEnd( output );
- }
- onArrayEnd( output );
+ onFieldStart( output, entry.getKey().toString() );
+ onValueStart( output );
+ doSerialize( options, entry.getValue(), output, false );
+ onValueEnd( output );
+ onFieldEnd( output );
}
+ onObjectEnd( output );
}
private void serializeBase64Serializable( Object object, OutputType output )
http://git-wip-us.apache.org/repos/asf/zest-java/blob/65c7df37/core/spi/src/main/java/org/apache/zest/valueserialization/orgjson/OrgJsonValueDeserializer.java
----------------------------------------------------------------------
diff --git a/core/spi/src/main/java/org/apache/zest/valueserialization/orgjson/OrgJsonValueDeserializer.java b/core/spi/src/main/java/org/apache/zest/valueserialization/orgjson/OrgJsonValueDeserializer.java
index 7b5eb4d..bd71cc4 100644
--- a/core/spi/src/main/java/org/apache/zest/valueserialization/orgjson/OrgJsonValueDeserializer.java
+++ b/core/spi/src/main/java/org/apache/zest/valueserialization/orgjson/OrgJsonValueDeserializer.java
@@ -464,43 +464,6 @@ public class OrgJsonValueDeserializer
}
@Override
- protected <K, V> void putArrayNodeInMap( ModuleDescriptor module,
- Object inputNode,
- Function<Object, K> keyDeserializer,
- Function<Object, V> valueDeserializer,
- Map<K, V> map
- )
- throws Exception
- {
- if( JSONObject.NULL.equals( inputNode ) )
- {
- return;
- }
- if( !( inputNode instanceof JSONArray ) )
- {
- throw new ValueSerializationException( "Expected an array but got " + inputNode );
- }
- JSONArray array = (JSONArray) inputNode;
- for( int idx = 0; idx < array.length(); idx++ )
- {
- Object item = array.get( idx );
- if( !( item instanceof JSONObject ) )
- {
- throw new ValueSerializationException( "Expected an object but got " + inputNode );
- }
- JSONObject object = (JSONObject) item;
- Object keyNode = object.get( "key" );
- Object valueNode = object.get( "value" );
- K key = keyDeserializer.apply( keyNode );
- V value = valueDeserializer.apply( valueNode );
- if( key != null )
- {
- map.put( key, value );
- }
- }
- }
-
- @Override
protected <V> void putObjectNodeInMap( ModuleDescriptor module,
Object inputNode,
Function<Object, V> valueDeserializer,
http://git-wip-us.apache.org/repos/asf/zest-java/blob/65c7df37/extensions/valueserialization-jackson/src/main/java/org/apache/zest/valueserialization/jackson/JacksonValueDeserializer.java
----------------------------------------------------------------------
diff --git a/extensions/valueserialization-jackson/src/main/java/org/apache/zest/valueserialization/jackson/JacksonValueDeserializer.java b/extensions/valueserialization-jackson/src/main/java/org/apache/zest/valueserialization/jackson/JacksonValueDeserializer.java
index 5589467..2fb106f 100644
--- a/extensions/valueserialization-jackson/src/main/java/org/apache/zest/valueserialization/jackson/JacksonValueDeserializer.java
+++ b/extensions/valueserialization-jackson/src/main/java/org/apache/zest/valueserialization/jackson/JacksonValueDeserializer.java
@@ -312,41 +312,6 @@ public class JacksonValueDeserializer
}
@Override
- protected <K, V> void putArrayNodeInMap( ModuleDescriptor module,
- JsonNode inputNode,
- Function<JsonNode, K> keyDeserializer,
- Function<JsonNode, V> valueDeserializer,
- Map<K, V> map
- )
- throws Exception
- {
- if( isNullOrMissing( inputNode ) )
- {
- return;
- }
- if( !inputNode.isArray() )
- {
- throw new ValueSerializationException( "Expected an array but got " + inputNode );
- }
- ArrayNode array = (ArrayNode) inputNode;
- for( JsonNode item : array )
- {
- if( !item.isObject() )
- {
- throw new ValueSerializationException( "Expected an object but got " + inputNode );
- }
- JsonNode keyNode = item.get( "key" );
- JsonNode valueNode = item.get( "value" );
- K key = keyDeserializer.apply( keyNode );
- V value = valueDeserializer.apply( valueNode );
- if( key != null )
- {
- map.put( key, value );
- }
- }
- }
-
- @Override
protected <V> void putObjectNodeInMap( ModuleDescriptor module,
JsonNode inputNode,
Function<JsonNode, V> valueDeserializer,
http://git-wip-us.apache.org/repos/asf/zest-java/blob/65c7df37/extensions/valueserialization-stax/src/main/java/org/apache/zest/valueserialization/stax/StaxValueDeserializer.java
----------------------------------------------------------------------
diff --git a/extensions/valueserialization-stax/src/main/java/org/apache/zest/valueserialization/stax/StaxValueDeserializer.java b/extensions/valueserialization-stax/src/main/java/org/apache/zest/valueserialization/stax/StaxValueDeserializer.java
index 85a159e..d1c17c6 100644
--- a/extensions/valueserialization-stax/src/main/java/org/apache/zest/valueserialization/stax/StaxValueDeserializer.java
+++ b/extensions/valueserialization-stax/src/main/java/org/apache/zest/valueserialization/stax/StaxValueDeserializer.java
@@ -404,35 +404,6 @@ public class StaxValueDeserializer
}
@Override
- protected <K, V> void putArrayNodeInMap( ModuleDescriptor module,
- Node inputNode,
- Function<Node, K> keyDeserializer,
- Function<Node, V> valueDeserializer, Map<K, V> map
- )
- throws Exception
- {
- if( inputNode == null )
- {
- return;
- }
- if( !"array".equals( inputNode.getLocalName() ) )
- {
- throw new ValueSerializationException( "Expected an <array/> but got " + inputNode );
- }
- NodeList entriesNodes = inputNode.getChildNodes();
- for( int idx = 0; idx < entriesNodes.getLength(); idx++ )
- {
- Node entryNode = entriesNodes.item( idx );
- K key = getObjectFieldValue( module, entryNode, "key", keyDeserializer );
- V value = getObjectFieldValue( module, entryNode, "value", valueDeserializer );
- if( key != null )
- {
- map.put( key, value );
- }
- }
- }
-
- @Override
protected <V> void putObjectNodeInMap( ModuleDescriptor module,
Node inputNode,
Function<Node, V> valueDeserializer,
http://git-wip-us.apache.org/repos/asf/zest-java/blob/65c7df37/libraries/restlet/src/main/java/org/apache/zest/library/restlet/serialization/JsonRepresentation.java
----------------------------------------------------------------------
diff --git a/libraries/restlet/src/main/java/org/apache/zest/library/restlet/serialization/JsonRepresentation.java b/libraries/restlet/src/main/java/org/apache/zest/library/restlet/serialization/JsonRepresentation.java
index 1527d90..71eaa12 100644
--- a/libraries/restlet/src/main/java/org/apache/zest/library/restlet/serialization/JsonRepresentation.java
+++ b/libraries/restlet/src/main/java/org/apache/zest/library/restlet/serialization/JsonRepresentation.java
@@ -42,7 +42,7 @@ import org.restlet.representation.Representation;
public class JsonRepresentation<T> extends OutputRepresentation
{
- private static final ValueSerializer.Options OPTIONS_NO_TYPE = new ValueSerializer.Options().withoutTypeInfo().withMapEntriesAsObjects();
+ private static final ValueSerializer.Options OPTIONS_NO_TYPE = new ValueSerializer.Options().withoutTypeInfo();
@Structure
private ZestSPI spi;
[19/25] zest-java git commit: ZEST-156 - removed Scheduler Library,
due to serious bug that is nearly impossible to fix.
Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/8915dfaa/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/TaskRunner.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/TaskRunner.java b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/TaskRunner.java
deleted file mode 100644
index 94e25b5..0000000
--- a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/TaskRunner.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-
-package org.apache.zest.library.scheduler.internal;
-
-import java.lang.reflect.UndeclaredThrowableException;
-import java.util.concurrent.locks.ReentrantLock;
-import org.apache.zest.api.injection.scope.Structure;
-import org.apache.zest.api.injection.scope.Uses;
-import org.apache.zest.api.unitofwork.UnitOfWork;
-import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
-import org.apache.zest.api.usecase.UsecaseBuilder;
-import org.apache.zest.library.scheduler.Schedule;
-import org.apache.zest.library.scheduler.Task;
-
-public class TaskRunner
- implements Runnable
-{
- private static ReentrantLock lock = new ReentrantLock();
-
- @Structure
- private UnitOfWorkFactory uowf;
-
- @Uses
- private ScheduleTime schedule;
-
- @Override
- public void run()
- {
- // TODO: (niclas) I am NOT happy with this implementation, requiring 3 UnitOfWorks to be created. 15-20 milliseconds on my MacBook. If there is a better way to detect overrun, two of those might not be needed.
- UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Task Runner initialize" ) );
- try
- {
- lock.lock();
- Schedule schedule = uow.get( Schedule.class, this.schedule.scheduleIdentity() );
- if( !schedule.running().get() ) // check for overrun.
- {
- try
- {
- schedule.taskStarting();
- schedule.running().set( true );
- uow.complete(); // This completion is needed to detect overrun
-
- uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Task Runner" ) );
- schedule = uow.get( schedule ); // re-attach the entity to the new UnitOfWork
- Task task = schedule.task().get();
- lock.unlock();
- task.run();
- lock.lock();
- uow.complete();
- uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Task Runner conclude" ) );
- schedule = uow.get( schedule ); // re-attach the entity to the new UnitOfWork
- schedule.running().set( false );
- schedule.taskCompletedSuccessfully();
- schedule.executionCounter().set( schedule.executionCounter().get() + 1 );
- }
- catch( RuntimeException ex )
- {
- schedule.running().set( false );
- processException( schedule, ex );
- }
- }
- else
- {
- schedule.overrun().set( schedule.overrun().get() + 1 );
- }
- uow.complete();
- }
- catch( Exception e )
- {
- e.printStackTrace();
- throw new UndeclaredThrowableException( e );
- }
- finally
- {
- uow.discard();
- try
- {
- lock.unlock();
- }
- catch( IllegalMonitorStateException e )
- {
- // ignore, as it may happen on certain exceptions.
- }
- }
- }
-
- private void processException( Schedule schedule, RuntimeException ex )
- {
- Throwable exception = ex;
- while( exception instanceof UndeclaredThrowableException )
- {
- exception = ( (UndeclaredThrowableException) ex ).getUndeclaredThrowable();
- }
- schedule.taskCompletedWithException( exception );
- schedule.exceptionCounter().set( schedule.exceptionCounter().get() + 1 );
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/8915dfaa/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/package.html
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/package.html b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/package.html
deleted file mode 100644
index 8ad4911..0000000
--- a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/package.html
+++ /dev/null
@@ -1,24 +0,0 @@
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one
- ~ or more contributor license agreements. See the NOTICE file
- ~ distributed with this work for additional information
- ~ regarding copyright ownership. The ASF licenses this file
- ~ to you under the Apache License, Version 2.0 (the
- ~ "License"); you may not use this file except in compliance
- ~ with the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- ~
- ~
- -->
-<html>
- <body>
- <h2>Scheduler Internals.</h2>
- </body>
-</html>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/zest-java/blob/8915dfaa/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/package.html
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/package.html b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/package.html
deleted file mode 100644
index 88c9599..0000000
--- a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/package.html
+++ /dev/null
@@ -1,24 +0,0 @@
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one
- ~ or more contributor license agreements. See the NOTICE file
- ~ distributed with this work for additional information
- ~ regarding copyright ownership. The ASF licenses this file
- ~ to you under the Apache License, Version 2.0 (the
- ~ "License"); you may not use this file except in compliance
- ~ with the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- ~
- ~
- -->
-<html>
- <body>
- <h2>Scheduler Library.</h2>
- </body>
-</html>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/zest-java/blob/8915dfaa/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/schedule/package.html
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/schedule/package.html b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/schedule/package.html
deleted file mode 100644
index f65aa12..0000000
--- a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/schedule/package.html
+++ /dev/null
@@ -1,24 +0,0 @@
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one
- ~ or more contributor license agreements. See the NOTICE file
- ~ distributed with this work for additional information
- ~ regarding copyright ownership. The ASF licenses this file
- ~ to you under the Apache License, Version 2.0 (the
- ~ "License"); you may not use this file except in compliance
- ~ with the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- ~
- ~
- -->
-<html>
- <body>
- <h2>Scheduler Schedules.</h2>
- </body>
-</html>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/zest-java/blob/8915dfaa/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/Timeline.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/Timeline.java b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/Timeline.java
deleted file mode 100644
index fac381d..0000000
--- a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/Timeline.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-package org.apache.zest.library.scheduler.timeline;
-
-import java.time.Instant;
-import java.time.ZonedDateTime;
-import org.apache.zest.api.unitofwork.concern.UnitOfWorkPropagation;
-
-/**
- * Timeline allow to browse in past and future Task runs.
- */
-// START SNIPPET: timeline
-public interface Timeline
-{
-// END SNIPPET: timeline
-
- /**
- * @param maxResults Maximum number of TimelineRecord to compute
- *
- * @return Last past records
- */
- @UnitOfWorkPropagation( UnitOfWorkPropagation.Propagation.MANDATORY )
-// START SNIPPET: timeline
- Iterable<TimelineRecord> getLastRecords( int maxResults );
-// END SNIPPET: timeline
-
- /**
- * @param maxResults Maximum number of TimelineRecord to compute
- *
- * @return Next running or future records
- */
- @UnitOfWorkPropagation( UnitOfWorkPropagation.Propagation.MANDATORY )
-// START SNIPPET: timeline
- Iterable<TimelineRecord> getNextRecords( int maxResults );
-// END SNIPPET: timeline
-
- /**
- * @param from Lower limit
- * @param to Upper limit
- *
- * @return Records between the given dates
- */
- @UnitOfWorkPropagation( UnitOfWorkPropagation.Propagation.MANDATORY )
-// START SNIPPET: timeline
- Iterable<TimelineRecord> getRecords( ZonedDateTime from, ZonedDateTime to );
-// END SNIPPET: timeline
-
- /**
- * @param from Lower limit
- * @param to Upper limit
- *
- * @return Records between the given dates
- */
- @UnitOfWorkPropagation( UnitOfWorkPropagation.Propagation.MANDATORY )
-// START SNIPPET: timeline
- Iterable<TimelineRecord> getRecords( Instant from, Instant to );
-}
-// END SNIPPET: timeline
http://git-wip-us.apache.org/repos/asf/zest-java/blob/8915dfaa/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/TimelineForScheduleConcern.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/TimelineForScheduleConcern.java b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/TimelineForScheduleConcern.java
deleted file mode 100644
index 6c50651..0000000
--- a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/TimelineForScheduleConcern.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-package org.apache.zest.library.scheduler.timeline;
-
-import java.io.BufferedOutputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.PrintStream;
-import java.time.Instant;
-import java.util.List;
-import org.apache.zest.api.concern.ConcernOf;
-import org.apache.zest.api.injection.scope.Structure;
-import org.apache.zest.api.injection.scope.This;
-import org.apache.zest.api.structure.Module;
-import org.apache.zest.api.value.ValueBuilder;
-import org.apache.zest.library.scheduler.Schedule;
-
-public abstract class TimelineForScheduleConcern
- extends ConcernOf<Schedule>
- implements Schedule
-{
- @This
- private TimelineScheduleState state;
-
- @Structure
- private Module module;
-
- @Override
- public void taskStarting()
- {
- addRecord( TimelineRecordStep.STARTED, "" );
- next.taskStarting();
- }
-
- @Override
- public void taskCompletedSuccessfully()
- {
- addRecord( TimelineRecordStep.SUCCESS, "" );
- next.taskCompletedSuccessfully();
- }
-
- @Override
- public void taskCompletedWithException( Throwable ex )
- {
- TimelineRecordStep step = TimelineRecordStep.FAILURE;
- String details = "Exception occurred:" + getStackTrace( ex );
- addRecord( step, details );
- next.taskCompletedWithException( ex );
- }
-
- private void addRecord( TimelineRecordStep step, String details )
- {
- ValueBuilder<TimelineRecord> builder = module.newValueBuilder( TimelineRecord.class );
- TimelineRecord prototype = builder.prototype();
- prototype.step().set( step );
- prototype.taskName().set( task().get().name().get() );
- List<String> tags = task().get().tags().get();
- prototype.taskTags().set( tags );
- prototype.timestamp().set( Instant.now() );
- prototype.scheduleIdentity().set( this.identity().get() );
- prototype.details().set( details );
- TimelineRecord record = builder.newInstance();
- List<TimelineRecord> timelineRecords = state.history().get();
- timelineRecords.add( record );
- state.history().set( timelineRecords );
- }
-
- private String getStackTrace( Throwable ex )
- {
- ByteArrayOutputStream baos = new ByteArrayOutputStream( 1000 );
- BufferedOutputStream out = new BufferedOutputStream( baos );
- PrintStream print = new PrintStream( out );
- ex.printStackTrace( print );
- print.flush();
- return baos.toString();
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/8915dfaa/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/TimelineRecord.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/TimelineRecord.java b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/TimelineRecord.java
deleted file mode 100644
index 39108a9..0000000
--- a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/TimelineRecord.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-package org.apache.zest.library.scheduler.timeline;
-
-import java.time.Instant;
-import java.util.List;
-import org.apache.zest.api.common.UseDefaults;
-import org.apache.zest.api.entity.Queryable;
-import org.apache.zest.api.mixin.Mixins;
-import org.apache.zest.api.property.Property;
-import org.apache.zest.api.value.ValueComposite;
-import org.apache.zest.library.scheduler.Scheduler;
-
-/**
- * Record in {@link Scheduler}'s {@link Timeline}.
- *
- * {@link TimelineRecord}s are {@link Comparable} regarding their {@link TimelineRecord#timestamp()}.
- */
-@Mixins( TimelineRecord.Mixin.class )
-public interface TimelineRecord
- extends Comparable<TimelineRecord>, ValueComposite
-{
- /**
- * @return Identity of the associated {@link Scheduler}
- */
- Property<String> scheduleIdentity();
-
- /**
- * @return Timestamp of this record
- */
- Property<Instant> timestamp();
-
- /**
- * @return Name of the associated {@link org.apache.zest.library.scheduler.Task}
- */
- Property<String> taskName();
-
- /**
- * @return Tags of the associated {@link org.apache.zest.library.scheduler.Task}
- */
- @UseDefaults
- Property<List<String>> taskTags();
-
- Property<TimelineRecordStep> step();
-
- /**
- * @return Details text of this record
- */
- @Queryable( false )
- @UseDefaults
- Property<String> details();
-
- abstract class Mixin
- implements TimelineRecord
- {
-
- @Override
- public int compareTo( TimelineRecord o )
- {
- return timestamp().get().compareTo( o.timestamp().get() );
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/8915dfaa/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/TimelineRecordStep.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/TimelineRecordStep.java b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/TimelineRecordStep.java
deleted file mode 100644
index 583a831..0000000
--- a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/TimelineRecordStep.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-package org.apache.zest.library.scheduler.timeline;
-
-public enum TimelineRecordStep
-{
- STARTED,
- SUCCESS,
- FAILURE,
- FUTURE
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/8915dfaa/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/TimelineScheduleMixin.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/TimelineScheduleMixin.java b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/TimelineScheduleMixin.java
deleted file mode 100644
index 9143bcf..0000000
--- a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/TimelineScheduleMixin.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-package org.apache.zest.library.scheduler.timeline;
-
-import java.time.Instant;
-import java.time.ZonedDateTime;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.SortedSet;
-import java.util.TreeSet;
-import org.apache.zest.api.injection.scope.Structure;
-import org.apache.zest.api.injection.scope.This;
-import org.apache.zest.api.structure.Module;
-import org.apache.zest.api.value.ValueBuilder;
-import org.apache.zest.library.scheduler.Schedule;
-
-public class TimelineScheduleMixin
- implements Timeline
-{
- @Structure
- private Module module;
-
- @This
- private TimelineScheduleState state;
-
- @This
- private Schedule me;
-
- @Override
- public Iterable<TimelineRecord> getLastRecords( int maxResults )
- {
- List<TimelineRecord> timelineRecords = state.history().get();
- int size = timelineRecords.size();
- if( size < maxResults )
- {
- return Collections.unmodifiableCollection( timelineRecords );
- }
- SortedSet<TimelineRecord> result = new TreeSet<>();
- for( int i = size - maxResults; i < size; i++ )
- {
- result.add( timelineRecords.get( i ) );
- }
- return result;
- }
-
- @Override
- public Iterable<TimelineRecord> getNextRecords( int maxResults )
- {
- SortedSet<TimelineRecord> result = new TreeSet<>();
- Instant time = Instant.now();
- for( int i = 0; i < maxResults; i++ )
- {
- time = me.nextRun( time );
- result.add( createFutureRecord( time ) );
- }
- return result;
- }
-
- @Override
- public Iterable<TimelineRecord> getRecords( ZonedDateTime from, ZonedDateTime to )
- {
- return getRecords( from.toInstant(), to.toInstant() );
- }
-
- @Override
- public Iterable<TimelineRecord> getRecords( Instant from, Instant to )
- {
- Instant now = Instant.now();
- SortedSet<TimelineRecord> result = new TreeSet<>();
- result.addAll( getPastRecords( from ) );
- result.addAll( getFutureRecords( now, to ) );
- return result;
- }
-
- private Collection<? extends TimelineRecord> getPastRecords( Instant from )
- {
- SortedSet<TimelineRecord> result = new TreeSet<>();
- List<TimelineRecord> timelineRecords = state.history().get();
- for( TimelineRecord record : timelineRecords )
- {
- Instant timestamp = record.timestamp().get();
- if( timestamp.isAfter( from ) )
- {
- result.add( record );
- }
- }
- return result;
- }
-
- private Collection<? extends TimelineRecord> getFutureRecords( Instant now, Instant to )
- {
- if( now.isAfter( to ) )
- {
- return Collections.emptyList();
- }
-
- SortedSet<TimelineRecord> result = new TreeSet<>();
- Instant time = Instant.now();
- while( time.isBefore(to) )
- {
- time = me.nextRun( time );
- if( time.isBefore( to ) )
- {
- result.add( createFutureRecord( time ) );
- }
- }
- return result;
- }
-
- private TimelineRecord createFutureRecord( Instant when )
- {
- ValueBuilder<TimelineRecord> builder = module.newValueBuilder( TimelineRecord.class );
- TimelineRecord prototype = builder.prototype();
- prototype.step().set( TimelineRecordStep.FUTURE );
- prototype.taskName().set( me.task().get().name().get() );
- List<String> tags = me.task().get().tags().get();
- prototype.taskTags().set( tags );
- prototype.timestamp().set( when );
- prototype.scheduleIdentity().set( me.identity().get() );
- prototype.details().set( "" );
- return builder.newInstance();
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/8915dfaa/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/TimelineScheduleState.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/TimelineScheduleState.java b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/TimelineScheduleState.java
deleted file mode 100644
index 981eb68..0000000
--- a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/TimelineScheduleState.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-package org.apache.zest.library.scheduler.timeline;
-
-import java.util.List;
-import org.apache.zest.api.common.UseDefaults;
-import org.apache.zest.api.property.Property;
-
-public interface TimelineScheduleState
-{
- @UseDefaults
- Property<List<TimelineRecord>> history();
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/8915dfaa/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/TimelineSchedulerServiceMixin.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/TimelineSchedulerServiceMixin.java b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/TimelineSchedulerServiceMixin.java
deleted file mode 100644
index 41d5a98..0000000
--- a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/TimelineSchedulerServiceMixin.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-package org.apache.zest.library.scheduler.timeline;
-
-import java.time.Instant;
-import java.time.ZonedDateTime;
-import java.util.SortedSet;
-import java.util.TreeSet;
-import org.apache.zest.api.injection.scope.Structure;
-import org.apache.zest.api.injection.scope.This;
-import org.apache.zest.api.service.ServiceComposite;
-import org.apache.zest.api.structure.Module;
-import org.apache.zest.functional.Iterables;
-import org.apache.zest.library.scheduler.SchedulerService;
-import org.apache.zest.library.scheduler.SchedulesHandler;
-import org.apache.zest.library.scheduler.Schedule;
-import org.apache.zest.library.scheduler.internal.Schedules;
-
-/**
- * WARN TimelineService Mixin use SortedSets to keep records ordered and repeatedly search for the next run.
- * Could be greedy with large intervals
- */
-public abstract class TimelineSchedulerServiceMixin
- implements Timeline, ServiceComposite
-{
- @Structure
- private Module module;
-
- @This
- private SchedulerService scheduler;
-
- @This
- private SchedulesHandler schedulesHandler;
-
- @Override
- public Iterable<TimelineRecord> getLastRecords( int maxResults )
- {
- SortedSet<TimelineRecord> result = new TreeSet<>();
-
- Schedules schedules = schedulesHandler.getActiveSchedules();
- for( Schedule schedule : schedules.schedules() )
- {
- Timeline timeline = (Timeline) schedule;
- Iterable<TimelineRecord> lastRecords = timeline.getLastRecords( maxResults );
- Iterables.addAll( result, lastRecords );
- }
- return Iterables.limit( maxResults, Iterables.reverse( result ) );
- }
-
- @Override
- public Iterable<TimelineRecord> getNextRecords( int maxResults )
- {
- SortedSet<TimelineRecord> result = new TreeSet<>();
- Schedules schedules = schedulesHandler.getActiveSchedules();
- for( Schedule schedule : schedules.schedules() )
- {
- Timeline timeline = (Timeline) schedule;
- Iterable<TimelineRecord> lastRecords = timeline.getNextRecords( maxResults );
- Iterables.addAll( result, lastRecords );
- }
- return Iterables.limit( maxResults, result );
- }
-
- @Override
- public Iterable<TimelineRecord> getRecords( ZonedDateTime from, ZonedDateTime to )
- {
- SortedSet<TimelineRecord> result = new TreeSet<>();
-
- Schedules schedules = schedulesHandler.getActiveSchedules();
- for( Schedule schedule : schedules.schedules() )
- {
- Timeline timeline = (Timeline) schedule;
- Iterable<TimelineRecord> lastRecords = timeline.getRecords( from, to );
- Iterables.addAll( result, lastRecords );
- }
- return result;
- }
-
- @Override
- public Iterable<TimelineRecord> getRecords( Instant from, Instant to )
- {
- SortedSet<TimelineRecord> result = new TreeSet<>();
-
- Schedules schedules = schedulesHandler.getActiveSchedules();
- for( Schedule schedule : schedules.schedules() )
- {
- Timeline timeline = (Timeline) schedule;
- Iterable<TimelineRecord> lastRecords = timeline.getRecords( from, to );
- Iterables.addAll( result, lastRecords );
- }
- return result;
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/8915dfaa/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/package.html
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/package.html b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/package.html
deleted file mode 100644
index 765cabc..0000000
--- a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/package.html
+++ /dev/null
@@ -1,24 +0,0 @@
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one
- ~ or more contributor license agreements. See the NOTICE file
- ~ distributed with this work for additional information
- ~ regarding copyright ownership. The ASF licenses this file
- ~ to you under the Apache License, Version 2.0 (the
- ~ "License"); you may not use this file except in compliance
- ~ with the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- ~
- ~
- -->
-<html>
- <body>
- <h2>Scheduler Timeline.</h2>
- </body>
-</html>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/zest-java/blob/8915dfaa/libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/AbstractSchedulerTest.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/AbstractSchedulerTest.java b/libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/AbstractSchedulerTest.java
deleted file mode 100644
index f1ca8cc..0000000
--- a/libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/AbstractSchedulerTest.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-package org.apache.zest.library.scheduler;
-
-import org.apache.zest.api.entity.EntityBuilder;
-import org.apache.zest.api.entity.IdentityGenerator;
-import org.apache.zest.api.unitofwork.UnitOfWork;
-import org.apache.zest.api.value.ValueSerialization;
-import org.apache.zest.bootstrap.AssemblyException;
-import org.apache.zest.bootstrap.ModuleAssembly;
-import org.apache.zest.bootstrap.ServiceDeclaration;
-import org.apache.zest.entitystore.memory.MemoryEntityStoreService;
-import org.apache.zest.index.rdf.assembly.RdfMemoryStoreAssembler;
-import org.apache.zest.spi.uuid.UuidIdentityGeneratorService;
-import org.apache.zest.test.AbstractZestTest;
-import org.apache.zest.test.EntityTestAssembler;
-import org.apache.zest.valueserialization.orgjson.OrgJsonValueSerializationService;
-
-public abstract class AbstractSchedulerTest
- extends AbstractZestTest
-{
- @Override
- public final void assemble( ModuleAssembly assembly )
- throws AssemblyException
- {
- assembly.entities( FooTask.class );
-
- assembly.services( MemoryEntityStoreService.class );
- assembly.services( UuidIdentityGeneratorService.class).withMixins( CountingIdentityGeneratorService.class );
- assembly.services( OrgJsonValueSerializationService.class ).taggedWith( ValueSerialization.Formats.JSON );
- new RdfMemoryStoreAssembler().assemble( assembly );
-
- onAssembly( assembly );
- }
-
- protected abstract void onAssembly( ModuleAssembly module )
- throws AssemblyException;
-
- protected final FooTask createFooTask( UnitOfWork uow, String name, String input )
- {
- EntityBuilder<FooTask> builder = uow.newEntityBuilder( FooTask.class );
- FooTask task = builder.instance();
- task.name().set( name );
- task.input().set( input );
- return builder.newInstance();
- }
-
- public static class CountingIdentityGeneratorService
- implements IdentityGenerator
- {
- int counter = 0;
-
- @Override
- public String generate( Class<?> compositeType )
- {
- return compositeType.getSimpleName() + ":" + counter++;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/8915dfaa/libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/Constants.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/Constants.java b/libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/Constants.java
deleted file mode 100644
index db61858..0000000
--- a/libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/Constants.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-package org.apache.zest.library.scheduler;
-
-// TODO Rename to TestConstants
-public interface Constants
-{
- String BAR = "bar";
- String BAZAR = "bazar";
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/8915dfaa/libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/CronScheduleTest.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/CronScheduleTest.java b/libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/CronScheduleTest.java
deleted file mode 100644
index a346f83..0000000
--- a/libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/CronScheduleTest.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-
-package org.apache.zest.library.scheduler;
-
-import java.time.Instant;
-import org.apache.zest.api.entity.EntityBuilder;
-import org.apache.zest.api.unitofwork.UnitOfWork;
-import org.apache.zest.bootstrap.AssemblyException;
-import org.apache.zest.bootstrap.ModuleAssembly;
-import org.apache.zest.test.AbstractZestTest;
-import org.apache.zest.test.EntityTestAssembler;
-import org.junit.Test;
-
-import static org.hamcrest.core.IsEqual.equalTo;
-import static org.junit.Assert.assertThat;
-
-public class CronScheduleTest extends AbstractZestTest
-{
- @Override
- public void assemble( ModuleAssembly module )
- throws AssemblyException
- {
- new EntityTestAssembler().assemble( module );
- module.entities( CronSchedule.class );
- module.entities( Task.class ).withMixins( DummyTask.class );
- }
-
- @Test
- public void given15SecondCronWhenRequestingNextExpectEvery15Seconds()
- throws Exception
- {
-
- UnitOfWork work = unitOfWorkFactory.newUnitOfWork();
- EntityBuilder<Task> builder1 = work.newEntityBuilder( Task.class );
- builder1.instance().name().set( "abc" );
- Task task = builder1.newInstance();
- EntityBuilder<CronSchedule> builder = work.newEntityBuilder( CronSchedule.class );
- builder.instance().start().set( Instant.now() );
- builder.instance().task().set( task );
- builder.instance().cronExpression().set( "*/15 * * * * *" );
- CronSchedule schedule = builder.newInstance();
- Instant nextRun = schedule.nextRun( Instant.now());
- for( int i = 0; i < 1000; i++ )
- {
- Instant previousRun = nextRun;
- nextRun = schedule.nextRun( previousRun );
- assertThat( "nextRun( previousRun + 1s ) @" + i, nextRun, equalTo( previousRun.plusSeconds( 15 )) );
- }
- work.discard();
- }
-
- public static abstract class DummyTask implements Task
- {
- @Override
- public void run()
- {
- System.out.println( "Dummy" );
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/8915dfaa/libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/FooTask.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/FooTask.java b/libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/FooTask.java
deleted file mode 100644
index 8718dbd..0000000
--- a/libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/FooTask.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-package org.apache.zest.library.scheduler;
-
-import org.apache.zest.api.common.Optional;
-import org.apache.zest.api.common.UseDefaults;
-import org.apache.zest.api.entity.Identity;
-import org.apache.zest.api.injection.scope.This;
-import org.apache.zest.api.mixin.Mixins;
-import org.apache.zest.api.property.Property;
-import org.apache.zest.api.unitofwork.concern.UnitOfWorkPropagation;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import static org.apache.zest.api.unitofwork.concern.UnitOfWorkPropagation.Propagation.REQUIRES_NEW;
-
-@Mixins( FooTask.Mixin.class )
-public interface FooTask
- extends Task, Identity
-{
- Property<String> input();
-
- @Optional
- Property<String> output();
-
- @UseDefaults
- Property<Integer> runCounter();
-
- abstract class Mixin
- implements Task
- {
- private static final Logger LOGGER = LoggerFactory.getLogger( FooTask.class );
-
- @This
- private FooTask me;
-
- @Override
- public void run()
- {
- LOGGER.info( "FooTask.run({})", me.input().get() );
- synchronized( this )
- {
- me.runCounter().set( me.runCounter().get() + 1 );
- LOGGER.info( "Identity: " + me.identity().get() );
- LOGGER.info( " Counter: " + me.runCounter().get() );
- }
- if( me.input().get().equals( Constants.BAZAR ) )
- {
- if( me.output().get() == null )
- {
- me.output().set( Constants.BAR );
- }
- else
- {
- me.output().set( me.output().get() + Constants.BAR );
- }
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/8915dfaa/libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/SchedulerTest.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/SchedulerTest.java b/libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/SchedulerTest.java
deleted file mode 100644
index 9f3eae6..0000000
--- a/libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/SchedulerTest.java
+++ /dev/null
@@ -1,206 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-package org.apache.zest.library.scheduler;
-
-import java.time.Duration;
-import java.time.ZonedDateTime;
-import java.util.concurrent.Callable;
-import org.apache.zest.api.common.Visibility;
-import org.apache.zest.api.unitofwork.UnitOfWork;
-import org.apache.zest.api.unitofwork.UnitOfWorkCompletionException;
-import org.apache.zest.api.usecase.Usecase;
-import org.apache.zest.api.usecase.UsecaseBuilder;
-import org.apache.zest.bootstrap.AssemblyException;
-import org.apache.zest.bootstrap.ModuleAssembly;
-import org.apache.zest.library.scheduler.bootstrap.SchedulerAssembler;
-import org.apache.zest.library.scheduler.timeline.Timeline;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import static com.jayway.awaitility.Awaitility.await;
-import static java.util.concurrent.TimeUnit.MILLISECONDS;
-import static java.util.concurrent.TimeUnit.SECONDS;
-import static org.apache.zest.functional.Iterables.count;
-import static org.apache.zest.library.scheduler.Constants.BAR;
-import static org.apache.zest.library.scheduler.Constants.BAZAR;
-import static org.hamcrest.core.Is.is;
-import static org.hamcrest.core.IsEqual.equalTo;
-import static org.junit.Assert.assertThat;
-
-public class SchedulerTest
- extends AbstractSchedulerTest
-{
- private static final Logger LOGGER = LoggerFactory.getLogger( SchedulerTest.class );
-
- @Override
- protected void onAssembly( ModuleAssembly testAssembly )
- throws AssemblyException
- {
- @SuppressWarnings( "UnnecessaryLocalVariable" )
- ModuleAssembly moduleAssembly = testAssembly;
-
- @SuppressWarnings( "UnnecessaryLocalVariable" )
- ModuleAssembly configModuleAssembly = testAssembly;
-
- // START SNIPPET: assembly
- new SchedulerAssembler().visibleIn( Visibility.application )
- .withConfig( configModuleAssembly, Visibility.layer )
- .withTimeline()
- .assemble( moduleAssembly );
- // END SNIPPET: assembly
- }
-
- @Test
- public void testTaskWithoutScheduling()
- throws UnitOfWorkCompletionException
- {
- Usecase usecase = UsecaseBuilder.newUsecase( "testTask" );
- String taskId;
- try( UnitOfWork uow = unitOfWorkFactory.newUnitOfWork( usecase ) )
- {
- FooTask task = createFooTask( uow, "TestTask", BAZAR );
- taskId = task.identity().get();
- task.run();
- uow.complete();
- }
- try( UnitOfWork uow = unitOfWorkFactory.newUnitOfWork( usecase ) )
- {
- FooTask task = uow.get( FooTask.class, taskId );
- assertThat( task.runCounter().get(), equalTo( 1 ) );
- assertThat( task.output().get(), equalTo( BAR ) );
- }
- }
-
- @Test
- public void testMinutely()
- throws UnitOfWorkCompletionException
- {
- Usecase usecase = UsecaseBuilder.newUsecase( "TestMinutely" );
- ZonedDateTime start = ZonedDateTime.now();
- String taskIdentity;
- long sleepMillis;
- try( UnitOfWork uow = unitOfWorkFactory.newUnitOfWork( usecase ) )
- {
- Scheduler scheduler = serviceFinder.findService( Scheduler.class ).get();
-
- FooTask task = createFooTask( uow, usecase.name(), BAZAR );
- taskIdentity = task.identity().get();
-
- ZonedDateTime expectedRun = start.withNano( 0 ).withSecond( 0 ).plusMinutes( 1 );
- scheduler.scheduleCron( task, "@minutely" );
-
- uow.complete();
-
- sleepMillis = Duration.between( start, expectedRun ).toMillis();
- LOGGER.info( "Task scheduled on {} to be run at {}", start.toLocalTime(), expectedRun.toLocalTime() );
- }
-
- await( usecase.name() )
- .atMost( sleepMillis + 5000, MILLISECONDS )
- .until( taskOutput( taskIdentity ), equalTo( 1 ) );
-
- //noinspection unused
- try( UnitOfWork uow = unitOfWorkFactory.newUnitOfWork( usecase ) )
- {
- Timeline timeline = serviceFinder.findService( Timeline.class ).get();
- ZonedDateTime now = ZonedDateTime.now();
-
- // Queries returning past records
- assertThat( count( timeline.getLastRecords( 5 ) ),
- is( 2L ) );
- assertThat( count( timeline.getRecords( start.toInstant(), now.toInstant() ) ),
- is( 2L ) );
-
- // Queries returning future records
- assertThat( count( timeline.getNextRecords( 4 ) ),
- is( 4L ) );
- assertThat( count( timeline.getRecords( now.plusNanos( 100000000L ), now.plusMinutes( 5 )) ),
- is( 5L ) );
-
- // Queries returning mixed past and future records
- assertThat( count( timeline.getRecords( start, now.plusMinutes( 5 ) ) ),
- is( 7L ) );
- }
- }
-
- @Test
- public void testOnce()
- throws UnitOfWorkCompletionException, InterruptedException
- {
- System.setProperty( "zest.entity.print.state", Boolean.TRUE.toString() );
- final Usecase usecase = UsecaseBuilder.newUsecase( "TestOnce" );
- final String taskIdentity;
- Scheduler scheduler = serviceFinder.findService( Scheduler.class ).get();
-
- Schedule schedule1;
- Schedule schedule2;
- Schedule schedule3;
- Schedule schedule4;
- try( UnitOfWork uow = unitOfWorkFactory.newUnitOfWork( usecase ) )
- {
- FooTask task = createFooTask( uow, usecase.name(), BAZAR );
- taskIdentity = task.identity().get();
-
- schedule1 = scheduler.scheduleOnce( task, 1 );
- schedule2 = scheduler.scheduleOnce( task, 2 );
- schedule3 = scheduler.scheduleOnce( task, 3 );
- schedule4 = scheduler.scheduleOnce( task, 4 );
-
- uow.complete();
- }
- await( usecase.name() )
- .atMost( 6, SECONDS )
- .until( taskOutput( taskIdentity ), equalTo( 4 ) );
-
- try( UnitOfWork uow = unitOfWorkFactory.newUnitOfWork( usecase ) )
- {
- schedule1 = uow.get( schedule1 );
- schedule2 = uow.get( schedule2 );
- schedule3 = uow.get( schedule3 );
- schedule4 = uow.get( schedule4 );
- assertThat(schedule1.cancelled().get(), equalTo( false ));
- assertThat(schedule2.cancelled().get(), equalTo( false ));
- assertThat(schedule3.cancelled().get(), equalTo( false ));
- assertThat(schedule4.cancelled().get(), equalTo( false ));
- assertThat(schedule1.done().get(), equalTo( true ));
- assertThat(schedule2.done().get(), equalTo( true ));
- assertThat(schedule3.done().get(), equalTo( true ));
- assertThat(schedule4.done().get(), equalTo( true ));
- assertThat(schedule1.running().get(), equalTo( false ));
- assertThat(schedule2.running().get(), equalTo( false ));
- assertThat(schedule3.running().get(), equalTo( false ));
- assertThat(schedule4.running().get(), equalTo( false ));
- }
- }
-
- private Callable<Integer> taskOutput( final String taskIdentity )
- {
- return () -> {
- try( UnitOfWork uow = unitOfWorkFactory.newUnitOfWork() )
- {
- FooTask task = uow.get( FooTask.class, taskIdentity );
- Integer count = task.runCounter().get();
- uow.discard();
- return count;
- }
- };
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/8915dfaa/libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/docsupport/SchedulerDocs.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/docsupport/SchedulerDocs.java b/libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/docsupport/SchedulerDocs.java
deleted file mode 100644
index 047e01e..0000000
--- a/libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/docsupport/SchedulerDocs.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-package org.apache.zest.library.scheduler.docsupport;
-
-import org.apache.zest.api.association.Association;
-import org.apache.zest.api.injection.scope.Service;
-import org.apache.zest.api.injection.scope.This;
-import org.apache.zest.api.property.Property;
-import org.apache.zest.api.unitofwork.concern.UnitOfWorkDiscardOn;
-import org.apache.zest.api.unitofwork.concern.UnitOfWorkPropagation;
-import org.apache.zest.api.unitofwork.concern.UnitOfWorkRetry;
-import org.apache.zest.library.scheduler.Scheduler;
-import org.apache.zest.library.scheduler.Task;
-import org.apache.zest.library.scheduler.Schedule;
-import org.apache.zest.library.scheduler.timeline.Timeline;
-
-public class SchedulerDocs
-{
-
- // START SNIPPET: timeline
- @Service
- Timeline timeline;
-// END SNIPPET: timeline
-
- // START SNIPPET: 2
- @Service
- Scheduler scheduler;
-
- public void method()
- {
- MyTaskEntity myTask = todo();
- Schedule schedule = scheduler.scheduleOnce( myTask, 10 );
- // myTask will be run in 10 seconds from now
- }
-
- // END SNIPPET: 2
- MyTaskEntity todo()
- {
- return null;
- }
-
- // START SNIPPET: 1
- interface MyTaskEntity extends Task
- {
- Property<String> myTaskState();
-
- Association<AnotherEntity> anotherEntity();
- }
-
- class MyTaskMixin implements Runnable
- {
- @This
- MyTaskEntity me;
-
- @Override
- public void run()
- {
- me.myTaskState().set( me.anotherEntity().get().doSomeStuff( me.myTaskState().get() ) );
- }
- }
-
- // END SNIPPET: 1
- interface AnotherEntity
- {
- String doSomeStuff( String p );
- }
-
- public class MyTask implements Runnable
- {
-
- // START SNIPPET: strategy
- @Override
- @UnitOfWorkRetry( retries = 3 )
- @UnitOfWorkDiscardOn( IllegalArgumentException.class )
- @UnitOfWorkPropagation( value = UnitOfWorkPropagation.Propagation.REQUIRES_NEW, usecase = "Load Data" )
- public void run()
- {
- // END SNIPPET: strategy
-
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/zest-java/blob/8915dfaa/libraries/scheduler/src/test/resources/logback-test.xml
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/test/resources/logback-test.xml b/libraries/scheduler/src/test/resources/logback-test.xml
deleted file mode 100644
index 41730a9..0000000
--- a/libraries/scheduler/src/test/resources/logback-test.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one
- ~ or more contributor license agreements. See the NOTICE file
- ~ distributed with this work for additional information
- ~ regarding copyright ownership. The ASF licenses this file
- ~ to you under the Apache License, Version 2.0 (the
- ~ "License"); you may not use this file except in compliance
- ~ with the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- ~
- ~
- -->
-<configuration>
-
- <appender name="stdout" class="ch.qos.logback.core.ConsoleAppender">
- <layout class="ch.qos.logback.classic.PatternLayout">
- <Pattern>@%-10thread %-5level %logger{20} - %msg%n</Pattern>
- </layout>
- </appender>
-
- <root level="info">
- <appender-ref ref="stdout" />
- </root>
-
- <logger name="org.apache.zest.library.scheduler" level="trace"/>
-
-</configuration>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/zest-java/blob/8915dfaa/libraries/scheduler/test-repeatedly.sh
----------------------------------------------------------------------
diff --git a/libraries/scheduler/test-repeatedly.sh b/libraries/scheduler/test-repeatedly.sh
deleted file mode 100755
index bb7516b..0000000
--- a/libraries/scheduler/test-repeatedly.sh
+++ /dev/null
@@ -1,35 +0,0 @@
-#!/bin/sh
-
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# Run clean test once and test repeatedly
-# Stop on first failure
-# cat build/num-repeats to see how many times it ran
-# Use time run-repeatedly.sh to get a time mesure
-#
-# Written because of milliseconds delays due to multithreading
-
-set -e
-
-../../gradlew clean test -Dversion=2.0-SNAPSHOT
-echo "x "`date` > build/num-repeats
-
-while ( true ) ; do
- ../../gradlew test -Dversion=2.0-SNAPSHOT
- echo "x "`date` >> build/num-repeats
-done
-
-exit 0
http://git-wip-us.apache.org/repos/asf/zest-java/blob/8915dfaa/manual/src/docs/userguide/libraries.txt
----------------------------------------------------------------------
diff --git a/manual/src/docs/userguide/libraries.txt b/manual/src/docs/userguide/libraries.txt
index fcbace9..5da7c9e 100644
--- a/manual/src/docs/userguide/libraries.txt
+++ b/manual/src/docs/userguide/libraries.txt
@@ -115,10 +115,6 @@ include::../../../../libraries/restlet/src/docs/restlet.txt[]
:leveloffset: 2
-include::../../../../libraries/scheduler/src/docs/scheduler.txt[]
-
-:leveloffset: 2
-
include::../../../../libraries/servlet/src/docs/servlet.txt[]
:leveloffset: 2
http://git-wip-us.apache.org/repos/asf/zest-java/blob/8915dfaa/settings.gradle
----------------------------------------------------------------------
diff --git a/settings.gradle b/settings.gradle
index c865591..7cabe8b 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -48,7 +48,6 @@ include 'core:functional',
'libraries:rest-common',
'libraries:rest-server',
'libraries:restlet',
- 'libraries:scheduler',
'libraries:scripting',
'libraries:servlet',
'libraries:shiro-core',
[02/25] 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.
Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/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<Date>( 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/49bab608/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<Date>( 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<Date>( 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/49bab608/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/49bab608/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<Date>( 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<ValueMap>( 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/49bab608/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/49bab608/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/49bab608/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> 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/49bab608/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<Delivery> 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/49bab608/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/49bab608/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<Delivery> 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> 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/49bab608/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<Delivery> 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/49bab608/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<Delivery> 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/49bab608/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<Delivery> 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> 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/49bab608/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<Delivery> 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> 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/49bab608/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<Delivery> 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> 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/49bab608/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<Delivery> 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> 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/49bab608/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<ParsedHandlingEventData> 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/49bab608/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<Date> registrationTime();
+ Property<LocalDate> registrationDate();
- Property<Date> completionTime();
+ Property<LocalDate> completionDate();
Property<String> 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/49bab608/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/49bab608/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/49bab608/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/49bab608/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<Itinerary> 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/49bab608/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/49bab608/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<HandlingEvent> 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/49bab608/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/49bab608/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<Location> destination();
- Property<Date> earliestDeparture();
+ Property<LocalDate> earliestDeparture();
- Property<Date> arrivalDeadline();
+ Property<LocalDate> 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/49bab608/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<Date> timestamp();
+ Property<Instant> timestamp();
/* (types:)
* RECEIVE
@@ -128,7 +129,7 @@ public interface Delivery
Property<Boolean> isMisdirected();
@Optional
- Property<Date> eta();
+ Property<LocalDate> 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/49bab608/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> location();
@Optional
- Property<Date> time();
+ Property<LocalDate> date();
@Optional
Association<Voyage> voyage();
[04/25] 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.
Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/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/49bab608/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> 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> schedule = module.newValueBuilder( Schedule.class );
- List<CarrierMovement> cm = new ArrayList<CarrierMovement>();
+ List<CarrierMovement> cm = new ArrayList<>();
cm.addAll( Arrays.asList( carrierMovements ) );
schedule.prototype().carrierMovements().set( cm );
return schedule.newInstance();
}
- protected Leg leg( Voyage voyage, Location load, Location unload, Date loadTime, Date unloadTime )
+ protected Leg leg( Voyage voyage, Location load, Location unload, LocalDate loadDate, LocalDate unloadDate )
{
ValueBuilder<Leg> leg = module.newValueBuilder( Leg.class );
leg.prototype().voyage().set( voyage );
leg.prototype().loadLocation().set( load );
leg.prototype().unloadLocation().set( unload );
- leg.prototype().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<RouteSpecification> 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/49bab608/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<ServiceReference<BaseDataService>>
+ extends ActivatorAdapter<ServiceReference<BaseDataService>>
{
@Override
public void afterActivation( ServiceReference<BaseDataService> 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/49bab608/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/49bab608/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<HandlingEventEntity> 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/49bab608/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<Date> completionTime();
+ Property<LocalDate> completionDate();
Property<TrackingId> trackingId();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/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/49bab608/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<Date>( 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<Date>( 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/49bab608/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<List<CargoDTO>> cargoList = new CommonQueries().cargoList();
// Save current trackingIds in session (for prev/next buttons on details page)
- ArrayList<String> ids = new ArrayList<String>();
+ ArrayList<String> 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<Date>( 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<String>( 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/49bab608/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<Date>( 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<Date>( 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/49bab608/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<Void>
{
// 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/49bab608/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<Date>( 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/49bab608/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/49bab608/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<Void>
{
private String trackingId;
- private String selectedTrackingId; // Set by Wicket property resolver
+
+ @SuppressWarnings( "unused" ) // Set by Wicket property resolver
+ private String selectedTrackingId;
private TextField<String> trackingIdInput;
private SelectorInForm selectedTrackingIdSelector;
@@ -73,7 +74,7 @@ public class TrackCargoPage extends BasePage
private TrackingForm()
{
// Manual input
- trackingIdInput = new TextField<String>( "trackingId", new PropertyModel<String>( this, "trackingId" ) );
+ trackingIdInput = new TextField<>( "trackingId", new PropertyModel<String>( 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<CargoDTO> cargoModel, Boolean visible )
+ StatusFragment( IModel<CargoDTO> 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<ValueMap>( 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/49bab608/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<RouteSpecification> routeSpec = vbf.newValueBuilder( RouteSpecification.class );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/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<ExpectedHandlingEvent> 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/49bab608/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<RegisterHandlingEventAttemptDTO> 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/49bab608/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/49bab608/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/49bab608/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<Date> registrationTime();
+ Property<LocalDate> registrationDate();
@Optional
- Property<Date> completionTime();
+ Property<LocalDate> completionDate();
@Optional
Property<String> trackingIdString();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/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/49bab608/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<Location> destination();
- Property<Date> arrivalDeadline();
+ Property<LocalDate> arrivalDeadline();
// Can we accept to have this "intelligent" logic here?
// DCI Data is supposed to be dumb, but it's really convenient to have this logic here,
@@ -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/49bab608/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<Date> timestamp();
+ Property<Instant> timestamp();
/*
* NOT_ROUTED
@@ -122,7 +123,7 @@ public interface Delivery
Association<Voyage> currentVoyage();
@Optional
- Property<Date> eta();
+ Property<LocalDate> eta();
@UseDefaults
Property<Boolean> isUnloadedAtDestination();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/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<Date> time();
+ Property<LocalDate> date();
@Optional
Association<Voyage> voyage();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/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<Date> registrationTime();
+ Property<LocalDate> registrationDate();
@Immutable
- Property<Date> completionTime();
+ Property<LocalDate> completionDate();
@Immutable
Property<TrackingId> trackingId();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/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<HandlingEvent> 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/49bab608/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
[16/25] zest-java git commit: ZEST-151 : Ooops,
there were dependencies. Took the time to refactor some of the DCI
Cargo demo code in the process. Tests passes,
but somehow I doubt that it still works in actual runtime. Need to spend time
on that later.
Posted by ni...@apache.org.
ZEST-151 : Ooops, there were dependencies. Took the time to refactor some of the DCI Cargo demo code in the process. Tests passes, but somehow I doubt that it still works in actual runtime. Need to spend time on that later.
Project: http://git-wip-us.apache.org/repos/asf/zest-java/repo
Commit: http://git-wip-us.apache.org/repos/asf/zest-java/commit/4275718c
Tree: http://git-wip-us.apache.org/repos/asf/zest-java/tree/4275718c
Diff: http://git-wip-us.apache.org/repos/asf/zest-java/diff/4275718c
Branch: refs/heads/ValueSerializationCleaning
Commit: 4275718c800d832c7f15e0aa2c39450ad7b9d060
Parents: 5229303
Author: Niclas Hedhman <ni...@hedhman.org>
Authored: Sun Jun 12 20:45:31 2016 +0800
Committer: Niclas Hedhman <ni...@hedhman.org>
Committed: Sun Jun 12 22:51:06 2016 +0800
----------------------------------------------------------------------
.../bonecp/BoneCPDataSourceServiceImporter.java | 4 +-
.../sql/dbcp/DBCPDataSourceServiceImporter.java | 4 +-
libraries/sql/build.gradle | 1 -
...bstractPooledDataSourceServiceAssembler.java | 2 -
.../AbstractDataSourceServiceImporterMixin.java | 27 +-
samples/dci-cargo/dcisample_a/build.gradle | 1 -
.../sample_a/bootstrap/assembly/Assembler.java | 54 ++-
.../bootstrap/sampledata/BaseDataService.java | 8 +-
.../bootstrap/sampledata/SampleDataService.java | 10 +-
.../communication/query/BookingQueries.java | 1 -
.../communication/query/CommonQueries.java | 17 +-
.../communication/query/HandlingQueries.java | 14 +-
.../communication/query/TrackingQueries.java | 23 +-
.../communication/query/dto/CargoDTO.java | 53 ---
.../query/dto/HandlingEventDTO.java | 51 ---
.../communication/query/dto/LocationDTO.java | 33 --
.../communication/query/dto/VoyageDTO.java | 33 --
.../web/booking/CargoDetailsPage.java | 8 +-
.../web/booking/CargoListPage.java | 12 +-
.../web/booking/ChangeDestinationPage.java | 4 +-
.../web/handling/RegisterHandlingEventPage.java | 5 +-
.../web/tracking/HandlingHistoryPanel.java | 16 +-
.../web/tracking/NextHandlingEventPanel.java | 8 +-
.../web/tracking/TrackCargoPage.java | 8 +-
.../sample_a/context/rolemap/CargoRoleMap.java | 7 +-
.../sample_a/context/rolemap/CargosRoleMap.java | 7 +-
.../context/rolemap/HandlingEventRoleMap.java | 10 +-
.../context/rolemap/HandlingEventsRoleMap.java | 8 +-
.../context/shipping/booking/BookNewCargo.java | 9 +-
.../handling/RegisterHandlingEvent.java | 6 +-
.../sample_a/data/entity/CargoEntity.java | 33 --
.../sample_a/data/entity/CargosEntity.java | 32 --
.../data/entity/HandlingEventEntity.java | 33 --
.../data/entity/HandlingEventsEntity.java | 34 --
.../sample_a/data/entity/LocationEntity.java | 36 --
.../sample_a/data/entity/VoyageEntity.java | 36 --
.../sample_a/data/shipping/cargo/Cargo.java | 3 +-
.../sample_a/data/shipping/cargo/Cargos.java | 2 +
.../data/shipping/cargo/TrackingId.java | 3 +-
.../data/shipping/delivery/Delivery.java | 1 -
.../delivery/ExpectedHandlingEvent.java | 1 -
.../data/shipping/handling/HandlingEvent.java | 3 +-
.../data/shipping/handling/HandlingEvents.java | 2 +
.../sample_a/data/shipping/itinerary/Leg.java | 1 -
.../data/shipping/location/UnLocode.java | 1 -
.../data/shipping/voyage/CarrierMovement.java | 1 -
.../sample_a/data/shipping/voyage/Schedule.java | 1 -
.../data/shipping/voyage/VoyageNumber.java | 1 -
.../infrastructure/WicketZestApplication.java | 6 +-
.../conversion/EntityToDTOService.java | 327 ------------------
.../infrastructure/model/EntityModel.java | 26 +-
.../infrastructure/model/QueryModel.java | 18 +-
.../infrastructure/model/ReadOnlyModel.java | 6 +-
.../sample_a/bootstrap/test/TestAssembler.java | 17 +-
.../shipping/booking/BookNewCargoTest.java | 17 +-
.../booking/BuildDeliverySnapshotTest.java | 31 +-
.../shipping/handling/InspectCargoTest.java | 11 +-
.../handling/RegisterHandlingEventTest.java | 3 +-
samples/dci-cargo/dcisample_b/build.gradle | 1 -
.../sample_b/bootstrap/assembly/Assembler.java | 32 +-
.../communication/query/CommonQueries.java | 17 +-
.../communication/query/HandlingQueries.java | 14 +-
.../communication/query/TrackingQueries.java | 19 +-
.../communication/query/dto/CargoDTO.java | 56 ----
.../query/dto/HandlingEventDTO.java | 52 ---
.../communication/query/dto/LocationDTO.java | 33 --
.../communication/query/dto/VoyageDTO.java | 33 --
.../web/booking/CargoDetailsPage.java | 8 +-
.../web/booking/CargoListPage.java | 12 +-
.../web/booking/ChangeDestinationPage.java | 4 +-
.../web/tracking/HandlingHistoryPanel.java | 14 +-
.../web/tracking/NextHandlingEventPanel.java | 6 +-
.../web/tracking/TrackCargoPage.java | 8 +-
.../DeriveUpdatedRouteSpecification.java | 10 +-
.../inspection/event/InspectCargoInCustoms.java | 12 +-
.../inspection/event/InspectClaimedCargo.java | 12 +-
.../inspection/event/InspectUnhandledCargo.java | 13 +-
.../parsing/dto/ParsedHandlingEventData.java | 2 +-
.../registration/RegisterHandlingEvent.java | 21 +-
.../sample_b/context/rolemap/CargoRoleMap.java | 27 +-
.../sample_b/data/entity/CargoEntity.java | 33 --
.../data/entity/HandlingEventEntity.java | 33 --
.../sample_b/data/entity/LocationEntity.java | 36 --
.../sample_b/data/entity/VoyageEntity.java | 36 --
.../sample_b/data/structure/cargo/Cargo.java | 3 +-
.../data/structure/handling/HandlingEvent.java | 7 +-
.../infrastructure/WicketZestApplication.java | 6 +-
.../sample_b/infrastructure/conversion/DTO.java | 3 +-
.../conversion/EntityToDTOService.java | 335 -------------------
.../infrastructure/model/EntityModel.java | 19 +-
.../infrastructure/model/QueryModel.java | 13 +-
.../infrastructure/model/ReadOnlyModel.java | 6 +-
.../sample_b/bootstrap/test/TestAssembler.java | 12 +-
.../context/test/booking/BookNewCargoTest.java | 12 +-
.../registration/RegisterHandlingEventTest.java | 3 +-
95 files changed, 338 insertions(+), 1755 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/libraries/sql-bonecp/src/main/java/org/apache/zest/library/sql/bonecp/BoneCPDataSourceServiceImporter.java
----------------------------------------------------------------------
diff --git a/libraries/sql-bonecp/src/main/java/org/apache/zest/library/sql/bonecp/BoneCPDataSourceServiceImporter.java b/libraries/sql-bonecp/src/main/java/org/apache/zest/library/sql/bonecp/BoneCPDataSourceServiceImporter.java
index c9e9a36..e1d6e65 100644
--- a/libraries/sql-bonecp/src/main/java/org/apache/zest/library/sql/bonecp/BoneCPDataSourceServiceImporter.java
+++ b/libraries/sql-bonecp/src/main/java/org/apache/zest/library/sql/bonecp/BoneCPDataSourceServiceImporter.java
@@ -24,7 +24,7 @@ import java.util.Properties;
import org.apache.zest.api.activation.Activators;
import org.apache.zest.api.mixin.Mixins;
import org.apache.zest.library.sql.datasource.AbstractDataSourceServiceImporterMixin;
-import org.apache.zest.library.sql.datasource.DataSourceConfigurationValue;
+import org.apache.zest.library.sql.datasource.DataSourceConfiguration;
import org.apache.zest.library.sql.datasource.DataSourceServiceImporterActivation;
/**
@@ -43,7 +43,7 @@ public class BoneCPDataSourceServiceImporter
{
@Override
- protected BoneCPDataSource setupDataSourcePool( DataSourceConfigurationValue config )
+ protected BoneCPDataSource setupDataSourcePool( DataSourceConfiguration config )
throws Exception
{
BoneCPDataSource pool = new BoneCPDataSource();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/libraries/sql-dbcp/src/main/java/org/apache/zest/library/sql/dbcp/DBCPDataSourceServiceImporter.java
----------------------------------------------------------------------
diff --git a/libraries/sql-dbcp/src/main/java/org/apache/zest/library/sql/dbcp/DBCPDataSourceServiceImporter.java b/libraries/sql-dbcp/src/main/java/org/apache/zest/library/sql/dbcp/DBCPDataSourceServiceImporter.java
index c54709c..92af487 100644
--- a/libraries/sql-dbcp/src/main/java/org/apache/zest/library/sql/dbcp/DBCPDataSourceServiceImporter.java
+++ b/libraries/sql-dbcp/src/main/java/org/apache/zest/library/sql/dbcp/DBCPDataSourceServiceImporter.java
@@ -26,7 +26,7 @@ import org.apache.zest.api.mixin.Mixins;
import org.apache.zest.api.service.ServiceComposite;
import org.apache.zest.api.service.ServiceImporter;
import org.apache.zest.library.sql.datasource.AbstractDataSourceServiceImporterMixin;
-import org.apache.zest.library.sql.datasource.DataSourceConfigurationValue;
+import org.apache.zest.library.sql.datasource.DataSourceConfiguration;
import org.apache.zest.library.sql.datasource.DataSourceServiceImporterActivation;
@Mixins( DBCPDataSourceServiceImporter.Mixin.class )
@@ -40,7 +40,7 @@ public interface DBCPDataSourceServiceImporter
{
@Override
- protected BasicDataSource setupDataSourcePool( DataSourceConfigurationValue config )
+ protected BasicDataSource setupDataSourcePool( DataSourceConfiguration config )
throws Exception
{
BasicDataSource pool = new BasicDataSource();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/libraries/sql/build.gradle
----------------------------------------------------------------------
diff --git a/libraries/sql/build.gradle b/libraries/sql/build.gradle
index 6e84d69..c168628 100644
--- a/libraries/sql/build.gradle
+++ b/libraries/sql/build.gradle
@@ -25,7 +25,6 @@ jar { manifest { name = "Apache Zest\u2122 Library - SQL" }}
dependencies {
compile(project(":org.apache.zest.core:org.apache.zest.core.bootstrap"))
compile(project(":org.apache.zest.libraries:org.apache.zest.library.circuitbreaker"))
- compile(project(":org.apache.zest.libraries:org.apache.zest.library.conversion"))
compile(project(":org.apache.zest.libraries:org.apache.zest.library.jmx"))
compile libraries.slf4j_api
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/libraries/sql/src/main/java/org/apache/zest/library/sql/assembly/AbstractPooledDataSourceServiceAssembler.java
----------------------------------------------------------------------
diff --git a/libraries/sql/src/main/java/org/apache/zest/library/sql/assembly/AbstractPooledDataSourceServiceAssembler.java b/libraries/sql/src/main/java/org/apache/zest/library/sql/assembly/AbstractPooledDataSourceServiceAssembler.java
index 0f67d14..a01ed9e 100644
--- a/libraries/sql/src/main/java/org/apache/zest/library/sql/assembly/AbstractPooledDataSourceServiceAssembler.java
+++ b/libraries/sql/src/main/java/org/apache/zest/library/sql/assembly/AbstractPooledDataSourceServiceAssembler.java
@@ -23,7 +23,6 @@ import org.apache.zest.api.common.Visibility;
import org.apache.zest.bootstrap.Assemblers;
import org.apache.zest.bootstrap.AssemblyException;
import org.apache.zest.bootstrap.ModuleAssembly;
-import org.apache.zest.library.conversion.values.EntityToValueService;
import org.apache.zest.library.sql.datasource.DataSourceConfiguration;
import org.apache.zest.library.sql.datasource.DataSourceConfigurationValue;
@@ -37,7 +36,6 @@ public abstract class AbstractPooledDataSourceServiceAssembler<AssemblerType>
throws AssemblyException
{
module.values( DataSourceConfigurationValue.class ).visibleIn( Visibility.module );
- module.services( EntityToValueService.class ).visibleIn( Visibility.module );
if( hasConfig() )
{
configModule().entities( DataSourceConfiguration.class ).visibleIn( configVisibility() );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/libraries/sql/src/main/java/org/apache/zest/library/sql/datasource/AbstractDataSourceServiceImporterMixin.java
----------------------------------------------------------------------
diff --git a/libraries/sql/src/main/java/org/apache/zest/library/sql/datasource/AbstractDataSourceServiceImporterMixin.java b/libraries/sql/src/main/java/org/apache/zest/library/sql/datasource/AbstractDataSourceServiceImporterMixin.java
index 1e02699..cb18e3c 100644
--- a/libraries/sql/src/main/java/org/apache/zest/library/sql/datasource/AbstractDataSourceServiceImporterMixin.java
+++ b/libraries/sql/src/main/java/org/apache/zest/library/sql/datasource/AbstractDataSourceServiceImporterMixin.java
@@ -38,7 +38,6 @@ import org.apache.zest.api.unitofwork.UnitOfWorkCompletionException;
import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
import org.apache.zest.api.usecase.UsecaseBuilder;
import org.apache.zest.library.circuitbreaker.CircuitBreaker;
-import org.apache.zest.library.conversion.values.EntityToValue;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -48,7 +47,7 @@ public abstract class AbstractDataSourceServiceImporterMixin<PooledDataSourceTyp
protected static final Logger LOGGER = LoggerFactory.getLogger( AbstractDataSourceServiceImporterMixin.class );
- private final Map<String, DataSourceConfigurationValue> configs = new HashMap<>();
+ private final Map<String, DataSourceConfiguration> configs = new HashMap<>();
private final Map<String, PooledDataSourceType> pools = new HashMap<>();
@@ -57,9 +56,6 @@ public abstract class AbstractDataSourceServiceImporterMixin<PooledDataSourceTyp
@Structure
protected UnitOfWorkFactory uowf;
- @Service
- private EntityToValue entityToValue;
-
@Override
public final void passivateDataSourceService()
throws Exception
@@ -81,7 +77,7 @@ public abstract class AbstractDataSourceServiceImporterMixin<PooledDataSourceTyp
try {
- DataSourceConfigurationValue config = getConfiguration( importedServiceDescriptor.identity() );
+ DataSourceConfiguration config = getConfiguration( importedServiceDescriptor.identity() );
if ( !config.enabled().get() ) {
// Not started
throw new ServiceImporterException( "DataSource not enabled" );
@@ -126,16 +122,16 @@ public abstract class AbstractDataSourceServiceImporterMixin<PooledDataSourceTyp
}
}
- private DataSourceConfigurationValue getConfiguration( String identity )
+ private DataSourceConfiguration getConfiguration( String identity )
throws InstantiationException
{
- DataSourceConfigurationValue config = configs.get( identity );
+ DataSourceConfiguration config = configs.get( identity );
if ( config == null ) {
UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Create DataSource pool configuration" ) );
try {
DataSourceConfiguration configEntity = uow.get( DataSourceConfiguration.class, identity );
- config = entityToValue.convert( DataSourceConfigurationValue.class, configEntity );
+ config = uow.toValue( DataSourceConfiguration.class, configEntity );
} catch ( NoSuchEntityException e ) {
EntityBuilder<DataSourceConfiguration> configBuilder = uow.newEntityBuilder( DataSourceConfiguration.class, identity );
@@ -154,7 +150,7 @@ public abstract class AbstractDataSourceServiceImporterMixin<PooledDataSourceTyp
}
DataSourceConfiguration configEntity = configBuilder.newInstance();
- config = entityToValue.convert( DataSourceConfigurationValue.class, configEntity );
+ config = uow.toValue( DataSourceConfiguration.class, configEntity );
// save
try {
@@ -176,19 +172,16 @@ public abstract class AbstractDataSourceServiceImporterMixin<PooledDataSourceTyp
@Override
public final boolean isAvailable( DataSource instance )
{
- if ( pools.containsValue( instance ) ) {
+ if ( pools.containsValue( instance ) )
+ {
CircuitBreaker circuitBreaker = circuitBreakers.get( instance );
- if ( circuitBreaker != null ) {
- return circuitBreaker.isOn();
- } else {
- return true;
- }
+ return circuitBreaker == null || circuitBreaker.isOn();
} else {
return false;
}
}
- protected abstract PooledDataSourceType setupDataSourcePool( DataSourceConfigurationValue configuration )
+ protected abstract PooledDataSourceType setupDataSourcePool( DataSourceConfiguration configuration )
throws Exception;
protected abstract void passivateDataSourcePool( PooledDataSourceType dataSourcePool )
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/samples/dci-cargo/dcisample_a/build.gradle
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/build.gradle b/samples/dci-cargo/dcisample_a/build.gradle
index f2f5424..2af8595 100644
--- a/samples/dci-cargo/dcisample_a/build.gradle
+++ b/samples/dci-cargo/dcisample_a/build.gradle
@@ -26,7 +26,6 @@ dependencies {
compile project( ':org.apache.zest.core:org.apache.zest.core.bootstrap' )
compile project( ':org.apache.zest.libraries:org.apache.zest.library.constraints' )
- compile project( ':org.apache.zest.libraries:org.apache.zest.library.conversion' )
compile project( ':org.apache.zest.extensions:org.apache.zest.extension.valueserialization-orgjson' )
compile project( ':org.apache.zest.extensions:org.apache.zest.extension.indexing-rdf' )
compile project( ':org.apache.zest.tools:org.apache.zest.tool.envisage' )
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/bootstrap/assembly/Assembler.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/bootstrap/assembly/Assembler.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/bootstrap/assembly/Assembler.java
index 267cd63..6572766 100644
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/bootstrap/assembly/Assembler.java
+++ b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/bootstrap/assembly/Assembler.java
@@ -41,10 +41,6 @@ import org.apache.zest.sample.dcicargo.sample_a.bootstrap.DCISampleApplication_a
import org.apache.zest.sample.dcicargo.sample_a.bootstrap.sampledata.BaseDataService;
import org.apache.zest.sample.dcicargo.sample_a.bootstrap.sampledata.SampleDataService;
import org.apache.zest.sample.dcicargo.sample_a.communication.query.BookingQueries;
-import org.apache.zest.sample.dcicargo.sample_a.communication.query.dto.CargoDTO;
-import org.apache.zest.sample.dcicargo.sample_a.communication.query.dto.HandlingEventDTO;
-import org.apache.zest.sample.dcicargo.sample_a.communication.query.dto.LocationDTO;
-import org.apache.zest.sample.dcicargo.sample_a.communication.query.dto.VoyageDTO;
import org.apache.zest.sample.dcicargo.sample_a.context.rolemap.CargoRoleMap;
import org.apache.zest.sample.dcicargo.sample_a.context.rolemap.CargosRoleMap;
import org.apache.zest.sample.dcicargo.sample_a.context.rolemap.HandlingEventRoleMap;
@@ -54,17 +50,18 @@ import org.apache.zest.sample.dcicargo.sample_a.context.rolemap.RouteSpecificati
import org.apache.zest.sample.dcicargo.sample_a.context.support.ApplicationEvents;
import org.apache.zest.sample.dcicargo.sample_a.context.support.RegisterHandlingEventAttemptDTO;
import org.apache.zest.sample.dcicargo.sample_a.context.support.RoutingService;
-import org.apache.zest.sample.dcicargo.sample_a.data.entity.LocationEntity;
-import org.apache.zest.sample.dcicargo.sample_a.data.entity.VoyageEntity;
+import org.apache.zest.sample.dcicargo.sample_a.data.shipping.cargo.Cargo;
import org.apache.zest.sample.dcicargo.sample_a.data.shipping.cargo.TrackingId;
import org.apache.zest.sample.dcicargo.sample_a.data.shipping.delivery.Delivery;
import org.apache.zest.sample.dcicargo.sample_a.data.shipping.delivery.ExpectedHandlingEvent;
+import org.apache.zest.sample.dcicargo.sample_a.data.shipping.handling.HandlingEvent;
import org.apache.zest.sample.dcicargo.sample_a.data.shipping.itinerary.Leg;
+import org.apache.zest.sample.dcicargo.sample_a.data.shipping.location.Location;
import org.apache.zest.sample.dcicargo.sample_a.data.shipping.location.UnLocode;
import org.apache.zest.sample.dcicargo.sample_a.data.shipping.voyage.CarrierMovement;
import org.apache.zest.sample.dcicargo.sample_a.data.shipping.voyage.Schedule;
+import org.apache.zest.sample.dcicargo.sample_a.data.shipping.voyage.Voyage;
import org.apache.zest.sample.dcicargo.sample_a.data.shipping.voyage.VoyageNumber;
-import org.apache.zest.sample.dcicargo.sample_a.infrastructure.conversion.EntityToDTOService;
import org.apache.zest.spi.uuid.UuidIdentityGeneratorService;
import org.apache.zest.valueserialization.orgjson.OrgJsonValueSerializationService;
@@ -173,18 +170,14 @@ public class Assembler
BookingQueries.class )
.visibleIn( application );
- queryModule
- .values(
- CargoDTO.class,
- LocationDTO.class,
- HandlingEventDTO.class,
- VoyageDTO.class );
+ queryModule.services( UuidIdentityGeneratorService.class );
- queryModule
- .addServices(
- EntityToDTOService.class,
- OrgJsonValueSerializationService.class )
- .visibleIn( application );
+ queryModule.values(
+ Cargo.class,
+ Location.class,
+ HandlingEvent.class,
+ Voyage.class
+ );
}
private void assembleContextLayer( LayerAssembly contextLayer )
@@ -192,20 +185,18 @@ public class Assembler
{
// Role-playing entities
ModuleAssembly entityRoleModule = contextLayer.module( "CONTEXT-EntityRole" );
- entityRoleModule
- .entities(
- CargoRoleMap.class,
- CargosRoleMap.class,
- HandlingEventRoleMap.class,
- HandlingEventsRoleMap.class )
+ entityRoleModule.entities( CargoRoleMap.class,
+ CargosRoleMap.class,
+ HandlingEventRoleMap.class,
+ HandlingEventsRoleMap.class )
.visibleIn( application );
// Non-role-playing entities
ModuleAssembly entityNonRoleModule = contextLayer.module( "CONTEXT-EntityNonRole" );
entityNonRoleModule
.entities(
- LocationEntity.class,
- VoyageEntity.class )
+ Location.class,
+ Voyage.class )
.visibleIn( application );
// Role-playing values
@@ -254,15 +245,8 @@ public class Assembler
serializationModule
.services( OrgJsonValueSerializationService.class )
.taggedWith( ValueSerialization.Formats.JSON )
- .setMetaInfo( new Function<Application, Module>()
- {
- @Override
- public Module apply( Application application )
- {
- return application.findModule( "CONTEXT", "CONTEXT-ContextSupport" );
- }
- } )
- .visibleIn( application );
+ .setMetaInfo( (Function<Application, Module>) application1 -> application1.findModule( "CONTEXT", "CONTEXT-ContextSupport" ) )
+ .visibleIn( application );
ModuleAssembly indexingModule = infrastructureLayer.module( "INFRASTRUCTURE-Indexing" );
indexingModule
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/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 c4d6ede..f1d5291 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
@@ -29,8 +29,8 @@ import org.apache.zest.api.service.ServiceReference;
import org.apache.zest.api.structure.Module;
import org.apache.zest.api.unitofwork.UnitOfWork;
import org.apache.zest.api.value.ValueBuilder;
-import org.apache.zest.sample.dcicargo.sample_a.data.entity.CargosEntity;
-import org.apache.zest.sample.dcicargo.sample_a.data.entity.HandlingEventsEntity;
+import org.apache.zest.sample.dcicargo.sample_a.data.shipping.cargo.Cargos;
+import org.apache.zest.sample.dcicargo.sample_a.data.shipping.handling.HandlingEvents;
import org.apache.zest.sample.dcicargo.sample_a.data.shipping.location.Location;
import org.apache.zest.sample.dcicargo.sample_a.data.shipping.location.UnLocode;
import org.apache.zest.sample.dcicargo.sample_a.data.shipping.voyage.Schedule;
@@ -139,8 +139,8 @@ public interface BaseDataService
) );
// Cargo and HandlingEvent factories
- CargosEntity CARGOS = uow.newEntity( CargosEntity.class, CargosEntity.CARGOS_ID );
- uow.newEntity( HandlingEventsEntity.class, HandlingEventsEntity.HANDLING_EVENTS_ID );
+ Cargos CARGOS = uow.newEntity( Cargos.class, Cargos.CARGOS_ID );
+ uow.newEntity( HandlingEvents.class, HandlingEvents.HANDLING_EVENTS_ID );
logger.debug( "BASIC DATA CREATED" );
uow.complete();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/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 da00cea..98fcdd8 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
@@ -20,7 +20,6 @@
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.List;
import java.util.Random;
@@ -41,8 +40,8 @@ import org.apache.zest.api.usecase.Usecase;
import org.apache.zest.api.usecase.UsecaseBuilder;
import org.apache.zest.sample.dcicargo.sample_a.context.shipping.booking.BookNewCargo;
import org.apache.zest.sample.dcicargo.sample_a.context.shipping.handling.RegisterHandlingEvent;
-import org.apache.zest.sample.dcicargo.sample_a.data.entity.CargosEntity;
import org.apache.zest.sample.dcicargo.sample_a.data.shipping.cargo.Cargo;
+import org.apache.zest.sample.dcicargo.sample_a.data.shipping.cargo.Cargos;
import org.apache.zest.sample.dcicargo.sample_a.data.shipping.delivery.ExpectedHandlingEvent;
import org.apache.zest.sample.dcicargo.sample_a.data.shipping.handling.HandlingEventType;
import org.apache.zest.sample.dcicargo.sample_a.data.shipping.itinerary.Itinerary;
@@ -65,8 +64,7 @@ public interface SampleDataService
void insertSampleData()
throws Exception;
- class Activator
- extends ActivatorAdapter<ServiceReference<SampleDataService>>
+ class Activator extends ActivatorAdapter<ServiceReference<SampleDataService>>
{
@Override
@@ -268,14 +266,14 @@ public interface SampleDataService
Usecase usecase = UsecaseBuilder.newUsecase( "### Populate Random Cargos ###" );
UnitOfWork uow = uowf.newUnitOfWork( usecase );
- CargosEntity cargos = uow.get( CargosEntity.class, CargosEntity.CARGOS_ID );
+ Cargos cargos = uow.get( Cargos.class, Cargos.CARGOS_ID );
QueryBuilder<Location> qb = qbf.newQueryBuilder( Location.class );
Query<Location> allLocations = uow.newQuery( qb );
int locationSize = (int) allLocations.count();
// Make array for selection of location with random index
- final List<Location> locationList = new ArrayList<Location>();
+ final List<Location> locationList = new ArrayList<>();
for( Location location : allLocations )
{
locationList.add( location );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/query/BookingQueries.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/query/BookingQueries.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/query/BookingQueries.java
index c4fbf4e..6d3b660 100644
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/query/BookingQueries.java
+++ b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/query/BookingQueries.java
@@ -68,7 +68,6 @@ public interface BookingQueries
{
modelList.add( JSONModel.of( itinerary ) );
}
-
return modelList;
}
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/query/CommonQueries.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/query/CommonQueries.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/query/CommonQueries.java
index 60fa98a..94ed7ce 100644
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/query/CommonQueries.java
+++ b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/query/CommonQueries.java
@@ -24,8 +24,7 @@ import java.util.List;
import org.apache.wicket.model.IModel;
import org.apache.zest.api.query.Query;
import org.apache.zest.api.query.QueryBuilder;
-import org.apache.zest.sample.dcicargo.sample_a.communication.query.dto.CargoDTO;
-import org.apache.zest.sample.dcicargo.sample_a.data.entity.CargoEntity;
+import org.apache.zest.sample.dcicargo.sample_a.data.shipping.cargo.Cargo;
import org.apache.zest.sample.dcicargo.sample_a.data.shipping.location.Location;
import org.apache.zest.sample.dcicargo.sample_a.infrastructure.model.EntityModel;
import org.apache.zest.sample.dcicargo.sample_a.infrastructure.model.Queries;
@@ -43,20 +42,20 @@ import static org.apache.zest.api.query.QueryExpressions.templateFor;
*/
public class CommonQueries extends Queries
{
- public IModel<CargoDTO> cargo( String trackingId )
+ public IModel<Cargo> cargo( String trackingId )
{
- return EntityModel.of( CargoEntity.class, trackingId, CargoDTO.class );
+ return EntityModel.of( Cargo.class, trackingId, Cargo.class );
}
- public IModel<List<CargoDTO>> cargoList()
+ public IModel<List<Cargo>> cargoList()
{
- return new QueryModel<CargoDTO, CargoEntity>( CargoDTO.class )
+ return new QueryModel<Cargo>( Cargo.class )
{
- public Query<CargoEntity> getQuery()
+ public Query<Cargo> getQuery()
{
- QueryBuilder<CargoEntity> qb = qbf.newQueryBuilder( CargoEntity.class );
+ QueryBuilder<Cargo> qb = qbf.newQueryBuilder( Cargo.class );
return uowf.currentUnitOfWork().newQuery( qb )
- .orderBy( orderBy( templateFor( CargoEntity.class ).trackingId().get().id() ) );
+ .orderBy( orderBy( templateFor( Cargo.class ).trackingId().get().id() ) );
}
};
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/query/HandlingQueries.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/query/HandlingQueries.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/query/HandlingQueries.java
index f9486f0..9e61655 100644
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/query/HandlingQueries.java
+++ b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/query/HandlingQueries.java
@@ -23,7 +23,7 @@ import java.util.ArrayList;
import java.util.List;
import org.apache.zest.api.query.Query;
import org.apache.zest.api.query.QueryBuilder;
-import org.apache.zest.sample.dcicargo.sample_a.data.entity.CargoEntity;
+import org.apache.zest.sample.dcicargo.sample_a.data.shipping.cargo.Cargo;
import org.apache.zest.sample.dcicargo.sample_a.data.shipping.handling.HandlingEventType;
import org.apache.zest.sample.dcicargo.sample_a.data.shipping.voyage.Voyage;
import org.apache.zest.sample.dcicargo.sample_a.infrastructure.model.Queries;
@@ -54,11 +54,11 @@ public class HandlingQueries extends Queries
public List<String> cargoIds()
{
- QueryBuilder<CargoEntity> qb = qbf.newQueryBuilder( CargoEntity.class );
- Query<CargoEntity> cargos = uowf.currentUnitOfWork().newQuery( qb )
- .orderBy( orderBy( templateFor( CargoEntity.class ).trackingId().get().id() ) );
- List<String> cargoList = new ArrayList<String>();
- for( CargoEntity cargo : cargos )
+ QueryBuilder<Cargo> qb = qbf.newQueryBuilder( Cargo.class );
+ Query<Cargo> cargos = uowf.currentUnitOfWork().newQuery( qb )
+ .orderBy( orderBy( templateFor( Cargo.class ).trackingId().get().id() ) );
+ List<String> cargoList = new ArrayList<>();
+ for( Cargo cargo : cargos )
{
cargoList.add( cargo.trackingId().get().id().get() );
}
@@ -67,7 +67,7 @@ public class HandlingQueries extends Queries
public List<String> eventTypes()
{
- List<String> eventTypes = new ArrayList<String>();
+ List<String> eventTypes = new ArrayList<>();
for( HandlingEventType eventType : HandlingEventType.values() )
{
eventTypes.add( eventType.name() );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/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 7685f77..f7d2e49 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
@@ -25,9 +25,6 @@ import org.apache.wicket.model.IModel;
import org.apache.zest.api.query.Query;
import org.apache.zest.api.query.QueryBuilder;
import org.apache.zest.api.query.QueryExpressions;
-import org.apache.zest.sample.dcicargo.sample_a.communication.query.dto.HandlingEventDTO;
-import org.apache.zest.sample.dcicargo.sample_a.data.entity.CargoEntity;
-import org.apache.zest.sample.dcicargo.sample_a.data.entity.HandlingEventEntity;
import org.apache.zest.sample.dcicargo.sample_a.data.shipping.cargo.Cargo;
import org.apache.zest.sample.dcicargo.sample_a.data.shipping.handling.HandlingEvent;
import org.apache.zest.sample.dcicargo.sample_a.infrastructure.model.Queries;
@@ -44,15 +41,15 @@ public class TrackingQueries extends Queries
{
public List<String> routedCargos()
{
- Cargo cargoEntity = templateFor( CargoEntity.class );
+ Cargo cargoEntity = templateFor( Cargo.class );
- QueryBuilder<CargoEntity> qb = qbf.newQueryBuilder( CargoEntity.class )
+ QueryBuilder<Cargo> qb = qbf.newQueryBuilder( Cargo.class )
.where( isNotNull( cargoEntity.itinerary() ) );
- Query<CargoEntity> cargos = uowf.currentUnitOfWork().newQuery( qb )
+ Query<Cargo> cargos = uowf.currentUnitOfWork().newQuery( qb )
.orderBy( orderBy( cargoEntity.trackingId().get().id() ) );
List<String> cargoList = new ArrayList<String>();
- for( CargoEntity cargo : cargos )
+ for( Cargo cargo : cargos )
{
cargoList.add( cargo.trackingId().get().id().get() );
}
@@ -60,17 +57,19 @@ public class TrackingQueries extends Queries
return cargoList;
}
- public IModel<List<HandlingEventDTO>> events( final String trackingIdString )
+ public IModel<List<HandlingEvent>> events( final String trackingIdString )
{
- return new QueryModel<HandlingEventDTO, HandlingEventEntity>( HandlingEventDTO.class )
+ return new QueryModel<HandlingEvent>( HandlingEvent.class )
{
- public Query<HandlingEventEntity> getQuery()
+ public Query<HandlingEvent> getQuery()
{
HandlingEvent eventTemplate = templateFor( HandlingEvent.class );
- QueryBuilder<HandlingEventEntity> qb = qbf.newQueryBuilder( HandlingEventEntity.class )
+ QueryBuilder<HandlingEvent> qb = qbf.newQueryBuilder( HandlingEvent.class )
.where( QueryExpressions.eq( eventTemplate.trackingId().get().id(), trackingIdString ) );
- return uowf.currentUnitOfWork().newQuery( qb )
+ return uowf
+ .currentUnitOfWork()
+ .newQuery( qb )
.orderBy( orderBy( eventTemplate.completionDate() ) );
}
};
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/query/dto/CargoDTO.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/query/dto/CargoDTO.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/query/dto/CargoDTO.java
deleted file mode 100644
index 4113088..0000000
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/query/dto/CargoDTO.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-package org.apache.zest.sample.dcicargo.sample_a.communication.query.dto;
-
-import org.apache.zest.api.common.Optional;
-import org.apache.zest.api.property.Property;
-import org.apache.zest.library.conversion.values.Unqualified;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.cargo.Cargo;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.cargo.RouteSpecification;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.cargo.TrackingId;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.delivery.Delivery;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.itinerary.Itinerary;
-import org.apache.zest.sample.dcicargo.sample_a.infrastructure.conversion.DTO;
-
-/**
- * Cargo DTO
- *
- * We need the @Unqualified annotation since the CargoDTO interface has other properties than {@link Cargo}
- * so that properties can not be directly mapped when we convert from entity to immutable value DTO.
- * With the annotation, property access methods are compared by name instead.
- */
-@Unqualified
-public interface CargoDTO extends DTO
-{
- Property<TrackingId> trackingId();
-
- // Associated Location entity in Cargo is converted to an immutable LocationDTO value object
- Property<LocationDTO> origin();
-
- Property<RouteSpecification> routeSpecification();
-
- Property<Delivery> delivery();
-
- @Optional
- Property<Itinerary> itinerary();
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/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
deleted file mode 100644
index 4b4c1ae..0000000
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/query/dto/HandlingEventDTO.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-package org.apache.zest.sample.dcicargo.sample_a.communication.query.dto;
-
-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;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.cargo.TrackingId;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.handling.HandlingEvent;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.handling.HandlingEventType;
-import org.apache.zest.sample.dcicargo.sample_a.infrastructure.conversion.DTO;
-
-/**
- * HandlingEvent DTO
- *
- * We need the @Unqualified annotation since the HandlingEventDTO interface has other properties than
- * {@link HandlingEvent} so that properties can not be directly mapped when we convert from entity to
- * immutable value DTO. With the annotation, property access methods are compared by name instead.
- */
-@Unqualified
-public interface HandlingEventDTO extends DTO
-{
- Property<LocalDate> completionDate();
-
- Property<TrackingId> trackingId();
-
- Property<HandlingEventType> handlingEventType();
-
- Property<LocationDTO> location();
-
- @Optional
- Property<VoyageDTO> voyage();
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/query/dto/LocationDTO.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/query/dto/LocationDTO.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/query/dto/LocationDTO.java
deleted file mode 100644
index 08a3036..0000000
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/query/dto/LocationDTO.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-package org.apache.zest.sample.dcicargo.sample_a.communication.query.dto;
-
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.location.Location;
-import org.apache.zest.sample.dcicargo.sample_a.infrastructure.conversion.DTO;
-
-/**
- * Location DTO
- *
- * Since all properties of Location are immutable, we can simply re-use the same interface.
- * We need the Location as a DTO when we do entity to value conversions.
- */
-public interface LocationDTO extends Location, DTO
-{
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/query/dto/VoyageDTO.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/query/dto/VoyageDTO.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/query/dto/VoyageDTO.java
deleted file mode 100644
index 6ad0b3b..0000000
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/query/dto/VoyageDTO.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-package org.apache.zest.sample.dcicargo.sample_a.communication.query.dto;
-
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.voyage.Voyage;
-import org.apache.zest.sample.dcicargo.sample_a.infrastructure.conversion.DTO;
-
-/**
- * Voyage DTO
- *
- * Since all properties of Voyage are immutable, we can simply re-use the same interface.
- * We need the Voyage as a DTO when we do entity to value conversions.
- */
-public interface VoyageDTO extends Voyage, DTO
-{
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/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 0e07841..d1a36f1 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
@@ -32,9 +32,9 @@ import org.apache.wicket.model.LoadableDetachableModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.apache.zest.sample.dcicargo.sample_a.communication.query.CommonQueries;
-import org.apache.zest.sample.dcicargo.sample_a.communication.query.dto.CargoDTO;
import org.apache.zest.sample.dcicargo.sample_a.communication.web.tracking.HandlingHistoryPanel;
import org.apache.zest.sample.dcicargo.sample_a.communication.web.tracking.NextHandlingEventPanel;
+import org.apache.zest.sample.dcicargo.sample_a.data.shipping.cargo.Cargo;
import org.apache.zest.sample.dcicargo.sample_a.data.shipping.cargo.RouteSpecification;
import org.apache.zest.sample.dcicargo.sample_a.data.shipping.delivery.Delivery;
import org.apache.zest.sample.dcicargo.sample_a.data.shipping.delivery.RoutingStatus;
@@ -62,8 +62,8 @@ public class CargoDetailsPage extends BookingBasePage
{
super( new PageParameters().set( 0, trackingId ) );
- IModel<CargoDTO> cargoModel = new CommonQueries().cargo( trackingId );
- CargoDTO cargo = cargoModel.getObject();
+ IModel<Cargo> cargoModel = new CommonQueries().cargo( trackingId );
+ Cargo cargo = cargoModel.getObject();
Delivery delivery = cargo.delivery().get();
RouteSpecification routeSpecification = cargo.routeSpecification().get();
final RoutingStatus routingStatus = delivery.routingStatus().get();
@@ -123,7 +123,7 @@ public class CargoDetailsPage extends BookingBasePage
private class ItineraryFragment extends Fragment
{
- public ItineraryFragment( final IModel<CargoDTO> cargoModel, final RoutingStatus routingStatus )
+ public ItineraryFragment( final IModel<Cargo> cargoModel, final RoutingStatus routingStatus )
{
super( "itinerary", "itineraryFragment", CargoDetailsPage.this );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/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 35e260f..25bc21e 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
@@ -31,7 +31,7 @@ import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
import org.apache.zest.sample.dcicargo.sample_a.communication.query.CommonQueries;
-import org.apache.zest.sample.dcicargo.sample_a.communication.query.dto.CargoDTO;
+import org.apache.zest.sample.dcicargo.sample_a.data.shipping.cargo.Cargo;
import org.apache.zest.sample.dcicargo.sample_a.data.shipping.cargo.RouteSpecification;
import org.apache.zest.sample.dcicargo.sample_a.data.shipping.delivery.Delivery;
import org.apache.zest.sample.dcicargo.sample_a.data.shipping.delivery.RoutingStatus;
@@ -50,22 +50,22 @@ public class CargoListPage extends BookingBasePage
{
public CargoListPage()
{
- IModel<List<CargoDTO>> cargoList = new CommonQueries().cargoList();
+ IModel<List<Cargo>> cargoList = new CommonQueries().cargoList();
// Save current trackingIds in session (for prev/next buttons on details page)
ArrayList<String> ids = new ArrayList<>();
- for( CargoDTO cargo : cargoList.getObject() )
+ for( Cargo cargo : cargoList.getObject() )
{
ids.add( cargo.trackingId().get().id().get() );
}
PrevNext.registerIds( Session.get(), ids );
- add( new ListView<CargoDTO>( "list", cargoList )
+ add( new ListView<Cargo>( "list", cargoList )
{
@Override
- protected void populateItem( ListItem<CargoDTO> item )
+ protected void populateItem( ListItem<Cargo> item )
{
- CargoDTO cargo = item.getModelObject();
+ Cargo cargo = item.getModelObject();
String trackingId = cargo.trackingId().get().id().get();
Delivery delivery = cargo.delivery().get();
RoutingStatus routingStatus = cargo.delivery().get().routingStatus().get();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/web/booking/ChangeDestinationPage.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/web/booking/ChangeDestinationPage.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/web/booking/ChangeDestinationPage.java
index c6a03bf..e435cdb 100644
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/web/booking/ChangeDestinationPage.java
+++ b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/communication/web/booking/ChangeDestinationPage.java
@@ -28,8 +28,8 @@ import org.apache.wicket.markup.html.panel.ComponentFeedbackPanel;
import org.apache.wicket.markup.html.panel.FeedbackPanel;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.apache.zest.sample.dcicargo.sample_a.communication.query.CommonQueries;
-import org.apache.zest.sample.dcicargo.sample_a.communication.query.dto.CargoDTO;
import org.apache.zest.sample.dcicargo.sample_a.context.shipping.booking.BookNewCargo;
+import org.apache.zest.sample.dcicargo.sample_a.data.shipping.cargo.Cargo;
import org.apache.zest.sample.dcicargo.sample_a.infrastructure.wicket.form.AbstractForm;
import org.apache.zest.sample.dcicargo.sample_a.infrastructure.wicket.form.SelectorInForm;
@@ -53,7 +53,7 @@ public class ChangeDestinationPage extends BookingBasePage
public CargoEditForm( final String trackingId )
{
CommonQueries fetch = new CommonQueries();
- CargoDTO cargo = fetch.cargo( trackingId ).getObject();
+ Cargo cargo = fetch.cargo( trackingId ).getObject();
List<String> locations = fetch.unLocodes();
origin = cargo.origin().get().getCode();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/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 93cbab2..e522a93 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
@@ -20,7 +20,6 @@
package org.apache.zest.sample.dcicargo.sample_a.communication.web.handling;
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;
@@ -106,8 +105,8 @@ public class RegisterHandlingEventPage extends BasePage
{
map.put( "voyage", voyageNumber );
}
- String msg = new StringResourceModel( "handlingEvent.${type}", this, new Model<ValueMap>( map ) )
- .getObject();
+ String msg = new StringResourceModel(
+ "handlingEvent.${type}", this, new Model<>( map ) ).getObject();
feedback.info( "Registered handling event for cargo '" + trackingId + "': " + msg );
target.add( feedback );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/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 d96bb39..5aa441f 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
@@ -32,8 +32,8 @@ import org.apache.wicket.model.Model;
import org.apache.wicket.model.StringResourceModel;
import org.apache.wicket.util.value.ValueMap;
import org.apache.zest.sample.dcicargo.sample_a.communication.query.TrackingQueries;
-import org.apache.zest.sample.dcicargo.sample_a.communication.query.dto.CargoDTO;
-import org.apache.zest.sample.dcicargo.sample_a.communication.query.dto.HandlingEventDTO;
+import org.apache.zest.sample.dcicargo.sample_a.data.shipping.cargo.Cargo;
+import org.apache.zest.sample.dcicargo.sample_a.data.shipping.handling.HandlingEvent;
import org.apache.zest.sample.dcicargo.sample_a.infrastructure.wicket.color.ErrorColor;
/**
@@ -44,18 +44,18 @@ import org.apache.zest.sample.dcicargo.sample_a.infrastructure.wicket.color.Erro
@StatelessComponent
public class HandlingHistoryPanel extends Panel
{
- public HandlingHistoryPanel( String id, final IModel<CargoDTO> cargoModel, String trackingId )
+ public HandlingHistoryPanel( String id, final IModel<Cargo> cargoModel, String trackingId )
{
super( id );
- IModel<List<HandlingEventDTO>> handlingEventsModel = new TrackingQueries().events( trackingId );
+ IModel<List<HandlingEvent>> handlingEventsModel = new TrackingQueries().events( trackingId );
- add( new ListView<HandlingEventDTO>( "handlingEvents", handlingEventsModel )
+ add( new ListView<HandlingEvent>( "handlingEvents", handlingEventsModel )
{
@Override
- protected void populateItem( ListItem<HandlingEventDTO> item )
+ protected void populateItem( ListItem<HandlingEvent> item )
{
- HandlingEventDTO event = item.getModelObject();
+ HandlingEvent event = item.getModelObject();
Boolean isLast = item.getIndex() == getList().size() - 1;
Boolean isMisdirected = cargoModel.getObject().delivery().get().isMisdirected().get();
@@ -74,7 +74,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<ValueMap>( 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/4275718c/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 80f405c..77091e4 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
@@ -27,7 +27,7 @@ import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.model.StringResourceModel;
import org.apache.wicket.util.value.ValueMap;
-import org.apache.zest.sample.dcicargo.sample_a.communication.query.dto.CargoDTO;
+import org.apache.zest.sample.dcicargo.sample_a.data.shipping.cargo.Cargo;
import org.apache.zest.sample.dcicargo.sample_a.data.shipping.delivery.ExpectedHandlingEvent;
import org.apache.zest.sample.dcicargo.sample_a.data.shipping.handling.HandlingEvent;
import org.apache.zest.sample.dcicargo.sample_a.data.shipping.handling.HandlingEventType;
@@ -41,16 +41,16 @@ import org.apache.zest.sample.dcicargo.sample_a.data.shipping.location.Location;
@StatelessComponent
public class NextHandlingEventPanel extends Panel
{
- public NextHandlingEventPanel( String id, IModel<CargoDTO> cargoModel )
+ public NextHandlingEventPanel( String id, IModel<Cargo> cargoModel )
{
super( id );
ValueMap map = new ValueMap();
Label label = new Label( "text", new StringResourceModel(
- "expectedEvent.${expectedEvent}", this, new Model<ValueMap>( map ) ) );
+ "expectedEvent.${expectedEvent}", this, new Model<>( map ) ) );
add( label );
- CargoDTO cargo = cargoModel.getObject();
+ Cargo cargo = cargoModel.getObject();
Location destination = cargo.routeSpecification().get().destination().get();
if( cargo.itinerary().get() == null )
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/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 2f7f999..e891be1 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
@@ -38,8 +38,8 @@ import org.apache.wicket.util.value.ValueMap;
import org.apache.zest.api.unitofwork.NoSuchEntityException;
import org.apache.zest.sample.dcicargo.sample_a.communication.query.CommonQueries;
import org.apache.zest.sample.dcicargo.sample_a.communication.query.TrackingQueries;
-import org.apache.zest.sample.dcicargo.sample_a.communication.query.dto.CargoDTO;
import org.apache.zest.sample.dcicargo.sample_a.communication.web.BasePage;
+import org.apache.zest.sample.dcicargo.sample_a.data.shipping.cargo.Cargo;
import org.apache.zest.sample.dcicargo.sample_a.data.shipping.handling.HandlingEvent;
import org.apache.zest.sample.dcicargo.sample_a.data.shipping.handling.HandlingEventType;
import org.apache.zest.sample.dcicargo.sample_a.infrastructure.wicket.form.AbstractForm;
@@ -115,7 +115,7 @@ public class TrackCargoPage extends BasePage
{
try
{
- IModel<CargoDTO> cargoModel = new CommonQueries().cargo( trackingId );
+ IModel<Cargo> cargoModel = new CommonQueries().cargo( trackingId );
statusFragment = (Fragment) statusFragment.replaceWith( new StatusFragment( cargoModel, false ) );
target.add( feedback, trackingIdInput, selectedTrackingIdSelector, statusFragment.setVisible( true ) );
}
@@ -135,12 +135,12 @@ public class TrackCargoPage extends BasePage
private class StatusFragment extends Fragment
{
- StatusFragment( IModel<CargoDTO> cargoModel, Boolean visible )
+ StatusFragment( IModel<Cargo> cargoModel, Boolean visible )
{
super( "status", "statusFragment", TrackingForm.this );
setVisible( visible );
- CargoDTO cargo = cargoModel.getObject();
+ Cargo cargo = cargoModel.getObject();
// Status ----------------------------------------------------------------------
ValueMap map = new ValueMap();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/rolemap/CargoRoleMap.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/rolemap/CargoRoleMap.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/rolemap/CargoRoleMap.java
index 01db3a0..8f713f7 100644
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/rolemap/CargoRoleMap.java
+++ b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/rolemap/CargoRoleMap.java
@@ -19,14 +19,13 @@
*/
package org.apache.zest.sample.dcicargo.sample_a.context.rolemap;
+import org.apache.zest.api.entity.EntityComposite;
import org.apache.zest.sample.dcicargo.sample_a.context.shipping.booking.BookNewCargo;
-import org.apache.zest.sample.dcicargo.sample_a.data.entity.CargoEntity;
+import org.apache.zest.sample.dcicargo.sample_a.data.shipping.cargo.Cargo;
/**
* Cargo Role Map
*/
-public interface CargoRoleMap
- extends CargoEntity,
- BookNewCargo.RoutingFacadeRole
+public interface CargoRoleMap extends BookNewCargo.RoutingFacadeRole, EntityComposite, Cargo
{
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/rolemap/CargosRoleMap.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/rolemap/CargosRoleMap.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/rolemap/CargosRoleMap.java
index 73b0097..51cdcd4 100644
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/rolemap/CargosRoleMap.java
+++ b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/rolemap/CargosRoleMap.java
@@ -19,14 +19,13 @@
*/
package org.apache.zest.sample.dcicargo.sample_a.context.rolemap;
+import org.apache.zest.api.entity.EntityComposite;
import org.apache.zest.sample.dcicargo.sample_a.context.shipping.booking.BookNewCargo;
-import org.apache.zest.sample.dcicargo.sample_a.data.entity.CargosEntity;
+import org.apache.zest.sample.dcicargo.sample_a.data.shipping.cargo.Cargos;
/**
* Cargos Role Map
*/
-public interface CargosRoleMap
- extends CargosEntity,
- BookNewCargo.CargoFactoryRole
+public interface CargosRoleMap extends BookNewCargo.CargoFactoryRole, EntityComposite, Cargos
{
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/rolemap/HandlingEventRoleMap.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/rolemap/HandlingEventRoleMap.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/rolemap/HandlingEventRoleMap.java
index fcc1c2f..e88f204 100644
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/rolemap/HandlingEventRoleMap.java
+++ b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/rolemap/HandlingEventRoleMap.java
@@ -19,16 +19,16 @@
*/
package org.apache.zest.sample.dcicargo.sample_a.context.rolemap;
+import org.apache.zest.api.entity.EntityComposite;
import org.apache.zest.sample.dcicargo.sample_a.context.shipping.booking.BuildDeliverySnapshot;
import org.apache.zest.sample.dcicargo.sample_a.context.shipping.handling.InspectCargo;
-import org.apache.zest.sample.dcicargo.sample_a.data.entity.HandlingEventEntity;
+import org.apache.zest.sample.dcicargo.sample_a.data.shipping.handling.HandlingEvent;
/**
* Handling Event Role Map
*/
-public interface HandlingEventRoleMap
- extends HandlingEventEntity,
- BuildDeliverySnapshot.HandlingEventRole,
- InspectCargo.CargoInspectorRole
+public interface HandlingEventRoleMap extends BuildDeliverySnapshot.HandlingEventRole,
+ InspectCargo.CargoInspectorRole,
+ EntityComposite, HandlingEvent
{
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/rolemap/HandlingEventsRoleMap.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/rolemap/HandlingEventsRoleMap.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/rolemap/HandlingEventsRoleMap.java
index c1eb858..637c871 100644
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/rolemap/HandlingEventsRoleMap.java
+++ b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/context/rolemap/HandlingEventsRoleMap.java
@@ -19,14 +19,14 @@
*/
package org.apache.zest.sample.dcicargo.sample_a.context.rolemap;
+import org.apache.zest.api.entity.EntityComposite;
import org.apache.zest.sample.dcicargo.sample_a.context.shipping.handling.RegisterHandlingEvent;
-import org.apache.zest.sample.dcicargo.sample_a.data.entity.HandlingEventsEntity;
+import org.apache.zest.sample.dcicargo.sample_a.data.shipping.handling.HandlingEvents;
/**
* Handling Events Role Map
*/
-public interface HandlingEventsRoleMap
- extends HandlingEventsEntity,
- RegisterHandlingEvent.HandlingEventFactoryRole
+public interface HandlingEventsRoleMap extends RegisterHandlingEvent.HandlingEventFactoryRole,
+ EntityComposite, HandlingEvents
{
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/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 7a7ff72..d57593d 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
@@ -29,9 +29,6 @@ import org.apache.zest.api.value.ValueBuilder;
import org.apache.zest.api.value.ValueBuilderFactory;
import org.apache.zest.sample.dcicargo.sample_a.context.support.FoundNoRoutesException;
import org.apache.zest.sample.dcicargo.sample_a.context.support.RoutingService;
-import org.apache.zest.sample.dcicargo.sample_a.data.entity.CargoEntity;
-import org.apache.zest.sample.dcicargo.sample_a.data.entity.CargosEntity;
-import org.apache.zest.sample.dcicargo.sample_a.data.entity.LocationEntity;
import org.apache.zest.sample.dcicargo.sample_a.data.shipping.cargo.Cargo;
import org.apache.zest.sample.dcicargo.sample_a.data.shipping.cargo.Cargos;
import org.apache.zest.sample.dcicargo.sample_a.data.shipping.cargo.RouteSpecification;
@@ -90,7 +87,7 @@ public class BookNewCargo extends Context
public BookNewCargo( String originId, String destinationId, LocalDate deadline )
throws Exception
{
- this( loadEntity( CargosEntity.class, CargosEntity.CARGOS_ID ),
+ this( loadEntity( Cargos.class, Cargos.CARGOS_ID ),
loadEntity( Location.class, originId ),
loadEntity( Location.class, destinationId ),
deadline );
@@ -98,7 +95,7 @@ public class BookNewCargo extends Context
public BookNewCargo( String trackingIdString )
{
- this( loadEntity( CargoEntity.class, trackingIdString ) );
+ this( loadEntity( Cargo.class, trackingIdString ) );
}
public BookNewCargo( String trackingIdString, Itinerary itinerary )
@@ -120,7 +117,7 @@ public class BookNewCargo extends Context
public void changeDestination( String destination )
{
- routingFacade.changeDestination( loadEntity( LocationEntity.class, destination ) );
+ routingFacade.changeDestination( loadEntity( Location.class, destination ) );
}
public List<Itinerary> routeCandidates()
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/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 4388edf..aa73033 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
@@ -20,7 +20,6 @@
package org.apache.zest.sample.dcicargo.sample_a.context.shipping.handling;
import java.time.LocalDate;
-import java.time.LocalDateTime;
import java.util.Arrays;
import org.apache.zest.api.injection.scope.Service;
import org.apache.zest.api.injection.scope.This;
@@ -30,7 +29,6 @@ import org.apache.zest.api.unitofwork.UnitOfWork;
import org.apache.zest.api.value.ValueBuilder;
import org.apache.zest.sample.dcicargo.sample_a.context.support.ApplicationEvents;
import org.apache.zest.sample.dcicargo.sample_a.context.support.RegisterHandlingEventAttemptDTO;
-import org.apache.zest.sample.dcicargo.sample_a.data.entity.HandlingEventsEntity;
import org.apache.zest.sample.dcicargo.sample_a.data.shipping.cargo.Cargo;
import org.apache.zest.sample.dcicargo.sample_a.data.shipping.cargo.TrackingId;
import org.apache.zest.sample.dcicargo.sample_a.data.shipping.handling.HandlingEvent;
@@ -41,7 +39,7 @@ import org.apache.zest.sample.dcicargo.sample_a.data.shipping.voyage.Voyage;
import org.apache.zest.sample.dcicargo.sample_a.infrastructure.dci.Context;
import org.apache.zest.sample.dcicargo.sample_a.infrastructure.dci.RoleMixin;
-import static org.apache.zest.sample.dcicargo.sample_a.data.entity.HandlingEventsEntity.HANDLING_EVENTS_ID;
+import static org.apache.zest.sample.dcicargo.sample_a.data.shipping.handling.HandlingEvents.HANDLING_EVENTS_ID;
/**
* Register new handling event use case.
@@ -71,7 +69,7 @@ public class RegisterHandlingEvent extends Context
String voyageNumberString
)
{
- handlingEventFactory = rolePlayer( HandlingEventFactoryRole.class, HandlingEventsEntity.class, HANDLING_EVENTS_ID );
+ handlingEventFactory = rolePlayer( HandlingEventFactoryRole.class, HandlingEvents.class, HANDLING_EVENTS_ID );
this.registrationDate = registrationDate;
this.completionDate = completionDate;
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/entity/CargoEntity.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/entity/CargoEntity.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/entity/CargoEntity.java
deleted file mode 100644
index f44b8e9..0000000
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/entity/CargoEntity.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-package org.apache.zest.sample.dcicargo.sample_a.data.entity;
-
-import org.apache.zest.api.entity.EntityComposite;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.cargo.Cargo;
-
-/**
- * Cargo entity
- */
-public interface CargoEntity
- extends EntityComposite,
-
- Cargo
-{
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/entity/CargosEntity.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/entity/CargosEntity.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/entity/CargosEntity.java
deleted file mode 100644
index c04340f..0000000
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/entity/CargosEntity.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-package org.apache.zest.sample.dcicargo.sample_a.data.entity;
-
-import org.apache.zest.api.entity.EntityComposite;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.cargo.Cargos;
-
-/**
- * Cargo aggregate root?
- */
-public interface CargosEntity
- extends EntityComposite, Cargos
-{
- public static final String CARGOS_ID = "Cargos_id";
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/entity/HandlingEventEntity.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/entity/HandlingEventEntity.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/entity/HandlingEventEntity.java
deleted file mode 100644
index fd718c3..0000000
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/entity/HandlingEventEntity.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-package org.apache.zest.sample.dcicargo.sample_a.data.entity;
-
-import org.apache.zest.api.entity.EntityComposite;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.handling.HandlingEvent;
-
-/**
- * Handling Event entity
- */
-public interface HandlingEventEntity
- extends EntityComposite,
-
- HandlingEvent
-{
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/entity/HandlingEventsEntity.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/entity/HandlingEventsEntity.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/entity/HandlingEventsEntity.java
deleted file mode 100644
index c941602..0000000
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/entity/HandlingEventsEntity.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-package org.apache.zest.sample.dcicargo.sample_a.data.entity;
-
-import org.apache.zest.api.entity.EntityComposite;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.handling.HandlingEvents;
-
-/**
- * HandlingEvent aggregate root?
- */
-public interface HandlingEventsEntity
- extends EntityComposite,
-
- HandlingEvents
-{
- public static final String HANDLING_EVENTS_ID = "Handling_events_id";
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/entity/LocationEntity.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/entity/LocationEntity.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/entity/LocationEntity.java
deleted file mode 100644
index f936893..0000000
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/entity/LocationEntity.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-package org.apache.zest.sample.dcicargo.sample_a.data.entity;
-
-import org.apache.zest.api.entity.EntityComposite;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.location.Location;
-
-/**
- * Location entity
- *
- * Locations have been created outside the shipping application context so we don't have any
- * separate aggregate root to create those from.
- */
-public interface LocationEntity
- extends EntityComposite,
-
- Location
-{
-}
[08/25] zest-java git commit: Adding missing license header.
Posted by ni...@apache.org.
Adding missing license header.
Project: http://git-wip-us.apache.org/repos/asf/zest-java/repo
Commit: http://git-wip-us.apache.org/repos/asf/zest-java/commit/3b07170a
Tree: http://git-wip-us.apache.org/repos/asf/zest-java/tree/3b07170a
Diff: http://git-wip-us.apache.org/repos/asf/zest-java/diff/3b07170a
Branch: refs/heads/ValueSerializationCleaning
Commit: 3b07170a615509041237f1e626f841262463c08d
Parents: f5a4d59
Author: Niclas Hedhman <ni...@hedhman.org>
Authored: Fri Jun 10 21:41:21 2016 +0800
Committer: Niclas Hedhman <ni...@hedhman.org>
Committed: Sun Jun 12 22:51:04 2016 +0800
----------------------------------------------------------------------
tools/shell/src/dist/bin/zest-boot | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/zest-java/blob/3b07170a/tools/shell/src/dist/bin/zest-boot
----------------------------------------------------------------------
diff --git a/tools/shell/src/dist/bin/zest-boot b/tools/shell/src/dist/bin/zest-boot
index 14013ad..2706289 100644
--- a/tools/shell/src/dist/bin/zest-boot
+++ b/tools/shell/src/dist/bin/zest-boot
@@ -1,4 +1,21 @@
#!/bin/sh
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
# This files copies itself to $HOME/bin, renames itself to "zest"
# and from then on pretends to be the tools.shell script.
#
[15/25] zest-java git commit: ZEST-151 : Ooops,
there were dependencies. Took the time to refactor some of the DCI
Cargo demo code in the process. Tests passes,
but somehow I doubt that it still works in actual runtime. Need to spend time
on that later.
Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/entity/VoyageEntity.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/entity/VoyageEntity.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/entity/VoyageEntity.java
deleted file mode 100644
index 7530162..0000000
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/entity/VoyageEntity.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-package org.apache.zest.sample.dcicargo.sample_a.data.entity;
-
-import org.apache.zest.api.entity.EntityComposite;
-import org.apache.zest.sample.dcicargo.sample_a.data.shipping.voyage.Voyage;
-
-/**
- * Voyage entity
- *
- * Voyages have been created outside the shipping application context so we don't have any
- * separate aggregate root to create those from.
- */
-public interface VoyageEntity
- extends EntityComposite,
-
- Voyage
-{
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/cargo/Cargo.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/cargo/Cargo.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/cargo/Cargo.java
index 24a3186..1d6e78f 100644
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/cargo/Cargo.java
+++ b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/cargo/Cargo.java
@@ -21,6 +21,7 @@ package org.apache.zest.sample.dcicargo.sample_a.data.shipping.cargo;
import org.apache.zest.api.association.Association;
import org.apache.zest.api.common.Optional;
+import org.apache.zest.api.entity.Identity;
import org.apache.zest.api.property.Immutable;
import org.apache.zest.api.property.Property;
import org.apache.zest.sample.dcicargo.sample_a.data.shipping.delivery.Delivery;
@@ -36,7 +37,7 @@ import org.apache.zest.sample.dcicargo.sample_a.data.shipping.location.Location;
* {@link Delivery} A calculated snapshot of the current delivery status (created by system)
* {@link Itinerary} Description of chosen route (optional)
*/
-public interface Cargo
+public interface Cargo extends Identity
{
@Immutable
Property<TrackingId> trackingId();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/cargo/Cargos.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/cargo/Cargos.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/cargo/Cargos.java
index d15ee65..2165575 100644
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/cargo/Cargos.java
+++ b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/cargo/Cargos.java
@@ -36,6 +36,8 @@ import org.apache.zest.sample.dcicargo.sample_a.data.shipping.delivery.Delivery;
@Mixins( Cargos.Mixin.class )
public interface Cargos
{
+ String CARGOS_ID = "Cargos_id";
+
Cargo createCargo( RouteSpecification routeSpecification, Delivery delivery, @Optional String id );
class Mixin
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/cargo/TrackingId.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/cargo/TrackingId.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/cargo/TrackingId.java
index 2c199c2..f2dd4cc 100644
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/cargo/TrackingId.java
+++ b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/cargo/TrackingId.java
@@ -27,8 +27,7 @@ import org.apache.zest.library.constraints.annotation.NotEmpty;
* A TrackingId uniquely identifies a particular cargo.
* Automatically generated by the application.
*/
-public interface TrackingId
- extends ValueComposite
+public interface TrackingId extends ValueComposite
{
@NotEmpty
Property<String> id();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/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 c12d495..759227a 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
@@ -77,7 +77,6 @@ import org.apache.zest.sample.dcicargo.sample_a.data.shipping.voyage.Voyage;
* The life cycle of a cargo ends when the cargo is claimed by the customer.
*/
public interface Delivery
- extends ValueComposite
{
Property<Instant> timestamp();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/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 7969659..063eb2b 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
@@ -33,7 +33,6 @@ import org.apache.zest.sample.dcicargo.sample_a.data.shipping.voyage.Voyage;
* is expected to be handled next.
*/
public interface ExpectedHandlingEvent
- extends ValueComposite
{
Property<HandlingEventType> handlingEventType();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/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 83a9ab5..057ea23 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
@@ -23,6 +23,7 @@ import java.time.LocalDate;
import org.apache.zest.api.association.Association;
import org.apache.zest.api.common.Optional;
import org.apache.zest.api.common.UseDefaults;
+import org.apache.zest.api.entity.Identity;
import org.apache.zest.api.property.Immutable;
import org.apache.zest.api.property.Property;
import org.apache.zest.sample.dcicargo.sample_a.data.shipping.cargo.TrackingId;
@@ -46,7 +47,7 @@ import org.apache.zest.sample.dcicargo.sample_a.data.shipping.voyage.Voyage;
* {@link HandlingEventType#CLAIM} or {@link HandlingEventType#CUSTOMS}.
* (Handling event type is mandatory).
*/
-public interface HandlingEvent
+public interface HandlingEvent extends Identity
{
@Immutable
Property<LocalDate> registrationDate();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/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 578a54e..2a11e11 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
@@ -37,6 +37,8 @@ import org.apache.zest.sample.dcicargo.sample_a.data.shipping.voyage.Voyage;
@Mixins( HandlingEvents.Mixin.class )
public interface HandlingEvents
{
+ String HANDLING_EVENTS_ID = "Handling_events_id";
+
HandlingEvent createHandlingEvent( LocalDate registrationDate,
LocalDate completionDate,
TrackingId trackingId,
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/itinerary/Leg.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/itinerary/Leg.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/itinerary/Leg.java
index ca0f9fc..8c985a2 100644
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/itinerary/Leg.java
+++ b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/itinerary/Leg.java
@@ -35,7 +35,6 @@ import org.apache.zest.sample.dcicargo.sample_a.data.shipping.voyage.Voyage;
* All properties are mandatory and immutable.
*/
public interface Leg
- extends ValueComposite
{
Association<Location> loadLocation();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/location/UnLocode.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/location/UnLocode.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/location/UnLocode.java
index 8abdba6..f0ee71f 100644
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/location/UnLocode.java
+++ b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/location/UnLocode.java
@@ -32,7 +32,6 @@ import org.apache.zest.library.constraints.annotation.Matches;
* UnLocode is mandatory and immutable.
*/
public interface UnLocode
- extends ValueComposite
{
// Country code is exactly two letters.
// Location code is usually three letters, but may contain the numbers 2-9 as well
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/voyage/CarrierMovement.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/voyage/CarrierMovement.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/voyage/CarrierMovement.java
index 5391319..b48b5fd 100644
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/voyage/CarrierMovement.java
+++ b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/voyage/CarrierMovement.java
@@ -31,7 +31,6 @@ import org.apache.zest.sample.dcicargo.sample_a.data.shipping.location.Location;
* All properties are mandatory and immutable.
*/
public interface CarrierMovement
- extends ValueComposite
{
Association<Location> departureLocation();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/voyage/Schedule.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/voyage/Schedule.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/voyage/Schedule.java
index 01ec211..f13c682 100644
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/voyage/Schedule.java
+++ b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/voyage/Schedule.java
@@ -29,7 +29,6 @@ import org.apache.zest.api.value.ValueComposite;
* List of carrier movements is mandatory and immutable.
*/
public interface Schedule
- extends ValueComposite
{
Property<List<CarrierMovement>> carrierMovements();
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/voyage/VoyageNumber.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/voyage/VoyageNumber.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/voyage/VoyageNumber.java
index 408c31d..9571cb1 100644
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/voyage/VoyageNumber.java
+++ b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/voyage/VoyageNumber.java
@@ -28,7 +28,6 @@ import org.apache.zest.api.value.ValueComposite;
* Voyage number is mandatory and immutable.
*/
public interface VoyageNumber
- extends ValueComposite
{
Property<String> number();
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/WicketZestApplication.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/WicketZestApplication.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/WicketZestApplication.java
index 62fb7af..696a67f 100644
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/WicketZestApplication.java
+++ b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/WicketZestApplication.java
@@ -39,7 +39,6 @@ import org.apache.zest.api.usecase.UsecaseBuilder;
import org.apache.zest.api.value.ValueBuilderFactory;
import org.apache.zest.bootstrap.ApplicationAssembler;
import org.apache.zest.bootstrap.Energy4Java;
-import org.apache.zest.sample.dcicargo.sample_a.infrastructure.conversion.EntityToDTOService;
import org.apache.zest.sample.dcicargo.sample_a.infrastructure.dci.Context;
import org.apache.zest.sample.dcicargo.sample_a.infrastructure.model.Queries;
import org.apache.zest.sample.dcicargo.sample_a.infrastructure.model.ReadOnlyModel;
@@ -73,9 +72,6 @@ public class WicketZestApplication
@Structure
protected ZestAPI api;
- @Service
- protected EntityToDTOService valueConverter;
-
/**
* Zest Assembler
*
@@ -133,7 +129,7 @@ public class WicketZestApplication
Context.prepareContextBaseClass( uowf );
BaseWebPage.prepareBaseWebPageClass( tbf );
- ReadOnlyModel.prepareModelBaseClass( zestModule, api, valueConverter );
+ ReadOnlyModel.prepareModelBaseClass( zestModule, api );
Queries.prepareQueriesBaseClass( uowf, qbf );
wicketInit();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/conversion/EntityToDTOService.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/conversion/EntityToDTOService.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/conversion/EntityToDTOService.java
deleted file mode 100644
index 063fcda..0000000
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/conversion/EntityToDTOService.java
+++ /dev/null
@@ -1,327 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-package org.apache.zest.sample.dcicargo.sample_a.infrastructure.conversion;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.function.Function;
-import java.util.stream.Collectors;
-import org.apache.zest.api.association.AssociationDescriptor;
-import org.apache.zest.api.association.AssociationStateHolder;
-import org.apache.zest.api.association.ManyAssociation;
-import org.apache.zest.api.entity.EntityComposite;
-import org.apache.zest.api.entity.EntityDescriptor;
-import org.apache.zest.api.entity.EntityReference;
-import org.apache.zest.api.entity.Identity;
-import org.apache.zest.api.injection.scope.Structure;
-import org.apache.zest.api.mixin.Mixins;
-import org.apache.zest.api.property.PropertyDescriptor;
-import org.apache.zest.api.service.ServiceComposite;
-import org.apache.zest.api.structure.ModuleDescriptor;
-import org.apache.zest.api.type.CollectionType;
-import org.apache.zest.api.value.NoSuchValueException;
-import org.apache.zest.api.value.ValueBuilder;
-import org.apache.zest.api.value.ValueBuilderFactory;
-import org.apache.zest.api.value.ValueDescriptor;
-import org.apache.zest.functional.Iterables;
-import org.apache.zest.library.conversion.values.Unqualified;
-import org.apache.zest.spi.ZestSPI;
-
-/**
- * Conversion of Entity objects to DTO's
- *
- * Value composites that extend {@link DTO} will have association properties converted recursively.
- *
- * Modification of {org.apache.zest.library.conversion.values.EntityToValue}
- * WARN No support of NamedAssociations
- */
-@SuppressWarnings( "unchecked" )
-@Mixins( EntityToDTOService.Mixin.class )
-public interface EntityToDTOService
- extends ServiceComposite
-{
- <T> T convert( Class<T> valueType, Object entity );
-
- static abstract class Mixin
- implements EntityToDTOService
- {
- @Structure
- private ValueBuilderFactory vbf;
-
- @Structure
- private ZestSPI spi;
-
- @Structure
- private ModuleDescriptor module;
-
- @Override
- public <T> T convert( final Class<T> valueType, Object entity )
- {
- ValueDescriptor valueDescriptor = module.valueDescriptor( valueType.getName() );
- if( valueDescriptor == null )
- {
- throw new NoSuchValueException( valueType.getName(), module.name(), module.typeLookup() );
- }
- Unqualified unqualified = valueDescriptor.metaInfo( Unqualified.class );
- final EntityComposite composite = (EntityComposite) entity;
- final EntityDescriptor entityDescriptor = spi.entityDescriptorFor( composite );
- final AssociationStateHolder associationState = spi.stateOf( composite );
- ValueBuilder<?> builder;
-
- if( unqualified == null || !unqualified.value() )
- {
- // Copy state using qualified names
- builder = vbf.newValueBuilderWithState( valueType, new Function<PropertyDescriptor, Object>()
- {
- @Override
- public Object apply( PropertyDescriptor descriptor )
- {
- try
- {
- return associationState.propertyFor( descriptor.accessor() ).get();
- }
- catch( IllegalArgumentException e )
- {
- if( descriptor.valueType().mainType().equals( String.class ) )
- {
- // Find Association and convert to string
- AssociationDescriptor associationDescriptor;
- try
- {
- associationDescriptor = entityDescriptor.state()
- .getAssociationByName( descriptor.qualifiedName().name() );
- }
- catch( IllegalArgumentException e1 )
- {
- return null;
- }
- Object entity = associationState.associationFor( associationDescriptor.accessor() ).get();
- if( entity != null )
- {
- return ( (Identity) entity ).identity().get();
- }
- return null;
- }
- else if( descriptor.valueType() instanceof CollectionType
- && ( (CollectionType) descriptor.valueType() ).collectedType().mainType().equals( String.class ) )
- {
- AssociationDescriptor associationDescriptor;
- try
- {
- associationDescriptor = entityDescriptor.state()
- .getManyAssociationByName( descriptor.qualifiedName().name() );
- }
- catch( IllegalArgumentException e1 )
- {
- return Collections.emptyList();
- }
-
- ManyAssociation<?> state = associationState.manyAssociationFor( associationDescriptor.accessor() );
- List<String> entities = new ArrayList<>( state.count() );
- for( Object entity : state )
- {
- entities.add( ( (Identity) entity ).identity().get() );
- }
- return entities;
- }
-
- // No NamedAssociation support
-
- return null;
- }
- }
- }, new Function<AssociationDescriptor, EntityReference>()
- {
- @Override
- public EntityReference apply( AssociationDescriptor associationDescriptor )
- {
- return EntityReference.entityReferenceFor(
- associationState.associationFor( associationDescriptor.accessor() ).get() );
- }
- }, new Function<AssociationDescriptor, Iterable<EntityReference>>()
- {
- @Override
- public Iterable<EntityReference> apply( AssociationDescriptor associationDescriptor )
- {
- ManyAssociation<?> state = associationState.manyAssociationFor( associationDescriptor.accessor() );
- List<EntityReference> refs = new ArrayList<>( state.count() );
- for( Object entity : state )
- {
- refs.add( EntityReference.entityReferenceFor( entity ) );
- }
- return refs;
- }
- }, new Function<AssociationDescriptor, Map<String, EntityReference>>()
- {
- @Override
- public Map<String, EntityReference> apply( AssociationDescriptor from )
- {
- // No NamedAssociation support
- return Collections.emptyMap();
- }
- } );
- }
- else
- {
- builder = vbf.newValueBuilderWithState( valueType, new Function<PropertyDescriptor, Object>()
- {
- @Override
- public Object apply( PropertyDescriptor descriptor )
- {
- try
- {
- PropertyDescriptor propertyDescriptor = entityDescriptor.state()
- .findPropertyModelByName( descriptor.qualifiedName().name() );
- return associationState.propertyFor( propertyDescriptor.accessor() ).get();
- }
- catch( IllegalArgumentException e )
- {
- if( descriptor.valueType().mainType().equals( String.class ) )
- {
- // Find Association and convert to string
- AssociationDescriptor associationDescriptor;
- try
- {
- associationDescriptor = entityDescriptor.state()
- .getAssociationByName( descriptor.qualifiedName().name() );
- }
- catch( IllegalArgumentException e1 )
- {
- return null;
- }
-
- Object entity = associationState.associationFor( associationDescriptor.accessor() ).get();
- if( entity != null )
- {
- return ( (Identity) entity ).identity().get();
- }
- return null;
- }
- else if( descriptor.valueType() instanceof CollectionType
- && ( (CollectionType) descriptor.valueType() ).collectedType().mainType().equals( String.class ) )
- {
- AssociationDescriptor associationDescriptor;
- try
- {
- associationDescriptor = entityDescriptor.state()
- .getManyAssociationByName( descriptor.qualifiedName().name() );
- }
- catch( IllegalArgumentException e1 )
- {
- return null;
- }
-
- ManyAssociation<?> state = associationState.manyAssociationFor( associationDescriptor.accessor() );
- List<String> entities = new ArrayList<>( state.count() );
- for( Object entity : state )
- {
- entities.add( ( (Identity) entity ).identity().get() );
- }
- return entities;
- }
-
- // No NamedAssociation support
-
- // DTO
- Class<?> type = descriptor.valueType().mainType();
- if( DTO.class.isAssignableFrom( type ) )
- {
- AssociationDescriptor associationDescriptor;
- try
- {
- associationDescriptor = entityDescriptor.state()
- .getAssociationByName( descriptor.qualifiedName().name() );
- }
- catch( IllegalArgumentException e1 )
- {
- return null;
- }
-
- Object entity = associationState.associationFor( associationDescriptor.accessor() ).get();
- if( entity != null )
- {
- return convert( type, entity );
- }
- }
-
- return null;
- }
- }
- }, new Function<AssociationDescriptor, EntityReference>()
- {
- @Override
- public EntityReference apply( AssociationDescriptor descriptor )
- {
- AssociationDescriptor associationDescriptor;
- try
- {
- associationDescriptor = entityDescriptor.state()
- .getAssociationByName( descriptor.qualifiedName().name() );
- }
- catch( IllegalArgumentException e )
- {
- return null;
- }
-
- return EntityReference.entityReferenceFor( associationState
- .associationFor( associationDescriptor.accessor() ).get() );
- }
- }, new Function<AssociationDescriptor, Iterable<EntityReference>>()
- {
- @Override
- public Iterable<EntityReference> apply( AssociationDescriptor descriptor )
- {
- AssociationDescriptor associationDescriptor;
- try
- {
- associationDescriptor = entityDescriptor.state()
- .getManyAssociationByName( descriptor.qualifiedName().name() );
- }
- catch( IllegalArgumentException e )
- {
- return Iterables.empty();
- }
-
- ManyAssociation<?> state = associationState.manyAssociationFor( associationDescriptor.accessor() );
- List<EntityReference> refs = new ArrayList<>( state.count() );
- for( Object entity : state )
- {
- refs.add( EntityReference.entityReferenceFor( entity ) );
- }
- return refs;
- }
- }, new Function<AssociationDescriptor, Map<String, EntityReference>>()
- {
- @Override
- public Map<String, EntityReference> apply( AssociationDescriptor from )
- {
- // No NamedAssociations support
- return Collections.emptyMap();
- }
- } );
- }
-
- return (T) builder.newInstance();
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/model/EntityModel.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/model/EntityModel.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/model/EntityModel.java
index f056c66..fdf1e9b 100644
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/model/EntityModel.java
+++ b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/model/EntityModel.java
@@ -20,43 +20,45 @@
package org.apache.zest.sample.dcicargo.sample_a.infrastructure.model;
import org.apache.wicket.model.IModel;
-import org.apache.zest.api.entity.EntityComposite;
import org.apache.zest.api.entity.EntityReference;
+import org.apache.zest.api.entity.Identity;
+import org.apache.zest.api.injection.scope.Structure;
import org.apache.zest.api.unitofwork.NoSuchEntityException;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
import org.apache.zest.api.usecase.Usecase;
-import org.apache.zest.sample.dcicargo.sample_a.infrastructure.conversion.DTO;
/**
* Javadoc
*/
-public class EntityModel<T extends DTO, U extends EntityComposite>
+public class EntityModel<T extends Identity>
extends ReadOnlyModel<T>
{
- private Class<U> entityClass;
+ private Class<T> entityClass;
private String identity;
private Class<T> dtoClass;
private transient T dtoComposite;
- public EntityModel( Class<U> entityClass, String identity, Class<T> dtoClass )
+ @Structure
+ private UnitOfWorkFactory uowf;
+
+ public EntityModel( Class<T> entityClass, String identity, Class<T> dtoClass )
{
this.entityClass = entityClass;
this.identity = identity;
this.dtoClass = dtoClass;
}
- public static <T extends DTO, U extends EntityComposite> IModel<T> of(
- Class<U> entityClass, String identity, Class<T> dtoClass
- )
+ public static <T extends Identity> IModel<T> of( Class<T> entityClass, String identity, Class<T> dtoClass )
{
- return new EntityModel<T, U>( entityClass, identity, dtoClass );
+ return new EntityModel<>( entityClass, identity, dtoClass );
}
public T getObject()
{
if( dtoComposite == null && identity != null )
{
- dtoComposite = valueConverter.convert( dtoClass, loadEntity() );
+ dtoComposite = uowf.currentUnitOfWork().toValue( dtoClass, loadEntity() );
}
return dtoComposite;
}
@@ -66,9 +68,9 @@ public class EntityModel<T extends DTO, U extends EntityComposite>
dtoComposite = null;
}
- private U loadEntity()
+ private T loadEntity()
{
- U entity = module.unitOfWorkFactory().currentUnitOfWork().get( entityClass, identity );
+ T entity = module.unitOfWorkFactory().currentUnitOfWork().get( entityClass, identity );
if( entity == null )
{
Usecase usecase = module.unitOfWorkFactory().currentUnitOfWork().usecase();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/model/QueryModel.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/model/QueryModel.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/model/QueryModel.java
index 25e6c5e..b2ee967 100644
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/model/QueryModel.java
+++ b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/model/QueryModel.java
@@ -22,18 +22,24 @@ package org.apache.zest.sample.dcicargo.sample_a.infrastructure.model;
import java.util.ArrayList;
import java.util.List;
import org.apache.zest.api.entity.EntityComposite;
+import org.apache.zest.api.entity.Identity;
+import org.apache.zest.api.injection.scope.Structure;
import org.apache.zest.api.query.Query;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
/**
* Callback Wicket model that holds a Zest Query object that can be called when needed to
* retrieve fresh data.
*/
-public abstract class QueryModel<T, U extends EntityComposite>
+public abstract class QueryModel<T extends Identity>
extends ReadOnlyModel<List<T>>
{
private Class<T> dtoClass;
private transient List<T> dtoList;
+ @Structure
+ private UnitOfWorkFactory uowf;
+
public QueryModel( Class<T> dtoClass )
{
this.dtoClass = dtoClass;
@@ -46,8 +52,8 @@ public abstract class QueryModel<T, U extends EntityComposite>
return dtoList;
}
- dtoList = new ArrayList<T>();
- for( U entity : getQuery() )
+ dtoList = new ArrayList<>();
+ for( T entity : getQuery() )
{
dtoList.add( getValue( entity ) );
}
@@ -56,11 +62,11 @@ public abstract class QueryModel<T, U extends EntityComposite>
}
// Callback to retrieve the (unserializable) Zest Query object
- public abstract Query<U> getQuery();
+ public abstract Query<T> getQuery();
- public T getValue( U entity )
+ public T getValue( T entity )
{
- return valueConverter.convert( dtoClass, entity );
+ return uowf.currentUnitOfWork().toValue( dtoClass, entity );
}
public void detach()
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/model/ReadOnlyModel.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/model/ReadOnlyModel.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/model/ReadOnlyModel.java
index 28d721b..34593fb 100644
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/model/ReadOnlyModel.java
+++ b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/model/ReadOnlyModel.java
@@ -22,7 +22,6 @@ package org.apache.zest.sample.dcicargo.sample_a.infrastructure.model;
import org.apache.wicket.model.IModel;
import org.apache.zest.api.ZestAPI;
import org.apache.zest.api.structure.Module;
-import org.apache.zest.sample.dcicargo.sample_a.infrastructure.conversion.EntityToDTOService;
/**
* Abstract base model for Wicket model objects taking Zest objects.
@@ -32,7 +31,6 @@ public abstract class ReadOnlyModel<T>
{
private static final long serialVersionUID = 1L;
- static protected EntityToDTOService valueConverter;
static protected ZestAPI api;
static protected Module module;
@@ -60,12 +58,10 @@ public abstract class ReadOnlyModel<T>
}
public static void prepareModelBaseClass( Module m,
- ZestAPI api,
- EntityToDTOService entityToDTO
+ ZestAPI api
)
{
module = m;
ReadOnlyModel.api = api;
- valueConverter = entityToDTO;
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/bootstrap/test/TestAssembler.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/bootstrap/test/TestAssembler.java b/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/bootstrap/test/TestAssembler.java
index 0f472d1..214fcc4 100644
--- a/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/bootstrap/test/TestAssembler.java
+++ b/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/bootstrap/test/TestAssembler.java
@@ -47,15 +47,15 @@ import org.apache.zest.sample.dcicargo.sample_a.context.rolemap.RouteSpecificati
import org.apache.zest.sample.dcicargo.sample_a.context.support.ApplicationEvents;
import org.apache.zest.sample.dcicargo.sample_a.context.support.RegisterHandlingEventAttemptDTO;
import org.apache.zest.sample.dcicargo.sample_a.context.support.RoutingService;
-import org.apache.zest.sample.dcicargo.sample_a.data.entity.LocationEntity;
-import org.apache.zest.sample.dcicargo.sample_a.data.entity.VoyageEntity;
import org.apache.zest.sample.dcicargo.sample_a.data.shipping.cargo.TrackingId;
import org.apache.zest.sample.dcicargo.sample_a.data.shipping.delivery.Delivery;
import org.apache.zest.sample.dcicargo.sample_a.data.shipping.delivery.ExpectedHandlingEvent;
import org.apache.zest.sample.dcicargo.sample_a.data.shipping.itinerary.Leg;
+import org.apache.zest.sample.dcicargo.sample_a.data.shipping.location.Location;
import org.apache.zest.sample.dcicargo.sample_a.data.shipping.location.UnLocode;
import org.apache.zest.sample.dcicargo.sample_a.data.shipping.voyage.CarrierMovement;
import org.apache.zest.sample.dcicargo.sample_a.data.shipping.voyage.Schedule;
+import org.apache.zest.sample.dcicargo.sample_a.data.shipping.voyage.Voyage;
import org.apache.zest.sample.dcicargo.sample_a.data.shipping.voyage.VoyageNumber;
import org.apache.zest.spi.uuid.UuidIdentityGeneratorService;
import org.apache.zest.valueserialization.orgjson.OrgJsonValueSerializationService;
@@ -164,8 +164,8 @@ public class TestAssembler
ModuleAssembly entityModule = domainLayer.module( "DOMAIN-Entity" ).withDefaultUnitOfWorkFactory();
entityModule
.entities(
- LocationEntity.class,
- VoyageEntity.class )
+ Location.class,
+ Voyage.class )
.visibleIn( application );
// Non-role-playing values
@@ -191,14 +191,7 @@ public class TestAssembler
serializationModule
.services( OrgJsonValueSerializationService.class )
.taggedWith( ValueSerialization.Formats.JSON )
- .setMetaInfo( new Function<Application, Module>()
- {
- @Override
- public Module apply( Application application )
- {
- return application.findModule( "CONTEXT", "CONTEXT-ContextSupport" );
- }
- } )
+ .setMetaInfo( (Function<Application, Module>) application1 -> application1.findModule( "CONTEXT", "CONTEXT-ContextSupport" ) )
.visibleIn( application );
ModuleAssembly indexingModule = infrastructureLayer.module( "INFRASTRUCTURE-Indexing" )
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/booking/BookNewCargoTest.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/booking/BookNewCargoTest.java b/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/booking/BookNewCargoTest.java
index 2256c1a..70f4056 100644
--- a/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/booking/BookNewCargoTest.java
+++ b/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/booking/BookNewCargoTest.java
@@ -26,7 +26,6 @@ import org.apache.zest.api.unitofwork.UnitOfWork;
import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
import org.apache.zest.sample.dcicargo.sample_a.bootstrap.test.TestApplication;
import org.apache.zest.sample.dcicargo.sample_a.context.support.FoundNoRoutesException;
-import org.apache.zest.sample.dcicargo.sample_a.data.entity.CargosEntity;
import org.apache.zest.sample.dcicargo.sample_a.data.shipping.cargo.Cargo;
import org.apache.zest.sample.dcicargo.sample_a.data.shipping.cargo.Cargos;
import org.apache.zest.sample.dcicargo.sample_a.data.shipping.cargo.TrackingId;
@@ -73,7 +72,7 @@ public class BookNewCargoTest
{
UnitOfWork uow = uowf.currentUnitOfWork();
Location HONGKONG = uow.get( Location.class, CNHKG.code().get() );
- Cargos CARGOS = uow.get( Cargos.class, CargosEntity.CARGOS_ID );
+ Cargos CARGOS = uow.get( Cargos.class, Cargos.CARGOS_ID );
new BookNewCargo( CARGOS, HONGKONG, HONGKONG, day( 17 ) ).book();
}
@@ -84,7 +83,7 @@ public class BookNewCargoTest
UnitOfWork uow = uowf.currentUnitOfWork();
Location HONGKONG = uow.get( Location.class, CNHKG.code().get() );
Location STOCKHOLM = uow.get( Location.class, SESTO.code().get() );
- Cargos CARGOS = uow.get( Cargos.class, CargosEntity.CARGOS_ID );
+ Cargos CARGOS = uow.get( Cargos.class, Cargos.CARGOS_ID );
new BookNewCargo( CARGOS, HONGKONG, STOCKHOLM, day( -1 ) ).book();
}
@@ -95,7 +94,7 @@ public class BookNewCargoTest
UnitOfWork uow = uowf.currentUnitOfWork();
Location HONGKONG = uow.get( Location.class, CNHKG.code().get() );
Location STOCKHOLM = uow.get( Location.class, SESTO.code().get() );
- Cargos CARGOS = uow.get( Cargos.class, CargosEntity.CARGOS_ID );
+ Cargos CARGOS = uow.get( Cargos.class, Cargos.CARGOS_ID );
new BookNewCargo( CARGOS, HONGKONG, STOCKHOLM, day( 0 ) ).book();
}
@@ -106,7 +105,7 @@ public class BookNewCargoTest
UnitOfWork uow = uowf.currentUnitOfWork();
Location HONGKONG = uow.get( Location.class, CNHKG.code().get() );
Location STOCKHOLM = uow.get( Location.class, SESTO.code().get() );
- Cargos CARGOS = uow.get( Cargos.class, CargosEntity.CARGOS_ID );
+ Cargos CARGOS = uow.get( Cargos.class, Cargos.CARGOS_ID );
new BookNewCargo( CARGOS, HONGKONG, STOCKHOLM, day( 1 ) ).book();
}
@@ -117,7 +116,7 @@ public class BookNewCargoTest
UnitOfWork uow = uowf.currentUnitOfWork();
Location HONGKONG = uow.get( Location.class, CNHKG.code().get() );
Location STOCKHOLM = uow.get( Location.class, SESTO.code().get() );
- Cargos CARGOS = uow.get( Cargos.class, CargosEntity.CARGOS_ID );
+ Cargos CARGOS = uow.get( Cargos.class, Cargos.CARGOS_ID );
// Create cargo with valid input from customer
TrackingId trackingId = new BookNewCargo( CARGOS, HONGKONG, STOCKHOLM, day( 17 ) ).book();
@@ -164,7 +163,7 @@ public class BookNewCargoTest
UnitOfWork uow = uowf.currentUnitOfWork();
Location HONGKONG = uow.get( Location.class, CNHKG.code().get() );
Location STOCKHOLM = uow.get( Location.class, SESTO.code().get() );
- Cargos CARGOS = uow.get( Cargos.class, CargosEntity.CARGOS_ID );
+ Cargos CARGOS = uow.get( Cargos.class, Cargos.CARGOS_ID );
TrackingId trackingId = new BookNewCargo( CARGOS, HONGKONG, STOCKHOLM, day( 1 ) ).book();
Cargo cargo = uow.get( Cargo.class, trackingId.id().get() );
@@ -179,7 +178,7 @@ public class BookNewCargoTest
UnitOfWork uow = uowf.currentUnitOfWork();
Location HONGKONG = uow.get( Location.class, CNHKG.code().get() );
Location STOCKHOLM = uow.get( Location.class, SESTO.code().get() );
- Cargos CARGOS = uow.get( Cargos.class, CargosEntity.CARGOS_ID );
+ Cargos CARGOS = uow.get( Cargos.class, Cargos.CARGOS_ID );
// Create valid cargo
TrackingId trackingId = new BookNewCargo( CARGOS, HONGKONG, STOCKHOLM, day( 30 ) ).book();
@@ -211,7 +210,7 @@ public class BookNewCargoTest
UnitOfWork uow = uowf.currentUnitOfWork();
Location HONGKONG = uow.get( Location.class, CNHKG.code().get() );
Location STOCKHOLM = uow.get( Location.class, SESTO.code().get() );
- Cargos CARGOS = uow.get( Cargos.class, CargosEntity.CARGOS_ID );
+ Cargos CARGOS = uow.get( Cargos.class, Cargos.CARGOS_ID );
// Create valid cargo
LocalDate deadline = day( 30 );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/booking/BuildDeliverySnapshotTest.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/booking/BuildDeliverySnapshotTest.java b/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/booking/BuildDeliverySnapshotTest.java
index a5455c8..9693d87 100644
--- a/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/booking/BuildDeliverySnapshotTest.java
+++ b/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/booking/BuildDeliverySnapshotTest.java
@@ -24,8 +24,6 @@ import java.time.ZoneOffset;
import org.apache.zest.api.unitofwork.UnitOfWork;
import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
import org.apache.zest.sample.dcicargo.sample_a.bootstrap.test.TestApplication;
-import org.apache.zest.sample.dcicargo.sample_a.data.entity.CargosEntity;
-import org.apache.zest.sample.dcicargo.sample_a.data.entity.HandlingEventsEntity;
import org.apache.zest.sample.dcicargo.sample_a.data.shipping.cargo.Cargo;
import org.apache.zest.sample.dcicargo.sample_a.data.shipping.cargo.Cargos;
import org.apache.zest.sample.dcicargo.sample_a.data.shipping.cargo.RouteSpecification;
@@ -35,6 +33,7 @@ import org.apache.zest.sample.dcicargo.sample_a.data.shipping.delivery.RoutingSt
import org.apache.zest.sample.dcicargo.sample_a.data.shipping.delivery.TransportStatus;
import org.apache.zest.sample.dcicargo.sample_a.data.shipping.handling.HandlingEvent;
import org.apache.zest.sample.dcicargo.sample_a.data.shipping.handling.HandlingEventType;
+import org.apache.zest.sample.dcicargo.sample_a.data.shipping.handling.HandlingEvents;
import org.apache.zest.sample.dcicargo.sample_a.data.shipping.itinerary.Itinerary;
import org.apache.zest.sample.dcicargo.sample_a.data.shipping.location.Location;
import org.apache.zest.sample.dcicargo.sample_a.data.shipping.voyage.Voyage;
@@ -109,7 +108,7 @@ public class BuildDeliverySnapshotTest
V400S = uow.get( Voyage.class, "V400S" );
V500S = uow.get( Voyage.class, "V500S" );
- Cargos CARGOS = uow.get( Cargos.class, CargosEntity.CARGOS_ID );
+ Cargos CARGOS = uow.get( Cargos.class, Cargos.CARGOS_ID );
trackingId = new BookNewCargo( CARGOS, HONGKONG, STOCKHOLM, day( 17 ) ).createCargo( "ABC" );
cargo = uow.get( Cargo.class, trackingId.id().get() );
@@ -172,7 +171,7 @@ public class BuildDeliverySnapshotTest
UnitOfWork uow = uowf.currentUnitOfWork();
RouteSpecification routeSpec = routeSpecification( HONGKONG, STOCKHOLM, day( 20 ) );
- Cargos CARGOS = uow.get( Cargos.class, CargosEntity.CARGOS_ID );
+ Cargos CARGOS = uow.get( Cargos.class, Cargos.CARGOS_ID );
Delivery delivery = new BuildDeliverySnapshot( routeSpec ).get();
CARGOS.createCargo( routeSpec, delivery, "ABCD" );
@@ -296,7 +295,7 @@ public class BuildDeliverySnapshotTest
deviation_3a_CargoHasNoHandlingHistory();
UnitOfWork uow = uowf.currentUnitOfWork();
- HandlingEventsEntity HANDLING_EVENTS = uow.get( HandlingEventsEntity.class, HandlingEventsEntity.HANDLING_EVENTS_ID );
+ HandlingEvents HANDLING_EVENTS = uow.get( HandlingEvents.class, HandlingEvents.HANDLING_EVENTS_ID );
// Unexpected receipt in Shanghai
HandlingEvent handlingEvent = HANDLING_EVENTS.createHandlingEvent( day( 1 ), day( 1 ), trackingId, HandlingEventType.RECEIVE, SHANGHAI, null );
Delivery delivery = new BuildDeliverySnapshot( cargo, handlingEvent ).get();
@@ -323,7 +322,7 @@ public class BuildDeliverySnapshotTest
deviation_4a_RECEIVE_1a_UnexpectedPort();
UnitOfWork uow = uowf.currentUnitOfWork();
- HandlingEventsEntity HANDLING_EVENTS = uow.get( HandlingEventsEntity.class, HandlingEventsEntity.HANDLING_EVENTS_ID );
+ HandlingEvents HANDLING_EVENTS = uow.get( HandlingEvents.class, HandlingEvents.HANDLING_EVENTS_ID );
// Expected receipt in Hong Kong
HandlingEvent handlingEvent = HANDLING_EVENTS.createHandlingEvent( day( 1 ), day( 1 ), trackingId, HandlingEventType.RECEIVE, HONGKONG, null );
Delivery delivery = new BuildDeliverySnapshot( cargo, handlingEvent ).get();
@@ -347,7 +346,7 @@ public class BuildDeliverySnapshotTest
deviation_4a_RECEIVE_1b_ExpectedPort();
UnitOfWork uow = uowf.currentUnitOfWork();
- HandlingEventsEntity HANDLING_EVENTS = uow.get( HandlingEventsEntity.class, HandlingEventsEntity.HANDLING_EVENTS_ID );
+ HandlingEvents HANDLING_EVENTS = uow.get( HandlingEvents.class, HandlingEvents.HANDLING_EVENTS_ID );
// Unexpected load in Tokyo
HandlingEvent handlingEvent = HANDLING_EVENTS.createHandlingEvent( day( 1 ), day( 1 ), trackingId, LOAD, TOKYO, V100S );
Delivery delivery = new BuildDeliverySnapshot( cargo, handlingEvent ).get();
@@ -370,7 +369,7 @@ public class BuildDeliverySnapshotTest
deviation_4b_LOAD_2a_UnexpectedPort();
UnitOfWork uow = uowf.currentUnitOfWork();
- HandlingEventsEntity HANDLING_EVENTS = uow.get( HandlingEventsEntity.class, HandlingEventsEntity.HANDLING_EVENTS_ID );
+ HandlingEvents HANDLING_EVENTS = uow.get( HandlingEvents.class, HandlingEvents.HANDLING_EVENTS_ID );
// Expected load in Hong Kong
HandlingEvent handlingEvent = HANDLING_EVENTS.createHandlingEvent( day( 1 ), day( 1 ), trackingId, LOAD, HONGKONG, V100S );
Delivery delivery = new BuildDeliverySnapshot( cargo, handlingEvent ).get();
@@ -395,7 +394,7 @@ public class BuildDeliverySnapshotTest
deviation_4b_LOAD_2b_ExpectedPort();
UnitOfWork uow = uowf.currentUnitOfWork();
- HandlingEventsEntity HANDLING_EVENTS = uow.get( HandlingEventsEntity.class, HandlingEventsEntity.HANDLING_EVENTS_ID );
+ HandlingEvents HANDLING_EVENTS = uow.get( HandlingEvents.class, HandlingEvents.HANDLING_EVENTS_ID );
// Load onto unexpected voyage
HandlingEvent handlingEvent = HANDLING_EVENTS.createHandlingEvent( day( 1 ), day( 1 ), trackingId, LOAD, HONGKONG, V400S );
Delivery delivery = new BuildDeliverySnapshot( cargo, handlingEvent ).get();
@@ -418,7 +417,7 @@ public class BuildDeliverySnapshotTest
deviation_4b_LOAD_2c_UnexpectedVoyageNotFromItinerary();
UnitOfWork uow = uowf.currentUnitOfWork();
- HandlingEventsEntity HANDLING_EVENTS = uow.get( HandlingEventsEntity.class, HandlingEventsEntity.HANDLING_EVENTS_ID );
+ HandlingEvents HANDLING_EVENTS = uow.get( HandlingEvents.class, HandlingEvents.HANDLING_EVENTS_ID );
// The system doesn't currently check if handling events happen in the right order, so
// a cargo can now suddenly load in New York, even though it hasn't got there yet.
@@ -447,7 +446,7 @@ public class BuildDeliverySnapshotTest
deviation_4b_LOAD_2c_ExpectedButLaterVoyageInItinerary();
UnitOfWork uow = uowf.currentUnitOfWork();
- HandlingEventsEntity HANDLING_EVENTS = uow.get( HandlingEventsEntity.class, HandlingEventsEntity.HANDLING_EVENTS_ID );
+ HandlingEvents HANDLING_EVENTS = uow.get( HandlingEvents.class, HandlingEvents.HANDLING_EVENTS_ID );
// Unexpected unload in Tokyo
HandlingEvent handlingEvent = HANDLING_EVENTS.createHandlingEvent( day( 5 ), day( 5 ), trackingId, UNLOAD, TOKYO, V100S );
@@ -541,7 +540,7 @@ public class BuildDeliverySnapshotTest
deviation_4c_UNLOAD_1a_UnexpectedPort();
UnitOfWork uow = uowf.currentUnitOfWork();
- HandlingEventsEntity HANDLING_EVENTS = uow.get( HandlingEventsEntity.class, HandlingEventsEntity.HANDLING_EVENTS_ID );
+ HandlingEvents HANDLING_EVENTS = uow.get( HandlingEvents.class, HandlingEvents.HANDLING_EVENTS_ID );
// Unload at midpoint location of itinerary
HandlingEvent handlingEvent = HANDLING_EVENTS.createHandlingEvent( day( 8 ), day( 8 ), trackingId, UNLOAD, HAMBURG, V400S );
@@ -568,7 +567,7 @@ public class BuildDeliverySnapshotTest
deviation_4c_UNLOAD_1b_ExpectedMidpointLocation();
UnitOfWork uow = uowf.currentUnitOfWork();
- HandlingEventsEntity HANDLING_EVENTS = uow.get( HandlingEventsEntity.class, HandlingEventsEntity.HANDLING_EVENTS_ID );
+ HandlingEvents HANDLING_EVENTS = uow.get( HandlingEvents.class, HandlingEvents.HANDLING_EVENTS_ID );
// Unload at destination
HandlingEvent handlingEvent = HANDLING_EVENTS.createHandlingEvent( day( 16 ), day( 16 ), trackingId, UNLOAD, STOCKHOLM, V500S );
@@ -597,7 +596,7 @@ public class BuildDeliverySnapshotTest
deviation_4c_UNLOAD_1c_Destination();
UnitOfWork uow = uowf.currentUnitOfWork();
- HandlingEventsEntity HANDLING_EVENTS = uow.get( HandlingEventsEntity.class, HandlingEventsEntity.HANDLING_EVENTS_ID );
+ HandlingEvents HANDLING_EVENTS = uow.get( HandlingEvents.class, HandlingEvents.HANDLING_EVENTS_ID );
// Cargo was handled by the customs authorities
HandlingEvent handlingEvent = HANDLING_EVENTS.createHandlingEvent( day( 16 ), day( 16 ), trackingId, CUSTOMS, STOCKHOLM, null );
@@ -624,7 +623,7 @@ public class BuildDeliverySnapshotTest
deviation_4d_CUSTOMS_1a_CargoIsInDestinationPort();
UnitOfWork uow = uowf.currentUnitOfWork();
- HandlingEventsEntity HANDLING_EVENTS = uow.get( HandlingEventsEntity.class, HandlingEventsEntity.HANDLING_EVENTS_ID );
+ HandlingEvents HANDLING_EVENTS = uow.get( HandlingEvents.class, HandlingEvents.HANDLING_EVENTS_ID );
// Cargo was claimed but not at destination location
HandlingEvent handlingEvent = HANDLING_EVENTS.createHandlingEvent( day( 1 ), day( 16 ), trackingId, CLAIM, HELSINKI, null );
@@ -651,7 +650,7 @@ public class BuildDeliverySnapshotTest
deviation_4e_CLAIM_1a_CargoIsNotInDestinationPort();
UnitOfWork uow = uowf.currentUnitOfWork();
- HandlingEventsEntity HANDLING_EVENTS = uow.get( HandlingEventsEntity.class, HandlingEventsEntity.HANDLING_EVENTS_ID );
+ HandlingEvents HANDLING_EVENTS = uow.get( HandlingEvents.class, HandlingEvents.HANDLING_EVENTS_ID );
// Cargo was claimed by customer at destination location
HandlingEvent handlingEvent = HANDLING_EVENTS.createHandlingEvent( day( 16 ), day( 16 ), trackingId, CLAIM, STOCKHOLM, null );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/handling/InspectCargoTest.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/handling/InspectCargoTest.java b/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/handling/InspectCargoTest.java
index 2e5fba3..0a05b2d 100644
--- a/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/handling/InspectCargoTest.java
+++ b/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/handling/InspectCargoTest.java
@@ -20,14 +20,13 @@
package org.apache.zest.sample.dcicargo.sample_a.context.shipping.handling;
import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
+import org.apache.zest.sample.dcicargo.sample_a.data.shipping.handling.HandlingEvents;
import org.junit.Before;
import org.junit.Test;
import org.apache.zest.api.unitofwork.UnitOfWork;
import org.apache.zest.sample.dcicargo.sample_a.bootstrap.test.TestApplication;
import org.apache.zest.sample.dcicargo.sample_a.context.shipping.booking.BookNewCargo;
import org.apache.zest.sample.dcicargo.sample_a.context.shipping.booking.BuildDeliverySnapshot;
-import org.apache.zest.sample.dcicargo.sample_a.data.entity.CargosEntity;
-import org.apache.zest.sample.dcicargo.sample_a.data.entity.HandlingEventsEntity;
import org.apache.zest.sample.dcicargo.sample_a.data.shipping.cargo.Cargo;
import org.apache.zest.sample.dcicargo.sample_a.data.shipping.cargo.Cargos;
import org.apache.zest.sample.dcicargo.sample_a.data.shipping.cargo.TrackingId;
@@ -66,7 +65,7 @@ public class InspectCargoTest
{
uowf = module.unitOfWorkFactory();
UnitOfWork uow = uowf.currentUnitOfWork();
- Cargos CARGOS = uow.get( Cargos.class, CargosEntity.CARGOS_ID );
+ Cargos CARGOS = uow.get( Cargos.class, Cargos.CARGOS_ID );
Location HONGKONG = uow.get( Location.class, CNHKG.code().get() );
SHANGHAI = uow.get( Location.class, CNSHA.code().get() );
STOCKHOLM = uow.get( Location.class, SESTO.code().get() );
@@ -95,7 +94,7 @@ public class InspectCargoTest
{
// Create misdirected handling event for cargo (receipt in Shanghai is unexpected)
UnitOfWork uow = uowf.currentUnitOfWork();
- HandlingEventsEntity HANDLING_EVENTS = uow.get( HandlingEventsEntity.class, HandlingEventsEntity.HANDLING_EVENTS_ID );
+ HandlingEvents HANDLING_EVENTS = uow.get( HandlingEvents.class, HandlingEvents.HANDLING_EVENTS_ID );
handlingEvent = HANDLING_EVENTS.createHandlingEvent( day( 0 ), day( 0 ), trackingId, HandlingEventType.RECEIVE, SHANGHAI, null );
Delivery delivery = new BuildDeliverySnapshot( cargo, handlingEvent ).get();
cargo.delivery().set( delivery );
@@ -112,7 +111,7 @@ public class InspectCargoTest
throws Exception
{
UnitOfWork uow = uowf.currentUnitOfWork();
- HandlingEventsEntity HANDLING_EVENTS = uow.get( HandlingEventsEntity.class, HandlingEventsEntity.HANDLING_EVENTS_ID );
+ HandlingEvents HANDLING_EVENTS = uow.get( HandlingEvents.class, HandlingEvents.HANDLING_EVENTS_ID );
handlingEvent = HANDLING_EVENTS.createHandlingEvent( day( 15 ), day( 15 ), trackingId, HandlingEventType.UNLOAD, STOCKHOLM, V300A );
Delivery delivery = new BuildDeliverySnapshot( cargo, handlingEvent ).get();
cargo.delivery().set( delivery );
@@ -130,7 +129,7 @@ public class InspectCargoTest
{
logger.info( " Handling cargo 'ABC' (unloaded in Dallas):" );
UnitOfWork uow = uowf.currentUnitOfWork();
- HandlingEventsEntity HANDLING_EVENTS = uow.get( HandlingEventsEntity.class, HandlingEventsEntity.HANDLING_EVENTS_ID );
+ HandlingEvents HANDLING_EVENTS = uow.get( HandlingEvents.class, HandlingEvents.HANDLING_EVENTS_ID );
handlingEvent = HANDLING_EVENTS.createHandlingEvent( day( 12 ), day( 12 ), trackingId, HandlingEventType.UNLOAD, DALLAS, V200T );
cargo.delivery().set( new BuildDeliverySnapshot( cargo, handlingEvent ).get() );
assertThat( cargo.delivery().get().isMisdirected().get(), is( equalTo( false ) ) );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/handling/RegisterHandlingEventTest.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/handling/RegisterHandlingEventTest.java b/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/handling/RegisterHandlingEventTest.java
index 416c3ab..0f3e992 100644
--- a/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/handling/RegisterHandlingEventTest.java
+++ b/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/handling/RegisterHandlingEventTest.java
@@ -25,7 +25,6 @@ import org.junit.Test;
import org.apache.zest.api.unitofwork.UnitOfWork;
import org.apache.zest.sample.dcicargo.sample_a.bootstrap.test.TestApplication;
import org.apache.zest.sample.dcicargo.sample_a.context.shipping.booking.BookNewCargo;
-import org.apache.zest.sample.dcicargo.sample_a.data.entity.CargosEntity;
import org.apache.zest.sample.dcicargo.sample_a.data.shipping.cargo.Cargo;
import org.apache.zest.sample.dcicargo.sample_a.data.shipping.cargo.Cargos;
import org.apache.zest.sample.dcicargo.sample_a.data.shipping.cargo.TrackingId;
@@ -67,7 +66,7 @@ public class RegisterHandlingEventTest
@Before
public void beforeEachTest() throws Exception {
UnitOfWork uow = module.unitOfWorkFactory().currentUnitOfWork();
- CARGOS = uow.get(Cargos.class, CargosEntity.CARGOS_ID );
+ CARGOS = uow.get(Cargos.class, Cargos.CARGOS_ID );
HONGKONG = uow.get( Location.class, CNHKG.code().get() );
STOCKHOLM = uow.get( Location.class, SESTO.code().get() );
NEWYORK = uow.get( Location.class, USNYC.code().get() );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/samples/dci-cargo/dcisample_b/build.gradle
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/build.gradle b/samples/dci-cargo/dcisample_b/build.gradle
index 4ea96e4..3b7b63c 100644
--- a/samples/dci-cargo/dcisample_b/build.gradle
+++ b/samples/dci-cargo/dcisample_b/build.gradle
@@ -26,7 +26,6 @@ dependencies {
compile project( ':org.apache.zest.core:org.apache.zest.core.bootstrap' )
compile project( ':org.apache.zest.libraries:org.apache.zest.library.constraints' )
- compile project( ':org.apache.zest.libraries:org.apache.zest.library.conversion' )
compile project( ':org.apache.zest.extensions:org.apache.zest.extension.valueserialization-orgjson' )
compile project( ':org.apache.zest.extensions:org.apache.zest.extension.indexing-rdf' )
compile project( ':org.apache.zest.tools:org.apache.zest.tool.envisage' )
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/bootstrap/assembly/Assembler.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/bootstrap/assembly/Assembler.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/bootstrap/assembly/Assembler.java
index 6e1a15c..6e3bf76 100644
--- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/bootstrap/assembly/Assembler.java
+++ b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/bootstrap/assembly/Assembler.java
@@ -41,10 +41,6 @@ import org.apache.zest.sample.dcicargo.sample_b.bootstrap.DCISampleApplication_b
import org.apache.zest.sample.dcicargo.sample_b.bootstrap.sampledata.BaseDataService;
import org.apache.zest.sample.dcicargo.sample_b.bootstrap.sampledata.SampleDataService;
import org.apache.zest.sample.dcicargo.sample_b.communication.query.BookingQueries;
-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.communication.query.dto.LocationDTO;
-import org.apache.zest.sample.dcicargo.sample_b.communication.query.dto.VoyageDTO;
import org.apache.zest.sample.dcicargo.sample_b.context.interaction.handling.ProcessHandlingEvent;
import org.apache.zest.sample.dcicargo.sample_b.context.interaction.handling.parsing.ParseHandlingEventData;
import org.apache.zest.sample.dcicargo.sample_b.context.interaction.handling.parsing.dto.ParsedHandlingEventData;
@@ -52,21 +48,21 @@ import org.apache.zest.sample.dcicargo.sample_b.context.rolemap.CargoRoleMap;
import org.apache.zest.sample.dcicargo.sample_b.context.rolemap.CargosRoleMap;
import org.apache.zest.sample.dcicargo.sample_b.context.rolemap.HandlingEventsRoleMap;
import org.apache.zest.sample.dcicargo.sample_b.context.service.routing.RoutingService;
-import org.apache.zest.sample.dcicargo.sample_b.data.entity.HandlingEventEntity;
-import org.apache.zest.sample.dcicargo.sample_b.data.entity.LocationEntity;
-import org.apache.zest.sample.dcicargo.sample_b.data.entity.VoyageEntity;
import org.apache.zest.sample.dcicargo.sample_b.data.factory.RouteSpecificationFactoryService;
+import org.apache.zest.sample.dcicargo.sample_b.data.structure.cargo.Cargo;
import org.apache.zest.sample.dcicargo.sample_b.data.structure.cargo.RouteSpecification;
import org.apache.zest.sample.dcicargo.sample_b.data.structure.delivery.Delivery;
import org.apache.zest.sample.dcicargo.sample_b.data.structure.delivery.NextHandlingEvent;
+import org.apache.zest.sample.dcicargo.sample_b.data.structure.handling.HandlingEvent;
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 org.apache.zest.sample.dcicargo.sample_b.data.structure.location.Location;
import org.apache.zest.sample.dcicargo.sample_b.data.structure.location.UnLocode;
import org.apache.zest.sample.dcicargo.sample_b.data.structure.tracking.TrackingId;
import org.apache.zest.sample.dcicargo.sample_b.data.structure.voyage.CarrierMovement;
import org.apache.zest.sample.dcicargo.sample_b.data.structure.voyage.Schedule;
+import org.apache.zest.sample.dcicargo.sample_b.data.structure.voyage.Voyage;
import org.apache.zest.sample.dcicargo.sample_b.data.structure.voyage.VoyageNumber;
-import org.apache.zest.sample.dcicargo.sample_b.infrastructure.conversion.EntityToDTOService;
import org.apache.zest.spi.uuid.UuidIdentityGeneratorService;
import org.apache.zest.valueserialization.orgjson.OrgJsonValueSerializationService;
@@ -171,21 +167,15 @@ public class Assembler
ModuleAssembly queryModule = communicationLayer.module( "COMMUNICATION-Query" );
queryModule
.values(
- CargoDTO.class,
- LocationDTO.class,
- HandlingEventDTO.class,
- VoyageDTO.class );
+ Cargo.class,
+ Location.class,
+ HandlingEvent.class,
+ Voyage.class );
queryModule
.transients(
BookingQueries.class )
.visibleIn( application );
-
- queryModule
- .addServices(
- EntityToDTOService.class,
- OrgJsonValueSerializationService.class )
- .visibleIn( application );
}
private void assembleContextLayer( LayerAssembly contextLayer )
@@ -202,9 +192,9 @@ public class Assembler
ModuleAssembly roleMapCandidatesModule = contextLayer.module( "CONTEXT-RoleMapCandidates" );
roleMapCandidatesModule
.entities(
- HandlingEventEntity.class,
- LocationEntity.class,
- VoyageEntity.class )
+ HandlingEvent.class,
+ Location.class,
+ Voyage.class )
.visibleIn( application );
roleMapCandidatesModule
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/query/CommonQueries.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/query/CommonQueries.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/query/CommonQueries.java
index a4c61ca..0b61115 100644
--- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/query/CommonQueries.java
+++ b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/query/CommonQueries.java
@@ -24,8 +24,7 @@ import java.util.List;
import org.apache.wicket.model.IModel;
import org.apache.zest.api.query.Query;
import org.apache.zest.api.query.QueryBuilder;
-import org.apache.zest.sample.dcicargo.sample_b.communication.query.dto.CargoDTO;
-import org.apache.zest.sample.dcicargo.sample_b.data.entity.CargoEntity;
+import org.apache.zest.sample.dcicargo.sample_b.data.structure.cargo.Cargo;
import org.apache.zest.sample.dcicargo.sample_b.data.structure.location.Location;
import org.apache.zest.sample.dcicargo.sample_b.infrastructure.model.EntityModel;
import org.apache.zest.sample.dcicargo.sample_b.infrastructure.model.Queries;
@@ -43,20 +42,20 @@ import static org.apache.zest.api.query.QueryExpressions.templateFor;
*/
public class CommonQueries extends Queries
{
- public IModel<CargoDTO> cargo( String trackingId )
+ public IModel<Cargo> cargo( String trackingId )
{
- return EntityModel.of( CargoEntity.class, trackingId, CargoDTO.class );
+ return EntityModel.of( Cargo.class, trackingId, Cargo.class );
}
- public IModel<List<CargoDTO>> cargoList()
+ public IModel<List<Cargo>> cargoList()
{
- return new QueryModel<CargoDTO, CargoEntity>( CargoDTO.class )
+ return new QueryModel<Cargo>( Cargo.class )
{
- public Query<CargoEntity> getQuery()
+ public Query<Cargo> getQuery()
{
- QueryBuilder<CargoEntity> qb = qbf.newQueryBuilder( CargoEntity.class );
+ QueryBuilder<Cargo> qb = qbf.newQueryBuilder( Cargo.class );
return uowf.currentUnitOfWork().newQuery( qb )
- .orderBy( orderBy( templateFor( CargoEntity.class ).trackingId().get().id() ) );
+ .orderBy( orderBy( templateFor( Cargo.class ).trackingId().get().id() ) );
}
};
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/query/HandlingQueries.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/query/HandlingQueries.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/query/HandlingQueries.java
index e3285a6..3eb9ea2 100644
--- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/query/HandlingQueries.java
+++ b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/query/HandlingQueries.java
@@ -23,7 +23,7 @@ import java.util.ArrayList;
import java.util.List;
import org.apache.zest.api.query.Query;
import org.apache.zest.api.query.QueryBuilder;
-import org.apache.zest.sample.dcicargo.sample_b.data.entity.CargoEntity;
+import org.apache.zest.sample.dcicargo.sample_b.data.structure.cargo.Cargo;
import org.apache.zest.sample.dcicargo.sample_b.data.structure.handling.HandlingEventType;
import org.apache.zest.sample.dcicargo.sample_b.data.structure.voyage.Voyage;
import org.apache.zest.sample.dcicargo.sample_b.infrastructure.model.Queries;
@@ -54,11 +54,11 @@ public class HandlingQueries extends Queries
public List<String> cargoIds()
{
- QueryBuilder<CargoEntity> qb = qbf.newQueryBuilder( CargoEntity.class );
- Query<CargoEntity> cargos = uowf.currentUnitOfWork().newQuery( qb )
- .orderBy( orderBy( templateFor( CargoEntity.class ).trackingId().get().id() ) );
- List<String> cargoList = new ArrayList<String>();
- for( CargoEntity cargo : cargos )
+ QueryBuilder<Cargo> qb = qbf.newQueryBuilder( Cargo.class );
+ Query<Cargo> cargos = uowf.currentUnitOfWork().newQuery( qb )
+ .orderBy( orderBy( templateFor( Cargo.class ).trackingId().get().id() ) );
+ List<String> cargoList = new ArrayList<>();
+ for( Cargo cargo : cargos )
{
cargoList.add( cargo.trackingId().get().id().get() );
}
@@ -67,7 +67,7 @@ public class HandlingQueries extends Queries
public List<String> eventTypes()
{
- List<String> eventTypes = new ArrayList<String>();
+ List<String> eventTypes = new ArrayList<>();
for( HandlingEventType eventType : HandlingEventType.values() )
{
eventTypes.add( eventType.name() );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/query/TrackingQueries.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/query/TrackingQueries.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/query/TrackingQueries.java
index ae4a1e8..fce2557 100644
--- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/query/TrackingQueries.java
+++ b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/query/TrackingQueries.java
@@ -25,9 +25,6 @@ import org.apache.wicket.model.IModel;
import org.apache.zest.api.query.Query;
import org.apache.zest.api.query.QueryBuilder;
import org.apache.zest.api.query.QueryExpressions;
-import org.apache.zest.sample.dcicargo.sample_b.communication.query.dto.HandlingEventDTO;
-import org.apache.zest.sample.dcicargo.sample_b.data.entity.CargoEntity;
-import org.apache.zest.sample.dcicargo.sample_b.data.entity.HandlingEventEntity;
import org.apache.zest.sample.dcicargo.sample_b.data.structure.cargo.Cargo;
import org.apache.zest.sample.dcicargo.sample_b.data.structure.handling.HandlingEvent;
import org.apache.zest.sample.dcicargo.sample_b.infrastructure.model.Queries;
@@ -44,15 +41,15 @@ public class TrackingQueries extends Queries
{
public List<String> routedCargos()
{
- Cargo cargoEntity = templateFor( CargoEntity.class );
+ Cargo cargoEntity = templateFor( Cargo.class );
- QueryBuilder<CargoEntity> qb = qbf.newQueryBuilder( CargoEntity.class )
+ QueryBuilder<Cargo> qb = qbf.newQueryBuilder( Cargo.class )
.where( isNotNull( cargoEntity.itinerary() ) );
- Query<CargoEntity> cargos = uowf.currentUnitOfWork().newQuery( qb )
+ Query<Cargo> cargos = uowf.currentUnitOfWork().newQuery( qb )
.orderBy( orderBy( cargoEntity.trackingId().get().id() ) );
List<String> cargoList = new ArrayList<String>();
- for( CargoEntity cargo : cargos )
+ for( Cargo cargo : cargos )
{
cargoList.add( cargo.trackingId().get().id().get() );
}
@@ -60,15 +57,15 @@ public class TrackingQueries extends Queries
return cargoList;
}
- public IModel<List<HandlingEventDTO>> events( final String trackingIdString )
+ public IModel<List<HandlingEvent>> events( final String trackingIdString )
{
- return new QueryModel<HandlingEventDTO, HandlingEventEntity>( HandlingEventDTO.class )
+ return new QueryModel<HandlingEvent>( HandlingEvent.class )
{
- public Query<HandlingEventEntity> getQuery()
+ public Query<HandlingEvent> getQuery()
{
HandlingEvent eventTemplate = templateFor( HandlingEvent.class );
- QueryBuilder<HandlingEventEntity> qb = qbf.newQueryBuilder( HandlingEventEntity.class )
+ QueryBuilder<HandlingEvent> qb = qbf.newQueryBuilder( HandlingEvent.class )
.where( QueryExpressions.eq( eventTemplate.trackingId().get().id(), trackingIdString ) );
return uowf.currentUnitOfWork().newQuery( qb )
.orderBy( orderBy( eventTemplate.completionDate() ) );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/query/dto/CargoDTO.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/query/dto/CargoDTO.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/query/dto/CargoDTO.java
deleted file mode 100644
index 955c3fc..0000000
--- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/query/dto/CargoDTO.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-package org.apache.zest.sample.dcicargo.sample_b.communication.query.dto;
-
-import org.apache.zest.api.common.Optional;
-import org.apache.zest.api.property.Property;
-import org.apache.zest.library.conversion.values.Unqualified;
-import org.apache.zest.sample.dcicargo.sample_b.data.structure.cargo.Cargo;
-import org.apache.zest.sample.dcicargo.sample_b.data.structure.cargo.RouteSpecification;
-import org.apache.zest.sample.dcicargo.sample_b.data.structure.delivery.Delivery;
-import org.apache.zest.sample.dcicargo.sample_b.data.structure.itinerary.Itinerary;
-import org.apache.zest.sample.dcicargo.sample_b.data.structure.tracking.TrackingId;
-import org.apache.zest.sample.dcicargo.sample_b.infrastructure.conversion.DTO;
-
-/**
- * Cargo DTO
- *
- * Zest-comment:
- * We need the @Unqualified annotation since the CargoDTO interface has other properties than {@link Cargo}
- * so that properties can not be directly mapped when we convert from entity to immutable value DTO.
- * With the annotation, property access methods are compared by name instead.
- *
- * @see Cargo
- */
-@Unqualified
-public interface CargoDTO extends DTO
-{
- Property<TrackingId> trackingId();
-
- // Associated Location entity in Cargo is converted to an immutable LocationDTO value object
- Property<LocationDTO> origin();
-
- Property<RouteSpecification> routeSpecification();
-
- Property<Delivery> delivery();
-
- @Optional
- Property<Itinerary> itinerary();
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/zest-java/blob/4275718c/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/query/dto/HandlingEventDTO.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/query/dto/HandlingEventDTO.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/query/dto/HandlingEventDTO.java
deleted file mode 100644
index 8f96aed..0000000
--- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/query/dto/HandlingEventDTO.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-package org.apache.zest.sample.dcicargo.sample_b.communication.query.dto;
-
-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;
-import org.apache.zest.sample.dcicargo.sample_b.data.structure.handling.HandlingEvent;
-import org.apache.zest.sample.dcicargo.sample_b.data.structure.handling.HandlingEventType;
-import org.apache.zest.sample.dcicargo.sample_b.data.structure.tracking.TrackingId;
-import org.apache.zest.sample.dcicargo.sample_b.infrastructure.conversion.DTO;
-
-/**
- * HandlingEvent DTO
- *
- * Zest-comment:
- * We need the @Unqualified annotation since the HandlingEventDTO interface has other properties than
- * {@link HandlingEvent} so that properties can not be directly mapped when we convert from entity to
- * immutable value DTO. With the annotation, property access methods are compared by name instead.
- */
-@Unqualified
-public interface HandlingEventDTO extends DTO
-{
- Property<LocalDate> completionDate();
-
- Property<TrackingId> trackingId();
-
- Property<HandlingEventType> handlingEventType();
-
- Property<LocationDTO> location();
-
- @Optional
- Property<VoyageDTO> voyage();
-}
[25/25] zest-java git commit: ZEST-156 - introducing a new Value
Serialization system
Posted by ni...@apache.org.
ZEST-156 - introducing a new Value Serialization system
Project: http://git-wip-us.apache.org/repos/asf/zest-java/repo
Commit: http://git-wip-us.apache.org/repos/asf/zest-java/commit/301f837d
Tree: http://git-wip-us.apache.org/repos/asf/zest-java/tree/301f837d
Diff: http://git-wip-us.apache.org/repos/asf/zest-java/diff/301f837d
Branch: refs/heads/ValueSerializationCleaning
Commit: 301f837df0e89f6966f56a953870d92816dad87e
Parents: 0e78cbc
Author: Niclas Hedhman <ni...@hedhman.org>
Authored: Fri Jul 22 18:54:55 2016 +0800
Committer: Niclas Hedhman <ni...@hedhman.org>
Committed: Fri Jul 22 18:54:55 2016 +0800
----------------------------------------------------------------------
.../java/org/apache/zest/api/type/MapType.java | 1 -
.../spi/value/BooleanClassDeserializer.java | 70 +++++
.../java/org/apache/zest/spi/value/Entry.java | 63 ++++
.../value/IllegalDeserializationException.java | 31 ++
.../org/apache/zest/spi/value/ObjectField.java | 63 ++++
.../apache/zest/spi/value/ParserLocation.java | 41 +++
.../apache/zest/spi/value/TypeDeserializer.java | 40 +++
.../value/ValueDeserializationException.java | 33 +++
.../index/rdf/query/RdfQueryParserFactory.java | 8 +-
.../rdf/query/internal/RdfQueryParserImpl.java | 4 +-
.../jackson/JacksonDeserializer.java | 239 +++++++++++++++
.../jackson/JacksonDeserializerTest.java | 293 +++++++++++++++++++
12 files changed, 876 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/zest-java/blob/301f837d/core/api/src/main/java/org/apache/zest/api/type/MapType.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/type/MapType.java b/core/api/src/main/java/org/apache/zest/api/type/MapType.java
index c76fd60..ace1fca 100644
--- a/core/api/src/main/java/org/apache/zest/api/type/MapType.java
+++ b/core/api/src/main/java/org/apache/zest/api/type/MapType.java
@@ -30,7 +30,6 @@ import org.apache.zest.api.util.Classes;
public final class MapType
extends ValueType
{
-
private ValueType keyType;
private ValueType valueType;
http://git-wip-us.apache.org/repos/asf/zest-java/blob/301f837d/core/spi/src/main/java/org/apache/zest/spi/value/BooleanClassDeserializer.java
----------------------------------------------------------------------
diff --git a/core/spi/src/main/java/org/apache/zest/spi/value/BooleanClassDeserializer.java b/core/spi/src/main/java/org/apache/zest/spi/value/BooleanClassDeserializer.java
new file mode 100644
index 0000000..0420672
--- /dev/null
+++ b/core/spi/src/main/java/org/apache/zest/spi/value/BooleanClassDeserializer.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ */
+
+package org.apache.zest.spi.value;
+
+import java.lang.reflect.Type;
+import java.util.List;
+
+public class BooleanClassDeserializer
+ implements TypeDeserializer<Boolean>
+{
+
+ @Override
+ public Boolean deserialize( Class<? extends Boolean> type, VDA parent, Object parser )
+ throws Exception
+ {
+ Object value = parent.nextValue( parser );
+ if( value instanceof String )
+ {
+ return Boolean.valueOf( (String) value );
+ }
+ if( value instanceof Boolean )
+ {
+ return (Boolean) value;
+ }
+ throw new IllegalDeserializationException( "Boolean value expected.", parent.location(parser) );
+ }
+
+ @Override
+ public Boolean deserialize( Class<? extends Boolean> type, VDA parent, String stringValue )
+ throws Exception
+ {
+ return Boolean.valueOf( stringValue );
+ }
+
+ @Override
+ public List<String> fieldNames( Class<?> type )
+ {
+ return null;
+ }
+
+ @Override
+ public Class<?> fieldTypeOf( Type parent, String fieldName )
+ {
+ return null;
+ }
+
+ @Override
+ public Boolean createObject( Object data )
+ {
+ return null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/301f837d/core/spi/src/main/java/org/apache/zest/spi/value/Entry.java
----------------------------------------------------------------------
diff --git a/core/spi/src/main/java/org/apache/zest/spi/value/Entry.java b/core/spi/src/main/java/org/apache/zest/spi/value/Entry.java
new file mode 100644
index 0000000..0362abd
--- /dev/null
+++ b/core/spi/src/main/java/org/apache/zest/spi/value/Entry.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ */
+
+package org.apache.zest.spi.value;
+
+import java.util.Objects;
+
+public class Entry<K, V>
+{
+ public final K key;
+ public final V value;
+
+ public Entry( K key, V value )
+ {
+ this.key = key;
+ this.value = value;
+ }
+
+ @Override
+ public boolean equals( Object o )
+ {
+ if( this == o )
+ {
+ return true;
+ }
+ if( !( o instanceof Entry ) )
+ {
+ return false;
+ }
+ Entry<?, ?> entry = (Entry<?, ?>) o;
+ return Objects.equals( key, entry.key ) &&
+ Objects.equals( value, entry.value );
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return Objects.hash( key, value );
+ }
+
+ @Override
+ public String toString()
+ {
+ return key + ":" + value;
+ }
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/301f837d/core/spi/src/main/java/org/apache/zest/spi/value/IllegalDeserializationException.java
----------------------------------------------------------------------
diff --git a/core/spi/src/main/java/org/apache/zest/spi/value/IllegalDeserializationException.java b/core/spi/src/main/java/org/apache/zest/spi/value/IllegalDeserializationException.java
new file mode 100644
index 0000000..7bd8dc0
--- /dev/null
+++ b/core/spi/src/main/java/org/apache/zest/spi/value/IllegalDeserializationException.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ */
+
+package org.apache.zest.spi.value;
+
+import org.apache.zest.api.value.ValueSerializationException;
+
+public class IllegalDeserializationException extends ValueDeserializationException
+{
+ public IllegalDeserializationException( String message, ParserLocation location )
+ {
+ super( message + " at " + location );
+ }
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/301f837d/core/spi/src/main/java/org/apache/zest/spi/value/ObjectField.java
----------------------------------------------------------------------
diff --git a/core/spi/src/main/java/org/apache/zest/spi/value/ObjectField.java b/core/spi/src/main/java/org/apache/zest/spi/value/ObjectField.java
new file mode 100644
index 0000000..17ecfe7
--- /dev/null
+++ b/core/spi/src/main/java/org/apache/zest/spi/value/ObjectField.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ */
+
+package org.apache.zest.spi.value;
+
+import java.util.Objects;
+
+public class ObjectField<V>
+{
+ public final String name;
+ public final V value;
+
+ public ObjectField( String name, V value )
+ {
+ this.name = name;
+ this.value = value;
+ }
+
+ @Override
+ public boolean equals( Object o )
+ {
+ if( this == o )
+ {
+ return true;
+ }
+ if( !( o instanceof ObjectField ) )
+ {
+ return false;
+ }
+ ObjectField<?> field = (ObjectField<?>) o;
+ return Objects.equals( name, field.name ) &&
+ Objects.equals( value, field.value );
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return Objects.hash( name, value );
+ }
+
+ @Override
+ public String toString()
+ {
+ return name + ':' + value;
+ }
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/301f837d/core/spi/src/main/java/org/apache/zest/spi/value/ParserLocation.java
----------------------------------------------------------------------
diff --git a/core/spi/src/main/java/org/apache/zest/spi/value/ParserLocation.java b/core/spi/src/main/java/org/apache/zest/spi/value/ParserLocation.java
new file mode 100644
index 0000000..e00483a
--- /dev/null
+++ b/core/spi/src/main/java/org/apache/zest/spi/value/ParserLocation.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ */
+
+package org.apache.zest.spi.value;
+
+public class ParserLocation
+{
+ public final String info;
+ public final int line;
+ public final int column;
+
+ public ParserLocation( String info, int line, int column )
+ {
+ this.info = info;
+ this.line = line;
+ this.column = column;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "'" + info + "' " + line + ":" + column;
+ }
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/301f837d/core/spi/src/main/java/org/apache/zest/spi/value/TypeDeserializer.java
----------------------------------------------------------------------
diff --git a/core/spi/src/main/java/org/apache/zest/spi/value/TypeDeserializer.java b/core/spi/src/main/java/org/apache/zest/spi/value/TypeDeserializer.java
new file mode 100644
index 0000000..e9db38f
--- /dev/null
+++ b/core/spi/src/main/java/org/apache/zest/spi/value/TypeDeserializer.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ */
+
+package org.apache.zest.spi.value;
+
+import java.lang.reflect.Type;
+import java.util.List;
+import java.util.Map;
+
+public interface TypeDeserializer<T>
+{
+ T deserialize( Class<? extends T> type, VDA parent, Object parser )
+ throws Exception;
+
+ T deserialize( Class<? extends T> type, VDA parent, String stringValue )
+ throws Exception;
+
+ List<String> fieldNames( Class<?> type );
+
+ Class<?> fieldTypeOf( Type parent, String fieldName );
+
+ T createObject( Object data );
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/301f837d/core/spi/src/main/java/org/apache/zest/spi/value/ValueDeserializationException.java
----------------------------------------------------------------------
diff --git a/core/spi/src/main/java/org/apache/zest/spi/value/ValueDeserializationException.java b/core/spi/src/main/java/org/apache/zest/spi/value/ValueDeserializationException.java
new file mode 100644
index 0000000..c4ddf20
--- /dev/null
+++ b/core/spi/src/main/java/org/apache/zest/spi/value/ValueDeserializationException.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ */
+
+package org.apache.zest.spi.value;
+
+public class ValueDeserializationException extends RuntimeException
+{
+ public ValueDeserializationException( String message )
+ {
+ super( message );
+ }
+
+ public ValueDeserializationException( String message, Exception cause )
+ {
+ }
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/301f837d/extensions/indexing-rdf/src/main/java/org/apache/zest/index/rdf/query/RdfQueryParserFactory.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-rdf/src/main/java/org/apache/zest/index/rdf/query/RdfQueryParserFactory.java b/extensions/indexing-rdf/src/main/java/org/apache/zest/index/rdf/query/RdfQueryParserFactory.java
index f89ff68..a3bfc6b 100644
--- a/extensions/indexing-rdf/src/main/java/org/apache/zest/index/rdf/query/RdfQueryParserFactory.java
+++ b/extensions/indexing-rdf/src/main/java/org/apache/zest/index/rdf/query/RdfQueryParserFactory.java
@@ -20,9 +20,7 @@
package org.apache.zest.index.rdf.query;
-import org.openrdf.query.QueryLanguage;
import org.apache.zest.api.injection.scope.Service;
-import org.apache.zest.api.injection.scope.Structure;
import org.apache.zest.api.mixin.Mixins;
import org.apache.zest.api.service.ServiceComposite;
import org.apache.zest.api.service.qualifier.Tagged;
@@ -30,7 +28,7 @@ import org.apache.zest.api.value.ValueSerialization;
import org.apache.zest.api.value.ValueSerializer;
import org.apache.zest.index.rdf.UnsupportedLanguageException;
import org.apache.zest.index.rdf.query.internal.RdfQueryParserImpl;
-import org.apache.zest.spi.ZestSPI;
+import org.openrdf.query.QueryLanguage;
@Mixins( RdfQueryParserFactory.RdfQueryParserFactoryMixin.class )
public interface RdfQueryParserFactory
@@ -41,8 +39,6 @@ public interface RdfQueryParserFactory
abstract class RdfQueryParserFactoryMixin
implements RdfQueryParserFactory
{
- @Structure
- private ZestSPI spi;
@Service
@Tagged( ValueSerialization.Formats.JSON )
private ValueSerializer valueSerializer;
@@ -52,7 +48,7 @@ public interface RdfQueryParserFactory
{
if( language.equals( QueryLanguage.SPARQL ) )
{
- return new RdfQueryParserImpl( spi, valueSerializer );
+ return new RdfQueryParserImpl( valueSerializer );
}
throw new UnsupportedLanguageException( language );
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/301f837d/extensions/indexing-rdf/src/main/java/org/apache/zest/index/rdf/query/internal/RdfQueryParserImpl.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-rdf/src/main/java/org/apache/zest/index/rdf/query/internal/RdfQueryParserImpl.java b/extensions/indexing-rdf/src/main/java/org/apache/zest/index/rdf/query/internal/RdfQueryParserImpl.java
index e79178f..f453d71 100644
--- a/extensions/indexing-rdf/src/main/java/org/apache/zest/index/rdf/query/internal/RdfQueryParserImpl.java
+++ b/extensions/indexing-rdf/src/main/java/org/apache/zest/index/rdf/query/internal/RdfQueryParserImpl.java
@@ -74,7 +74,6 @@ public class RdfQueryParserImpl
private final Namespaces namespaces = new Namespaces();
private final Triples triples = new Triples( namespaces );
- private final ZestSPI spi;
private final ValueSerializer valueSerializer;
private Map<String, Object> variables;
@@ -93,9 +92,8 @@ public class RdfQueryParserImpl
) );
}
- public RdfQueryParserImpl( ZestSPI spi, ValueSerializer valueSerializer )
+ public RdfQueryParserImpl( ValueSerializer valueSerializer )
{
- this.spi = spi;
this.valueSerializer = valueSerializer;
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/301f837d/extensions/valueserialization-jackson/src/main/java/org/apache/zest/valueserialization/jackson/JacksonDeserializer.java
----------------------------------------------------------------------
diff --git a/extensions/valueserialization-jackson/src/main/java/org/apache/zest/valueserialization/jackson/JacksonDeserializer.java b/extensions/valueserialization-jackson/src/main/java/org/apache/zest/valueserialization/jackson/JacksonDeserializer.java
new file mode 100644
index 0000000..08474ab
--- /dev/null
+++ b/extensions/valueserialization-jackson/src/main/java/org/apache/zest/valueserialization/jackson/JacksonDeserializer.java
@@ -0,0 +1,239 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ */
+
+package org.apache.zest.valueserialization.jackson;
+
+import com.fasterxml.jackson.core.JsonFactory;
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.JsonToken;
+import java.io.InputStream;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.apache.zest.spi.value.Entry;
+import org.apache.zest.spi.value.ObjectField;
+import org.apache.zest.spi.value.ParserLocation;
+import org.apache.zest.spi.value.VDA;
+
+public class JacksonDeserializer extends VDA<JsonParser>
+{
+ private final JsonFactory jsonFactory = new JsonFactory();
+
+ @Override
+ protected JsonParser adaptInput( InputStream input )
+ throws Exception
+ {
+ return jsonFactory.createParser( input );
+ }
+
+ @Override
+ protected <T> T readPlainValue( Class<T> type, JsonParser jsonParser )
+ throws Exception
+ {
+ JsonToken currentToken = jsonParser.nextValue();
+ if( type.equals( Boolean.class ) || type.equals( Boolean.TYPE ) )
+ {
+ if( currentToken == JsonToken.VALUE_TRUE )
+ {
+ return (T) Boolean.TRUE;
+ }
+ if( currentToken == JsonToken.VALUE_FALSE )
+ {
+ return (T) Boolean.FALSE;
+ }
+ return (T) Boolean.valueOf( (String) jsonParser.getCurrentValue() );
+ }
+ if( type.equals( Byte.class ) || type.equals( Byte.TYPE ) )
+ {
+ if( currentToken == JsonToken.VALUE_NUMBER_INT ||
+ currentToken == JsonToken.VALUE_NUMBER_FLOAT )
+ {
+ return (T) Byte.valueOf( (Byte) jsonParser.getCurrentValue() );
+ }
+ return (T) Byte.valueOf( (String) jsonParser.getCurrentValue() );
+ }
+ if( type.equals( Character.class ) || type.equals( Character.TYPE ) )
+ {
+ return (T) Character.valueOf( ( (String) jsonParser.getCurrentValue() ).charAt( 0 ) );
+ }
+ if( type.equals( Short.class ) || type.equals( Short.TYPE ) )
+ {
+ if( currentToken == JsonToken.VALUE_NUMBER_INT ||
+ currentToken == JsonToken.VALUE_NUMBER_FLOAT )
+ {
+ return (T) Short.valueOf( (Byte) jsonParser.getCurrentValue() );
+ }
+ return (T) Short.valueOf( (String) jsonParser.getCurrentValue() );
+ }
+ if( type.equals( Integer.class ) || type.equals( Integer.TYPE ) )
+ {
+ if( currentToken == JsonToken.VALUE_NUMBER_INT ||
+ currentToken == JsonToken.VALUE_NUMBER_FLOAT )
+ {
+ return (T) Integer.valueOf( (Byte) jsonParser.getCurrentValue() );
+ }
+ return (T) Integer.valueOf( (String) jsonParser.getCurrentValue() );
+ }
+ if( type.equals( Long.class ) || type.equals( Long.TYPE ) )
+ {
+ if( currentToken == JsonToken.VALUE_NUMBER_INT ||
+ currentToken == JsonToken.VALUE_NUMBER_FLOAT )
+ {
+ return (T) Long.valueOf( (Byte) jsonParser.getCurrentValue() );
+ }
+ return (T) Long.valueOf( (String) jsonParser.getCurrentValue() );
+ }
+ if( type.equals( Float.class ) || type.equals( Float.TYPE ) )
+ {
+ if( currentToken == JsonToken.VALUE_NUMBER_INT ||
+ currentToken == JsonToken.VALUE_NUMBER_FLOAT )
+ {
+ return (T) Float.valueOf( (Byte) jsonParser.getCurrentValue() );
+ }
+ return (T) Float.valueOf( (String) jsonParser.getCurrentValue() );
+ }
+ if( type.equals( Double.class ) || type.equals( Double.TYPE ) )
+ {
+ if( currentToken == JsonToken.VALUE_NUMBER_INT ||
+ currentToken == JsonToken.VALUE_NUMBER_FLOAT )
+ {
+ return (T) Double.valueOf( (Byte) jsonParser.getCurrentValue() );
+ }
+ return (T) Double.valueOf( (String) jsonParser.getCurrentValue() );
+ }
+ throw new InternalError( "Please contact dev@zest.apache.org." );
+ }
+
+ protected <T> T readObjectValue( Type tType, JsonParser jsonParser )
+ throws Exception
+ {
+ JsonToken currentToken = jsonParser.nextToken();
+ Map<Object, Object> entries = new HashMap<>();
+ if( currentToken == JsonToken.START_OBJECT )
+ {
+ while( currentToken != JsonToken.END_OBJECT )
+ {
+ String fieldName = jsonParser.nextFieldName();
+ Class<?> fieldType = fieldTypeOf( tType, fieldName );
+ Object fieldValue = readObject( fieldType, jsonParser );
+ entries.put( fieldName, fieldValue );
+ currentToken = jsonParser.nextToken();
+ }
+ return createObject( tType, entries );
+ }
+ return null;
+ }
+
+ @Override
+ protected <T> T readArrayValue( Class<T> type, JsonParser jsonParser )
+ throws Exception
+ {
+ JsonToken currentToken = jsonParser.nextToken();
+ List<Object> entries = new ArrayList<>();
+ if( currentToken == JsonToken.START_ARRAY )
+ {
+ while( currentToken != JsonToken.END_ARRAY )
+ {
+ Object fieldValue = readObject( type.getComponentType(), jsonParser );
+ entries.add( fieldValue );
+ currentToken = jsonParser.nextToken();
+ }
+ return createArray( type, entries );
+ }
+ return null;
+ }
+
+ @Override
+ protected <K, V> Map<K, V> readMapValue( Type mapType, JsonParser jsonParser )
+ throws Exception
+ {
+ Type keyType;
+ Type valueType;
+ if( mapType instanceof ParameterizedType )
+ {
+ keyType = ( (ParameterizedType) mapType ).getActualTypeArguments()[ 0 ];
+ valueType = ( (ParameterizedType) mapType ).getActualTypeArguments()[ 1 ];
+ }
+ else
+ {
+ keyType = Object.class;
+ valueType = Object.class;
+ }
+
+ JsonToken currentToken = jsonParser.nextToken();
+ Map<Object, Object> entries = new HashMap<>();
+ if( currentToken == JsonToken.START_OBJECT )
+ {
+ while( currentToken != JsonToken.END_OBJECT )
+ {
+ Object fieldKey = readObject( keyType, jsonParser );
+ Object fieldValue = readObject( valueType, jsonParser );
+ entries.put( fieldKey, fieldValue );
+ currentToken = jsonParser.nextToken();
+ }
+ return createObject(mapType, entries);
+ }
+ return null;
+ }
+
+ @Override
+ protected <T> T readListValue( Type listType, JsonParser jsonParser )
+ throws Exception
+ {
+ return null;
+ }
+
+ @Override
+ protected <T> T readEnumValue( Class<T> type, JsonParser jsonParser )
+ throws Exception
+ {
+ return null;
+ }
+
+ @Override
+ protected ObjectField nextField( JsonParser jsonParser )
+ throws Exception
+ {
+ return null;
+ }
+
+ @Override
+ protected Entry nextEntry( JsonParser jsonParser )
+ throws Exception
+ {
+ return null;
+ }
+
+ @Override
+ protected Object nextValue( JsonParser jsonParser )
+ throws Exception
+ {
+ return null;
+ }
+
+ @Override
+ public ParserLocation location( JsonParser jsonParser )
+ {
+ return null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/301f837d/extensions/valueserialization-jackson/src/test/java/org/apache/zest/valueserialization/jackson/JacksonDeserializerTest.java
----------------------------------------------------------------------
diff --git a/extensions/valueserialization-jackson/src/test/java/org/apache/zest/valueserialization/jackson/JacksonDeserializerTest.java b/extensions/valueserialization-jackson/src/test/java/org/apache/zest/valueserialization/jackson/JacksonDeserializerTest.java
new file mode 100644
index 0000000..2943037
--- /dev/null
+++ b/extensions/valueserialization-jackson/src/test/java/org/apache/zest/valueserialization/jackson/JacksonDeserializerTest.java
@@ -0,0 +1,293 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ */
+
+package org.apache.zest.valueserialization.jackson;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.OffsetDateTime;
+import java.time.ZoneOffset;
+import java.time.ZonedDateTime;
+import org.apache.zest.api.entity.EntityBuilder;
+import org.apache.zest.api.entity.EntityReference;
+import org.apache.zest.api.injection.scope.Service;
+import org.apache.zest.api.property.Property;
+import org.apache.zest.api.unitofwork.UnitOfWork;
+import org.apache.zest.api.usecase.UsecaseBuilder;
+import org.apache.zest.api.value.ValueBuilder;
+import org.apache.zest.api.value.ValueSerialization;
+import org.apache.zest.bootstrap.AssemblyException;
+import org.apache.zest.bootstrap.ModuleAssembly;
+import org.apache.zest.entitystore.memory.MemoryEntityStoreService;
+import org.apache.zest.spi.uuid.UuidIdentityGeneratorService;
+import org.apache.zest.test.AbstractZestTest;
+import org.junit.Test;
+
+import static org.hamcrest.core.IsEqual.equalTo;
+import static org.hamcrest.core.IsNot.not;
+import static org.junit.Assert.assertThat;
+
+public class JacksonDeserializerTest extends AbstractZestTest
+{
+
+ @Service
+ @SuppressWarnings( "ProtectedField" )
+ protected ValueSerialization valueSerialization;
+
+ @Override
+ public void assemble( ModuleAssembly module )
+ throws AssemblyException
+ {
+ module.values( Regression142Type.class );
+ module.entities( Regression142Type.class );
+
+ module.services( MemoryEntityStoreService.class );
+ module.services( UuidIdentityGeneratorService.class );
+ }
+
+ @Test
+ public void givenCharacterValueWhenSerializingAndDeserializingExpectEquals()
+ {
+ String serialized = valueSerialization.serialize( 'q' );
+ assertThat( "Serialized", serialized, equalTo( "q" ) );
+
+ Character deserialized = valueSerialization.deserialize( module, Character.class, serialized );
+ assertThat( "Deserialized", deserialized, equalTo( 'q' ) );
+ }
+
+ @Test
+ public void givenEmptyStringValueWhenSerializingAndDeserializingExpectEquals()
+ {
+ String serialized = valueSerialization.serialize( "" );
+ assertThat( "Serialized", serialized, equalTo( "" ) );
+
+ String deserialized = valueSerialization.deserialize( module, String.class, serialized );
+ assertThat( "Deserialized", deserialized, equalTo( "" ) );
+ }
+
+ @Test
+ public void givenStringValueWhenSerializingAndDeserializingExpectEquals()
+ {
+ String serialized = valueSerialization.serialize( "test" );
+ assertThat( serialized, equalTo( "test" ) );
+
+ String deserialized = valueSerialization.deserialize( module, String.class, serialized );
+ assertThat( deserialized, equalTo( "test" ) );
+ }
+
+ @Test
+ public void givenBooleanValueWhenSerializingAndDeserializingExpectEquals()
+ {
+ String serialized = valueSerialization.serialize( Boolean.TRUE );
+ assertThat( serialized, equalTo( "true" ) );
+
+ Boolean deserialized = valueSerialization.deserialize( module, Boolean.class, serialized );
+ assertThat( deserialized, equalTo( Boolean.TRUE ) );
+ }
+
+ @Test
+ public void givenIntegerValueWhenSerializingAndDeserializingExpectEquals()
+ {
+ String serialized = valueSerialization.serialize( 42 );
+ assertThat( serialized, equalTo( "42" ) );
+ Integer deserialized = valueSerialization.deserialize( module, Integer.class, serialized );
+ assertThat( deserialized, equalTo( 42 ) );
+ }
+
+ @Test
+ public void givenLongValueWhenSerializingAndDeserializingExpectEquals()
+ {
+ String serialized = valueSerialization.serialize( 42L );
+ assertThat( serialized, equalTo( "42" ) );
+
+ Long deserialized = valueSerialization.deserialize( module, Long.class, serialized );
+ assertThat( deserialized, equalTo( 42L ) );
+ }
+
+ @Test
+ public void givenShortValueWhenSerializingAndDeserializingExpectEquals()
+ {
+ String serialized = valueSerialization.serialize( (short) 42 );
+ assertThat( serialized, equalTo( "42" ) );
+
+ Short deserialized = valueSerialization.deserialize( module, Short.class, serialized );
+ assertThat( deserialized, equalTo( (short) 42 ) );
+ }
+
+ @Test
+ public void givenByteValueWhenSerializingAndDeserializingExpectEquals()
+ {
+ String serialized = valueSerialization.serialize( (byte) 42 );
+ assertThat( serialized, equalTo( "42" ) );
+ Byte deserialized = valueSerialization.deserialize( module, Byte.class, serialized );
+ assertThat( deserialized, equalTo( (byte) 42 ) );
+ }
+
+ @Test
+ public void givenFloatValueWhenSerializingAndDeserializingExpectEquals()
+ {
+ String serialized = valueSerialization.serialize( 42F );
+ assertThat( serialized, equalTo( "42.0" ) );
+
+ Float deserialized = valueSerialization.deserialize( module, Float.class, serialized );
+ assertThat( deserialized, equalTo( 42F ) );
+ }
+
+ @Test
+ public void givenDoubleValueWhenSerializingAndDeserializingExpectEquals()
+ {
+ String serialized = valueSerialization.serialize( 42D );
+ assertThat( serialized, equalTo( "42.0" ) );
+
+ Double deserialized = valueSerialization.deserialize( module, Double.class, serialized );
+ assertThat( deserialized, equalTo( 42D ) );
+ }
+
+ @Test
+ public void givenBigIntegerValueWhenSerializingAndDeserializingExpectEquals()
+ {
+ BigInteger bigInteger = new BigInteger( "42424242424242424242424242" );
+ assertThat( bigInteger, not( equalTo( BigInteger.valueOf( bigInteger.longValue() ) ) ) );
+
+ String serialized = valueSerialization.serialize( bigInteger );
+ assertThat( serialized, equalTo( "42424242424242424242424242" ) );
+
+ BigInteger deserialized = valueSerialization.deserialize( module, BigInteger.class, serialized );
+ assertThat( deserialized, equalTo( bigInteger ) );
+ }
+
+ @Test
+ public void givenBigDecimalValueWhenSerializingAndDeserializingExpectEquals()
+ {
+ BigDecimal bigDecimal = new BigDecimal( "42.2376931348623157e+309" );
+ assertThat( bigDecimal.doubleValue(), equalTo( Double.POSITIVE_INFINITY ) );
+
+ String serialized = valueSerialization.serialize( bigDecimal );
+ assertThat( serialized, equalTo( "4.22376931348623157E+310" ) );
+
+ BigDecimal deserialized = valueSerialization.deserialize( module, BigDecimal.class, serialized );
+ assertThat( deserialized, equalTo( bigDecimal ) );
+ }
+
+ @Test
+ public void givenDateTimeValueWhenSerializingAndDeserializingExpectEquals()
+ {
+ String serialized = valueSerialization.serialize( OffsetDateTime.of( 2020, 3, 4, 13, 24, 35, 123000000, ZoneOffset
+ .ofHours( 1 ) ) );
+ assertThat( serialized, equalTo( "2020-03-04T13:24:35.123+01:00" ) );
+ ZonedDateTime deserialized = valueSerialization.deserialize( module, ZonedDateTime.class, serialized );
+ assertThat( deserialized, equalTo( ZonedDateTime.of( 2020, 3, 4, 13, 24, 35, 123000000, ZoneOffset.ofHours( 1 ) ) ) );
+ }
+
+ @Test
+ public void givenLocalDateTimeValueWhenSerializingAndDeserializingExpectEquals()
+ {
+ // Serialized without TimeZone
+ String serialized = valueSerialization.serialize( LocalDateTime.of( 2020, 3, 4, 13, 23, 12 ) );
+ assertThat( serialized, equalTo( "2020-03-04T13:23:12" ) );
+
+ LocalDateTime deserialized = valueSerialization.deserialize( module, LocalDateTime.class, serialized );
+ assertThat( deserialized, equalTo( LocalDateTime.of( 2020, 3, 4, 13, 23, 12 ) ) );
+ }
+
+ @Test
+ public void givenLocalDateValueWhenSerializingAndDeserializingExpectEquals()
+ {
+ String serialized = valueSerialization.serialize( LocalDate.of( 2020, 3, 4 ) );
+ assertThat( serialized, equalTo( "2020-03-04" ) );
+
+ LocalDate deserialized = valueSerialization.deserialize( module, LocalDate.class, serialized );
+ assertThat( deserialized, equalTo( LocalDate.of( 2020,3,4 ) ) );
+ }
+
+ @Test
+ public void givenEntityReferenceValueWhenSerializingAndDeserializingExpectEquals()
+ {
+ String serialized = valueSerialization.serialize( EntityReference.parseEntityReference( "ABCD-1234" ) );
+ assertThat( serialized, equalTo( "ABCD-1234" ) );
+
+ EntityReference deserialized = valueSerialization.deserialize( module, EntityReference.class, serialized );
+ assertThat( deserialized, equalTo( EntityReference.parseEntityReference( "ABCD-1234" ) ) );
+ }
+
+ @Test
+ public void zest142RegressionTest()
+ throws Exception
+ {
+ if( getClass().getName().equals( "org.apache.zest.valueserialization.stax.StaxPlainValueSerializationTest" ) )
+ {
+ // This test is disabled, as this test expect a JSON capable serializer as it uses
+ // the JSONMapEntityStoreMixin in MemoryEntityStore.
+ return;
+ }
+ ValueSerialization serialization = serviceFinder.findService( ValueSerialization.class ).get();
+
+ Regression142Type value;
+ {
+ ValueBuilder<Regression142Type> builder = valueBuilderFactory.newValueBuilder( Regression142Type.class );
+ builder.prototype().price().set( 23.45 );
+ builder.prototype().testenum().set( Regression142Enum.B );
+ value = builder.newInstance();
+ String serialized = serialization.serialize( value );
+ System.out.println( serialized ); // ok
+ value = serialization.deserialize( module, Regression142Type.class, serialized ); // ok
+ }
+ {
+ String valueId = "abcdefg";
+ {
+ try (UnitOfWork uow = unitOfWorkFactory.newUnitOfWork( UsecaseBuilder.newUsecase( "create" ) ))
+ {
+ EntityBuilder<Regression142Type> builder = uow.newEntityBuilder( Regression142Type.class, valueId );
+ builder.instance().price().set( 45.67 );
+ builder.instance().testenum().set( Regression142Enum.A );
+ value = builder.newInstance();
+ System.out.println( value.testenum().get() );
+ uow.complete();
+ }
+ catch( Exception e_ )
+ {
+ e_.printStackTrace();
+ }
+ }
+ {
+ try (UnitOfWork uow = unitOfWorkFactory.newUnitOfWork( UsecaseBuilder.newUsecase( "create" ) ))
+ {
+ value = uow.get( Regression142Type.class, valueId );
+ System.out.println( value.price().get() );
+ System.out.println( value.testenum().get() ); // FAIL
+ }
+ }
+ }
+ }
+
+ private enum Regression142Enum
+ {
+ A, B, C, D
+ }
+
+ interface Regression142Type
+ {
+ Property<Double> price();
+
+ Property<Regression142Enum> testenum();
+ }
+}
[11/25] zest-java git commit: ZEST-124 - Fixed Solr Time API
refactoring bug. java.util.Date is needed here.
Posted by ni...@apache.org.
ZEST-124 - Fixed Solr Time API refactoring bug. java.util.Date is needed here.
Project: http://git-wip-us.apache.org/repos/asf/zest-java/repo
Commit: http://git-wip-us.apache.org/repos/asf/zest-java/commit/79021c9a
Tree: http://git-wip-us.apache.org/repos/asf/zest-java/tree/79021c9a
Diff: http://git-wip-us.apache.org/repos/asf/zest-java/diff/79021c9a
Branch: refs/heads/ValueSerializationCleaning
Commit: 79021c9abf62ecdb0c82df790cd6c4f78ae744e3
Parents: dd35dc1
Author: Niclas Hedhman <ni...@hedhman.org>
Authored: Sun Jun 12 16:08:54 2016 +0800
Committer: Niclas Hedhman <ni...@hedhman.org>
Committed: Sun Jun 12 22:51:05 2016 +0800
----------------------------------------------------------------------
.../solr/internal/SolrEntityIndexerMixin.java | 65 +++++++++++++-------
.../zest/index/solr/SolrQueryServiceTest.java | 15 ++---
2 files changed, 50 insertions(+), 30 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/zest-java/blob/79021c9a/extensions/indexing-solr/src/main/java/org/apache/zest/index/solr/internal/SolrEntityIndexerMixin.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-solr/src/main/java/org/apache/zest/index/solr/internal/SolrEntityIndexerMixin.java b/extensions/indexing-solr/src/main/java/org/apache/zest/index/solr/internal/SolrEntityIndexerMixin.java
index c34ff0b..6f9d6f9 100644
--- a/extensions/indexing-solr/src/main/java/org/apache/zest/index/solr/internal/SolrEntityIndexerMixin.java
+++ b/extensions/indexing-solr/src/main/java/org/apache/zest/index/solr/internal/SolrEntityIndexerMixin.java
@@ -30,6 +30,13 @@ import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.core.SolrCore;
import org.apache.solr.schema.SchemaField;
+import org.apache.zest.api.injection.scope.Service;
+import org.apache.zest.api.injection.scope.Uses;
+import org.apache.zest.index.solr.EmbeddedSolrService;
+import org.apache.zest.index.solr.SolrQueryService;
+import org.apache.zest.library.rdf.entity.EntityStateSerializer;
+import org.apache.zest.spi.entity.EntityState;
+import org.apache.zest.spi.entity.EntityStatus;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
@@ -41,13 +48,6 @@ import org.openrdf.model.Statement;
import org.openrdf.model.URI;
import org.openrdf.model.impl.GraphImpl;
import org.openrdf.model.impl.URIImpl;
-import org.apache.zest.api.injection.scope.Service;
-import org.apache.zest.api.injection.scope.Uses;
-import org.apache.zest.index.solr.EmbeddedSolrService;
-import org.apache.zest.index.solr.SolrQueryService;
-import org.apache.zest.library.rdf.entity.EntityStateSerializer;
-import org.apache.zest.spi.entity.EntityState;
-import org.apache.zest.spi.entity.EntityStatus;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -55,7 +55,7 @@ import org.slf4j.LoggerFactory;
* JAVADOC
*/
public abstract class SolrEntityIndexerMixin
- implements SolrQueryService
+ implements SolrQueryService
{
@Service
private EmbeddedSolrService solr;
@@ -78,7 +78,8 @@ public abstract class SolrEntityIndexerMixin
try
{
indexedFields = solrCore.getSchema().getFields();
- } finally
+ }
+ finally
{
solrCore.close();
}
@@ -108,12 +109,16 @@ public abstract class SolrEntityIndexerMixin
if( entityState.status().equals( EntityStatus.REMOVED ) )
{
if( deleted == null )
+ {
deleted = new ArrayList<>();
+ }
deleted.add( entityState.identity().identity() );
- } else if( entityState.status().equals( EntityStatus.UPDATED ) )
+ }
+ else if( entityState.status().equals( EntityStatus.UPDATED ) )
{
added.add( indexEntityState( entityState ) );
- } else if( entityState.status().equals( EntityStatus.NEW ) )
+ }
+ else if( entityState.status().equals( EntityStatus.NEW ) )
{
added.add( indexEntityState( entityState ) );
}
@@ -122,17 +127,23 @@ public abstract class SolrEntityIndexerMixin
// Send changes to Solr
if( deleted != null )
+ {
server.deleteById( deleted );
+ }
if( !added.isEmpty() )
+ {
server.add( added );
- } finally
+ }
+ }
+ finally
{
if( server != null )
{
server.commit( false, false );
}
}
- } catch( Throwable e )
+ }
+ catch( Throwable e )
{
logger.error( "Could not update Solr", e );
//TODO What shall we do with the exception?
@@ -140,7 +151,7 @@ public abstract class SolrEntityIndexerMixin
}
private SolrInputDocument indexEntityState( final EntityState entityState )
- throws IOException, SolrServerException, JSONException
+ throws IOException, SolrServerException, JSONException
{
Graph graph = new GraphImpl();
stateSerializer.serialize( entityState, false, graph );
@@ -148,7 +159,7 @@ public abstract class SolrEntityIndexerMixin
SolrInputDocument input = new SolrInputDocument();
input.addField( "id", entityState.identity().identity() );
input.addField( "type", entityState.entityDescriptor().types().findFirst().get().getName() );
- input.addField( "lastModified", entityState.lastModified() );
+ input.addField( "lastModified", new java.util.Date( entityState.lastModified() ) );
for( Statement statement : graph )
{
@@ -164,22 +175,26 @@ public abstract class SolrEntityIndexerMixin
{
JSONArray array = new JSONArray( value );
indexJson( input, array );
- } else if( value.charAt( 0 ) == '{' )
+ }
+ else if( value.charAt( 0 ) == '{' )
{
JSONObject object = new JSONObject( value );
indexJson( input, object );
}
- } else
+ }
+ else
{
input.addField( field.getName(), value );
}
- } else if( statement.getObject() instanceof URI && !"type".equals( field.getName() ) )
+ }
+ else if( statement.getObject() instanceof URI && !"type".equals( field.getName() ) )
{
String value = statement.getObject().stringValue();
value = value.substring( value.lastIndexOf( ':' ) + 1, value.length() );
String name = field.getName();
input.addField( name, value );
- } else if( statement.getObject() instanceof BNode )
+ }
+ else if( statement.getObject() instanceof BNode )
{
Resource resource = (Resource) statement.getObject();
URIImpl uri = new URIImpl( "http://www.w3.org/1999/02/22-rdf-syntax-ns#li" );
@@ -194,20 +209,23 @@ public abstract class SolrEntityIndexerMixin
}
}
}
-
}
return input;
}
- private void indexJson( SolrInputDocument input, Object object ) throws JSONException
+ private void indexJson( SolrInputDocument input, Object object )
+ throws JSONException
{
if( object instanceof JSONArray )
{
JSONArray array = (JSONArray) object;
for( int i = 0; i < array.length(); i++ )
+ {
indexJson( input, array.get( i ) );
- } else
+ }
+ }
+ else
{
JSONObject jsonObject = (JSONObject) object;
Iterator keys = jsonObject.keys();
@@ -218,7 +236,8 @@ public abstract class SolrEntityIndexerMixin
if( value instanceof JSONObject || value instanceof JSONArray )
{
indexJson( input, value );
- } else
+ }
+ else
{
SchemaField field = indexedFields.get( name.toString() );
if( field != null )
http://git-wip-us.apache.org/repos/asf/zest-java/blob/79021c9a/extensions/indexing-solr/src/test/java/org/apache/zest/index/solr/SolrQueryServiceTest.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-solr/src/test/java/org/apache/zest/index/solr/SolrQueryServiceTest.java b/extensions/indexing-solr/src/test/java/org/apache/zest/index/solr/SolrQueryServiceTest.java
index 4b59ac0..4d59f9c 100644
--- a/extensions/indexing-solr/src/test/java/org/apache/zest/index/solr/SolrQueryServiceTest.java
+++ b/extensions/indexing-solr/src/test/java/org/apache/zest/index/solr/SolrQueryServiceTest.java
@@ -83,7 +83,7 @@ public class SolrQueryServiceTest
TestEntity test = uow.newEntity( TestEntity.class );
test.name().set( "Hello World" );
uow.complete();
- Thread.sleep( 40 );
+ Thread.sleep( 140 );
}
@Test
@@ -91,13 +91,14 @@ public class SolrQueryServiceTest
throws UnitOfWorkCompletionException
{
// Search for it
- UnitOfWork uow = unitOfWorkFactory.newUnitOfWork();
- Query<TestEntity> query = uow.newQuery( queryBuilderFactory.newQueryBuilder( TestEntity.class ).where( SolrExpressions.search( "hello" ) ) );
-
- TestEntity test = query.find();
- Assert.assertThat( test.name().get(), equalTo( "Hello World" ) );
+ try( UnitOfWork uow = unitOfWorkFactory.newUnitOfWork() )
+ {
+ Query<TestEntity> query = uow.newQuery( queryBuilderFactory.newQueryBuilder( TestEntity.class )
+ .where( SolrExpressions.search( "hello" ) ) );
- uow.discard();
+ TestEntity test = query.find();
+ Assert.assertThat( test.name().get(), equalTo( "Hello World" ) );
+ }
}
@Test
[10/25] zest-java git commit: ZEST-151 : Removed Conversion Library
Posted by ni...@apache.org.
ZEST-151 : Removed Conversion Library
Project: http://git-wip-us.apache.org/repos/asf/zest-java/repo
Commit: http://git-wip-us.apache.org/repos/asf/zest-java/commit/5229303a
Tree: http://git-wip-us.apache.org/repos/asf/zest-java/tree/5229303a
Diff: http://git-wip-us.apache.org/repos/asf/zest-java/diff/5229303a
Branch: refs/heads/ValueSerializationCleaning
Commit: 5229303a2394233af083f81e2e46aa4bcac5356f
Parents: e4736b0
Author: Niclas Hedhman <ni...@hedhman.org>
Authored: Sun Jun 12 16:56:17 2016 +0800
Committer: Niclas Hedhman <ni...@hedhman.org>
Committed: Sun Jun 12 22:51:05 2016 +0800
----------------------------------------------------------------------
libraries/conversion/build.gradle | 32 -
libraries/conversion/dev-status.xml | 38 -
libraries/conversion/src/docs/conversion.txt | 129 ----
.../conversion/values/EntityToValue.java | 463 ------------
.../values/EntityToValueAssembler.java | 45 --
.../conversion/values/EntityToValueService.java | 55 --
.../values/PropertyNotPresentException.java | 46 --
.../zest/library/conversion/values/Shared.java | 71 --
.../library/conversion/values/Unqualified.java | 35 -
.../conversion/values/ValueToEntity.java | 137 ----
.../values/ValueToEntityAssembler.java | 45 --
.../conversion/values/ValueToEntityMixin.java | 730 -------------------
.../conversion/values/ValueToEntityService.java | 33 -
.../zest/library/conversion/values/package.html | 24 -
.../conversion/values/EntityToValueTest.java | 232 ------
.../values/NestedValuesConversionTest.java | 130 ----
.../library/conversion/values/TestModel.java | 202 -----
.../conversion/values/ValueToEntityTest.java | 355 ---------
settings.gradle | 1 -
19 files changed, 2803 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/zest-java/blob/5229303a/libraries/conversion/build.gradle
----------------------------------------------------------------------
diff --git a/libraries/conversion/build.gradle b/libraries/conversion/build.gradle
deleted file mode 100644
index 7443b58..0000000
--- a/libraries/conversion/build.gradle
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-
-description = "Apache Zest\u2122 Conversion Library has various generic services to manipulate Apache Zest\u2122 ValueComposites, such as converting an Entity to a Value."
-
-jar { manifest { name = "Apache Zest\u2122 Library - Conversion" }}
-
-dependencies {
- compile(project(":org.apache.zest.core:org.apache.zest.core.bootstrap"))
-
- testCompile(project(":org.apache.zest.core:org.apache.zest.core.testsupport"))
-
- testRuntime(project(":org.apache.zest.core:org.apache.zest.core.runtime"))
- testRuntime(libraries.logback)
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/zest-java/blob/5229303a/libraries/conversion/dev-status.xml
----------------------------------------------------------------------
diff --git a/libraries/conversion/dev-status.xml b/libraries/conversion/dev-status.xml
deleted file mode 100644
index 5b78a6d..0000000
--- a/libraries/conversion/dev-status.xml
+++ /dev/null
@@ -1,38 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one
- ~ or more contributor license agreements. See the NOTICE file
- ~ distributed with this work for additional information
- ~ regarding copyright ownership. The ASF licenses this file
- ~ to you under the Apache License, Version 2.0 (the
- ~ "License"); you may not use this file except in compliance
- ~ with the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- ~
- ~
- -->
-<module xmlns="http://zest.apache.org/schemas/2008/dev-status/1"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://zest.apache.org/schemas/2008/dev-status/1
- http://zest.apache.org/schemas/2008/dev-status/1/dev-status.xsd">
- <status>
- <!--none,early,beta,stable,mature-->
- <codebase>stable</codebase>
-
- <!-- none, brief, good, complete -->
- <documentation>brief</documentation>
-
- <!-- none, some, good, complete -->
- <unittests>some</unittests>
- </status>
- <licenses>
- <license>ALv2</license>
- </licenses>
-</module>
http://git-wip-us.apache.org/repos/asf/zest-java/blob/5229303a/libraries/conversion/src/docs/conversion.txt
----------------------------------------------------------------------
diff --git a/libraries/conversion/src/docs/conversion.txt b/libraries/conversion/src/docs/conversion.txt
deleted file mode 100644
index a8eb3cf..0000000
--- a/libraries/conversion/src/docs/conversion.txt
+++ /dev/null
@@ -1,129 +0,0 @@
-///////////////////////////////////////////////////////////////
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
-///////////////////////////////////////////////////////////////
-
-[[library-conversion, Conversion Library]]
-= Conversion - DEPRECATED =
-
-[devstatus]
---------------
-source=libraries/conversion/dev-status.xml
---------------
-
-The Conversion Library provides support for converting composite types.
-
-include::../../build/docs/buildinfo/artifact.txt[]
-
-
-[WARNING]
-.DEPRECATED
-====
-This functionality is now present in <<def-unitofwork>> as
-the two methods toEntity() and toValue(). Since this library was written
-assocations of all kinds are now fully supported in Values.
-====
-
-
-== Entities to Values ==
-
-To convert Entities to Values, use the EntityToValueService. It is easily assembled:
-
-[snippet,java]
-----
-source=libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/EntityToValueTest.java
-tag=assembly
-----
-
-Let's say we have an interface defining state:
-
-[snippet,java]
-----
-source=libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/TestModel.java
-tag=state
-----
-
-An EntityComposite using the state as a Private Mixin:
-
-[snippet,java]
-----
-source=libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/TestModel.java
-tag=entity
-----
-
-And a ValueComposite extending this very same state;
-
-[snippet,java]
-----
-source=libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/TestModel.java
-tag=value
-----
-
-Here is how to convert an EntityComposite to a ValueComposite:
-
-[snippet,java]
-----
-source=libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/EntityToValueTest.java
-tag=conversion
-----
-
-
-== Values to Entities ==
-
-Using the ValueToEntity service one can create new Entities or update existing ones from Values.
-It is easy assembled:
-
-[snippet,java]
-----
-source=libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/ValueToEntityTest.java
-tag=assembly
-----
-
-Let's say we have the exact same model as described above.
-
-Here is how to create an EntityComposite from a ValueComposite:
-
-[snippet,java]
-----
-source=libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/ValueToEntityTest.java
-tag=creation
-----
-
-Here is how to update an EntityComposite from a ValueComposite:
-
-[snippet,java]
-----
-source=libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/ValueToEntityTest.java
-tag=update
-----
-
-
-== Associations are converted to Identity strings ==
-
-If your Entities and Values cannot use the same state type, you can annotate the Value that is the target of the
-conversion with the `@Unqualified` annotation. Then, the lookup of the Value Property will be performed using the
-*unqualified* name only, and not via the default of the full qualified name. In other words, this means that the
-Property may be declared in the different interfaces and still be matched.
-
-Here is an example:
-
-[snippet,java]
-----
-source=libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/TestModel.java
-tag=unqualified
-----
-
http://git-wip-us.apache.org/repos/asf/zest-java/blob/5229303a/libraries/conversion/src/main/java/org/apache/zest/library/conversion/values/EntityToValue.java
----------------------------------------------------------------------
diff --git a/libraries/conversion/src/main/java/org/apache/zest/library/conversion/values/EntityToValue.java b/libraries/conversion/src/main/java/org/apache/zest/library/conversion/values/EntityToValue.java
deleted file mode 100644
index bdddaa4..0000000
--- a/libraries/conversion/src/main/java/org/apache/zest/library/conversion/values/EntityToValue.java
+++ /dev/null
@@ -1,463 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-package org.apache.zest.library.conversion.values;
-
-import java.lang.reflect.AccessibleObject;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.function.Function;
-import java.util.stream.Collectors;
-import org.apache.zest.api.association.Association;
-import org.apache.zest.api.association.AssociationDescriptor;
-import org.apache.zest.api.association.AssociationStateDescriptor;
-import org.apache.zest.api.association.AssociationStateHolder;
-import org.apache.zest.api.association.ManyAssociation;
-import org.apache.zest.api.association.NamedAssociation;
-import org.apache.zest.api.entity.EntityComposite;
-import org.apache.zest.api.entity.EntityDescriptor;
-import org.apache.zest.api.entity.EntityReference;
-import org.apache.zest.api.entity.Identity;
-import org.apache.zest.api.injection.scope.Structure;
-import org.apache.zest.api.mixin.Mixins;
-import org.apache.zest.api.property.PropertyDescriptor;
-import org.apache.zest.api.structure.Module;
-import org.apache.zest.api.value.NoSuchValueException;
-import org.apache.zest.api.value.ValueBuilder;
-import org.apache.zest.api.value.ValueDescriptor;
-import org.apache.zest.functional.Iterables;
-import org.apache.zest.spi.ZestSPI;
-
-import static org.apache.zest.library.conversion.values.Shared.STRING_COLLECTION_TYPE_SPEC;
-import static org.apache.zest.library.conversion.values.Shared.STRING_MAP_TYPE_SPEC;
-import static org.apache.zest.library.conversion.values.Shared.STRING_TYPE_SPEC;
-
-/**
- * @deprecated Please use {@link org.apache.zest.api.unitofwork.UnitOfWork#toValue(Class, Identity)} instead.
- */
-@Mixins( EntityToValue.EntityToValueMixin.class )
-public interface EntityToValue
-{
- /**
- * Convert an entity to a value.
- *
- * @param <T> parametrized type of the value
- * @param valueType type of the value
- * @param entity the entity to convert to a value
- * @return the resulting value
- */
- <T> T convert( Class<T> valueType, Object entity );
-
- /**
- * Convert an entity to a value with an opportunity to customize its prototype.
- *
- * @param <T> parametrized type of the value
- * @param valueType type of the value
- * @param entity the entity to convert to a value
- * @param prototypeOpportunity a Function that will be mapped on the value prototype before instanciantion
- * @return the resulting value
- */
- <T> T convert( Class<T> valueType, Object entity, Function<T, T> prototypeOpportunity );
-
- /**
- * Convert an iterable of entities to an iterable of values.
- *
- * @param <T> parametrized type of the value
- * @param valueType type of the value
- * @param entities the entities to convert to values
- * @return the resulting values
- */
- <T> Iterable<T> convert( Class<T> valueType, Iterable<Object> entities );
-
- /**
- * Convert an iterable of entities to an iterable of values with an opportunity to customize their prototypes.
- *
- * @param <T> parametrized type of the value
- * @param valueType type of the value
- * @param entities the entities to convert to values
- * @param prototypeOpportunity a Function that will be mapped on each of the value prototypes before instanciation.
- * @return the resulting values
- */
- <T> Iterable<T> convert( Class<T> valueType, Iterable<Object> entities, Function<T, T> prototypeOpportunity );
-
- static class EntityToValueMixin
- implements EntityToValue
- {
-
- @Structure
- private ZestSPI spi;
- @Structure
- private Module module;
-
- @Override
- public <T> T convert( final Class<T> valueType, Object entity )
- {
- return createInstance( doConversion( valueType, entity ) );
- }
-
- @Override
- @SuppressWarnings( "unchecked" )
- public <T> T convert( final Class<T> valueType, Object entity, Function<T, T> prototypeOpportunity )
- {
- ValueBuilder<?> builder = doConversion( valueType, entity );
- prototypeOpportunity.apply( (T) builder.prototype() );
- return createInstance( builder );
- }
-
- @Override
- public <T> Iterable<T> convert( final Class<T> valueType, Iterable<Object> entities )
- {
- return Iterables.map(
- new Function<Object, T>()
- {
- @Override
- public T apply( Object entity )
- {
- return convert( valueType, entity );
- }
- }, entities );
- }
-
- @Override
- public <T> Iterable<T> convert( final Class<T> valueType, Iterable<Object> entities, final Function<T, T> prototypeOpportunity )
- {
- return Iterables.map(
- new Function<Object, T>()
- {
- @Override
- public T apply( Object entity )
- {
- return convert( valueType, entity, prototypeOpportunity );
- }
- }, entities );
- }
-
- private <T> ValueBuilder<?> doConversion( final Class<T> valueType, Object entity )
- {
- ValueDescriptor valueDescriptor = module.descriptor().valueDescriptor( valueType.getName() );
- if( valueDescriptor == null )
- {
- throw new NoSuchValueException( valueType.getName(), module.name(), module.typeLookup() );
- }
- Unqualified unqualified = valueDescriptor.metaInfo( Unqualified.class );
-// Iterable<? extends PropertyDescriptor> properties = valueDescriptor.state().properties();
- final EntityComposite composite = (EntityComposite) entity;
- final EntityDescriptor entityDescriptor = spi.entityDescriptorFor( composite );
- final AssociationStateHolder associationState = spi.stateOf( composite );
- ValueBuilder<?> builder;
-
- if( unqualified == null || !unqualified.value() )
- {
- // Copy state using qualified names
- builder = module.newValueBuilderWithState(
- valueType,
- new Function<PropertyDescriptor, Object>()
- {
- @Override
- public Object apply( PropertyDescriptor descriptor )
- {
- try
- {
- return associationState.propertyFor( descriptor.accessor() ).get();
- }
- catch( IllegalArgumentException e )
- {
- AssociationStateDescriptor entityState = entityDescriptor.state();
- String associationName = descriptor.qualifiedName().name();
- if( STRING_TYPE_SPEC.test( descriptor.valueType() ) )
- {
- // Find Association and convert to string
- AssociationDescriptor associationDescriptor;
- try
- {
- associationDescriptor = entityState.getAssociationByName( associationName );
- }
- catch( IllegalArgumentException e1 )
- {
- return null;
- }
- AccessibleObject associationMethod = associationDescriptor.accessor();
- Object entity = associationState.associationFor( associationMethod ).get();
- if( entity != null )
- {
- return ( (Identity) entity ).identity().get();
- }
- else
- {
- return null;
- }
- }
- else if( STRING_COLLECTION_TYPE_SPEC.test( descriptor.valueType() ) )
- {
- AssociationDescriptor associationDescriptor;
- try
- {
- associationDescriptor = entityState.getManyAssociationByName( associationName );
- }
- catch( IllegalArgumentException e1 )
- {
- return Collections.emptyList();
- }
-
- ManyAssociation<?> state = associationState.manyAssociationFor( associationDescriptor.accessor() );
- List<String> entities = new ArrayList<>( state.count() );
- for( Object entity : state )
- {
- entities.add( ( (Identity) entity ).identity().get() );
- }
- return entities;
- }
- else if( STRING_MAP_TYPE_SPEC.test( descriptor.valueType() ) )
- {
- AssociationDescriptor associationDescriptor;
- try
- {
- associationDescriptor = entityState.getNamedAssociationByName( associationName );
- }
- catch( IllegalArgumentException e1 )
- {
- return Collections.emptyMap();
- }
-
- NamedAssociation<?> state = associationState.namedAssociationFor( associationDescriptor.accessor() );
- Map<String, String> entities = new LinkedHashMap<>( state.count() );
- for( String name : state )
- {
- entities.put( name, ( (Identity) state.get( name ) ).identity().get() );
- }
- return entities;
- }
-
- return null;
- }
- }
- },
- new Function<AssociationDescriptor, EntityReference>()
- {
- @Override
- public EntityReference apply( AssociationDescriptor associationDescriptor )
- {
- return EntityReference.entityReferenceFor(
- associationState.associationFor( associationDescriptor.accessor() ).get() );
- }
- },
- new Function<AssociationDescriptor, Iterable<EntityReference>>()
- {
- @Override
- public Iterable<EntityReference> apply( AssociationDescriptor associationDescriptor )
- {
- ManyAssociation<?> state = associationState.manyAssociationFor( associationDescriptor.accessor() );
- List<EntityReference> refs = new ArrayList<>( state.count() );
- for( Object entity : state )
- {
- refs.add( EntityReference.entityReferenceFor( entity ) );
- }
- return refs;
- }
- },
- new Function<AssociationDescriptor, Map<String, EntityReference>>()
- {
- @Override
- public Map<String, EntityReference> apply( AssociationDescriptor associationDescriptor )
- {
- NamedAssociation<?> assoc = associationState.namedAssociationFor( associationDescriptor.accessor() );
- Map<String, EntityReference> refs = new LinkedHashMap<>( assoc.count() );
- for( String name : assoc )
- {
- refs.put( name, EntityReference.entityReferenceFor( assoc.get( name ) ) );
- }
- return refs;
- }
- } );
- }
- else
- {
- builder = module.newValueBuilderWithState(valueType,
- new Function<PropertyDescriptor, Object>()
- {
- @Override
- public Object apply( final PropertyDescriptor descriptor )
- {
- AssociationStateDescriptor entityState = entityDescriptor.state();
- String propertyName = descriptor.qualifiedName().name();
- try
- {
- PropertyDescriptor propertyDescriptor = entityState.findPropertyModelByName( propertyName );
- return associationState.propertyFor( propertyDescriptor.accessor() ).get();
- }
- catch( IllegalArgumentException e )
- {
- if( STRING_TYPE_SPEC.test( descriptor.valueType() ) )
- {
- // Find Association and convert to string
- AssociationDescriptor associationDescriptor;
- try
- {
- associationDescriptor = entityState.getAssociationByName( propertyName );
- }
- catch( IllegalArgumentException e1 )
- {
- return null;
- }
-
- AccessibleObject associationMethod = associationDescriptor.accessor();
- Object entity = associationState.associationFor( associationMethod ).get();
- if( entity != null )
- {
- return ( (Identity) entity ).identity().get();
- }
- else
- {
- return null;
- }
- }
- else if( STRING_COLLECTION_TYPE_SPEC.test( descriptor.valueType() ) )
- {
- AssociationDescriptor associationDescriptor;
- try
- {
- associationDescriptor = entityState.getManyAssociationByName( propertyName );
- }
- catch( IllegalArgumentException e1 )
- {
- return null;
- }
-
- AccessibleObject associationMethod = associationDescriptor.accessor();
- ManyAssociation<?> state = associationState.manyAssociationFor( associationMethod );
- List<String> entities = new ArrayList<>( state.count() );
- for( Object entity : state )
- {
- entities.add( ( (Identity) entity ).identity().get() );
- }
- return entities;
- }
- else if( STRING_MAP_TYPE_SPEC.test( descriptor.valueType() ) )
- {
- AssociationDescriptor associationDescriptor;
- try
- {
- associationDescriptor = entityState.getNamedAssociationByName( propertyName );
- }
- catch( IllegalArgumentException e1 )
- {
- return null;
- }
-
- AccessibleObject associationMethod = associationDescriptor.accessor();
- NamedAssociation<?> state = associationState.namedAssociationFor( associationMethod );
- Map<String, String> entities = new LinkedHashMap<>( state.count() );
- for( String name : state )
- {
- entities.put( name, ( (Identity) state.get( name ) ).identity().get() );
- }
- return entities;
- }
- return null;
- }
- }
- },
- new Function<AssociationDescriptor, EntityReference>()
- {
- @Override
- public EntityReference apply( AssociationDescriptor descriptor )
- {
- AssociationDescriptor associationDescriptor;
- try
- {
- associationDescriptor = entityDescriptor.state()
- .getAssociationByName( descriptor.qualifiedName().name() );
- }
- catch( IllegalArgumentException e )
- {
- return null;
- }
-
- AccessibleObject associationMethod = associationDescriptor.accessor();
- Association<Object> association = associationState.associationFor( associationMethod );
- return EntityReference.entityReferenceFor( association.get() );
- }
- },
- new Function<AssociationDescriptor, Iterable<EntityReference>>()
- {
- @Override
- public Iterable<EntityReference> apply( final AssociationDescriptor descriptor )
- {
- AssociationDescriptor associationDescriptor;
- try
- {
- String associationName = descriptor.qualifiedName().name();
- AssociationStateDescriptor entityState = entityDescriptor.state();
- associationDescriptor = entityState.getManyAssociationByName( associationName );
- }
- catch( IllegalArgumentException e )
- {
- return Iterables.empty();
- }
-
- ManyAssociation<?> state = associationState.manyAssociationFor( associationDescriptor.accessor() );
- List<EntityReference> refs = new ArrayList<>( state.count() );
- for( Object entity : state )
- {
- refs.add( EntityReference.entityReferenceFor( entity ) );
- }
- return refs;
- }
- },
- new Function<AssociationDescriptor, Map<String, EntityReference>>()
- {
- @Override
- public Map<String, EntityReference> apply( AssociationDescriptor descriptor )
- {
- AssociationDescriptor associationDescriptor;
- try
- {
- String associationName = descriptor.qualifiedName().name();
- AssociationStateDescriptor entityState = entityDescriptor.state();
- associationDescriptor = entityState.getNamedAssociationByName( associationName );
- }
- catch( IllegalArgumentException e )
- {
- return Collections.emptyMap();
- }
- AccessibleObject associationMethod = associationDescriptor.accessor();
- NamedAssociation<Object> assoc = associationState.namedAssociationFor( associationMethod );
- Map<String, EntityReference> refs = new LinkedHashMap<>( assoc.count() );
- for( String name : assoc )
- {
- refs.put( name, EntityReference.entityReferenceFor( assoc.get( name ) ) );
- }
- return refs;
- }
- } );
- }
- return builder;
- }
-
- @SuppressWarnings( "unchecked" )
- private <T> T createInstance( ValueBuilder<?> builder )
- {
- return (T) builder.newInstance();
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/5229303a/libraries/conversion/src/main/java/org/apache/zest/library/conversion/values/EntityToValueAssembler.java
----------------------------------------------------------------------
diff --git a/libraries/conversion/src/main/java/org/apache/zest/library/conversion/values/EntityToValueAssembler.java b/libraries/conversion/src/main/java/org/apache/zest/library/conversion/values/EntityToValueAssembler.java
deleted file mode 100644
index 3f071cb..0000000
--- a/libraries/conversion/src/main/java/org/apache/zest/library/conversion/values/EntityToValueAssembler.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-package org.apache.zest.library.conversion.values;
-
-import org.apache.zest.api.entity.Identity;
-import org.apache.zest.bootstrap.Assemblers;
-import org.apache.zest.bootstrap.AssemblyException;
-import org.apache.zest.bootstrap.ModuleAssembly;
-import org.apache.zest.bootstrap.ServiceDeclaration;
-
-/**
- * EntityToValue Service Assembler.
- * @deprecated Please use {@link org.apache.zest.api.unitofwork.UnitOfWork#toValue(Class, Identity)} instead.
- */
-public class EntityToValueAssembler
- extends Assemblers.VisibilityIdentity<EntityToValueAssembler>
-{
- @Override
- public void assemble( ModuleAssembly module )
- throws AssemblyException
- {
- ServiceDeclaration service = module.services( EntityToValueService.class ).visibleIn( visibility() );
- if( hasIdentity() )
- {
- service.identifiedBy( identity() );
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/5229303a/libraries/conversion/src/main/java/org/apache/zest/library/conversion/values/EntityToValueService.java
----------------------------------------------------------------------
diff --git a/libraries/conversion/src/main/java/org/apache/zest/library/conversion/values/EntityToValueService.java b/libraries/conversion/src/main/java/org/apache/zest/library/conversion/values/EntityToValueService.java
deleted file mode 100644
index 8bdaa01..0000000
--- a/libraries/conversion/src/main/java/org/apache/zest/library/conversion/values/EntityToValueService.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-package org.apache.zest.library.conversion.values;
-
-import org.apache.zest.api.entity.Identity;
-import org.apache.zest.api.service.ServiceComposite;
-
-/** The EntityToValueService converts Entities to matching Values.
- * <p>
- * The main purpose of this service is to provide convenience to map entities to serializable values, for instance
- * to be transported across a network. The ValueComposite to convert the Entity to must closely match the Entity
- * for this mapping to work. The rules are fairly straight forward;
- * </p>
- * <ol>
- * <li>Any Property in the EntityComposite to be mapped, must (by default) exist in the ValueComposite with the same
- * fully qualified name, i.e. method declared in the same interface. If the ValueComposite is annotated with
- * @Unqualified then the Property method look up will only locate the properties with the name only,
- * i.e. the methods may defined in different interfaces.</li>
- * <li>For any Association in the EntityComposite, a Property<String> with the same <strong>unqualified</strong>
- * name will be looked up in the ValueComposite. If found, the EntityReference of the Association will be
- * converted to an URI and written to the String property.</li>
- * <li>For any ManyAssociation in the EntityComposite, a Property<List<String>> with the same <strong>
- * unqualified</strong> name will be looked up in the ValueComposite. If found, the EntityReferences in the
- * ManyAssociation will be converted to URIs and placed into a List and set to the Property in ValueComposite.</li>
- * <li>For any NamedAssociation in the EntityComposite, a Property<Map<String,String>> with the same
- * <strong>unqualified</strong> name will be looked up in the ValueComposite. If found, the EntityReferences in
- * the NamedAssociation will be converted to URIs and placed into a Map and set to the Property in ValueComposite.
- * </li>
- *
- * </ol>
- * <p>
- * If a Property from the Entity is not found in the Value, then it is ignored.
- * </p>
- * @deprecated Please use {@link org.apache.zest.api.unitofwork.UnitOfWork#toValue(Class, Identity)} instead.
- */
-public interface EntityToValueService extends EntityToValue, ServiceComposite
-{
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/5229303a/libraries/conversion/src/main/java/org/apache/zest/library/conversion/values/PropertyNotPresentException.java
----------------------------------------------------------------------
diff --git a/libraries/conversion/src/main/java/org/apache/zest/library/conversion/values/PropertyNotPresentException.java b/libraries/conversion/src/main/java/org/apache/zest/library/conversion/values/PropertyNotPresentException.java
deleted file mode 100644
index 1450852..0000000
--- a/libraries/conversion/src/main/java/org/apache/zest/library/conversion/values/PropertyNotPresentException.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-
-package org.apache.zest.library.conversion.values;
-
-import org.apache.zest.api.entity.EntityComposite;
-
-public class PropertyNotPresentException extends RuntimeException
-{
- private Class valueType;
- private Class<? extends EntityComposite> entityType;
-
- public PropertyNotPresentException( String message, Class valueType, Class<? extends EntityComposite> entityType )
- {
- super(message);
- this.valueType = valueType;
- this.entityType = entityType;
- }
-
- public Class valueType()
- {
- return valueType;
- }
-
- public Class entityType()
- {
- return entityType;
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/5229303a/libraries/conversion/src/main/java/org/apache/zest/library/conversion/values/Shared.java
----------------------------------------------------------------------
diff --git a/libraries/conversion/src/main/java/org/apache/zest/library/conversion/values/Shared.java b/libraries/conversion/src/main/java/org/apache/zest/library/conversion/values/Shared.java
deleted file mode 100644
index 936d086..0000000
--- a/libraries/conversion/src/main/java/org/apache/zest/library/conversion/values/Shared.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-package org.apache.zest.library.conversion.values;
-
-import java.util.function.Predicate;
-import org.apache.zest.api.type.CollectionType;
-import org.apache.zest.api.type.MapType;
-import org.apache.zest.api.type.ValueType;
-
-/**
- * Shared.
- */
-final class Shared
-{
- static final Predicate<ValueType> STRING_TYPE_SPEC;
- static final Predicate<ValueType> STRING_COLLECTION_TYPE_SPEC;
- static final Predicate<ValueType> STRING_MAP_TYPE_SPEC;
-
- static
- {
- // Type Specifications
- STRING_TYPE_SPEC = new Predicate<ValueType>()
- {
- @Override
- public boolean test( ValueType valueType )
- {
- return valueType.mainType().equals( String.class );
- }
- };
- STRING_COLLECTION_TYPE_SPEC = new Predicate<ValueType>()
- {
- @Override
- public boolean test( ValueType valueType )
- {
- return valueType instanceof CollectionType
- && ( (CollectionType) valueType ).collectedType().mainType().equals( String.class );
- }
- };
- STRING_MAP_TYPE_SPEC = new Predicate<ValueType>()
- {
- @Override
- public boolean test( ValueType valueType )
- {
- return valueType instanceof MapType
- && ( (MapType) valueType ).keyType().mainType().equals( String.class )
- && ( (MapType) valueType ).valueType().mainType().equals( String.class );
- }
- };
- }
-
- private Shared()
- {
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/5229303a/libraries/conversion/src/main/java/org/apache/zest/library/conversion/values/Unqualified.java
----------------------------------------------------------------------
diff --git a/libraries/conversion/src/main/java/org/apache/zest/library/conversion/values/Unqualified.java b/libraries/conversion/src/main/java/org/apache/zest/library/conversion/values/Unqualified.java
deleted file mode 100644
index 8e3497f..0000000
--- a/libraries/conversion/src/main/java/org/apache/zest/library/conversion/values/Unqualified.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-
-package org.apache.zest.library.conversion.values;
-
-import java.lang.annotation.*;
-
-/** If the ValueComposite is annotated with this, it means that the lookup of the Value Property should be performed
- * using the <strong>unqualified</strong> name only, and not via the default of the full qualified name. This
- * means that the Property may be declared in the different interfaces and still be matched.
- */
-@Retention( RetentionPolicy.RUNTIME )
-@Target( ElementType.TYPE )
-@Documented
-public @interface Unqualified
-{
- boolean value() default true;
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/5229303a/libraries/conversion/src/main/java/org/apache/zest/library/conversion/values/ValueToEntity.java
----------------------------------------------------------------------
diff --git a/libraries/conversion/src/main/java/org/apache/zest/library/conversion/values/ValueToEntity.java b/libraries/conversion/src/main/java/org/apache/zest/library/conversion/values/ValueToEntity.java
deleted file mode 100644
index 70ec04f..0000000
--- a/libraries/conversion/src/main/java/org/apache/zest/library/conversion/values/ValueToEntity.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-package org.apache.zest.library.conversion.values;
-
-import java.util.function.Function;
-import org.apache.zest.api.entity.EntityComposite;
-import org.apache.zest.api.entity.Identity;
-import org.apache.zest.api.unitofwork.NoSuchEntityException;
-import org.apache.zest.api.value.ValueComposite;
-
-/**
- * Create or update Entities from matching Values.
- * @deprecated Please use {@link org.apache.zest.api.unitofwork.UnitOfWork#toEntity(Class, Identity)} instead.
- */
-public interface ValueToEntity
-{
- /**
- * Create an Entity from a Value.
- * <p>
- * If the Value extends {@link Identity} the Entity identity is taken from the Value's state.
- * Else, if the Value's state for {@code Identity} is absent, a new Identity is generated.
- *
- * @param <T> Value Type
- * @param entityType Entity Type
- * @param value Value
- *
- * @return the created Entity
- */
- <T> T create( Class<T> entityType, Object value );
-
- /**
- * Create an Entity from a Value.
- * <p>
- * If {@code identity} is not null, it is used as Entity identity.
- * Else, if the Value extends {@link Identity} the Entity identity is taken from the Value's state.
- * Else, if the Value's state for {@code Identity} is absent, a new Identity is generated.
- *
- * @param <T> Value Type
- * @param entityType Entity Type
- * @param identity Entity Identity, may be null
- * @param value Value
- *
- * @return the created Entity
- */
- <T> T create( Class<T> entityType, String identity, Object value );
-
- /**
- * Create an Entity from a Value.
- * <p>
- * If the Value extends {@link Identity} the Entity identity is taken from the Value's state.
- * Else, if the Value's state for {@code Identity} is absent, a new Identity is generated.
- *
- * @param <T> Value Type
- * @param entityType Entity Type
- * @param value Value
- * @param prototypeOpportunity A Function that will be mapped on the Entity prototype before instanciation
- *
- * @return the created Entity
- */
- <T> T create( Class<T> entityType, Object value, Function<T, T> prototypeOpportunity );
-
- /**
- * Create an Entity from a Value.
- * <p>
- * If {@code identity} is not null, it is used as Entity identity.
- * Else, if the Value extends {@link Identity} the Entity identity is taken from the Value's state.
- * Else, if the Value's state for {@code Identity} is absent, a new Identity is generated.
- *
- * @param <T> Value Type
- * @param entityType Entity Type
- * @param identity Entity Identity, may be null
- * @param value Value
- * @param prototypeOpportunity A Function that will be mapped on the Entity prototype before instanciation
- *
- * @return the created Entity
- */
- <T> T create( Class<T> entityType, String identity, Object value, Function<T, T> prototypeOpportunity );
-
- /**
- * Create an Iterable of Entities from an Iterable of Values.
- * <p>
- * If a Value extends {@link Identity} the Entity identity is taken from the Value's state.
- * Else, if a Value's state for {@code Identity} is absent, a new Identity is generated.
- *
- * @param <T> Value Type
- * @param entityType Entity Type
- * @param values An Iterable of Values
- *
- * @return the Iterable of created Entities
- */
- <T> Iterable<T> create( Class<T> entityType, Iterable<Object> values );
-
- /**
- * Create an Iterable of Entities from an Iterable of Values.
- * <p>
- * If a Value extends {@link Identity} the Entity identity is taken from the Value's state.
- * Else, if a Value's state for {@code Identity} is absent, a new Identity is generated.
- *
- * @param <T> Value Type
- * @param entityType Entity Type
- * @param values An Iterable of Values
- * @param prototypeOpportunity A Function that will be mapped on each Entity prototype before instanciation
- *
- * @return the Iterable of created Entities
- */
- <T> Iterable<T> create( Class<T> entityType, Iterable<Object> values, Function<T, T> prototypeOpportunity );
-
- /**
- * Update an Entity from a Value.
- *
- * @param entity Entity
- * @param value Value
- *
- * @throws ClassCastException If {@code entity} is not an {@link EntityComposite}
- * or if {@code value} is not a {@link ValueComposite}
- * @throws NoSuchEntityException If some associated Entity is absent from the EntityStore/UoW
- */
- void update( Object entity, Object value )
- throws ClassCastException, NoSuchEntityException;
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/5229303a/libraries/conversion/src/main/java/org/apache/zest/library/conversion/values/ValueToEntityAssembler.java
----------------------------------------------------------------------
diff --git a/libraries/conversion/src/main/java/org/apache/zest/library/conversion/values/ValueToEntityAssembler.java b/libraries/conversion/src/main/java/org/apache/zest/library/conversion/values/ValueToEntityAssembler.java
deleted file mode 100644
index 6774712..0000000
--- a/libraries/conversion/src/main/java/org/apache/zest/library/conversion/values/ValueToEntityAssembler.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-package org.apache.zest.library.conversion.values;
-
-import org.apache.zest.api.entity.Identity;
-import org.apache.zest.bootstrap.Assemblers;
-import org.apache.zest.bootstrap.AssemblyException;
-import org.apache.zest.bootstrap.ModuleAssembly;
-import org.apache.zest.bootstrap.ServiceDeclaration;
-
-/**
- * ValueToEntity Service Assembler.
- * @deprecated Please use {@link org.apache.zest.api.unitofwork.UnitOfWork#toEntity(Class, Identity)} instead.
- */
-public class ValueToEntityAssembler
- extends Assemblers.VisibilityIdentity<ValueToEntityAssembler>
-{
- @Override
- public void assemble( ModuleAssembly module )
- throws AssemblyException
- {
- ServiceDeclaration service = module.services( ValueToEntityService.class ).visibleIn( visibility() );
- if( hasIdentity() )
- {
- service.identifiedBy( identity() );
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/5229303a/libraries/conversion/src/main/java/org/apache/zest/library/conversion/values/ValueToEntityMixin.java
----------------------------------------------------------------------
diff --git a/libraries/conversion/src/main/java/org/apache/zest/library/conversion/values/ValueToEntityMixin.java b/libraries/conversion/src/main/java/org/apache/zest/library/conversion/values/ValueToEntityMixin.java
deleted file mode 100644
index 52ec6da..0000000
--- a/libraries/conversion/src/main/java/org/apache/zest/library/conversion/values/ValueToEntityMixin.java
+++ /dev/null
@@ -1,730 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-package org.apache.zest.library.conversion.values;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.function.Function;
-import java.util.stream.Collectors;
-import org.apache.zest.api.association.Association;
-import org.apache.zest.api.association.AssociationDescriptor;
-import org.apache.zest.api.association.AssociationStateDescriptor;
-import org.apache.zest.api.association.AssociationStateHolder;
-import org.apache.zest.api.association.ManyAssociation;
-import org.apache.zest.api.association.NamedAssociation;
-import org.apache.zest.api.common.QualifiedName;
-import org.apache.zest.api.entity.EntityBuilder;
-import org.apache.zest.api.entity.EntityComposite;
-import org.apache.zest.api.entity.EntityDescriptor;
-import org.apache.zest.api.entity.EntityReference;
-import org.apache.zest.api.entity.Identity;
-import org.apache.zest.api.injection.scope.Structure;
-import org.apache.zest.api.property.PropertyDescriptor;
-import org.apache.zest.api.structure.ModuleDescriptor;
-import org.apache.zest.api.unitofwork.NoSuchEntityTypeException;
-import org.apache.zest.api.unitofwork.NoSuchEntityException;
-import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
-import org.apache.zest.api.value.ValueComposite;
-import org.apache.zest.api.value.ValueDescriptor;
-import org.apache.zest.functional.Iterables;
-import org.apache.zest.spi.ZestSPI;
-
-import static org.apache.zest.library.conversion.values.Shared.STRING_COLLECTION_TYPE_SPEC;
-import static org.apache.zest.library.conversion.values.Shared.STRING_MAP_TYPE_SPEC;
-import static org.apache.zest.library.conversion.values.Shared.STRING_TYPE_SPEC;
-
-/**
- * ValueToEntity Mixin.
- *
- * @deprecated Please use {@link org.apache.zest.api.unitofwork.UnitOfWork#toEntity(Class, Identity)} instead.
- */
-public class ValueToEntityMixin
- implements ValueToEntity
-{
- private static final QualifiedName IDENTITY_STATE_NAME;
- private static final Function<ManyAssociation<?>, Iterable<EntityReference>> MANY_ASSOC_TO_ENTITY_REF_ITERABLE;
- private static final Function<NamedAssociation<?>, Map<String, EntityReference>> NAMED_ASSOC_TO_ENTITY_REF_MAP;
- private static final Function<Collection<String>, Iterable<EntityReference>> STRING_COLLEC_TO_ENTITY_REF_ITERABLE;
- private static final Function<Map<String, String>, Map<String, EntityReference>> STRING_MAP_TO_ENTITY_REF_MAP;
-
- static
- {
- try
- {
- IDENTITY_STATE_NAME = QualifiedName.fromAccessor( Identity.class.getMethod( "identity" ) );
- }
- catch( NoSuchMethodException e )
- {
- throw new InternalError( "Zest Core Runtime codebase is corrupted. Contact Zest team: ValueToEntityMixin" );
- }
- MANY_ASSOC_TO_ENTITY_REF_ITERABLE = manyAssoc -> {
- if( manyAssoc == null )
- {
- return Iterables.empty();
- }
- List<EntityReference> refs = new ArrayList<>( manyAssoc.count() );
- for( Object entity : manyAssoc )
- {
- refs.add( EntityReference.entityReferenceFor( entity ) );
- }
- return refs;
- };
- NAMED_ASSOC_TO_ENTITY_REF_MAP = namedAssoc -> {
- if( namedAssoc == null )
- {
- return Collections.emptyMap();
- }
- Map<String, EntityReference> refs = new LinkedHashMap<>( namedAssoc.count() );
- for( String name : namedAssoc )
- {
- refs.put( name, EntityReference.entityReferenceFor( namedAssoc.get( name ) ) );
- }
- return refs;
- };
- STRING_COLLEC_TO_ENTITY_REF_ITERABLE = stringCollec -> {
- if( stringCollec == null )
- {
- return Iterables.empty();
- }
- return stringCollec.stream()
- .map( EntityReference::parseEntityReference )
- .collect( Collectors.toList() );
- };
- STRING_MAP_TO_ENTITY_REF_MAP = stringMap -> {
- if( stringMap == null )
- {
- return Collections.emptyMap();
- }
- Map<String, EntityReference> refMap = new LinkedHashMap<>( stringMap.size() );
- for( Map.Entry<String, String> entry : stringMap.entrySet() )
- {
- refMap.put( entry.getKey(), EntityReference.parseEntityReference( entry.getValue() ) );
- }
- return refMap;
- };
- }
-
- @Structure
- private ZestSPI spi;
-
- @Structure
- private UnitOfWorkFactory uowf;
-
- @Structure
- private ModuleDescriptor module;
-
- @Override
- public <T> T create( Class<T> entityType, Object value )
- {
- return createInstance( doConversion( entityType, null, value ) );
- }
-
- @Override
- public <T> T create( Class<T> entityType, String identity, Object value )
- {
- return createInstance( doConversion( entityType, identity, value ) );
- }
-
- @Override
- public <T> T create( Class<T> entityType, Object value, Function<T, T> prototypeOpportunity )
- {
- EntityBuilder<?> builder = doConversion( entityType, null, value );
- //noinspection unchecked
- prototypeOpportunity.apply( (T) builder.instance() );
- return createInstance( builder );
- }
-
- @Override
- public <T> T create( Class<T> entityType, String identity, Object value, Function<T, T> prototypeOpportunity )
- {
- EntityBuilder<?> builder = doConversion( entityType, identity, value );
- //noinspection unchecked
- prototypeOpportunity.apply( (T) builder.instance() );
- return createInstance( builder );
- }
-
- @Override
- public <T> Iterable<T> create( final Class<T> entityType, final Iterable<Object> values )
- {
- return Iterables.map(
- value -> create( entityType, value ),
- values
- );
- }
-
- @Override
- public <T> Iterable<T> create( final Class<T> entityType,
- final Iterable<Object> values,
- final Function<T, T> prototypeOpportunity
- )
- {
- return Iterables.map(
- value -> create( entityType, value, prototypeOpportunity ),
- values
- );
- }
-
- private <T> EntityBuilder<?> doConversion( Class<T> entityType, String identity, Object value )
- {
- EntityDescriptor eDesc = module.entityDescriptor( entityType.getName() );
- if( eDesc == null )
- {
- throw new NoSuchEntityTypeException( entityType.getName(), module.name(), module.typeLookup() );
- }
-
- ValueComposite vComposite = (ValueComposite) value;
-
- ValueDescriptor vDesc = spi.valueDescriptorFor( vComposite );
- AssociationStateHolder vState = spi.stateOf( vComposite );
- AssociationStateDescriptor vStateDesc = vDesc.state();
-
- Unqualified unqualified = vDesc.metaInfo( Unqualified.class );
- if( unqualified == null || !unqualified.value() )
- {
- return doQualifiedConversion( entityType, identity, vState, vStateDesc );
- }
- return doUnqualifiedConversion( entityType, identity, vState, vStateDesc );
- }
-
- private <T> EntityBuilder<?> doQualifiedConversion(
- Class<T> entityType, String identity,
- final AssociationStateHolder vState, final AssociationStateDescriptor vStateDesc
- )
- {
- Function<PropertyDescriptor, Object> props = ePropDesc -> {
- try
- {
- return vState.propertyFor( ePropDesc.accessor() ).get();
- }
- catch( IllegalArgumentException propNotFoundOnValue )
- {
- // Property not found
- return null;
- }
- };
- Function<AssociationDescriptor, EntityReference> assocs = eAssocDesc -> {
- try
- {
- return EntityReference.entityReferenceFor( vState.associationFor( eAssocDesc.accessor() ) );
- }
- catch( IllegalArgumentException assocNotFoundOnValue )
- {
- // Find String Property and convert to Association
- String propName = eAssocDesc.qualifiedName().name();
- try
- {
- PropertyDescriptor vPropDesc = vStateDesc.findPropertyModelByName( propName );
- if( STRING_TYPE_SPEC.test( vPropDesc.valueType() ) )
- {
- String assocState = (String) vState.propertyFor( vPropDesc.accessor() ).get();
- return EntityReference.parseEntityReference( assocState );
- }
- return null;
- }
- catch( IllegalArgumentException propNotFoundOnValue )
- {
- return null;
- }
- }
- };
- Function<AssociationDescriptor, Iterable<EntityReference>> manyAssocs = eAssocDesc -> {
- try
- {
- ManyAssociation<Object> vAssocState = vState.manyAssociationFor( eAssocDesc.accessor() );
- return MANY_ASSOC_TO_ENTITY_REF_ITERABLE.apply( vAssocState );
- }
- catch( IllegalArgumentException assocNotFoundOnValue )
- {
- // Find Collection<String> Property and convert to ManyAssociation
- String propName = eAssocDesc.qualifiedName().name();
- try
- {
- PropertyDescriptor vPropDesc = vStateDesc.findPropertyModelByName( propName );
- if( STRING_COLLECTION_TYPE_SPEC.test( vPropDesc.valueType() ) )
- {
- @SuppressWarnings( "unchecked" )
- Collection<String> vAssocState = (Collection) vState.propertyFor( vPropDesc.accessor() ).get();
- return STRING_COLLEC_TO_ENTITY_REF_ITERABLE.apply( vAssocState );
- }
- return Iterables.empty();
- }
- catch( IllegalArgumentException propNotFoundOnValue )
- {
- return Iterables.empty();
- }
- }
- };
- Function<AssociationDescriptor, Map<String, EntityReference>> namedAssocs = eAssocDesc -> {
- try
- {
- NamedAssociation<?> vAssocState = vState.namedAssociationFor( eAssocDesc.accessor() );
- return NAMED_ASSOC_TO_ENTITY_REF_MAP.apply( vAssocState );
- }
- catch( IllegalArgumentException assocNotFoundOnValue )
- {
- // Find Map<String,String> Property and convert to NamedAssociation
- String propName = eAssocDesc.qualifiedName().name();
- try
- {
- PropertyDescriptor vPropDesc = vStateDesc.findPropertyModelByName( propName );
- if( STRING_MAP_TYPE_SPEC.test( vPropDesc.valueType() ) )
- {
- //noinspection unchecked
- Map<String, String> vAssocState = (Map) vState.propertyFor( vPropDesc.accessor() ).get();
- return STRING_MAP_TO_ENTITY_REF_MAP.apply( vAssocState );
- }
- return Collections.EMPTY_MAP;
- }
- catch( IllegalArgumentException propNotFoundOnValue )
- {
- return Collections.EMPTY_MAP;
- }
- }
- };
- return uowf.currentUnitOfWork().newEntityBuilderWithState(
- entityType, identity, props, assocs, manyAssocs, namedAssocs
- );
- }
-
- private <T> EntityBuilder<?> doUnqualifiedConversion(
- Class<T> entityType, String identity,
- final AssociationStateHolder vState, final AssociationStateDescriptor vStateDesc
- )
- {
- Function<PropertyDescriptor, Object> props = ePropDesc -> {
- String propName = ePropDesc.qualifiedName().name();
- try
- {
- PropertyDescriptor vPropDesc = vStateDesc.findPropertyModelByName( propName );
- return vState.propertyFor( vPropDesc.accessor() ).get();
- }
- catch( IllegalArgumentException propNotFoundOnValue )
- {
- // Property not found on Value
- return null;
- }
- };
- Function<AssociationDescriptor, EntityReference> assocs = eAssocDesc -> {
- String assocName = eAssocDesc.qualifiedName().name();
- try
- {
- AssociationDescriptor vAssocDesc = vStateDesc.getAssociationByName( assocName );
- Object assocEntity = vState.associationFor( vAssocDesc.accessor() ).get();
- return assocEntity == null ? null : EntityReference.entityReferenceFor( assocEntity );
- }
- catch( IllegalArgumentException assocNotFoundOnValue )
- {
- // Association not found on Value, find Property<String> and convert to Association
- try
- {
- PropertyDescriptor vPropDesc = vStateDesc.findPropertyModelByName( assocName );
- if( STRING_TYPE_SPEC.test( vPropDesc.valueType() ) )
- {
- String assocId = (String) vState.propertyFor( vPropDesc.accessor() ).get();
- return assocId == null ? null : EntityReference.parseEntityReference( assocId );
- }
- return null;
- }
- catch( IllegalArgumentException propNotFoundOnValue )
- {
- return null;
- }
- }
- };
- Function<AssociationDescriptor, Iterable<EntityReference>> manyAssocs = eAssocDesc -> {
- String assocName = eAssocDesc.qualifiedName().name();
- try
- {
- AssociationDescriptor vAssocDesc = vStateDesc.getManyAssociationByName( assocName );
- ManyAssociation<Object> vManyAssoc = vState.manyAssociationFor( vAssocDesc.accessor() );
- return MANY_ASSOC_TO_ENTITY_REF_ITERABLE.apply( vManyAssoc );
- }
- catch( IllegalArgumentException assocNotFoundOnValue )
- {
- // ManyAssociation not found on Value, find List<String> and convert to ManyAssociation
- try
- {
- PropertyDescriptor vPropDesc = vStateDesc.findPropertyModelByName( assocName );
- if( STRING_COLLECTION_TYPE_SPEC.test( vPropDesc.valueType() ) )
- {
- @SuppressWarnings( "unchecked" )
- Collection<String> vAssocState = (Collection) vState.propertyFor( vPropDesc.accessor() ).get();
- return STRING_COLLEC_TO_ENTITY_REF_ITERABLE.apply( vAssocState );
- }
- return Iterables.empty();
- }
- catch( IllegalArgumentException propNotFoundOnValue )
- {
- return Iterables.empty();
- }
- }
- };
- Function<AssociationDescriptor, Map<String, EntityReference>> namedAssocs = eAssocDesc -> {
- String assocName = eAssocDesc.qualifiedName().name();
- try
- {
- AssociationDescriptor vAssocDesc = vStateDesc.getNamedAssociationByName( assocName );
- NamedAssociation<Object> vAssocState = vState.namedAssociationFor( vAssocDesc.accessor() );
- return NAMED_ASSOC_TO_ENTITY_REF_MAP.apply( vAssocState );
- }
- catch( IllegalArgumentException assocNotFoundOnValue )
- {
- // Find Map<String,String> Property and convert to NamedAssociation
- try
- {
- PropertyDescriptor vPropDesc = vStateDesc.findPropertyModelByName( assocName );
- if( STRING_MAP_TYPE_SPEC.test( vPropDesc.valueType() ) )
- {
- @SuppressWarnings( "unchecked" )
- Map<String, String> vAssocState = (Map) vState.propertyFor( vPropDesc.accessor() ).get();
- return STRING_MAP_TO_ENTITY_REF_MAP.apply( vAssocState );
- }
- return Collections.EMPTY_MAP;
- }
- catch( IllegalArgumentException propNotFoundOnValue )
- {
- return Collections.EMPTY_MAP;
- }
- }
- };
- return uowf.currentUnitOfWork().newEntityBuilderWithState(
- entityType, identity, props, assocs, manyAssocs, namedAssocs
- );
- }
-
- protected <T> T createInstance( EntityBuilder<?> builder )
- {
- //noinspection unchecked
- return (T) builder.newInstance();
- }
-
- @Override
- public void update( Object entity, Object value )
- throws NoSuchEntityException
- {
- EntityComposite eComposite = (EntityComposite) entity;
- ValueComposite vComposite = (ValueComposite) value;
-
- EntityDescriptor eDesc = spi.entityDescriptorFor( eComposite );
- AssociationStateHolder eState = spi.stateOf( eComposite );
- AssociationStateDescriptor eStateDesc = eDesc.state();
-
- ValueDescriptor vDesc = spi.valueDescriptorFor( vComposite );
- AssociationStateHolder vState = spi.stateOf( vComposite );
- AssociationStateDescriptor vStateDesc = vDesc.state();
-
- Unqualified unqualified = vDesc.metaInfo( Unqualified.class );
- if( unqualified == null || !unqualified.value() )
- {
- doQualifiedUpdate( eState, eStateDesc, vState, vStateDesc );
- }
- else
- {
- doUnQualifiedUpdate( eState, eStateDesc, vState, vStateDesc );
- }
- }
-
- private void doQualifiedUpdate(
- AssociationStateHolder eState, AssociationStateDescriptor eStateDesc,
- AssociationStateHolder vState, AssociationStateDescriptor vStateDesc
- )
- throws NoSuchEntityException
- {
- eStateDesc.properties().forEach( ePropDesc ->
- {
- if( ! IDENTITY_STATE_NAME.equals( ePropDesc.qualifiedName() ) )
- {
- try
- {
- PropertyDescriptor vPropDesc = vStateDesc.findPropertyModelByQualifiedName( ePropDesc.qualifiedName() );
- eState.propertyFor( ePropDesc.accessor() ).set( vState.propertyFor( vPropDesc.accessor() ).get() );
- }
- catch( IllegalArgumentException propNotFoundOnValue )
- {
- // Property not found on Value, do nothing
- }
- }
- } );
- eStateDesc.associations().forEach( eAssocDesc ->
- {
- Association<Object> eAssoc = eState.associationFor( eAssocDesc.accessor() );
- try
- {
- AssociationDescriptor vAssocDesc
- = vStateDesc.getAssociationByQualifiedName( eAssocDesc.qualifiedName() );
- eAssoc.set( vState.associationFor( vAssocDesc.accessor() ).get() );
- }
- catch( IllegalArgumentException assocNotFoundOnValue )
- {
- // Association not found on Value, find Property<String> and load associated Entity
- try
- {
- PropertyDescriptor vPropDesc
- = vStateDesc.findPropertyModelByName( eAssocDesc.qualifiedName().name() );
- if( STRING_TYPE_SPEC.test( vPropDesc.valueType() ) )
- {
- String assocId = (String) vState.propertyFor( vPropDesc.accessor() ).get();
- if( assocId != null )
- {
- eAssoc.set( uowf.currentUnitOfWork().get( (Class) eAssocDesc.type(), assocId ) );
- }
- else
- {
- eAssoc.set( null );
- }
- }
- }
- catch( IllegalArgumentException propNotFoundOnValue )
- {
- // Do nothing
- }
- }
- });
- eStateDesc.manyAssociations().forEach( eAssocDesc ->
- {
- ManyAssociation<Object> eManyAssoc = eState.manyAssociationFor( eAssocDesc.accessor() );
- try
- {
- AssociationDescriptor vAssocDesc
- = vStateDesc.getManyAssociationByQualifiedName( eAssocDesc.qualifiedName() );
- ManyAssociation<Object> vManyAssoc = vState.manyAssociationFor( vAssocDesc.accessor() );
- eManyAssoc.toList().forEach( eManyAssoc::remove );
- vManyAssoc.toList().forEach( eManyAssoc::add );
- }
- catch( IllegalArgumentException assocNotFoundOnValue )
- {
- // ManyAssociation not found on Value, find Property<List<String>> and load associated Entities
- try
- {
- PropertyDescriptor vPropDesc
- = vStateDesc.findPropertyModelByName( eAssocDesc.qualifiedName().name() );
- if( STRING_COLLECTION_TYPE_SPEC.test( vPropDesc.valueType() ) )
- {
- @SuppressWarnings( "unchecked" )
- Collection<String> vAssocState = (Collection) vState.propertyFor( vPropDesc.accessor() ).get();
- eManyAssoc.toList().forEach( eManyAssoc::remove );
- if( vAssocState != null )
- {
- for( String eachAssoc : vAssocState )
- {
- eManyAssoc.add(
- uowf.currentUnitOfWork().get( (Class) eAssocDesc.type(), eachAssoc )
- );
- }
- }
- }
- }
- catch( IllegalArgumentException propNotFoundOnValue )
- {
- // Do nothing
- }
- }
- });
- eStateDesc.namedAssociations().forEach( eAssocDesc ->
- {
- NamedAssociation<Object> eNamedAssoc = eState.namedAssociationFor( eAssocDesc.accessor() );
- try
- {
- AssociationDescriptor vAssocDesc
- = vStateDesc.getNamedAssociationByQualifiedName( eAssocDesc.qualifiedName() );
- NamedAssociation<Object> vNamedAssoc = vState.namedAssociationFor( vAssocDesc.accessor() );
- Iterables.toList( eNamedAssoc ).forEach( eNamedAssoc::remove );
- for( Map.Entry<String, Object> assocEntry : vNamedAssoc.toMap().entrySet() )
- {
- eNamedAssoc.put( assocEntry.getKey(), assocEntry.getValue() );
- }
- }
- catch( IllegalArgumentException assocNotFoundOnValue )
- {
- // NamedAssociation not found on Value, find Property<Map<String,String>> and load associated Entities
- try
- {
- PropertyDescriptor vPropDesc
- = vStateDesc.findPropertyModelByName( eAssocDesc.qualifiedName().name() );
- if( STRING_MAP_TYPE_SPEC.test( vPropDesc.valueType() ) )
- {
- @SuppressWarnings( "unchecked" )
- Map<String, String> vAssocState = (Map) vState.propertyFor( vPropDesc.accessor() ).get();
- Iterables.toList( eNamedAssoc ).forEach( eNamedAssoc::remove );
- if( vAssocState != null )
- {
- for( Map.Entry<String, String> assocEntry : vAssocState.entrySet() )
- {
- eNamedAssoc.put(
- assocEntry.getKey(),
- uowf.currentUnitOfWork().get( (Class) eAssocDesc.type(), assocEntry.getValue() )
- );
- }
- }
- }
- }
- catch( IllegalArgumentException propNotFoundOnValue )
- {
- // Do nothing
- }
- }
- } );
- }
-
- private void doUnQualifiedUpdate(
- AssociationStateHolder eState, AssociationStateDescriptor eStateDesc,
- AssociationStateHolder vState, AssociationStateDescriptor vStateDesc
- )
- {
- eStateDesc.properties().forEach( ePropDesc ->
- {
- if( ! IDENTITY_STATE_NAME.equals( ePropDesc.qualifiedName() ) )
- {
- try
- {
- PropertyDescriptor vPropDesc = vStateDesc.findPropertyModelByName( ePropDesc.qualifiedName().name() );
- eState.propertyFor( ePropDesc.accessor() ).set( vState.propertyFor( vPropDesc.accessor() ).get() );
- }
- catch( IllegalArgumentException propNotFoundOnValue )
- {
- // Property not found on Value, do nothing
- }
- }
- } );
- eStateDesc.associations().forEach( eAssocDesc ->
- {
- Association<Object> eAssoc = eState.associationFor( eAssocDesc.accessor() );
- try
- {
- AssociationDescriptor vAssocDesc = vStateDesc.getAssociationByName( eAssocDesc.qualifiedName().name() );
- eAssoc.set( vState.associationFor( vAssocDesc.accessor() ).get() );
- }
- catch( IllegalArgumentException assocNotFoundOnValue )
- {
- // Association not found on Value, find Property<String> and load associated Entity
- try
- {
- PropertyDescriptor vPropDesc
- = vStateDesc.findPropertyModelByName( eAssocDesc.qualifiedName().name() );
- if( STRING_TYPE_SPEC.test( vPropDesc.valueType() ) )
- {
- String assocId = (String) vState.propertyFor( vPropDesc.accessor() ).get();
- if( assocId != null )
- {
- eAssoc.set( uowf.currentUnitOfWork().get( (Class) eAssocDesc.type(), assocId ) );
- }
- else
- {
- eAssoc.set( null );
- }
- }
- }
- catch( IllegalArgumentException propNotFoundOnValue )
- {
- // Do nothing
- }
- }
- } );
- eStateDesc.manyAssociations().forEach( eAssocDesc ->
- {
- ManyAssociation<Object> eManyAssoc = eState.manyAssociationFor( eAssocDesc.accessor() );
- try
- {
- AssociationDescriptor vAssDesc
- = vStateDesc.getManyAssociationByName( eAssocDesc.qualifiedName().name() );
- ManyAssociation<Object> vManyAss = vState.manyAssociationFor( vAssDesc.accessor() );
- eManyAssoc.toList().forEach( eManyAssoc::remove );
- vManyAss.toList().forEach( eManyAssoc::add );
- }
- catch( IllegalArgumentException assNotFoundOnValue )
- {
- // ManyAssociation not found on Value, find Property<List<String>> and load associated Entities
- try
- {
- PropertyDescriptor vPropDesc
- = vStateDesc.findPropertyModelByName( eAssocDesc.qualifiedName().name() );
- if( STRING_COLLECTION_TYPE_SPEC.test( vPropDesc.valueType() ) )
- {
- @SuppressWarnings( "unchecked" )
- Collection<String> vAssocState = (Collection) vState.propertyFor( vPropDesc.accessor() ).get();
- eManyAssoc.toList().forEach( eManyAssoc::remove );
- if( vAssocState != null )
- {
- vAssocState.forEach( eachAssoc ->
- {
- eManyAssoc.add(
- uowf.currentUnitOfWork().get( (Class<?>) eAssocDesc.type(), eachAssoc )
- );
- } );
- }
- }
- }
- catch( IllegalArgumentException propNotFoundOnValue )
- {
- // Do nothing
- }
- }
- } );
- eStateDesc.namedAssociations().forEach( eAssocDesc ->
- {
- NamedAssociation<Object> eNamedAssoc = eState.namedAssociationFor( eAssocDesc.accessor() );
- try
- {
- AssociationDescriptor vAssocDesc
- = vStateDesc.getNamedAssociationByName( eAssocDesc.qualifiedName().name() );
- NamedAssociation<Object> vNamedAssoc = vState.namedAssociationFor( vAssocDesc.accessor() );
- Iterables.toList( eNamedAssoc ).forEach( eNamedAssoc::remove );
- for( Map.Entry<String, Object> assocEntry : vNamedAssoc.toMap().entrySet() )
- {
- eNamedAssoc.put( assocEntry.getKey(), assocEntry.getValue() );
- }
- }
- catch( IllegalArgumentException assocNotFoundOnValue )
- {
- // NamedAssociation not found on Value, find Property<Map<String,String>> and load associated Entities
- try
- {
- PropertyDescriptor vPropDesc
- = vStateDesc.findPropertyModelByName( eAssocDesc.qualifiedName().name() );
- if( STRING_MAP_TYPE_SPEC.test( vPropDesc.valueType() ) )
- {
- @SuppressWarnings( "unchecked" )
- Map<String, String> vAssocState =
- (Map<String,String>) vState.propertyFor( vPropDesc.accessor() ).get();
- Iterables.toList( eNamedAssoc ).forEach( eNamedAssoc::remove );
- if( vAssocState != null )
- {
- for( Map.Entry<String, String> assocEntry : vAssocState.entrySet() )
- {
- eNamedAssoc.put(
- assocEntry.getKey(),
- uowf.currentUnitOfWork().get( (Class) eAssocDesc.type(), assocEntry.getValue() )
- );
- }
- }
- }
- }
- catch( IllegalArgumentException propNotFoundOnValue )
- {
- // Do nothing
- }
- }
- } );
- }
-}
[17/25] zest-java git commit: Merge remote-tracking branch
'origin/develop' into develop
Posted by ni...@apache.org.
Merge remote-tracking branch 'origin/develop' into develop
Project: http://git-wip-us.apache.org/repos/asf/zest-java/repo
Commit: http://git-wip-us.apache.org/repos/asf/zest-java/commit/5762bf83
Tree: http://git-wip-us.apache.org/repos/asf/zest-java/tree/5762bf83
Diff: http://git-wip-us.apache.org/repos/asf/zest-java/diff/5762bf83
Branch: refs/heads/ValueSerializationCleaning
Commit: 5762bf83f94c23fc935e8b48efe86fd18774bb75
Parents: 4275718 eb9ec0d
Author: Niclas Hedhman <ni...@hedhman.org>
Authored: Sun Jun 12 23:25:07 2016 +0800
Committer: Niclas Hedhman <ni...@hedhman.org>
Committed: Sun Jun 12 23:25:07 2016 +0800
----------------------------------------------------------------------
.../runtime/composite/FragmentClassLoader.java | 28 +++++++--------
.../runtime/composite/TransientClassLoader.java | 26 +++++---------
extensions/reindexer/dev-status.xml | 2 +-
extensions/reindexer/src/docs/reindexer.txt | 38 ++++++++++++++++++--
.../zest/index/reindexer/ReindexerTest.java | 7 +++-
manual/src/docs/userguide/libraries.txt | 4 ---
6 files changed, 64 insertions(+), 41 deletions(-)
----------------------------------------------------------------------
[03/25] 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.
Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/itinerary/Leg.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/itinerary/Leg.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/itinerary/Leg.java
index 8044a3e..ca0f9fc 100644
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/itinerary/Leg.java
+++ b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/itinerary/Leg.java
@@ -19,7 +19,8 @@
*/
package org.apache.zest.sample.dcicargo.sample_a.data.shipping.itinerary;
-import java.util.Date;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
import org.apache.zest.api.association.Association;
import org.apache.zest.api.property.Property;
import org.apache.zest.api.value.ValueComposite;
@@ -38,11 +39,11 @@ public interface Leg
{
Association<Location> loadLocation();
- Property<Date> loadTime();
+ Property<LocalDate> loadDate();
Association<Voyage> voyage();
- Property<Date> unloadTime();
+ Property<LocalDate> unloadDate();
Association<Location> unloadLocation();
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/voyage/CarrierMovement.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/voyage/CarrierMovement.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/voyage/CarrierMovement.java
index dca0c20..5391319 100644
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/voyage/CarrierMovement.java
+++ b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/data/shipping/voyage/CarrierMovement.java
@@ -19,7 +19,7 @@
*/
package org.apache.zest.sample.dcicargo.sample_a.data.shipping.voyage;
-import java.util.Date;
+import java.time.LocalDate;
import org.apache.zest.api.association.Association;
import org.apache.zest.api.property.Property;
import org.apache.zest.api.value.ValueComposite;
@@ -37,7 +37,7 @@ public interface CarrierMovement
Association<Location> arrivalLocation();
- Property<Date> departureTime();
+ Property<LocalDate> departureDate();
- Property<Date> arrivalTime();
+ Property<LocalDate> arrivalDate();
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/wicket/form/DateTextFieldWithPicker.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/wicket/form/DateTextFieldWithPicker.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/wicket/form/DateTextFieldWithPicker.java
index 9c0dccb..0237052 100644
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/wicket/form/DateTextFieldWithPicker.java
+++ b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/wicket/form/DateTextFieldWithPicker.java
@@ -20,7 +20,10 @@
package org.apache.zest.sample.dcicargo.sample_a.infrastructure.wicket.form;
import com.google.code.joliratools.StatelessAjaxEventBehavior;
-import java.util.Date;
+import java.time.LocalDate;
+import java.time.LocalTime;
+import java.time.ZoneOffset;
+import java.time.format.DateTimeFormatter;
import java.util.Map;
import org.apache.wicket.Component;
import org.apache.wicket.ajax.AjaxRequestTarget;
@@ -35,9 +38,8 @@ import org.apache.wicket.model.Model;
import org.apache.wicket.model.PropertyModel;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.apache.wicket.validation.validator.DateValidator;
-import org.joda.time.DateTime;
-import org.joda.time.LocalDate;
-import org.joda.time.LocalTime;
+
+import static java.util.Date.from;
//import org.wicketstuff.stateless.StatelessAjaxEventBehavior;
@@ -50,18 +52,17 @@ public class DateTextFieldWithPicker extends DateTextField
DatePicker datePicker;
// Configurable widget options
- LocalDate earliestDate;
- LocalDate selectedDate;
+ private LocalDate earliestDate;
+ private LocalDate selectedDate;
- final static String YUI_DATE_FORMAT = "MM/dd/yyyy";
+ private final static DateTimeFormatter YUI_DATE_FORMAT = DateTimeFormatter.ofPattern( "MM/dd/yyyy" );
public DateTextFieldWithPicker( String id, String label, Component model )
{
-// this( id, new PropertyModel<Date>( model, id ), new StyleDateConverter( "S-", true ) );
- this( id, label, new PropertyModel<Date>( model, id ), new PatternDateConverter( "yyyy-MM-dd", true ) );
+ this( id, label, new PropertyModel<>( model, id ), new PatternDateConverter( "yyyy-MM-dd", true ) );
}
- public DateTextFieldWithPicker( String id, String label, IModel<Date> model, DateConverter converter )
+ public DateTextFieldWithPicker( String id, String label, IModel<java.util.Date> model, DateConverter converter )
{
super( id, model, converter );
@@ -189,9 +190,7 @@ public class DateTextFieldWithPicker extends DateTextField
// Input field validation - date should be _after_ minimumDate (not the same)
LocalDate minimumDate = newEarliestDate.minusDays( 1 );
- Date convertedMinimumDate = new DateTime( minimumDate.toDateTime( new LocalTime() ) ).toDate();
- add( DateValidator.minimum( convertedMinimumDate ) );
-
+ add( DateValidator.minimum( from( minimumDate.atTime( LocalTime.now() ).toInstant( ZoneOffset.UTC ) ) ) );
return this;
}
@@ -213,17 +212,17 @@ public class DateTextFieldWithPicker extends DateTextField
{
if( selectedDate != null )
{
- return selectedDate.toString( YUI_DATE_FORMAT );
+ return YUI_DATE_FORMAT.format( selectedDate );
}
// Select today or earliest date (if later) as default
return earliestDate == null ?
- new LocalDate().toString( YUI_DATE_FORMAT ) :
- earliestDate.toString( YUI_DATE_FORMAT );
+ YUI_DATE_FORMAT.format( LocalDate.now() ) :
+ YUI_DATE_FORMAT.format( earliestDate );
}
private String getEarliestDateStr()
{
- return earliestDate == null ? "" : earliestDate.toString( YUI_DATE_FORMAT );
+ return earliestDate == null ? "" : YUI_DATE_FORMAT.format( earliestDate );
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/wicket/prevnext/PrevNext.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/wicket/prevnext/PrevNext.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/wicket/prevnext/PrevNext.java
index 3c69a82..c6c955e 100644
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/wicket/prevnext/PrevNext.java
+++ b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/sample_a/infrastructure/wicket/prevnext/PrevNext.java
@@ -19,6 +19,7 @@
*/
package org.apache.zest.sample.dcicargo.sample_a.infrastructure.wicket.prevnext;
+import java.io.Serializable;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
@@ -45,14 +46,14 @@ public class PrevNext extends Panel
private static final long serialVersionUID = 1L;
};
- public static void registerIds( Session session, ArrayList<String> ids )
+ public static void registerIds( Session session, List<String> ids )
{
if( ids == null || ids.isEmpty() )
{
throw new RuntimeException( "Please register a list of ids." );
}
- session.setMetaData( PREV_NEXT_PANEL_KEY, ids );
+ session.setMetaData( PREV_NEXT_PANEL_KEY, (Serializable) ids );
session.bind();
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/samples/dci-cargo/dcisample_a/src/main/resources/org/apache/zest/sample/dcicargo/sample_a/communication/web/booking/CargoDetailsPage.html
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/resources/org/apache/zest/sample/dcicargo/sample_a/communication/web/booking/CargoDetailsPage.html b/samples/dci-cargo/dcisample_a/src/main/resources/org/apache/zest/sample/dcicargo/sample_a/communication/web/booking/CargoDetailsPage.html
index e16a0a2..a0f6d15 100644
--- a/samples/dci-cargo/dcisample_a/src/main/resources/org/apache/zest/sample/dcicargo/sample_a/communication/web/booking/CargoDetailsPage.html
+++ b/samples/dci-cargo/dcisample_a/src/main/resources/org/apache/zest/sample/dcicargo/sample_a/communication/web/booking/CargoDetailsPage.html
@@ -93,9 +93,9 @@
<tr wicket:id="legs">
<td wicket:id="voyage"></td>
<td wicket:id="loadLocation"></td>
- <td wicket:id="loadTime"></td>
+ <td wicket:id="loadDate"></td>
<td wicket:id="unloadLocation"></td>
- <td wicket:id="unloadTime"></td>
+ <td wicket:id="unloadDate"></td>
</tr>
</tbody>
</table>
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/samples/dci-cargo/dcisample_a/src/main/resources/org/apache/zest/sample/dcicargo/sample_a/communication/web/booking/RoutePanel.html
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/resources/org/apache/zest/sample/dcicargo/sample_a/communication/web/booking/RoutePanel.html b/samples/dci-cargo/dcisample_a/src/main/resources/org/apache/zest/sample/dcicargo/sample_a/communication/web/booking/RoutePanel.html
index fc3ea2e..3cf259f 100644
--- a/samples/dci-cargo/dcisample_a/src/main/resources/org/apache/zest/sample/dcicargo/sample_a/communication/web/booking/RoutePanel.html
+++ b/samples/dci-cargo/dcisample_a/src/main/resources/org/apache/zest/sample/dcicargo/sample_a/communication/web/booking/RoutePanel.html
@@ -51,9 +51,9 @@
<tr wicket:id="legs">
<td wicket:id="voyage"></td>
<td wicket:id="loadLocation"></td>
- <td wicket:id="loadTime"></td>
+ <td wicket:id="loadDate"></td>
<td wicket:id="unloadLocation"></td>
- <td wicket:id="unloadTime"></td>
+ <td wicket:id="unloadDate"></td>
</tr>
</tbody>
</table>
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/booking/BookNewCargoTest.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/booking/BookNewCargoTest.java b/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/booking/BookNewCargoTest.java
index fffcb68..2256c1a 100644
--- a/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/booking/BookNewCargoTest.java
+++ b/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/booking/BookNewCargoTest.java
@@ -19,12 +19,11 @@
*/
package org.apache.zest.sample.dcicargo.sample_a.context.shipping.booking;
-import java.util.Date;
+import java.time.LocalDate;
+import java.time.ZoneOffset;
import java.util.List;
-import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
-import org.junit.Before;
-import org.junit.Test;
import org.apache.zest.api.unitofwork.UnitOfWork;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
import org.apache.zest.sample.dcicargo.sample_a.bootstrap.test.TestApplication;
import org.apache.zest.sample.dcicargo.sample_a.context.support.FoundNoRoutesException;
import org.apache.zest.sample.dcicargo.sample_a.data.entity.CargosEntity;
@@ -37,10 +36,13 @@ import org.apache.zest.sample.dcicargo.sample_a.data.shipping.delivery.Transport
import org.apache.zest.sample.dcicargo.sample_a.data.shipping.handling.HandlingEventType;
import org.apache.zest.sample.dcicargo.sample_a.data.shipping.itinerary.Itinerary;
import org.apache.zest.sample.dcicargo.sample_a.data.shipping.location.Location;
+import org.junit.Before;
+import org.junit.Test;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
/**
* Test of Book New Cargo use case.
@@ -51,10 +53,10 @@ import static org.junit.Assert.*;
* Test method names describe the test purpose. The prefix refers to the step in the use case.
*/
public class BookNewCargoTest
- extends TestApplication
+ extends TestApplication
{
- private static final Date TODAY = new Date();
+ private static final LocalDate TODAY = LocalDate.now();
private UnitOfWorkFactory uowf;
@Before
@@ -66,7 +68,8 @@ public class BookNewCargoTest
}
@Test( expected = RouteException.class )
- public void deviation2a_OriginAndDestinationSame() throws Exception
+ public void deviation2a_OriginAndDestinationSame()
+ throws Exception
{
UnitOfWork uow = uowf.currentUnitOfWork();
Location HONGKONG = uow.get( Location.class, CNHKG.code().get() );
@@ -75,7 +78,8 @@ public class BookNewCargoTest
}
@Test( expected = RouteException.class )
- public void deviation_2b_1_DeadlineInThePastNotAccepted() throws Exception
+ public void deviation_2b_1_DeadlineInThePastNotAccepted()
+ throws Exception
{
UnitOfWork uow = uowf.currentUnitOfWork();
Location HONGKONG = uow.get( Location.class, CNHKG.code().get() );
@@ -85,7 +89,8 @@ public class BookNewCargoTest
}
@Test( expected = RouteException.class )
- public void deviation_2b_2_DeadlineTodayIsTooEarly() throws Exception
+ public void deviation_2b_2_DeadlineTodayIsTooEarly()
+ throws Exception
{
UnitOfWork uow = uowf.currentUnitOfWork();
Location HONGKONG = uow.get( Location.class, CNHKG.code().get() );
@@ -95,7 +100,8 @@ public class BookNewCargoTest
}
@Test
- public void deviation_2b_3_DeadlineTomorrowIsOkay() throws Exception
+ public void deviation_2b_3_DeadlineTomorrowIsOkay()
+ throws Exception
{
UnitOfWork uow = uowf.currentUnitOfWork();
Location HONGKONG = uow.get( Location.class, CNHKG.code().get() );
@@ -105,7 +111,8 @@ public class BookNewCargoTest
}
@Test
- public void step_2_CreateNewCargo() throws Exception
+ public void step_2_CreateNewCargo()
+ throws Exception
{
UnitOfWork uow = uowf.currentUnitOfWork();
Location HONGKONG = uow.get( Location.class, CNHKG.code().get() );
@@ -124,16 +131,22 @@ public class BookNewCargoTest
// Test route specification
assertThat( cargo.routeSpecification().get().destination().get(), is( equalTo( STOCKHOLM ) ) );
// day(17) here is calculated a few milliseconds after initial day(17), so it will be later...
- assertThat( cargo.routeSpecification().get().arrivalDeadline().get(), equalTo( day( 17 ) ));
+ assertThat( cargo.routeSpecification().get().arrivalDeadline().get(), equalTo( day( 17 ) ) );
// (Itinerary is not assigned yet)
// Test derived delivery snapshot
Delivery delivery = cargo.delivery().get();
- assertThat( delivery.timestamp().get().after( TODAY ), is( equalTo( true ) ) ); // TODAY is set first
+ assertThat( delivery.timestamp()
+ .get()
+ .isAfter( TODAY.atStartOfDay()
+ .toInstant( ZoneOffset.UTC ) ), is( equalTo( true ) ) ); // TODAY is set first
assertThat( delivery.routingStatus().get(), is( equalTo( RoutingStatus.NOT_ROUTED ) ) );
assertThat( delivery.transportStatus().get(), is( equalTo( TransportStatus.NOT_RECEIVED ) ) );
- assertThat( delivery.nextExpectedHandlingEvent().get().handlingEventType().get(), is( equalTo( HandlingEventType.RECEIVE ) ) );
+ assertThat( delivery.nextExpectedHandlingEvent()
+ .get()
+ .handlingEventType()
+ .get(), is( equalTo( HandlingEventType.RECEIVE ) ) );
assertThat( delivery.nextExpectedHandlingEvent().get().location().get(), is( equalTo( HONGKONG ) ) );
assertThat( delivery.nextExpectedHandlingEvent().get().voyage().get(), is( equalTo( null ) ) );
assertThat( delivery.lastHandlingEvent().get(), is( equalTo( null ) ) );
@@ -145,7 +158,8 @@ public class BookNewCargoTest
}
@Test( expected = FoundNoRoutesException.class )
- public void deviation_3a_NoRoutesCanBeThatFast() throws Exception
+ public void deviation_3a_NoRoutesCanBeThatFast()
+ throws Exception
{
UnitOfWork uow = uowf.currentUnitOfWork();
Location HONGKONG = uow.get( Location.class, CNHKG.code().get() );
@@ -159,7 +173,8 @@ public class BookNewCargoTest
}
@Test
- public void step_3_CalculatePossibleRoutes() throws Exception
+ public void step_3_CalculatePossibleRoutes()
+ throws Exception
{
UnitOfWork uow = uowf.currentUnitOfWork();
Location HONGKONG = uow.get( Location.class, CNHKG.code().get() );
@@ -174,7 +189,7 @@ public class BookNewCargoTest
List<Itinerary> routeCandidates = new BookNewCargo( cargo ).routeCandidates();
// Check possible routes
- for (Itinerary itinerary : routeCandidates)
+ for( Itinerary itinerary : routeCandidates )
{
assertThat( "First load location equals origin location.",
itinerary.firstLeg().loadLocation().get(),
@@ -183,13 +198,15 @@ public class BookNewCargoTest
itinerary.lastLeg().unloadLocation().get(),
is( equalTo( cargo.routeSpecification().get().destination().get() ) ) );
assertThat( "Cargo will be delivered in time.",
- itinerary.finalArrivalDate().before( cargo.routeSpecification().get().arrivalDeadline().get() ),
+ itinerary.finalArrivalDate()
+ .isBefore( cargo.routeSpecification().get().arrivalDeadline().get() ),
is( equalTo( true ) ) );
}
}
@Test
- public void step_5_AssignCargoToRoute() throws Exception
+ public void step_5_AssignCargoToRoute()
+ throws Exception
{
UnitOfWork uow = uowf.currentUnitOfWork();
Location HONGKONG = uow.get( Location.class, CNHKG.code().get() );
@@ -197,7 +214,7 @@ public class BookNewCargoTest
Cargos CARGOS = uow.get( Cargos.class, CargosEntity.CARGOS_ID );
// Create valid cargo
- Date deadline = day( 30 );
+ LocalDate deadline = day( 30 );
TrackingId trackingId = new BookNewCargo( CARGOS, HONGKONG, STOCKHOLM, deadline ).book();
Cargo cargo = uow.get( Cargo.class, trackingId.id().get() );
@@ -219,6 +236,6 @@ public class BookNewCargoTest
assertThat( delivery.routingStatus().get(), is( equalTo( RoutingStatus.ROUTED ) ) );
// ETA (= Unload time of last Leg) is before Deadline (set in previous test)
- assertTrue( delivery.eta().get().before( deadline ) );
+ assertTrue( delivery.eta().get().isBefore( deadline ) );
}
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/booking/BuildDeliverySnapshotTest.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/booking/BuildDeliverySnapshotTest.java b/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/booking/BuildDeliverySnapshotTest.java
index 53c90d4..a5455c8 100644
--- a/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/booking/BuildDeliverySnapshotTest.java
+++ b/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/booking/BuildDeliverySnapshotTest.java
@@ -19,11 +19,10 @@
*/
package org.apache.zest.sample.dcicargo.sample_a.context.shipping.booking;
-import java.util.Date;
-import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
-import org.junit.Before;
-import org.junit.Test;
+import java.time.LocalDate;
+import java.time.ZoneOffset;
import org.apache.zest.api.unitofwork.UnitOfWork;
+import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
import org.apache.zest.sample.dcicargo.sample_a.bootstrap.test.TestApplication;
import org.apache.zest.sample.dcicargo.sample_a.data.entity.CargosEntity;
import org.apache.zest.sample.dcicargo.sample_a.data.entity.HandlingEventsEntity;
@@ -39,10 +38,19 @@ import org.apache.zest.sample.dcicargo.sample_a.data.shipping.handling.HandlingE
import org.apache.zest.sample.dcicargo.sample_a.data.shipping.itinerary.Itinerary;
import org.apache.zest.sample.dcicargo.sample_a.data.shipping.location.Location;
import org.apache.zest.sample.dcicargo.sample_a.data.shipping.voyage.Voyage;
+import org.junit.Before;
+import org.junit.Test;
-import static org.hamcrest.CoreMatchers.*;
-import static org.junit.Assert.*;
-import static org.apache.zest.sample.dcicargo.sample_a.data.shipping.handling.HandlingEventType.*;
+import static org.apache.zest.sample.dcicargo.sample_a.data.shipping.handling.HandlingEventType.CLAIM;
+import static org.apache.zest.sample.dcicargo.sample_a.data.shipping.handling.HandlingEventType.CUSTOMS;
+import static org.apache.zest.sample.dcicargo.sample_a.data.shipping.handling.HandlingEventType.LOAD;
+import static org.apache.zest.sample.dcicargo.sample_a.data.shipping.handling.HandlingEventType.UNLOAD;
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.not;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
/**
* Tests of the Build Delivery Snapshot subfunction use case.
@@ -56,9 +64,9 @@ import static org.apache.zest.sample.dcicargo.sample_a.data.shipping.handling.Ha
* FIXME: Test methods call each other to allow ordered execution, ie. tests are not indepedants !
*/
public class BuildDeliverySnapshotTest
- extends TestApplication
+ extends TestApplication
{
- final Date TODAY = new Date();
+ private final LocalDate TODAY = LocalDate.now();
private Location HONGKONG;
private Location STOCKHOLM;
@@ -110,36 +118,40 @@ public class BuildDeliverySnapshotTest
leg( V200T, NEWYORK, DALLAS, day( 9 ), day( 12 ) ),
leg( V300A, DALLAS, STOCKHOLM, day( 13 ), day( 16 ) )
);
-
-
}
// DERIVE WITH ROUTE SPECIFICATION ==============================================================================
@Test( expected = RouteException.class )
- public void deviation_2a_InvalidRouteSpecification_sameLocations() throws Exception
+ public void deviation_2a_InvalidRouteSpecification_sameLocations()
+ throws Exception
{
RouteSpecification routeSpec = routeSpecification( HONGKONG, HONGKONG, day( 20 ) );
new BuildDeliverySnapshot( routeSpec ).get();
}
@Test( expected = RouteException.class )
- public void deviation_2b_InvalidRouteSpecification_tooEarlyDeadline() throws Exception
+ public void deviation_2b_InvalidRouteSpecification_tooEarlyDeadline()
+ throws Exception
{
RouteSpecification routeSpec = routeSpecification( HONGKONG, STOCKHOLM, TODAY );
new BuildDeliverySnapshot( routeSpec ).get();
}
@Test
- public void deviation_2c_ItineraryIsUnknown_buildFromRouteSpecification() throws Exception
+ public void deviation_2c_ItineraryIsUnknown_buildFromRouteSpecification()
+ throws Exception
{
RouteSpecification routeSpec = routeSpecification( HONGKONG, STOCKHOLM, day( 20 ) );
Delivery delivery = new BuildDeliverySnapshot( routeSpec ).get();
- assertThat( delivery.timestamp().get().after( TODAY ), is( equalTo( true ) ) ); // TODAY is set first
+ assertThat( delivery.timestamp().get().isAfter( TODAY.atStartOfDay().toInstant( ZoneOffset.UTC ) ), is( equalTo( true ) ) ); // TODAY is set first
assertThat( delivery.routingStatus().get(), is( equalTo( RoutingStatus.NOT_ROUTED ) ) );
assertThat( delivery.transportStatus().get(), is( equalTo( TransportStatus.NOT_RECEIVED ) ) );
- assertThat( delivery.nextExpectedHandlingEvent().get().handlingEventType().get(), is( equalTo( HandlingEventType.RECEIVE ) ) );
+ assertThat( delivery.nextExpectedHandlingEvent()
+ .get()
+ .handlingEventType()
+ .get(), is( equalTo( HandlingEventType.RECEIVE ) ) );
assertThat( delivery.nextExpectedHandlingEvent().get().location().get(), is( equalTo( HONGKONG ) ) );
assertThat( delivery.nextExpectedHandlingEvent().get().voyage().get(), is( equalTo( null ) ) );
assertThat( delivery.lastHandlingEvent().get(), is( equalTo( null ) ) );
@@ -150,11 +162,11 @@ public class BuildDeliverySnapshotTest
assertThat( delivery.isUnloadedAtDestination().get(), is( equalTo( false ) ) );
}
-
// DERIVE WITH NON-ROUTED CARGO ==============================================================================
@Test
- public void deviation_2c_ItineraryIsUnknown_buildFromNonRoutedCargo() throws Exception
+ public void deviation_2c_ItineraryIsUnknown_buildFromNonRoutedCargo()
+ throws Exception
{
deviation_2c_ItineraryIsUnknown_buildFromRouteSpecification();
@@ -162,13 +174,14 @@ public class BuildDeliverySnapshotTest
RouteSpecification routeSpec = routeSpecification( HONGKONG, STOCKHOLM, day( 20 ) );
Cargos CARGOS = uow.get( Cargos.class, CargosEntity.CARGOS_ID );
Delivery delivery = new BuildDeliverySnapshot( routeSpec ).get();
- Cargo cargo = CARGOS.createCargo( routeSpec, delivery, "ABCD" );
+ CARGOS.createCargo( routeSpec, delivery, "ABCD" );
// Same as previous test (just build from cargo instead)
- assertThat( delivery.timestamp().get().after( TODAY ), is( equalTo( true ) ) ); // TODAY is set first
+ assertThat( delivery.timestamp().get().isAfter( TODAY.atStartOfDay().toInstant( ZoneOffset.UTC ) ), is( equalTo( true ) ) ); // TODAY is set first
assertThat( delivery.routingStatus().get(), is( equalTo( RoutingStatus.NOT_ROUTED ) ) );
assertThat( delivery.transportStatus().get(), is( equalTo( TransportStatus.NOT_RECEIVED ) ) );
- assertThat( delivery.nextExpectedHandlingEvent().get().handlingEventType().get(), is( equalTo( HandlingEventType.RECEIVE ) ) );
+ assertThat( delivery.nextExpectedHandlingEvent().get().handlingEventType().get(),
+ is( equalTo( HandlingEventType.RECEIVE ) ) );
assertThat( delivery.nextExpectedHandlingEvent().get().location().get(), is( equalTo( HONGKONG ) ) );
assertThat( delivery.nextExpectedHandlingEvent().get().voyage().get(), is( equalTo( null ) ) );
assertThat( delivery.lastHandlingEvent().get(), is( equalTo( null ) ) );
@@ -179,11 +192,11 @@ public class BuildDeliverySnapshotTest
assertThat( delivery.isUnloadedAtDestination().get(), is( equalTo( false ) ) );
}
-
// DERIVE WITH ROUTE SPECIFICATION + ITINERARY (Routed cargo) ==============================================
@Test
- public void deviation_2d_UnsatisfyingItinerary_wrongOrigin() throws Exception
+ public void deviation_2d_UnsatisfyingItinerary_wrongOrigin()
+ throws Exception
{
deviation_2c_ItineraryIsUnknown_buildFromNonRoutedCargo();
@@ -205,7 +218,8 @@ public class BuildDeliverySnapshotTest
}
@Test
- public void deviation_2d_UnsatisfyingItinerary_wrongDestination() throws Exception
+ public void deviation_2d_UnsatisfyingItinerary_wrongDestination()
+ throws Exception
{
deviation_2d_UnsatisfyingItinerary_wrongOrigin();
@@ -220,7 +234,8 @@ public class BuildDeliverySnapshotTest
}
@Test
- public void deviation_2d_UnsatisfyingItinerary_missedDeadline() throws Exception
+ public void deviation_2d_UnsatisfyingItinerary_missedDeadline()
+ throws Exception
{
deviation_2d_UnsatisfyingItinerary_wrongDestination();
@@ -230,17 +245,18 @@ public class BuildDeliverySnapshotTest
Delivery delivery = new BuildDeliverySnapshot( cargo ).get();
// Route specification not satisfied by itinerary
- assertFalse( routeSpec.arrivalDeadline().get().after( itinerary.finalArrivalDate() ) );
+ assertFalse( routeSpec.arrivalDeadline().get().isAfter( itinerary.finalArrivalDate() ) );
assertThat( delivery.routingStatus().get(), is( equalTo( RoutingStatus.MISROUTED ) ) );
}
@Test
- public void deviation_3a_CargoHasNoHandlingHistory() throws Exception
+ public void deviation_3a_CargoHasNoHandlingHistory()
+ throws Exception
{
deviation_2d_UnsatisfyingItinerary_missedDeadline();
- Date arrival = day( 16 );
- Date deadline = day( 20 );
+ LocalDate arrival = day( 16 );
+ LocalDate deadline = day( 20 );
// Itinerary will satisfy route specification
RouteSpecification routeSpec = routeSpecification( HONGKONG, STOCKHOLM, deadline );
cargo.routeSpecification().set( routeSpec );
@@ -249,12 +265,18 @@ public class BuildDeliverySnapshotTest
// Route specification satisfied by itinerary
assertThat( itinerary.firstLeg().loadLocation().get(), is( equalTo( routeSpec.origin().get() ) ) );
assertThat( itinerary.lastLeg().unloadLocation().get(), is( equalTo( routeSpec.destination().get() ) ) );
- assertTrue( routeSpec.arrivalDeadline().get().after( itinerary.finalArrivalDate() ) );
+ assertTrue( routeSpec.arrivalDeadline().get().isAfter( itinerary.finalArrivalDate() ) );
assertThat( delivery.routingStatus().get(), is( equalTo( RoutingStatus.ROUTED ) ) );
- assertThat( delivery.timestamp().get().after( TODAY ), is( equalTo( true ) ) ); // TODAY is set first
+ assertThat( delivery.timestamp()
+ .get()
+ .isAfter( TODAY.atStartOfDay()
+ .toInstant( ZoneOffset.UTC ) ), is( equalTo( true ) ) ); // TODAY is set first
assertThat( delivery.transportStatus().get(), is( equalTo( TransportStatus.NOT_RECEIVED ) ) );
- assertThat( delivery.nextExpectedHandlingEvent().get().handlingEventType().get(), is( equalTo( HandlingEventType.RECEIVE ) ) );
+ assertThat( delivery.nextExpectedHandlingEvent()
+ .get()
+ .handlingEventType()
+ .get(), is( equalTo( HandlingEventType.RECEIVE ) ) );
assertThat( delivery.nextExpectedHandlingEvent().get().location().get(), is( equalTo( HONGKONG ) ) );
assertThat( delivery.nextExpectedHandlingEvent().get().voyage().get(), is( equalTo( null ) ) );
assertThat( delivery.lastHandlingEvent().get(), is( equalTo( null ) ) );
@@ -265,11 +287,11 @@ public class BuildDeliverySnapshotTest
assertThat( delivery.isUnloadedAtDestination().get(), is( equalTo( false ) ) );
}
-
// DERIVE WITH ROUTE SPECIFICATION + ITINERARY + LAST HANDLING EVENT ============================================
@Test
- public void deviation_4a_RECEIVE_1a_UnexpectedPort() throws Exception
+ public void deviation_4a_RECEIVE_1a_UnexpectedPort()
+ throws Exception
{
deviation_3a_CargoHasNoHandlingHistory();
@@ -295,7 +317,8 @@ public class BuildDeliverySnapshotTest
}
@Test
- public void deviation_4a_RECEIVE_1b_ExpectedPort() throws Exception
+ public void deviation_4a_RECEIVE_1b_ExpectedPort()
+ throws Exception
{
deviation_4a_RECEIVE_1a_UnexpectedPort();
@@ -317,9 +340,9 @@ public class BuildDeliverySnapshotTest
assertThat( delivery.nextExpectedHandlingEvent().get().voyage().get(), is( equalTo( V100S ) ) );
}
-
@Test
- public void deviation_4b_LOAD_2a_UnexpectedPort() throws Exception
+ public void deviation_4b_LOAD_2a_UnexpectedPort()
+ throws Exception
{
deviation_4a_RECEIVE_1b_ExpectedPort();
@@ -341,7 +364,8 @@ public class BuildDeliverySnapshotTest
}
@Test
- public void deviation_4b_LOAD_2b_ExpectedPort() throws Exception
+ public void deviation_4b_LOAD_2b_ExpectedPort()
+ throws Exception
{
deviation_4b_LOAD_2a_UnexpectedPort();
@@ -365,7 +389,8 @@ public class BuildDeliverySnapshotTest
}
@Test
- public void deviation_4b_LOAD_2c_UnexpectedVoyageNotFromItinerary() throws Exception
+ public void deviation_4b_LOAD_2c_UnexpectedVoyageNotFromItinerary()
+ throws Exception
{
deviation_4b_LOAD_2b_ExpectedPort();
@@ -387,7 +412,8 @@ public class BuildDeliverySnapshotTest
}
@Test
- public void deviation_4b_LOAD_2c_ExpectedButLaterVoyageInItinerary() throws Exception
+ public void deviation_4b_LOAD_2c_ExpectedButLaterVoyageInItinerary()
+ throws Exception
{
deviation_4b_LOAD_2c_UnexpectedVoyageNotFromItinerary();
@@ -414,9 +440,9 @@ public class BuildDeliverySnapshotTest
assertThat( delivery.nextExpectedHandlingEvent().get().voyage().get(), is( equalTo( V200T ) ) );
}
-
@Test
- public void deviation_4c_UNLOAD_1a_UnexpectedPort() throws Exception
+ public void deviation_4c_UNLOAD_1a_UnexpectedPort()
+ throws Exception
{
deviation_4b_LOAD_2c_ExpectedButLaterVoyageInItinerary();
@@ -455,7 +481,7 @@ public class BuildDeliverySnapshotTest
assertThat( delivery.routingStatus().get(), is( equalTo( RoutingStatus.MISROUTED ) ) );
// Old planned arrival time is still satisfying new deadline
- assertTrue( routeSpec.arrivalDeadline().get().after( itinerary.finalArrivalDate() ) );
+ assertTrue( routeSpec.arrivalDeadline().get().isAfter( itinerary.finalArrivalDate() ) );
// We don't know what's next before a new itinerary has been chosen
assertThat( delivery.nextExpectedHandlingEvent().get(), is( equalTo( null ) ) );
@@ -474,10 +500,10 @@ public class BuildDeliverySnapshotTest
assertThat( delivery.isUnloadedAtDestination().get(), is( equalTo( false ) ) );
// New itinerary that satisfy the new route specification. New origin departure from Tokyo.
- Date arrival= day( 19 );
+ LocalDate arrival = day( 19 );
itinerary = itinerary(
- leg( V400S, TOKYO, HAMBURG, day( 9 ), day( 16 ) ),
- leg( V500S, HAMBURG, STOCKHOLM, day( 17 ), arrival )
+ leg( V400S, TOKYO, HAMBURG, day( 9 ), day( 16 ) ),
+ leg( V500S, HAMBURG, STOCKHOLM, day( 17 ), arrival )
);
// Customer reroutes cargo. This is a possible step in the cargo booking process.
@@ -509,7 +535,8 @@ public class BuildDeliverySnapshotTest
}
@Test
- public void deviation_4c_UNLOAD_1b_ExpectedMidpointLocation() throws Exception
+ public void deviation_4c_UNLOAD_1b_ExpectedMidpointLocation()
+ throws Exception
{
deviation_4c_UNLOAD_1a_UnexpectedPort();
@@ -535,7 +562,8 @@ public class BuildDeliverySnapshotTest
}
@Test
- public void deviation_4c_UNLOAD_1c_Destination() throws Exception
+ public void deviation_4c_UNLOAD_1c_Destination()
+ throws Exception
{
deviation_4c_UNLOAD_1b_ExpectedMidpointLocation();
@@ -562,9 +590,9 @@ public class BuildDeliverySnapshotTest
assertThat( delivery.nextExpectedHandlingEvent().get().voyage().get(), is( equalTo( null ) ) );
}
-
@Test
- public void deviation_4d_CUSTOMS_1a_CargoIsInDestinationPort() throws Exception
+ public void deviation_4d_CUSTOMS_1a_CargoIsInDestinationPort()
+ throws Exception
{
deviation_4c_UNLOAD_1c_Destination();
@@ -589,9 +617,9 @@ public class BuildDeliverySnapshotTest
assertThat( delivery.nextExpectedHandlingEvent().get(), is( equalTo( null ) ) );
}
-
@Test
- public void deviation_4e_CLAIM_1a_CargoIsNotInDestinationPort() throws Exception
+ public void deviation_4e_CLAIM_1a_CargoIsNotInDestinationPort()
+ throws Exception
{
deviation_4d_CUSTOMS_1a_CargoIsInDestinationPort();
@@ -617,7 +645,8 @@ public class BuildDeliverySnapshotTest
}
@Test
- public void deviation_4e_CLAIM_1b_CargoIsInDestinationPort() throws Exception
+ public void deviation_4e_CLAIM_1b_CargoIsInDestinationPort()
+ throws Exception
{
deviation_4e_CLAIM_1a_CargoIsNotInDestinationPort();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/handling/RegisterHandlingEventTest.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/handling/RegisterHandlingEventTest.java b/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/handling/RegisterHandlingEventTest.java
index 7a801ea..416c3ab 100644
--- a/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/handling/RegisterHandlingEventTest.java
+++ b/samples/dci-cargo/dcisample_a/src/test/java/org/apache/zest/sample/dcicargo/sample_a/context/shipping/handling/RegisterHandlingEventTest.java
@@ -19,7 +19,7 @@
*/
package org.apache.zest.sample.dcicargo.sample_a.context.shipping.handling;
-import java.util.Date;
+import java.time.LocalDate;
import org.junit.Before;
import org.junit.Test;
import org.apache.zest.api.unitofwork.UnitOfWork;
@@ -49,10 +49,10 @@ import static org.apache.zest.sample.dcicargo.sample_a.data.shipping.handling.Ha
public class RegisterHandlingEventTest
extends TestApplication
{
- Date time;
- String trackId;
- String msg;
- private Date arrival;
+ private LocalDate date;
+ private String trackId;
+ private String msg;
+ private LocalDate arrival;
private Cargo cargo;
private TrackingId trackingId;
private Cargos CARGOS;
@@ -84,7 +84,7 @@ public class RegisterHandlingEventTest
arrival = day( 16 ) )
);
new BookNewCargo( cargo, itinerary ).assignCargoToRoute();
- time = day( 1 );
+ date = day( 1 );
trackId = trackingId.id().get();
}
@@ -93,62 +93,62 @@ public class RegisterHandlingEventTest
@Test
public void deviation_2a_MissingRegistrationTime() throws Exception
{
- msg = register( null, time, trackId, "RECEIVE", "CNHKG", null );
+ msg = register( null, date, trackId, "RECEIVE", "CNHKG", null );
assertThat( msg, is( equalTo( "Registration time was null. All parameters have to be passed." ) ) );
}
@Test
public void deviation_2a_MissingCompletionTime() throws Exception
{
- msg = register( time, null, trackId, "RECEIVE", "CNHKG", null );
+ msg = register( date, null, trackId, "RECEIVE", "CNHKG", null );
assertThat( msg, is( equalTo( "Completion time was null. All parameters have to be passed." ) ) );
}
@Test
public void deviation_2a_MissingTrackingId() throws Exception
{
- msg = register( time, time, null, "RECEIVE", "CNHKG", null );
+ msg = register( date, date, null, "RECEIVE", "CNHKG", null );
assertThat( msg, is( equalTo( "Tracking id was null. All parameters have to be passed." ) ) );
}
@Test
public void deviation_2a_EmptyTrackingId() throws Exception
{
- msg = register( time, time, "", "RECEIVE", "CNHKG", null );
+ msg = register( date, date, "", "RECEIVE", "CNHKG", null );
assertThat( msg, is( equalTo( "Tracking id cannot be empty." ) ) );
}
@Test
public void deviation_2a_MissingEventType() throws Exception
{
- msg = register( time, time, trackId, null, "CNHKG", null );
+ msg = register( date, date, trackId, null, "CNHKG", null );
assertThat( msg, is( equalTo( "Event type was null. All parameters have to be passed." ) ) );
}
@Test
public void deviation_2a_EmptyEventType() throws Exception
{
- msg = register( time, time, trackId, "", "CNHKG", null );
+ msg = register( date, date, trackId, "", "CNHKG", null );
assertThat( msg, is( equalTo( "Event type cannot be empty." ) ) );
}
@Test
public void deviation_2a_MissingUnlocode() throws Exception
{
- msg = register( time, time, trackId, "RECEIVE", null, null );
+ msg = register( date, date, trackId, "RECEIVE", null, null );
assertThat( msg, is( equalTo( "UnLocode was null. All parameters have to be passed." ) ) );
}
@Test
public void deviation_2a_EmptyUnlocode() throws Exception
{
- msg = register( time, time, trackId, "RECEIVE", "", null );
+ msg = register( date, date, trackId, "RECEIVE", "", null );
assertThat( msg, is( equalTo( "UnLocode cannot be empty." ) ) );
}
@Test
public void step_2_CompleteData__Receive_in_Hong_Kong() throws Exception
{
- new RegisterHandlingEvent( time, time, trackId, "RECEIVE", "CNHKG", null ).register();
+ new RegisterHandlingEvent( date, date, trackId, "RECEIVE", "CNHKG", null ).register();
}
@@ -157,7 +157,7 @@ public class RegisterHandlingEventTest
@Test
public void deviation_3a_HandlingTypeNotRecognized() throws Exception
{
- msg = register( time, time, trackId, "RECEIPT", "CNHKG", null );
+ msg = register( date, date, trackId, "RECEIPT", "CNHKG", null );
assertThat( msg, is( equalTo(
"'RECEIPT' is not a valid handling event type. Valid types are: [RECEIVE, LOAD, UNLOAD, CUSTOMS, CLAIM]" ) ) );
}
@@ -165,7 +165,7 @@ public class RegisterHandlingEventTest
@Test
public void deviation_3b_NoCargoWithTrackingId() throws Exception
{
- msg = register( time, time, "XXX", "RECEIVE", "CNHKG", null );
+ msg = register( date, date, "XXX", "RECEIVE", "CNHKG", null );
assertThat( msg, is( equalTo( "Found no cargo with tracking id 'XXX'." ) ) );
}
@@ -175,42 +175,42 @@ public class RegisterHandlingEventTest
TrackingId nonRoutedTrackingId = new BookNewCargo( CARGOS, HONGKONG, STOCKHOLM, day( 17 ) ).createCargo( "NonRoutedCargo" );
String nonRouted = nonRoutedTrackingId.id().get();
- msg = register( time, time, nonRouted, "RECEIVE", "CNHKG", null );
+ msg = register( date, date, nonRouted, "RECEIVE", "CNHKG", null );
assertThat( msg, is( equalTo( "Can't create handling event for non-routed cargo '" + nonRouted + "'." ) ) );
}
@Test
public void deviation_3d_NoLocationWithUnlocode() throws Exception
{
- msg = register( time, time, trackId, "RECEIVE", "ZZZZZ", null );
+ msg = register( date, date, trackId, "RECEIVE", "ZZZZZ", null );
assertThat( msg, is( equalTo( "Unknown location: ZZZZZ" ) ) );
}
@Test
public void deviation_3e_1a_MissingVoyageNumber() throws Exception
{
- msg = register( time, time, trackId, "LOAD", "CNHKG", null );
+ msg = register( date, date, trackId, "LOAD", "CNHKG", null );
assertThat( msg, is( equalTo( "Handling event LOAD requires a voyage. No voyage number submitted." ) ) );
}
@Test
public void deviation_3e_1b_MissingVoyage() throws Exception
{
- msg = register( time, time, trackId, "LOAD", "CNHKG", "V600S" );
+ msg = register( date, date, trackId, "LOAD", "CNHKG", "V600S" );
assertThat( msg, is( equalTo( "Found no voyage with voyage number 'V600S'." ) ) );
}
@Test
public void deviation_3f_SkipVoyageNumberSilentlyWhenProhibited() throws Exception
{
- new RegisterHandlingEvent( time, time, trackId, "RECEIVE", "CNHKG", "V100S" ).register();
+ new RegisterHandlingEvent( date, date, trackId, "RECEIVE", "CNHKG", "V100S" ).register();
assertThat( cargo.delivery().get().currentVoyage().get(), is( equalTo( null ) ) );
}
@Test
public void step_3_to_5_ValidRegistration__Load_in_Hong_Kong() throws Exception
{
- new RegisterHandlingEvent( time, time, trackId, "LOAD", "CNHKG", "V100S" ).register();
+ new RegisterHandlingEvent( date, date, trackId, "LOAD", "CNHKG", "V100S" ).register();
Delivery delivery = cargo.delivery().get();
assertThat( delivery.routingStatus().get(), is( equalTo( RoutingStatus.ROUTED ) ) );
@@ -226,8 +226,8 @@ public class RegisterHandlingEventTest
}
- private String register( Date registrationTime,
- Date completionTime,
+ private String register( LocalDate registrationDate,
+ LocalDate completionDate,
String trackingIdString,
String eventTypeString,
String unLocodeString,
@@ -235,8 +235,8 @@ public class RegisterHandlingEventTest
{
try
{
- new RegisterHandlingEvent( registrationTime,
- completionTime,
+ new RegisterHandlingEvent( registrationDate,
+ completionDate,
trackingIdString,
eventTypeString,
unLocodeString,
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_b/api/GraphTraversalService.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_b/api/GraphTraversalService.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_b/api/GraphTraversalService.java
index 8e09c0d..754188b 100644
--- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_b/api/GraphTraversalService.java
+++ b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_b/api/GraphTraversalService.java
@@ -21,7 +21,7 @@ package org.apache.zest.sample.dcicargo.pathfinder_b.api;
import java.rmi.Remote;
import java.rmi.RemoteException;
-import java.util.Date;
+import java.time.LocalDate;
import java.util.List;
/**
@@ -40,7 +40,7 @@ public interface GraphTraversalService extends Remote
*
* @throws RemoteException RMI problem
*/
- List<TransitPath> findShortestPath( Date departureDate, String originUnLocode, String destinationUnLocode )
+ List<TransitPath> findShortestPath( LocalDate departureDate, String originUnLocode, String destinationUnLocode )
throws RemoteException;
List<TransitPath> getVoyages()
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_b/api/TransitEdge.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_b/api/TransitEdge.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_b/api/TransitEdge.java
index 98dd39c..82174d5 100644
--- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_b/api/TransitEdge.java
+++ b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_b/api/TransitEdge.java
@@ -20,7 +20,7 @@
package org.apache.zest.sample.dcicargo.pathfinder_b.api;
import java.io.Serializable;
-import java.util.Date;
+import java.time.LocalDate;
/**
* Represents an edge in a path through a graph,
@@ -32,23 +32,23 @@ public final class TransitEdge implements Serializable
private final String voyageNumber;
private final String fromUnLocode;
private final String toUnLocode;
- private final Date fromDate;
- private final Date toDate;
+ private final LocalDate fromDate;
+ private final LocalDate toDate;
/**
* Constructor.
*
- * @param voyageNumber
- * @param fromUnLocode
- * @param toUnLocode
- * @param fromDate
- * @param toDate
+ * @param voyageNumber The voyage number
+ * @param fromUnLocode The UNLO code of the originating port
+ * @param toUnLocode The UNLO code of the destination port
+ * @param fromDate The starting date of the voyage
+ * @param toDate The last day of the voyage
*/
public TransitEdge( final String voyageNumber,
final String fromUnLocode,
final String toUnLocode,
- final Date fromDate,
- final Date toDate
+ final LocalDate fromDate,
+ final LocalDate toDate
)
{
this.voyageNumber = voyageNumber;
@@ -73,12 +73,12 @@ public final class TransitEdge implements Serializable
return toUnLocode;
}
- public Date getFromDate()
+ public LocalDate getFromDate()
{
return fromDate;
}
- public Date getToDate()
+ public LocalDate getToDate()
{
return toDate;
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_b/api/TransitPath.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_b/api/TransitPath.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_b/api/TransitPath.java
index 818e9ca..d03403e 100644
--- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_b/api/TransitPath.java
+++ b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_b/api/TransitPath.java
@@ -20,7 +20,6 @@
package org.apache.zest.sample.dcicargo.pathfinder_b.api;
import java.io.Serializable;
-import java.text.SimpleDateFormat;
import java.util.Collections;
import java.util.List;
@@ -64,11 +63,11 @@ public final class TransitPath implements Serializable
{
sb.append( "\n Leg " ).append( i );
sb.append( " Load " );
- sb.append( new SimpleDateFormat( "yyyy-MM-dd" ).format( edge.getFromDate() ) );
+ sb.append( edge.getFromDate() );
sb.append( " " ).append( edge.getFromUnLocode() );
sb.append( " " ).append( edge.getVoyageNumber() );
sb.append( " Unload " );
- sb.append( new SimpleDateFormat( "yyyy-MM-dd" ).format( edge.getToDate() ) );
+ sb.append( edge.getToDate() );
sb.append( " " ).append( edge.getToUnLocode() );
}
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_b/internal/GraphDAO.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_b/internal/GraphDAO.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_b/internal/GraphDAO.java
index 46cea8c..3ff7a87 100644
--- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_b/internal/GraphDAO.java
+++ b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_b/internal/GraphDAO.java
@@ -19,10 +19,10 @@
*/
package org.apache.zest.sample.dcicargo.pathfinder_b.internal;
+import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
-import java.util.Date;
import java.util.List;
import java.util.Random;
import org.apache.zest.sample.dcicargo.pathfinder_b.api.TransitEdge;
@@ -30,42 +30,36 @@ import org.apache.zest.sample.dcicargo.pathfinder_b.api.TransitPath;
public class GraphDAO
{
+ private List<TransitPath> voyages = new ArrayList<>();
- private static final Random random = new Random();
- private static final long ONE_MIN_MS = 1000 * 60;
- private static final long ONE_HOUR_MS = ONE_MIN_MS * 60;
- private static final long ONE_DAY_MS = ONE_HOUR_MS * 24;
-
- private List<TransitPath> voyages = new ArrayList<TransitPath>();
-
- public List<String> listLocations()
+ private List<String> listLocations()
{
- return new ArrayList<String>( Arrays.asList(
+ return new ArrayList<>( Arrays.asList(
"CNHKG", "AUMEL", "SESTO", "FIHEL", "USCHI", "JNTKO", "DEHAM", "CNSHA", "NLRTM", "SEGOT", "CNHGH", "SOMGQ", "USNYC", "USDAL"
) );
}
- public List<TransitPath> voyages()
+ List<TransitPath> voyages()
{
if( voyages.size() > 0 )
{
return voyages;
}
- Date departureDate = new Date();
+ LocalDate departureDate = LocalDate.now();
for( int i = 0; i < 50; i++ )
{
List<String> locations = getRandomChunkOfLocations( listLocations() );
- final List<TransitEdge> transitEdges = new ArrayList<TransitEdge>( locations.size() - 1 );
+ final List<TransitEdge> transitEdges = new ArrayList<>( locations.size() - 1 );
final String voyageNumber = "V" + ( 101 + i );
// Origin and destination of voyage schedule
String from = locations.remove( 0 );
String destination = locations.remove( 0 );
- Date date = nextDate( departureDate );
- Date fromDate;
- Date toDate;
+ LocalDate date = nextDate( departureDate );
+ LocalDate fromDate;
+ LocalDate toDate;
// Carrier movements
for( final String to : locations )
@@ -90,9 +84,9 @@ public class GraphDAO
return voyages;
}
- private Date nextDate( Date date )
+ private LocalDate nextDate( LocalDate date )
{
- return new Date( date.getTime() + ONE_DAY_MS + ( random.nextInt( 1000 ) - 500 ) * ONE_MIN_MS );
+ return date.plusDays(1);
}
private List<String> getRandomChunkOfLocations( List<String> allLocations )
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_b/internal/GraphTraversalServiceImpl.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_b/internal/GraphTraversalServiceImpl.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_b/internal/GraphTraversalServiceImpl.java
index 197efd1..c7b6484 100644
--- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_b/internal/GraphTraversalServiceImpl.java
+++ b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_b/internal/GraphTraversalServiceImpl.java
@@ -20,9 +20,9 @@
package org.apache.zest.sample.dcicargo.pathfinder_b.internal;
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 java.util.Random;
import org.apache.zest.sample.dcicargo.pathfinder_b.api.GraphTraversalService;
@@ -42,7 +42,7 @@ public class GraphTraversalServiceImpl
}
// Combine existing voyages to create a route.
- public List<TransitPath> findShortestPath( final Date departureDate,
+ public List<TransitPath> findShortestPath( final LocalDate departureDate,
final String originUnLocode,
final String destinationUnLocode
)
@@ -56,7 +56,7 @@ public class GraphTraversalServiceImpl
do
{
String expectedDeparture = originUnLocode;
- Date lastArrivalTime = departureDate;
+ LocalDate lastArrivalTime = departureDate;
// Transit edges (itinerary legs)
final List<TransitEdge> routeEdges = new ArrayList<TransitEdge>();
@@ -81,13 +81,13 @@ public class GraphTraversalServiceImpl
final String departure = voyageEdge.getFromUnLocode();
final String arrival = voyageEdge.getToUnLocode();
- final Date departureTime = voyageEdge.getFromDate();
- final Date arrivalTime = voyageEdge.getToDate();
+ final LocalDate departureTime = voyageEdge.getFromDate();
+ final LocalDate arrivalTime = voyageEdge.getToDate();
boolean expectsDeparture = departure.equals( expectedDeparture );
boolean uniqueDeparture = !oldDepartures.contains( departure );
boolean uniqueArrival = !oldDepartures.contains( arrival );
- boolean afterLastArrivalTime = departureTime.after( lastArrivalTime );
+ boolean afterLastArrivalTime = departureTime.isAfter( lastArrivalTime );
if( expectsDeparture && uniqueDeparture && uniqueArrival && afterLastArrivalTime )
{
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/bootstrap/DCISampleApplication_b.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/bootstrap/DCISampleApplication_b.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/bootstrap/DCISampleApplication_b.java
index 628fbda..6e25291 100644
--- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/bootstrap/DCISampleApplication_b.java
+++ b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/bootstrap/DCISampleApplication_b.java
@@ -19,7 +19,6 @@
*/
package org.apache.zest.sample.dcicargo.sample_b.bootstrap;
-import java.util.Date;
import org.apache.wicket.ConverterLocator;
import org.apache.wicket.Page;
import org.apache.wicket.datetime.PatternDateConverter;
@@ -58,7 +57,8 @@ public class DCISampleApplication_b
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/49bab608/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/bootstrap/sampledata/BaseData.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/bootstrap/sampledata/BaseData.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/bootstrap/sampledata/BaseData.java
index abd4e05..08a9bb7 100644
--- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/bootstrap/sampledata/BaseData.java
+++ b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/bootstrap/sampledata/BaseData.java
@@ -19,10 +19,13 @@
*/
package org.apache.zest.sample.dcicargo.sample_b.bootstrap.sampledata;
+import java.time.Instant;
+import java.time.LocalDate;
+import java.time.ZoneOffset;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Date;
import java.util.List;
+import java.util.Random;
import org.apache.zest.api.value.ValueBuilder;
import org.apache.zest.api.value.ValueBuilderFactory;
import org.apache.zest.sample.dcicargo.sample_b.context.interaction.handling.parsing.dto.ParsedHandlingEventData;
@@ -45,6 +48,7 @@ import org.apache.zest.sample.dcicargo.sample_b.data.structure.voyage.Voyage;
*/
public abstract class BaseData
{
+ private static Random random = new Random();
protected UnLocode AUMEL;
protected UnLocode CNHGH;
protected UnLocode CNHKG;
@@ -73,13 +77,13 @@ 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> carrierMovement = vbf.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();
}
@@ -92,14 +96,14 @@ public abstract class BaseData
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> leg = vbf.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();
}
@@ -118,13 +122,13 @@ public abstract class BaseData
Boolean isUnloadedAtDestination,
RoutingStatus routingStatus,
Boolean isMisdirected,
- Date eta,
+ LocalDate eta,
Integer itineraryProgressIndex,
NextHandlingEvent nextHandlingEvent
)
{
ValueBuilder<Delivery> delivery = vbf.newValueBuilder( Delivery.class );
- delivery.prototype().timestamp().set( new Date() );
+ delivery.prototype().timestamp().set( Instant.now() );
delivery.prototype().lastHandlingEvent().set( lastHandlingEvent );
delivery.prototype().transportStatus().set( transportStatus );
delivery.prototype().isUnloadedAtDestination().set( isUnloadedAtDestination );
@@ -137,14 +141,14 @@ public abstract class BaseData
}
// Delivery with only mandatory values
- protected Delivery delivery( Date date,
+ protected Delivery delivery( LocalDate date,
TransportStatus transportStatus,
RoutingStatus routingStatus,
Integer itineraryProgressIndex
)
{
ValueBuilder<Delivery> delivery = vbf.newValueBuilder( Delivery.class );
- delivery.prototype().timestamp().set( date );
+ delivery.prototype().timestamp().set( date.atStartOfDay().toInstant( ZoneOffset.UTC ) );
delivery.prototype().transportStatus().set( transportStatus );
delivery.prototype().routingStatus().set( routingStatus );
delivery.prototype().itineraryProgressIndex().set( itineraryProgressIndex );
@@ -153,20 +157,20 @@ public abstract class BaseData
protected NextHandlingEvent nextHandlingEvent( HandlingEventType handlingEventType,
Location location,
- Date time,
+ LocalDate time,
Voyage voyage
)
{
ValueBuilder<NextHandlingEvent> nextHandlingEvent = vbf.newValueBuilder( NextHandlingEvent.class );
nextHandlingEvent.prototype().handlingEventType().set( handlingEventType );
nextHandlingEvent.prototype().location().set( location );
- nextHandlingEvent.prototype().time().set( time );
+ nextHandlingEvent.prototype().date().set( time );
nextHandlingEvent.prototype().voyage().set( voyage );
return nextHandlingEvent.newInstance();
}
- protected ParsedHandlingEventData parsedHandlingEventData( Date registrationTime,
- Date completionTime,
+ protected ParsedHandlingEventData parsedHandlingEventData( LocalDate registrationDate,
+ LocalDate completionDate,
String trackingIdString,
HandlingEventType handlingEventType,
String unLocodeString,
@@ -175,8 +179,8 @@ public abstract class BaseData
throws Exception
{
ValueBuilder<ParsedHandlingEventData> attempt = vbf.newValueBuilder( ParsedHandlingEventData.class );
- attempt.prototype().registrationTime().set( registrationTime );
- attempt.prototype().completionTime().set( completionTime );
+ attempt.prototype().registrationDate().set( registrationDate );
+ attempt.prototype().completionDate().set( completionDate );
attempt.prototype().trackingIdString().set( trackingIdString );
attempt.prototype().handlingEventType().set( handlingEventType );
attempt.prototype().unLocodeString().set( unLocodeString );
@@ -185,10 +189,8 @@ public abstract class BaseData
return attempt.newInstance();
}
- protected static Date day( int days )
+ protected static LocalDate day( int days )
{
- Date today = new Date();
- long aDay = 24 * 60 * 60 * 1000;
- return new Date( today.getTime() + days * aDay );
+ return LocalDate.now().plusDays( days );
}
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/bootstrap/sampledata/SampleDataService.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/bootstrap/sampledata/SampleDataService.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/bootstrap/sampledata/SampleDataService.java
index ad43acf..aee65fd 100644
--- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/bootstrap/sampledata/SampleDataService.java
+++ b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/bootstrap/sampledata/SampleDataService.java
@@ -19,8 +19,8 @@
*/
package org.apache.zest.sample.dcicargo.sample_b.bootstrap.sampledata;
+import java.time.LocalDate;
import java.util.ArrayList;
-import java.util.Date;
import java.util.List;
import java.util.Random;
import java.util.UUID;
@@ -57,9 +57,6 @@ import org.apache.zest.sample.dcicargo.sample_b.data.structure.itinerary.Itinera
import org.apache.zest.sample.dcicargo.sample_b.data.structure.location.Location;
import org.apache.zest.sample.dcicargo.sample_b.data.structure.voyage.CarrierMovement;
import org.apache.zest.sample.dcicargo.sample_b.data.structure.voyage.Voyage;
-import org.joda.time.DateTime;
-import org.joda.time.LocalDate;
-import org.joda.time.LocalTime;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -147,7 +144,7 @@ public interface SampleDataService
routeSpec.print();
NextHandlingEvent nextEvent = null;
- Date time = null;
+ LocalDate date = null;
String port = null;
String voyageNumber = null;
Voyage voyage;
@@ -182,8 +179,7 @@ public interface SampleDataService
}
final RouteSpecification unsatisfiedRouteSpec =
- routeSpecFactory.build( origin, badDest, new Date(), new DateTime().plusDays( 25 )
- .toDate() );
+ routeSpecFactory.build( origin, badDest, LocalDate.now(), LocalDate.now().plusDays( 25 ) );
cargo.routeSpecification().set( unsatisfiedRouteSpec );
new InspectUnhandledCargo( cargo ).inspect();
@@ -194,7 +190,7 @@ public interface SampleDataService
{
nextEvent = cargo.delivery().get().nextHandlingEvent().get();
port = nextEvent.location().get().getCode();
- final Date mockTime = new Date();
+ final LocalDate mockTime = LocalDate.now();
registerEvent( mockTime, mockTime, trackingId, RECEIVE, port, null );
}
@@ -202,7 +198,7 @@ public interface SampleDataService
if( i == 15 )
{
nextEvent = cargo.delivery().get().nextHandlingEvent().get();
- time = nextEvent.time().get();
+ date = nextEvent.date().get();
port = nextEvent.location().get().getCode();
voyageNumber = nextEvent.voyage().get().voyageNumber().get().number().get();
@@ -247,21 +243,21 @@ public interface SampleDataService
}
while( wrongVoyage == null && depth++ < 10 );
- registerEvent( time, time, trackingId, LOAD, port, wrongVoyage );
+ registerEvent( date, date, trackingId, LOAD, port, wrongVoyage );
}
// LOAD
if( i > 15 )
{
nextEvent = cargo.delivery().get().nextHandlingEvent().get();
- time = nextEvent.time().get();
+ date = nextEvent.date().get();
port = nextEvent.location().get().getCode();
voyageNumber = nextEvent.voyage().get().voyageNumber().get().number().get();
- registerEvent( time, time, trackingId, LOAD, port, voyageNumber );
+ registerEvent( date, date, trackingId, LOAD, port, voyageNumber );
// Cargo is now on board carrier
nextEvent = cargo.delivery().get().nextHandlingEvent().get();
- time = nextEvent.time().get();
+ date = nextEvent.date().get();
type = nextEvent.handlingEventType().get();
port = nextEvent.location().get().getCode();
voyageNumber = nextEvent.voyage().get().voyageNumber().get().number().get();
@@ -282,21 +278,21 @@ public interface SampleDataService
break;
}
}
- registerEvent( time, time, trackingId, UNLOAD, wrongPort, voyageNumber );
+ registerEvent( date, date, trackingId, UNLOAD, wrongPort, voyageNumber );
}
// UNLOAD
if( i > 17 )
{
nextEvent = cargo.delivery().get().nextHandlingEvent().get();
- time = nextEvent.time().get();
+ date = nextEvent.date().get();
port = nextEvent.location().get().getCode();
voyageNumber = nextEvent.voyage().get().voyageNumber().get().number().get();
- registerEvent( time, time, trackingId, UNLOAD, port, voyageNumber );
+ registerEvent( date, date, trackingId, UNLOAD, port, voyageNumber );
// Cargo is now in midpoint location
nextEvent = cargo.delivery().get().nextHandlingEvent().get();
- time = nextEvent.time().get();
+ date = nextEvent.date().get();
type = nextEvent.handlingEventType().get();
port = nextEvent.location().get().getCode();
}
@@ -304,13 +300,13 @@ public interface SampleDataService
// CUSTOMS: Customs handling in midpoint location (doesn't affect misdirection status)
if( i == 19 )
{
- registerEvent( time, time, trackingId, CUSTOMS, port, null );
+ registerEvent( date, date, trackingId, CUSTOMS, port, null );
}
// MISDIRECT: Unexpected claim before reaching destination
if( i == 20 )
{
- registerEvent( time, time, trackingId, CLAIM, port, null );
+ registerEvent( date, date, trackingId, CLAIM, port, null );
}
// Complete all LOAD/UNLOADS
@@ -320,10 +316,10 @@ public interface SampleDataService
{
//noinspection ConstantConditions
voyageNumber = nextEvent.voyage().get().voyageNumber().get().number().get();
- registerEvent( time, time, trackingId, type, port, voyageNumber );
+ registerEvent( date, date, trackingId, type, port, voyageNumber );
nextEvent = cargo.delivery().get().nextHandlingEvent().get();
- time = nextEvent.time().get();
+ date = nextEvent.date().get();
port = nextEvent.location().get().getCode();
type = nextEvent.handlingEventType().get();
}
@@ -333,7 +329,7 @@ public interface SampleDataService
// CLAIM at destination - this ends the life cycle of the cargo delivery
if( i == 22 )
{
- registerEvent( time, time, trackingId, CLAIM, port, null );
+ registerEvent( date, date, trackingId, CLAIM, port, null );
}
// Add more cases if needed...
@@ -372,7 +368,7 @@ public interface SampleDataService
Location origin;
Location destination;
Random random = new Random();
- Date deadline;
+ LocalDate deadline;
String uuid;
String id;
try
@@ -388,9 +384,7 @@ public interface SampleDataService
}
while( destination.equals( origin ) );
- deadline = new LocalDate().plusDays( 35 + random.nextInt( 10 ) )
- .toDateTime( new LocalTime() )
- .toDate();
+ deadline = LocalDate.now().plusDays( 35 + random.nextInt( 10 ) );
// Build sortable random tracking ids
uuid = UUID.randomUUID().toString().toUpperCase();
@@ -407,8 +401,8 @@ public interface SampleDataService
}
}
- private void registerEvent( Date registrationTime,
- Date completionTime,
+ private void registerEvent( LocalDate registrationDate,
+ LocalDate completionDate,
String trackingIdString,
HandlingEventType handlingEventType,
String unLocodeString,
@@ -417,8 +411,8 @@ public interface SampleDataService
throws Exception
{
ValueBuilder<ParsedHandlingEventData> event = vbf.newValueBuilder( ParsedHandlingEventData.class );
- event.prototype().registrationTime().set( registrationTime );
- event.prototype().completionTime().set( completionTime );
+ event.prototype().registrationDate().set( registrationDate );
+ event.prototype().completionDate().set( completionDate );
event.prototype().trackingIdString().set( trackingIdString );
event.prototype().handlingEventType().set( handlingEventType );
event.prototype().unLocodeString().set( unLocodeString );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/query/TrackingQueries.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/query/TrackingQueries.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/query/TrackingQueries.java
index 082b706..ae4a1e8 100644
--- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/query/TrackingQueries.java
+++ b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/query/TrackingQueries.java
@@ -71,7 +71,7 @@ public class TrackingQueries extends Queries
QueryBuilder<HandlingEventEntity> 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/49bab608/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/query/dto/HandlingEventDTO.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/query/dto/HandlingEventDTO.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/query/dto/HandlingEventDTO.java
index 60f7f09..8f96aed 100644
--- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/query/dto/HandlingEventDTO.java
+++ b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/query/dto/HandlingEventDTO.java
@@ -19,7 +19,7 @@
*/
package org.apache.zest.sample.dcicargo.sample_b.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;
@@ -39,7 +39,7 @@ import org.apache.zest.sample.dcicargo.sample_b.infrastructure.conversion.DTO;
@Unqualified
public interface HandlingEventDTO extends DTO
{
- Property<Date> completionTime();
+ Property<LocalDate> completionDate();
Property<TrackingId> trackingId();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/web/booking/BookNewCargoPage.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/web/booking/BookNewCargoPage.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/web/booking/BookNewCargoPage.java
index 2c70545..7c19a97 100644
--- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/web/booking/BookNewCargoPage.java
+++ b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/web/booking/BookNewCargoPage.java
@@ -19,7 +19,7 @@
*/
package org.apache.zest.sample.dcicargo.sample_b.communication.web.booking;
-import java.util.Date;
+import java.time.LocalDate;
import java.util.List;
import org.apache.wicket.Session;
import org.apache.wicket.ajax.AjaxRequestTarget;
@@ -29,7 +29,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_b.communication.query.CommonQueries;
import org.apache.zest.sample.dcicargo.sample_b.context.interaction.booking.BookNewCargo;
import org.apache.zest.sample.dcicargo.sample_b.data.structure.tracking.TrackingId;
@@ -59,7 +58,7 @@ public class BookNewCargoPage extends BookingBasePage
{
// Set by Wicket property resolvers:
private String origin, destination;
- private Date deadline;
+ private LocalDate deadline;
public BookNewCargoForm()
{
@@ -109,7 +108,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/49bab608/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/web/booking/CargoDetailsPage.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/web/booking/CargoDetailsPage.java b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/web/booking/CargoDetailsPage.java
index 3451e49..65f568f 100644
--- a/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/web/booking/CargoDetailsPage.java
+++ b/samples/dci-cargo/dcisample_b/src/main/java/org/apache/zest/sample/dcicargo/sample_b/communication/web/booking/CargoDetailsPage.java
@@ -19,7 +19,7 @@
*/
package org.apache.zest.sample.dcicargo.sample_b.communication.web.booking;
-import java.util.Date;
+import java.time.Instant;
import java.util.List;
import org.apache.wicket.AttributeModifier;
import org.apache.wicket.devutils.stateless.StatelessComponent;
@@ -46,6 +46,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.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.TransportStatus.CLAIMED;
@@ -163,14 +165,16 @@ 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<Date>( leg.loadTime().get() ) ) );
+ Instant loadTime = leg.loadDate().get().atStartOfDay().toInstant( UTC );
+ item.add( new Label( "loadDate", new Model<>( from( loadTime ) ) ) );
item.add( new Label( "voyage", leg.voyage().get().voyageNumber().get().number().get() ) );
Boolean isMisrouted = 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<Date>( leg.unloadTime().get() ) ) );
+ Instant unloadTime = leg.unloadDate().get().atStartOfDay().toInstant( UTC );
+ item.add( new Label( "unloadDate", new Model<>( from( unloadTime ) ) ) );
}
} );
}
[18/25] zest-java git commit: Merge remote-tracking branch
'origin/develop' into develop
Posted by ni...@apache.org.
Merge remote-tracking branch 'origin/develop' into develop
Project: http://git-wip-us.apache.org/repos/asf/zest-java/repo
Commit: http://git-wip-us.apache.org/repos/asf/zest-java/commit/ab96cf49
Tree: http://git-wip-us.apache.org/repos/asf/zest-java/tree/ab96cf49
Diff: http://git-wip-us.apache.org/repos/asf/zest-java/diff/ab96cf49
Branch: refs/heads/ValueSerializationCleaning
Commit: ab96cf490bec71b6d908de363b6f38964d81dac3
Parents: 5762bf8 7862b9c
Author: Niclas Hedhman <ni...@hedhman.org>
Authored: Tue Jun 14 18:07:31 2016 +0800
Committer: Niclas Hedhman <ni...@hedhman.org>
Committed: Tue Jun 14 18:07:31 2016 +0800
----------------------------------------------------------------------
build.gradle | 16 +-
.../src/main/groovy/AsciidocBuildInfo.groovy | 4 +-
buildSrc/src/main/groovy/VersionClass.groovy | 2 +-
.../apache/zest/bootstrap/ClassScannerTest.java | 2 +-
def.xml | 334 -------------------
extensions/entitystore-geode/build.gradle | 39 +++
extensions/entitystore-geode/dev-status.xml | 38 +++
.../entitystore-geode/src/docs/es-geode.txt | 51 +++
.../entitystore/geode/GeodeConfiguration.java | 81 +++++
.../geode/GeodeEntityStoreMixin.java | 223 +++++++++++++
.../geode/GeodeEntityStoreService.java | 50 +++
.../zest/entitystore/geode/GeodeTopology.java | 29 ++
.../assembly/GeodeEntityStoreAssembler.java | 51 +++
.../entitystore/geode/assembly/package.html | 24 ++
.../apache/zest/entitystore/geode/package.html | 24 ++
.../entitystore/geode/GeodeEntityStoreTest.java | 47 +++
.../geode/GeodeEntityStoreWithCacheTest.java | 43 +++
gradle/wrapper/gradle-wrapper.properties | 2 +-
libraries.gradle | 88 +++--
.../zest/library/http/AbstractJettyTest.java | 28 +-
.../library/http/AbstractSecureJettyTest.java | 115 ++++---
.../library/http/SecureJettyServiceTest.java | 32 +-
libraries/lang-scala/build.gradle | 2 -
.../zest/library/rest/admin/RestTest.java | 121 +++----
libraries/restlet/src/docs/restlet.txt | 2 +-
...bstractPooledDataSourceServiceAssembler.java | 3 +-
.../sql/datasource/DataSourceConfiguration.java | 5 +-
.../DataSourceConfigurationValue.java | 30 --
manual/src/docs/userguide/extensions.txt | 4 +
settings.gradle | 1 +
tools/shell/src/docs/shell.txt | 8 +-
31 files changed, 910 insertions(+), 589 deletions(-)
----------------------------------------------------------------------
[13/25] zest-java git commit: ZEST-124 - Added more asserts in Entity
Store test suite.
Posted by ni...@apache.org.
ZEST-124 - Added more asserts in Entity Store test suite.
Project: http://git-wip-us.apache.org/repos/asf/zest-java/repo
Commit: http://git-wip-us.apache.org/repos/asf/zest-java/commit/e4736b0f
Tree: http://git-wip-us.apache.org/repos/asf/zest-java/tree/e4736b0f
Diff: http://git-wip-us.apache.org/repos/asf/zest-java/diff/e4736b0f
Branch: refs/heads/ValueSerializationCleaning
Commit: e4736b0fd0128dda819acb8f400b25bacba5abc3
Parents: 79021c9
Author: Niclas Hedhman <ni...@hedhman.org>
Authored: Sun Jun 12 16:50:41 2016 +0800
Committer: Niclas Hedhman <ni...@hedhman.org>
Committed: Sun Jun 12 22:51:05 2016 +0800
----------------------------------------------------------------------
.../test/entity/AbstractEntityStoreTest.java | 30 ++++++++++++++++++++
1 file changed, 30 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/zest-java/blob/e4736b0f/core/testsupport/src/main/java/org/apache/zest/test/entity/AbstractEntityStoreTest.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/entity/AbstractEntityStoreTest.java b/core/testsupport/src/main/java/org/apache/zest/test/entity/AbstractEntityStoreTest.java
index b050570..e1f17c1 100644
--- a/core/testsupport/src/main/java/org/apache/zest/test/entity/AbstractEntityStoreTest.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/entity/AbstractEntityStoreTest.java
@@ -21,9 +21,12 @@ package org.apache.zest.test.entity;
import java.math.BigDecimal;
import java.math.BigInteger;
+import java.time.Duration;
import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.time.Period;
import java.time.ZonedDateTime;
import java.util.HashMap;
import java.util.List;
@@ -112,6 +115,12 @@ public abstract class AbstractEntityStoreTest
instance.dateTimeValue().set( refDate );
instance.localDateTimeValue().set( LocalDateTime.of( 2020, 3, 4, 13, 23, 00 ) );
instance.localDateValue().set( LocalDate.of( 2020, 3, 4 ) );
+ instance.localTimeValue().set( LocalTime.of( 19, 20, 21 ) );
+
+ instance.duractionValue().set( Duration.between( LocalDateTime.of( 2010, 1, 2, 19, 20, 21 ),
+ LocalDateTime.of( 2010, 1, 2, 20, 21, 22 ) ) );
+ instance.periodValue().set( Period.between( LocalDate.of( 2005, 12, 21 ), LocalDate.of( 2007, 1, 23 ) ) );
+
instance.association().set( instance );
ValueBuilder<Tjabba> valueBuilder4 = moduleInstance.newValueBuilder( Tjabba.class );
@@ -209,6 +218,18 @@ public abstract class AbstractEntityStoreTest
instance.localDateValue().get(),
equalTo( LocalDate.of( 2020, 3, 4 ) ) );
+ assertThat( "property 'localTimeValue' has correct value",
+ instance.localTimeValue().get(),
+ equalTo( LocalTime.of( 19, 20, 21 ) ) );
+
+ assertThat( "property 'periodValue' has correct value",
+ instance.periodValue().get(),
+ equalTo( Period.of( 1, 1, 2 ) ) );
+
+ assertThat( "property 'durationValue' has correct value",
+ instance.duractionValue().get(),
+ equalTo( Duration.ofSeconds( 3661 ) ) );
+
assertThat( "property 'name' has correct value",
instance.name().get(),
equalTo( "Test" ) );
@@ -519,6 +540,15 @@ public abstract class AbstractEntityStoreTest
Property<LocalDate> localDateValue();
@Optional
+ Property<LocalTime> localTimeValue();
+
+ @Optional
+ Property<Period> periodValue();
+
+ @Optional
+ Property<Duration> duractionValue();
+
+ @Optional
Property<String> name();
@Optional
[23/25] zest-java git commit: Since the Jenkins build is broken
anyway, I am committing this testcase,
which exposes a Value Equality issue. The two values should be equal,
but are not.
Posted by ni...@apache.org.
Since the Jenkins build is broken anyway, I am committing this testcase, which exposes a Value Equality issue. The two values should be equal, but are not.
Project: http://git-wip-us.apache.org/repos/asf/zest-java/repo
Commit: http://git-wip-us.apache.org/repos/asf/zest-java/commit/c62ee068
Tree: http://git-wip-us.apache.org/repos/asf/zest-java/tree/c62ee068
Diff: http://git-wip-us.apache.org/repos/asf/zest-java/diff/c62ee068
Branch: refs/heads/ValueSerializationCleaning
Commit: c62ee068d5d82608bb3ab556899220c5ef2d389a
Parents: 65c7df3
Author: Niclas Hedhman <ni...@hedhman.org>
Authored: Thu Jun 16 18:05:30 2016 +0800
Committer: Niclas Hedhman <ni...@hedhman.org>
Committed: Thu Jun 16 18:05:30 2016 +0800
----------------------------------------------------------------------
.../zest/runtime/value/ValueEqualityTest.java | 43 +++++++++++++++++++-
1 file changed, 42 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/zest-java/blob/c62ee068/core/runtime/src/test/java/org/apache/zest/runtime/value/ValueEqualityTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/value/ValueEqualityTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/value/ValueEqualityTest.java
index 91c5868..c88f4ae 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/value/ValueEqualityTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/value/ValueEqualityTest.java
@@ -19,6 +19,15 @@
*/
package org.apache.zest.runtime.value;
+import java.time.Duration;
+import java.time.Period;
+import java.time.temporal.ChronoUnit;
+import java.util.HashMap;
+import java.util.Map;
+import org.apache.zest.api.common.UseDefaults;
+import org.apache.zest.api.property.Property;
+import org.apache.zest.api.value.ValueBuilder;
+import org.apache.zest.test.value.AbstractValueCompositeSerializationTest;
import org.junit.Test;
import org.apache.zest.api.association.AssociationStateHolder;
import org.apache.zest.api.value.ValueComposite;
@@ -55,7 +64,7 @@ public class ValueEqualityTest
public void assemble( ModuleAssembly module )
throws AssemblyException
{
- module.values( PrimitivesValue.class, Some.class, AnotherSome.class, Other.class );
+ module.values( PrimitivesValue.class, Some.class, AnotherSome.class, Other.class, ComplexKey.class );
}
//
@@ -238,4 +247,36 @@ public class ValueEqualityTest
some.hashCode(),
not( equalTo( anotherSome.hashCode() ) ) );
}
+
+ @Test
+ public void givenComplexKeyWhenEqualityCheckExpectEqual()
+ throws Exception
+ {
+ Map<String, Map<Duration, Period>> map3 = new HashMap<>();
+ Map<Duration, Period> map4 = new HashMap<>();
+ map4.put( Duration.of( 1000, ChronoUnit.MILLIS ), Period.of( 1, 2, 3 ) );
+ map3.put( "habba", map4 );
+ ValueBuilder<ComplexKey> builder1 = valueBuilderFactory.newValueBuilder( ComplexKey.class );
+ builder1.prototype().durations().set( map3 );
+ ComplexKey key1 = builder1.newInstance();
+
+ Map<String, Map<Duration, Period>> map1 = new HashMap<>();
+ Map<Duration, Period> map2 = new HashMap<>();
+ map2.put( Duration.of( 1000, ChronoUnit.MILLIS ), Period.of( 1, 2, 3 ) );
+ map1.put( "habba", map2 );
+ ValueBuilder<ComplexKey> builder2 = valueBuilderFactory.newValueBuilder( ComplexKey.class );
+ builder2.prototype().durations().set( map1 );
+ ComplexKey key2 = builder2.newInstance();
+
+ assertThat( key1, equalTo( key2 ) );
+ }
+
+ public interface ComplexKey
+ {
+ @UseDefaults
+ Property<Map<String, Map<Duration, Period>>> durations();
+ }
+
+
+
}
[24/25] zest-java git commit: Saving the mess I am in before trying
to restore 'develop' branch.
Posted by ni...@apache.org.
Saving the mess I am in before trying to restore 'develop' branch.
Project: http://git-wip-us.apache.org/repos/asf/zest-java/repo
Commit: http://git-wip-us.apache.org/repos/asf/zest-java/commit/0e78cbcf
Tree: http://git-wip-us.apache.org/repos/asf/zest-java/tree/0e78cbcf
Diff: http://git-wip-us.apache.org/repos/asf/zest-java/diff/0e78cbcf
Branch: refs/heads/ValueSerializationCleaning
Commit: 0e78cbcf4de7a43e5508a886659c239f03b324c7
Parents: c62ee06
Author: Niclas Hedhman <ni...@hedhman.org>
Authored: Thu Jun 16 22:15:05 2016 +0800
Committer: Niclas Hedhman <ni...@hedhman.org>
Committed: Thu Jun 16 22:15:05 2016 +0800
----------------------------------------------------------------------
.../apache/zest/api/value/ValueSerializer.java | 185 ++-----------------
.../spi/value/ValueDeserializerAdapter.java | 11 +-
.../zest/spi/value/ValueSerializerAdapter.java | 33 +---
...AbstractValueCompositeSerializationTest.java | 54 +++++-
.../elasticsearch/ElasticSearchIndexer.java | 2 +-
.../rdf/query/internal/RdfQueryParserImpl.java | 4 +-
.../jackson/JacksonValueDeserializer.java | 51 ++---
.../JacksonCollectionSerializationTest.java | 9 +
.../rdf/entity/EntityStateSerializer.java | 2 +-
.../serialization/JsonRepresentation.java | 2 +-
10 files changed, 88 insertions(+), 265 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/zest-java/blob/0e78cbcf/core/api/src/main/java/org/apache/zest/api/value/ValueSerializer.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/value/ValueSerializer.java b/core/api/src/main/java/org/apache/zest/api/value/ValueSerializer.java
index 249b78f..bd605c9 100644
--- a/core/api/src/main/java/org/apache/zest/api/value/ValueSerializer.java
+++ b/core/api/src/main/java/org/apache/zest/api/value/ValueSerializer.java
@@ -57,10 +57,14 @@ import org.apache.zest.api.composite.AmbiguousTypeException;
* <li>Double or double,</li>
* <li>BigInteger,</li>
* <li>BigDecimal,</li>
- * <li>Date,</li>
- * <li>DateTime (JodaTime),</li>
- * <li>LocalDateTime (JodaTime),</li>
- * <li>LocalDate (JodaTime).</li>
+ * <li>ZonedDateTime</li>
+ * <li>OffsetDateTime</li>
+ * <li>LocalDateTime</li>
+ * <li>LocalDate</li>
+ * <li>LocalTime</li>
+ * <li>Duration</li>
+ * <li>Period</li>
+ * <li>Instant</li>
* </ul>
* <p>
* Values of unknown types and all arrays are considered as {@link java.io.Serializable} and by so are serialized to
@@ -93,16 +97,6 @@ public interface ValueSerializer
<T> Function<T, String> serialize( Options options );
/**
- * Factory method for a serialize function.
- *
- * @param <T> the parametrized function input type
- * @param includeTypeInfo if type information should be included in the output
- * @return a serialization function.
- */
- @Deprecated
- <T> Function<T, String> serialize( boolean includeTypeInfo );
-
- /**
* Serialize the state of a value with type information.
*
* @param object an Object to serialize
@@ -124,18 +118,6 @@ public interface ValueSerializer
throws ValueSerializationException;
/**
- * Serialize the state of a value.
- *
- * @param object an Object to serialize
- * @param includeTypeInfo if type information should be included in the output
- * @return the state
- * @throws ValueSerializationException if the Value serialization failed
- */
- @Deprecated
- String serialize( Object object, boolean includeTypeInfo )
- throws ValueSerializationException;
-
- /**
* Serialize the state of a value with type information.
*
* @param object an Object to serialize
@@ -157,159 +139,14 @@ public interface ValueSerializer
throws ValueSerializationException;
/**
- * Serialize the state of a value.
- *
- * @param object an Object to serialize
- * @param output that will be used as output
- * @param includeTypeInfo if type information should be included in the output
- * @throws ValueSerializationException if the Value serialization failed
- */
- @Deprecated
- void serialize( Object object, OutputStream output, boolean includeTypeInfo )
- throws ValueSerializationException;
-
- /**
* Serialization options.
*/
final class Options
{
- /**
- * Boolean flag to include type information.
- * Default to TRUE.
- */
- public static final String INCLUDE_TYPE_INFO = "includeTypeInfo";
- private final Map<String, String> options = new HashMap<>();
-
- /**
- * Create new default ValueSerializer Options.
- */
- public Options()
- {
- this.options.put( INCLUDE_TYPE_INFO, "true" );
- }
-
- /**
- * Set {@link #INCLUDE_TYPE_INFO} option to TRUE.
- * @return This
- */
- public Options withTypeInfo()
- {
- return put( INCLUDE_TYPE_INFO, true );
- }
-
- /**
- * Set {@link #INCLUDE_TYPE_INFO} option to FALSE.
- * @return This
- */
- public Options withoutTypeInfo()
- {
- return put( INCLUDE_TYPE_INFO, false );
- }
-
- /**
- * Get Boolean option value.
- * @param option The option
- * @return The boolean value of the option, or null if absent
- */
- public Boolean getBoolean( String option )
- {
- if( !options.containsKey( option ) )
- {
- return null;
- }
- return Boolean.valueOf( options.get( option ) );
- }
-
- /**
- * Get Integer option value.
- * @param option The option
- * @return The integer value of the option, or null if absent
- */
- public Integer getInteger( String option )
- {
- if( !options.containsKey( option ) )
- {
- return null;
- }
- return Integer.valueOf( options.get( option ) );
- }
-
- /**
- * Get String option value.
- * @param option The option
- * @return The string value of the option, or null if absent
- */
- public String getString( String option )
- {
- return options.get( option );
- }
-
- /**
- * Put an option String value.
- * @param option The option
- * @param value The value
- * @return This Options instance
- */
- public Options put( String option, String value )
- {
- if( value == null )
- {
- return remove( option );
- }
- options.put( option, value );
- return this;
- }
-
- /**
- * Put an option boolean value.
- * @param option The option
- * @param value The value
- * @return This Options instance
- */
- public Options put( String option, Boolean value )
- {
- if( value == null )
- {
- return remove( option );
- }
- options.put( option, Boolean.toString( value ) );
- return this;
- }
-
- /**
- * Put an option Integer value.
- * @param option The option
- * @param value The value
- * @return This Options instance
- */
- public Options put( String option, Integer value )
- {
- if( value == null )
- {
- return remove( option );
- }
- options.put( option, value.toString() );
- return this;
- }
-
- /**
- * Remove an option value.
- * @param option The option
- * @return This Options instance
- */
- public Options remove( String option )
- {
- options.remove( option );
- return this;
- }
+ public final boolean includeTypeInfo;
- /**
- * Get all defined options as a Map.
- * @return All defined options in a new Map
- */
- public Map<String, String> toMap()
- {
- return new HashMap<>( options );
+ public Options( boolean includeTypeInfo ){
+ this.includeTypeInfo = includeTypeInfo;
}
}
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/0e78cbcf/core/spi/src/main/java/org/apache/zest/spi/value/ValueDeserializerAdapter.java
----------------------------------------------------------------------
diff --git a/core/spi/src/main/java/org/apache/zest/spi/value/ValueDeserializerAdapter.java b/core/spi/src/main/java/org/apache/zest/spi/value/ValueDeserializerAdapter.java
index e9c8c75..169f95e 100644
--- a/core/spi/src/main/java/org/apache/zest/spi/value/ValueDeserializerAdapter.java
+++ b/core/spi/src/main/java/org/apache/zest/spi/value/ValueDeserializerAdapter.java
@@ -80,13 +80,10 @@ import static org.apache.zest.functional.Iterables.empty;
* </p>
* <ul>
* <li>BigInteger and BigDecimal depends on {@link org.apache.zest.api.value.ValueSerializer.Options};</li>
- * <li>ZonedDateTime as a ISO-8601 String with optional timezone name;</li>
- * <li>OffsetDateTime as a ISO-8601 String with optional timezone offset;</li>
- * <li>LocalDateTime as whatever {@link LocalDateTime#parse} accept as {@literal instant};</li>
- * <li>LocalDate as whatever {@link LocalDate#parse} accept as {@literal instant};</li>
- * <li>LocalTime as whatever {@link LocalTime#parse} accept as {@literal instant};</li>
- * <li>Duration as a ISO-8601 String representing a {@link java.time.Duration}</li>
- * <li>Period as a ISO-8601 String representing a {@link java.time.Period}</li>
+ * <li>Date as String in ISO-8601, {@literal @millis@} or {@literal /Date(..)} Microsoft format;</li>
+ * <li>DateTime (JodaTime) as a ISO-8601 String with optional timezone offset;</li>
+ * <li>LocalDateTime (JodaTime) as whatever {@link LocalDateTime#parse} accept as {@literal instant};</li>
+ * <li>LocalDate (JodaTime) as whatever {@link LocalDate#parse} accept as {@literal instant};</li>
* </ul>
*
* @param <InputType> Implementor pull-parser type
http://git-wip-us.apache.org/repos/asf/zest-java/blob/0e78cbcf/core/spi/src/main/java/org/apache/zest/spi/value/ValueSerializerAdapter.java
----------------------------------------------------------------------
diff --git a/core/spi/src/main/java/org/apache/zest/spi/value/ValueSerializerAdapter.java b/core/spi/src/main/java/org/apache/zest/spi/value/ValueSerializerAdapter.java
index 8a223e5..a643476 100644
--- a/core/spi/src/main/java/org/apache/zest/spi/value/ValueSerializerAdapter.java
+++ b/core/spi/src/main/java/org/apache/zest/spi/value/ValueSerializerAdapter.java
@@ -172,19 +172,10 @@ public abstract class ValueSerializerAdapter<OutputType>
}
@Override
- @Deprecated
- public final <T> Function<T, String> serialize( final boolean includeTypeInfo )
- {
- return object -> serialize(
- includeTypeInfo ? new Options().withTypeInfo() : new Options().withoutTypeInfo(),
- object );
- }
-
- @Override
public final String serialize( Object object )
throws ValueSerializationException
{
- return serialize( new Options(), object );
+ return serialize( new Options(true), object );
}
@Override
@@ -208,19 +199,10 @@ public abstract class ValueSerializerAdapter<OutputType>
}
@Override
- @Deprecated
- public final String serialize( Object object, boolean includeTypeInfo )
- throws ValueSerializationException
- {
- return serialize( includeTypeInfo ? new Options().withTypeInfo() : new Options().withoutTypeInfo(),
- object );
- }
-
- @Override
public final void serialize( Object object, OutputStream output )
throws ValueSerializationException
{
- serialize( new Options(), object, output );
+ serialize( new Options(true), object, output );
}
@Override
@@ -241,15 +223,6 @@ public abstract class ValueSerializerAdapter<OutputType>
}
}
- @Override
- @Deprecated
- public final void serialize( Object object, OutputStream output, boolean includeTypeInfo )
- throws ValueSerializationException
- {
- serialize( includeTypeInfo ? new Options().withTypeInfo() : new Options().withoutTypeInfo(),
- object, output );
- }
-
private void serializeRoot( Options options, Object object, OutputStream output )
throws Exception
{
@@ -345,7 +318,7 @@ public abstract class ValueSerializerAdapter<OutputType>
onObjectStart( output );
//noinspection ConstantConditions
- if( options.getBoolean( Options.INCLUDE_TYPE_INFO ) && !rootPass )
+ if( options.includeTypeInfo && !rootPass )
{
onFieldStart( output, "_type" );
onValueStart( output );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/0e78cbcf/core/testsupport/src/main/java/org/apache/zest/test/value/AbstractValueCompositeSerializationTest.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/value/AbstractValueCompositeSerializationTest.java b/core/testsupport/src/main/java/org/apache/zest/test/value/AbstractValueCompositeSerializationTest.java
index ce9d361..08a47f5 100644
--- a/core/testsupport/src/main/java/org/apache/zest/test/value/AbstractValueCompositeSerializationTest.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/value/AbstractValueCompositeSerializationTest.java
@@ -21,19 +21,18 @@ package org.apache.zest.test.value;
import java.io.ByteArrayOutputStream;
import java.io.Serializable;
+import java.time.Duration;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.OffsetDateTime;
+import java.time.Period;
import java.time.ZoneOffset;
+import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import org.apache.zest.api.injection.scope.Structure;
-import org.apache.zest.api.structure.Module;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TestName;
import org.apache.zest.api.association.Association;
import org.apache.zest.api.association.ManyAssociation;
import org.apache.zest.api.association.NamedAssociation;
@@ -44,9 +43,11 @@ import org.apache.zest.api.entity.EntityBuilder;
import org.apache.zest.api.entity.EntityComposite;
import org.apache.zest.api.entity.EntityReference;
import org.apache.zest.api.injection.scope.Service;
+import org.apache.zest.api.injection.scope.Structure;
import org.apache.zest.api.injection.scope.This;
import org.apache.zest.api.mixin.Mixins;
import org.apache.zest.api.property.Property;
+import org.apache.zest.api.structure.Module;
import org.apache.zest.api.unitofwork.UnitOfWork;
import org.apache.zest.api.value.ValueBuilder;
import org.apache.zest.api.value.ValueComposite;
@@ -55,6 +56,9 @@ import org.apache.zest.bootstrap.AssemblyException;
import org.apache.zest.bootstrap.ModuleAssembly;
import org.apache.zest.test.AbstractZestTest;
import org.apache.zest.test.EntityTestAssembler;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TestName;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
@@ -79,7 +83,9 @@ public abstract class AbstractValueCompositeSerializationTest
throws AssemblyException
{
module.values( SomeValue.class, AnotherValue.class, FooValue.class, CustomFooValue.class,
- SpecificCollection.class /*, SpecificValue.class, GenericValue.class */ );
+ SpecificCollection.class, /* SpecificValue.class, GenericValue.class, */
+ ComplexKey.class
+ );
new EntityTestAssembler().visibleIn( Visibility.layer ).assemble( module.layer().module( "persistence" ) );
module.entities( BarEntity.class );
@@ -89,10 +95,28 @@ public abstract class AbstractValueCompositeSerializationTest
protected ValueSerialization valueSerialization;
@Test
+ public void givenComplexKeyWhenDeserializingExpectSuccess()
+ throws Exception
+ {
+ Map<String, Map<Duration, Period>> map1 = new HashMap<>();
+ Map<Duration, Period> map2 = new HashMap<>();
+ map2.put( Duration.of( 1000, ChronoUnit.MILLIS ), Period.of( 1, 2, 3 ) );
+ map1.put( "habba", map2 );
+ ValueBuilder<ComplexKey> builder = valueBuilderFactory.newValueBuilder( ComplexKey.class );
+ builder.prototype().durations().set( map1 );
+ ComplexKey underTest = builder.newInstance();
+
+ String serialized = valueSerialization.serialize( underTest );
+ assertThat( serialized, equalTo( "{\"durations\":{\"habba\":{\"PT1S\":\"P1Y2M3D\"}}}" ) );
+ ComplexKey result = moduleInstance.newValueFromSerializedState( ComplexKey.class, serialized );
+ assertThat( result, equalTo( underTest ) );
+ }
+
+ @Test
public void givenValueCompositeWhenSerializingAndDeserializingExpectEquals()
throws Exception
{
- try(UnitOfWork uow = unitOfWorkFactory.newUnitOfWork())
+ try (UnitOfWork uow = unitOfWorkFactory.newUnitOfWork())
{
SomeValue some = buildSomeValue();
@@ -102,12 +126,15 @@ public abstract class AbstractValueCompositeSerializationTest
String stateString = output.toString( "UTF-8" );
// Deserialize using Module API
- System.out.println(stateString);
+ System.out.println( stateString );
SomeValue some2 = moduleInstance.newValueFromSerializedState( SomeValue.class, stateString );
assertThat( "String Integer Map", some2.stringIntMap().get().get( "foo" ), equalTo( 42 ) );
assertThat( "String Value Map", some2.stringValueMap().get().get( "foo" ).internalVal(), equalTo( "Bar" ) );
- assertThat( "Nested Entities", some2.barAssociation().get().cathedral().get(), equalTo( "bazar in barAssociation" ) );
+ assertThat( "Nested Entities", some2.barAssociation()
+ .get()
+ .cathedral()
+ .get(), equalTo( "bazar in barAssociation" ) );
assertThat( "Same value", some, equalTo( some2 ) );
assertThat( "Same JSON value toString", stateString, equalTo( some2.toString() ) );
@@ -189,7 +216,8 @@ public abstract class AbstractValueCompositeSerializationTest
proto.barNamedAssociation().put( "bazar", buildBarEntity( "bazar in barNamedAssociation" ) );
proto.barNamedAssociation().put( "cathedral", buildBarEntity( "cathedral in barNamedAssociation" ) );
proto.barEntityNamedAssociation().put( "bazar", buildBarEntity( "bazar in barEntityNamedAssociation" ) );
- proto.barEntityNamedAssociation().put( "cathedral", buildBarEntity( "cathedral in barEntityNamedAssociation" ) );
+ proto.barEntityNamedAssociation()
+ .put( "cathedral", buildBarEntity( "cathedral in barEntityNamedAssociation" ) );
return builder.newInstance();
}
@@ -396,6 +424,12 @@ public abstract class AbstractValueCompositeSerializationTest
{
}
+ public interface ComplexKey
+ {
+ @UseDefaults
+ Property<Map<String, Map<Duration, Period>>> durations();
+ }
+
public static class SerializableObject
implements Serializable
{
http://git-wip-us.apache.org/repos/asf/zest-java/blob/0e78cbcf/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/ElasticSearchIndexer.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/ElasticSearchIndexer.java b/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/ElasticSearchIndexer.java
index f51d512..0c04214 100755
--- a/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/ElasticSearchIndexer.java
+++ b/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/ElasticSearchIndexer.java
@@ -219,7 +219,7 @@ public interface ElasticSearchIndexer
}
else
{
- String serialized = valueSerializer.serialize( new Options().withoutTypeInfo(), value );
+ String serialized = valueSerializer.serialize( new Options(false), value );
// TODO Theses tests are pretty fragile, find a better way to fix this, Jackson API should behave better
if( serialized.startsWith( "{" ) )
{
http://git-wip-us.apache.org/repos/asf/zest-java/blob/0e78cbcf/extensions/indexing-rdf/src/main/java/org/apache/zest/index/rdf/query/internal/RdfQueryParserImpl.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-rdf/src/main/java/org/apache/zest/index/rdf/query/internal/RdfQueryParserImpl.java b/extensions/indexing-rdf/src/main/java/org/apache/zest/index/rdf/query/internal/RdfQueryParserImpl.java
index 0932df0..e79178f 100644
--- a/extensions/indexing-rdf/src/main/java/org/apache/zest/index/rdf/query/internal/RdfQueryParserImpl.java
+++ b/extensions/indexing-rdf/src/main/java/org/apache/zest/index/rdf/query/internal/RdfQueryParserImpl.java
@@ -331,7 +331,7 @@ public class RdfQueryParserImpl
private String createAndEscapeJSONString( Object value )
{
- return escapeJSONString( valueSerializer.serialize( new Options().withoutTypeInfo(), value ) );
+ return escapeJSONString( valueSerializer.serialize( new Options(false), value ) );
}
private String createRegexStringForContaining( String valueVariable, String containedString )
@@ -387,7 +387,7 @@ public class RdfQueryParserImpl
String jsonStr = "";
if( item != null )
{
- String serialized = valueSerializer.serialize( item, false );
+ String serialized = valueSerializer.serialize( new Options(false), item );
if( item instanceof String )
{
serialized = "\"" + StringEscapeUtils.escapeJava( serialized ) + "\"";
http://git-wip-us.apache.org/repos/asf/zest-java/blob/0e78cbcf/extensions/valueserialization-jackson/src/main/java/org/apache/zest/valueserialization/jackson/JacksonValueDeserializer.java
----------------------------------------------------------------------
diff --git a/extensions/valueserialization-jackson/src/main/java/org/apache/zest/valueserialization/jackson/JacksonValueDeserializer.java b/extensions/valueserialization-jackson/src/main/java/org/apache/zest/valueserialization/jackson/JacksonValueDeserializer.java
index 2fb106f..e355f94 100644
--- a/extensions/valueserialization-jackson/src/main/java/org/apache/zest/valueserialization/jackson/JacksonValueDeserializer.java
+++ b/extensions/valueserialization-jackson/src/main/java/org/apache/zest/valueserialization/jackson/JacksonValueDeserializer.java
@@ -22,6 +22,7 @@ package org.apache.zest.valueserialization.jackson;
import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonToken;
+import com.fasterxml.jackson.core.TreeNode;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.MappingJsonFactory;
import com.fasterxml.jackson.databind.node.ArrayNode;
@@ -135,58 +136,30 @@ public class JacksonValueDeserializer
)
throws Exception
{
- JsonToken token = input.getCurrentToken();
- if( token == JsonToken.VALUE_NULL )
+ JsonToken currentToken = input.getCurrentToken();
+ if( currentToken == JsonToken.VALUE_NULL )
{
return null;
}
- if( token != JsonToken.START_ARRAY )
+ if( currentToken != JsonToken.START_OBJECT )
{
- token = input.nextToken();
+ currentToken = input.nextToken();
}
- if( token == JsonToken.VALUE_NULL )
+ if( currentToken == JsonToken.VALUE_NULL )
{
return null;
}
- if( token != JsonToken.START_ARRAY )
+ if( currentToken != JsonToken.START_OBJECT )
{
throw new ValueSerializationException( "Expected an array start at "
+ input.getCurrentLocation().toString() );
}
- JsonToken currentToken = input.nextToken();
- while( currentToken != JsonToken.END_ARRAY )
+ currentToken = input.nextToken(); // Take the object start
+ while( currentToken != JsonToken.END_OBJECT )
{
- if( currentToken != JsonToken.START_OBJECT )
- {
- throw new ValueSerializationException( "Expected an object start at "
- + input.getCurrentLocation().toString() );
- }
- currentToken = input.nextToken();
- K key = null;
- V value = null;
- while( currentToken != JsonToken.END_OBJECT )
- {
- String objectKey = input.getCurrentName();
- input.nextToken();
- if( "key".equals( objectKey ) )
- {
- key = keyDeserializer.apply( input );
- }
- else if( "value".equals( objectKey ) )
- {
- value = valueDeserializer.apply( input );
- }
- else
- {
- //input.nextToken();
- input.skipChildren();
- }
- currentToken = input.nextToken();
- }
- if( key != null )
- {
- map.put( key, value );
- }
+ K key = keyDeserializer.apply( input );
+ V value = valueDeserializer.apply( input );
+ map.put( key, value );
currentToken = input.nextToken();
}
return map;
http://git-wip-us.apache.org/repos/asf/zest-java/blob/0e78cbcf/extensions/valueserialization-jackson/src/test/java/org/apache/zest/valueserialization/jackson/JacksonCollectionSerializationTest.java
----------------------------------------------------------------------
diff --git a/extensions/valueserialization-jackson/src/test/java/org/apache/zest/valueserialization/jackson/JacksonCollectionSerializationTest.java b/extensions/valueserialization-jackson/src/test/java/org/apache/zest/valueserialization/jackson/JacksonCollectionSerializationTest.java
index dffa616..98a09d8 100644
--- a/extensions/valueserialization-jackson/src/test/java/org/apache/zest/valueserialization/jackson/JacksonCollectionSerializationTest.java
+++ b/extensions/valueserialization-jackson/src/test/java/org/apache/zest/valueserialization/jackson/JacksonCollectionSerializationTest.java
@@ -19,6 +19,15 @@
*/
package org.apache.zest.valueserialization.jackson;
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.core.JsonToken;
+import com.fasterxml.jackson.core.TreeNode;
+import com.fasterxml.jackson.databind.MappingJsonFactory;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
import org.apache.zest.bootstrap.AssemblyException;
import org.apache.zest.bootstrap.ModuleAssembly;
import org.apache.zest.test.value.AbstractCollectionSerializationTest;
http://git-wip-us.apache.org/repos/asf/zest-java/blob/0e78cbcf/libraries/rdf/src/main/java/org/apache/zest/library/rdf/entity/EntityStateSerializer.java
----------------------------------------------------------------------
diff --git a/libraries/rdf/src/main/java/org/apache/zest/library/rdf/entity/EntityStateSerializer.java b/libraries/rdf/src/main/java/org/apache/zest/library/rdf/entity/EntityStateSerializer.java
index 1be4b52..1d6c3b2 100644
--- a/libraries/rdf/src/main/java/org/apache/zest/library/rdf/entity/EntityStateSerializer.java
+++ b/libraries/rdf/src/main/java/org/apache/zest/library/rdf/entity/EntityStateSerializer.java
@@ -152,7 +152,7 @@ public class EntityStateSerializer
}
else
{
- String stringProperty = valueSerializer.serialize( new Options().withoutTypeInfo(), property );
+ String stringProperty = valueSerializer.serialize( new Options(false), property );
final Literal object = valueFactory.createLiteral( stringProperty );
graph.add( subject, predicate, object );
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/0e78cbcf/libraries/restlet/src/main/java/org/apache/zest/library/restlet/serialization/JsonRepresentation.java
----------------------------------------------------------------------
diff --git a/libraries/restlet/src/main/java/org/apache/zest/library/restlet/serialization/JsonRepresentation.java b/libraries/restlet/src/main/java/org/apache/zest/library/restlet/serialization/JsonRepresentation.java
index 71eaa12..56fa850 100644
--- a/libraries/restlet/src/main/java/org/apache/zest/library/restlet/serialization/JsonRepresentation.java
+++ b/libraries/restlet/src/main/java/org/apache/zest/library/restlet/serialization/JsonRepresentation.java
@@ -42,7 +42,7 @@ import org.restlet.representation.Representation;
public class JsonRepresentation<T> extends OutputRepresentation
{
- private static final ValueSerializer.Options OPTIONS_NO_TYPE = new ValueSerializer.Options().withoutTypeInfo();
+ private static final ValueSerializer.Options OPTIONS_NO_TYPE = new ValueSerializer.Options(false);
@Structure
private ZestSPI spi;
[12/25] zest-java git commit: ZEST-124 - Fixed some of the
refactoring bugs.
Posted by ni...@apache.org.
ZEST-124 - Fixed some of the refactoring bugs.
Project: http://git-wip-us.apache.org/repos/asf/zest-java/repo
Commit: http://git-wip-us.apache.org/repos/asf/zest-java/commit/dd35dc1f
Tree: http://git-wip-us.apache.org/repos/asf/zest-java/tree/dd35dc1f
Diff: http://git-wip-us.apache.org/repos/asf/zest-java/diff/dd35dc1f
Branch: refs/heads/ValueSerializationCleaning
Commit: dd35dc1fd058664e7b4d4953086791770de65622
Parents: 49bab60
Author: Niclas Hedhman <ni...@hedhman.org>
Authored: Sun Jun 12 15:28:10 2016 +0800
Committer: Niclas Hedhman <ni...@hedhman.org>
Committed: Sun Jun 12 22:51:05 2016 +0800
----------------------------------------------------------------------
.../zest/test/indexing/AbstractQueryTest.java | 34 +++++++++++---------
.../sql/postgresql/PostgreSQLQueryTest.java | 8 ++---
2 files changed, 22 insertions(+), 20 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dd35dc1f/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractQueryTest.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractQueryTest.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractQueryTest.java
index 8a0dc57..1175bc4 100644
--- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractQueryTest.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractQueryTest.java
@@ -22,6 +22,7 @@ package org.apache.zest.test.indexing;
import java.io.IOException;
import java.math.BigDecimal;
import java.math.BigInteger;
+import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneId;
@@ -79,7 +80,6 @@ public abstract class AbstractQueryTest
{
@Structure
Module moduleInstance;
- private ZonedDateTime refDate;
@Test
public void showNetwork()
@@ -573,35 +573,37 @@ public abstract class AbstractQueryTest
{
QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Person person = templateFor( Person.class );
- refDate = ZonedDateTime.of( 2010, 3, 4, 13, 24, 35, 0, UTC );
+ Instant refInstant = ZonedDateTime.of( 2010, 3, 4, 13, 24, 35, 0, UTC ).toInstant();
+ System.out.println( refInstant );
Query<Person> query = unitOfWork.newQuery( qb.where(
- eq( person.instantValue(), refDate.toInstant() ) ) );
+ eq( person.instantValue(), refInstant ) ) );
System.out.println( "*** script40_Date: " + query );
verifyUnorderedResults( query, "Jack Doe" );
}
@Test
- public void script41_Date()
+ public void script41_Instant()
{
QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Person person = templateFor( Person.class );
+ Instant refInstant = ZonedDateTime.of( 2010, 3, 4, 13, 24, 35, 0, UTC ).toInstant();
Query<Person> query = unitOfWork.newQuery( qb.where(
- ne( person.instantValue(), refDate.toInstant() ) ) );
- System.out.println( "*** script41_Date: " + query );
+ ne( person.instantValue(), refInstant ) ) );
+ System.out.println( "*** script41_Instant: " + query );
verifyUnorderedResults( query, "Joe Doe" );
}
@Test
- public void script42_Date()
+ public void script42_Instant()
{
QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Person person = templateFor( Person.class );
ZonedDateTime cetTime = ZonedDateTime.of( 2010, 3, 4, 14, 24, 35, 0, ZoneId.of( "CET" ) );
Query<Person> query = unitOfWork.newQuery( qb.where(
ne( person.instantValue(), cetTime.toInstant() ) ) );
- System.out.println( "*** script42_Date: " + query );
+ System.out.println( "*** script42_Instant: " + query );
verifyUnorderedResults( query, "Joe Doe" );
}
@@ -704,9 +706,9 @@ public abstract class AbstractQueryTest
{
QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Person person = templateFor( Person.class );
- ZonedDateTime time = ZonedDateTime.of( 2010, 3, 4, 13, 24, 35, 0, ZoneId.of( "CET" ) );
+ LocalDateTime time = LocalDateTime.of( 2010, 3, 4, 13, 23, 0 );
Query<Person> query = unitOfWork.newQuery( qb.where(
- ne( person.localDateTimeValue(), time.toLocalDateTime() ) ) );
+ ne( person.localDateTimeValue(), time ) ) );
System.out.println( "*** script42_LocalDateTime: " + query );
verifyUnorderedResults( query, "Joe Doe" );
@@ -733,7 +735,7 @@ public abstract class AbstractQueryTest
QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Person person = templateFor( Person.class );
Query<Person> query = unitOfWork.newQuery( qb.where(
- eq( person.localDateValue(), LocalDate.of( 2010,3,4 ) ) ) );
+ eq( person.localDateValue(), LocalDate.of( 2010, 3, 4 ) ) ) );
System.out.println( "*** script40_LocalDate: " + query );
verifyUnorderedResults( query, "Jack Doe" );
@@ -745,7 +747,7 @@ public abstract class AbstractQueryTest
QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Person person = templateFor( Person.class );
Query<Person> query = unitOfWork.newQuery( qb.where(
- ne( person.localDateValue(), LocalDate.of( 2010,3,4 ) ) ) );
+ ne( person.localDateValue(), LocalDate.of( 2010, 3, 4 ) ) ) );
System.out.println( "*** script41_LocalDate: " + query );
verifyUnorderedResults( query, "Joe Doe" );
@@ -756,7 +758,7 @@ public abstract class AbstractQueryTest
{
QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Person person = templateFor( Person.class );
- LocalDate time = ZonedDateTime.of(2010,3,4,13,24,35,0, ZoneId.of("CET")).toLocalDate();
+ LocalDate time = ZonedDateTime.of( 2010, 3, 4, 13, 24, 35, 0, ZoneId.of( "CET" ) ).toLocalDate();
Query<Person> query = unitOfWork.newQuery( qb.where(
ne( person.localDateValue(), time ) ) );
System.out.println( "*** script42_LocalDate: " + query );
@@ -769,10 +771,10 @@ public abstract class AbstractQueryTest
{
QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Person person = templateFor( Person.class );
- LocalDate start = ZonedDateTime.of(2010,3,4,13,24,35,0,UTC).toLocalDate();
- LocalDate end = ZonedDateTime.of(2010,3,4,13,24,35,0,UTC).toLocalDate();
+ LocalDate start = ZonedDateTime.of( 2005, 3, 4, 13, 24, 35, 0, UTC ).toLocalDate();
+ LocalDate end = ZonedDateTime.of( 2015, 3, 4, 13, 24, 35, 0, UTC ).toLocalDate();
Query<Person> query = unitOfWork.newQuery( qb.where(
- and( gt( person.localDateValue(), start),
+ and( gt( person.localDateValue(), start ),
lt( person.localDateValue(), end ) ) ) );
System.out.println( "*** script43_LocalDate: " + query );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/dd35dc1f/extensions/indexing-sql/src/test/java/org/apache/zest/index/sql/postgresql/PostgreSQLQueryTest.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-sql/src/test/java/org/apache/zest/index/sql/postgresql/PostgreSQLQueryTest.java b/extensions/indexing-sql/src/test/java/org/apache/zest/index/sql/postgresql/PostgreSQLQueryTest.java
index 013c498..503269f 100644
--- a/extensions/indexing-sql/src/test/java/org/apache/zest/index/sql/postgresql/PostgreSQLQueryTest.java
+++ b/extensions/indexing-sql/src/test/java/org/apache/zest/index/sql/postgresql/PostgreSQLQueryTest.java
@@ -158,9 +158,9 @@ public class PostgreSQLQueryTest
@Test
@Ignore( "NeSpecification is not supported by SQL Indexing" )
@Override
- public void script41_Date()
+ public void script41_Instant()
{
- super.script41_Date();
+ super.script41_Instant();
}
@Test
@@ -190,9 +190,9 @@ public class PostgreSQLQueryTest
@Test
@Ignore( "NeSpecification is not supported by SQL Indexing" )
@Override
- public void script42_Date()
+ public void script42_Instant()
{
- super.script42_Date();
+ super.script42_Instant();
}
@Test
[07/25] 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.
Posted by ni...@apache.org.
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.
Project: http://git-wip-us.apache.org/repos/asf/zest-java/repo
Commit: http://git-wip-us.apache.org/repos/asf/zest-java/commit/49bab608
Tree: http://git-wip-us.apache.org/repos/asf/zest-java/tree/49bab608
Diff: http://git-wip-us.apache.org/repos/asf/zest-java/diff/49bab608
Branch: refs/heads/ValueSerializationCleaning
Commit: 49bab608265a1d618b8391513881f34eaf8b5c0a
Parents: 3b07170
Author: Niclas Hedhman <ni...@hedhman.org>
Authored: Sun Jun 12 14:23:23 2016 +0800
Committer: Niclas Hedhman <ni...@hedhman.org>
Committed: Sun Jun 12 22:51:04 2016 +0800
----------------------------------------------------------------------
build.gradle | 1 -
core/api/build.gradle | 1 -
.../zest/api/composite/PropertyMapper.java | 96 +++-
.../java/org/apache/zest/api/util/Dates.java | 104 -----
.../runtime/property/PropertyEqualityTest.java | 67 +--
.../apache/zest/runtime/query/model/Person.java | 4 +-
.../org/apache/zest/spi/entity/EntityState.java | 1 +
.../entitystore/helpers/DefaultEntityState.java | 8 +-
.../spi/value/ValueDeserializerAdapter.java | 29 +-
.../zest/spi/value/ValueSerializerAdapter.java | 43 +-
.../test/entity/AbstractEntityStoreTest.java | 48 +-
.../zest/test/indexing/AbstractQueryTest.java | 97 ++--
.../org/apache/zest/test/indexing/TestData.java | 24 +-
.../apache/zest/test/indexing/model/Person.java | 12 +-
.../test/value/AbstractJsonDateFormatTest.java | 108 ++++-
.../AbstractPlainValueSerializationTest.java | 43 +-
...AbstractValueCompositeSerializationTest.java | 50 +--
def.xml | 334 ++++++++++++++
.../rdf/query/internal/RdfQueryParserImpl.java | 21 +-
.../solr/internal/SolrEntityIndexerMixin.java | 3 +-
.../index/sql/support/common/QNameInfo.java | 18 +-
.../postgresql/PostgreSQLTypeHelper.java | 9 +-
.../support/skeletons/AbstractSQLStartup.java | 26 +-
.../jackson/JacksonValueDeserializer.java | 4 +-
libraries.gradle | 2 -
.../apache/zest/library/alarm/AlarmEvent.java | 4 +-
.../apache/zest/library/alarm/AlarmStatus.java | 6 +-
.../apache/zest/library/alarm/AlarmSystem.java | 4 +-
.../alarm/ExtendedAlarmModelService.java | 6 +-
.../library/alarm/SimpleAlarmModelService.java | 6 +-
.../alarm/StandardAlarmModelService.java | 6 +-
.../library/alarm/ExtendedAlarmModelTest.java | 4 +-
.../library/alarm/SimpleAlarmModelTest.java | 4 +-
.../library/alarm/StandardAlarmModelTest.java | 4 +-
.../zest/library/appbrowser/AppBrowserTest.java | 1 -
.../library/circuitbreaker/CircuitBreaker.java | 26 +-
.../circuitbreaker/jmx/CircuitBreakerJMX.java | 11 +-
.../conversion/values/EntityToValueTest.java | 9 +-
.../library/conversion/values/TestModel.java | 34 +-
.../conversion/values/ValueToEntityTest.java | 4 +-
.../rest/server/DomainEventSourceResource.java | 16 +-
.../application/api/ApplicationEvent.java | 4 +-
.../factory/ApplicationEventFactoryService.java | 5 +-
.../replay/ApplicationEventPlayerService.java | 12 +-
.../source/helper/ApplicationEvents.java | 53 +--
.../domain/api/UnitOfWorkDomainEventsValue.java | 3 +-
.../factory/UnitOfWorkNotificationConcern.java | 3 +-
.../domain/replay/DomainEventPlayerService.java | 109 +++--
.../domain/source/helper/Events.java | 12 -
.../domain/source/helper/EventRouterTest.java | 5 +-
.../domain/source/helper/EventsTest.java | 5 +-
.../source/helper/UnitOfWorkRouterTest.java | 5 +-
.../rdf/entity/EntityTypeSerializer.java | 28 +-
.../zest/library/rest/client/ClientCache.java | 209 +++++----
.../responsereader/TableResponseReader.java | 22 +-
.../library/rest/common/table/TableBuilder.java | 442 ++++++++++---------
.../rest/server/api/ResourceValidity.java | 40 +-
.../requestreader/DefaultRequestReader.java | 37 +-
.../responsewriter/TableResponseWriter.java | 13 +-
.../zest/library/rest/admin/EntityResource.java | 11 +-
.../zest/library/rest/admin/RestTest.java | 3 +-
libraries/scheduler/dev-status.xml | 2 +-
.../zest/library/scheduler/CronSchedule.java | 13 +-
.../zest/library/scheduler/OnceSchedule.java | 9 +-
.../apache/zest/library/scheduler/Schedule.java | 8 +-
.../zest/library/scheduler/ScheduleFactory.java | 7 +-
.../zest/library/scheduler/Scheduler.java | 6 +-
.../defaults/DefaultScheduleFactoryMixin.java | 10 +-
.../library/scheduler/internal/Execution.java | 32 +-
.../scheduler/internal/ScheduleTime.java | 9 +-
.../scheduler/internal/SchedulerMixin.java | 27 +-
.../library/scheduler/timeline/Timeline.java | 3 +-
.../timeline/TimelineForScheduleConcern.java | 3 +-
.../scheduler/timeline/TimelineRecord.java | 3 +-
.../timeline/TimelineScheduleMixin.java | 27 +-
.../timeline/TimelineSchedulerServiceMixin.java | 3 +-
.../library/scheduler/CronScheduleTest.java | 12 +-
.../zest/library/scheduler/SchedulerTest.java | 20 +-
.../manual/recipes/createEntity/Accident.java | 6 +-
.../dcicargo/pathfinder_a/api/TransitEdge.java | 14 +-
.../internal/GraphTraversalServiceImpl.java | 18 +-
.../bootstrap/DCISampleApplication_a.java | 12 +-
.../sample_a/bootstrap/sampledata/BaseData.java | 23 +-
.../bootstrap/sampledata/BaseDataService.java | 98 ++--
.../bootstrap/sampledata/SampleDataService.java | 49 +-
.../communication/query/TrackingQueries.java | 2 +-
.../query/dto/HandlingEventDTO.java | 4 +-
.../web/booking/BookNewCargoPage.java | 8 +-
.../web/booking/CargoDetailsPage.java | 13 +-
.../web/booking/CargoListPage.java | 19 +-
.../communication/web/booking/RoutePanel.java | 8 +-
.../web/handling/RegisterHandlingEventPage.java | 14 +-
.../web/tracking/HandlingHistoryPanel.java | 3 +-
.../web/tracking/NextHandlingEventPanel.java | 5 +-
.../web/tracking/TrackCargoPage.java | 17 +-
.../context/shipping/booking/BookNewCargo.java | 20 +-
.../shipping/booking/BuildDeliverySnapshot.java | 45 +-
.../handling/RegisterHandlingEvent.java | 32 +-
.../context/support/ApplicationEvents.java | 12 +-
.../context/support/FoundNoRoutesException.java | 8 +-
.../RegisterHandlingEventAttemptDTO.java | 6 +-
.../context/support/RoutingService.java | 7 +-
.../data/shipping/cargo/RouteSpecification.java | 6 +-
.../data/shipping/delivery/Delivery.java | 7 +-
.../delivery/ExpectedHandlingEvent.java | 4 +-
.../data/shipping/handling/HandlingEvent.java | 6 +-
.../data/shipping/handling/HandlingEvents.java | 14 +-
.../data/shipping/itinerary/Itinerary.java | 26 +-
.../sample_a/data/shipping/itinerary/Leg.java | 7 +-
.../data/shipping/voyage/CarrierMovement.java | 6 +-
.../wicket/form/DateTextFieldWithPicker.java | 33 +-
.../wicket/prevnext/PrevNext.java | 5 +-
.../web/booking/CargoDetailsPage.html | 4 +-
.../communication/web/booking/RoutePanel.html | 4 +-
.../shipping/booking/BookNewCargoTest.java | 61 ++-
.../booking/BuildDeliverySnapshotTest.java | 135 +++---
.../handling/RegisterHandlingEventTest.java | 54 +--
.../pathfinder_b/api/GraphTraversalService.java | 4 +-
.../dcicargo/pathfinder_b/api/TransitEdge.java | 24 +-
.../dcicargo/pathfinder_b/api/TransitPath.java | 5 +-
.../pathfinder_b/internal/GraphDAO.java | 30 +-
.../internal/GraphTraversalServiceImpl.java | 12 +-
.../bootstrap/DCISampleApplication_b.java | 4 +-
.../sample_b/bootstrap/sampledata/BaseData.java | 44 +-
.../bootstrap/sampledata/SampleDataService.java | 54 +--
.../communication/query/TrackingQueries.java | 2 +-
.../query/dto/HandlingEventDTO.java | 4 +-
.../web/booking/BookNewCargoPage.java | 7 +-
.../web/booking/CargoDetailsPage.java | 14 +-
.../web/booking/CargoListPage.java | 12 +-
.../communication/web/booking/RoutePanel.java | 10 +-
.../IncidentLoggingApplicationMockupPage.java | 16 +-
.../web/tracking/HandlingHistoryPanel.java | 10 +-
.../web/tracking/NextHandlingEventPanel.java | 5 +-
.../web/tracking/TrackCargoPage.java | 7 +-
.../interaction/booking/BookNewCargo.java | 13 +-
.../booking/routing/AssignCargoToRoute.java | 43 +-
.../DeriveUpdatedRouteSpecification.java | 14 +-
.../inspection/event/InspectArrivedCargo.java | 24 +-
.../inspection/event/InspectCargoInCustoms.java | 4 +-
.../inspection/event/InspectClaimedCargo.java | 8 +-
.../inspection/event/InspectLoadedCargo.java | 49 +-
.../inspection/event/InspectReceivedCargo.java | 30 +-
.../inspection/event/InspectUnhandledCargo.java | 6 +-
.../inspection/event/InspectUnloadedCargo.java | 28 +-
.../parsing/ParseHandlingEventData.java | 17 +-
.../parsing/dto/ParsedHandlingEventData.java | 27 +-
.../registration/RegisterHandlingEvent.java | 4 +-
.../CannotRegisterHandlingEventException.java | 11 +-
.../exception/ChronologicalException.java | 6 +-
.../context/service/routing/RoutingService.java | 11 +-
.../exception/FoundNoRoutesException.java | 8 +-
.../data/factory/HandlingEventFactory.java | 14 +-
.../RouteSpecificationFactoryService.java | 23 +-
.../structure/cargo/RouteSpecification.java | 31 +-
.../data/structure/delivery/Delivery.java | 7 +-
.../structure/delivery/NextHandlingEvent.java | 4 +-
.../data/structure/handling/HandlingEvent.java | 27 +-
.../data/structure/itinerary/Itinerary.java | 26 +-
.../sample_b/data/structure/itinerary/Leg.java | 6 +-
.../data/structure/voyage/CarrierMovement.java | 6 +-
.../sample_b/data/structure/voyage/Voyage.java | 5 +-
.../wicket/form/DateTextFieldWithPicker.java | 31 +-
.../web/booking/CargoDetailsPage.html | 4 +-
.../communication/web/booking/RoutePanel.html | 4 +-
.../bootstrap/test/TestApplication.java | 112 ++---
.../booking/routing/AssignCargoToRouteTest.java | 6 +-
.../event/InspectArrivedCargoTest.java | 4 +-
.../event/InspectCargoInCustomsTest.java | 4 +-
.../event/InspectClaimedCargoTest.java | 8 +-
.../event/InspectLoadedCargoTest.java | 6 +-
.../event/InspectReceivedCargoTest.java | 2 +-
.../event/InspectUnhandledCargoTest.java | 4 +-
.../event/InspectUnloadedCargoTest.java | 6 +-
.../parsing/ParseHandlingEventDataTest.java | 22 +-
.../registration/RegisterHandlingEventTest.java | 8 +-
.../sample/forum/context/view/ViewPost.java | 20 +-
.../zest/sample/forum/data/entity/Post.java | 4 +-
.../zest/sample/rental/domain/Booking.java | 6 +-
.../apache/zest/sample/rental/domain/Car.java | 6 +-
.../zest/sample/rental/domain/Period.java | 6 +-
.../zest/sample/rental/domain/RentalShop.java | 33 +-
.../sample/rental/domain/dev/InitialData.java | 71 ++-
.../apache/zest/sample/rental/web/MainPage.java | 8 +-
tools/shell/src/dist/bin/zest-boot | 2 +
.../demo/thirtyminutes/ThirtyMinutesDocs.java | 14 +-
186 files changed, 2471 insertions(+), 1964 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/build.gradle
----------------------------------------------------------------------
diff --git a/build.gradle b/build.gradle
index 67f1ad9..0591ba7 100644
--- a/build.gradle
+++ b/build.gradle
@@ -164,7 +164,6 @@ allprojects {
options.noTimestamp = true
options.links = [
'http://docs.oracle.com/javase/7/docs/api/',
- 'http://www.joda.org/joda-time/apidocs/',
'http://www.json.org/javadoc/',
'http://junit.org/javadoc/latest/'
]
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/core/api/build.gradle
----------------------------------------------------------------------
diff --git a/core/api/build.gradle b/core/api/build.gradle
index 595b47d..f9e42b8 100644
--- a/core/api/build.gradle
+++ b/core/api/build.gradle
@@ -23,7 +23,6 @@ jar { manifest { name = "Apache Zest\u2122 Core API"}}
dependencies {
compile project( ':org.apache.zest.core:org.apache.zest.core.io' )
- compile libraries.jodatime
testCompile project( ':org.apache.zest.core:org.apache.zest.core.testsupport' )
testCompile project( ':org.apache.zest.libraries:org.apache.zest.library.constraints' )
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/core/api/src/main/java/org/apache/zest/api/composite/PropertyMapper.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/composite/PropertyMapper.java b/core/api/src/main/java/org/apache/zest/api/composite/PropertyMapper.java
index e23683b..63911ac 100644
--- a/core/api/src/main/java/org/apache/zest/api/composite/PropertyMapper.java
+++ b/core/api/src/main/java/org/apache/zest/api/composite/PropertyMapper.java
@@ -28,9 +28,15 @@ import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.math.BigDecimal;
import java.math.BigInteger;
+import java.time.Duration;
+import java.time.Instant;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.OffsetDateTime;
+import java.time.Period;
+import java.time.ZonedDateTime;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -41,7 +47,6 @@ import org.apache.zest.api.ZestAPI;
import org.apache.zest.api.property.GenericPropertyInfo;
import org.apache.zest.api.property.Property;
import org.apache.zest.api.util.Classes;
-import org.apache.zest.api.util.Dates;
import org.apache.zest.api.value.ValueComposite;
/**
@@ -63,7 +68,13 @@ public final class PropertyMapper
STRATEGY.put( Character.class, new CharMapper() );
STRATEGY.put( Float.class, new FloatMapper() );
STRATEGY.put( Double.class, new DoubleMapper() );
- STRATEGY.put( Date.class, new DateMapper() );
+ STRATEGY.put( LocalDate.class, new LocalDateMapper() );
+ STRATEGY.put( LocalDateTime.class, new LocalDateTimeMapper() );
+ STRATEGY.put( ZonedDateTime.class, new ZonedDateTimeMapper() );
+ STRATEGY.put( OffsetDateTime.class, new OffsetDateTimeMapper() );
+ STRATEGY.put( Instant.class, new InstantMapper() );
+ STRATEGY.put( Duration.class, new DurationMapper() );
+ STRATEGY.put( Period.class, new PeriodMapper() );
STRATEGY.put( Boolean.class, new BooleanMapper() );
STRATEGY.put( BigDecimal.class, new BigDecimalMapper() );
STRATEGY.put( BigInteger.class, new BigIntegerMapper() );
@@ -140,7 +151,7 @@ public final class PropertyMapper
{
strategy = STRATEGY.get( type );
}
- if( strategy == null ) // If null, try with the ValueComposite Mapper...
+ if( strategy == null ) // If null, try with the ValueComposite Mapper...
{
strategy = STRATEGY.get( ValueComposite.class );
}
@@ -446,13 +457,73 @@ public final class PropertyMapper
}
}
- private static class DateMapper
+ private static class LocalDateMapper
implements MappingStrategy
{
@Override
public Object map( Composite composite, Type type, String value )
{
- return Dates.fromString( value.trim() );
+ return LocalDate.parse( value.trim() );
+ }
+ }
+
+ private static class LocalDateTimeMapper
+ implements MappingStrategy
+ {
+ @Override
+ public Object map( Composite composite, Type type, String value )
+ {
+ return LocalDateTime.parse( value.trim() );
+ }
+ }
+
+ private static class ZonedDateTimeMapper
+ implements MappingStrategy
+ {
+ @Override
+ public Object map( Composite composite, Type type, String value )
+ {
+ return ZonedDateTime.parse( value.trim() );
+ }
+ }
+
+ private static class OffsetDateTimeMapper
+ implements MappingStrategy
+ {
+ @Override
+ public Object map( Composite composite, Type type, String value )
+ {
+ return OffsetDateTime.parse( value.trim() );
+ }
+ }
+
+ private static class InstantMapper
+ implements MappingStrategy
+ {
+ @Override
+ public Object map( Composite composite, Type type, String value )
+ {
+ return Instant.parse( value.trim() );
+ }
+ }
+
+ private static class DurationMapper
+ implements MappingStrategy
+ {
+ @Override
+ public Object map( Composite composite, Type type, String value )
+ {
+ return Duration.parse( value.trim() );
+ }
+ }
+
+ private static class PeriodMapper
+ implements MappingStrategy
+ {
+ @Override
+ public Object map( Composite composite, Type type, String value )
+ {
+ return Period.parse( value.trim() );
}
}
@@ -463,7 +534,10 @@ public final class PropertyMapper
@SuppressWarnings( "unchecked" )
public Object map( Composite composite, Type type, String value )
{
- return ZestAPI.FUNCTION_COMPOSITE_INSTANCE_OF.apply( composite ).module().instance().newValueFromSerializedState( (Class<Object>) type, value );
+ return ZestAPI.FUNCTION_COMPOSITE_INSTANCE_OF.apply( composite )
+ .module()
+ .instance()
+ .newValueFromSerializedState( (Class<Object>) type, value );
}
}
@@ -471,7 +545,7 @@ public final class PropertyMapper
implements MappingStrategy
{
@Override
- @SuppressWarnings( {"raw", "unchecked"} )
+ @SuppressWarnings( { "raw", "unchecked" } )
public Object map( final Composite composite, Type type, String value )
{
final Class arrayType = ( (Class) type ).getComponentType();
@@ -502,7 +576,7 @@ public final class PropertyMapper
implements MappingStrategy
{
@Override
- @SuppressWarnings( {"raw", "unchecked"} )
+ @SuppressWarnings( { "raw", "unchecked" } )
public Object map( final Composite composite, Type type, String value )
{
final Type dataType = ( (ParameterizedType) type ).getActualTypeArguments()[ 0 ];
@@ -523,7 +597,7 @@ public final class PropertyMapper
implements MappingStrategy
{
@Override
- @SuppressWarnings( {"raw", "unchecked"} )
+ @SuppressWarnings( { "raw", "unchecked" } )
public Object map( final Composite composite, Type type, String value )
{
final Type dataType = ( (ParameterizedType) type ).getActualTypeArguments()[ 0 ];
@@ -544,7 +618,7 @@ public final class PropertyMapper
implements MappingStrategy
{
@Override
- @SuppressWarnings( {"raw", "unchecked"} )
+ @SuppressWarnings( { "raw", "unchecked" } )
public Object map( final Composite composite, Type generictype, String value )
{
ParameterizedType type = (ParameterizedType) generictype;
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/core/api/src/main/java/org/apache/zest/api/util/Dates.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/util/Dates.java b/core/api/src/main/java/org/apache/zest/api/util/Dates.java
deleted file mode 100644
index edd5392..0000000
--- a/core/api/src/main/java/org/apache/zest/api/util/Dates.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-package org.apache.zest.api.util;
-
-import java.text.DateFormat;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.TimeZone;
-
-/**
- * Useful methods for handling Dates.
- */
-public final class Dates
-{
- // Formatters are not thread-safe. Create one per thread
- private static final ThreadLocal<DateFormat> ISO8601 = new ThreadLocal<DateFormat>()
- {
- @Override
- protected DateFormat initialValue()
- {
- return new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss.SSSZ" );
- }
- };
-
- private static final ThreadLocal<DateFormat> ISO8601_UTC = new ThreadLocal<DateFormat>()
- {
- @Override
- protected DateFormat initialValue()
- {
- SimpleDateFormat dateFormat = new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'" );
- dateFormat.setTimeZone( TimeZone.getTimeZone( "UTC" ) );
- return dateFormat;
- }
- };
-
- /**
- * @param stringDate a string representing a date as either ISO8601, @millis@ or /Date() formats
- * @return a Date
- */
- public static Date fromString( String stringDate )
- {
- try
- {
- Date date = ISO8601_UTC.get().parse( stringDate );
- return date;
- }
- catch( ParseException e )
- {
- try
- {
- Date date = ISO8601.get().parse( stringDate );
- return date;
- }
- catch( ParseException e1 )
- {
- // @millis@ format
- if( stringDate.startsWith( "@" ) && stringDate.endsWith( "@" ) )
- {
- long time = Long.parseLong( stringDate.substring( 1, stringDate.length() - 1 ) );
- Date date = new Date( time );
- return date;
- }
- else if( stringDate.startsWith( "/Date(" ) && stringDate.endsWith( ")/" ) ) // Microsoft format
- {
- long time = Long.parseLong( stringDate.substring( 6, stringDate.length() - 2 ) );
- Date date = new Date( time );
- return date;
- }
- throw new IllegalStateException( "Illegal date:" + stringDate );
- }
- }
- }
-
- /**
- * @param date a Date
- * @return String representation in ISO8601 UTC
- */
- public static String toUtcString( Date date )
- {
- return ISO8601_UTC.get().format( date );
- }
-
- private Dates()
- {
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/core/runtime/src/test/java/org/apache/zest/runtime/property/PropertyEqualityTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/property/PropertyEqualityTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/property/PropertyEqualityTest.java
index 2cf33d5..56bf92e 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/property/PropertyEqualityTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/property/PropertyEqualityTest.java
@@ -21,26 +21,25 @@ package org.apache.zest.runtime.property;
import java.math.BigDecimal;
import java.math.BigInteger;
-import java.util.Date;
-import org.apache.zest.api.value.ValueBuilderFactory;
-import org.joda.time.DateTime;
-import org.joda.time.LocalDate;
-import org.joda.time.LocalDateTime;
-import org.junit.Test;
+import java.time.Instant;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.ZonedDateTime;
import org.apache.zest.api.common.Optional;
import org.apache.zest.api.property.Property;
import org.apache.zest.api.property.PropertyDescriptor;
-import org.apache.zest.api.structure.Module;
import org.apache.zest.api.value.ValueBuilder;
+import org.apache.zest.api.value.ValueBuilderFactory;
import org.apache.zest.api.value.ValueDescriptor;
import org.apache.zest.bootstrap.AssemblyException;
import org.apache.zest.bootstrap.ModuleAssembly;
import org.apache.zest.test.AbstractZestTest;
+import org.junit.Test;
+import static java.time.ZoneOffset.UTC;
import static org.hamcrest.CoreMatchers.allOf;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.not;
-import static org.joda.time.DateTimeZone.UTC;
import static org.junit.Assert.assertThat;
/**
@@ -60,7 +59,7 @@ public class PropertyEqualityTest
module.values( PrimitivesValue.class, Some.class, AnotherSome.class, Other.class );
}
- public enum AnEnum
+ private enum AnEnum
{
BAZAR, CATHEDRAL
@@ -101,9 +100,9 @@ public class PropertyEqualityTest
Property<BigDecimal> bigDecimalProperty();
- Property<Date> dateProperty();
+ Property<Instant> instantProperty();
- Property<DateTime> dateTimeProperty();
+ Property<ZonedDateTime> dateTimeProperty();
Property<LocalDate> localDateProperty();
@@ -127,7 +126,7 @@ public class PropertyEqualityTest
@Test
public void givenValuesOfTheSameTypeWhenTestingPropertyDescriptorEqualityExpectEquals()
{
- Some some = buildSomeValue(valueBuilderFactory);
+ Some some = buildSomeValue( valueBuilderFactory );
ValueDescriptor someDescriptor = zest.api().valueDescriptorFor( some );
PropertyDescriptor someCharPropDesc = someDescriptor.state().findPropertyModelByName( "characterProperty" );
@@ -152,7 +151,8 @@ public class PropertyEqualityTest
PrimitivesValue primitive = buildPrimitivesValue( valueBuilderFactory );
ValueDescriptor primitiveDescriptor = zest.api().valueDescriptorFor( primitive );
- PropertyDescriptor primitiveCharPropDesc = primitiveDescriptor.state().findPropertyModelByName( "characterProperty" );
+ PropertyDescriptor primitiveCharPropDesc = primitiveDescriptor.state()
+ .findPropertyModelByName( "characterProperty" );
assertThat( "PropertyDescriptors equal",
someCharPropDesc,
@@ -297,7 +297,7 @@ public class PropertyEqualityTest
return primitive;
}
- public static PrimitivesValue buildPrimitivesValueWithDifferentState( ValueBuilderFactory vbf )
+ private static PrimitivesValue buildPrimitivesValueWithDifferentState( ValueBuilderFactory vbf )
{
PrimitivesValue primitive;
{
@@ -317,10 +317,12 @@ public class PropertyEqualityTest
return primitive;
}
- public static Some buildSomeValue(ValueBuilderFactory vbf)
+ public static Some buildSomeValue( ValueBuilderFactory vbf )
{
Some some;
{
+ ZonedDateTime refDate = ZonedDateTime.of( 2020, 3, 4, 13, 24, 35, 0, UTC );
+
ValueBuilder<Some> builder = vbf.newValueBuilder( Some.class );
builder.prototype().characterProperty().set( 'q' );
builder.prototype().stringProperty().set( "foo" );
@@ -334,10 +336,10 @@ public class PropertyEqualityTest
builder.prototype().enumProperty().set( AnEnum.BAZAR );
builder.prototype().bigIntegerProperty().set( new BigInteger( "42" ) );
builder.prototype().bigDecimalProperty().set( new BigDecimal( "42.23" ) );
- builder.prototype().dateProperty().set( new DateTime( "2020-03-04T13:24:35", UTC ).toDate() );
- builder.prototype().dateTimeProperty().set( new DateTime( "2020-03-04T13:24:35", UTC ) );
- builder.prototype().localDateProperty().set( new LocalDate( "2020-03-04" ) );
- builder.prototype().localDateTimeProperty().set( new LocalDateTime( "2020-03-04T13:23:00", UTC ) );
+ builder.prototype().instantProperty().set( refDate.toInstant() );
+ builder.prototype().dateTimeProperty().set( refDate );
+ builder.prototype().localDateProperty().set( LocalDate.of( 2020, 3, 4 ) );
+ builder.prototype().localDateTimeProperty().set( LocalDateTime.of( 2020, 3, 4, 13, 23, 0 ) );
some = builder.newInstance();
}
return some;
@@ -347,6 +349,7 @@ public class PropertyEqualityTest
{
Some some;
{
+ ZonedDateTime refDate = ZonedDateTime.of( 2030, 2, 8, 9, 9, 9, 0, UTC );
ValueBuilder<Some> builder = vbf.newValueBuilder( Some.class );
builder.prototype().characterProperty().set( 'i' );
builder.prototype().stringProperty().set( "bar" );
@@ -360,10 +363,10 @@ public class PropertyEqualityTest
builder.prototype().enumProperty().set( AnEnum.CATHEDRAL );
builder.prototype().bigIntegerProperty().set( new BigInteger( "23" ) );
builder.prototype().bigDecimalProperty().set( new BigDecimal( "23.42" ) );
- builder.prototype().dateProperty().set( new DateTime( "2030-02-08T09:09:09", UTC ).toDate() );
- builder.prototype().dateTimeProperty().set( new DateTime( "2030-02-08T09:09:09", UTC ) );
- builder.prototype().localDateProperty().set( new LocalDate( "2030-02-08" ) );
- builder.prototype().localDateTimeProperty().set( new LocalDateTime( "2030-02-08T09:09:09", UTC ) );
+ builder.prototype().instantProperty().set( refDate.toInstant() );
+ builder.prototype().dateTimeProperty().set( refDate );
+ builder.prototype().localDateProperty().set( LocalDate.of( 2030, 2, 8 ) );
+ builder.prototype().localDateTimeProperty().set( LocalDateTime.of( 2030, 2, 8, 9, 9, 9 ) );
some = builder.newInstance();
}
return some;
@@ -373,6 +376,7 @@ public class PropertyEqualityTest
{
AnotherSome anotherSome;
{
+ ZonedDateTime refDate = ZonedDateTime.of( 2020, 3, 4, 13, 24, 35, 0, UTC );
ValueBuilder<AnotherSome> builder = vbf.newValueBuilder( AnotherSome.class );
builder.prototype().characterProperty().set( 'q' );
builder.prototype().stringProperty().set( "foo" );
@@ -386,10 +390,10 @@ public class PropertyEqualityTest
builder.prototype().enumProperty().set( AnEnum.BAZAR );
builder.prototype().bigIntegerProperty().set( new BigInteger( "42" ) );
builder.prototype().bigDecimalProperty().set( new BigDecimal( "42.23" ) );
- builder.prototype().dateProperty().set( new DateTime( "2020-03-04T13:24:35", UTC ).toDate() );
- builder.prototype().dateTimeProperty().set( new DateTime( "2020-03-04T13:24:35", UTC ) );
- builder.prototype().localDateProperty().set( new LocalDate( "2020-03-04" ) );
- builder.prototype().localDateTimeProperty().set( new LocalDateTime( "2020-03-04T13:23:00", UTC ) );
+ builder.prototype().instantProperty().set( refDate.toInstant() );
+ builder.prototype().dateTimeProperty().set( refDate );
+ builder.prototype().localDateProperty().set( refDate.toLocalDate() );
+ builder.prototype().localDateTimeProperty().set( LocalDateTime.of( 2020, 3, 4, 13, 23, 0 ) );
anotherSome = builder.newInstance();
}
return anotherSome;
@@ -412,10 +416,11 @@ public class PropertyEqualityTest
builder.prototype().enumProperty().set( AnEnum.CATHEDRAL );
builder.prototype().bigIntegerProperty().set( new BigInteger( "23" ) );
builder.prototype().bigDecimalProperty().set( new BigDecimal( "23.42" ) );
- builder.prototype().dateProperty().set( new DateTime( "2030-02-08T09:09:09", UTC ).toDate() );
- builder.prototype().dateTimeProperty().set( new DateTime( "2030-02-08T09:09:09", UTC ) );
- builder.prototype().localDateProperty().set( new LocalDate( "2030-02-08" ) );
- builder.prototype().localDateTimeProperty().set( new LocalDateTime( "2030-02-08T09:09:09", UTC ) );
+ ZonedDateTime refDate = ZonedDateTime.of( 2030, 2, 8, 9, 9, 9, 0, UTC );
+ builder.prototype().instantProperty().set( refDate.toInstant() );
+ builder.prototype().dateTimeProperty().set( refDate );
+ builder.prototype().localDateProperty().set( LocalDate.of( 2030, 2, 8 ) );
+ builder.prototype().localDateTimeProperty().set( LocalDateTime.of( 2030, 2, 8, 9, 9, 9 ) );
anotherSome = builder.newInstance();
}
return anotherSome;
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/core/runtime/src/test/java/org/apache/zest/runtime/query/model/Person.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/query/model/Person.java b/core/runtime/src/test/java/org/apache/zest/runtime/query/model/Person.java
index a4eff58..8f1b842 100644
--- a/core/runtime/src/test/java/org/apache/zest/runtime/query/model/Person.java
+++ b/core/runtime/src/test/java/org/apache/zest/runtime/query/model/Person.java
@@ -19,7 +19,7 @@
*/
package org.apache.zest.runtime.query.model;
-import java.util.Date;
+import java.time.LocalDate;
import java.util.List;
import java.util.Map;
import org.apache.zest.api.association.Association;
@@ -50,7 +50,7 @@ public interface Person
Property<String> email();
@Optional
- Property<Map<Date, String>> datesToRemember();
+ Property<Map<LocalDate, String>> datesToRemember();
@Optional
Property<List<String>> tags();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/core/spi/src/main/java/org/apache/zest/spi/entity/EntityState.java
----------------------------------------------------------------------
diff --git a/core/spi/src/main/java/org/apache/zest/spi/entity/EntityState.java b/core/spi/src/main/java/org/apache/zest/spi/entity/EntityState.java
index 6031851..95b13f2 100644
--- a/core/spi/src/main/java/org/apache/zest/spi/entity/EntityState.java
+++ b/core/spi/src/main/java/org/apache/zest/spi/entity/EntityState.java
@@ -19,6 +19,7 @@
*/
package org.apache.zest.spi.entity;
+import java.time.Instant;
import org.apache.zest.api.common.QualifiedName;
import org.apache.zest.api.entity.EntityDescriptor;
import org.apache.zest.api.entity.EntityReference;
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/DefaultEntityState.java
----------------------------------------------------------------------
diff --git a/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/DefaultEntityState.java b/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/DefaultEntityState.java
index a95fa57..3375670 100644
--- a/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/DefaultEntityState.java
+++ b/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/DefaultEntityState.java
@@ -61,10 +61,10 @@ public final class DefaultEntityState
identity,
EntityStatus.NEW,
entityDescriptor,
- new HashMap<QualifiedName, Object>(),
- new HashMap<QualifiedName, EntityReference>(),
- new HashMap<QualifiedName, List<EntityReference>>(),
- new HashMap<QualifiedName, Map<String, EntityReference>>() );
+ new HashMap<>(),
+ new HashMap<>(),
+ new HashMap<>(),
+ new HashMap<>() );
}
public DefaultEntityState( String version,
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/core/spi/src/main/java/org/apache/zest/spi/value/ValueDeserializerAdapter.java
----------------------------------------------------------------------
diff --git a/core/spi/src/main/java/org/apache/zest/spi/value/ValueDeserializerAdapter.java b/core/spi/src/main/java/org/apache/zest/spi/value/ValueDeserializerAdapter.java
index a3c72e1..93a8d7e 100644
--- a/core/spi/src/main/java/org/apache/zest/spi/value/ValueDeserializerAdapter.java
+++ b/core/spi/src/main/java/org/apache/zest/spi/value/ValueDeserializerAdapter.java
@@ -24,11 +24,18 @@ import java.io.InputStream;
import java.io.ObjectInputStream;
import java.math.BigDecimal;
import java.math.BigInteger;
+import java.time.Duration;
+import java.time.Instant;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.time.OffsetDateTime;
+import java.time.Period;
+import java.time.ZonedDateTime;
import java.util.ArrayList;
import java.util.Base64;
import java.util.Collection;
import java.util.Collections;
-import java.util.Date;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.List;
@@ -44,14 +51,10 @@ import org.apache.zest.api.type.MapType;
import org.apache.zest.api.type.Serialization;
import org.apache.zest.api.type.ValueCompositeType;
import org.apache.zest.api.type.ValueType;
-import org.apache.zest.api.util.Dates;
import org.apache.zest.api.value.ValueBuilder;
import org.apache.zest.api.value.ValueDescriptor;
import org.apache.zest.api.value.ValueDeserializer;
import org.apache.zest.api.value.ValueSerializationException;
-import org.joda.time.DateTime;
-import org.joda.time.LocalDate;
-import org.joda.time.LocalDateTime;
import static org.apache.zest.functional.Iterables.empty;
@@ -80,8 +83,8 @@ import static org.apache.zest.functional.Iterables.empty;
* <li>BigInteger and BigDecimal depends on {@link org.apache.zest.api.value.ValueSerializer.Options};</li>
* <li>Date as String in ISO-8601, {@literal @millis@} or {@literal /Date(..)} Microsoft format;</li>
* <li>DateTime (JodaTime) as a ISO-8601 String with optional timezone offset;</li>
- * <li>LocalDateTime (JodaTime) as whatever {@link LocalDateTime#LocalDateTime(java.lang.Object)} accept as {@literal instant};</li>
- * <li>LocalDate (JodaTime) as whatever {@link LocalDate#LocalDate(java.lang.Object)} accept as {@literal instant};</li>
+ * <li>LocalDateTime (JodaTime) as whatever {@link LocalDateTime#parse} accept as {@literal instant};</li>
+ * <li>LocalDate (JodaTime) as whatever {@link LocalDate#parse} accept as {@literal instant};</li>
* </ul>
*
* @param <InputType> Implementor pull-parser type
@@ -157,10 +160,14 @@ public abstract class ValueDeserializerAdapter<InputType, InputNodeType>
registerDeserializer( BigInteger.class, input -> new BigInteger( input.toString() ) );
// Date types
- registerDeserializer( Date.class, input -> Dates.fromString( input.toString() ) );
- registerDeserializer( DateTime.class, input -> DateTime.parse( input.toString() ) );
- registerDeserializer( LocalDateTime.class, LocalDateTime::new );
- registerDeserializer( LocalDate.class, LocalDate::new );
+ registerDeserializer( Instant.class, input -> Instant.parse( input.toString() ) );
+ registerDeserializer( ZonedDateTime.class, input -> ZonedDateTime.parse( input.toString() ) );
+ registerDeserializer( OffsetDateTime.class, input -> OffsetDateTime.parse( input.toString() ) );
+ registerDeserializer( LocalDateTime.class, input -> LocalDateTime.parse( input.toString() ) );
+ registerDeserializer( LocalDate.class, input -> LocalDate.parse( input.toString() ));
+ registerDeserializer( LocalTime.class, input -> LocalTime.parse( input.toString() ));
+ registerDeserializer( Duration.class, input -> Duration.parse( input.toString() ));
+ registerDeserializer( Period.class, input -> Period.parse( input.toString() ));
// Other supported types
registerDeserializer( EntityReference.class, input -> EntityReference.parseEntityReference( input.toString() ) );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/core/spi/src/main/java/org/apache/zest/spi/value/ValueSerializerAdapter.java
----------------------------------------------------------------------
diff --git a/core/spi/src/main/java/org/apache/zest/spi/value/ValueSerializerAdapter.java b/core/spi/src/main/java/org/apache/zest/spi/value/ValueSerializerAdapter.java
index 6e0a2ad..e428f4e 100644
--- a/core/spi/src/main/java/org/apache/zest/spi/value/ValueSerializerAdapter.java
+++ b/core/spi/src/main/java/org/apache/zest/spi/value/ValueSerializerAdapter.java
@@ -24,8 +24,15 @@ import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.math.BigDecimal;
import java.math.BigInteger;
+import java.time.Duration;
+import java.time.Instant;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.time.OffsetDateTime;
+import java.time.Period;
+import java.time.ZonedDateTime;
import java.util.Base64;
-import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.function.BiFunction;
@@ -39,14 +46,10 @@ import org.apache.zest.api.composite.CompositeInstance;
import org.apache.zest.api.entity.EntityComposite;
import org.apache.zest.api.entity.EntityReference;
import org.apache.zest.api.property.Property;
-import org.apache.zest.api.util.Dates;
import org.apache.zest.api.value.ValueComposite;
import org.apache.zest.api.value.ValueDescriptor;
import org.apache.zest.api.value.ValueSerializationException;
import org.apache.zest.api.value.ValueSerializer;
-import org.joda.time.DateTime;
-import org.joda.time.LocalDate;
-import org.joda.time.LocalDateTime;
/**
* Adapter for pull-parsing capable ValueSerializers.
@@ -83,7 +86,7 @@ public abstract class ValueSerializerAdapter<OutputType>
implements ValueSerializer
{
- public static interface ComplexSerializer<T, OutputType>
+ public interface ComplexSerializer<T, OutputType>
{
void serialize( Options options, T object, OutputType output )
throws Exception;
@@ -128,25 +131,29 @@ public abstract class ValueSerializerAdapter<OutputType>
public ValueSerializerAdapter()
{
// Primitive Value types
- registerSerializer( String.class, ValueSerializerAdapter.<Object, String>identitySerializer() );
- registerSerializer( Character.class, ValueSerializerAdapter.<Object, Character>identitySerializer() );
- registerSerializer( Boolean.class, ValueSerializerAdapter.<Object, Boolean>identitySerializer() );
- registerSerializer( Integer.class, ValueSerializerAdapter.<Object, Integer>identitySerializer() );
- registerSerializer( Long.class, ValueSerializerAdapter.<Object, Long>identitySerializer() );
- registerSerializer( Short.class, ValueSerializerAdapter.<Object, Short>identitySerializer() );
- registerSerializer( Byte.class, ValueSerializerAdapter.<Object, Byte>identitySerializer() );
- registerSerializer( Float.class, ValueSerializerAdapter.<Object, Float>identitySerializer() );
- registerSerializer( Double.class, ValueSerializerAdapter.<Object, Double>identitySerializer() );
+ registerSerializer( String.class, ValueSerializerAdapter.identitySerializer() );
+ registerSerializer( Character.class, ValueSerializerAdapter.identitySerializer() );
+ registerSerializer( Boolean.class, ValueSerializerAdapter.identitySerializer() );
+ registerSerializer( Integer.class, ValueSerializerAdapter.identitySerializer() );
+ registerSerializer( Long.class, ValueSerializerAdapter.identitySerializer() );
+ registerSerializer( Short.class, ValueSerializerAdapter.identitySerializer() );
+ registerSerializer( Byte.class, ValueSerializerAdapter.identitySerializer() );
+ registerSerializer( Float.class, ValueSerializerAdapter.identitySerializer() );
+ registerSerializer( Double.class, ValueSerializerAdapter.identitySerializer() );
// Number types
registerSerializer( BigDecimal.class, ( options, bigDecimal ) -> bigDecimal.toString() );
registerSerializer( BigInteger.class, ( options, bigInteger ) -> bigInteger.toString() );
// Date types
- registerSerializer( Date.class, ( options, date ) -> Dates.toUtcString( date ) );
- registerSerializer( DateTime.class, ( options, date ) -> date.toString() );
+ registerSerializer( Instant.class, ( options, date ) -> date.toString() );
+ registerSerializer( Duration.class, ( options, date ) -> date.toString() );
+ registerSerializer( Period.class, ( options, date ) -> date.toString() );
+ registerSerializer( ZonedDateTime.class, ( options, date ) -> date.toString() );
+ registerSerializer( OffsetDateTime.class, ( options, date ) -> date.toString() );
registerSerializer( LocalDateTime.class, ( options, date ) -> date.toString() );
registerSerializer( LocalDate.class, ( options, date ) -> date.toString() );
+ registerSerializer( LocalTime.class, ( options, date ) -> date.toString() );
// Other supported types
registerSerializer( EntityReference.class, ( options, ref ) -> ref.toString() );
@@ -155,7 +162,7 @@ public abstract class ValueSerializerAdapter<OutputType>
@Override
public final <T> Function<T, String> serialize()
{
- return object -> serialize( object );
+ return this::serialize;
}
@Override
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/core/testsupport/src/main/java/org/apache/zest/test/entity/AbstractEntityStoreTest.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/entity/AbstractEntityStoreTest.java b/core/testsupport/src/main/java/org/apache/zest/test/entity/AbstractEntityStoreTest.java
index 73455ec..b050570 100644
--- a/core/testsupport/src/main/java/org/apache/zest/test/entity/AbstractEntityStoreTest.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/entity/AbstractEntityStoreTest.java
@@ -21,17 +21,13 @@ package org.apache.zest.test.entity;
import java.math.BigDecimal;
import java.math.BigInteger;
-import java.util.Date;
+import java.time.Instant;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.ZonedDateTime;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import org.apache.zest.api.injection.scope.Structure;
-import org.apache.zest.api.structure.Module;
-import org.joda.time.DateTime;
-import org.joda.time.LocalDate;
-import org.joda.time.LocalDateTime;
-import org.junit.After;
-import org.junit.Test;
import org.apache.zest.api.association.Association;
import org.apache.zest.api.association.ManyAssociation;
import org.apache.zest.api.association.NamedAssociation;
@@ -40,7 +36,9 @@ import org.apache.zest.api.common.UseDefaults;
import org.apache.zest.api.entity.EntityBuilder;
import org.apache.zest.api.entity.EntityComposite;
import org.apache.zest.api.injection.scope.Service;
+import org.apache.zest.api.injection.scope.Structure;
import org.apache.zest.api.property.Property;
+import org.apache.zest.api.structure.Module;
import org.apache.zest.api.unitofwork.ConcurrentEntityModificationException;
import org.apache.zest.api.unitofwork.NoSuchEntityException;
import org.apache.zest.api.unitofwork.UnitOfWork;
@@ -52,11 +50,13 @@ import org.apache.zest.bootstrap.ModuleAssembly;
import org.apache.zest.spi.entitystore.EntityStore;
import org.apache.zest.spi.uuid.UuidIdentityGeneratorService;
import org.apache.zest.test.AbstractZestTest;
+import org.junit.After;
+import org.junit.Test;
+import static java.time.ZoneOffset.UTC;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
-import static org.joda.time.DateTimeZone.UTC;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
@@ -72,6 +72,7 @@ public abstract class AbstractEntityStoreTest
@Structure
private Module moduleInstance;
+ private ZonedDateTime refDate = ZonedDateTime.of( 2020, 3, 4, 13, 24, 35, 0, UTC );
@Override
public void assemble( ModuleAssembly module )
@@ -96,7 +97,7 @@ public abstract class AbstractEntityStoreTest
{
// Create entity
EntityBuilder<TestEntity> builder = unitOfWork.newEntityBuilder( TestEntity.class );
- builder.instance().dateValue().set( new Date() );
+ builder.instance().instantValue().set( Instant.now() );
TestEntity instance = builder.newInstance();
instance.name().set( "Test" );
@@ -107,10 +108,10 @@ public abstract class AbstractEntityStoreTest
instance.booleanValue().set( Boolean.TRUE );
instance.bigIntegerValue().set( new BigInteger( "42" ) );
instance.bigDecimalValue().set( new BigDecimal( "42" ) );
- instance.dateValue().set( new DateTime( "2020-03-04T13:24:35", UTC ).toDate() );
- instance.dateTimeValue().set( new DateTime( "2020-03-04T13:24:35", UTC ) );
- instance.localDateTimeValue().set( new LocalDateTime( "2020-03-04T13:23:00" ) );
- instance.localDateValue().set( new LocalDate( "2020-03-04" ) );
+ instance.instantValue().set( refDate.toInstant() );
+ instance.dateTimeValue().set( refDate );
+ instance.localDateTimeValue().set( LocalDateTime.of( 2020, 3, 4, 13, 23, 00 ) );
+ instance.localDateValue().set( LocalDate.of( 2020, 3, 4 ) );
instance.association().set( instance );
ValueBuilder<Tjabba> valueBuilder4 = moduleInstance.newValueBuilder( Tjabba.class );
@@ -192,21 +193,21 @@ public abstract class AbstractEntityStoreTest
instance.bigDecimalValue().get(),
equalTo( new BigDecimal( "42" ) ) );
- assertThat( "property 'dateValue' has correct value",
- instance.dateValue().get(),
- equalTo( new DateTime( "2020-03-04T13:24:35", UTC ).toDate() ) );
+ assertThat( "property 'instantValue' has correct value",
+ instance.instantValue().get(),
+ equalTo( refDate.toInstant() ) );
assertThat( "property 'dateTimeValue' has correct value",
instance.dateTimeValue().get(),
- equalTo( new DateTime( "2020-03-04T13:24:35", UTC ) ) );
+ equalTo( refDate ) );
assertThat( "property 'localDateTimeValue' has correct value",
instance.localDateTimeValue().get(),
- equalTo( new LocalDateTime( "2020-03-04T13:23:00", UTC ) ) );
+ equalTo( LocalDateTime.of( 2020, 3, 4, 13, 23, 0 ) ) );
assertThat( "property 'localDateValue' has correct value",
instance.localDateValue().get(),
- equalTo( new LocalDate( "2020-03-04" ) ) );
+ equalTo( LocalDate.of( 2020, 3, 4 ) ) );
assertThat( "property 'name' has correct value",
instance.name().get(),
@@ -506,10 +507,10 @@ public abstract class AbstractEntityStoreTest
Property<BigDecimal> bigDecimalValue();
@Optional
- Property<Date> dateValue();
+ Property<Instant> instantValue();
@Optional
- Property<DateTime> dateTimeValue();
+ Property<ZonedDateTime> dateTimeValue();
@Optional
Property<LocalDateTime> localDateTimeValue();
@@ -580,7 +581,6 @@ public abstract class AbstractEntityStoreTest
public interface TestValue2
extends ValueComposite
{
-
Property<String> stringValue();
Property<Tjabba> anotherValue();
@@ -588,8 +588,6 @@ public abstract class AbstractEntityStoreTest
public enum TestEnum
{
-
VALUE1, VALUE2, VALUE3
}
-
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractQueryTest.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractQueryTest.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractQueryTest.java
index 9b40b62..8a0dc57 100644
--- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractQueryTest.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractQueryTest.java
@@ -22,19 +22,18 @@ package org.apache.zest.test.indexing;
import java.io.IOException;
import java.math.BigDecimal;
import java.math.BigInteger;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.ZoneId;
+import java.time.ZonedDateTime;
import java.util.HashMap;
import java.util.Map;
import org.apache.zest.api.injection.scope.Structure;
-import org.apache.zest.api.structure.Module;
-import org.joda.time.DateTime;
-import org.joda.time.LocalDate;
-import org.joda.time.LocalDateTime;
-import org.junit.Ignore;
-import org.junit.Test;
import org.apache.zest.api.query.NotQueryableException;
import org.apache.zest.api.query.Query;
import org.apache.zest.api.query.QueryBuilder;
import org.apache.zest.api.query.grammar.OrderBy;
+import org.apache.zest.api.structure.Module;
import org.apache.zest.spi.query.EntityFinderException;
import org.apache.zest.spi.query.IndexExporter;
import org.apache.zest.test.indexing.model.Account;
@@ -46,12 +45,10 @@ import org.apache.zest.test.indexing.model.Male;
import org.apache.zest.test.indexing.model.Nameable;
import org.apache.zest.test.indexing.model.Person;
import org.apache.zest.test.indexing.model.QueryParam;
+import org.junit.Ignore;
+import org.junit.Test;
-import static org.hamcrest.core.Is.is;
-import static org.hamcrest.core.IsEqual.equalTo;
-import static org.joda.time.DateTimeZone.UTC;
-import static org.joda.time.DateTimeZone.forID;
-import static org.junit.Assert.assertThat;
+import static java.time.ZoneOffset.UTC;
import static org.apache.zest.api.query.QueryExpressions.and;
import static org.apache.zest.api.query.QueryExpressions.contains;
import static org.apache.zest.api.query.QueryExpressions.containsName;
@@ -70,6 +67,9 @@ import static org.apache.zest.api.query.QueryExpressions.orderBy;
import static org.apache.zest.api.query.QueryExpressions.templateFor;
import static org.apache.zest.test.indexing.NameableAssert.verifyOrderedResults;
import static org.apache.zest.test.indexing.NameableAssert.verifyUnorderedResults;
+import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsEqual.equalTo;
+import static org.junit.Assert.assertThat;
/**
* Abstract satisfiedBy with tests for simple queries against Index/Query engines.
@@ -79,7 +79,7 @@ public abstract class AbstractQueryTest
{
@Structure
Module moduleInstance;
-
+ private ZonedDateTime refDate;
@Test
public void showNetwork()
@@ -117,7 +117,7 @@ public abstract class AbstractQueryTest
QueryBuilder<Nameable> qb = this.moduleInstance.newQueryBuilder( Nameable.class );
Query<Nameable> query = unitOfWork.newQuery( qb );
System.out.println( "*** script03: " + query );
- verifyUnorderedResults( query, "Felix", "Joe Doe", "Ann Doe", "Jack Doe", "Penang", "Kuala Lumpur", "Cooking", "Gaming",
+ verifyUnorderedResults( query, "Felix", "Joe Doe", "Ann Doe", "Jack Doe", "Penang", "Kuala Lumpur", "Cooking", "Gaming",
"Programming", "Cars" );
}
@@ -152,10 +152,10 @@ public abstract class AbstractQueryTest
QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Person person = templateFor( Person.class );
Query<Person> query = unitOfWork.newQuery( qb.where( eq( person.mother()
- .get()
- .placeOfBirth()
- .get()
- .name(), "Kuala Lumpur" ) )
+ .get()
+ .placeOfBirth()
+ .get()
+ .name(), "Kuala Lumpur" ) )
);
System.out.println( "*** script05: " + query );
verifyUnorderedResults( query, "Joe Doe" );
@@ -441,10 +441,10 @@ public abstract class AbstractQueryTest
QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Person person = templateFor( Person.class );
Query<Person> query = unitOfWork.newQuery( qb.where( eq( person.personalWebsite()
- .get()
- .protocol()
- .get()
- .value(), "http" ) )
+ .get()
+ .protocol()
+ .get()
+ .value(), "http" ) )
);
System.out.println( "*** script29: " + query );
verifyUnorderedResults( query, "Jack Doe" );
@@ -573,8 +573,9 @@ public abstract class AbstractQueryTest
{
QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Person person = templateFor( Person.class );
+ refDate = ZonedDateTime.of( 2010, 3, 4, 13, 24, 35, 0, UTC );
Query<Person> query = unitOfWork.newQuery( qb.where(
- eq( person.dateValue(), new DateTime( "2010-03-04T13:24:35", UTC ).toDate() ) ) );
+ eq( person.instantValue(), refDate.toInstant() ) ) );
System.out.println( "*** script40_Date: " + query );
verifyUnorderedResults( query, "Jack Doe" );
@@ -586,7 +587,7 @@ public abstract class AbstractQueryTest
QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Person person = templateFor( Person.class );
Query<Person> query = unitOfWork.newQuery( qb.where(
- ne( person.dateValue(), new DateTime( "2010-03-04T13:24:35", UTC ).toDate() ) ) );
+ ne( person.instantValue(), refDate.toInstant() ) ) );
System.out.println( "*** script41_Date: " + query );
verifyUnorderedResults( query, "Joe Doe" );
@@ -597,8 +598,9 @@ public abstract class AbstractQueryTest
{
QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Person person = templateFor( Person.class );
+ ZonedDateTime cetTime = ZonedDateTime.of( 2010, 3, 4, 14, 24, 35, 0, ZoneId.of( "CET" ) );
Query<Person> query = unitOfWork.newQuery( qb.where(
- ne( person.dateValue(), new DateTime( "2010-03-04T14:24:35", forID( "CET" ) ).toDate() ) ) );
+ ne( person.instantValue(), cetTime.toInstant() ) ) );
System.out.println( "*** script42_Date: " + query );
verifyUnorderedResults( query, "Joe Doe" );
@@ -609,9 +611,11 @@ public abstract class AbstractQueryTest
{
QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Person person = templateFor( Person.class );
+ ZonedDateTime start = ZonedDateTime.of( 2005, 3, 4, 13, 24, 35, 0, UTC );
+ ZonedDateTime end = ZonedDateTime.of( 2015, 3, 4, 13, 24, 35, 0, UTC );
Query<Person> query = unitOfWork.newQuery( qb.where(
- and( gt( person.dateValue(), new DateTime( "2005-03-04T13:24:35", UTC ).toDate() ),
- lt( person.dateValue(), new DateTime( "2015-03-04T13:24:35", UTC ).toDate() ) ) ) );
+ and( gt( person.instantValue(), start.toInstant() ),
+ lt( person.instantValue(), end.toInstant() ) ) ) );
System.out.println( "*** script43_Date: " + query );
verifyUnorderedResults( query, "Jack Doe" );
@@ -622,8 +626,9 @@ public abstract class AbstractQueryTest
{
QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Person person = templateFor( Person.class );
+ ZonedDateTime time = ZonedDateTime.of( 2010, 3, 4, 13, 24, 35, 0, UTC );
Query<Person> query = unitOfWork.newQuery( qb.where(
- eq( person.dateTimeValue(), new DateTime( "2010-03-04T13:24:35", UTC ) ) ) );
+ eq( person.dateTimeValue(), time ) ) );
System.out.println( "*** script40_DateTime: " + query );
verifyUnorderedResults( query, "Jack Doe" );
@@ -634,8 +639,9 @@ public abstract class AbstractQueryTest
{
QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Person person = templateFor( Person.class );
+ ZonedDateTime time = ZonedDateTime.of( 2010, 3, 4, 13, 24, 35, 0, UTC );
Query<Person> query = unitOfWork.newQuery( qb.where(
- ne( person.dateTimeValue(), new DateTime( "2010-03-04T13:24:35", UTC ) ) ) );
+ ne( person.dateTimeValue(), time ) ) );
System.out.println( "*** script41_DateTime: " + query );
verifyUnorderedResults( query, "Joe Doe" );
@@ -646,8 +652,9 @@ public abstract class AbstractQueryTest
{
QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Person person = templateFor( Person.class );
+ ZonedDateTime time = ZonedDateTime.of( 2010, 3, 4, 13, 24, 35, 0, ZoneId.of( "CET" ) );
Query<Person> query = unitOfWork.newQuery( qb.where(
- ne( person.dateTimeValue(), new DateTime( "2010-03-04T14:24:35", forID( "CET" ) ) ) ) );
+ ne( person.dateTimeValue(), time ) ) );
System.out.println( "*** script42_DateTime: " + query );
verifyUnorderedResults( query, "Jack Doe", "Joe Doe" );
@@ -658,9 +665,11 @@ public abstract class AbstractQueryTest
{
QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Person person = templateFor( Person.class );
+ ZonedDateTime start = ZonedDateTime.of( 2005, 3, 4, 13, 24, 35, 0, UTC );
+ ZonedDateTime end = ZonedDateTime.of( 2015, 3, 4, 13, 24, 35, 0, UTC );
Query<Person> query = unitOfWork.newQuery( qb.where(
- and( gt( person.dateTimeValue(), new DateTime( "2005-03-04T13:24:35", UTC ) ),
- lt( person.dateTimeValue(), new DateTime( "2015-03-04T13:24:35", UTC ) ) ) ) );
+ and( gt( person.dateTimeValue(), start ),
+ lt( person.dateTimeValue(), end ) ) ) );
System.out.println( "*** script43_DateTime: " + query );
verifyUnorderedResults( query, "Jack Doe" );
@@ -672,7 +681,7 @@ public abstract class AbstractQueryTest
QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Person person = templateFor( Person.class );
Query<Person> query = unitOfWork.newQuery( qb.where(
- eq( person.localDateTimeValue(), new LocalDateTime( "2010-03-04T13:23:00", UTC ) ) ) );
+ eq( person.localDateTimeValue(), LocalDateTime.of( 2010, 3, 4, 13, 23, 0 ) ) ) );
System.out.println( "*** script40_LocalDateTime: " + query );
verifyUnorderedResults( query, "Jack Doe" );
@@ -684,7 +693,7 @@ public abstract class AbstractQueryTest
QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Person person = templateFor( Person.class );
Query<Person> query = unitOfWork.newQuery( qb.where(
- ne( person.localDateTimeValue(), new LocalDateTime( "2010-03-04T13:23:00", UTC ) ) ) );
+ ne( person.localDateTimeValue(), LocalDateTime.of( 2010, 3, 4, 13, 23, 0 ) ) ) );
System.out.println( "*** script41_LocalDateTime: " + query );
verifyUnorderedResults( query, "Joe Doe" );
@@ -695,8 +704,9 @@ public abstract class AbstractQueryTest
{
QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Person person = templateFor( Person.class );
+ ZonedDateTime time = ZonedDateTime.of( 2010, 3, 4, 13, 24, 35, 0, ZoneId.of( "CET" ) );
Query<Person> query = unitOfWork.newQuery( qb.where(
- ne( person.localDateTimeValue(), new LocalDateTime( "2010-03-04T13:23:00", forID( "CET" ) ) ) ) );
+ ne( person.localDateTimeValue(), time.toLocalDateTime() ) ) );
System.out.println( "*** script42_LocalDateTime: " + query );
verifyUnorderedResults( query, "Joe Doe" );
@@ -707,9 +717,11 @@ public abstract class AbstractQueryTest
{
QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Person person = templateFor( Person.class );
+ LocalDateTime start = ZonedDateTime.of( 2005, 3, 4, 13, 24, 35, 0, UTC ).toLocalDateTime();
+ LocalDateTime end = ZonedDateTime.of( 2015, 3, 4, 13, 24, 35, 0, UTC ).toLocalDateTime();
Query<Person> query = unitOfWork.newQuery( qb.where(
- and( gt( person.localDateTimeValue(), new LocalDateTime( "2005-03-04T13:24:35", UTC ) ),
- lt( person.localDateTimeValue(), new LocalDateTime( "2015-03-04T13:24:35", UTC ) ) ) ) );
+ and( gt( person.localDateTimeValue(), start ),
+ lt( person.localDateTimeValue(), end ) ) ) );
System.out.println( "*** script43_LocalDateTime: " + query );
verifyUnorderedResults( query, "Jack Doe" );
@@ -721,7 +733,7 @@ public abstract class AbstractQueryTest
QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Person person = templateFor( Person.class );
Query<Person> query = unitOfWork.newQuery( qb.where(
- eq( person.localDateValue(), new LocalDate( "2010-03-04", UTC ) ) ) );
+ eq( person.localDateValue(), LocalDate.of( 2010,3,4 ) ) ) );
System.out.println( "*** script40_LocalDate: " + query );
verifyUnorderedResults( query, "Jack Doe" );
@@ -733,7 +745,7 @@ public abstract class AbstractQueryTest
QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Person person = templateFor( Person.class );
Query<Person> query = unitOfWork.newQuery( qb.where(
- ne( person.localDateValue(), new LocalDate( "2010-03-04", UTC ) ) ) );
+ ne( person.localDateValue(), LocalDate.of( 2010,3,4 ) ) ) );
System.out.println( "*** script41_LocalDate: " + query );
verifyUnorderedResults( query, "Joe Doe" );
@@ -744,8 +756,9 @@ public abstract class AbstractQueryTest
{
QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Person person = templateFor( Person.class );
+ LocalDate time = ZonedDateTime.of(2010,3,4,13,24,35,0, ZoneId.of("CET")).toLocalDate();
Query<Person> query = unitOfWork.newQuery( qb.where(
- ne( person.localDateValue(), new LocalDate( "2010-03-04", forID( "CET" ) ) ) ) );
+ ne( person.localDateValue(), time ) ) );
System.out.println( "*** script42_LocalDate: " + query );
verifyUnorderedResults( query, "Joe Doe" );
@@ -756,9 +769,11 @@ public abstract class AbstractQueryTest
{
QueryBuilder<Person> qb = this.moduleInstance.newQueryBuilder( Person.class );
Person person = templateFor( Person.class );
+ LocalDate start = ZonedDateTime.of(2010,3,4,13,24,35,0,UTC).toLocalDate();
+ LocalDate end = ZonedDateTime.of(2010,3,4,13,24,35,0,UTC).toLocalDate();
Query<Person> query = unitOfWork.newQuery( qb.where(
- and( gt( person.localDateValue(), new LocalDate( "2005-03-04", UTC ) ),
- lt( person.localDateValue(), new LocalDate( "2015-03-04", UTC ) ) ) ) );
+ and( gt( person.localDateValue(), start),
+ lt( person.localDateValue(), end ) ) ) );
System.out.println( "*** script43_LocalDate: " + query );
verifyUnorderedResults( query, "Jack Doe" );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/core/testsupport/src/main/java/org/apache/zest/test/indexing/TestData.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/TestData.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/TestData.java
index 7c5d2fa..8d20a6e 100644
--- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/TestData.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/TestData.java
@@ -21,6 +21,9 @@ package org.apache.zest.test.indexing;
import java.math.BigDecimal;
import java.math.BigInteger;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.ZonedDateTime;
import java.util.ArrayList;
import java.util.List;
import org.apache.zest.api.entity.EntityBuilder;
@@ -39,11 +42,8 @@ import org.apache.zest.test.indexing.model.Person;
import org.apache.zest.test.indexing.model.Protocol;
import org.apache.zest.test.indexing.model.QueryParam;
import org.apache.zest.test.indexing.model.URL;
-import org.joda.time.DateTime;
-import org.joda.time.LocalDate;
-import org.joda.time.LocalDateTime;
-import static org.joda.time.DateTimeZone.UTC;
+import static java.time.ZoneOffset.UTC;
/**
* Utility class to populate Index/Query tests data.
@@ -176,10 +176,10 @@ public class TestData
joeDoe.address().set( address );
joeDoe.bigInteger().set( new BigInteger( "23232323232323232323232323" ) );
joeDoe.bigDecimal().set( new BigDecimal( "23.4276931348623157e+309" ) );
- joeDoe.dateValue().set( new DateTime( "2020-03-04T13:24:35", UTC ).toDate() );
- joeDoe.dateTimeValue().set( new DateTime( "2020-03-04T13:24:35", UTC ) );
- joeDoe.localDateTimeValue().set( new LocalDateTime( "2020-03-04T13:23:00" ) );
- joeDoe.localDateValue().set( new LocalDate( "2020-03-04" ) );
+ joeDoe.instantValue().set( ZonedDateTime.of( 2020, 3, 4, 13, 24, 35, 0, UTC ).toInstant() );
+ joeDoe.dateTimeValue().set( ZonedDateTime.of( 2020, 3, 4, 13, 24, 35, 0, UTC ) );
+ joeDoe.localDateTimeValue().set( LocalDateTime.of( 2020, 3, 4, 13, 23, 0 ) );
+ joeDoe.localDateValue().set( LocalDate.of( 2020, 3, 4 ) );
NameableAssert.trace( joeDoe );
}
@@ -201,10 +201,10 @@ public class TestData
jackDoe.address().set( address );
jackDoe.bigInteger().set( new BigInteger( "42424242424242424242424242" ) );
jackDoe.bigDecimal().set( new BigDecimal( "42.2376931348623157e+309" ) );
- jackDoe.dateValue().set( new DateTime( "2010-03-04T13:24:35", UTC ).toDate() );
- jackDoe.dateTimeValue().set( new DateTime( "2010-03-04T13:24:35", UTC ) );
- jackDoe.localDateTimeValue().set( new LocalDateTime( "2010-03-04T13:23:00" ) );
- jackDoe.localDateValue().set( new LocalDate( "2010-03-04" ) );
+ jackDoe.instantValue().set( ZonedDateTime.of( 2010, 3, 4, 13, 24, 35, 0, UTC ).toInstant() );
+ jackDoe.dateTimeValue().set( ZonedDateTime.of( 2010, 3, 4, 13, 24, 35, 0, UTC ) );
+ jackDoe.localDateTimeValue().set( LocalDateTime.of( 2010, 3, 4, 13, 23, 0 ) );
+ jackDoe.localDateValue().set( LocalDate.of( 2010, 3, 4 ) );
ValueBuilder<URL> urlBuilder = module.newValueBuilder( URL.class );
ValueBuilder<Protocol> protocolBuilder = module.newValueBuilder( Protocol.class );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/Person.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/Person.java b/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/Person.java
index e9bfd11..1046879 100644
--- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/Person.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/model/Person.java
@@ -21,11 +21,11 @@ package org.apache.zest.test.indexing.model;
import java.math.BigDecimal;
import java.math.BigInteger;
-import java.util.Date;
+import java.time.Instant;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.ZonedDateTime;
import java.util.Map;
-import org.joda.time.DateTime;
-import org.joda.time.LocalDate;
-import org.joda.time.LocalDateTime;
import org.apache.zest.api.association.Association;
import org.apache.zest.api.association.ManyAssociation;
import org.apache.zest.api.association.NamedAssociation;
@@ -86,10 +86,10 @@ public interface Person
Property<BigDecimal> bigDecimal();
@Optional
- Property<Date> dateValue();
+ Property<Instant> instantValue();
@Optional
- Property<DateTime> dateTimeValue();
+ Property<ZonedDateTime> dateTimeValue();
@Optional
Property<LocalDateTime> localDateTimeValue();
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/core/testsupport/src/main/java/org/apache/zest/test/value/AbstractJsonDateFormatTest.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/value/AbstractJsonDateFormatTest.java b/core/testsupport/src/main/java/org/apache/zest/test/value/AbstractJsonDateFormatTest.java
index 3ad92cc..4cb33ba 100644
--- a/core/testsupport/src/main/java/org/apache/zest/test/value/AbstractJsonDateFormatTest.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/value/AbstractJsonDateFormatTest.java
@@ -19,12 +19,17 @@
*/
package org.apache.zest.test.value;
-import java.util.Date;
+import java.time.Duration;
+import java.time.Instant;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.time.OffsetDateTime;
+import java.time.Period;
+import java.time.ZoneId;
+import java.time.ZoneOffset;
+import java.time.ZonedDateTime;
import java.util.List;
-import org.joda.time.DateTime;
-import org.joda.time.DateTimeZone;
-import org.junit.Before;
-import org.junit.Test;
import org.apache.zest.api.injection.scope.Service;
import org.apache.zest.api.type.CollectionType;
import org.apache.zest.api.type.ValueType;
@@ -32,8 +37,10 @@ import org.apache.zest.api.value.ValueDeserializer;
import org.apache.zest.bootstrap.AssemblyException;
import org.apache.zest.bootstrap.ModuleAssembly;
import org.apache.zest.test.AbstractZestTest;
+import org.junit.Test;
-import static org.junit.Assert.*;
+import static org.hamcrest.core.IsEqual.equalTo;
+import static org.junit.Assert.assertThat;
/**
* Assert that a JSON ValueDeserializer support various date formats.
@@ -43,7 +50,14 @@ public class AbstractJsonDateFormatTest
extends AbstractZestTest
{
- private final ValueType dateType = new ValueType( Date.class );
+ private final ValueType offsetDateTimeType = new ValueType( OffsetDateTime.class );
+ private final ValueType zonedDateTimeType = new ValueType( ZonedDateTime.class );
+ private final ValueType localDateTimeType = new ValueType( LocalDateTime.class );
+ private final ValueType localTimeType = new ValueType( LocalTime.class );
+ private final ValueType localDateType = new ValueType( LocalDate.class );
+ private final ValueType instantType = new ValueType( Instant.class );
+ private final ValueType durationType = new ValueType( Duration.class );
+ private final ValueType periodType = new ValueType( Period.class );
@Override
public void assemble( ModuleAssembly module )
@@ -55,31 +69,83 @@ public class AbstractJsonDateFormatTest
protected ValueDeserializer valueDeserializer;
@Test
- public void givenISO6801DateFormatWhenConvertingFromSerializedStateExpectValidDate()
+ public void givenLocalDateTimeFormatWhenConvertingFromSerializedStateExpectValidDate()
+ throws Exception
+ {
+ CollectionType collectionType = new CollectionType( List.class, localDateTimeType );
+ List<LocalDateTime> value = valueDeserializer.deserialize( module, collectionType, "[\"2009-08-12T14:54:27\"]" );
+ LocalDateTime expected = LocalDateTime.of( 2009, 8, 12, 14, 54, 27 );
+ assertThat( value.get( 0 ), equalTo( expected ) );
+ }
+
+ @Test
+ public void givenLocalDateFormatWhenConvertingFromSerializedStateExpectValidDate()
+ throws Exception
+ {
+ CollectionType collectionType = new CollectionType( List.class, localDateType );
+ List<LocalDate> value = valueDeserializer.deserialize( module, collectionType, "[\"2009-08-12\"]" );
+ LocalDate expected = LocalDate.of( 2009, 8, 12 );
+ assertThat( value.get( 0 ), equalTo( expected ) );
+ }
+
+ @Test
+ public void givenLocalTimeFormatWhenConvertingFromSerializedStateExpectValidDate()
+ throws Exception
+ {
+ CollectionType collectionType = new CollectionType( List.class, localTimeType );
+ List<LocalTime> value = valueDeserializer.deserialize( module, collectionType, "[\"14:54:27\"]" );
+ LocalTime expected = LocalTime.of( 14, 54, 27 );
+ assertThat( value.get( 0 ), equalTo( expected ) );
+ }
+
+ @Test
+ public void givenOffsetDateTimeFormatWhenConvertingFromSerializedStateExpectValidDate()
+ throws Exception
+ {
+ CollectionType collectionType = new CollectionType( List.class, offsetDateTimeType );
+ List<OffsetDateTime> value = valueDeserializer.deserialize( module, collectionType, "[\"2009-08-12T14:54:27.895+08:00\"]" );
+ OffsetDateTime expected = OffsetDateTime.of( 2009, 8, 12, 14, 54, 27, 895000000, ZoneOffset.ofHours( 8 ) );
+ assertThat( value.get( 0 ), equalTo( expected ) );
+ }
+
+ @Test
+ public void givenZonedDateTimeFormatWhenConvertingFromSerializedStateExpectValidDate()
throws Exception
{
- CollectionType collectionType = new CollectionType( List.class, dateType );
- List<Date> value = valueDeserializer.deserialize( module, collectionType, "[\"2009-08-12T14:54:27.895+0800\"]" );
- assertEquals( new DateTime( "2009-08-12T06:54:27.895Z", DateTimeZone.UTC ).toDate(), value.get( 0 ) );
+ CollectionType collectionType = new CollectionType( List.class, zonedDateTimeType );
+ List<ZonedDateTime> value = valueDeserializer.deserialize( module, collectionType, "[\"2009-08-12T14:54:27.895+02:00[CET]\"]" );
+ ZonedDateTime expected = ZonedDateTime.of( 2009, 8, 12, 14, 54, 27, 895000000, ZoneId.of( "CET" ) );
+ assertThat( value.get( 0 ), equalTo( expected ) );
}
@Test
- public void givenAtDateFormatWhenConvertingFromSerializedStateExpectValidDate()
+ public void givenInstantFormatWhenConvertingFromSerializedStateExpectValidDate()
throws Exception
{
- long tstamp = System.currentTimeMillis();
- CollectionType collectionType = new CollectionType( List.class, dateType );
- List<Date> value = valueDeserializer.deserialize( module, collectionType, "[\"@" + tstamp + "@\"]" );
- assertEquals( new Date( tstamp ), value.get( 0 ) );
+ CollectionType collectionType = new CollectionType( List.class, instantType);
+ List<Instant> value = valueDeserializer.deserialize( module, collectionType, "[\"2016-06-11T08:47:12.620Z\"]" );
+ Instant expected = Instant.parse("2016-06-11T08:47:12.620Z" );
+ assertThat( value.get( 0 ), equalTo( expected ) );
}
@Test
- public void givenMicrosoftDateFormatWhenConvertingFromSerializedStateExpectValidDate()
+ public void givenDurationFormatWhenConvertingFromSerializedStateExpectValidDate()
throws Exception
{
- long tstamp = System.currentTimeMillis();
- CollectionType collectionType = new CollectionType( List.class, dateType );
- List<Date> value = valueDeserializer.deserialize( module, collectionType, "[\"/Date(" + tstamp + ")/\"]" );
- assertEquals( new Date( tstamp ), value.get( 0 ) );
+ CollectionType collectionType = new CollectionType( List.class, durationType );
+ List<Duration> value = valueDeserializer.deserialize( module, collectionType, "[\"PT3.5S\"]" );
+ Duration expected = Duration.ofMillis( 3500 );
+ assertThat( value.get( 0 ), equalTo( expected ) );
}
+
+ @Test
+ public void givenPeriodFormatWhenConvertingFromSerializedStateExpectValidDate()
+ throws Exception
+ {
+ CollectionType collectionType = new CollectionType( List.class, periodType );
+ List<ZonedDateTime> value = valueDeserializer.deserialize( module, collectionType, "[\"P3Y5M13D\"]" );
+ Period expected = Period.of( 3, 5, 13);
+ assertThat( value.get( 0 ), equalTo( expected ) );
+ }
+
}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/49bab608/core/testsupport/src/main/java/org/apache/zest/test/value/AbstractPlainValueSerializationTest.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/value/AbstractPlainValueSerializationTest.java b/core/testsupport/src/main/java/org/apache/zest/test/value/AbstractPlainValueSerializationTest.java
index f00af68..3ac1039 100644
--- a/core/testsupport/src/main/java/org/apache/zest/test/value/AbstractPlainValueSerializationTest.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/value/AbstractPlainValueSerializationTest.java
@@ -21,7 +21,11 @@ package org.apache.zest.test.value;
import java.math.BigDecimal;
import java.math.BigInteger;
-import java.util.Date;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.OffsetDateTime;
+import java.time.ZoneOffset;
+import java.time.ZonedDateTime;
import org.apache.zest.api.entity.EntityBuilder;
import org.apache.zest.api.entity.EntityReference;
import org.apache.zest.api.injection.scope.Service;
@@ -35,16 +39,10 @@ import org.apache.zest.bootstrap.ModuleAssembly;
import org.apache.zest.entitystore.memory.MemoryEntityStoreService;
import org.apache.zest.spi.uuid.UuidIdentityGeneratorService;
import org.apache.zest.test.AbstractZestTest;
-import org.joda.time.DateTime;
-import org.joda.time.LocalDate;
-import org.joda.time.LocalDateTime;
import org.junit.Test;
import static org.hamcrest.core.IsEqual.equalTo;
import static org.hamcrest.core.IsNot.not;
-import static org.joda.time.DateTimeZone.UTC;
-import static org.joda.time.DateTimeZone.forID;
-import static org.joda.time.DateTimeZone.forOffsetHours;
import static org.junit.Assert.assertThat;
/**
@@ -194,46 +192,33 @@ public abstract class AbstractPlainValueSerializationTest
}
@Test
- public void givenDateValueWhenSerializingAndDeserializingExpectEquals()
- {
- String serialized = valueSerialization.serialize( new DateTime( "2020-03-04T13:24:35", forID( "CET" ) ).toDate() );
- assertThat( serialized, equalTo( "2020-03-04T12:24:35.000Z" ) );
-
- Date deserialized = valueSerialization.deserialize( module, Date.class, serialized );
- assertThat( deserialized, equalTo( new DateTime( "2020-03-04T13:24:35", forID( "CET" ) ).toDate() ) );
- assertThat( deserialized, equalTo( new DateTime( "2020-03-04T12:24:35", UTC ).toDate() ) );
- }
-
- @Test
public void givenDateTimeValueWhenSerializingAndDeserializingExpectEquals()
{
- // We specify the TimeZone explicitely here so that serialized/deserialized is equals
- // See https://github.com/JodaOrg/joda-time/issues/106
- String serialized = valueSerialization.serialize( new DateTime( "2020-03-04T13:24:35", forOffsetHours( 1 ) ) );
- assertThat( serialized, equalTo( "2020-03-04T13:24:35.000+01:00" ) );
- DateTime deserialized = valueSerialization.deserialize( module, DateTime.class, serialized );
- assertThat( deserialized, equalTo( new DateTime( "2020-03-04T13:24:35", forOffsetHours( 1 ) ) ) );
+ String serialized = valueSerialization.serialize( OffsetDateTime.of( 2020, 3, 4, 13, 24, 35, 123000000, ZoneOffset.ofHours( 1 ) ) );
+ assertThat( serialized, equalTo( "2020-03-04T13:24:35.123+01:00" ) );
+ ZonedDateTime deserialized = valueSerialization.deserialize( module, ZonedDateTime.class, serialized );
+ assertThat( deserialized, equalTo( ZonedDateTime.of( 2020, 3, 4, 13, 24, 35, 123000000, ZoneOffset.ofHours( 1 ) ) ) );
}
@Test
public void givenLocalDateTimeValueWhenSerializingAndDeserializingExpectEquals()
{
// Serialized without TimeZone
- String serialized = valueSerialization.serialize( new LocalDateTime( "2020-03-04T13:23:00", forID( "CET" ) ) );
- assertThat( serialized, equalTo( "2020-03-04T13:23:00.000" ) );
+ String serialized = valueSerialization.serialize( LocalDateTime.of( 2020, 3, 4, 13, 23, 12 ) );
+ assertThat( serialized, equalTo( "2020-03-04T13:23:12" ) );
LocalDateTime deserialized = valueSerialization.deserialize( module, LocalDateTime.class, serialized );
- assertThat( deserialized, equalTo( new LocalDateTime( "2020-03-04T13:23:00", UTC ) ) );
+ assertThat( deserialized, equalTo( LocalDateTime.of( 2020, 3, 4, 13, 23, 12 ) ) );
}
@Test
public void givenLocalDateValueWhenSerializingAndDeserializingExpectEquals()
{
- String serialized = valueSerialization.serialize( new LocalDate( "2020-03-04" ) );
+ String serialized = valueSerialization.serialize( LocalDate.of( 2020, 3, 4 ) );
assertThat( serialized, equalTo( "2020-03-04" ) );
LocalDate deserialized = valueSerialization.deserialize( module, LocalDate.class, serialized );
- assertThat( deserialized, equalTo( new LocalDate( "2020-03-04" ) ) );
+ assertThat( deserialized, equalTo( LocalDate.of( 2020,3,4 ) ) );
}
@Test
[21/25] zest-java git commit: Merge remote-tracking branch
'origin/develop' into develop
Posted by ni...@apache.org.
Merge remote-tracking branch 'origin/develop' into develop
Project: http://git-wip-us.apache.org/repos/asf/zest-java/repo
Commit: http://git-wip-us.apache.org/repos/asf/zest-java/commit/93b6d030
Tree: http://git-wip-us.apache.org/repos/asf/zest-java/tree/93b6d030
Diff: http://git-wip-us.apache.org/repos/asf/zest-java/diff/93b6d030
Branch: refs/heads/ValueSerializationCleaning
Commit: 93b6d0302aa8a74ccce1689464405b518ad5f95c
Parents: 8915dfa 17543d3
Author: Niclas Hedhman <ni...@hedhman.org>
Authored: Thu Jun 16 10:30:42 2016 +0800
Committer: Niclas Hedhman <ni...@hedhman.org>
Committed: Thu Jun 16 10:30:42 2016 +0800
----------------------------------------------------------------------
.../org/apache/zest/test/util/RetryRule.java | 55 ++++++++++++++++++++
.../apache/zest/test/cache/RetryRuleTest.java | 22 ++++++++
.../zest/library/metrics/MetricsTest.java | 4 ++
.../rest/admin/RestServerConfiguration.java | 32 ++++++++++++
.../library/rest/admin/RestServerMixin.java | 9 +++-
.../zest/library/rest/admin/RestTest.java | 35 ++++++++++---
6 files changed, 148 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
[09/25] zest-java git commit: ZEST-151 : Removed Conversion Library
Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/5229303a/libraries/conversion/src/main/java/org/apache/zest/library/conversion/values/ValueToEntityService.java
----------------------------------------------------------------------
diff --git a/libraries/conversion/src/main/java/org/apache/zest/library/conversion/values/ValueToEntityService.java b/libraries/conversion/src/main/java/org/apache/zest/library/conversion/values/ValueToEntityService.java
deleted file mode 100644
index 07eb026..0000000
--- a/libraries/conversion/src/main/java/org/apache/zest/library/conversion/values/ValueToEntityService.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-package org.apache.zest.library.conversion.values;
-
-import org.apache.zest.api.entity.Identity;
-import org.apache.zest.api.mixin.Mixins;
-
-/**
- * Service that creates or updates Entities from matching Values.
- * @deprecated Please use {@link org.apache.zest.api.unitofwork.UnitOfWork#toEntity(Class, Identity)} instead.
- */
-@Mixins( ValueToEntityMixin.class )
-public interface ValueToEntityService
- extends ValueToEntity
-{
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/5229303a/libraries/conversion/src/main/java/org/apache/zest/library/conversion/values/package.html
----------------------------------------------------------------------
diff --git a/libraries/conversion/src/main/java/org/apache/zest/library/conversion/values/package.html b/libraries/conversion/src/main/java/org/apache/zest/library/conversion/values/package.html
deleted file mode 100644
index 8e3482c..0000000
--- a/libraries/conversion/src/main/java/org/apache/zest/library/conversion/values/package.html
+++ /dev/null
@@ -1,24 +0,0 @@
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one
- ~ or more contributor license agreements. See the NOTICE file
- ~ distributed with this work for additional information
- ~ regarding copyright ownership. The ASF licenses this file
- ~ to you under the Apache License, Version 2.0 (the
- ~ "License"); you may not use this file except in compliance
- ~ with the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- ~
- ~
- -->
-<html>
- <body>
- <h2>Entities to Values Conversion.</h2>
- </body>
-</html>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/zest-java/blob/5229303a/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/EntityToValueTest.java
----------------------------------------------------------------------
diff --git a/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/EntityToValueTest.java b/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/EntityToValueTest.java
deleted file mode 100644
index 13c1868..0000000
--- a/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/EntityToValueTest.java
+++ /dev/null
@@ -1,232 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-package org.apache.zest.library.conversion.values;
-
-import java.time.Instant;
-import java.time.LocalDate;
-import java.util.function.Function;
-import org.junit.Test;
-import org.apache.zest.api.constraint.ConstraintViolationException;
-import org.apache.zest.api.service.ServiceReference;
-import org.apache.zest.api.unitofwork.UnitOfWork;
-import org.apache.zest.api.unitofwork.UnitOfWorkCompletionException;
-import org.apache.zest.bootstrap.AssemblyException;
-import org.apache.zest.bootstrap.ModuleAssembly;
-import org.apache.zest.library.conversion.values.TestModel.PersonEntity;
-import org.apache.zest.library.conversion.values.TestModel.PersonValue;
-import org.apache.zest.library.conversion.values.TestModel.PersonValue2;
-import org.apache.zest.library.conversion.values.TestModel.PersonValue3;
-import org.apache.zest.library.conversion.values.TestModel.PersonValue4;
-import org.apache.zest.test.AbstractZestTest;
-import org.apache.zest.test.EntityTestAssembler;
-
-import static org.junit.Assert.assertEquals;
-import static org.apache.zest.library.conversion.values.TestModel.createBirthDate;
-import static org.apache.zest.library.conversion.values.TestModel.createPerson;
-
-public class EntityToValueTest
- extends AbstractZestTest
-{
- @Override
- public void assemble( ModuleAssembly module )
- throws AssemblyException
- {
- // START SNIPPET: assembly
- new EntityToValueAssembler().assemble( module );
- // END SNIPPET: assembly
- new EntityTestAssembler().assemble( module );
- module.entities( PersonEntity.class );
- module.values( PersonValue.class );
- module.values( PersonValue2.class );
- module.values( PersonValue3.class );
- module.values( PersonValue4.class );
- }
-
- @Test
- public void whenConvertingEntityToValueExpectCorrectValues()
- throws UnitOfWorkCompletionException
- {
- UnitOfWork uow = unitOfWorkFactory.newUnitOfWork();
- try
- {
- PersonEntity entity = setupPersonEntities( uow );
-
- // START SNIPPET: conversion
- EntityToValueService conversion = serviceFinder.findService( EntityToValueService.class ).get();
- PersonValue value = conversion.convert( PersonValue.class, entity );
- // END SNIPPET: conversion
- assertEquals( "Niclas", value.firstName().get() );
- assertEquals( "Hedhman", value.lastName().get() );
- assertEquals( "id:Lis", value.spouse().get() );
- assertEquals( "id:Eric", value.children().get().get( 0 ) );
- uow.complete();
- }
- finally
- {
- uow.discard();
- }
- }
-
- @Test
- public void givenUnqualifiedValueWhenConvertingEntityExpectCorrectMapping()
- throws UnitOfWorkCompletionException
- {
- UnitOfWork uow = unitOfWorkFactory.newUnitOfWork();
- try
- {
- PersonEntity niclas = setupPersonEntities( uow );
-
- ServiceReference<EntityToValueService> reference = serviceFinder.findService( EntityToValueService.class );
- EntityToValueService service = reference.get();
-
- PersonValue2 niclasValue = service.convert( PersonValue2.class, niclas );
- assertEquals( "Niclas", niclasValue.firstName().get() );
- assertEquals( "Hedhman", niclasValue.lastName().get() );
- assertEquals( "id:Lis", niclasValue.spouse().get() );
- assertEquals( "id:Eric", niclasValue.children().get().get( 0 ) );
- uow.complete();
- }
- finally
- {
- uow.discard();
- }
- }
-
- @Test
- public void givenUnqualifiedValue2WhenConvertingEntityExpectCorrectMapping()
- throws UnitOfWorkCompletionException
- {
- UnitOfWork uow = unitOfWorkFactory.newUnitOfWork();
- try
- {
- PersonEntity niclas = setupPersonEntities( uow );
-
- ServiceReference<EntityToValueService> reference = serviceFinder.findService( EntityToValueService.class );
- EntityToValueService service = reference.get();
-
- PersonValue3 niclasValue = service.convert( PersonValue3.class, niclas );
- assertEquals( "Niclas", niclasValue.firstName().get() );
- assertEquals( "Hedhman", niclasValue.lastName().get() );
- assertEquals( "id:Lis", niclasValue.spouse().get() );
- assertEquals( "id:Eric", niclasValue.children().get().get( 0 ) );
- uow.complete();
- }
- finally
- {
- uow.discard();
- }
- }
-
- @Test( expected = ConstraintViolationException.class )
- public void givenQualifiedValueNotFromSameInterfaceWhenConvertingEntityExpectNonOptionalException()
- throws UnitOfWorkCompletionException
- {
- UnitOfWork uow = unitOfWorkFactory.newUnitOfWork();
- try
- {
- PersonEntity niclas = setupPersonEntities( uow );
-
- ServiceReference<EntityToValueService> reference = serviceFinder.findService( EntityToValueService.class );
- EntityToValueService service = reference.get();
-
- PersonValue4 niclasValue = service.convert( PersonValue4.class, niclas );
- uow.complete();
- }
- finally
- {
- uow.discard();
- }
- }
-
- @Test
- public void whenConvertingEntityToValueUsingPrototypeOpportunityExpectCorrectValues()
- throws UnitOfWorkCompletionException
- {
- UnitOfWork uow = unitOfWorkFactory.newUnitOfWork();
- try
- {
- PersonEntity entity = setupPersonEntities( uow );
-
- // START SNIPPET: prototypeOpportunity
- EntityToValueService conversion = serviceFinder.findService( EntityToValueService.class ).get();
- PersonValue value = conversion.convert( PersonValue.class, entity, new Function<PersonValue, PersonValue>()
- {
- @Override
- public PersonValue apply( PersonValue prototype )
- {
- prototype.firstName().set( "Prototype Opportunity" );
- return prototype;
- }
- } );
- // END SNIPPET: prototypeOpportunity
- assertEquals( "Prototype Opportunity", value.firstName().get() );
- assertEquals( "Hedhman", value.lastName().get() );
- assertEquals( "id:Lis", value.spouse().get() );
- assertEquals( "id:Eric", value.children().get().get( 0 ) );
- uow.complete();
- }
- finally
- {
- uow.discard();
- }
- }
-
- private static PersonEntity setupPersonEntities( UnitOfWork uow )
- {
- PersonEntity niclas = createNiclas( uow );
- PersonEntity lis = createLis( uow );
- PersonEntity eric = createEric( uow );
- niclas.spouse().set( lis );
- niclas.children().add( eric );
- lis.spouse().set( niclas );
- lis.children().add( eric );
- assertEquals( "Niclas", niclas.firstName() );
- assertEquals( "Hedhman", niclas.lastName() );
- assertEquals( "Lis", lis.firstName() );
- assertEquals( "Gazi", lis.lastName() );
- assertEquals( "Eric", eric.firstName() );
- assertEquals( "Hedman", eric.lastName() );
- return niclas;
- }
-
- private static PersonEntity createNiclas( UnitOfWork uow )
- {
- String firstName = "Niclas";
- String lastName = "Hedhman";
- LocalDate birthTime = createBirthDate( 1964, 9, 25 );
- return createPerson( uow, firstName, lastName, birthTime );
- }
-
- private static PersonEntity createLis( UnitOfWork uow )
- {
- String firstName = "Lis";
- String lastName = "Gazi";
- LocalDate birthTime = createBirthDate( 1976, 2, 19 );
- return createPerson( uow, firstName, lastName, birthTime );
- }
-
- private static PersonEntity createEric( UnitOfWork uow )
- {
- String firstName = "Eric";
- String lastName = "Hedman";
- LocalDate birthTime = createBirthDate( 2004, 4, 8 );
- return createPerson( uow, firstName, lastName, birthTime );
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/5229303a/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/NestedValuesConversionTest.java
----------------------------------------------------------------------
diff --git a/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/NestedValuesConversionTest.java b/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/NestedValuesConversionTest.java
deleted file mode 100644
index e049c30..0000000
--- a/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/NestedValuesConversionTest.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-package org.apache.zest.library.conversion.values;
-
-import java.util.Arrays;
-import java.util.List;
-import org.junit.Test;
-import org.apache.zest.api.entity.EntityBuilder;
-import org.apache.zest.api.entity.EntityComposite;
-import org.apache.zest.api.property.Property;
-import org.apache.zest.api.unitofwork.UnitOfWork;
-import org.apache.zest.api.unitofwork.UnitOfWorkCompletionException;
-import org.apache.zest.api.value.ValueBuilder;
-import org.apache.zest.api.value.ValueComposite;
-import org.apache.zest.bootstrap.AssemblyException;
-import org.apache.zest.bootstrap.ModuleAssembly;
-import org.apache.zest.test.AbstractZestTest;
-import org.apache.zest.test.EntityTestAssembler;
-
-import static org.hamcrest.core.IsEqual.equalTo;
-import static org.junit.Assert.assertThat;
-
-public class NestedValuesConversionTest
- extends AbstractZestTest
-{
-
- @Override
- public void assemble( ModuleAssembly ma )
- throws AssemblyException
- {
- new EntityToValueAssembler().assemble( ma );
- new EntityTestAssembler().assemble( ma );
-
- ma.entities( FooEntity.class );
- ma.values( FooValue.class, BarValue.class );
- }
-
- @Test
- public void testNestedValuesConversion()
- throws UnitOfWorkCompletionException
- {
- UnitOfWork uow = unitOfWorkFactory.newUnitOfWork();
- try
- {
- FooEntity fooEntity = createFooEntity( uow, "Test nested values conversion" );
- EntityToValueService conversion = serviceFinder.findService( EntityToValueService.class ).get();
- FooValue fooValue = conversion.convert( FooValue.class, fooEntity );
- assertThat( fooValue.name().get(), equalTo( "Test nested values conversion" ) );
- assertThat( fooValue.bar().get().bazar().get(), equalTo( "single" ) );
- List<BarValue> barList = fooValue.barList().get();
- assertThat( barList.size(), equalTo( 3 ) );
- assertThat( barList.get( 0 ).bazar().get(), equalTo( "multi-one" ) );
- assertThat( barList.get( 1 ).bazar().get(), equalTo( "multi-two" ) );
- assertThat( barList.get( 2 ).bazar().get(), equalTo( "multi-three" ) );
- uow.complete();
- uow = null;
- }
- finally
- {
- if( uow != null )
- {
- uow.discard();
- }
- }
- }
-
- private FooEntity createFooEntity( UnitOfWork uow, String name )
- {
- EntityBuilder<FooEntity> builder = uow.newEntityBuilder( FooEntity.class );
- builder.instance().name().set( name );
- builder.instance().bar().set( createBarValue( "single" ) );
- List<BarValue> bars = Arrays.asList( createBarValue( "multi-one" ),
- createBarValue( "multi-two" ),
- createBarValue( "multi-three" ) );
- builder.instance().barList().set( bars );
- return builder.newInstance();
- }
-
- private BarValue createBarValue( String bazar )
- {
- ValueBuilder<BarValue> builder = valueBuilderFactory.newValueBuilder( BarValue.class );
- builder.prototype().bazar().set( bazar );
- return builder.newInstance();
- }
-
- public interface FooState
- {
-
- Property<String> name();
-
- Property<BarValue> bar();
-
- Property<List<BarValue>> barList();
- }
-
- public interface FooValue
- extends FooState, ValueComposite
- {
- }
-
- public interface FooEntity
- extends FooState, EntityComposite
- {
- }
-
- public interface BarValue
- extends ValueComposite
- {
-
- Property<String> bazar();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/5229303a/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/TestModel.java
----------------------------------------------------------------------
diff --git a/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/TestModel.java b/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/TestModel.java
deleted file mode 100644
index 54fe910..0000000
--- a/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/TestModel.java
+++ /dev/null
@@ -1,202 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-package org.apache.zest.library.conversion.values;
-
-import java.time.Duration;
-import java.time.Instant;
-import java.time.LocalDate;
-import java.time.ZoneId;
-import java.time.ZonedDateTime;
-import java.util.List;
-import org.apache.zest.api.association.Association;
-import org.apache.zest.api.association.ManyAssociation;
-import org.apache.zest.api.common.Optional;
-import org.apache.zest.api.entity.EntityBuilder;
-import org.apache.zest.api.entity.EntityComposite;
-import org.apache.zest.api.injection.scope.This;
-import org.apache.zest.api.mixin.Mixins;
-import org.apache.zest.api.property.Property;
-import org.apache.zest.api.unitofwork.UnitOfWork;
-import org.apache.zest.api.value.ValueComposite;
-
-import static java.time.ZoneOffset.UTC;
-
-/**
- * Test Model.
- */
-final class TestModel
-{
- static PersonEntity createPerson( UnitOfWork uow, String firstName, String lastName, LocalDate birthDate )
- {
- EntityBuilder<PersonEntity> builder = uow.newEntityBuilder( PersonEntity.class, "id:" + firstName );
- PersonState state = builder.instanceFor( PersonState.class );
- state.firstName().set( firstName );
- state.lastName().set( lastName );
- state.dateOfBirth().set( birthDate );
- return builder.newInstance();
- }
-
- static LocalDate createBirthDate( int year, int month, int day )
- {
- return LocalDate.of( year, month, day);
- }
-
- // START SNIPPET: state
- public interface PersonState
- {
-
- Property<String> firstName();
-
- Property<String> lastName();
-
- Property<LocalDate> dateOfBirth();
-
- }
- // END SNIPPET: state
-
- // START SNIPPET: value
- public interface PersonValue
- extends PersonState, ValueComposite
- {
-
- @Optional
- Property<String> spouse();
-
- @Optional
- Property<List<String>> children();
-
- }
- // END SNIPPET: value
-
- // START SNIPPET: entity
- @Mixins( PersonMixin.class )
- public interface PersonEntity
- extends EntityComposite
- {
-
- String firstName();
-
- String lastName();
-
- Integer age();
-
- @Optional
- Association<PersonEntity> spouse();
-
- ManyAssociation<PersonEntity> children();
-
- }
- // END SNIPPET: entity
-
- // START SNIPPET: entity
- public static abstract class PersonMixin
- implements PersonEntity
- {
-
- @This
- private PersonState state;
- // END SNIPPET: entity
-
- @Override
- public String firstName()
- {
- return state.firstName().get();
- }
-
- @Override
- public String lastName()
- {
- return state.lastName().get();
- }
-
- @Override
- public Integer age()
- {
- Duration age = Duration.between( state.dateOfBirth().get(), Instant.now() );
- return (int) age.toDays()/365;
- }
-
- // START SNIPPET: entity
- }
- // END SNIPPET: entity
-
- // START SNIPPET: unqualified
- @Unqualified
- public interface PersonValue2
- extends ValueComposite
- {
-
- Property<String> firstName();
-
- Property<String> lastName();
-
- Property<LocalDate> dateOfBirth();
-
- @Optional
- Property<String> spouse();
-
- @Optional
- Property<List<String>> children();
-
- }
- // END SNIPPET: unqualified
-
- @Unqualified( true )
- public interface PersonValue3
- extends ValueComposite
- {
-
- Property<String> firstName();
-
- Property<String> lastName();
-
- Property<LocalDate> dateOfBirth();
-
- @Optional
- Property<String> spouse();
-
- @Optional
- Property<List<String>> children();
-
- }
-
- @Unqualified( false )
- public interface PersonValue4
- extends ValueComposite
- {
-
- Property<String> firstName();
-
- Property<String> lastName();
-
- Property<LocalDate> dateOfBirth();
-
- @Optional
- Property<String> spouse();
-
- @Optional
- Property<List<String>> children();
-
- }
-
- private TestModel()
- {
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/5229303a/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/ValueToEntityTest.java
----------------------------------------------------------------------
diff --git a/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/ValueToEntityTest.java b/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/ValueToEntityTest.java
deleted file mode 100644
index c0f8eea..0000000
--- a/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/ValueToEntityTest.java
+++ /dev/null
@@ -1,355 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- */
-package org.apache.zest.library.conversion.values;
-
-import java.time.LocalDate;
-import java.util.Arrays;
-import java.util.function.Predicate;
-import org.junit.Before;
-import org.junit.Test;
-import org.apache.zest.api.constraint.ConstraintViolationException;
-import org.apache.zest.api.unitofwork.UnitOfWork;
-import org.apache.zest.api.unitofwork.UnitOfWorkCompletionException;
-import org.apache.zest.api.value.ValueBuilder;
-import org.apache.zest.bootstrap.AssemblyException;
-import org.apache.zest.bootstrap.ModuleAssembly;
-import org.apache.zest.functional.Iterables;
-import org.apache.zest.library.conversion.values.TestModel.PersonEntity;
-import org.apache.zest.library.conversion.values.TestModel.PersonValue;
-import org.apache.zest.library.conversion.values.TestModel.PersonValue2;
-import org.apache.zest.library.conversion.values.TestModel.PersonValue3;
-import org.apache.zest.library.conversion.values.TestModel.PersonValue4;
-import org.apache.zest.test.AbstractZestTest;
-import org.apache.zest.test.EntityTestAssembler;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.hamcrest.CoreMatchers.nullValue;
-import static org.hamcrest.core.IsEqual.equalTo;
-import static org.junit.Assert.assertThat;
-import static org.apache.zest.api.usecase.UsecaseBuilder.newUsecase;
-import static org.apache.zest.library.conversion.values.TestModel.createBirthDate;
-import static org.apache.zest.library.conversion.values.TestModel.createPerson;
-
-/**
- * ValueToEntity Service Test.
- */
-public class ValueToEntityTest
- extends AbstractZestTest
-{
- @Override
- public void assemble( ModuleAssembly module )
- throws AssemblyException
- {
- // START SNIPPET: assembly
- new ValueToEntityAssembler().assemble( module );
- // END SNIPPET: assembly
- new EntityTestAssembler().assemble( module );
- module.entities( PersonEntity.class );
- module.values( PersonValue.class );
- module.values( PersonValue2.class );
- module.values( PersonValue3.class );
- module.values( PersonValue4.class );
- }
-
- private LocalDate someBirthDate;
- private String ednaIdentity;
- private String zekeIdentity;
- private String fredIdentity;
-
- @Before
- public void setupInitialData()
- throws UnitOfWorkCompletionException
- {
- // See http://en.wikipedia.org/wiki/Template:Flintstones_family_tree
- someBirthDate = createBirthDate( 1, 1, 1 );
- try( UnitOfWork uow = unitOfWorkFactory.newUnitOfWork( newUsecase( "InitialData" ) ) )
- {
- ednaIdentity = createPerson( uow, "Edna", "Flintstone", someBirthDate ).identity().get();
- zekeIdentity = createPerson( uow, "Zeke", "Flintstone", someBirthDate ).identity().get();
- fredIdentity = createPerson( uow, "Fred", "Flintstone", someBirthDate ).identity().get();
- uow.complete();
- }
- }
-
- @Test
- public void givenQualifiedValueWhenCreatingEntityExpectCorrectEntity()
- throws UnitOfWorkCompletionException
- {
- ValueBuilder<PersonValue> builder = valueBuilderFactory.newValueBuilder( PersonValue.class );
- builder.prototype().firstName().set( "Ed" );
- builder.prototype().lastName().set( "Flintstone" );
- builder.prototype().dateOfBirth().set( someBirthDate );
- builder.prototype().spouse().set( ednaIdentity );
- builder.prototype().children().set( Arrays.asList( zekeIdentity, fredIdentity ) );
- PersonValue edValue = builder.newInstance();
- try( UnitOfWork uow = unitOfWorkFactory.newUnitOfWork( newUsecase( "CreatingEntityFromQualifiedValue" ) ) )
- {
- // START SNIPPET: creation
- ValueToEntity conversion = serviceFinder.findService( ValueToEntity.class ).get();
- PersonEntity edEntity = conversion.create( PersonEntity.class, edValue );
- // END SNIPPET: creation
- assertThat( edEntity.firstName(), equalTo( "Ed" ) );
- assertThat( edEntity.lastName(), equalTo( "Flintstone" ) );
- assertThat( edEntity.spouse().get().firstName(), equalTo( "Edna" ) );
- assertThat( Iterables.count( Iterables.filter( new Predicate<PersonEntity>()
- {
- @Override
- public boolean test( PersonEntity child )
- {
- return "Zeke".equals( child.firstName() ) || "Fred".equals( child.firstName() );
- }
- }, edEntity.children() ) ), is( 2L ) );
-
- uow.complete();
- }
- }
-
- @Test
- public void givenUnqualifiedValueWhenCreatingEntityExpectCorrectEntity()
- throws UnitOfWorkCompletionException
- {
- ValueBuilder<PersonValue2> builder = valueBuilderFactory.newValueBuilder( PersonValue2.class );
- builder.prototype().firstName().set( "Ed" );
- builder.prototype().lastName().set( "Flintstone" );
- builder.prototype().dateOfBirth().set( someBirthDate );
- builder.prototype().spouse().set( ednaIdentity );
- builder.prototype().children().set( Arrays.asList( zekeIdentity, fredIdentity ) );
- PersonValue2 edValue = builder.newInstance();
- try( UnitOfWork uow = unitOfWorkFactory.newUnitOfWork( newUsecase( "CreatingEntityFromUnqualifiedValue" ) ) )
- {
- ValueToEntity conversion = serviceFinder.findService( ValueToEntity.class ).get();
-
- PersonEntity edEntity = conversion.create( PersonEntity.class, "id:Ed", edValue );
-
- assertThat( edEntity.identity().get(), equalTo( "id:Ed" ) );
- assertThat( edEntity.firstName(), equalTo( "Ed" ) );
- assertThat( edEntity.lastName(), equalTo( "Flintstone" ) );
- assertThat( edEntity.spouse().get().firstName(), equalTo( "Edna" ) );
- assertThat( Iterables.count( Iterables.filter( new Predicate<PersonEntity>()
- {
- @Override
- public boolean test( PersonEntity child )
- {
- return "Zeke".equals( child.firstName() ) || "Fred".equals( child.firstName() );
- }
- }, edEntity.children() ) ), is( 2L ) );
-
- uow.complete();
- }
- }
-
- @Test
- public void givenUnqualifiedValue2WhenCreatingEntityExpectCorrectEntity()
- throws UnitOfWorkCompletionException
- {
- ValueBuilder<PersonValue3> builder = valueBuilderFactory.newValueBuilder( PersonValue3.class );
- builder.prototype().firstName().set( "Ed" );
- builder.prototype().lastName().set( "Flintstone" );
- builder.prototype().dateOfBirth().set( someBirthDate );
- builder.prototype().spouse().set( ednaIdentity );
- builder.prototype().children().set( Arrays.asList( zekeIdentity, fredIdentity ) );
- PersonValue3 edValue = builder.newInstance();
- try( UnitOfWork uow = unitOfWorkFactory.newUnitOfWork( newUsecase( "CreatingEntityFromUnqualifiedValue" ) ) )
- {
- ValueToEntity conversion = serviceFinder.findService( ValueToEntity.class ).get();
-
- PersonEntity edEntity = conversion.create( PersonEntity.class, "id:Ed", edValue );
-
- assertThat( edEntity.identity().get(), equalTo( "id:Ed" ) );
- assertThat( edEntity.firstName(), equalTo( "Ed" ) );
- assertThat( edEntity.lastName(), equalTo( "Flintstone" ) );
- assertThat( edEntity.spouse().get().firstName(), equalTo( "Edna" ) );
- assertThat( Iterables.count( Iterables.filter( new Predicate<PersonEntity>()
- {
- @Override
- public boolean test( PersonEntity child )
- {
- return "Zeke".equals( child.firstName() ) || "Fred".equals( child.firstName() );
- }
- }, edEntity.children() ) ), is( 2L ) );
-
- uow.complete();
- }
- }
-
- @Test( expected = ConstraintViolationException.class )
- public void givenQualifiedValueNotFromSameInterfaceWhenCreatingEntityExpectNonOptionalException()
- throws UnitOfWorkCompletionException
- {
- ValueBuilder<PersonValue4> builder = valueBuilderFactory.newValueBuilder( PersonValue4.class );
- builder.prototype().firstName().set( "Ed" );
- builder.prototype().lastName().set( "Flintstone" );
- builder.prototype().dateOfBirth().set( someBirthDate );
- builder.prototype().spouse().set( ednaIdentity );
- builder.prototype().children().set( Arrays.asList( zekeIdentity, fredIdentity ) );
- PersonValue4 edValue = builder.newInstance();
- try( UnitOfWork uow = unitOfWorkFactory.newUnitOfWork( newUsecase( "CreatingEntityFromUnqualifiedValue" ) ) )
- {
- ValueToEntity conversion = serviceFinder.findService( ValueToEntity.class ).get();
-
- PersonEntity edEntity = conversion.create( PersonEntity.class, "id:Ed", edValue );
-
- uow.complete();
- }
-
- }
-
- @Test
- public void givenQualifiedValueWhenUpdatingEntityExpectCorrectEntity()
- throws UnitOfWorkCompletionException
- {
- String rickyIdentity;
- try( UnitOfWork uow = unitOfWorkFactory.newUnitOfWork( newUsecase( "CreateRickySlaghoopleWithTypo" ) ) )
- {
- PersonEntity ricky = createPerson( uow, "Ricky", "Slaghople", someBirthDate );
- ricky.spouse().set( uow.get( PersonEntity.class, ednaIdentity ) );
- ricky.children().add( uow.get( PersonEntity.class, zekeIdentity ) );
- rickyIdentity = ricky.identity().get();
- assertThat( ricky.spouse().get(), notNullValue() );
- assertThat( ricky.children().count(), is( 1 ) );
- uow.complete();
- }
- ValueBuilder<PersonValue> builder = valueBuilderFactory.newValueBuilder( PersonValue.class );
- builder.prototype().firstName().set( "Ricky" );
- builder.prototype().lastName().set( "Slaghoople" );
- builder.prototype().dateOfBirth().set( someBirthDate );
- PersonValue rickyNewStateValue = builder.newInstance();
- try( UnitOfWork uow = unitOfWorkFactory.newUnitOfWork( newUsecase( "UpdateRickySlaghoople" ) ) )
- {
- PersonEntity rickyEntity = uow.get( PersonEntity.class, rickyIdentity );
- // START SNIPPET: update
- ValueToEntity conversion = serviceFinder.findService( ValueToEntity.class ).get();
- conversion.update( rickyEntity, rickyNewStateValue );
- // END SNIPPET: update
-
- assertThat( rickyEntity.lastName(), equalTo( "Slaghoople" ) );
- assertThat( rickyEntity.spouse().get(), nullValue() );
- assertThat( rickyEntity.children().count(), is( 0 ) );
-
- uow.complete();
- }
- }
-
- @Test
- public void givenUnqualifiedValueWhenUpdatingEntityExpectCorrectEntity()
- throws UnitOfWorkCompletionException
- {
- String rickyIdentity;
- try( UnitOfWork uow = unitOfWorkFactory.newUnitOfWork( newUsecase( "CreateRickySlaghoopleWithTypo" ) ) )
- {
- PersonEntity ricky = createPerson( uow, "Ricky", "Slaghople", someBirthDate );
- ricky.spouse().set( uow.get( PersonEntity.class, ednaIdentity ) );
- ricky.children().add( uow.get( PersonEntity.class, zekeIdentity ) );
- rickyIdentity = ricky.identity().get();
- assertThat( ricky.spouse().get(), notNullValue() );
- assertThat( ricky.children().count(), is( 1 ) );
- uow.complete();
- }
- ValueBuilder<PersonValue2> builder = valueBuilderFactory.newValueBuilder( PersonValue2.class );
- builder.prototype().firstName().set( "Ricky" );
- builder.prototype().lastName().set( "Slaghoople" );
- builder.prototype().dateOfBirth().set( someBirthDate );
- PersonValue2 newStateValue = builder.newInstance();
- try( UnitOfWork uow = unitOfWorkFactory.newUnitOfWork( newUsecase( "UpdateRickySlaghoople" ) ) )
- {
- PersonEntity ricky = uow.get( PersonEntity.class, rickyIdentity );
-
- ValueToEntity conversion = serviceFinder.findService( ValueToEntity.class ).get();
- conversion.update( ricky, newStateValue );
-
- assertThat( ricky.lastName(), equalTo( "Slaghoople" ) );
- assertThat( ricky.spouse().get(), nullValue() );
- assertThat( ricky.children().count(), is( 0 ) );
-
- uow.complete();
- }
- }
-
- @Test
- public void givenUnqualifiedValue2WhenUpdatingEntityExpectCorrectEntity()
- throws UnitOfWorkCompletionException
- {
- String rickyIdentity;
- try( UnitOfWork uow = unitOfWorkFactory.newUnitOfWork( newUsecase( "CreateRickySlaghoopleWithTypo" ) ) )
- {
- PersonEntity ricky = createPerson( uow, "Ricky", "Slaghople", someBirthDate );
- ricky.spouse().set( uow.get( PersonEntity.class, ednaIdentity ) );
- ricky.children().add( uow.get( PersonEntity.class, zekeIdentity ) );
- rickyIdentity = ricky.identity().get();
- assertThat( ricky.spouse().get(), notNullValue() );
- assertThat( ricky.children().count(), is( 1 ) );
- uow.complete();
- }
- ValueBuilder<PersonValue3> builder = valueBuilderFactory.newValueBuilder( PersonValue3.class );
- builder.prototype().firstName().set( "Ricky" );
- builder.prototype().lastName().set( "Slaghoople" );
- builder.prototype().dateOfBirth().set( someBirthDate );
- PersonValue3 newStateValue = builder.newInstance();
- try( UnitOfWork uow = unitOfWorkFactory.newUnitOfWork( newUsecase( "UpdateRickySlaghoople" ) ) )
- {
- PersonEntity ricky = uow.get( PersonEntity.class, rickyIdentity );
-
- ValueToEntity conversion = serviceFinder.findService( ValueToEntity.class ).get();
- conversion.update( ricky, newStateValue );
-
- assertThat( ricky.lastName(), equalTo( "Slaghoople" ) );
- assertThat( ricky.spouse().get(), nullValue() );
- assertThat( ricky.children().count(), is( 0 ) );
-
- uow.complete();
- }
- }
-
- @Test
- public void givenQualifiedValueNotFromSameInterfaceWhenUpdatingEntityExpectPropsNotUpdated()
- throws UnitOfWorkCompletionException
- {
- String rickyIdentity;
- try( UnitOfWork uow = unitOfWorkFactory.newUnitOfWork( newUsecase( "CreateRickySlaghoopleWithTypo" ) ) )
- {
- PersonEntity ricky = createPerson( uow, "Ricky", "Slaghople", someBirthDate );
- ricky.spouse().set( uow.get( PersonEntity.class, ednaIdentity ) );
- ricky.children().add( uow.get( PersonEntity.class, zekeIdentity ) );
- rickyIdentity = ricky.identity().get();
- assertThat( ricky.spouse().get(), notNullValue() );
- assertThat( ricky.children().count(), is( 1 ) );
- uow.complete();
- }
- ValueBuilder<PersonValue4> builder = valueBuilderFactory.newValueBuilder( PersonValue4.class );
- builder.prototype().firstName().set( "Ricky" );
- builder.prototype().lastName().set( "Slaghoople" );
- builder.prototype().dateOfBirth().set( someBirthDate );
- PersonValue4 newStateValue = builder.newInstance();
- try( UnitOfWork uow = unitOfWorkFactory.newUnitOfWork( newUsecase( "UpdateRickySlaghoopleWontWork" ) ) )
- {
- PersonEntity ricky = uow.get( PersonEntity.class, rickyIdentity );
-
- ValueToEntity conversion = serviceFinder.findService( ValueToEntity.class ).get();
- conversion.update( ricky, newStateValue );
-
- assertThat( ricky.lastName(), equalTo( "Slaghople" ) );
- assertThat( ricky.spouse().get(), nullValue() );
- assertThat( ricky.children().count(), is( 0 ) );
-
- uow.complete();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-java/blob/5229303a/settings.gradle
----------------------------------------------------------------------
diff --git a/settings.gradle b/settings.gradle
index 16a0615..058f616 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -28,7 +28,6 @@ include 'core:functional',
'libraries:alarm',
'libraries:circuitbreaker',
'libraries:constraints',
- 'libraries:conversion',
'libraries:eventsourcing',
'libraries:eventsourcing-jdbm',
'libraries:eventsourcing-rest',