1 22 package com.geinuke.dao; 23 24 import java.util.ArrayList ; 25 import java.util.HashMap ; 26 import java.util.List ; 27 28 import com.geinuke.bizlogic.BLException; 29 import com.geinuke.vo.SurveyAnswerVO; 30 import com.geinuke.vo.SurveyVO; 31 import com.geinuke.vo.SurveyVoteVO; 32 import com.geinuke.vo.WikiArticleVO; 33 34 35 public class SurveyDAO extends GeiDAO{ 36 37 public SurveyDAO() throws Exception { 38 super(); 39 40 } 41 42 public void insertSurvey(SurveyVO s) throws Exception { 43 44 try{ 45 this.sqlMap().startTransaction(); 46 this.sqlMap().insert("insSurvey",s); 47 this.sqlMap().commitTransaction(); 48 }finally{ 49 this.sqlMap().endTransaction(); 50 } 51 52 } 53 54 public void insertSurveyAnswer(SurveyAnswerVO sa) throws Exception { 55 56 try{ 57 this.sqlMap().startTransaction(); 58 this.sqlMap().insert("insSurveyAnswer",sa); 59 this.sqlMap().commitTransaction(); 60 }finally{ 61 this.sqlMap().endTransaction(); 62 } 63 64 } 65 66 public ArrayList getSurveys()throws Exception { 67 ArrayList ll=null; 68 List list=null; 69 try{ 70 this.sqlMap().startTransaction(); 71 list=this.sqlMap().queryForList("getSurveys",null); 72 this.sqlMap().commitTransaction(); 73 }finally{ 74 this.sqlMap().endTransaction(); 75 } 76 return new ArrayList (list); 77 78 } 79 80 public ArrayList getSurveysByStatus(int status)throws Exception { 81 ArrayList ll=null; 82 List list=null; 83 try{ 84 this.sqlMap().startTransaction(); 85 list=this.sqlMap().queryForList("getSurveysByStatus",new Integer (status)); 86 this.sqlMap().commitTransaction(); 87 }finally{ 88 this.sqlMap().endTransaction(); 89 } 90 return new ArrayList (list); 91 92 } 93 94 public ArrayList getSurveyAnswersByESID(int sid)throws Exception { 95 ArrayList ll=null; 96 List list=null; 97 try{ 98 this.sqlMap().startTransaction(); 99 list=this.sqlMap().queryForList("getSurveyAnswersByESID",new Integer (sid)); 100 this.sqlMap().commitTransaction(); 101 }finally{ 102 this.sqlMap().endTransaction(); 103 } 104 return new ArrayList (list); 105 106 } 107 108 public void updateSurveyAnswerVO(SurveyAnswerVO sa) throws Exception { 109 110 try{ 111 this.sqlMap().startTransaction(); 112 this.sqlMap().update("updateSurveyAnswer",sa); 113 this.sqlMap().commitTransaction(); 114 }finally{ 115 this.sqlMap().endTransaction(); 116 } 117 118 } 119 120 public void updateSurveyVO(SurveyVO su) throws Exception { 121 122 try{ 123 this.sqlMap().startTransaction(); 124 this.sqlMap().update("updateSurvey",su); 125 this.sqlMap().commitTransaction(); 126 }finally{ 127 this.sqlMap().endTransaction(); 128 } 129 130 } 131 132 public void delSurveyBySID(int sid) throws Exception { 133 134 try{ 135 this.sqlMap().startTransaction(); 136 this.sqlMap().delete("delSurveyBySID",new Integer (sid)); 137 this.sqlMap().commitTransaction(); 138 }finally{ 139 this.sqlMap().endTransaction(); 140 } 141 142 } 143 144 public void delSurveyAnswersByESID(int esid) throws Exception { 145 146 try{ 147 this.sqlMap().startTransaction(); 148 this.sqlMap().delete("delSurveyAnswersByESID",new Integer (esid)); 149 this.sqlMap().commitTransaction(); 150 }finally{ 151 this.sqlMap().endTransaction(); 152 } 153 154 } 155 156 public void delSurveyAnswerByAID(int aid) throws Exception { 157 158 try{ 159 this.sqlMap().startTransaction(); 160 this.sqlMap().delete("delSurveyAnswerByAID",new Integer (aid)); 161 this.sqlMap().commitTransaction(); 162 }finally{ 163 this.sqlMap().endTransaction(); 164 } 165 166 } 167 168 public SurveyVO getSurveyBySID(int sid) throws Exception { 169 SurveyVO res=null; 170 try{ 171 this.sqlMap().startTransaction(); 172 res=(SurveyVO)this.sqlMap().queryForObject("getSurveyBySID",new Integer (sid)); 173 this.sqlMap().commitTransaction(); 174 }finally{ 175 this.sqlMap().endTransaction(); 176 } 177 return res; 178 } 179 180 public boolean checkVote(int sid, int uid) throws Exception { 181 SurveyVoteVO vo=null; 182 boolean res=false; 183 try{ 184 this.sqlMap().startTransaction(); 185 HashMap hm=new HashMap (); 186 hm.put("sid",new Integer (sid)); 187 hm.put("uid",new Integer (uid)); 188 189 vo=(SurveyVoteVO)this.sqlMap().queryForObject("getVoteByUID",hm); 190 res=vo==null; 191 this.sqlMap().commitTransaction(); 192 }finally{ 193 this.sqlMap().endTransaction(); 194 } 195 return res; 196 } 197 198 199 200 public boolean checkVote(int sid, String ip) throws Exception { 201 SurveyVoteVO vo=null; 202 boolean res=false; 203 try{ 204 this.sqlMap().startTransaction(); 205 HashMap hm=new HashMap (); 206 hm.put("sid",new Integer (sid)); 207 hm.put("ip",ip); 208 209 vo=(SurveyVoteVO)this.sqlMap().queryForObject("getVoteByIP",hm); 210 res=vo==null; 211 this.sqlMap().commitTransaction(); 212 }finally{ 213 this.sqlMap().endTransaction(); 214 } 215 return res; 216 } 217 218 public void insertVote(SurveyVoteVO vo) throws Exception { 219 try{ 220 this.sqlMap().startTransaction(); 221 this.sqlMap().insert("insertVote",vo); 222 this.sqlMap().commitTransaction(); 223 }catch(Exception e){ 224 e.printStackTrace(); 225 }finally{ 226 this.sqlMap().endTransaction(); 227 } 228 } 229 230 } 231 | Popular Tags |