Пример #1
0
 /**
  * Updates an History resource
  *
  * @param id this id of the history
  * @param updatedHistoryTO a TO containing the history data
  * @return an instance of PublicHistoryTO
  * @throws ch.heigvd.skeleton.exceptions.EntityNotFoundException
  */
 @PUT
 @Path("{id}")
 @Consumes({"application/json"})
 public Response Resource(PublicHistoryTO updatedHistoryTO, @PathParam("id") long id)
     throws EntityNotFoundException {
   History historyToUpdate = historiesManager.findById(id);
   historiesTOService.updateHistoryEntity(historyToUpdate, updatedHistoryTO);
   historiesManager.update(historyToUpdate);
   return Response.ok().build();
 }
Пример #2
0
 /**
  * Retrieves representation of an History resource
  *
  * @param id this id of the history
  * @return an instance of PublicHistoryTO
  * @throws ch.heigvd.skeleton.exceptions.EntityNotFoundException
  */
 @GET
 @Path("{id}")
 @Produces({"application/json"})
 public PublicHistoryTO getResource(@PathParam("id") long id) throws EntityNotFoundException {
   History history = historiesManager.findById(id);
   PublicHistoryTO historyTO = historiesTOService.buildPublicHistoryTO(history);
   return historyTO;
 }
Пример #3
0
 /**
  * Creates a new History resource from the provided representation
  *
  * @return an instance of PublicHistoryTO
  */
 @POST
 @Consumes({"application/json"})
 public Response createResource(PublicHistoryTO newHistoryTO) {
   History newHistory = new History();
   historiesTOService.updateHistoryEntity(newHistory, newHistoryTO);
   long newHistoryId = historiesManager.create(newHistory);
   URI createdURI = context.getAbsolutePathBuilder().path(Long.toString(newHistoryId)).build();
   return Response.created(createdURI).build();
 }
Пример #4
0
 /**
  * Retrieves a representation of a list of History resources
  *
  * @return an instance of PublicHistoryTO
  */
 @GET
 @Produces({"application/json"})
 public List<PublicHistoryTO> getResourceList() {
   List<History> histories = historiesManager.findAll();
   List<PublicHistoryTO> result = new LinkedList<>();
   for (History history : histories) {
     result.add(historiesTOService.buildPublicHistoryTO(history));
   }
   return result;
 }
Пример #5
0
 /**
  * Deletes an History resource
  *
  * @param id this id of the history
  * @return an instance of PublicHistoryTO
  * @throws ch.heigvd.skeleton.exceptions.EntityNotFoundException
  */
 @DELETE
 @Path("{id}")
 public Response deleteResource(@PathParam("id") long id) throws EntityNotFoundException {
   historiesManager.delete(id);
   return Response.ok().build();
 }