use of org.talend.dataquality.indicators.IndicatorParameters in project tdq-studio-se by Talend.
the class ModelElementIndicatorImpl method createPlainIndicatorUnit.
/**
* Create a new IndicatorUnit according to indicatorEnum and indicator, if the parameter indicator is null, will
* create a new indicator .
*
* @param indicatorEnum
* @param indicator
* @return
*/
private IndicatorUnit createPlainIndicatorUnit(IndicatorEnum indicatorEnum, Indicator indicator) {
Indicator tempIndicator = indicator;
if (tempIndicator == null) {
EFactoryImpl factory = (EFactoryImpl) indicatorEnum.getIndicatorType().getEPackage().getEFactoryInstance();
tempIndicator = (Indicator) factory.create(indicatorEnum.getIndicatorType());
// MOD scorreia 2008-09-18: bug 5131 fixed: set indicator's definition when the indicator is created.
if (!DefinitionHandler.getInstance().setDefaultIndicatorDefinition(tempIndicator)) {
// $NON-NLS-1$
log.error("Could not set the definition of the given indicator :" + tempIndicator.getName());
}
// for 4225, the frequency indicator need be initialized
int sqlType = getJavaType();
if (tempIndicator instanceof FrequencyIndicator && Java2SqlType.isDateInSQL(sqlType)) {
IndicatorParameters parameters = tempIndicator.getParameters();
if (parameters == null) {
parameters = IndicatorsFactory.eINSTANCE.createIndicatorParameters();
tempIndicator.setParameters(parameters);
}
DateParameters dateParameters = parameters.getDateParameters();
// "Year Frequency Table" when applying on "Time" type
if (dateParameters == null && !(indicatorEnum == IndicatorEnum.PatternFreqIndicatorEnum || indicatorEnum == IndicatorEnum.PatternLowFreqIndicatorEnum || indicatorEnum == IndicatorEnum.FrequencyIndicatorEnum || indicatorEnum == IndicatorEnum.LowFrequencyIndicatorEnum)) {
dateParameters = IndicatorsFactory.eINSTANCE.createDateParameters();
parameters.setDateParameters(dateParameters);
}
// TDQ-5357~
// MOD scorreia 2008-06-19 default is already set in the model
// dateParameters.setDateAggregationType(DateGrain.YEAR);
}
}
IndicatorUnit indicatorUnit = new ColumnIndicatorUnit(indicatorEnum, tempIndicator, this);
this.plainIndicatorUnitMap.put(indicatorEnum, indicatorUnit);
return indicatorUnit;
}
use of org.talend.dataquality.indicators.IndicatorParameters in project tdq-studio-se by Talend.
the class DateFrequencyIndicatorImpl method getParameters.
@Override
public IndicatorParameters getParameters() {
IndicatorParameters parameters = super.getParameters();
if (parameters == null) {
parameters = IndicatorsFactory.eINSTANCE.createIndicatorParameters();
}
DateParameters dateParameters = parameters.getDateParameters();
if (dateParameters == null) {
dateParameters = IndicatorsFactory.eINSTANCE.createDateParameters();
}
dateParameters.setDateAggregationType(DateGrain.DAY);
parameters.setDateParameters(dateParameters);
this.setParameters(parameters);
return parameters;
}
use of org.talend.dataquality.indicators.IndicatorParameters in project tdq-studio-se by Talend.
the class WeekFrequencyIndicatorImpl method getParameters.
@Override
public IndicatorParameters getParameters() {
IndicatorParameters parameters = super.getParameters();
if (parameters == null) {
parameters = IndicatorsFactory.eINSTANCE.createIndicatorParameters();
}
DateParameters dateParameters = parameters.getDateParameters();
if (dateParameters == null) {
dateParameters = IndicatorsFactory.eINSTANCE.createDateParameters();
}
dateParameters.setDateAggregationType(DateGrain.WEEK);
parameters.setDateParameters(dateParameters);
this.setParameters(parameters);
return parameters;
}
use of org.talend.dataquality.indicators.IndicatorParameters 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;
}
use of org.talend.dataquality.indicators.IndicatorParameters 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;
}
Aggregations