Search in sources :

Example 46 with Expression

use of orgomg.cwm.objectmodel.core.Expression in project tdq-studio-se by Talend.

the class DbmsLanguageTest method testExtractRegularExpressionFunctionForNetezza.

/**
 * {@link org.talend.dq.dbms.DbmsLanguage#extractRegularExpressionFunction(Expression)}.
 *
 * case 6:Netezza database expression
 */
@Test
public void testExtractRegularExpressionFunctionForNetezza() {
    DbmsLanguage netezzaDbmsLanguage = DbmsLanguageFactory.createDbmsLanguage(SupportDBUrlType.NETEZZADEFAULTURL);
    Expression createExpression = CoreFactory.eINSTANCE.createExpression();
    // netezza Database UDP mode
    createExpression.setBody(// $NON-NLS-1$
    "SELECT COUNT(CASE WHEN REGEXP_EXTRACT(<%=__COLUMN_NAMES__%>,<%=__PATTERN_EXPR__%>) THEN 1 END), COUNT(*) FROM <%=__TABLE_NAME__%> <%=__WHERE_CLAUSE__%>");
    try {
        // $NON-NLS-1$
        netezzaDbmsLanguage.extractRegularExpressionFunction(createExpression, "<%=__PATTERN_EXPR__%>");
    } catch (UnsupportedOperationException e) {
        // $NON-NLS-1$
        Assert.fail("Default DbmsLanguage don't should call extractRegularExpressionFunction method should thorw UnsupportedOperationException.");
    }
}
Also used : TdExpression(org.talend.cwm.relational.TdExpression) RegularExpression(org.talend.dataquality.domain.pattern.RegularExpression) Expression(orgomg.cwm.objectmodel.core.Expression) Test(org.junit.Test)

Example 47 with Expression

use of orgomg.cwm.objectmodel.core.Expression in project tdq-studio-se by Talend.

the class DbmsLanguageTest method testGetSelectRegexpTestStringStringExpression.

/**
 * Test method for
 * {@link org.talend.dq.dbms.DbmsLanguage#getSelectRegexpTestString(java.lang.String, orgomg.cwm.objectmodel.core.Expression)}
 * .
 */
@Test
public void testGetSelectRegexpTestStringStringExpression() {
    try {
        // $NON-NLS-1$
        Expression createExpression = createExpression("Mysql");
        DbmsLanguage dbms = getMysqlDbmsLanguage();
        Assert.assertNotNull(dbms.getSelectRegexpTestString(REGEXP_STR, createExpression));
    } catch (Exception e) {
        fail(e.getMessage());
    }
}
Also used : TdExpression(org.talend.cwm.relational.TdExpression) RegularExpression(org.talend.dataquality.domain.pattern.RegularExpression) Expression(orgomg.cwm.objectmodel.core.Expression) Test(org.junit.Test)

Example 48 with Expression

use of orgomg.cwm.objectmodel.core.Expression in project tdq-studio-se by Talend.

the class DbmsLanguageTest method testSetFunctionReturnValueCase4.

/**
 * {@link org.talend.dq.dbms.DbmsLanguage#setFunctionReturnValue(Expression)}.
 *
 * case 4:Can not find the keyword for "THEN" in the body of expression.
 */
@Test
public void testSetFunctionReturnValueCase4() {
    // $NON-NLS-1$
    DbmsLanguage dbmsLanguage = DbmsLanguageFactory.createDbmsLanguage(DbmsLanguage.MSSQL, "1.0");
    Expression createExpression = CoreFactory.eINSTANCE.createExpression();
    // default Database
    // $NON-NLS-1$
    createExpression.setBody("**** WHEN RegularFunctionName(***)returnValue **)****");
    // $NON-NLS-1$
    dbmsLanguage.setFunctionReturnValue(dbmsLanguage.extractRegularExpressionFunctionReturnValue(createExpression, "***"));
    String regularfunctionReturnValue = dbmsLanguage.getFunctionReturnValue();
    Assert.assertEquals(StringUtils.EMPTY, regularfunctionReturnValue);
}
Also used : TdExpression(org.talend.cwm.relational.TdExpression) RegularExpression(org.talend.dataquality.domain.pattern.RegularExpression) Expression(orgomg.cwm.objectmodel.core.Expression) Test(org.junit.Test)

Example 49 with Expression

use of orgomg.cwm.objectmodel.core.Expression in project tdq-studio-se by Talend.

the class DbmsLanguageTest method testExtractRegularExpressionFunctionForVertica.

/**
 * {@link org.talend.dq.dbms.DbmsLanguage#extractRegularExpressionFunction(Expression)}.
 *
 * case 1:vertica database expression
 */
@Test
public void testExtractRegularExpressionFunctionForVertica() {
    DbmsLanguage netezzaDbmsLanguage = DbmsLanguageFactory.createDbmsLanguage(SupportDBUrlType.VERTICA);
    Expression createExpression = CoreFactory.eINSTANCE.createExpression();
    // Vertica Database
    // $NON-NLS-1$
    createExpression.setBody("**");
    // $NON-NLS-1$
    String regularFunctionName = netezzaDbmsLanguage.extractRegularExpressionFunction(createExpression, "***");
    // $NON-NLS-1$
    Assert.assertEquals("REGEXP_LIKE", regularFunctionName);
}
Also used : TdExpression(org.talend.cwm.relational.TdExpression) RegularExpression(org.talend.dataquality.domain.pattern.RegularExpression) Expression(orgomg.cwm.objectmodel.core.Expression) Test(org.junit.Test)

Example 50 with Expression

use of orgomg.cwm.objectmodel.core.Expression in project tdq-studio-se by Talend.

the class DbmsLanguageTest method testExtractRegularExpressionFunctionForOracle.

/**
 * {@link org.talend.dq.dbms.DbmsLanguage#extractRegularExpressionFunction(Expression)}.
 *
 * case 4:Oracle database expression
 */
@Test
public void testExtractRegularExpressionFunctionForOracle() {
    DbmsLanguage netezzaDbmsLanguage = DbmsLanguageFactory.createDbmsLanguage(SupportDBUrlType.ORACLEWITHSIDDEFAULTURL);
    Expression createExpression = CoreFactory.eINSTANCE.createExpression();
    // oracle Database
    // $NON-NLS-1$
    createExpression.setBody("**");
    // $NON-NLS-1$
    String regularFunctionName = netezzaDbmsLanguage.extractRegularExpressionFunction(createExpression, "***");
    // $NON-NLS-1$
    Assert.assertEquals("REGEXP_LIKE", regularFunctionName);
}
Also used : TdExpression(org.talend.cwm.relational.TdExpression) RegularExpression(org.talend.dataquality.domain.pattern.RegularExpression) Expression(orgomg.cwm.objectmodel.core.Expression) Test(org.junit.Test)

Aggregations

Expression (orgomg.cwm.objectmodel.core.Expression)71 TdExpression (org.talend.cwm.relational.TdExpression)42 RegularExpression (org.talend.dataquality.domain.pattern.RegularExpression)37 Test (org.junit.Test)25 Domain (org.talend.dataquality.domain.Domain)14 ArrayList (java.util.ArrayList)13 TdColumn (org.talend.cwm.relational.TdColumn)11 Pattern (org.talend.dataquality.domain.pattern.Pattern)10 Catalog (orgomg.cwm.resource.relational.Catalog)10 Indicator (org.talend.dataquality.indicators.Indicator)9 IndicatorParameters (org.talend.dataquality.indicators.IndicatorParameters)8 Analysis (org.talend.dataquality.analysis.Analysis)7 PatternMatchingIndicator (org.talend.dataquality.indicators.PatternMatchingIndicator)7 UDIndicatorDefinition (org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition)7 DbmsLanguage (org.talend.dq.dbms.DbmsLanguage)7 Connection (org.talend.core.model.metadata.builder.connection.Connection)6 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)6 AnalysisContext (org.talend.dataquality.analysis.AnalysisContext)6 IndicatorDefinition (org.talend.dataquality.indicators.definition.IndicatorDefinition)6 ChartDataEntity (org.talend.dq.indicators.preview.table.ChartDataEntity)6