1 43 package net.jforum.view.admin; 44 45 46 import net.jforum.dao.DataAccessDriver; 47 import net.jforum.dao.RankingDAO; 48 import net.jforum.entities.Ranking; 49 import net.jforum.repository.RankingRepository; 50 import net.jforum.util.preferences.TemplateKeys; 51 52 56 public class RankingAction extends AdminCommand 57 { 58 public void list() throws Exception 60 { 61 this.context.put("ranks", DataAccessDriver.getInstance().newRankingDAO().selectAll()); 62 this.setTemplateName(TemplateKeys.RANKING_LIST); 63 } 64 65 public void insert() throws Exception 67 { 68 this.setTemplateName(TemplateKeys.RANKING_INSERT); 69 this.context.put("action", "insertSave"); 70 } 71 72 public void edit() throws Exception 74 { 75 this.context.put("rank", DataAccessDriver.getInstance().newRankingDAO().selectById( 76 this.request.getIntParameter("ranking_id"))); 77 this.setTemplateName(TemplateKeys.RANKING_EDIT); 78 this.context.put("action", "editSave"); 79 } 80 81 public void editSave() throws Exception 83 { 84 Ranking r = new Ranking(); 85 r.setTitle(this.request.getParameter("rank_title")); 86 r.setMin(this.request.getIntParameter("rank_min")); 87 r.setId(this.request.getIntParameter("rank_id")); 88 89 91 DataAccessDriver.getInstance().newRankingDAO().update(r); 92 RankingRepository.loadRanks(); 93 this.list(); 94 } 95 96 public void delete() throws Exception 98 { 99 String ids[] = this.request.getParameterValues("rank_id"); 100 101 RankingDAO rm = DataAccessDriver.getInstance().newRankingDAO(); 102 103 if (ids != null) { 104 for (int i = 0; i < ids.length; i++) { 105 rm.delete(Integer.parseInt(ids[i])); 106 } 107 } 108 109 this.list(); 110 } 111 112 public void insertSave() throws Exception 114 { 115 Ranking r = new Ranking(); 116 r.setTitle(this.request.getParameter("rank_title")); 117 r.setMin(this.request.getIntParameter("rank_min")); 118 119 DataAccessDriver.getInstance().newRankingDAO().addNew(r); 121 this.list(); 122 } 123 } 124 | Popular Tags |