Search in sources :

Example 6 with TextParameters

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

the class WellFormIntePhoneCountIndicatorImpl 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.INTERNATIONAL);
        if (data.toString().equals(format)) {
            wellFormIntePhoneCount++;
            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 7 with TextParameters

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

the class AbstractColumnDropTree method hasIndicatorParameters.

/**
 * DOC msjian Comment method "hasIndicatorParameters".
 *
 * @param indicatorUnit
 * @return
 */
private boolean hasIndicatorParameters(IndicatorUnit indicatorUnit) {
    IndicatorParameters parameters = indicatorUnit.getIndicator().getParameters();
    if (parameters == null) {
        return false;
    }
    if (hideParameters(indicatorUnit)) {
        return false;
    }
    if (indicatorUnit.getIndicator() instanceof FrequencyIndicator) {
        // set on tree
        if (parameters.getBins() == null) {
            return false;
        }
        // ~
        return true;
    }
    TextParameters tParameter = parameters.getTextParameter();
    if (tParameter != null && !hideTextParameters(indicatorUnit)) {
        return true;
    }
    DateParameters dParameters = parameters.getDateParameters();
    if (dParameters != null) {
        return true;
    }
    Domain indicatorValidDomain = parameters.getIndicatorValidDomain();
    if (indicatorValidDomain != null) {
        if (indicatorValidDomain.getRanges() != null && !indicatorValidDomain.getRanges().isEmpty()) {
            return true;
        }
    }
    Domain bins = parameters.getBins();
    if (bins != null) {
        return true;
    }
    return false;
}
Also used : TextParameters(org.talend.dataquality.indicators.TextParameters) IndicatorParameters(org.talend.dataquality.indicators.IndicatorParameters) DateParameters(org.talend.dataquality.indicators.DateParameters) Domain(org.talend.dataquality.domain.Domain) FrequencyIndicator(org.talend.dataquality.indicators.FrequencyIndicator)

Example 8 with TextParameters

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

the class PhoneNumberForm method initiateCountryList.

/**
 * DOC qiongli Comment method "initiateCountryList".
 *
 * @return
 */
private String[] initiateCountryList() {
    SortedSet<String> countryList = new TreeSet<String>();
    TextParameters textParameter = parameters.getTextParameter();
    String oldCountryCode = null;
    if (textParameter != null) {
        oldCountryCode = textParameter.getCountryCode();
    }
    for (Locale locale : Locale.getAvailableLocales()) {
        if (locale.getDisplayCountry().compareTo("") != 0) {
            // $NON-NLS-1$
            countryList.add(locale.getDisplayCountry());
            combo.setData(locale.getDisplayCountry(), locale.getCountry());
            if (oldCountryCode != null && oldCountryCode.equals(locale.getCountry())) {
                oldCountryName = locale.getDisplayCountry();
            }
        }
    }
    String defaultCountry = Locale.getDefault().getDisplayCountry();
    // give a value of "United States" to defaultCountry when it is empty string.
    if (defaultCountry.equals(PluginConstant.EMPTY_STRING)) {
        String countryBySys = IndicatorHelper.getDefCountryCodeBySystem();
        Locale defLocalBySys = new Locale(Locale.getDefault().getLanguage(), countryBySys);
        defaultCountry = defLocalBySys.getDisplayCountry();
    // defaultCountry = "United States";
    }
    int i = 0;
    if (oldCountryName != null) {
        for (String country : countryList) {
            if (country.equals(oldCountryName)) {
                countryToSelect = i;
                // combo.select(i);
                break;
            }
            i++;
        }
    } else {
        for (String country : countryList) {
            if (country.equals(defaultCountry)) {
                countryToSelect = i;
                // combo.select(i);
                break;
            }
            i++;
        }
    }
    return countryList.toArray(new String[] {});
}
Also used : TextParameters(org.talend.dataquality.indicators.TextParameters) Locale(java.util.Locale) TreeSet(java.util.TreeSet)

Example 9 with TextParameters

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

the class TextParametersForm method performFinish.

@Override
public boolean performFinish() {
    TextParameters textParameter = parameters.getTextParameter();
    if (textParameter == null) {
        textParameter = IndicatorsFactory.eINSTANCE.createTextParameters();
    }
    textParameter.setIgnoreCase(caseBtn.getSelection());
    parameters.setTextParameter(textParameter);
    return true;
}
Also used : TextParameters(org.talend.dataquality.indicators.TextParameters)

Example 10 with TextParameters

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

the class PossiblePhoneCountIndicatorImplTest method setUp.

@Before
public void setUp() throws Exception {
    possiblePhoneCountIndicatorImpl = new PossiblePhoneCountIndicatorImpl();
    IndicatorParameters createIndicatorParameters = IndicatorsFactory.eINSTANCE.createIndicatorParameters();
    TextParameters textParameters = IndicatorsFactory.eINSTANCE.createTextParameters();
    textParameters.setCountryCode(java.util.Locale.CHINA.getCountry());
    createIndicatorParameters.setTextParameter(textParameters);
    possiblePhoneCountIndicatorImpl.setParameters(createIndicatorParameters);
}
Also used : TextParameters(org.talend.dataquality.indicators.TextParameters) IndicatorParameters(org.talend.dataquality.indicators.IndicatorParameters) Before(org.junit.Before)

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