Examples of Voyage


Examples of org.qi4j.sample.dcicargo.sample_a.data.shipping.voyage.Voyage

            id = registeredHandlingEvent.trackingId().get().id().get();
            time = parseDate( registeredHandlingEvent.completionTime().get() );
            type = registeredHandlingEvent.handlingEventType().get().name();
            unloc = registeredHandlingEvent.location().get().getCode();
            loc = registeredHandlingEvent.location().get().name().get();
            Voyage voy = registeredHandlingEvent.voyage().get();
            voyage = voy != null ? ", voyage " + voy.voyageNumber().get().number().get() : "";

            logger.info( "  Cargo '" + id + "' was handled " + time
                         + " (" + type + " in " + loc + "/" + unloc + voyage + ")." );
        }
View Full Code Here

Examples of org.qi4j.sample.dcicargo.sample_a.data.shipping.voyage.Voyage

        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() );
        Location NEWYORK = uow.get( Location.class, USNYC.code().get() );
        DALLAS = uow.get( Location.class, USDAL.code().get() );
        Voyage V100S = uow.get( Voyage.class, "V100S" );
        V200T = uow.get( Voyage.class, "V200T" );
        V300A = uow.get( Voyage.class, "V300A" );

        // Create cargo
        trackingId = new BookNewCargo( CARGOS, HONGKONG, STOCKHOLM, day( 17 ) ).createCargo( "ABC" );
View Full Code Here

Examples of org.qi4j.sample.dcicargo.sample_a.data.shipping.voyage.Voyage

                Location CHICAGO = location( USCHI, "Chicago" );
                Location DALLAS = location( USDAL, "Dallas" );
                Location NEWYORK = location( USNYC, "New York" );

              // Voyage entity objects
                Voyage V100S = voyage( "V100S", schedule(
                  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 ) )
              ) );
                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 ) )
              ) );
                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 ) )
              ) );
                Voyage V500S = voyage( "V500S", schedule(
                  carrierMovement( HAMBURG, STOCKHOLM, day( 17 ), day( 19 ) ),
                  carrierMovement( STOCKHOLM, HELSINKI, day( 20 ), day( 21 ) )
              ) );

              // Cargo and HandlingEvent factories
View Full Code Here

Examples of org.qi4j.sample.dcicargo.sample_b.data.structure.voyage.Voyage

                    NextHandlingEvent nextEvent = null;
                    Date time = null;
                    String port = null;
                    String voyageNumber = null;
                    Voyage voyage;
                    HandlingEventType type = null;
                    String wrongPort = null;
                    String wrongVoyage = null;

                    // First cargo with id 11 is not routed

                    // ROUTE
                    if( i > 11 )
                    {
                        final List<Itinerary> routes = routingService.fetchRoutesForSpecification( routeSpec );
                        final Itinerary itinerary = routes.get( 0 );
                        new AssignCargoToRoute( cargo, itinerary ).assign();
                    }

                    // MISROUTE: Route specification not satisfied with itinerary
                    if( i == 12 )
                    {
                        Location origin = routeSpec.origin().get();
                        Location dest = routeSpec.destination().get();
                        Location badDest = null;
                        Query<Location> locations = uow.newQuery( module.newQueryBuilder( Location.class ) );
                        for( Location loc : locations )
                        {
                            if( !origin.equals( loc ) && !dest.equals( loc ) )
                            {
                                badDest = loc;
                                break;
                            }
                        }

                        final RouteSpecification unsatisfiedRouteSpec =
                            routeSpecFactory.build( origin, badDest, new Date(), new DateTime().plusDays( 25 )
                                .toDate() );
                        cargo.routeSpecification().set( unsatisfiedRouteSpec );

                        new InspectUnhandledCargo( cargo ).inspect();
                    }

                    // RECEIVE
                    if( i > 13 )
                    {
                        nextEvent = cargo.delivery().get().nextHandlingEvent().get();
                        port = nextEvent.location().get().getCode();
                        final Date mockTime = new Date();
                        registerEvent( mockTime, mockTime, trackingId, RECEIVE, port, null );
                    }

                    // MISDIRECT: LOAD onto wrong carrier
                    if( i == 15 )
                    {
                        nextEvent = cargo.delivery().get().nextHandlingEvent().get();
                        time = nextEvent.time().get();
                        port = nextEvent.location().get().getCode();
                        voyageNumber = nextEvent.voyage().get().voyageNumber().get().number().get();

                        // Find earliest wrong carrier movement (voyage) with same departure location
                        final Query<Voyage> voyages = module.currentUnitOfWork()
                            .newQuery( module.newQueryBuilder( Voyage.class ) );
                        int depth = 0;
                        do
                        {
                            for( Voyage voy : voyages )
                            {
                                if( voy.voyageNumber().get().number().get().equals( voyageNumber ) )
                                {
                                    continue;
                                }

                                if( depth >= voy.schedule().get().carrierMovements().get().size() )
                                {
                                    continue;
                                }

                                // Carrier movement at current depth
                                final CarrierMovement movement = voy.schedule()
                                    .get()
                                    .carrierMovements()
                                    .get()
                                    .get( depth );
                                final boolean goingFromSamePort = movement.departureLocation()
                                    .get()
                                    .getCode()
                                    .equals( port );
                                final boolean notGoingToDestination = !movement.arrivalLocation()
                                    .get()
                                    .equals( routeSpec.destination().get() );

                                if( goingFromSamePort && notGoingToDestination )
                                {
                                    wrongVoyage = voy.voyageNumber().get().number().get();
                                    break;
                                }
                            }
                        }
                        while( wrongVoyage == null && depth++ < 10 );

                        registerEvent( time, time, trackingId, LOAD, port, wrongVoyage );
                    }

                    // LOAD
                    if( i > 15 )
                    {
                        nextEvent = cargo.delivery().get().nextHandlingEvent().get();
                        time = nextEvent.time().get();
                        port = nextEvent.location().get().getCode();
                        voyageNumber = nextEvent.voyage().get().voyageNumber().get().number().get();
                        registerEvent( time, time, trackingId, LOAD, port, voyageNumber );

                        // Cargo is now on board carrier
                        nextEvent = cargo.delivery().get().nextHandlingEvent().get();
                        time = nextEvent.time().get();
                        type = nextEvent.handlingEventType().get();
                        port = nextEvent.location().get().getCode();
                        voyageNumber = nextEvent.voyage().get().voyageNumber().get().number().get();
                    }

                    // MISDIRECT: UNLOAD from carrier in wrong location
                    if( i == 17 )
                    {
                        voyage = uow.get( Voyage.class, voyageNumber );
                        for( CarrierMovement movement : voyage.schedule().get().carrierMovements().get() )
                        {
                            final String arrivalPort = movement.arrivalLocation().get().getCode();

                            // Take first voyage with different arrival location
                            if( !arrivalPort.equals( port ) )
View Full Code Here

Examples of org.qi4j.sample.dcicargo.sample_b.data.structure.voyage.Voyage

                throws CannotRegisterHandlingEventException
            {
                UnitOfWork uow = uowf.currentUnitOfWork();
                TrackingId trackingId;
                Location location;
                Voyage voyage = null;

                // Step 1 - Find Cargo from tracking id string
                try
                {
                    trackingId = uow.get( Cargo.class, c.trackingIdString ).trackingId().get();
View Full Code Here

Examples of org.qi4j.sample.dcicargo.sample_b.data.structure.voyage.Voyage

                    nextHandlingEvent.location().set( c.itinerary.firstLeg().loadLocation().get() );
                }
                else if( c.transportStatus.equals( ONBOARD_CARRIER ) )
                {
                    // Re-routed cargo onboard carrier is expected to be unloaded in next port (regardless of new itinerary).
                    Voyage voyage = c.lastHandlingEvent.voyage().get();
                    CarrierMovement carrierMovement = voyage.carrierMovementDepartingFrom( c.lastHandlingEvent
                                                                                               .location()
                                                                                               .get() );

                    // Estimate carrier arrival time
                    Date estimatedArrivalDate = carrierMovement.arrivalTime().get();
View Full Code Here

Examples of org.qi4j.sample.dcicargo.sample_b.data.structure.voyage.Voyage

                    newOrigin = cargo.origin().get();
                    newEarliestDeparture = c.routeSpecification.earliestDeparture().get();
                }
                else if( c.transportStatus.equals( ONBOARD_CARRIER ) )
                {
                    Voyage voyage = c.lastHandlingEvent.voyage().get();
                    Location departureLocation = c.lastHandlingEvent.location().get();
                    CarrierMovement carrierMovement = voyage.carrierMovementDepartingFrom( departureLocation );
                    if( carrierMovement == null )
                    {
                        throw new UnexpectedCarrierException( c.lastHandlingEvent );
                    }
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.