コード例 #1
0
 @DELETE
 @Path("/{id:[0-9][0-9]*}")
 public Response deleteById(@PathParam("id") int id) {
   KsKamera entity = dao.find(id);
   if (entity == null) {
     return Response.status(Status.NOT_FOUND).build();
   }
   dao.remove(entity);
   return Response.noContent().build();
 }
コード例 #2
0
 @GET
 @Path("searchSeriNo/{cihazSeriNo}")
 @Produces("application/json")
 public Response searchSeriNo(@PathParam("cihazSeriNo") String cihazSeriNo) {
   KsKamera entity = dao.searchRest(0, cihazSeriNo);
   if (entity != null) return Response.ok(entity).build();
   return Response.noContent().build();
 }
コード例 #3
0
 @GET
 @Path("searchBarkod/{barkod}")
 @Produces("application/json")
 public Response searchBarkod(@PathParam("barkod") Integer barkod) {
   KsKamera entity = dao.searchRest(barkod, null);
   if (entity != null) return Response.ok(entity).build();
   return Response.noContent().build();
 }
コード例 #4
0
 @POST
 @Consumes("application/json")
 @Produces("application/json")
 public KsKamera create(KsKamera entity) {
   entity.setGununTarihi(new Date());
   dao.persist(entity);
   entity.setKullanici(kullaniciDao.find(entity.getKullaniciID()));
   entity.setBolge(bolgeDao.find(entity.getBolgeID()));
   return entity;
 }
コード例 #5
0
  @PUT
  @Path("/{id:[0-9][0-9]*}")
  @Consumes("application/json")
  public Response update(@PathParam("id") int id, KsKamera 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();
  }
コード例 #6
0
 @GET
 @Path("/{id:[0-9][0-9]*}")
 @Produces("application/json")
 public Response findById(@PathParam("id") int id) {
   KsKamera entity;
   try {
     entity = dao.find(id);
   } catch (NoResultException nre) {
     entity = null;
   }
   if (entity == null) {
     return Response.status(Status.NOT_FOUND).build();
   }
   return Response.ok(entity).build();
 }
コード例 #7
0
 @GET
 @Produces("application/json")
 public List<KsKamera> listAll() {
   List<KsKamera> results = dao.findAll();
   return results;
 }