Search in sources :

Example 16 with TextParameters

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

the class IndicatorHelper method setCountryCodeParameter.

/**
 * set country code as parameter for indicator
 *
 * @param indicator
 * @param countryCode
 */
public static void setCountryCodeParameter(Indicator indicator, String countryCode) {
    IndicatorParameters parameters = indicator.getParameters();
    if (parameters == null) {
        parameters = IndicatorsFactory.eINSTANCE.createIndicatorParameters();
        indicator.setParameters(parameters);
    }
    TextParameters textParameter = parameters.getTextParameter();
    if (textParameter == null) {
        textParameter = IndicatorsFactory.eINSTANCE.createTextParameters();
    }
    textParameter.setCountryCode(countryCode);
    parameters.setTextParameter(textParameter);
}
Also used : TextParameters(org.talend.dataquality.indicators.TextParameters) IndicatorParameters(org.talend.dataquality.indicators.IndicatorParameters)

Example 17 with TextParameters

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

the class TextParametersWithoutOptionsForm method performFinish.

@Override
public boolean performFinish() {
    TextParameters textParameter = parameters.getTextParameter();
    if (textParameter == null) {
        textParameter = IndicatorsFactory.eINSTANCE.createTextParameters();
    }
    parameters.setTopN(Integer.parseInt(numberTxt.getText()));
    return true;
}
Also used : TextParameters(org.talend.dataquality.indicators.TextParameters)

Example 18 with TextParameters

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

the class PatternFreqIndicatorImpl method prepare.

@Override
public boolean prepare() {
    // MOD xqliu 2009-06-29 bug 7068
    final TextParameters textParameter = this.getParameters() == null ? null : this.getParameters().getTextParameter();
    // ~
    if (textParameter != null) {
        // TDQ-10044: fix when the user didn't set the replace and charactersToReplace, use the default value(only
        // for jave engine)
        String replacementCharacters = textParameter.getReplacementCharacters();
        if (!StringUtils.isBlank(replacementCharacters)) {
            this.replacementChars = replacementCharacters;
            hasBeanCustomized = true;
        } else {
            replacementChars = REPLACEMENT_CHARS;
            hasBeanCustomized = false;
        }
        String charactersToReplace = textParameter.getCharactersToReplace();
        if (!StringUtils.isBlank(charactersToReplace)) {
            this.charsToReplace = charactersToReplace;
        } else {
            charsToReplace = CHARS_TO_REPLACE;
        }
    // TDQ-10044~
    }
    return super.prepare();
}
Also used : TextParameters(org.talend.dataquality.indicators.TextParameters)

Example 19 with TextParameters

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

the class PossiblePhoneCountIndicatorImpl method handle.

@Override
public boolean handle(Object data) {
    super.handle(data);
    if (data == null) {
        return false;
    }
    try {
        PhoneNumberUtil phoneUtil = PhoneNumberUtil.getInstance();
        IndicatorParameters indParameters = this.getParameters();
        TextParameters textParameters = indParameters == null ? null : indParameters.getTextParameter();
        String country = IndicatorHelper.getCountryCodeByParameter(textParameters);
        PhoneNumber phoneNumeber = phoneUtil.parse(data.toString(), country);
        // number.
        if (phoneUtil.isPossibleNumber(phoneNumeber)) {
            this.possiblePhoneCount++;
            if (checkMustStoreCurrentRow() || this.checkMustStoreCurrentRow(drillDownValueCount)) {
                this.mustStoreRow = true;
            }
        }
    } catch (NumberParseException e) {
        return false;
    }
    return true;
}
Also used : TextParameters(org.talend.dataquality.indicators.TextParameters) PhoneNumberUtil(com.google.i18n.phonenumbers.PhoneNumberUtil) IndicatorParameters(org.talend.dataquality.indicators.IndicatorParameters) PhoneNumber(com.google.i18n.phonenumbers.Phonenumber.PhoneNumber) NumberParseException(com.google.i18n.phonenumbers.NumberParseException)

Example 20 with TextParameters

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

the class WellFormE164PhoneCountIndicatorImpl method handle.

@Override
public boolean handle(Object data) {
    super.handle(data);
    if (data == null) {
        return false;
    }
    try {
        PhoneNumberUtil phoneUtil = PhoneNumberUtil.getInstance();
        IndicatorParameters indParameters = this.getParameters();
        TextParameters textParameters = indParameters == null ? null : indParameters.getTextParameter();
        String country = IndicatorHelper.getCountryCodeByParameter(textParameters);
        PhoneNumber phoneNumeber = phoneUtil.parse(data.toString(), country);
        String format = phoneUtil.format(phoneNumeber, PhoneNumberFormat.E164);
        if (data.toString().equals(format)) {
            wellFormE164PhoneCount++;
            if (checkMustStoreCurrentRow() || checkMustStoreCurrentRow(drillDownValueCount)) {
                this.mustStoreRow = true;
            }
        }
    } catch (NumberParseException e) {
        return false;
    }
    return true;
}
Also used : TextParameters(org.talend.dataquality.indicators.TextParameters) PhoneNumberUtil(com.google.i18n.phonenumbers.PhoneNumberUtil) IndicatorParameters(org.talend.dataquality.indicators.IndicatorParameters) PhoneNumber(com.google.i18n.phonenumbers.Phonenumber.PhoneNumber) NumberParseException(com.google.i18n.phonenumbers.NumberParseException)

Aggregations

TextParameters (org.talend.dataquality.indicators.TextParameters)20 IndicatorParameters (org.talend.dataquality.indicators.IndicatorParameters)12 PhoneNumberUtil (com.google.i18n.phonenumbers.PhoneNumberUtil)6 PhoneNumber (com.google.i18n.phonenumbers.Phonenumber.PhoneNumber)6 NumberParseException (com.google.i18n.phonenumbers.NumberParseException)5 Domain (org.talend.dataquality.domain.Domain)3 DateParameters (org.talend.dataquality.indicators.DateParameters)3 Before (org.junit.Before)2 FrequencyIndicator (org.talend.dataquality.indicators.FrequencyIndicator)2 ArrayList (java.util.ArrayList)1 Locale (java.util.Locale)1 TreeSet (java.util.TreeSet)1 EClass (org.eclipse.emf.ecore.EClass)1 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)1 TdColumn (org.talend.cwm.relational.TdColumn)1 TdExpression (org.talend.cwm.relational.TdExpression)1 DateGrain (org.talend.dataquality.indicators.DateGrain)1 IndicatorDefinition (org.talend.dataquality.indicators.definition.IndicatorDefinition)1 Expression (orgomg.cwm.objectmodel.core.Expression)1