} // end if (preferencename != null)
} // end while (it.hasNext())
// Get all the views.
ListPreference listPreference = null;
ListView listView = null;
// Step One: we will get all the Default Views for the Individual, who is
// logged in.
cvdl.setSqlQueryToNull();
cvdl.setSqlQuery("SELECT listviews.viewid, listviews.listtype, listviews.sorttype, listviews.sortmember AS sortelement, listviews.noofrecords AS recordsperpage, listviews.viewname, listviews.searchid FROM listviews, defaultviews WHERE listviews.listtype = defaultviews.listtype AND listviews.viewid = defaultviews.viewid");
Collection ownerViewCollection = cvdl.executeQuery();
Iterator ownerViewIterator = ownerViewCollection.iterator();
while (ownerViewIterator.hasNext()) {
HashMap ownerViewHM = (HashMap) ownerViewIterator.next();
String listType = (String) ownerViewHM.get("listtype");
int viewId = ((Number) ownerViewHM.get("viewid")).intValue();
listPreference = new ListPreference(listType);
// Step Two:
// We must get all the Views which exist for each ListType from the
// query for default views.
cvdl.setSqlQueryToNull();
cvdl.setSqlQuery("SELECT viewid, viewname, searchid FROM listviews WHERE listtype = ? and ownerid IS NULL UNION SELECT viewid, viewname, searchid FROM listviews WHERE listtype = ? and ownerid = ?");
cvdl.setString(1, listType);
cvdl.setString(2, listType);
cvdl.setInt(3, individualId);
Collection allViewCollection = cvdl.executeQuery();
Iterator allViewIterator = allViewCollection.iterator();
while (allViewIterator.hasNext()) {
HashMap allViewHM = (HashMap) allViewIterator.next();
int allViewId = ((Number) allViewHM.get("viewid")).intValue();
listView = new ListView(allViewId);
listView.setListType(listType);
listView.setViewName((String) allViewHM.get("viewname"));
listView.setViewID(allViewId);
listView.setSearchID(((Number) allViewHM.get("searchid")).intValue());
// Get all columns for the View. Which we are processing.
cvdl.setSqlQueryToNull();
cvdl.setSql("view.getownerallcolumn");
cvdl.setInt(1, allViewId);
cvdl.setString(2, listType);
Collection viewColumnCollection = cvdl.executeQuery();
Iterator viewColumnIterator = viewColumnCollection.iterator();
while (viewColumnIterator.hasNext()) {
HashMap viewColumnHM = (HashMap) viewColumnIterator.next();
listView.addColumnName((String) viewColumnHM.get("columnname"));
}// end of while (viewColumnIterator.hasNext())
listPreference.addListView(listView);
}// end of while (allViewIterator.hasNext())
listPreference.setDefaultView(viewId);
listPreference.setRecordsPerPage(((Long) ownerViewHM.get("recordsperpage")).intValue());