@Override
 public void handleJobInsertion(Job job, InsertionData iData, VehicleRoute route) {
   if (job instanceof Service) {
     route.setVehicleAndDepartureTime(
         iData.getSelectedVehicle(), iData.getVehicleDepartureTime());
     if (!iData.getSelectedVehicle().isReturnToDepot()) {
       if (iData.getDeliveryInsertionIndex()
           >= route.getTourActivities().getActivities().size()) {
         setEndLocation(route, (Service) job);
       }
     }
     TourActivity activity = vehicleRoutingProblem.copyAndGetActivities(job).get(0);
     route.getTourActivities().addActivity(iData.getDeliveryInsertionIndex(), activity);
   } else delegator.handleJobInsertion(job, iData, route);
 }
  public void insertJob(Job job, InsertionData insertionData, VehicleRoute vehicleRoute) {
    insertionListeners.informBeforeJobInsertion(job, insertionData, vehicleRoute);

    if (insertionData == null || (insertionData instanceof NoInsertionFound))
      throw new IllegalStateException("insertionData null. cannot insert job.");
    if (job == null) throw new IllegalStateException("cannot insert null-job");
    if (!(vehicleRoute.getVehicle().getId().equals(insertionData.getSelectedVehicle().getId()))) {
      insertionListeners.informVehicleSwitched(
          vehicleRoute, vehicleRoute.getVehicle(), insertionData.getSelectedVehicle());
      vehicleRoute.setVehicleAndDepartureTime(
          insertionData.getSelectedVehicle(), insertionData.getVehicleDepartureTime());
    }
    jobInsertionHandler.handleJobInsertion(job, insertionData, vehicleRoute);

    insertionListeners.informJobInserted(
        job, vehicleRoute, insertionData.getInsertionCost(), insertionData.getAdditionalTime());
  }
 @Override
 public void handleJobInsertion(Job job, InsertionData iData, VehicleRoute route) {
   if (job instanceof Shipment) {
     List<AbstractActivity> acts = vehicleRoutingProblem.copyAndGetActivities(job);
     TourActivity pickupShipment = acts.get(0);
     TourActivity deliverShipment = acts.get(1);
     route.setVehicleAndDepartureTime(
         iData.getSelectedVehicle(), iData.getVehicleDepartureTime());
     if (!iData.getSelectedVehicle().isReturnToDepot()) {
       if (iData.getDeliveryInsertionIndex() >= route.getActivities().size()) {
         setEndLocation(route, (Shipment) job);
       }
     }
     route.getTourActivities().addActivity(iData.getDeliveryInsertionIndex(), deliverShipment);
     route.getTourActivities().addActivity(iData.getPickupInsertionIndex(), pickupShipment);
   } else delegator.handleJobInsertion(job, iData, route);
 }