Beispiel #1
0
 @POST
 @Consumes("application/json")
 @Produces("application/json")
 public LCD create(LCD entity) {
   entity.setGununTarihi(new Date());
   dao.persist(entity);
   entity.setKullanici(kullaniciDao.find(entity.getKullaniciID()));
   entity.setBolge(bolgeDao.find(entity.getBolgeID()));
   return entity;
 }
Beispiel #2
0
  @PUT
  @Path("/{id:[0-9][0-9]*}")
  @Consumes("application/json")
  public Response update(@PathParam("id") int id, LCD entity) {
    if (entity == null) {
      return Response.status(Status.BAD_REQUEST).build();
    }
    if (id != entity.getBarkod()) {
      return Response.status(Status.CONFLICT).entity(entity).build();
    }
    if (dao.find(id) == null) {
      return Response.status(Status.NOT_FOUND).build();
    }
    try {
      entity = dao.merge(entity);
    } catch (OptimisticLockException e) {
      return Response.status(Response.Status.CONFLICT).entity(e.getEntity()).build();
    }

    return Response.noContent().build();
  }