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;
}
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;
}
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[] {});
}
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;
}
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);
}
Aggregations