The Random DataSource Wizard is shown in Figure 14.1, “Random DataSource Wizard”.
Name: Enter the DataSource name in the text box. This should be a unique name.
Description: Any extra description that is used to describe the data source can be entered in the Description text box.
Count: The number of records
that should be generated. You can use ${substitution}
of dynamic parameters
here, so that the caller can supply the count value.
The remaining UI items on this page allow you to define the schema and value options for the records you wish to create. In the screenshot shown above, you can see five columns defined.
When a column is created or edited, you will see Figure 14.2, “Edit Column”.
This dialog allows you to specify the name and type of the column and then choose how the value should be constructed. Value Type allows you to choose Expression, Literal or Script.
The Expression option provides three modes, either an auto-increment value, a value range, or a set of predefined values.
The auto-increment option will generate an incremental progression of values in any of the available data types. The first value will be the logical "zero" element - which is 0 for numeric types, false for Boolean, and 1970-01-01 for Dates (the beginning of the Unix Epoch). When a limit of the data type is reached (e.g. for byte, at 127) the value will be reset to the minimum supported value (so for byte, -128) and the sequence will proceed.
If the range option is chosen, you should enter the
first and last allowed values. These values may include ${substitution}
strings. For example, for an Integer between 5 and 10,
enter First=5
and Last=10
.
Range has special behaviour for Strings, Doubles and Floats.
String: The first and last strings are padded with spaces as necessary to make them the same length. Then, for each character, a random value is chosen between (inclusive) the corresponding character position from each string, so H and W might give P, for example, but never A or Z. Here is an example:
String Range S1000000A to S2999999Z
This allows realistic looking Singapore ICs to be generated. The first letter will always be S (S->S), the second letter will be either 1 or 2 (1->2) subsequent digits might be anything (0->9), finishing with an uppercase character (A-Z) (representing the checksum, which of course is random, so it will not usually be correct). Similarly,
String Range Mr Aaaaaaa to Mr Zzzzzz
allows random names. Of course you could separate Title as a set of Values (see later) Dr,Mr,Ms etc. for even more flexibility.
Doubles and Floats: To generate
a random floating point number between 1 and 10, you can enter First=1
and
Last=10
, as you would expect. You will get a random number with the full
precision of the data type, e.g. 5.183456738923. If you want a number that
represents an amount, you might want something like 5.18 instead. To obtain
this, specify the number of decimal spaces in the First and Last strings:
First=1.00
Last=10.00
will give you floating point numbers, but only to two
decimal places. This option only works for up to four decimal places. Thus
if you want a full precision decimal in the range 0.5 to 1.5, you should specify
First=0.50000
Last=1.50000
(the five decimal places exceeds the limit of four,
so full precision will be used. If you use 0.5 to 1.5, you will only get one
decimal place of precision, as described earlier.
The alternative to a range is to specify allowed values, that are comma separated. For example:
Normal, Warning, Critical
Each option here will have a one-third chance of being selected for each record. If you want more Normals, then just add more to the list:
Normal, Normal, Normal, Warning, Critical
Now Normal will occur with higher frequency than Warning or Critical. If you need
a comma to appear in one of your values, you should escape it with a backslash.
For example "Hello\, World, Goodbye" has two values, the first being "Hello, World".
Once again, you can use ${substitution}
strings in the values.
The literal type supports ${substitution}
and then sets the value
into the record. This can be used when you want a specific value to occur in
every record.
The script type supports ${substitution}
. It evaluates the script
using the JavaScript engine and then inserts the value into the record.
Use this when you want a logical progression of values, for example
an auto-increment of ID, or a calculated value, such as today's date. For
today's date, it may be preferable to perform the calculation once and reuse
the value for efficiency, as the script will be run for each record generated.