Example #1
0
 private void populateSelectedVehicle(HttpServletRequest request, Vehicle veh) {
   SelectedVehicle selVeh = (SelectedVehicle) request.getAttribute(DLRConstants.SELECTED_VEHICLE);
   if (selVeh == null) {
     selVeh = new SelectedVehicle();
   }
   selVeh.setDisplaySelectedVehicleInfo(true);
   selVeh.setVin(veh.getVin());
   request.setAttribute(DLRConstants.SELECTED_VEHICLE, selVeh);
 }
  @Override
  protected Object formBackingObject(HttpServletRequest request) throws Exception {
    Vehicle vehicle = null;
    // Get the vehicle ID from the Request.
    String vehicleId = (String) request.getParameter(VTRConstants.VEHICLEID);
    Long vehId = Long.parseLong(vehicleId);

    // activating the Customer Tab
    request.setAttribute("customerActiveBoolean", true);
    String transactionId = request.getParameter(VTRConstants.TRANSACTION_ID);

    TransactionDetail transDetail =
        vehicleTitlingBusiness.findAndKeepTransactionDetailById(Long.parseLong(transactionId));
    Long titleId =
        vehicleTitlingBusiness.findAndKeepTitleIdByTransactionId(Long.valueOf(transactionId));
    if (request.getParameter(VTRConstants.VEHICLEID) != null) {
      vehicle =
          vehicleTitlingBusiness.findAndKeepVehicleRegistrationDetailsByVehicleId(vehId, titleId);
      vehicle.getTitleList().addAll(vehicle.getTitles());
      // Setting the header attributes in the request
      request.setAttribute(VTRConstants.YEAR, vehicle.getYear());
      request.setAttribute(VTRConstants.MAKE, vehicle.getMake());
      request.setAttribute(VTRConstants.MODEL, vehicle.getModel());
      request.setAttribute(VTRConstants.VIN, vehicle.getVin());
      if (vehicle == null) {
        vehicle = new Vehicle();
      }
    } else {
      vehicle = new Vehicle();
    }

    request.setAttribute(
        VTRConstants.ADD_VEHICLE_CONTINUE_TO_TITLE, transDetail.getContinueToTitle());
    request.setAttribute(
        VTRConstants.ADD_VEHICLE_CONTINUE_TO_REG, transDetail.getContinueToRegFromTitling());

    return vehicle;
  }