@PUT @Consumes(MediaType.APPLICATION_JSON) public Response updateHr(@HeaderParam("authorization") String authorization, Hr hr) { EntityManager em = helper.getEntityManager(); helper.mergeObject(em, hr); return Response.ok().entity("Succesffully update!").build(); }
@POST @Consumes(MediaType.APPLICATION_JSON) public Response insertHr(@HeaderParam("authorization") String authorization, Hr hr) { EntityManager em = helper.getEntityManager(); helper.persistObject(em, hr); return Response.status(Response.Status.CREATED).build(); }
@GET @Produces(MediaType.APPLICATION_JSON) public Response getHrs(@HeaderParam("authorization") String authorization) { EntityManager em = helper.getEntityManager(); List<Hr> hrs = em.createNamedQuery("Hr.findAll").getResultList(); return Response.ok().entity(hrs).build(); }
@GET @Produces(MediaType.APPLICATION_JSON) @Path("/{id}") public Response getHr( @HeaderParam("authorization") String authorization, @PathParam("id") long id) { EntityManager em = helper.getEntityManager(); Hr hrs = (Hr) em.createNamedQuery("Hr.findById").setParameter("id", id).getSingleResult(); return Response.ok().entity(hrs).build(); }
public HRRESTEndpoint() { helper = new Helper(); tokenJson = helper.getAbstractToken(); }