Search in sources :

Example 31 with IndicatorParameters

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

the class IndicatorHelper method setDataThresholds.

/**
 * DOC scorreia Comment method "setDataThresholds".
 *
 * @param rangeIndicator
 * @param dataThreshold
 */
private static void setDataThresholds(RangeIndicator rangeIndicator, String[] dataThreshold) {
    if (rangeIndicator != null) {
        IndicatorHelper.setDataThreshold(rangeIndicator, dataThreshold[0], dataThreshold[1]);
        MinValueIndicator lowerValue = rangeIndicator.getLowerValue();
        // MOD qiongli 2011-11-25,propgate the parameter to children ,convert the dataThreshold to
        // IndicatorThreshold for MaxValueIndicator/MinValueIndicator.
        IndicatorParameters parameters = rangeIndicator.getParameters();
        if (parameters != null) {
            if (lowerValue != null) {
                IndicatorParameters lowParameters = lowerValue.getParameters();
                if (lowParameters == null) {
                    lowParameters = IndicatorsFactory.eINSTANCE.createIndicatorParameters();
                    lowerValue.setParameters(lowParameters);
                }
                IndicatorHelper.setIndicatorThreshold(lowParameters, dataThreshold[0], dataThreshold[1]);
            // IndicatorHelper.setDataThreshold(lowerValue, dataThreshold[0], dataThreshold[1]);
            }
            MaxValueIndicator upperValue = rangeIndicator.getUpperValue();
            if (upperValue != null) {
                IndicatorParameters upperParameters = upperValue.getParameters();
                if (upperParameters == null) {
                    upperParameters = IndicatorsFactory.eINSTANCE.createIndicatorParameters();
                    upperValue.setParameters(upperParameters);
                }
                IndicatorHelper.setIndicatorThreshold(upperParameters, dataThreshold[0], dataThreshold[1]);
            // IndicatorHelper.setDataThreshold(lowerValue, dataThreshold[0], dataThreshold[1]);
            }
        }
    }
}
Also used : MaxValueIndicator(org.talend.dataquality.indicators.MaxValueIndicator) IndicatorParameters(org.talend.dataquality.indicators.IndicatorParameters) MinValueIndicator(org.talend.dataquality.indicators.MinValueIndicator)

Example 32 with IndicatorParameters

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

the class IndicatorHelper method setDataThreshold.

public static void setDataThreshold(Indicator indicator, String min, String max) {
    IndicatorParameters parameters = indicator.getParameters();
    if (parameters == null) {
        parameters = IndicatorsFactory.eINSTANCE.createIndicatorParameters();
        indicator.setParameters(parameters);
    }
    setDataThreshold(parameters, min, max);
}
Also used : IndicatorParameters(org.talend.dataquality.indicators.IndicatorParameters)

Example 33 with IndicatorParameters

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

the class PatternIndicatorFactory method createRegexpMatchingIndicator.

/**
 * Method "createRegexpMatchingIndicator".
 *
 * @param pattern the pattern from which the RegexpMatchingIndicator is created
 * @return the new RegexpMatchingIndicator with the same name as the pattern
 */
public static RegexpMatchingIndicator createRegexpMatchingIndicator(Pattern pattern) {
    RegexpMatchingIndicator patternMatchingIndicator = IndicatorsFactory.eINSTANCE.createRegexpMatchingIndicator();
    IndicatorParameters indicParams = IndicatorsFactory.eINSTANCE.createIndicatorParameters();
    Domain validData = DomainFactory.eINSTANCE.createDomain();
    validData.getPatterns().add(pattern);
    indicParams.setDataValidDomain(validData);
    patternMatchingIndicator.setParameters(indicParams);
    patternMatchingIndicator.setName(pattern.getName());
    return patternMatchingIndicator;
}
Also used : IndicatorParameters(org.talend.dataquality.indicators.IndicatorParameters) RegexpMatchingIndicator(org.talend.dataquality.indicators.RegexpMatchingIndicator) Domain(org.talend.dataquality.domain.Domain)

Example 34 with IndicatorParameters

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

the class PatternIndicatorFactory method createSqlPatternMatchingIndicator.

/**
 * Method "createSqlPatternMatchingIndicator".
 *
 * @param pattern the pattern from which the SqlPatternMatchingIndicator is created
 * @return the new SqlPatternMatchingIndicator with the same name as the pattern
 */
public static SqlPatternMatchingIndicator createSqlPatternMatchingIndicator(Pattern pattern) {
    SqlPatternMatchingIndicator patternMatchingIndicator = IndicatorsFactory.eINSTANCE.createSqlPatternMatchingIndicator();
    IndicatorParameters indicParams = IndicatorsFactory.eINSTANCE.createIndicatorParameters();
    Domain validData = DomainFactory.eINSTANCE.createDomain();
    validData.getPatterns().add(pattern);
    indicParams.setDataValidDomain(validData);
    patternMatchingIndicator.setParameters(indicParams);
    patternMatchingIndicator.setName(pattern.getName());
    return patternMatchingIndicator;
}
Also used : SqlPatternMatchingIndicator(org.talend.dataquality.indicators.SqlPatternMatchingIndicator) IndicatorParameters(org.talend.dataquality.indicators.IndicatorParameters) Domain(org.talend.dataquality.domain.Domain)

Example 35 with IndicatorParameters

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

the class EMailValidationIndicator method initParameters.

boolean initParameters() {
    // Check prerequisite
    IndicatorParameters param = this.getParameters();
    if (param == null) {
        // $NON-NLS-1$
        log.error("No parameter set in the user defined indicator " + this.getName());
        return false;
    }
    Domain indicatorValidDomain = param.getIndicatorValidDomain();
    if (indicatorValidDomain == null) {
        // $NON-NLS-1$
        log.error("No parameter set in the user defined indicator " + this.getName());
        return false;
    }
    // else retrieve email from parameter
    EList<JavaUDIIndicatorParameter> javaUDIIndicatorParameter = indicatorValidDomain.getJavaUDIIndicatorParameter();
    for (JavaUDIIndicatorParameter p : javaUDIIndicatorParameter) {
        if (EMAIL_PARAM.equalsIgnoreCase(p.getKey())) {
            this.emailAddress = p.getValue();
        } else if (INVALID_PARAM.equalsIgnoreCase(p.getKey())) {
            this.storeInvalidData = true;
            // TODO add more checks on the file
            try {
                this.tempInvalidData = new StringBuffer();
                this.os = new FileOutputStream(new File(p.getValue()));
            } catch (FileNotFoundException e) {
                // $NON-NLS-1$
                log.error("Invalid file path in the user defined indicator: " + this.getName(), e);
                return false;
            }
        } else if (BUFFER_SIZE_PARAM.equalsIgnoreCase(p.getKey())) {
            try {
                this.buffSize = Integer.valueOf(p.getValue());
            } catch (Exception e) {
                // $NON-NLS-1$
                log.error("Invalid buffer size: " + p.getValue(), e);
                return false;
            }
        } else {
            // log warn but keep running (don't return false)
            if (!NAMING_PARAM.equalsIgnoreCase(p.getKey())) {
                // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                log.warn("Unknown parameter given to UDI: " + this.getName() + ": " + p.getKey() + " = " + p.getValue());
            }
        }
    }
    if (!this.isAddressValid(emailAddress)) {
        log.error(// $NON-NLS-1$ //$NON-NLS-2$
        "Invalid sender email set in parameters of the user defined indicator \"" + this.getName() + "\": " + emailAddress);
        return false;
    }
    return true;
}
Also used : IndicatorParameters(org.talend.dataquality.indicators.IndicatorParameters) FileOutputStream(java.io.FileOutputStream) JavaUDIIndicatorParameter(org.talend.dataquality.domain.JavaUDIIndicatorParameter) FileNotFoundException(java.io.FileNotFoundException) Domain(org.talend.dataquality.domain.Domain) File(java.io.File) NamingException(javax.naming.NamingException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException)

Aggregations

IndicatorParameters (org.talend.dataquality.indicators.IndicatorParameters)65 Domain (org.talend.dataquality.domain.Domain)27 DateParameters (org.talend.dataquality.indicators.DateParameters)15 Test (org.junit.Test)14 TdColumn (org.talend.cwm.relational.TdColumn)14 Pattern (org.talend.dataquality.domain.pattern.Pattern)14 TdExpression (org.talend.cwm.relational.TdExpression)13 TextParameters (org.talend.dataquality.indicators.TextParameters)12 RegularExpression (org.talend.dataquality.domain.pattern.RegularExpression)10 ChartDataEntity (org.talend.dq.indicators.preview.table.ChartDataEntity)10 Indicator (org.talend.dataquality.indicators.Indicator)9 ArrayList (java.util.ArrayList)8 PatternMatchingIndicator (org.talend.dataquality.indicators.PatternMatchingIndicator)8 Expression (orgomg.cwm.objectmodel.core.Expression)8 RegexpMatchingIndicator (org.talend.dataquality.indicators.RegexpMatchingIndicator)7 UserDefIndicator (org.talend.dataquality.indicators.sql.UserDefIndicator)7 PhoneNumberUtil (com.google.i18n.phonenumbers.PhoneNumberUtil)6 PhoneNumber (com.google.i18n.phonenumbers.Phonenumber.PhoneNumber)6 Analysis (org.talend.dataquality.analysis.Analysis)6 UDIndicatorDefinition (org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition)6