Search in sources :

Example 16 with RegexpMatchingIndicator

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

the class AnalysisHelper method getPatterns.

public static List<Pattern> getPatterns(Analysis analysis) {
    List<Pattern> rets = new ArrayList<Pattern>();
    EList<Indicator> indicators = analysis.getResults().getIndicators();
    for (Indicator indicator : indicators) {
        if (indicator instanceof PatternMatchingIndicator) {
            IndicatorParameters parameters = ((PatternMatchingIndicator) indicator).getParameters();
            if (null != parameters && null != parameters.getDataValidDomain()) {
                rets.addAll(parameters.getDataValidDomain().getPatterns());
            }
        }
        // MOD yyi 2010-08-03 14292 Add dependency for children indicator in Column Set analysis
        if (indicator instanceof AllMatchIndicator) {
            EList<RegexpMatchingIndicator> list = ((AllMatchIndicator) indicator).getCompositeRegexMatchingIndicators();
            for (RegexpMatchingIndicator pattern : list) {
                IndicatorParameters parameters = pattern.getParameters();
                if (null != parameters && null != parameters.getDataValidDomain()) {
                    rets.addAll(parameters.getDataValidDomain().getPatterns());
                }
            }
        }
    // ~
    }
    return rets;
}
Also used : Pattern(org.talend.dataquality.domain.pattern.Pattern) PatternMatchingIndicator(org.talend.dataquality.indicators.PatternMatchingIndicator) AllMatchIndicator(org.talend.dataquality.indicators.columnset.AllMatchIndicator) IndicatorParameters(org.talend.dataquality.indicators.IndicatorParameters) ArrayList(java.util.ArrayList) RegexpMatchingIndicator(org.talend.dataquality.indicators.RegexpMatchingIndicator) PatternMatchingIndicator(org.talend.dataquality.indicators.PatternMatchingIndicator) RecordMatchingIndicator(org.talend.dataquality.indicators.columnset.RecordMatchingIndicator) RegexpMatchingIndicator(org.talend.dataquality.indicators.RegexpMatchingIndicator) Indicator(org.talend.dataquality.indicators.Indicator) AllMatchIndicator(org.talend.dataquality.indicators.columnset.AllMatchIndicator) UserDefIndicator(org.talend.dataquality.indicators.sql.UserDefIndicator)

Example 17 with RegexpMatchingIndicator

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

the class ModelElementDuplicateHandle method dupAnaWithoutBuiltInPattern.

/**
 * when duplicate an analysis,remove the built-in pattern. or else, the reference pattern will be copied as a built-in
 * pattern.
 *
 * @param oldModelElement
 * @return
 */
private ModelElement dupAnaWithoutBuiltInPattern(ModelElement oldModelElement) {
    ModelElement newModEle = null;
    if (!(oldModelElement instanceof Analysis)) {
        newModEle = (ModelElement) EMFSharedResources.getInstance().copyEObject(oldModelElement);
        return newModEle;
    }
    try {
        Analysis analysis = (Analysis) oldModelElement;
        EList<Indicator> indicators = analysis.getResults().getIndicators();
        List<Indicator> orignalIndicators = new ArrayList<Indicator>();
        orignalIndicators.addAll(indicators);
        Map<Indicator, List<Pattern>> map = new HashMap<Indicator, List<Pattern>>();
        // 2.after copy the analysis without built-in pattern, reset the built for the old analysis.
        for (Indicator indicator : indicators) {
            if (!(indicator instanceof PatternMatchingIndicator)) {
                continue;
            }
            List<Pattern> builtInLs = new ArrayList<Pattern>();
            if (indicator instanceof AllMatchIndicator) {
                EList<RegexpMatchingIndicator> list = ((AllMatchIndicator) indicator).getCompositeRegexMatchingIndicators();
                for (RegexpMatchingIndicator regxIndicator : list) {
                    builtInLs.addAll(regxIndicator.getParameters().getDataValidDomain().getBuiltInPatterns());
                    map.put(regxIndicator, builtInLs);
                    regxIndicator.getParameters().getDataValidDomain().getBuiltInPatterns().clear();
                }
            } else {
                builtInLs.addAll(indicator.getParameters().getDataValidDomain().getBuiltInPatterns());
                map.put(indicator, builtInLs);
                indicator.getParameters().getDataValidDomain().getBuiltInPatterns().clear();
            }
        }
        newModEle = (ModelElement) EMFSharedResources.getInstance().copyEObject(analysis);
        for (Indicator patternInd : map.keySet()) {
            patternInd.getParameters().getDataValidDomain().getBuiltInPatterns().addAll(map.get(patternInd));
        }
        ProxyRepositoryFactory.getInstance().getRepositoryFactoryFromProvider().getResourceManager().saveResource(analysis.eResource());
    } catch (Exception e) {
        LOG.error(e);
    }
    return newModEle;
}
Also used : Pattern(org.talend.dataquality.domain.pattern.Pattern) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) PatternMatchingIndicator(org.talend.dataquality.indicators.PatternMatchingIndicator) RegexpMatchingIndicator(org.talend.dataquality.indicators.RegexpMatchingIndicator) Indicator(org.talend.dataquality.indicators.Indicator) AllMatchIndicator(org.talend.dataquality.indicators.columnset.AllMatchIndicator) BusinessException(org.talend.commons.exception.BusinessException) ModelElement(orgomg.cwm.objectmodel.core.ModelElement) PatternMatchingIndicator(org.talend.dataquality.indicators.PatternMatchingIndicator) AllMatchIndicator(org.talend.dataquality.indicators.columnset.AllMatchIndicator) Analysis(org.talend.dataquality.analysis.Analysis) ArrayList(java.util.ArrayList) EList(org.eclipse.emf.common.util.EList) List(java.util.List) RegexpMatchingIndicator(org.talend.dataquality.indicators.RegexpMatchingIndicator)

Example 18 with RegexpMatchingIndicator

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

the class PatternsSelectPage method organizeTableInput.

/**
 * zshen.
 *
 * @return the input of table.
 */
private List<Map<Integer, RegexpMatchingIndicator>> organizeTableInput() {
    List<Map<Integer, RegexpMatchingIndicator>> returnList = new ArrayList<Map<Integer, RegexpMatchingIndicator>>();
    AllMatchIndicatorImpl allMatchIndicator = this.selectPatternsWizard.getAllMatchIndicator();
    if (allMatchIndicator == null) {
        return returnList;
    }
    List<ModelElement> analysisColumns = this.selectPatternsWizard.getAllMatchIndicator().getAnalyzedColumns();
    List<RegexpMatchingIndicator> regexpMatchingIndicatorList = this.selectPatternsWizard.getAllMatchIndicator().getCompositeRegexMatchingIndicators();
    for (RegexpMatchingIndicator regexIndicator : regexpMatchingIndicatorList) {
        int index = analysisColumns.indexOf(regexIndicator.getAnalyzedElement());
        Map<Integer, RegexpMatchingIndicator> returnMap = getMapLocation(returnList, index);
        // new HashMap<Integer, String>();
        returnMap.put(index, regexIndicator);
        if (returnMap.size() == 1) {
            returnList.add(returnMap);
        }
    }
    return returnList;
}
Also used : ModelElement(orgomg.cwm.objectmodel.core.ModelElement) AllMatchIndicatorImpl(org.talend.dataquality.indicators.columnset.impl.AllMatchIndicatorImpl) ArrayList(java.util.ArrayList) RegexpMatchingIndicator(org.talend.dataquality.indicators.RegexpMatchingIndicator) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

RegexpMatchingIndicator (org.talend.dataquality.indicators.RegexpMatchingIndicator)18 IndicatorParameters (org.talend.dataquality.indicators.IndicatorParameters)7 ArrayList (java.util.ArrayList)6 Test (org.junit.Test)6 Pattern (org.talend.dataquality.domain.pattern.Pattern)6 Domain (org.talend.dataquality.domain.Domain)5 Indicator (org.talend.dataquality.indicators.Indicator)5 AllMatchIndicator (org.talend.dataquality.indicators.columnset.AllMatchIndicator)5 ModelElement (orgomg.cwm.objectmodel.core.ModelElement)4 TdExpression (org.talend.cwm.relational.TdExpression)3 PatternComponent (org.talend.dataquality.domain.pattern.PatternComponent)3 RegularExpression (org.talend.dataquality.domain.pattern.RegularExpression)3 PatternMatchingIndicator (org.talend.dataquality.indicators.PatternMatchingIndicator)3 HashMap (java.util.HashMap)2 Matcher (java.util.regex.Matcher)2 Pattern (java.util.regex.Pattern)2 ModelElementIndicator (org.talend.dataprofiler.core.model.ModelElementIndicator)2 Analysis (org.talend.dataquality.analysis.Analysis)2 CompositeIndicator (org.talend.dataquality.indicators.CompositeIndicator)2 SimpleStatIndicator (org.talend.dataquality.indicators.columnset.SimpleStatIndicator)2