Configuring default behaviour
Rules can specify configuration for copying and superseding files. Parts of this configuration can be the same for many rules. Repeating this configuration in each rule can bloat the configuration file and make it difficult to apply changes consistently when requirements change.
Consider the following application Supersede.json
configuration:
{
"Supersede": {
"Rules": [
{
"Pattern": "(?<SheetNumber>.+) - (?<SheetName>.+) \\((?<Revision>.+)\\)",
"Extensions": [ ".pdf" ],
"Copy": {
"Enabled": true,
"Path": "..\\Current"
},
"Supersede": {
"Enabled": true,
"MatchFields": [ "SheetNumber" ],
"Mode": "Move",
"Path": "..\\Superseded"
}
},
{
"Pattern": "(?<SheetNumber>.+) \\((?<Revision>.+)\\)",
"Extensions": [ ".dwg" ],
"Copy": {
"Enabled": true,
"Path": "..\\Current"
},
"Supersede": {
"Enabled": true,
"MatchFields": [ "SheetNumber" ],
"Mode": "Move",
"Path": "..\\Superseded"
}
}
]
}
}
This can be simplified to the following:
{
"Supersede": {
"Copy": {
"Enabled": true,
"Path": "..\\Current"
},
"Supersede": {
"Enabled": true,
"Mode": "Move",
"Path": "..\\Superseded"
},
"Rules": [
{
"Pattern": "(?<SheetNumber>.+) - (?<SheetName>.+) \\((?<Revision>.+)\\)",
"Extensions": [ ".pdf" ],
"Supersede": {
"MatchFields": [ "SheetNumber" ]
}
},
{
"Pattern": "(?<SheetNumber>.+) \\((?<Revision>.+)\\)",
"Extensions": [ ".dwg" ],
"Supersede": {
"MatchFields": [ "SheetNumber" ]
}
}
]
}
}
The default Copy
configuration object (lines 3-6) and default Supersede
configuration object (lines 7-11) specify some default settings that will apply to any Rules
that don't specify these settings.
This means that copying or superseding can be enabled or disabled for any rules that don’t explicitly specify these settings. Similarly, the folder paths can easily be updated consistently as well.