See: Description
| Interface | Description |
|---|---|
| NumberRange |
| Class | Description |
|---|---|
| NumberGenerator | |
| NumberGenerators |
Contains functionality for generating unique numbers, used when creating new business object instances.
A certain business-type, can have a set of number generators associated. These numbergenerators are represented themselves by businessobjects of type "TVC Number Generator Settings".
To associate a new number generator to be used for when creating business objects of a certain type, simply add such a number generator by running following MQL/TCL code:
mql add bus \
"TVC Number Generator Settings" \
"type_MyType" \
"A-Size" \
vault "TVC Administration" \
policy "TVC Number Generator Settings" \
"TVC Number" "0" \
"TVC Digits" "16" \
"TVC Prefix" "A-" \
"TVC Suffix" "-XXX"
This number generator is associated to the type (or any sub-type) registered through the symbolic name: type_MyType. You can either use symbolic names, or real names.
The name of this number generator is "A-Size".
This number generator creates numbers according to this format: A-0000000000000001-XXX
Explanation:
When allocating new numbers using a number generator, you can simply do following:
NumberGenerators ng = NumberGenerators.get(type);
NumberGenerator gen = ng.getByName("A-Size");
String number = gen.allocate();
OR:
NumberGenerators ng = NumberGenerators.get(type);
NumberGenerator gen = ng.findMostSuitable(1); // 1 = the number of "numbers" to generate
String number = gen.allocate();
If you want to allocate more than one number, and you know the amount of numbers to be generated, then you can do this by using the following code example. (Please note that this approach is much faster than allocating the numbers in a loop, one-by-one).
NumberGenerator gen = ...
NumberRange range = gen.allocate(100); // allocate 100 numbers...
Iterator<String> itr = range.getNumbers();
while (itr.hasNext()) {
String number = itr.next();
}
Copyright ? Technia AB. All Rights Reserved.