/** * @method deleteVehicle - used to delete the vehicleId * @param vehicleId * @return response/deleteVehicle */ @DELETE @Transactional @Path("{vehicleId}") @Produces(MediaType.APPLICATION_JSON) public Response deleteVehicle(@PathParam("vehicleId") int vehicleId) { Vehicle vehicle = (Vehicle) vehicleDAO.getOneVehicle(vehicleId); Vehicle deletedVehicle = vehicleDAO.deleteVehicle(vehicle); return Response.status(200).entity(deletedVehicle).build(); }
/** * @method getOneVehicle -used to get the vehicleid and create the vehicle object. * @param vehicleId * @return Responsible/vehicle */ @GET @Transactional @Path("{vehicleId}") @Produces(MediaType.APPLICATION_JSON) public Response getOneVehicle(@PathParam("vehicleId") int vehicleId) { logger.info("@@@ getOneVehicle Method..."); Vehicle vehicle = (Vehicle) vehicleDAO.getOneVehicle(vehicleId); return Response.status(200).entity(vehicle).build(); }
/** * @method getVehicleList -is used to get the VehicleList and return the response * @return response/vehiclesList */ @GET @Transactional @Produces(MediaType.APPLICATION_JSON) public Response getVehiclesList() { logger.info("@@@ In getVehiclesList Method in AddVehilce.java"); ArrayList<Vehicle> vehiclesList = (ArrayList<Vehicle>) vehicleDAO.getAllVehicles(); return Response.status(200).entity(vehiclesList).build(); }
/** * @method UpdateUser -used to update the user details and create the vehicle object * @param vehicle_master_id * @param vehicle_registration_number * @param userId * @param is_active * @param created_by * @param updated_by * @param created_on * @param updated_on * @return response/updatedVehicle */ @PUT @Transactional @Path("/updateVehicle") @Produces(MediaType.APPLICATION_JSON) public Response UpdateUser( @FormParam("vehicle_master_id") int vehicle_master_id, @FormParam("vehicle_registration_number") String vehicle_registration_number, @FormParam("user") int userId, @FormParam("is_active") String is_active, @FormParam("created_by") int created_by, @FormParam("updated_by") int updated_by) { Vehicle vehicle = (Vehicle) vehicleDAO.getOneVehicle(vehicle_master_id); if (vehicle_registration_number != null) { vehicle.setVehicle_registration_number(vehicle_registration_number); } if (is_active != null) { vehicle.setIs_active(is_active.charAt(0)); } vehicle.setCreated_by(created_by); vehicle.setUpdated_by(updated_by); vehicle.setUser(userDAO.getOneUser(userId)); Calendar currentDate = Calendar.getInstance(); currentDate.setTimeZone(TimeZone.getTimeZone("IST")); SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy hh:mm:ss"); // 2015-10-14 00:00:00 Date currentDateTime = null; try { currentDateTime = (Date) formatter.parse(formatter.format(currentDate.getTime())); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } if (currentDateTime != null) { vehicle.setCreated_on(currentDateTime); } if (currentDateTime != null) { // Date updated_Date = dbDateFormat.parse(updated_on); vehicle.setUpdated_on(currentDateTime); } Vehicle updatedVehicle = vehicleDAO.updateVehicle(vehicle); return Response.status(200).entity(updatedVehicle).build(); }