[Formed-commits] r414 - in trunk: . formed/formed/plugins/export
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Tue Oct 12 16:39:13 CEST 2010
Author: roland
Date: 2010-10-12 16:39:13 +0200 (Tue, 12 Oct 2010)
New Revision: 414
Modified:
trunk/ChangeLog
trunk/formed/formed/plugins/export/rules_sh.py
Log:
Ignore rules if fields in repeat group
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2010-10-11 12:37:08 UTC (rev 413)
+++ trunk/ChangeLog 2010-10-12 14:39:13 UTC (rev 414)
@@ -1,3 +1,8 @@
+2010-10-12 Roland Geider <roland.geider at intevation.de>
+
+ * formed/formed/plugins/export/rules_sh.py: Ignore rules if any fields
+ in the rule are in a repeat group
+
2010-10-11 Roland Geider <roland.geider at intevation.de>
* formed/plugins/export/rules_sh.py: Added support to more opperators
Modified: trunk/formed/formed/plugins/export/rules_sh.py
===================================================================
--- trunk/formed/formed/plugins/export/rules_sh.py 2010-10-11 12:37:08 UTC (rev 413)
+++ trunk/formed/formed/plugins/export/rules_sh.py 2010-10-12 14:39:13 UTC (rev 414)
@@ -197,6 +197,7 @@
tag = int(rule.getTag())
except ValueError:
tag = 1000+num
+
name = rule.getDescription().replace("'", '"')
desc = rule.getValue().replace("'", '"')
add_sql = base_sql % {
@@ -253,11 +254,33 @@
all_rules = list(document.findAllByClass(data.RuleLeaf, mode, allModes))
error_rules = []
known_rules = []
+ rg_fields = []
for idx, rule in enumerate(all_rules):
- if rule.getMark().find('error') < 0: continue
- # filter out already generated rules.
+ ignore_rule = False
+
+ # If rule does not result in error, ignore
+ if rule.getMark().find('error') < 0:
+ ignore_rule = True
+
+ # If rule already generated, ignore
rule_str = recursive_parse(rule.getExpr().prog, document)
- if rule_str in known_rules: continue
+ if rule_str in known_rules:
+ ignore_rule = True
+
+ # If field is in in a repeat group, ignore
+ # TODO: if this is needed, the SQL statements have to be adapted
+ for dependent_field in rule.getExpr().getDependencies():
+ field = document.getNodeComponentByName(dependent_field, mode, allModes)
+ if field in rg_fields:
+ ignore_rule = True
+ for parent in field.pathToRoot(True):
+ if isinstance(parent, data.RepeatNode):
+ rg_fields.append(field)
+ ignore_rule = True
+
+ if ignore_rule:
+ continue
+
error_rules.append(rule)
known_rules.append(rule_str)
sql = generate_tagging(error_rules, document)
More information about the Formed-commits
mailing list