use of org.talend.dataquality.rules.ParserRule in project tdq-studio-se by Talend.
the class NewParserRulesWizard method createAndSaveCWMFile.
public TypedReturnCode<Object> createAndSaveCWMFile(ModelElement cwmElement) {
ParserRule parserRule = (ParserRule) cwmElement;
TaggedValueHelper.setValidStatus(true, parserRule);
if (isComeFromTestEditor()) {
// MOD klliu bug TDQ-4772 2012-03-20
// copy the informations of old Expressions for the new parser rule,and it's used when an new rule is
// created in testing rule editor.
List<TdExpression> ruleExpressions = parameter.getParserRule().getExpression();
for (TdExpression expression : ruleExpressions) {
parserRule.addExpression(expression.getName(), expression.getLanguage(), expression.getBody());
}
// ~
} else {
parserRule.addExpression(parameter.getParserRuleName(), parameter.getParserRuleType(), parameter.getParserRuleValue());
IndicatorCategory ruleIndicatorCategory = DefinitionHandler.getInstance().getDQRuleIndicatorCategory();
if (ruleIndicatorCategory != null && !parserRule.getCategories().contains(ruleIndicatorCategory)) {
parserRule.getCategories().add(ruleIndicatorCategory);
}
}
IFolder folder = parameter.getFolderProvider().getFolderResource();
return ElementWriterFactory.getInstance().createdRuleWriter().create(parserRule, folder);
}
Aggregations