private void flatten(VariableRestrictionDescr descr) {
AnalyticsData data = AnalyticsDataFactory.getAnalyticsData();
Variable variable = data.getVariableByRuleAndVariableName(currentRule
.getRuleName(), descr.getIdentifier());
VariableRestriction restriction = new VariableRestriction();
restriction.setRuleId(currentRule.getId());
restriction.setRuleName(currentRule.getRuleName());
restriction.setPatternId(currentPattern.getId());
restriction.setPatternIsNot(currentPattern.isPatternNot());
restriction.setConstraintId(currentConstraint.getId());
restriction.setFieldId(currentConstraint.getFieldId());
restriction.setEvaluator(descr.getEvaluator());
restriction.setVariableId(variable.getId());
restriction.setVariableName(descr.getIdentifier());
// Set field value, if it is unset.
currentField.setFieldType(Field.FieldType.VARIABLE);
data.save(restriction);