Esempio n. 1
0
 /**
  * Order new ticket
  *
  * @param departureDate
  * @param arrivalCity
  * @param departureCity
  * @param personName
  * @param personSurname
  * @return unique ticket number in system
  */
 @GET
 @Path("/orderTicket")
 @Produces(MediaType.TEXT_PLAIN)
 public String orderTicket(
     @QueryParam("departureDate") String departureDate,
     @QueryParam("arrivalCity") String arrivalCity,
     @QueryParam("departureCity") String departureCity,
     @QueryParam("personName") String personName,
     @QueryParam("personSurname") String personSurname) {
   String ret = "";
   try {
     long orderedTicketId = persistanceModel.getLastID(true);
     orderedTicketId++;
     Ticket ticket = new Ticket();
     ticket.setOrderedSign(true);
     Date date = new SimpleDateFormat("MM.DD.YY").parse(departureDate);
     ticket.setDepartureDate(date);
     ticket.setArrivalCity(arrivalCity);
     ticket.setDepartureDate(date);
     ticket.setTicketId(orderedTicketId);
     ticket.setPersonId(persistanceModel.selectPersonIdByName(personName));
     persistanceModel.insertTicket(ticket);
     ret = String.valueOf(orderedTicketId);
   } catch (Exception ex) {
     ret = "";
   } finally {
     return ret;
   }
 }
Esempio n. 2
0
 /**
  * Delete ticket method
  *
  * @param ticketId
  * @return true if ticket deleted successfully
  */
 @POST
 @Path("/delete")
 @Produces(MediaType.TEXT_PLAIN)
 public Response delete(@QueryParam("ticketId") int ticketId) {
   Response response;
   if (persistanceModel.deleteTicket(ticketId)) {
     response = Response.ok().build();
   } else {
     response = Response.status(666).build();
   }
   return response;
 }
Esempio n. 3
0
 /**
  * Payment status
  *
  * @param ticketId
  * @return true if ticket paid
  */
 @POST
 @Path("/buyTicket")
 @Produces(MediaType.TEXT_PLAIN)
 public Response buyTicket(@QueryParam("ticketId") int ticketId) {
   Response response;
   if (persistanceModel.updatePaymentStatus(ticketId)) {
     response = Response.ok().build();
   } else {
     response = Response.status(666).build();
   }
   return response;
 }
Esempio n. 4
0
 /**
  * Get human readable ticket by id
  *
  * @param ticketId
  * @return return ticket if exists
  */
 @POST
 @Path("/getTickByID")
 @Produces(MediaType.TEXT_PLAIN)
 public String getTickByID(@QueryParam("ticketId") int ticketId) {
   return persistanceModel.selectTicketByID(ticketId).toString();
 }