1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 package org.dbforms.event.datalist;
24
25 import org.apache.commons.logging.Log;
26 import org.apache.commons.logging.LogFactory;
27
28 import org.dbforms.config.DbFormsConfig;
29 import org.dbforms.config.FieldValue;
30 import org.dbforms.config.ResultSetVector;
31 import org.dbforms.config.Table;
32
33 import org.dbforms.event.AbstractNavigationEvent;
34 import org.dbforms.event.datalist.dao.DataSourceFactory;
35 import org.dbforms.event.datalist.dao.DataSourceSessionList;
36 import org.dbforms.interfaces.DbEventInterceptorData;
37
38 import java.sql.SQLException;
39
40 import javax.servlet.http.HttpServletRequest;
41
42 /***
43 * This event scrolls the current ResultSet to its first row of data. <br>
44 * Works with new factory classes.
45 *
46 * @author Henner Kollmann
47 */
48 public class NavFirstEvent extends AbstractNavigationEvent {
49
50 private static Log logCat = LogFactory
51 .getLog(NavFirstEvent.class.getName());
52
53 /***
54 * Creates a new NavFirstEvent object.
55 *
56 * @param action
57 * the action string
58 * @param request
59 * the request object
60 * @param config
61 * the configuration object
62 */
63 public NavFirstEvent(String action, HttpServletRequest request,
64 DbFormsConfig config) {
65 super(action, request, config);
66 }
67
68 /***
69 * Creates a new NavFirstEvent object.
70 *
71 * @param table
72 * the input table object
73 * @param request
74 * the request object
75 * @param config
76 * the configuration object
77 */
78 public NavFirstEvent(Table table, HttpServletRequest request,
79 DbFormsConfig config) {
80 super(table, request, config);
81 }
82
83 /***
84 * Process the current event.
85 *
86 * @param filterFieldValues
87 * FieldValue array used to restrict a set of data
88 * @param orderConstraint
89 * FieldValue array used to build a cumulation of rules for
90 * ordering (sorting) and restricting fields to the actual block
91 * of data
92 * @param sqlFilter
93 * DOCUMENT ME!
94 * @param sqlFilterParams
95 * DOCUMENT ME!
96 * @param count
97 * record count
98 * @param firstPosition
99 * a string identifying the first resultset position
100 * @param lastPosition
101 * a string identifying the last resultset position
102 * @param dbConnectionName
103 * name of the used db connection. Can be used to get an own db
104 * connection, e.g. to hold it during the session (see
105 * DataSourceJDBC for example!)
106 * @param con
107 * the JDBC Connection object
108 *
109 * @return a ResultSetVector object
110 *
111 * @exception SQLException
112 * if any error occurs
113 */
114 public ResultSetVector processEvent(FieldValue[] filterFieldValues,
115 FieldValue[] orderConstraint, String sqlFilter,
116 FieldValue[] sqlFilterParams, int count, String firstPosition,
117 String lastPosition, DbEventInterceptorData interceptorData)
118 throws SQLException {
119 logCat.info("==>NavFirstEvent.processEvent");
120
121 DataSourceSessionList ds = DataSourceSessionList
122 .getInstance(getRequest());
123 DataSourceFactory qry = null;
124 boolean force = getRequest().getAttribute("forceUpdate") != null;
125 if (force) {
126 ds.remove(getTable(), getRequest());
127 } else {
128 qry = ds.get(getTable(), getRequest());
129 }
130
131 if (qry == null) {
132 qry = new DataSourceFactory((String) interceptorData
133 .getAttribute(DbEventInterceptorData.CONNECTIONNAME),
134 interceptorData.getConnection(), getTable());
135 qry.setSelect(filterFieldValues, orderConstraint, sqlFilter,
136 sqlFilterParams);
137 ds.put(getTable(), getRequest(), qry);
138 }
139
140 return qry.getFirst(interceptorData, count);
141 }
142 }