Uploaded image for project: 'OptaPlanner'
  1. OptaPlanner
  2. PLANNER-2126

Quarkus quickstarts polishing: Use REST CRUD Panache services

XMLWordPrintable

    • NEW
    • NEW

      This code:

      @Path("/rooms")
      @Produces(MediaType.APPLICATION_JSON)
      @Consumes(MediaType.APPLICATION_JSON)
      @Transactional
      public class RoomResource {
      
          @GET
          public List<Room> getAllRooms() {
              return Room.listAll(Sort.by("name").and("id"));
          }
      
          @POST
          public Response add(Room room) {
              Room.persist(room);
              return Response.accepted(room).build();
          }
      
          @DELETE
          @Path("{roomId}")
          public Response delete(@PathParam("roomId") Long roomId) {
              Room room = Room.findById(roomId);
              if (room == null) {
                  return Response.status(Response.Status.NOT_FOUND).build();
              }
              room.delete();
              return Response.status(Response.Status.OK).build();
          }
      
      }
      

      can probably replaced by:

      public interface RoomResource extends PanacheEntityResource<Room, Long> {
      }
      

      See https://quarkus.io/guides/rest-data-panache

      Same for Timeslot and Lesson. Probably not same for TimeTable.

      Only applies to school timetabling I think (facility location doesn't use a database).

              gdesmet@redhat.com Geoffrey De Smet (Inactive)
              gdesmet@redhat.com Geoffrey De Smet (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: