This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal



May 10, 2011, 5:17 AM
30 Posts

Dynamically adding data sources

  • Category: Performance
  • Platform: All
  • Release: 8.5.2
  • Role: Developer
  • Tags: performance,data source
  • Replies: 1
 I'm retrieving data from around 20 users calendars, looking for specific keywords.
 
I don't know beforehand which users so I look up configured group names, retrieve the members, check the the filepaths of each users mailfile and then poll the database for new data.
 
I got an efficient way of doing this up until polling of the actual data. I could do it "LS style": Do a search in each database compare results with what I have cached - rinse- repeat. 
 
But I imagine having 20 (or so) datasources might be more efficient(?). Which, finally, leads me to the actual question: Can I dynamically specify them somehow? Thinking of  a custom control that accepts parameters and then include a number of those on the page.
 
Natural followup: Would I gain anything in performance? 
 
 
Thanks! 
 
 
/J 
May 10, 2011, 6:43 PM
41 Posts
Re: Dynamically adding data sources
 Yes, data sources can be added dynamically at runtime; for example, adding a view data source:
 
var newViewData = new com.ibm.xsp.model.domino.DominoViewData();
newViewData.setVar("variable by which you will refer to this data source");
newViewData.setDatabaseName("Path to database");
newViewData.setViewName("Name of View");
newViewData.setSearch("Terms to search for"); 
view.addData(newViewData);
 
The tricky part will be actually extracting the data from each view... the ideal approach to this likely depends upon how you want the data represented to the user. If you want them to see a separate "report" for each source database, then this is fairly easy: bind a repeat to a list / array of the data sources you defined, then within the repeat, bind a view panel or inner repeat to each data source instance.
 
If, on the other hand, you want to blend all of the results into one big repeat (obviously, a view panel would be out of the question here, given the disparate data sources), you'd probably need to do something like this: 
 
var result = new java.util.ArrayList(); 
for (var eachDataSource in dataSources) { // where dataSources is an array of all the data sources you've added
 var viewModel = eachDataSource.getDataModel();
 var dataContainer = viewModel.getDataContainer(); 
 var viewNavigator = dataContainer.getNavigator(); 
 result.addAll(viewNavigator.readEntries(dataContainer.getDominoView(), 0, viewNavigator.getCount()));
}
return result; 
 
If you bind a repeat to the above, that should  show the search results from each view in a single repeat. One word of caution, however: while this is likely to be more performant than using the low-level API's to merge the search results, since the classes involved are very highly optimized, this is still likely to be a fairly expensive operation. As a result, I'd recommend setting this repeat's value to be an onload binding ($ instead of #). This requires the following:
  1.  The repeatControls attribute of the repeat must be set to "true"
  2. The search criteria and views to search must be known at load time; this means you'll either need to pass this information in the query string, or store it in the sessionScope prior to loading the page. This makes this less interactive than it would be otherwise, but the performance gain is likely to be worth the tradeoff.
Hope that helps...

This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal