Search in sources :

Example 11 with IndicatorCategory

use of org.talend.dataquality.indicators.definition.IndicatorCategory in project tdq-studio-se by Talend.

the class TOPRepositoryService method createParserRuleItem.

public void createParserRuleItem(ArrayList<HashMap<String, Object>> values, String parserRuleName) {
    ParserRule parserRule = null;
    DqRuleBuilder ruleBuilder = new DqRuleBuilder();
    boolean ruleInitialized = ruleBuilder.initializeParserRuleBuilder(parserRuleName);
    if (ruleInitialized) {
        parserRule = ruleBuilder.getParserRule();
    }
    TaggedValueHelper.setValidStatus(true, parserRule);
    for (HashMap<String, Object> expression : values) {
        parserRule.addExpression(expression.get(RULE_NAME).toString(), expression.get(RULE_TYPE) instanceof Integer ? Integer.toString((Integer) expression.get(RULE_TYPE)) : expression.get(RULE_TYPE).toString(), expression.get(RULE_VALUE).toString());
    }
    IndicatorCategory ruleIndicatorCategory = DefinitionHandler.getInstance().getDQRuleIndicatorCategory();
    if (ruleIndicatorCategory != null && !parserRule.getCategories().contains(ruleIndicatorCategory)) {
        parserRule.getCategories().add(ruleIndicatorCategory);
    }
    IFolder folder = ResourceManager.getRulesParserFolder();
    TypedReturnCode<Object> returnObject = ElementWriterFactory.getInstance().createdRuleWriter().create(parserRule, folder);
    Object object = returnObject.getObject();
    RuleRepNode parserRuleNode = RepositoryNodeHelper.recursiveFindRuleParser(parserRule);
    BusinessRuleItemEditorInput parserRuleEditorInput = new BusinessRuleItemEditorInput(parserRuleNode);
    CorePlugin.getDefault().openEditor(parserRuleEditorInput, DQRuleEditor.class.getName());
    refresh(object);
}
Also used : ParserRule(org.talend.dataquality.rules.ParserRule) BusinessRuleItemEditorInput(org.talend.dataprofiler.core.ui.editor.dqrules.BusinessRuleItemEditorInput) DQRuleEditor(org.talend.dataprofiler.core.ui.editor.dqrules.DQRuleEditor) DqRuleBuilder(org.talend.dq.dqrule.DqRuleBuilder) RuleRepNode(org.talend.dq.nodes.RuleRepNode) IndicatorCategory(org.talend.dataquality.indicators.definition.IndicatorCategory) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IFolder(org.eclipse.core.resources.IFolder)

Example 12 with IndicatorCategory

use of org.talend.dataquality.indicators.definition.IndicatorCategory in project tdq-studio-se by Talend.

the class IndicatorHelper method getIndicatorValue.

/**
 * DOC bZhou Comment method "getIndicatorValue".
 *
 * @param indicator
 * @return
 */
public static String getIndicatorValue(Indicator indicator) {
    IndicatorsSwitch<String> mySwitch = new IndicatorsSwitch<String>() {

        @Override
        public String caseAverageLengthIndicator(AverageLengthIndicator object) {
            return createStandardNumber(object.getAverageLength());
        }

        @Override
        public String caseBlankCountIndicator(BlankCountIndicator object) {
            return String.valueOf(object.getBlankCount());
        }

        @Override
        public String caseDefValueCountIndicator(DefValueCountIndicator object) {
            return String.valueOf(object.getDefaultValCount());
        }

        @Override
        public String caseDistinctCountIndicator(DistinctCountIndicator object) {
            return String.valueOf(object.getDistinctValueCount());
        }

        @Override
        public String caseDuplicateCountIndicator(DuplicateCountIndicator object) {
            return String.valueOf(object.getDuplicateValueCount());
        }

        @Override
        public String caseMaxLengthIndicator(MaxLengthIndicator object) {
            return String.valueOf(object.getLength());
        }

        @Override
        public String caseMeanIndicator(MeanIndicator object) {
            return createStandardNumber(object.getMean());
        }

        @Override
        public String caseMedianIndicator(MedianIndicator object) {
            return createStandardNumber(object.getMedian());
        }

        @Override
        public String caseMinLengthIndicator(MinLengthIndicator object) {
            return String.valueOf(object.getLength());
        }

        @Override
        public String caseModeIndicator(ModeIndicator object) {
            return String.valueOf(object.getMode());
        }

        @Override
        public String caseNullCountIndicator(NullCountIndicator object) {
            return String.valueOf(object.getNullCount());
        }

        @Override
        public String casePatternMatchingIndicator(PatternMatchingIndicator object) {
            return String.valueOf(object.getMatchingValueCount());
        }

        @Override
        public String caseRowCountIndicator(RowCountIndicator object) {
            return String.valueOf(object.getCount());
        }

        @Override
        public String caseUniqueCountIndicator(UniqueCountIndicator object) {
            return String.valueOf(object.getUniqueValueCount());
        }

        @Override
        public String caseValueIndicator(ValueIndicator object) {
            return object.getValue();
        }

        @Override
        public String caseValidPhoneCountIndicator(ValidPhoneCountIndicator object) {
            return String.valueOf(object.getValidPhoneNumCount());
        }

        @Override
        public String casePossiblePhoneCountIndicator(PossiblePhoneCountIndicator object) {
            return String.valueOf(object.getPossiblePhoneCount());
        }

        @Override
        public String caseValidRegCodeCountIndicator(ValidRegCodeCountIndicator object) {
            return String.valueOf(object.getValidRegCount());
        }

        @Override
        public String caseInvalidRegCodeCountIndicator(InvalidRegCodeCountIndicator object) {
            return String.valueOf(object.getInvalidRegCount());
        }

        @Override
        public String caseWellFormE164PhoneCountIndicator(WellFormE164PhoneCountIndicator object) {
            return String.valueOf(object.getWellFormE164PhoneCount());
        }

        @Override
        public String caseWellFormIntePhoneCountIndicator(WellFormIntePhoneCountIndicator object) {
            return String.valueOf(object.getWellFormIntePhoneCount());
        }

        @Override
        public String caseWellFormNationalPhoneCountIndicator(WellFormNationalPhoneCountIndicator object) {
            return String.valueOf(object.getWellFormNatiPhoneCount());
        }
    };
    // TDQ-11114: consider the UDI type
    IndicatorSqlSwitch<String> sqlSwitch = new IndicatorSqlSwitch<String>() {

        @Override
        public String caseWhereRuleIndicator(WhereRuleIndicator object) {
            return String.valueOf(object.getUserCount());
        }

        @Override
        public String caseUserDefIndicator(UserDefIndicator object) {
            // TDQ-11114: get the correct value for user define realvalue indicator
            if (object instanceof UserDefIndicator) {
                UserDefIndicator userDefineIndicator = object;
                IndicatorCategory category = IndicatorCategoryHelper.getCategory(userDefineIndicator.getIndicatorDefinition());
                if (IndicatorCategoryHelper.isUserDefRealValue(category)) {
                    return String.valueOf(userDefineIndicator.getRealValue());
                }
            }
            // TDQ-11485: fix the match udi get result value error
            return String.valueOf(object.getIntegerValue());
        }

        @Override
        public String caseJavaUserDefIndicator(JavaUserDefIndicator object) {
            return String.valueOf(object.getUserCount());
        }
    };
    String result = mySwitch.doSwitch(indicator);
    return result == null ? sqlSwitch.doSwitch(indicator) : result;
}
Also used : BlankCountIndicator(org.talend.dataquality.indicators.BlankCountIndicator) MedianIndicator(org.talend.dataquality.indicators.MedianIndicator) UniqueCountIndicator(org.talend.dataquality.indicators.UniqueCountIndicator) ModeIndicator(org.talend.dataquality.indicators.ModeIndicator) NullCountIndicator(org.talend.dataquality.indicators.NullCountIndicator) DistinctCountIndicator(org.talend.dataquality.indicators.DistinctCountIndicator) WellFormIntePhoneCountIndicator(org.talend.dataquality.indicators.WellFormIntePhoneCountIndicator) PatternMatchingIndicator(org.talend.dataquality.indicators.PatternMatchingIndicator) WhereRuleIndicator(org.talend.dataquality.indicators.sql.WhereRuleIndicator) IndicatorCategory(org.talend.dataquality.indicators.definition.IndicatorCategory) IndicatorsSwitch(org.talend.dataquality.indicators.util.IndicatorsSwitch) RowCountIndicator(org.talend.dataquality.indicators.RowCountIndicator) MeanIndicator(org.talend.dataquality.indicators.MeanIndicator) JavaUserDefIndicator(org.talend.dataquality.indicators.sql.JavaUserDefIndicator) UserDefIndicator(org.talend.dataquality.indicators.sql.UserDefIndicator) IndicatorSqlSwitch(org.talend.dataquality.indicators.sql.util.IndicatorSqlSwitch) PossiblePhoneCountIndicator(org.talend.dataquality.indicators.PossiblePhoneCountIndicator) WellFormE164PhoneCountIndicator(org.talend.dataquality.indicators.WellFormE164PhoneCountIndicator) ValidPhoneCountIndicator(org.talend.dataquality.indicators.ValidPhoneCountIndicator) DuplicateCountIndicator(org.talend.dataquality.indicators.DuplicateCountIndicator) MaxLengthIndicator(org.talend.dataquality.indicators.MaxLengthIndicator) MaxValueIndicator(org.talend.dataquality.indicators.MaxValueIndicator) MinValueIndicator(org.talend.dataquality.indicators.MinValueIndicator) ValueIndicator(org.talend.dataquality.indicators.ValueIndicator) ValidRegCodeCountIndicator(org.talend.dataquality.indicators.ValidRegCodeCountIndicator) MinLengthIndicator(org.talend.dataquality.indicators.MinLengthIndicator) InvalidRegCodeCountIndicator(org.talend.dataquality.indicators.InvalidRegCodeCountIndicator) JavaUserDefIndicator(org.talend.dataquality.indicators.sql.JavaUserDefIndicator) DefValueCountIndicator(org.talend.dataquality.indicators.DefValueCountIndicator) AverageLengthIndicator(org.talend.dataquality.indicators.AverageLengthIndicator) WellFormNationalPhoneCountIndicator(org.talend.dataquality.indicators.WellFormNationalPhoneCountIndicator)

Example 13 with IndicatorCategory

use of org.talend.dataquality.indicators.definition.IndicatorCategory in project tdq-studio-se by Talend.

the class UDIFactory method createIndicator.

@Deprecated
public static Indicator createIndicator(IndicatorDefinition indicatorDefinition) {
    IndicatorCategory category = UDIHelper.getUDICategory(indicatorDefinition);
    Indicator indicator = null;
    if (category != null) {
        if (category.equals(DefinitionHandler.getInstance().getUserDefinedCountIndicatorCategory())) {
            indicator = IndicatorsFactory.eINSTANCE.createRowCountIndicator();
        } else if (category.equals(DefinitionHandler.getInstance().getUserDefinedMatchIndicatorCategory())) {
            indicator = IndicatorsFactory.eINSTANCE.createRegexpMatchingIndicator();
        } else if (category.equals(DefinitionHandler.getInstance().getUserDefinedFrequencyIndicatorCategory())) {
            indicator = IndicatorsFactory.eINSTANCE.createFrequencyIndicator();
        }
        if (indicator != null) {
            IndicatorParameters indicParams = IndicatorsFactory.eINSTANCE.createIndicatorParameters();
            indicator.setParameters(indicParams);
            indicator.setName(indicatorDefinition.getName());
        }
    }
    return indicator;
}
Also used : IndicatorParameters(org.talend.dataquality.indicators.IndicatorParameters) IndicatorCategory(org.talend.dataquality.indicators.definition.IndicatorCategory) UserDefIndicator(org.talend.dataquality.indicators.sql.UserDefIndicator) Indicator(org.talend.dataquality.indicators.Indicator)

Example 14 with IndicatorCategory

use of org.talend.dataquality.indicators.definition.IndicatorCategory in project tdq-studio-se by Talend.

the class CategoryHandler method buildCategories.

/**
 * DOC xqliu Comment method "buildCategories".
 *
 * @return
 */
private static Map<IndicatorCategory, List<IndicatorDefinition>> buildCategories() {
    Map<IndicatorCategory, List<IndicatorDefinition>> categories = new HashMap<IndicatorCategory, List<IndicatorDefinition>>();
    for (IndicatorDefinition indicatorDefinition : getShowIndicatorsDefinitions()) {
        IndicatorCategory category = IndicatorCategoryHelper.getCategory(indicatorDefinition);
        if (category == null) {
            category = getIndicatorCategory();
        }
        if (category != null) {
            List<IndicatorDefinition> list = categories.get(category);
            if (list == null) {
                List<IndicatorDefinition> tempList = new ArrayList<IndicatorDefinition>();
                tempList.add(indicatorDefinition);
                categories.put(category, tempList);
            } else {
                list.add(indicatorDefinition);
            }
        }
    }
    return categories;
}
Also used : HashMap(java.util.HashMap) IndicatorCategory(org.talend.dataquality.indicators.definition.IndicatorCategory) ArrayList(java.util.ArrayList) EList(org.eclipse.emf.common.util.EList) ArrayList(java.util.ArrayList) List(java.util.List) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition)

Example 15 with IndicatorCategory

use of org.talend.dataquality.indicators.definition.IndicatorCategory in project tdq-studio-se by Talend.

the class ImportFactory method createAndStoreParserRule.

/**
 * DOC klliu Comment method "createAndStoreParserRule".
 *
 * @param prParameters
 * @param selectionFolder
 */
public static void createAndStoreParserRule(ParserRuleParameters prParameters, IFolder selectionFolder, String name) {
    DqRuleBuilder ruleBuilder = new DqRuleBuilder();
    boolean ruleInitialized = ruleBuilder.initializeParserRuleBuilder(prParameters.label);
    if (ruleInitialized) {
        ParserRule parserRule = ruleBuilder.getParserRule();
        parserRule.setName(name);
        TaggedValueHelper.setValidStatus(true, parserRule);
        List<ParserRuleTdExpresstion> prExpresstions = prParameters.getPrExpresstions();
        for (ParserRuleTdExpresstion prtde : prExpresstions) {
            parserRule.addExpression(prtde.name, prtde.type, prtde.value);
        }
        IndicatorCategory ruleIndicatorCategory = DefinitionHandler.getInstance().getDQRuleIndicatorCategory();
        if (ruleIndicatorCategory != null && !parserRule.getCategories().contains(ruleIndicatorCategory)) {
            parserRule.getCategories().add(ruleIndicatorCategory);
        }
        ElementWriterFactory.getInstance().createdRuleWriter().create(parserRule, selectionFolder);
    }
}
Also used : ParserRule(org.talend.dataquality.rules.ParserRule) IndicatorCategory(org.talend.dataquality.indicators.definition.IndicatorCategory) DqRuleBuilder(org.talend.dq.dqrule.DqRuleBuilder)

Aggregations

IndicatorCategory (org.talend.dataquality.indicators.definition.IndicatorCategory)17 TdExpression (org.talend.cwm.relational.TdExpression)5 ArrayList (java.util.ArrayList)4 IFolder (org.eclipse.core.resources.IFolder)3 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)2 IndicatorDefinition (org.talend.dataquality.indicators.definition.IndicatorDefinition)2 UDIndicatorDefinition (org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition)2 ParserRule (org.talend.dataquality.rules.ParserRule)2 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 List (java.util.List)1 CoreException (org.eclipse.core.runtime.CoreException)1 EList (org.eclipse.emf.common.util.EList)1 LoginException (org.talend.commons.exception.LoginException)1 PersistenceException (org.talend.commons.exception.PersistenceException)1 Property (org.talend.core.model.properties.Property)1 Folder (org.talend.core.model.repository.Folder)1 BusinessRuleItemEditorInput (org.talend.dataprofiler.core.ui.editor.dqrules.BusinessRuleItemEditorInput)1 DQRuleEditor (org.talend.dataprofiler.core.ui.editor.dqrules.DQRuleEditor)1 AverageLengthIndicator (org.talend.dataquality.indicators.AverageLengthIndicator)1