Examples of Leg


Examples of org.qi4j.sample.dcicargo.sample_a.data.shipping.itinerary.Leg

            // Next expected handling event ----------------------------------------------

            public ExpectedHandlingEvent expectedEventAfterReceive()
            {
                // 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() );
            }
View Full Code Here

Examples of org.qi4j.sample.dcicargo.sample_a.data.shipping.itinerary.Leg

            public ExpectedHandlingEvent expectedEventAfterUnloadAt( Location lastUnloadLocation )
            {
                // After UNLOAD, expect LOAD location and voyage of following itinerary leg, or CLAIM if no more legs
                for( Iterator<Leg> it = itinerary.legs().get().iterator(); it.hasNext(); )
                {
                    final Leg leg = it.next();
                    if( leg.unloadLocation().get().equals( lastUnloadLocation ) )
                    {
                        // Cargo has a matching unload location in itinerary

                        if( it.hasNext() )
                        {
                            // 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() );
                        }
                        else
                        {
                            // Cargo has arrived (no more legs in itinerary)
                            // We expect it to be claimed by the customer
View Full Code Here

Examples of org.qi4j.sample.dcicargo.sample_a.data.shipping.itinerary.Leg

            add( new ListView<Leg>( "legs", legListModel )
            {
                @Override
                protected void populateItem( ListItem<Leg> item )
                {
                    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( "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( "unloadTime", new Model<Date>( leg.unloadTime().get() ) ) );
                }
            } );
        }
View Full Code Here

Examples of org.qi4j.sample.dcicargo.sample_a.data.shipping.itinerary.Leg

        add( new ListView<Leg>( "legs", legListModel )
        {
            @Override
            protected void populateItem( ListItem<Leg> item )
            {
                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( "unloadLocation", leg.unloadLocation().get().getCode() ),
                          new Label( "unloadTime", new Model<Date>( leg.unloadTime().get() ) )
                );
            }
        } );

        Form form = new Form<Void>( "form" );
View Full Code Here

Examples of org.qi4j.sample.dcicargo.sample_b.data.structure.itinerary.Leg

            add( new ListView<Leg>( "legs", legListModel )
            {
                @Override
                protected void populateItem( ListItem<Leg> item )
                {
                    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( "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( "unloadTime", new Model<Date>( leg.unloadTime().get() ) ) );
                }
            } );
        }
View Full Code Here

Examples of org.qi4j.sample.dcicargo.sample_b.data.structure.itinerary.Leg

                // Current itinerary progress
                newDelivery.itineraryProgressIndex().set( c.itineraryProgressIndex );

                // Step 3 - Verify cargo is on track

                Leg plannedCarrierMovement = c.itinerary.leg( c.itineraryProgressIndex );
                if( plannedCarrierMovement == null )
                {
                    throw new InspectionFailedException( "Itinerary progress index '" + c.itineraryProgressIndex + "' is invalid!" );
                }

                Integer itineraryProgressIndex;
//                if (c.wasMisdirected && c.unloadLocation.equals( c.routeSpecification.origin().get() ))
                if( c.unloadLocation.equals( c.routeSpecification.origin().get() ) )
//                if (c.itineraryProgressIndex == -1)
                {
                    /**
                     * Unloading in the origin of a route specification of a misdirected cargo
                     * tells us that the cargo has been re-routed (re-routing while on board a
                     * carrier sets new origin of route specification to arrival location of
                     * current carrier movement).
                     *
                     * Since the current unload was related to the old itinerary, we don't verify
                     * the misdirection status against the new itinerary.
                     *
                     * The itinerary index starts over from the first leg of the new itinerary
                     * */
                    itineraryProgressIndex = 0;
                }
                else if( !plannedCarrierMovement.unloadLocation().get().equals( c.unloadLocation ) )
                {
                    newDelivery.isMisdirected().set( true );
                    cargo.delivery().set( newDeliveryBuilder.newInstance() );
                    throw new CargoMisdirectedException( c.unloadEvent, "Itinerary expected unload in "
                                                                        + plannedCarrierMovement.unloadLocation()
                        .get() );
                }
                else if( !plannedCarrierMovement.voyage().get().equals( c.voyage ) )
                {
                    // Do we care if cargo unloads from an unexpected carrier?
                    itineraryProgressIndex = c.itineraryProgressIndex + 1;
                }
                else
                {
                    // Cargo delivery has progressed and we expect a load in next itinerary leg load location
                    itineraryProgressIndex = c.itineraryProgressIndex + 1;
                }

                newDelivery.isMisdirected().set( false );

                // Modify itinerary progress index according to misdirection status
                newDelivery.itineraryProgressIndex().set( itineraryProgressIndex );

                // Step 4 - Determine next expected handling event

                Leg nextCarrierMovement = c.itinerary.leg( itineraryProgressIndex );

                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().voyage().set( nextCarrierMovement.voyage().get() );
                newDelivery.nextHandlingEvent().set( nextHandlingEvent.newInstance() );

                // Step 5 - Save cargo delivery snapshot

                cargo.delivery().set( newDeliveryBuilder.newInstance() );
View Full Code Here

Examples of org.qi4j.sample.dcicargo.sample_b.data.structure.itinerary.Leg

                if( newDelivery.routingStatus().get().equals( ROUTED ) )
                {
                    // Step 3 - Verify cargo is received in origin

                    Leg firstLeg = c.itinerary.firstLeg();
                    if( !firstLeg.loadLocation().get().equals( c.receiveEvent.location().get() ) )
                    {
                        newDelivery.isMisdirected().set( true );
                        cargo.delivery().set( newDeliveryBuilder.newInstance() );
                        throw new CargoMisdirectedException( c.receiveEvent, "Itinerary expected receipt in "
                                                                             + firstLeg.loadLocation()
                            .get()
                            .getString() );
                    }

                    newDelivery.isMisdirected().set( false );
                    newDelivery.eta().set( c.itinerary.eta() );

                    // Step 4 - Determine next expected handling event

                    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().voyage().set( firstLeg.voyage().get() );
                    newDelivery.nextHandlingEvent().set( nextHandlingEvent.newInstance() );
                }

                // Step 5 - Save cargo delivery snapshot
View Full Code Here

Examples of org.qi4j.sample.dcicargo.sample_b.data.structure.itinerary.Leg

                newDelivery.eta().set( c.itinerary.eta() );
                newDelivery.itineraryProgressIndex().set( c.itineraryProgressIndex );

                // Step 4 - Verify cargo is on track

                Leg plannedCarrierMovement = c.itinerary.leg( c.itineraryProgressIndex );

                // Unexpected internal state
                if( plannedCarrierMovement == null )
                {
                    // We should always know the current itinerary leg
                    throw new InspectionFailedException( "Itinerary progress index '" + c.itineraryProgressIndex + "' is invalid!" );
                }

                // Unexpected load location - Cargo can't travel in time!
                // Either previous or current location is wrong - only investigation can clarify...
                if( !plannedCarrierMovement.loadLocation().get().equals( c.loadLocation ) )
                {
                    newDelivery.isMisdirected().set( true );
                    newDelivery.nextHandlingEvent().set( null );
                    cargo.delivery().set( newDeliveryBuilder.newInstance() );
                    throw new CargoMisdirectedException( c.loadEvent, "Itinerary expected load in "
                                                                      + plannedCarrierMovement.loadLocation()
                        .get()
                        .getString() );
                }

                // Unexpected carrier
                if( !plannedCarrierMovement.voyage().get().equals( c.voyage ) )
                {
                    newDelivery.isMisdirected().set( true );
                    cargo.delivery().set( newDeliveryBuilder.newInstance() );

                    // ...Expected arrival location - should we accept this?
                    if( plannedCarrierMovement.unloadLocation()
                        .get()
                        .equals( carrierMovement.arrivalLocation().get() ) )
                    {
                        throw new CargoMisdirectedException( c.loadEvent, c.itinerary, "Cargo is heading to expected arrival location "
                                                                                       + plannedCarrierMovement.unloadLocation()
                            .get() + " but on unexpected voyage "
                                                                                       + c.voyage
                            .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() );
                }

                // Unexpected carrier destination
                if( !plannedCarrierMovement.unloadLocation().get().equals( carrierMovement.arrivalLocation().get() ) )
                {
                    newDelivery.isMisdirected().set( true );
                    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 "
                                                                      + carrierMovement.arrivalLocation().get() );
                }

                // True exception
View Full Code Here

Examples of org.qi4j.sample.dcicargo.sample_b.data.structure.itinerary.Leg

        add( new ListView<Leg>( "legs", legListModel )
        {
            @Override
            protected void populateItem( ListItem<Leg> item )
            {
                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( "unloadLocation", leg.unloadLocation().get().getCode() ),
                          new Label( "unloadTime", new Model<Date>( leg.unloadTime().get() ) )
                );
            }
        } );

        StatelessForm form = new StatelessForm<Void>( "form" );
View Full Code Here

Examples of org.qi4j.sample.dcicargo.sample_b.data.structure.itinerary.Leg

        // Expected load (leg 3)
        handlingEvent = HANDLING_EVENTS.createHandlingEvent( DAY7, DAY7, trackingId, LOAD, NEWYORK, V202 );
        new InspectLoadedCargo( cargo, handlingEvent ).inspect();

        Leg currentCarrierMovement = itinerary.leg( delivery.itineraryProgressIndex().get() );
        assertThat( currentCarrierMovement.unloadLocation().get(), is( equalTo( DALLAS ) ) );
        assertThat( currentCarrierMovement.unloadTime().get(), is( equalTo( DAY8 ) ) );
        assertThat( currentCarrierMovement.voyage().get(), is( equalTo( V202 ) ) );

        assertDelivery( LOAD, NEWYORK, DAY7, V202,
                        ONBOARD_CARRIER, notArrived,
                        ROUTED, directed, itinerary.eta(), leg3,
                        UNLOAD, DALLAS, DAY8, V202 );
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.