Package org.qi4j.sample.dcicargo.sample_a.data.shipping.delivery

Examples of org.qi4j.sample.dcicargo.sample_a.data.shipping.delivery.ExpectedHandlingEvent


                    context.newDeliverySnapshot.eta().set( null );
                    context.newDeliverySnapshot.isMisdirected().set( true );
                }
                else if( cargoIsNotMisrouted )
                {
                    ExpectedHandlingEvent expectedEvent = context.itinerary.expectedEventAfterReceive();
                    context.newDeliverySnapshot.nextExpectedHandlingEvent().set( expectedEvent );
                }
            }
View Full Code Here


                if( cargoIsRerouted )
                {
                    // After a reroute following a load in an unexpected location, we expected the cargo to be
                    // unloaded at the unload location of the first leg of the new itinerary.
                    ExpectedHandlingEvent expectedEvent = context.itinerary
                        .expectedEventAfterLoadAt( lastKnownLocation );
                    context.newDeliverySnapshot.nextExpectedHandlingEvent().set( expectedEvent );
                }
                else if( !context.itinerary.expectsLoad( lastKnownLocation, currentVoyage ) )
                {
                    context.newDeliverySnapshot.eta().set( null );
                    context.newDeliverySnapshot.isMisdirected().set( true );
                }
                else if( cargoIsNotMisrouted )
                {
                    ExpectedHandlingEvent expectedEvent = context.itinerary
                        .expectedEventAfterLoadAt( lastKnownLocation );
                    context.newDeliverySnapshot.nextExpectedHandlingEvent().set( expectedEvent );
                }
            }
View Full Code Here

                if( cargoIsRerouted )
                {
                    // After a reroute following an unload in an unexpected location, we expected the cargo
                    // to be loaded onto a carrier at the first location of the new route specification.
                    ExpectedHandlingEvent expectedEvent = context.itinerary.expectedEventAfterReceive();
                    context.newDeliverySnapshot.nextExpectedHandlingEvent().set( expectedEvent );
                }
                else if( !context.itinerary.expectsUnload( lastKnownLocation, currentVoyage ) )
                {
                    context.newDeliverySnapshot.eta().set( null );
                    context.newDeliverySnapshot.isMisdirected().set( true );
                }
                else if( cargoIsNotMisrouted )
                {
                    ExpectedHandlingEvent expectedEvent = context.itinerary
                        .expectedEventAfterUnloadAt( lastKnownLocation );
                    context.newDeliverySnapshot.nextExpectedHandlingEvent().set( expectedEvent );

                    Location expectedDestination = ( (RouteSpecification) context.factory ).destination().get();
                    context.newDeliverySnapshot
View Full Code Here

                int i = 11; // starting at 11 for sortable tracking id prefix in lists
                QueryBuilder<Cargo> qb = qbf.newQueryBuilder( Cargo.class );
                for( Cargo cargo : uow.newQuery( qb ) )
                {
                    String trackingId = cargo.trackingId().get().id().get();
                    ExpectedHandlingEvent nextEvent;
                    Date time;
                    String port;
                    String voyage;
                    HandlingEventType type;

                    // BOOK cargo with no handling (i == 11)

                    // ROUTE
                    if( i > 11 )
                    {
                        Itinerary itinerary = new BookNewCargo( cargo ).routeCandidates().get( 0 );
                        new BookNewCargo( cargo, itinerary ).assignCargoToRoute();
                    }

                    // RECEIVE
                    if( i > 12 )
                    {
                        nextEvent = cargo.delivery().get().nextExpectedHandlingEvent().get();
                        port = nextEvent.location().get().getCode();
                        Date mockTime = new Date();
                        new RegisterHandlingEvent( mockTime, mockTime, trackingId, "RECEIVE", port, null ).register();
                    }

                    // LOAD
                    if( i > 13 )
                    {
                        nextEvent = cargo.delivery().get().nextExpectedHandlingEvent().get();
                        time = nextEvent.time().get();
                        port = nextEvent.location().get().getCode();
                        voyage = nextEvent.voyage().get().voyageNumber().get().number().get();
                        new RegisterHandlingEvent( time, time, trackingId, "LOAD", port, voyage ).register();
                    }

                    // UNLOAD
                    if( i > 14 )
                    {
                        nextEvent = cargo.delivery().get().nextExpectedHandlingEvent().get();
                        time = nextEvent.time().get();
                        port = nextEvent.location().get().getCode();
                        voyage = nextEvent.voyage().get().voyageNumber().get().number().get();
                        new RegisterHandlingEvent( time, time, trackingId, "UNLOAD", port, voyage ).register();
                    }

                    // Cargo is now in port
                    nextEvent = cargo.delivery().get().nextExpectedHandlingEvent().get();
                    time = nextEvent.time().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();
                    }

                    // MISDIRECTED: Unexpected claim before reaching destination
                    if( i == 17 )
                    {
                        new RegisterHandlingEvent( time, time, trackingId, "CLAIM", port, null ).register();
                    }

                    // MISDIRECTED: LOAD in wrong port
                    if( i == 18 )
                    {
                        String wrongPort = port.equals( "USDAL" ) ? "USCHI" : "USDAL";
                        voyage = nextEvent.voyage().get().voyageNumber().get().number().get();
                        new RegisterHandlingEvent( time, time, trackingId, "LOAD", wrongPort, voyage ).register();
                    }

                    // MISDIRECTED: LOAD onto wrong carrier
                    if( i == 19 )
                    {
                        voyage = nextEvent.voyage().get().voyageNumber().get().number().get();
                        String wrongVoyage = voyage.equals( "V100S" ) ? "V200T" : "V100S";
                        new RegisterHandlingEvent( time, time, trackingId, "LOAD", port, wrongVoyage ).register();
                    }

                    // MISDIRECTED: LOAD onto wrong carrier in wrong port
                    if( i == 20 )
                    {
                        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();
                    }

                    // MISDIRECTED: UNLOAD in wrong port
                    if( i == 21 )
                    {
                        String wrongPort = port.equals( "USDAL" ) ? "USCHI" : "USDAL";
                        voyage = nextEvent.voyage().get().voyageNumber().get().number().get();
                        new RegisterHandlingEvent( time, time, trackingId, "UNLOAD", wrongPort, voyage ).register();
                    }

                    // MISDIRECTED: UNLOAD from wrong carrier
                    if( i == 22 )
                    {
                        voyage = nextEvent.voyage().get().voyageNumber().get().number().get();
                        String wrongVoyage = voyage.equals( "V100S" ) ? "V200T" : "V100S";
                        new RegisterHandlingEvent( time, time, trackingId, "UNLOAD", port, wrongVoyage ).register();
                    }

                    // MISDIRECTED: UNLOAD from wrong carrier in wrong port
                    if( i == 23 )
                    {
                        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();
                    }

                    // Complete all LOAD/UNLOADS
                    if( i > 23 )
                    {
                        do
                        {
                            voyage = nextEvent.voyage().get().voyageNumber().get().number().get();
                            new RegisterHandlingEvent( time, time, trackingId, type.name(), port, voyage ).register();

                            nextEvent = cargo.delivery().get().nextExpectedHandlingEvent().get();
                            time = nextEvent.time().get();
                            port = nextEvent.location().get().getCode();
                            type = nextEvent.handlingEventType().get();
                        }
                        while( type != HandlingEventType.CLAIM );
                    }

                    // CLAIM at destination - this ends the life cycle of the cargo delivery
View Full Code Here

            map.put( "location", destination.getString() );
            label.add( new AttributeModifier( "class", "correctColor" ) );
            return;
        }

        ExpectedHandlingEvent nextEvent = cargo.delivery().get().nextExpectedHandlingEvent().get();
        if( nextEvent == null )
        {
            map.put( "expectedEvent", "UNKNOWN" );
            label.add( new AttributeModifier( "class", "errorColor" ) );
            return;
        }

        map.put( "expectedEvent", nextEvent.handlingEventType().get().name() );
        map.put( "location", nextEvent.location().get().getString() );

        if( nextEvent.time() != null )
        {
            map.put( "time", new SimpleDateFormat( "yyyy-MM-dd" ).format( nextEvent.time().get() ) );
        }

        if( nextEvent.voyage().get() != null )
        {
            map.put( "voyage", nextEvent.voyage().get().voyageNumber().get().number().get() );
        }
    }
View Full Code Here

TOP

Related Classes of org.qi4j.sample.dcicargo.sample_a.data.shipping.delivery.ExpectedHandlingEvent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.