@Override
 public boolean update(int id, Category category) {
   try {
     Connection connection = PoolConnection.getConnection();
     try {
       connection.setAutoCommit(false);
       //                assertTransaction(cdao.update(connection, id, category));
       //                assertTransaction(chtdao.deleteByCategoryId(connection, id));
       //                for (Task task : category.getTasks()) {
       //                    assertTransaction(chtdao.insert(connection, id, task.getId()));
       //                }
       cdao.update(connection, id, category);
       chtdao.deleteByCategoryId(connection, id);
       for (Task task : category.getTasks()) {
         chtdao.insert(connection, id, task.getId());
       }
       connection.commit();
     } catch (SQLTransactionException e) {
       connection.rollback();
       return false;
     } finally {
       if (connection != null) {
         connection.setAutoCommit(true);
         connection.close();
       }
     }
   } catch (SQLException e) {
     e.printStackTrace();
   }
   return true;
 }
Exemple #2
0
 public boolean processing(Post post, Task task) {
   List<Category> categories = categoryService.getByTaskId(task.getId());
   post.setUserId(-1);
   if (postService.insert(post)) {
     postService.bindWithCategories(post.getId(), categories);
     if (feedReceiver != null) feedReceiver.send(post.getId(), "new|" + post.getId());
   }
   return false;
 }