private void updateTopicTime(int _topicid, String _updatetime) { Topic topic = new Topic(); try { topic = bm.loadTopicById(_topicid); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (SQLException e) { e.printStackTrace(); } topic.setLastupdate(_updatetime); try { bm.update(topic); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (SQLException e) { e.printStackTrace(); } }
public String topicsdelete() { String delTopicId = this.request.getParameter("topicid"); System.out.println("topicid=" + delTopicId); List<Comment> topiccomments = new ArrayList<Comment>(); if (delTopicId != null && delTopicId.length() > 0) { try { topiccomments = bm.loadCommentsByTopicId(Integer.parseInt(delTopicId)); } catch (NumberFormatException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (SQLException e) { e.printStackTrace(); } for (Comment comm : topiccomments) { System.out.println("$$$---" + comm.toString()); try { bm.delete(comm); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (SQLException e) { e.printStackTrace(); } } Topic deltopic = new Topic(); deltopic.setId(Integer.parseInt(delTopicId)); try { bm.delete(deltopic); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (SQLException e) { e.printStackTrace(); } } this.listAllTopics(); return "delete"; }
private void sortTopiclistByDate(List<Topic> _list) { List<String> toSort = new ArrayList<String>(); for (Topic topic : _list) { if (topic.getLastupdate() != null && topic.getLastupdate().length() >= 10) toSort.add(topic.getLastupdate()); else { topic.setLastupdate(topic.getDate()); toSort.add(topic.getLastupdate()); } } List<Integer> seqs = new ArrayList<Integer>(); seqs = CONSTANT.sortDatesDesc(toSort); List<Topic> sortedTopiclist = new ArrayList<Topic>(); for (Integer seq : seqs) sortedTopiclist.add(_list.get(seq)); this.setTopiclist(sortedTopiclist); }