Пример #1
0
 @POST
 @Path("/add")
 public Response addShirt(
     @BeanParam ShirtFormData shirtFormData, @Context SecurityContext securityContext)
     throws Exception {
   final Shirt shirt = new Shirt(shirtFormData.getName());
   shirt.setCount(shirtFormData.getCount());
   shirt.setCut(shirtFormData.getCut());
   shirt.setSize(shirtFormData.getSize());
   shirtDatastore.add(shirt);
   return Response.status(Response.Status.FOUND).location(INDEX_URI).build();
 }
Пример #2
0
 @POST
 @Path("/{id}/edit")
 public Response editShirt(@PathParam("id") String id, @BeanParam ShirtFormData shirtData)
     throws Exception {
   final Shirt toUpdate = new Shirt(shirtData.getName());
   toUpdate.setId(id);
   toUpdate.setCount(shirtData.getCount());
   toUpdate.setCut(shirtData.getCut());
   toUpdate.setSize(shirtData.getSize());
   shirtDatastore.update(toUpdate);
   return Response.status(Response.Status.FOUND).location(INDEX_URI).build();
 }
Пример #3
0
 @Override
 public String getValue(Shirt entity, int columnIndex) {
   switch (columnIndex) {
     case 0:
       return entity.getName();
     case 1:
       return StringUtils.isBlank(entity.getCut()) ? "" : entity.getCut();
     case 2:
       return StringUtils.isBlank(entity.getSize()) ? "" : entity.getSize();
     case 3:
       return Integer.toString(entity.getCount());
     default:
       throw new IllegalArgumentException("Unrecognized index: " + columnIndex);
   }
 }