Search in sources :

Example 11 with TextParameters

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

the class ValidPhoneCountIndicatorImplTest method setUp.

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

Example 12 with TextParameters

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

the class ColumnAnalysisSqlExecutor method createSqlQuery.

/**
 * Method "createSqlQuery".
 *
 * @param dataFilterExpression
 * @param analysis
 * @param indicator
 *
 * @throws ParseException
 * @throws AnalysisExecutionException
 */
private boolean createSqlQuery(String dataFilterAsString, Indicator indicator) throws AnalysisExecutionException {
    TypedReturnCode<TdColumn> checkResult = getTdColumn(indicator);
    if (!checkResult.isOk()) {
        return false;
    }
    TdColumn tdColumn = checkResult.getObject();
    if (tdColumn.eIsProxy()) {
        tdColumn = (TdColumn) EObjectHelper.resolveObject(tdColumn);
    }
    TypedReturnCode<String> columnName = getColumnName(indicator, tdColumn);
    if (!columnName.isOk()) {
        return false;
    }
    String colName = columnName.getObject();
    TypedReturnCode<IndicatorDefinition> id = getIndicatorDefinition(indicator);
    if (!id.isOk()) {
        return false;
    }
    IndicatorDefinition indicatorDefinition = id.getObject();
    // get correct language for current database
    String language = dbms().getDbmsName();
    // --- create select statement
    // get indicator's sql columnS (generate the real SQL statement from its definition)
    Expression sqlGenericExpression = dbms().getSqlExpression(indicatorDefinition);
    final EClass indicatorEclass = indicator.eClass();
    if (sqlGenericExpression == null || sqlGenericExpression.getBody() == null) {
        // analysis, will not check the sql expression and create again(from the definition).
        if (UDIHelper.isUDI(indicator) && indicator.getInstantiatedExpressions().size() > 0) {
            return Boolean.TRUE;
        }
        // expressions.
        if (IndicatorsPackage.eINSTANCE.getRegexpMatchingIndicator().equals(indicatorEclass)) {
            // $NON-NLS-1$
            traceError(Messages.getString("ColumnAnalysisSqlExecutor.PLEASEREMOVEALLPATTEN"));
            return Boolean.FALSE;
        }
        traceError(Messages.getString(// $NON-NLS-1$
        "ColumnAnalysisSqlExecutor.UNSUPPORTEDINDICATOR", (indicator.getName() != null ? AnalysisExecutorHelper.getIndicatorName(indicator) : indicatorEclass.getName())));
        return Boolean.FALSE;
    }
    // --- get indicator parameters and convert them into sql expression
    List<String> whereExpression = new ArrayList<String>();
    if (StringUtils.isNotBlank(dataFilterAsString)) {
        whereExpression.add(dataFilterAsString);
    }
    List<String> rangeStrings = null;
    DateGrain dateAggregationType = null;
    IndicatorParameters parameters = indicator.getParameters();
    if (parameters != null) {
        // handle bins
        Domain bins = parameters.getBins();
        if (bins != null) {
            rangeStrings = getBinsAsGenericString(bins.getRanges(), colName);
        }
        DateParameters dateParameters = parameters.getDateParameters();
        if (dateParameters != null) {
            dateAggregationType = dateParameters.getDateAggregationType();
        }
        TextParameters textParameter = parameters.getTextParameter();
        if (textParameter != null) {
            if (textParameter.isIgnoreCase()) {
                colName = dbms().toUpperCase(colName);
            }
            if (!textParameter.isUseBlank() && IndicatorsPackage.eINSTANCE.getLengthIndicator().isSuperTypeOf(indicatorEclass)) {
                String tdColName = getQuotedColumnName(tdColumn);
                // $NON-NLS-1$
                tdColName = dbms().replaceNullsWithString(tdColName, "'NULL TALEND'");
            } else if (textParameter.isUseBlank() && IndicatorsPackage.eINSTANCE.getFrequencyIndicator().isSuperTypeOf(indicatorEclass)) {
                colName = dbms().trim(colName);
            }
        }
    }
    TypedReturnCode<String> completedQuery = getCompletedQuery(indicator, tdColumn, colName, indicatorDefinition, language, sqlGenericExpression, indicatorEclass, whereExpression, rangeStrings, dateAggregationType);
    if (!completedQuery.isOk()) {
        return false;
    }
    String finalQuery = completedQuery.getObject();
    if (finalQuery != null) {
        TdExpression instantiateSqlExpression = BooleanExpressionHelper.createTdExpression(language, finalQuery);
        indicator.setInstantiatedExpression(instantiateSqlExpression);
        return true;
    }
    return false;
}
Also used : DateGrain(org.talend.dataquality.indicators.DateGrain) TdExpression(org.talend.cwm.relational.TdExpression) IndicatorParameters(org.talend.dataquality.indicators.IndicatorParameters) ArrayList(java.util.ArrayList) DateParameters(org.talend.dataquality.indicators.DateParameters) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition) TextParameters(org.talend.dataquality.indicators.TextParameters) EClass(org.eclipse.emf.ecore.EClass) TdColumn(org.talend.cwm.relational.TdColumn) TdExpression(org.talend.cwm.relational.TdExpression) Expression(orgomg.cwm.objectmodel.core.Expression) Domain(org.talend.dataquality.domain.Domain)

Example 13 with TextParameters

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

the class AnalysisTableTreeViewer method hasIndicatorParameters.

/**
 * DOC msjian Comment method "hasIndicatorParameters".
 *
 * @param indicatorUnit
 * @return
 */
private boolean hasIndicatorParameters(TableIndicatorUnit indicatorUnit) {
    IndicatorParameters parameters = indicatorUnit.getIndicator().getParameters();
    if (parameters == null) {
        return false;
    }
    if (indicatorUnit.getIndicator() instanceof FrequencyIndicator) {
        return true;
    }
    TextParameters tParameter = parameters.getTextParameter();
    if (tParameter != null) {
        return true;
    }
    DateParameters dParameters = parameters.getDateParameters();
    if (dParameters != null) {
        return true;
    }
    Domain dataValidDomain = parameters.getDataValidDomain();
    if (dataValidDomain != null) {
        return true;
    }
    Domain indicatorValidDomain = parameters.getIndicatorValidDomain();
    if (indicatorValidDomain != null) {
        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 14 with TextParameters

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

the class TextLengthForm method initialize.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.dataprofiler.core.ui.utils.AbstractForm#initialize()
     */
@Override
protected void initialize() {
    TextParameters textParameter = parameters.getTextParameter();
    if (textParameter != null) {
        nullBtn.setSelection(textParameter.isUseNulls());
        blankBtn.setSelection(textParameter.isUseBlank());
    }
}
Also used : TextParameters(org.talend.dataquality.indicators.TextParameters)

Example 15 with TextParameters

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

the class TextLengthForm method performFinish.

@Override
public boolean performFinish() {
    TextParameters textParameter = parameters.getTextParameter();
    if (textParameter == null) {
        textParameter = IndicatorsFactory.eINSTANCE.createTextParameters();
    }
    textParameter.setUseNulls(nullBtn.getSelection());
    textParameter.setUseBlank(blankBtn.getSelection());
    parameters.setTextParameter(textParameter);
    return true;
}
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