Database Reference
In-Depth Information
clear() method. We also set the table model, appsTM
to a
null
Vector
—we don't want to show any
applications until an available proxy is selected.
As we walk through the
ResultSet
, we check to see if we have already started a
dataVector
for the
proxy user,
rs.getString(2)
. We check if the
appsHashTable
contains a key by that name. If so, we get the
value from
appsHashTable
which is our
Vector
of applications for the proxy, else we instantiate a new
Vector
. Again, each application is an item in a new
Vector
that is added to the
dataVector
for this proxy.
Then the
dataVector
is put into the
appsHashTable
with the proxy user name as the key.
Listing 12-36.
Build Data for Applications for Proxy Table
rs = stmt.executeQuery("SELECT DISTINCT a.application_id, p.proxy " +
"FROM ojsaadm.instance_proxy_users p, appsec.v_application_registry a " +
"WHERE p.instance <> 'APVER' " +
"AND p.proxy NOT IN ('APPVER','AVADMIN','APPSEC','OJSAADM') " +
"AND a.app_user = p.proxy ORDER BY a.application_id");
// appsHashtable must be Hashtable of Vectors of Vectors
// empty static Hashtable each time you enter this screen
appsHashtable.clear()
;
appsTM.setDataVector(
null
, appColumnIdentifiers);
while (rs.next()) {
if (appsHashtable.containsKey(rs.getString(2))) {
dataVector = appsHashtable.get(rs.getString(2))
;
itemVector = new Vector();
itemVector.add(rs.getString(1));
dataVector.add(itemVector);
} else {
dataVector = new Vector()
;
itemVector = new Vector();
itemVector.add(rs.getString(1));
dataVector.add(itemVector);
}
appsHashtable.put(rs.getString(2), dataVector)
;
}
To build the table data for both the available proxies table and the applications for proxy table, we
are selecting from the
v.application_registry
view, and in this functional screen, we are connected as
the
ojsaadm
user with the
ojs_adm_admin
role. In order to select from the
appsec
schema view, the proxy
user needs
SELECT
privilege. As the Security Administrator,
secadm
on the
orcl
instance, we execute this
grant:
GRANT SELECT ON appsec.v_application_registry TO ojs_adm_admin;
Selecting an Available Proxy in the Table
When the application user selects an available proxy from the table, the
availableProxiesTable_mouseClicked()
method gets called. The significant code of that method is
shown in Listing 12-37. To find the value of the data selected in a table, we need to get the value in a
specified row, at a specified column. In a single-column table, all the data is in column index zero. So to
get the value of the available proxy that was selected in the table, we get the value at the selected row and
column zero. We use that selected proxy user name as the key to get the related
dataVector
from
appsHashtable
. Then we set the applications table model to use that
dataVector
.