Search in sources :

Example 16 with ParserRule

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);
}
Also used : ParserRule(org.talend.dataquality.rules.ParserRule) TdExpression(org.talend.cwm.relational.TdExpression) IndicatorCategory(org.talend.dataquality.indicators.definition.IndicatorCategory) IFolder(org.eclipse.core.resources.IFolder)

Aggregations

ParserRule (org.talend.dataquality.rules.ParserRule)16 ArrayList (java.util.ArrayList)7 IFile (org.eclipse.core.resources.IFile)7 TdExpression (org.talend.cwm.relational.TdExpression)7 File (java.io.File)6 IFolder (org.eclipse.core.resources.IFolder)6 Test (org.junit.Test)6 BufferedWriter (java.io.BufferedWriter)4 FileWriter (java.io.FileWriter)4 ImportObject (org.talend.dataprofiler.core.ui.action.actions.ImportObject)4 ReturnCode (org.talend.utils.sugars.ReturnCode)4 IndicatorCategory (org.talend.dataquality.indicators.definition.IndicatorCategory)3 HashMap (java.util.HashMap)2 Map (java.util.Map)2 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)2 MatchRuleDefinition (org.talend.dataquality.rules.MatchRuleDefinition)2 DqRuleBuilder (org.talend.dq.dqrule.DqRuleBuilder)2 RuleRepNode (org.talend.dq.nodes.RuleRepNode)2 CSVWriter (com.talend.csv.CSVWriter)1 FileNotFoundException (java.io.FileNotFoundException)1