|
One of the major report designer/generators for Delphi/BCB is Report
Builder from Digital Metaphors.
They have just reached version 10. Lately there have been several questions
on how to use kbmMW with RB10. This is what this article will try to provide an
answer for.
kbmMW contains a so called DADE plugin, which is Report Builders generalized
API towards databases. The kbmMW based DADE plugin lets one or more published
queries, on one or more query services, on one or more app servers (that was a
complex sentence) operate as a virtual database for the Report Builder designer
and report generator.
Prepping the development environment
Firstly install RB 10 if you havnt already. As far as I can tell, you need to
use Professional version as minimum to have support from the RB side for
DADE.
Next step is to ensure that the kbmMW DADE plugin is installed in the
component palette. The DADE plugin is only available with kbmMW Pro, ProPlus or
Enterprise Editions. In case you have one of these editions, open
kbmMWConfig.inc and ensure that it also contains the following lines:
{$DEFINE
KBMMW_RBDADE_SUPPORT}
// ReportBuilder DADE support {$DEFINE
KBMMW_USING_7_NEWER_RB}
// If using RB 7 or newer.
If the lines are in place, and you have compiled the kbmMW runtime and
designtime packages, you should find one new component in the kbmMW DADE
component tab: TdakbmMWDatabase
If not, then make sure you are using the latest version of kbmMW, as
a misspelling was introduced in one of the earlier 2.50 versions. This was
fixed in start of January.
A client side designed report demo
The demo is based on having the standard BDE demo application server (any
other of the standard database demo application servers is also fine). The demo
application server contains a query service, which in turn contains 3 published
kbmMW query components, ALL_EVENTS, SELECTED_EVENT and CLIENTSIDEQUERY.
Each or all of these queries can be used by RB to query for data.
In kbmMW's install directory you will find a Demo folder. In it you will find
a sample application (based on one of the demoes provided with RB) with all the
needed kbmMW and RB components (for more information about how to make this
application, please read the whitepaper in the
University section.)

When this demo application is run, one button will show... Launch. Click
it.

To design the report, we need to select the data to be
used for the report. In RB, there are several ways to obtain data. The
one kbmMW provides is the DADE method.
We select the Data tab and in it, the menu File - Data
Settings to prepare for accessing a backend kbmMW virtual database..
In this screen, we can choose which published query on the
application server that we want to use for getting our data. That means that its
possible to access different databases by simply putting multiple appropriate
queries on the query service on the application server, each pointing to their
specific database. The end user will not know, or need to know, where the data
in reality originates from.
Due to this design, its even possible to feed virtual data to the
end user by for example publishing a TkbmMWMTQuery which is a query component
that accesses a memory table. The contents of the populated memory
table will simply be the data provided for the end user's report design.
Next we define a dataselection, via the menu New and
selecting either using the 'Query wizard' or the 'Query
designer'. For demo purposes we just use the Query wizard.

The wizard have obtained all the tables known to the application
server via the given published query. Its possible to filter or modify what
tables are available for the end user report designer to use, by putting some
code in the query services OnApproveMetaData event.
Lets select for example the Customer, and simply go thru the
wizard step by step. Finally we choose to see what the query brings back to
us.

And when we close that data preview, we will see a box containing the fields
of the defined query.

Now its possible to return to the designer tab where we now can select the
chosen queries and drag and drop the fields to the report.

Limitations of end users freedom
One of the biggest problems with end user report designer tools, is that the
end user often gets full access to a database. This problem can be solved
efficiently using kbmMW as a virtual database.
All requests for data are going thru kbmMW, and thus all the requests can be
monitored, data selection limited, requests modified etc. to provide the
level of security that is required.
Also consider that users are - usually - not programmers and do not
understand the potential performance hit a given report could pose to a
database. I.e. selecting an open join between multiple tables with millions of
rows in each is something that can bring even the best database to its knees.
This is another reason why there should be implemented quite strict limitations
or control over what end users are allowed to do in the reports.
As kbmMW is there as the intermediate, thats a natural place to put the
restrictions.
Kim Madsen
(Top)
|