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

Examples of org.qi4j.sample.dcicargo.sample_b.data.structure.location.Location


        public List<Itinerary> fetchRoutesForSpecification( RouteSpecification routeSpecification )
            throws FoundNoRoutesException
        {
            final Date departureDate = routeSpecification.earliestDeparture().get();
            final Location origin = routeSpecification.origin().get();
            final Location destination = routeSpecification.destination().get();

            List<TransitPath> transitPaths;
            List<Itinerary> itineraries = new ArrayList<Itinerary>();

            try
            {
                transitPaths = graphTraversalService.findShortestPath( departureDate, origin.getCode(), destination.getCode() );
            }
            catch( RemoteException e )
            {
                logger.error( e.getMessage(), e );
                return Collections.emptyList();
            }

            // The returned result is then translated back into our domain model.
            for( TransitPath transitPath : transitPaths )
            {
                final Itinerary itinerary = toItinerary( transitPath );

                // Use the specification to safe-guard against invalid itineraries
                // We can use the side-effects free method of the RouteSpecification data object
                if( routeSpecification.isSatisfiedBy( itinerary ) )
                {
                    itineraries.add( itinerary );
                }
            }

            if( itineraries.size() == 0 )
            {
                throw new FoundNoRoutesException( destination.name().get(),
                                                  new LocalDate( routeSpecification.arrivalDeadline().get() ) );
            }

            return itineraries;
        }
View Full Code Here


                    String voyageNumber = null;
                    List<CarrierMovement> carrierMovements = new ArrayList<>();
                    for( TransitEdge voyageEdge : voyagePath.getTransitEdges() )
                    {
                        voyageNumber = voyageEdge.getVoyageNumber();
                        Location from = uow.get( Location.class, voyageEdge.getFromUnLocode() );
                        Location to = uow.get( Location.class, voyageEdge.getToUnLocode() );
                        carrierMovements.add( carrierMovement( from, to, voyageEdge.getFromDate(), voyageEdge.getToDate() ) );
                    }

                    ValueBuilder<Schedule> schedule = module.newValueBuilder( Schedule.class );
                    schedule.prototype().carrierMovements().set( carrierMovements );
View Full Code Here

                    }

                    // 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 ) )
                            {
View Full Code Here

            for( Location location : allLocations )
            {
                locationList.add( location );
            }

            Location origin;
            Location destination;
            Random random = new Random();
            Date deadline;
            String uuid;
            String id;
            try
            {
                for( int i = 0; i < numberOfCargos; i++ )
                {
                    origin = locationList.get( random.nextInt( locationSize ) );

                    // Find destination different from origin
                    do
                    {
                        destination = locationList.get( random.nextInt( locationSize ) );
                    }
                    while( destination.equals( origin ) );

                    deadline = new LocalDate().plusDays( 35 + random.nextInt( 10 ) )
                        .toDateTime( new LocalTime() )
                        .toDate();
View Full Code Here

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

                // Step 1 - Find Cargo from tracking id string
                try
                {
View Full Code Here

                    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

        Label label = new Label( "text", new StringResourceModel(
            "nextEvent.${nextEvent}", this, new Model<ValueMap>( map ) ) );
        add( label );

        CargoDTO cargo = cargoModel.getObject();
        Location destination = cargo.routeSpecification().get().destination().get();

        if( cargo.itinerary().get() == null )
        {
            map.put( "nextEvent", "ROUTE" );
            return;
        }

        HandlingEvent previousEvent = cargo.delivery().get().lastHandlingEvent().get();
        if( previousEvent == null )
        {
            map.put( "nextEvent", "RECEIVE" );
            map.put( "location", cargo.routeSpecification().get().origin().get().getString() );
            return;
        }

        Location lastLocation = previousEvent.location().get();
        if( previousEvent.handlingEventType().get() == HandlingEventType.CLAIM && lastLocation == destination )
        {
            map.put( "nextEvent", "END_OF_CYCLE" );
            map.put( "location", destination.getString() );
            label.add( new AttributeModifier( "class", "correctColor" ) );
View Full Code Here

TOP

Related Classes of org.qi4j.sample.dcicargo.sample_b.data.structure.location.Location

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.