@GET @Path("{id}") // TODO: get projects by idea_ID @UnitOfWork public Project get(@Context User user, @PathParam("id") Long projectId) { System.out.println(user + " " + "get project " + projectId); return projectDao.get(projectId); }
@PUT @Path("{id}") @UnitOfWork public Project amend(Project project) { if (project.getInitiatorId() != null) { User author = userDao.get(project.getInitiatorId()); if (author == null) { throw new IllegalArgumentException("Author id is incorrect"); } project = project.withInitiator(author); } return projectDao.saveOrUpdate(project); }
@DELETE @Path("{id}") @UnitOfWork public void delete(@Context User user, @PathParam("id") Long id) { projectDao.delete(id); }
@POST @UnitOfWork public Project save(@Context User user, Project project) { return projectDao.saveOrUpdate( project.withInitiator(user).withStartDate(Calendar.getInstance().getTime())); }
@GET @UnitOfWork // TODO: get all last 30 public List<Project> getProjects() { return projectDao.findAll(); }