The SOA.UI library has, since its introduction, defined its standard UI-serving services not only in terms of interfaces and DataContracts,
but as a set of base classes to be inherited. This approach provides the
automatic inheritance of the relevant interface and DataContract, but also allows for more helpful functionality to be built into the base class and leveraged by the end developer. With ComponentArt SOA.UI 2009.3 SP1,
released yesterday, we have begun to add some of that functionality.
One of the most common tasks that we ourselves have had to solve when writing our control samples is the standard approach to performing a SoaDataGridService.Select operation in a way that supports paging, sorting and
filtering. The approach to doing this was as follows:
public override SoaDataGridSelectResponse Select(SoaDataGridSelectRequest request)
{
// load all the data into a data set (from database or elsewhere)
DataSet oDS = LoadData();
DataView oView = new DataView(oDS.Tables[0]);
// apply order and filters to view
oView.Sort = request.Sortings.ToSqlString();
oView.RowFilter = request.Filters.ToSqlString();
SoaDataGridSelectResponse response = new SoaDataGridSelectResponse();
List<List<object>> arItems = new List<List<object>>();
// chop the requested part of the record set
for (int i = request.Offset; i < request.Offset + request.Count && i < oView.Count; i++)
{
// load data row
List<object> item = new List<object>();
foreach (SoaDataGridColumn oColumn in request.Columns)
{
item.Add(oView[i][oColumn.Name]);
}
arItems.Add(item);
}
response.ItemCount = oView.Count;
response.Data = arItems;
return response;
}
The solution was pretty much always the same in the context of our demos, so it made sense to package it in a way that's usable right out of the box. So, in applications where all the data is accessible to the service in
the form of a DataTable, we can now implement SoaDataGridService.Select in just a couple of lines. First, we load the DataSet (or just DataTable), and take a look at what tools we have inherited:
The new SelectFromDataTable protected method can be called right away on the DataTable which contains our data, and it performs all the typical processing automatically. Our final Select
implementation looks like this:
A similar helper method has been added for the Group operation (GroupFromDataTable), to handle the "ConstantGroups" grouping mode via SOA.UI.
Our intention is to introduce helper functionality to SOA.UI base classes in a conservative manner, starting from where the time-saving potential is greatest. The initial buildout, this being a minor service pack
release, is modest and highly focused, but we welcome your feedback on the sorts of functionality you'd like to see!