Пример #1
0
 @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);
 }
Пример #2
0
 @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);
 }
Пример #3
0
 @DELETE
 @Path("{id}")
 @UnitOfWork
 public void delete(@Context User user, @PathParam("id") Long id) {
   projectDao.delete(id);
 }
Пример #4
0
 @POST
 @UnitOfWork
 public Project save(@Context User user, Project project) {
   return projectDao.saveOrUpdate(
       project.withInitiator(user).withStartDate(Calendar.getInstance().getTime()));
 }
Пример #5
0
 @GET
 @UnitOfWork
 // TODO: get all last 30
 public List<Project> getProjects() {
   return projectDao.findAll();
 }