Search in sources :

Example 11 with Expression

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

the class DbmsLanguageTest method testSetFunctionReturnValueCase1.

/**
 * {@link org.talend.dq.dbms.DbmsLanguage#setFunctionReturnValue(Expression)}.
 *
 * case 1:The body of expression is null
 */
@Test
public void testSetFunctionReturnValueCase1() {
    // $NON-NLS-1$
    DbmsLanguage dbmsLanguage = DbmsLanguageFactory.createDbmsLanguage(DbmsLanguage.MSSQL, "1.0");
    Expression createExpression = CoreFactory.eINSTANCE.createExpression();
    // $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 12 with Expression

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

the class DbmsLanguageTest method testSetFunctionReturnValueCase6.

/**
 * {@link org.talend.dq.dbms.DbmsLanguage#setFunctionReturnValue(Expression)}.
 *
 * case 6: dbmsLanguage is sql
 */
@Test
public void testSetFunctionReturnValueCase6() {
    // $NON-NLS-1$ //$NON-NLS-2$
    DbmsLanguage dbmsLanguage = DbmsLanguageFactory.createDbmsLanguage("sql", "1.0");
    Expression createExpression = CoreFactory.eINSTANCE.createExpression();
    // default Database
    // $NON-NLS-1$
    createExpression.setBody("**** WHEN RegularFunctionName(***)returnValue THEN **)****");
    // $NON-NLS-1$
    dbmsLanguage.setFunctionReturnValue(dbmsLanguage.extractRegularExpressionFunctionReturnValue(createExpression, "***"));
    String regularfunctionReturnValue = dbmsLanguage.getFunctionReturnValue();
    // $NON-NLS-1$
    Assert.assertEquals("RETURNVALUE", 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 13 with Expression

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

the class DbmsLanguageTest method testExtractRegularExpressionFunctionForOthers.

/**
 * {@link org.talend.dq.dbms.DbmsLanguage#extractRegularExpressionFunction(Expression)}.
 *
 * case 7:Other database expression
 */
@Test
public void testExtractRegularExpressionFunctionForOthers() {
    // $NON-NLS-1$ //$NON-NLS-2$
    DbmsLanguage netezzaDbmsLanguage = DbmsLanguageFactory.createDbmsLanguage("SQL", "0.1");
    Expression createExpression = CoreFactory.eINSTANCE.createExpression();
    // default case
    // $NON-NLS-1$
    createExpression.setBody("**** WHEN RegularFunctionName(***)returnValue THEN **)****");
    try {
        // $NON-NLS-1$
        netezzaDbmsLanguage.extractRegularExpressionFunction(createExpression, "***");
    } 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 14 with Expression

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

the class AnalysisColumnTreeViewer method isExpressionNull.

private String isExpressionNull(TreeItem item) {
    String expressContent = null;
    ModelElement me = null;
    IndicatorUnit indicatorUnit = (IndicatorUnit) item.getData(INDICATOR_UNIT_KEY);
    ModelElementIndicator meIndicator = (ModelElementIndicator) item.getData(MODELELEMENT_INDICATOR_KEY);
    if (indicatorUnit != null) {
        IRepositoryViewObject reposViewObj = meIndicator.getModelElementRepositoryNode().getObject();
        // MetadataXmlElementTypeRepositoryObject
        if (reposViewObj instanceof MetadataColumnRepositoryObject) {
            me = ((MetadataColumnRepositoryObject) reposViewObj).getTdColumn();
        }
        Connection dataprovider = ModelElementHelper.getTdDataProvider(me);
        DbmsLanguage dbmsLang = DbmsLanguageFactory.createDbmsLanguage(dataprovider);
        Expression expression = dbmsLang.getInstantiatedExpression(indicatorUnit.getIndicator());
        if (expression != null) {
            expressContent = expression.getBody();
        }
    } else {
        IRepositoryNode parentNodeForColumnNode = RepositoryNodeHelper.getParentNodeForColumnNode(meIndicator.getModelElementRepositoryNode());
        expressContent = DefaultMessagesImpl.getString("AnalysisColumnTreeViewer.columnParent", // $NON-NLS-1$ //;
        parentNodeForColumnNode.getObject().getLabel());
    }
    return expressContent;
}
Also used : DbmsLanguage(org.talend.dq.dbms.DbmsLanguage) ModelElement(orgomg.cwm.objectmodel.core.ModelElement) IRepositoryNode(org.talend.repository.model.IRepositoryNode) Expression(orgomg.cwm.objectmodel.core.Expression) IndicatorUnit(org.talend.dataprofiler.core.ui.editor.preview.IndicatorUnit) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) Connection(org.talend.core.model.metadata.builder.connection.Connection) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) ModelElementIndicator(org.talend.dataprofiler.core.model.ModelElementIndicator)

Example 15 with Expression

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

the class RegexPatternExplorer method initRegularExpressionParameter.

@Override
protected void initRegularExpressionParameter() {
    // MOD gdbu 2011-12-5 TDQ-4087 get function name from sql sentence when use MSSQL
    EList<Expression> instantiatedExpressions = indicator.getInstantiatedExpressions();
    if (instantiatedExpressions.size() > 0) {
        Expression expression = instantiatedExpressions.get(0);
        String regexp = dbmsLanguage.getRegexPatternString(indicator);
        dbmsLanguage.setRegularExpressionFunction(dbmsLanguage.extractRegularExpressionFunction(expression, regexp));
        dbmsLanguage.setFunctionReturnValue(dbmsLanguage.extractRegularExpressionFunctionReturnValue(expression, regexp));
    }
}
Also used : Expression(orgomg.cwm.objectmodel.core.Expression)

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