DataBasedDMGenerator
Sometimes, we have a requirement to generate multiple DMs based on how many rows were returned from the DB for some particular column. To achieve this use the DataBasedDMGenerator element. This is the same as the DM definition except for a SqlDiscriminator element. This element provides a columnName from the query based on which application generates the separate DMs.
<
TLVList
xmlns
=
"http://www.onenetwork.com/Platform"
>
<
TLV
>
<
Name
>MyFirstTLV</
Name
>
<
Description
>My First TLV Report Example</
Description
>
<
Bucketization
>DAILY</
Bucketization
>
<
BucketsPerPage
>7</
BucketsPerPage
>
<
Filters
bindSqlNulls
=
"true"
>
<
CustomFilterField
>
<
FieldRef
category
=
"PDF"
levelType
=
"Undefined"
>
<
FieldName
>DateRange</
FieldName
>
</
FieldRef
>
<
Hidden
>false</
Hidden
>
<
Editable
>true</
Editable
>
<
Type
>DATE_RANGE</
Type
>
<
Optional
>false</
Optional
>
<
DateRangeMapping
fromSqlName
=
"DATE_RANGE_START"
toSqlName
=
"DATE_RANGE_END"
/>
</
CustomFilterField
>
<
DateRange
start
=
"$NULL$"
end
=
"$NULL$"
/>
</
Filters
>
<
DMRef
>ZBKS.BookIssued</
DMRef
>
<
DataBasedDMGenerator
bucketization
=
"DAILY"
>
<
Name
>DataBasedDMGeneratorExample</
Name
>
<
DisplayName
>Test Display Name - {0}</
DisplayName
>
<
SqlDefName
>SqlDiscriminatorExample</
SqlDefName
>
<
SqlQuantityField
levelType
=
"Undefined"
>
<
FieldName
>ship_count</
FieldName
>
</
SqlQuantityField
>
<
SqlDateField
levelType
=
"Undefined"
>
<
FieldName
>the_date</
FieldName
>
</
SqlDateField
>
<
SqlDiscriminator
column
=
"trans_name"
/>
</
DataBasedDMGenerator
>
</
TLVList
>
For example, assume we have multiple custom definitions for the Shipment model in our SPT. For each uniquely fetched custom definition, we want to generate a separate DM at run time. We would write a query that returns the following results:
25/06/2011, 12, Standard Shipment
27/06/2011, 1, ProgressiveRetailer-Shipment
24/06/2011, 4, Standard Shipment
20/06/2011, 5, ONE Shipment
If you provide the third column name as your discriminator, Platform will create one DataMeasure for each "distinct" value in the third column. For the above example, 3 DMs will be generated. One for each of Standard Shipment, ProgressiveRetailer-Shipment and ONE Shipment
We can use any relevant column from the query as a SqlDiscriminator column. Also, the "DisplayName" field supports message formatting as follows:
<
DisplayName
>Request Quanity: {0}</
DisplayName
>
Platform will substitute the discriminator value for {0}. For example:
Request Quantity: Standard Shipment
Request Quantity: ONE Shipment
Just like DM, we can reuse DataBasedDMGenerators across TLVs by defining them in the .dms file and referencing them through a DMRef.