Search in sources :

Example 81 with Indicator

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

the class IndicatorHelper method getIndicatorLeaves.

/**
 * This method only used when running analysis. it get RowCountIndicator from RowCountIndicatorsAdapter.
 *
 * @param result
 * @return all the leaf indicators
 */
public static List<Indicator> getIndicatorLeaves(AnalysisResult result) {
    List<Indicator> leafIndicators = new ArrayList<>();
    EList<Indicator> indicators = result.getIndicators();
    RowCountIndicatorsAdapter.getInstance().clear();
    for (Indicator indicator : indicators) {
        for (Indicator indi : getIndicatorLeaves(indicator)) {
            if (!leafIndicators.contains(indi)) {
                leafIndicators.add(indi);
            }
        }
    }
    return leafIndicators;
}
Also used : ArrayList(java.util.ArrayList) UniqueCountIndicator(org.talend.dataquality.indicators.UniqueCountIndicator) MaxValueIndicator(org.talend.dataquality.indicators.MaxValueIndicator) ValidRegCodeCountIndicator(org.talend.dataquality.indicators.ValidRegCodeCountIndicator) PhoneNumbStatisticsIndicator(org.talend.dataquality.indicators.PhoneNumbStatisticsIndicator) MinLengthIndicator(org.talend.dataquality.indicators.MinLengthIndicator) MinValueIndicator(org.talend.dataquality.indicators.MinValueIndicator) AverageLengthIndicator(org.talend.dataquality.indicators.AverageLengthIndicator) MeanIndicator(org.talend.dataquality.indicators.MeanIndicator) DefValueCountIndicator(org.talend.dataquality.indicators.DefValueCountIndicator) WellFormE164PhoneCountIndicator(org.talend.dataquality.indicators.WellFormE164PhoneCountIndicator) RangeIndicator(org.talend.dataquality.indicators.RangeIndicator) JavaUserDefIndicator(org.talend.dataquality.indicators.sql.JavaUserDefIndicator) ValueIndicator(org.talend.dataquality.indicators.ValueIndicator) InvalidRegCodeCountIndicator(org.talend.dataquality.indicators.InvalidRegCodeCountIndicator) UserDefIndicator(org.talend.dataquality.indicators.sql.UserDefIndicator) ValidPhoneCountIndicator(org.talend.dataquality.indicators.ValidPhoneCountIndicator) RowCountIndicator(org.talend.dataquality.indicators.RowCountIndicator) WellFormIntePhoneCountIndicator(org.talend.dataquality.indicators.WellFormIntePhoneCountIndicator) FormatFreqPieIndicator(org.talend.dataquality.indicators.FormatFreqPieIndicator) PossiblePhoneCountIndicator(org.talend.dataquality.indicators.PossiblePhoneCountIndicator) ModeIndicator(org.talend.dataquality.indicators.ModeIndicator) PatternMatchingIndicator(org.talend.dataquality.indicators.PatternMatchingIndicator) MaxLengthIndicator(org.talend.dataquality.indicators.MaxLengthIndicator) RecordMatchingIndicator(org.talend.dataquality.indicators.columnset.RecordMatchingIndicator) NullCountIndicator(org.talend.dataquality.indicators.NullCountIndicator) MedianIndicator(org.talend.dataquality.indicators.MedianIndicator) Indicator(org.talend.dataquality.indicators.Indicator) CompositeIndicator(org.talend.dataquality.indicators.CompositeIndicator) BlankCountIndicator(org.talend.dataquality.indicators.BlankCountIndicator) DistinctCountIndicator(org.talend.dataquality.indicators.DistinctCountIndicator) DuplicateCountIndicator(org.talend.dataquality.indicators.DuplicateCountIndicator) IQRIndicator(org.talend.dataquality.indicators.IQRIndicator) BoxIndicator(org.talend.dataquality.indicators.BoxIndicator) WellFormNationalPhoneCountIndicator(org.talend.dataquality.indicators.WellFormNationalPhoneCountIndicator) WhereRuleIndicator(org.talend.dataquality.indicators.sql.WhereRuleIndicator)

Example 82 with Indicator

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

the class IndicatorHelper method getRowCountIndicator.

/**
 * DOC scorreia Comment method "getRowCountIndicator".
 *
 * @param modelElement
 * @param elementToIndicator
 * @return
 */
public static RowCountIndicator getRowCountIndicator(ModelElement modelElement, Map<ModelElement, List<Indicator>> elementToIndicator) {
    List<Indicator> list = elementToIndicator.get(modelElement);
    RowCountIndicator rowCountIndicator = null;
    if (list == null) {
        return rowCountIndicator;
    }
    for (Indicator indicator : list) {
        if (IndicatorsPackage.eINSTANCE.getRowCountIndicator().equals(indicator.eClass())) {
            rowCountIndicator = (RowCountIndicator) indicator;
            break;
        }
    }
    return rowCountIndicator;
}
Also used : RowCountIndicator(org.talend.dataquality.indicators.RowCountIndicator) UniqueCountIndicator(org.talend.dataquality.indicators.UniqueCountIndicator) MaxValueIndicator(org.talend.dataquality.indicators.MaxValueIndicator) ValidRegCodeCountIndicator(org.talend.dataquality.indicators.ValidRegCodeCountIndicator) PhoneNumbStatisticsIndicator(org.talend.dataquality.indicators.PhoneNumbStatisticsIndicator) MinLengthIndicator(org.talend.dataquality.indicators.MinLengthIndicator) MinValueIndicator(org.talend.dataquality.indicators.MinValueIndicator) AverageLengthIndicator(org.talend.dataquality.indicators.AverageLengthIndicator) MeanIndicator(org.talend.dataquality.indicators.MeanIndicator) DefValueCountIndicator(org.talend.dataquality.indicators.DefValueCountIndicator) WellFormE164PhoneCountIndicator(org.talend.dataquality.indicators.WellFormE164PhoneCountIndicator) RangeIndicator(org.talend.dataquality.indicators.RangeIndicator) JavaUserDefIndicator(org.talend.dataquality.indicators.sql.JavaUserDefIndicator) ValueIndicator(org.talend.dataquality.indicators.ValueIndicator) InvalidRegCodeCountIndicator(org.talend.dataquality.indicators.InvalidRegCodeCountIndicator) UserDefIndicator(org.talend.dataquality.indicators.sql.UserDefIndicator) ValidPhoneCountIndicator(org.talend.dataquality.indicators.ValidPhoneCountIndicator) RowCountIndicator(org.talend.dataquality.indicators.RowCountIndicator) WellFormIntePhoneCountIndicator(org.talend.dataquality.indicators.WellFormIntePhoneCountIndicator) FormatFreqPieIndicator(org.talend.dataquality.indicators.FormatFreqPieIndicator) PossiblePhoneCountIndicator(org.talend.dataquality.indicators.PossiblePhoneCountIndicator) ModeIndicator(org.talend.dataquality.indicators.ModeIndicator) PatternMatchingIndicator(org.talend.dataquality.indicators.PatternMatchingIndicator) MaxLengthIndicator(org.talend.dataquality.indicators.MaxLengthIndicator) RecordMatchingIndicator(org.talend.dataquality.indicators.columnset.RecordMatchingIndicator) NullCountIndicator(org.talend.dataquality.indicators.NullCountIndicator) MedianIndicator(org.talend.dataquality.indicators.MedianIndicator) Indicator(org.talend.dataquality.indicators.Indicator) CompositeIndicator(org.talend.dataquality.indicators.CompositeIndicator) BlankCountIndicator(org.talend.dataquality.indicators.BlankCountIndicator) DistinctCountIndicator(org.talend.dataquality.indicators.DistinctCountIndicator) DuplicateCountIndicator(org.talend.dataquality.indicators.DuplicateCountIndicator) IQRIndicator(org.talend.dataquality.indicators.IQRIndicator) BoxIndicator(org.talend.dataquality.indicators.BoxIndicator) WellFormNationalPhoneCountIndicator(org.talend.dataquality.indicators.WellFormNationalPhoneCountIndicator) WhereRuleIndicator(org.talend.dataquality.indicators.sql.WhereRuleIndicator)

Example 83 with Indicator

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

the class AnalysisHelper method getUserDefinedIndicators.

public static List<IndicatorDefinition> getUserDefinedIndicators(Analysis analysis) {
    List<IndicatorDefinition> rets = new ArrayList<IndicatorDefinition>();
    EList<Indicator> indicators = analysis.getResults().getIndicators();
    for (Indicator indicator : indicators) {
        if (indicator instanceof UserDefIndicator) {
            rets.add(indicator.getIndicatorDefinition());
        }
    }
    return rets;
}
Also used : ArrayList(java.util.ArrayList) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition) UserDefIndicator(org.talend.dataquality.indicators.sql.UserDefIndicator) 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 84 with Indicator

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

the class UDIHelper method updateJUDIsForAnalysis.

/**
 * check all the indicators, convert common udi to a Java UDI if needed.
 *
 * @param analysis
 */
public static void updateJUDIsForAnalysis(Analysis analysis) {
    EList<Indicator> allIndics = analysis.getResults().getIndicators();
    List<Indicator> updatedIndWithJUDI = new ArrayList<Indicator>();
    for (Indicator indicator : allIndics) {
        // MOD TDQ-8177 sizhaoliu update only the UDIs
        if (UDIHelper.isUDI(indicator) && UDIHelper.needUpdateJUDI(indicator)) {
            try {
                indicator = UDIHelper.adaptToJavaUDI(indicator);
            } catch (Throwable e) {
                ExceptionHandler.process(e);
            }
        }
        updatedIndWithJUDI.add(indicator);
    }
    allIndics.clear();
    allIndics.addAll(updatedIndWithJUDI);
}
Also used : ArrayList(java.util.ArrayList) Indicator(org.talend.dataquality.indicators.Indicator) UserDefIndicator(org.talend.dataquality.indicators.sql.UserDefIndicator)

Example 85 with Indicator

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

the class UDIHelper method adaptToJavaUDI.

/**
 * DOC mzhao feature 11128, If the execute engine and by the same time Java User Defined Indicator is also defined,
 * then compute via Java UDI, here convert common udi to a Java UDI.
 *
 * @param udi
 * @return
 * @throws Exception
 */
public static Indicator adaptToJavaUDI(Indicator indicator) throws Throwable {
    Indicator returnIndicator = getUDIFromMap(indicator);
    if (returnIndicator != null) {
        return returnIndicator;
    }
    UserDefIndicator adaptedUDI = null;
    if (userDefIndSwitch.doSwitch(indicator) != null) {
        EList<TaggedValue> taggedValues = indicator.getIndicatorDefinition().getTaggedValue();
        String userJavaClassName = null;
        String jarPath = null;
        for (TaggedValue tv : taggedValues) {
            if (tv.getTag().equals(TaggedValueHelper.CLASS_NAME_TEXT)) {
                userJavaClassName = tv.getValue();
                continue;
            }
            if (tv.getTag().equals(TaggedValueHelper.JAR_FILE_PATH)) {
                jarPath = tv.getValue();
            }
        }
        // MOD by zshen for feature 18724
        if (validateJavaUDI(userJavaClassName, jarPath)) {
            List<URL> jarUrls = new ArrayList<URL>();
            for (File file : getContainJarFile(jarPath)) {
                jarUrls.add(file.toURI().toURL());
            }
            TalendURLClassLoader cl;
            // Note that the 2nd parameter (classloader) is needed to load class UserDefinitionIndicator from
            // org.talend.dataquality plugin.
            cl = new TalendURLClassLoader(jarUrls.toArray(new URL[jarUrls.size()]), UDIHelper.class.getClassLoader());
            Class<?> clazz = null;
            clazz = cl.findClass(userJavaClassName);
            if (clazz != null) {
                // MOD yyin 20121012 TDQ-6259
                UserDefIndicator judi = (UserDefIndicator) clazz.newInstance();
                // judi.setIndicatorDefinition(indicator.getIndicatorDefinition());
                PropertyUtils.copyProperties(judi, indicator);
                // judi.setAnalyzedElement(indicator.getAnalyzedElement());
                adaptedUDI = judi;
                JAVAUDIMAP.put(indicator, adaptedUDI);
            }
        }
    }
    return adaptedUDI;
}
Also used : TaggedValue(orgomg.cwm.objectmodel.core.TaggedValue) ArrayList(java.util.ArrayList) UserDefIndicator(org.talend.dataquality.indicators.sql.UserDefIndicator) IFile(org.eclipse.core.resources.IFile) File(java.io.File) Indicator(org.talend.dataquality.indicators.Indicator) UserDefIndicator(org.talend.dataquality.indicators.sql.UserDefIndicator) URL(java.net.URL) TalendURLClassLoader(org.talend.utils.classloader.TalendURLClassLoader)

Aggregations

Indicator (org.talend.dataquality.indicators.Indicator)178 ArrayList (java.util.ArrayList)58 RowCountIndicator (org.talend.dataquality.indicators.RowCountIndicator)40 CompositeIndicator (org.talend.dataquality.indicators.CompositeIndicator)31 ModelElement (orgomg.cwm.objectmodel.core.ModelElement)31 ModelElementIndicator (org.talend.dataprofiler.core.model.ModelElementIndicator)28 Analysis (org.talend.dataquality.analysis.Analysis)27 DuplicateCountIndicator (org.talend.dataquality.indicators.DuplicateCountIndicator)27 UniqueCountIndicator (org.talend.dataquality.indicators.UniqueCountIndicator)27 AllMatchIndicator (org.talend.dataquality.indicators.columnset.AllMatchIndicator)26 ReturnCode (org.talend.utils.sugars.ReturnCode)25 SimpleStatIndicator (org.talend.dataquality.indicators.columnset.SimpleStatIndicator)24 UserDefIndicator (org.talend.dataquality.indicators.sql.UserDefIndicator)24 PatternMatchingIndicator (org.talend.dataquality.indicators.PatternMatchingIndicator)23 DistinctCountIndicator (org.talend.dataquality.indicators.DistinctCountIndicator)22 NullCountIndicator (org.talend.dataquality.indicators.NullCountIndicator)22 TdColumn (org.talend.cwm.relational.TdColumn)20 WhereRuleIndicator (org.talend.dataquality.indicators.sql.WhereRuleIndicator)18 FrequencyIndicator (org.talend.dataquality.indicators.FrequencyIndicator)17 Test (org.junit.Test)16