1 23 24 package org.dbforms.event; 25 26 import org.dbforms.config.DbEventInterceptor; 27 import org.dbforms.config.DbEventInterceptorData; 28 import org.dbforms.config.DbFormsConfig; 29 import org.dbforms.config.Field; 30 import org.dbforms.config.FieldValue; 31 import org.dbforms.config.FieldValues; 32 import org.dbforms.config.MultipleValidationException; 33 import org.dbforms.config.Table; 34 import org.dbforms.config.ValidationException; 35 36 import java.sql.Connection ; 37 38 import java.util.Map ; 39 40 import javax.servlet.http.HttpServletRequest ; 41 42 43 44 49 public class DbEventInterceptorSupport implements DbEventInterceptor { 50 private Map params; 51 52 55 public void setParameterMap(Map params) { 56 this.params = params; 57 } 58 59 60 63 public Map getParameterMap() { 64 return params; 65 } 66 67 70 public String getParameter(String key) { 71 return (String )params.get(key); 72 } 73 74 75 78 public void postAddRow(DbEventInterceptorData data) { 79 } 80 81 82 85 public void postDelete(DbEventInterceptorData data) { 86 postDelete(data.getRequest(), data.getConfig(), data.getConnection()); 87 } 88 89 90 99 public void postDelete(HttpServletRequest request, 100 DbFormsConfig config, 101 Connection con) { 102 } 103 104 105 108 public void postInsert(DbEventInterceptorData data) { 109 postInsert(data.getRequest(), data.getConfig(), data.getConnection()); 110 } 111 112 113 122 public void postInsert(HttpServletRequest request, 123 DbFormsConfig config, 124 Connection con) { 125 } 126 127 128 131 public void postSelect(DbEventInterceptorData data) { 132 postSelect(data.getRequest(), data.getConfig(), data.getConnection()); 133 } 134 135 136 145 public void postSelect(HttpServletRequest request, 146 DbFormsConfig config, 147 Connection con) { 148 } 149 150 151 154 public void postUpdate(DbEventInterceptorData data) { 155 postUpdate(data.getRequest(), data.getConfig(), data.getConnection()); 156 } 157 158 159 168 public void postUpdate(HttpServletRequest request, 169 DbFormsConfig config, 170 Connection con) { 171 } 172 173 174 177 public int preAddRow(DbEventInterceptorData data) 178 throws ValidationException, MultipleValidationException { 179 return GRANT_OPERATION; 180 } 181 182 183 186 public int preDelete(DbEventInterceptorData data) 187 throws ValidationException, MultipleValidationException { 188 return preDelete(data.getRequest(), data.getTable(), 189 (FieldValues) data.getAttribute(DbEventInterceptorData.FIELDVALUES), 190 data.getConfig(), data.getConnection()); 191 } 192 193 194 209 public int preDelete(HttpServletRequest request, 210 Table table, 211 FieldValues fieldValues, 212 DbFormsConfig config, 213 Connection con) throws ValidationException { 214 return GRANT_OPERATION; 215 } 216 217 218 221 public int preInsert(DbEventInterceptorData data) 222 throws ValidationException, MultipleValidationException { 223 return preInsert(data.getRequest(), data.getTable(), 224 (FieldValues) data.getAttribute(DbEventInterceptorData.FIELDVALUES), 225 data.getConfig(), data.getConnection()); 226 } 227 228 229 244 public int preInsert(HttpServletRequest request, 245 Table table, 246 FieldValues fieldValues, 247 DbFormsConfig config, 248 Connection con) throws ValidationException { 249 return GRANT_OPERATION; 250 } 251 252 253 256 public int preSelect(DbEventInterceptorData data) 257 throws ValidationException, MultipleValidationException { 258 return preSelect(data.getRequest(), data.getConfig(), data.getConnection()); 259 } 260 261 262 275 public int preSelect(HttpServletRequest request, 276 DbFormsConfig config, 277 Connection con) throws ValidationException { 278 return GRANT_OPERATION; 279 } 280 281 282 285 public int preUpdate(DbEventInterceptorData data) 286 throws ValidationException, MultipleValidationException { 287 return preUpdate(data.getRequest(), data.getTable(), 288 (FieldValues) data.getAttribute(DbEventInterceptorData.FIELDVALUES), 289 data.getConfig(), data.getConnection()); 290 } 291 292 293 308 public int preUpdate(HttpServletRequest request, 309 Table table, 310 FieldValues fieldValues, 311 DbFormsConfig config, 312 Connection con) throws ValidationException { 313 return GRANT_OPERATION; 314 } 315 316 317 325 protected void setValue(Table table, 326 FieldValues fieldValues, 327 String fieldName, 328 String value) { 329 FieldValue fv = fieldValues.get(fieldName); 330 Field f = table.getFieldByName(fieldName); 331 332 if (f != null) { 333 if (fv == null) { 334 fv = new FieldValue(f, value); 335 fieldValues.put(fv); 336 } else { 337 fv.setFieldValue(value); 338 } 339 } 340 } 341 } 342
| Popular Tags
|