Sequence generation
If a substitution is followed by a NFA(GEN_NEW_SEQUENCE)
this means that one can generate a unique number (only whole
numbers are used) to act as a substitute to the order number.
Case: Substitution of fields with content.
Status: ACTIVE
SUBSTITUTION=(#4,ORDNO.#3),
KEYS((#3,ORDNO.#1),(#4,ORDNO.#2)), NFA(GEN_NEW_SEQNUM)
Field #3 is Item String (char)
Field #4 is order number (Long)
these are used to generate unique order numbers.
There can be no empty lines in the ORDNO file.
If the file ORDNO contains orders such as:
INSIDE;1;1;
INSIDE;2;7;
PEN/GOLD;1;5;
It looks like:
INSIDE;1;1;
INSIDE;2;7;
PEN/GOLD;1;5;
TOP/GOLD;900003;8; <<
BOTTOM/GREY;900005;9;
The next generated order number has been chosen that is maximum the existing order number plus 1.
Case: Creation
When a Record finds a SUBSTITUTION Token, it will call up the static
Substitution::ReadSubstitution
function for this
Record.
Parsed keys result in the creation of a new FileDefColl
by calling the FileDef
for the
file. FileDef::CreateColl
is parsed as a BaseFileData
pointer for the correct/expected type. In addition
information about the index number (the position of the column), the FileDef::CreateColl
returns a pointer to the newly created FileDefColl
. It is then stored in a new vector arKeys.
A new Substitution (,y, ? ) is then created.
Case: Read
When a Record has conducted a Read
/
FetchData
it calls for the record substitutions one by
one.
Each substitution will prompt the primary record for a value and perform a
hash calculation. The hash calculation is used to access the primary Key Map for the primary
Keys relevant indexes. They are accessed one at the time and the primary key is matched to
the primary Record Entry. The primary record entry BaseFileData
performs this and comparisons/matches are conducted
polymorphically. If a match is found the substitution prompt the next keys/FileDefColl
for the entry with the same index and the record
entry performs the matching, etc.
If a match is found for the substitution, then it extracts the substitution
value from the FileDefColl
and call on the BaseFileData
to substitute/update this value.
Case: Read with NFA Skip
If a match is not found, then the substitution does not do anything.
Case: Read with NFA Sequence Generation
If a match is not found, then the substitution will react by generating a new sequence number.
The Substitution also asks the FileDef
to
add a new line, by appending a new entry to each FileDefColl
it has, default is a dummy holding a string. It then generates the
new sequence entry / number by asking the FileDefColl
.
FileDefColl
prompts the BaseFileData
to create a new DataEntry
of the correct type. This is placed in the last entry of the FileDefColl
, (the one just added by FileDef
)
Substitution also asks each of the keys (for example, FileDefColl
) to replace the last added index.
Case: Write
The Record is called to perform the write data method.
The Record will have each BaseFileData
retrieve the data from the global data in M3 PWB. This data is stored in the associated Data
Entry.
The substitution is run. If a substitution is found, then this will replace the record Entry with the replacement value. This is done by locating the primary key from prime Key Map, searching for a match on the primary key and checking all other keys for match. This process continues until a match is found or until there are no additional prime Keys with a hash key.
Case: Write with NFA Skip
Entries not found are ignored.
Case: Write with NFA Sequence Generation
Should always find a substitution.