public StatusFragment( IModel<CargoDTO> cargoModel, Boolean visible )
{
super( "status", "statusFragment", TrackingForm.this );
setVisible( visible );
CargoDTO cargo = cargoModel.getObject();
// Status ----------------------------------------------------------------------
ValueMap map = new ValueMap();
map.put( "status", cargo.delivery().get().transportStatus().get().name() );
map.put( "trackingId", trackingId );
HandlingEvent lastEvent = cargo.delivery().get().lastHandlingEvent().get();
if( lastEvent != null )
{
String voyageString = lastEvent.voyage().get() != null ?
lastEvent.voyage()
.get()
.voyageNumber()
.get()
.number()
.get() : "UNKNOWN_VOYAGE";
map.put( "voyage", voyageString );
map.put( "location", lastEvent.location().get().getString() );
}
else
{
map.put( "voyage", "UNKNOWN_VOYAGE" );
map.put( "location", cargo.origin().get().getString() );
}
add( new Label( "transportStatus", new StringResourceModel(
"transportStatus.${status}", this, new Model<ValueMap>( 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 );
add( new Label( "eta", new StringResourceModel(
"eta", this, null, Model.of( destination ), Model.of( etaString ) ) ) );
// Warning/Notifier ----------------------------------------------------------------------
add( new WebMarkupContainer( "isMisdirected" ).setVisible( cargo.delivery()
.get()
.isMisdirected()
.get() ) );
add( new WebMarkupContainer( "isClaimed" ).setVisible(
!cargo.delivery().get().isMisdirected().get()
&& cargo.delivery().get().isUnloadedAtDestination().get()
&& lastEvent != null
&& lastEvent.handlingEventType().get() == HandlingEventType.CLAIM
) );
// Handling history ----------------------------------------------------------------------
if( cargo.delivery().get().lastHandlingEvent().get() == null )
{
add( new Label( "handlingHistoryPanel" ) );
}
else
{