Search in sources :

Example 1 with TextParameters

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

the class WellFormNationalPhoneCountIndicatorImpl 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.parseAndKeepRawInput(data.toString(), country);
        String format = phoneUtil.format(phoneNumeber, PhoneNumberFormat.NATIONAL);
        if (data.toString().equals(format)) {
            this.wellFormNatiPhoneCount++;
            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)

Example 2 with TextParameters

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

the class ValidPhoneCountIndicatorImpl method handle.

/*
     * (non-Jsdoc)
     * 
     * @see org.talend.dataquality.indicators.impl.IndicatorImpl#handle(java.lang.Object)
     */
@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 phoneNumber = phoneUtil.parse(data.toString(), country);
        if (phoneUtil.isValidNumberForRegion(phoneNumber, country)) {
            // if (phoneUtil.isValidNumber(phoneNumber)) {
            validPhoneNumCount++;
            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)

Example 3 with TextParameters

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

the class FormatFreqPieIndicatorImpl method handle.

@Override
public boolean handle(Object data) {
    count++;
    boolean isInvalidForm = false;
    try {
        if (data == null || data.toString().trim().equals(PluginConstant.EMPTY_STRING)) {
            isInvalidForm = true;
        } else {
            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);
            // MOD msjian TDQ-7603 2013-7-19: with the Standard value to compare
            String format_E164 = phoneUtil.format(phoneNumeber, PhoneNumberFormat.E164);
            String format_inter = phoneUtil.format(phoneNumeber, PhoneNumberFormat.INTERNATIONAL);
            String format_national = phoneUtil.format(phoneNumeber, PhoneNumberFormat.NATIONAL);
            if (data.toString().equals(format_E164)) {
                this.mustStoreRow = checkMustStoreCurrentRow(wellFormE164Count);
                wellFormE164Count++;
                setCurrentKey(WELL_FORM_E164_KEY);
            } else if (data.toString().equals(format_inter)) {
                this.mustStoreRow = checkMustStoreCurrentRow(wellFormInteCount);
                wellFormInteCount++;
                setCurrentKey(WELL_FORM_INTE_KEY);
            } else if (data.toString().equals(format_national)) {
                this.mustStoreRow = checkMustStoreCurrentRow(wellFormNatiCount);
                wellFormNatiCount++;
                setCurrentKey(WELL_FORM_NATI_KEY);
            } else {
                isInvalidForm = true;
            }
        // TDQ-7603~
        }
    } catch (Exception e) {
        isInvalidForm = true;
    }
    if (isInvalidForm) {
        this.mustStoreRow = checkMustStoreCurrentRow(invalidFormCount);
        invalidFormCount++;
        setCurrentKey(INVALID_FORM_KEY);
    }
    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)

Example 4 with TextParameters

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

the class IndicatorParametersImpl method basicSetTextParameter.

/**
 * <!-- begin-user-doc --> <!-- end-user-doc -->
 *
 * @generated
 */
public NotificationChain basicSetTextParameter(TextParameters newTextParameter, NotificationChain msgs) {
    TextParameters oldTextParameter = textParameter;
    textParameter = newTextParameter;
    if (eNotificationRequired()) {
        ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, IndicatorsPackage.INDICATOR_PARAMETERS__TEXT_PARAMETER, oldTextParameter, newTextParameter);
        if (msgs == null) {
            msgs = notification;
        } else {
            msgs.add(notification);
        }
    }
    return msgs;
}
Also used : TextParameters(org.talend.dataquality.indicators.TextParameters) ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl)

Example 5 with TextParameters

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

the class PatternLowFreqIndicatorImpl 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 = "aaaaaaaaaaaaaaaaaaaaaaaaaaAAAAAAAAAAAAAAAAAAAAAAAAAA9999999999";
            hasBeanCustomized = false;
        }
        String charactersToReplace = textParameter.getCharactersToReplace();
        if (!StringUtils.isBlank(charactersToReplace)) {
            this.charsToReplace = charactersToReplace;
        } else {
            charsToReplace = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
        }
    // TDQ-10044~
    }
    return super.prepare();
}
Also used : TextParameters(org.talend.dataquality.indicators.TextParameters)

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