Closed Bernardo-MG closed 9 years ago
As creating a completely new DSL may take much more time than it's worth the time, and would require a new parser, it is preferably to keep using YAML for the new DSL.
According to this, the DSL could be similar to:
transaction_record:
id: acknowledgement
head: 'ACK'
rules:
- sequence:
- field: creation_date_time
- field: original_group_id
- field: original_transaction_sequence_n
- field: original_transaction_type
- field: creation_title
- field: submitter_creation_n
- field: recipient_creation_n
- field: processing_date
- field: transaction_status
Compare to the current configuration for the same record:
acknowledgement:
id: acknowledgement
record_type: 'ACK'
rule_type: transaction
rules:
- group_type: sequence
rules:
- rule_type: field
id: creation_date_time
- rule_type: field
id: original_group_id
- rule_type: field
id: original_transaction_sequence_n
- rule_type: field
id: original_transaction_type
- rule_type: field
id: creation_title
- rule_type: field
id: submitter_creation_n
- rule_type: field
id: recipient_creation_n
- rule_type: field
id: processing_date
- rule_type: field
id: transaction_status
This example is much less verbose, and easier to read.
A more complex example:
group:
id: acknowledgement_transaction
rules:
- sequence:
- record: acknowledgement
- record:
- message
- optional
- at_least_one
- option:
- sequence:
- record: agreement
- sequence:
- record: work
- record:
- work_conflict
- optional
Comes from
acknowledgement_transaction:
id: acknowledgement_transaction
rule_type: group
rules:
- group_type: sequence
rules:
- rule_type: record
id: acknowledgement
- rule_type: record
id: message
modifiers:
- optional
- at_least_one
- group_type: option
rules:
- group_type: sequence
rules:
- rule_type: record
id: agreement
- group_type: sequence
rules:
- rule_type: record
id: work
- rule_type: record
id: work_conflict
modifiers:
- optional
Note that if a rule has modifiers, then that rule becomes a list, with the rule name follows by the modifiers.
Still, there are other extensions needed.
For example. It should be posible to define blank rules in the configuration.
Something like this:
group:
id: acknowledgement_transaction
rules:
- sequence:
- record: acknowledgement
- record: blank_20
Should become:
group:
id: acknowledgement_transaction
rules:
- sequence:
- record: acknowledgement
- record: blank(20)
Where the number in parenthesis should be parsed, to indicate the size of the blank record.
The at_least_one and at_least_two modifiers should work in some other way. Probably an at_least(x) modifier, where x is the minimum number of apparitions.
The config files use the enhanced style. The factories now need to be cleaned up to work better with them.
In the future, a more detailed DSL may be needed, for now this probably, I hope, will be enough.
The YAML files used to set up the records for the factory are becomming too complex. It would be better creating and using a DSL for this job.