Package org.qi4j.sample.dcicargo.sample_b.data.structure.cargo

Examples of org.qi4j.sample.dcicargo.sample_b.data.structure.cargo.RouteSpecification


                CargoDTO cargo = item.getModelObject();
                String trackingId = cargo.trackingId().get().id().get();
                String origin = cargo.origin().get().getCode();

                // Route specification
                RouteSpecification routeSpec = cargo.routeSpecification().get();
                String destination = routeSpec.destination().get().getCode();
                Date deadline = routeSpec.arrivalDeadline().get();

                // Routing status
                Delivery delivery = cargo.delivery().get();
                RoutingStatus routingStatus = cargo.delivery().get().routingStatus().get();
                boolean isMisrouted = routingStatus == RoutingStatus.MISROUTED;
View Full Code Here


        add( new FeedbackPanel( "feedback" ) );

        try
        {
            // Temporary routeSpec to get correct route candidates
            RouteSpecification tempRouteSpec = new DeriveUpdatedRouteSpecification( trackingIdString ).getRouteSpec();

            add( new ListView<IModel<Itinerary>>( "routes", query( BookingQueries.class ).routeCandidates( tempRouteSpec ) )
            {
                @Override
                protected void populateItem( ListItem<IModel<Itinerary>> item )
View Full Code Here

        IModel<CargoDTO> cargoModel = new CommonQueries().cargo( trackingId );
        CargoDTO cargo = cargoModel.getObject();
        Delivery delivery = cargo.delivery().get();
        TransportStatus transportStatus = delivery.transportStatus().get();
        RouteSpecification routeSpecification = cargo.routeSpecification().get();
        final RoutingStatus routingStatus = delivery.routingStatus().get();
        boolean isMisrouted = routingStatus == MISROUTED;
        boolean isReRouted = !cargo.origin().get().getCode().equals( routeSpecification.origin().get().getCode() );

        add( new PrevNext( "prevNext", CargoDetailsPage.class, trackingId ) );

        add( new Label( "trackingId", trackingId ) );

        // Show both cargo origin and new route spec origin when re-routed during transport
        if( isReRouted )
        {
            Fragment originFragment = new Fragment( "origin", "re-routed-originFragment", this );
            originFragment.add( new Label( "cargoOrigin", cargo.origin().get().getString() ) );
            originFragment.add( new Label( "routeOrigin", routeSpecification.origin()
                .get()
                .getString() ).add( new CorrectColor( isMisrouted ) ) );
            add( originFragment );
        }
        else
        {
            Fragment originFragment = new Fragment( "origin", "originFragment", this );
            originFragment.add( new Label( "cargoOrigin", cargo.origin().get().getString() ) );
            add( originFragment );
        }

        add( new Label( "departure", Model.of( routeSpecification.earliestDeparture().get() ) ) );
        add( new Label( "destination", routeSpecification.destination()
            .get()
            .getString() ).add( new CorrectColor( isMisrouted ) ) );
        add( new Label( "deadline", Model.of( routeSpecification.arrivalDeadline().get() ) ) );
        add( new Label( "routingStatus", routingStatus.toString() ).add( new ErrorColor( isMisrouted ) ) );
        add( new LinkPanel( "changeDestination", ChangeDestinationPage.class, trackingId, "Change destination" ) );

        if( transportStatus.equals( CLAIMED ) )
        {
View Full Code Here

        public List<IModel<Itinerary>> routeCandidates( final String trackingIdString )
            throws FoundNoRoutesException
        {
            Cargo cargo = uowf.currentUnitOfWork().get( Cargo.class, trackingIdString );
            RouteSpecification routeSpec = cargo.routeSpecification().get();

            return routeCandidates( routeSpec );
        }
View Full Code Here

                QueryBuilder<Cargo> qb = module.newQueryBuilder( Cargo.class );
                for( Cargo cargo : uow.newQuery( qb ) )

                {
                    final String trackingId = cargo.trackingId().get().id().get();
                    final RouteSpecification routeSpec = cargo.routeSpecification().get();
                    routeSpec.print();

                    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();
View Full Code Here

        super.prepareTest();
        UnitOfWork uow = module.currentUnitOfWork();
        CARGOS = uow.get( CargoAggregateRoot.class, CargoAggregateRoot.CARGOS_ID );
        HANDLING_EVENTS = uow.get( HandlingEventAggregateRoot.class, HandlingEventAggregateRoot.HANDLING_EVENTS_ID );
        // Create new cargo
        RouteSpecification routeSpec = routeSpecFactory.build( HONGKONG, STOCKHOLM, TODAY, deadline = DAY24 );
        Delivery delivery = delivery( TODAY, IN_PORT, ROUTED, leg1 );
        cargo = CARGOS.createCargo( routeSpec, delivery, "Loaded_CARGO" );
        trackingId = cargo.trackingId().get();
//        delivery = cargo.delivery().get();
    }
View Full Code Here

            public TrackingId createCargo( String trackingIdString )
                throws Exception
            {
                Date earliestDeparture = new Date();
                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().transportStatus().set( TransportStatus.NOT_RECEIVED );
                delivery.prototype().routingStatus().set( RoutingStatus.NOT_ROUTED );

                // Expect receipt in origin (time unknown / no voyage yet)
                ValueBuilder<NextHandlingEvent> nextEvent = vbf.newValueBuilder( NextHandlingEvent.class );
                nextEvent.prototype().handlingEventType().set( RECEIVE );
                nextEvent.prototype().location().set( routeSpec.origin().get() );
                delivery.prototype().nextHandlingEvent().set( nextEvent.newInstance() );

                Cargo cargo = cargoFactory.createCargo( routeSpec, delivery.newInstance(), trackingIdString );

                return cargo.trackingId().get();
View Full Code Here

TOP

Related Classes of org.qi4j.sample.dcicargo.sample_b.data.structure.cargo.RouteSpecification

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.