Search in sources :

Example 21 with IndicatorDefinition

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

the class DbmsLanguageTest method testGetSqlExpressionDB2Case1.

/**
 * Test method for
 * {@link org.talend.dq.dbms.DbmsLanguage#getSqlExpression(IndicatorDefinition, String, EList, ProductVersion)} .
 */
@Test
public void testGetSqlExpressionDB2Case1() {
    // $NON-NLS-1$
    String sqlLang = "SQL";
    // $NON-NLS-1$
    String sqlBody = "SQL body";
    // $NON-NLS-1$
    String db2Lang = "DB2";
    // $NON-NLS-1$
    String db2Body = "DB2 body";
    // $NON-NLS-1$
    String db2NTLang = "DB2/NT";
    // $NON-NLS-1$
    String db2NTBody = "DB2/NT body";
    IndicatorDefinition indicatorDefinition = DefinitionFactory.eINSTANCE.createIndicatorDefinition();
    String language = db2NTLang;
    EList<TdExpression> sqlGenericExpression = new BasicEList<TdExpression>();
    TdExpression tdExpression1 = RelationalFactory.eINSTANCE.createTdExpression();
    tdExpression1.setLanguage(sqlLang);
    tdExpression1.setBody(sqlBody);
    sqlGenericExpression.add(tdExpression1);
    TdExpression tdExpression2 = RelationalFactory.eINSTANCE.createTdExpression();
    tdExpression2.setLanguage(db2Lang);
    tdExpression2.setBody(db2Body);
    sqlGenericExpression.add(tdExpression2);
    TdExpression tdExpression3 = RelationalFactory.eINSTANCE.createTdExpression();
    tdExpression3.setLanguage(db2NTLang);
    tdExpression3.setBody(db2NTBody);
    sqlGenericExpression.add(tdExpression3);
    ProductVersion dbVersion = new ProductVersion(1, 0);
    TdExpression sqlExpression = DbmsLanguage.getSqlExpression(indicatorDefinition, language, sqlGenericExpression, dbVersion);
    Assert.assertEquals(tdExpression3, sqlExpression);
}
Also used : TdExpression(org.talend.cwm.relational.TdExpression) BasicEList(org.eclipse.emf.common.util.BasicEList) ProductVersion(org.talend.utils.ProductVersion) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition) UDIndicatorDefinition(org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition) Test(org.junit.Test)

Example 22 with IndicatorDefinition

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

the class DbmsLanguageTest method testGetSqlExpressionRedshiftCase2.

/**
 * Test method for
 * {@link org.talend.dq.dbms.DbmsLanguage#getSqlExpression(IndicatorDefinition, String, EList, ProductVersion)} .
 */
@Test
public void testGetSqlExpressionRedshiftCase2() {
    // TDQ-11558 msjian: test for get sql expresstion for redshift database when there is no redshift defined
    // $NON-NLS-1$
    String sqlLang = "SQL";
    // $NON-NLS-1$
    String sqlBody = "SQL body";
    String redshiftLang = SupportDBUrlType.REDSHIFT.getLanguage();
    String postgresqlLang = SupportDBUrlType.POSTGRESQLEFAULTURL.getLanguage();
    // $NON-NLS-1$
    String postgresqlBody = "PostgreSQL body";
    IndicatorDefinition indicatorDefinition = DefinitionFactory.eINSTANCE.createIndicatorDefinition();
    EList<TdExpression> sqlGenericExpression = new BasicEList<TdExpression>();
    TdExpression tdExpression1 = RelationalFactory.eINSTANCE.createTdExpression();
    tdExpression1.setLanguage(sqlLang);
    tdExpression1.setBody(sqlBody);
    sqlGenericExpression.add(tdExpression1);
    TdExpression tdExpression3 = RelationalFactory.eINSTANCE.createTdExpression();
    tdExpression3.setLanguage(postgresqlLang);
    tdExpression3.setBody(postgresqlBody);
    sqlGenericExpression.add(tdExpression3);
    ProductVersion dbVersion = new ProductVersion(1, 0);
    TdExpression sqlExpression = DbmsLanguage.getSqlExpression(indicatorDefinition, redshiftLang, sqlGenericExpression, dbVersion);
    Assert.assertEquals(tdExpression3, sqlExpression);
}
Also used : TdExpression(org.talend.cwm.relational.TdExpression) BasicEList(org.eclipse.emf.common.util.BasicEList) ProductVersion(org.talend.utils.ProductVersion) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition) UDIndicatorDefinition(org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition) Test(org.junit.Test)

Example 23 with IndicatorDefinition

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

the class DbmsLanguageTest method testGetPatternFinderFunctionStringEListOfCharactersMappingCase1.

/**
 * Test method for
 * {@link org.talend.dq.dbms.DbmsLanguage#getPatternFinderFunction(java.lang.String, org.eclipse.emf.common.util.EList)}
 * .
 *
 * case 1 : netezza case
 */
@Test
public void testGetPatternFinderFunctionStringEListOfCharactersMappingCase1() {
    // $NON-NLS-1$
    String expectedResult = "TRANSLATE(name , \'abcdefghijklmnopqrstuvwxyzçâêîôûéèùïöüABCDEFGHIJKLMNOPQRSTUVWXYZÇÂÊÎÔÛÉÈÙÏÖÜ0123456789Netezza\' , \'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA9999999999Netezza\')";
    NetezzaDbmsLanguage netezzaDbmsLanguage = (NetezzaDbmsLanguage) DbmsLanguageFactory.createDbmsLanguage(SupportDBUrlType.NETEZZADEFAULTURL);
    IndicatorDefinition createIndicatorDefinition = DefinitionFactory.eINSTANCE.createIndicatorDefinition();
    EList<CharactersMapping> charactersMapping = createIndicatorDefinition.getCharactersMapping();
    CharactersMapping createCharactersMapping = DefinitionFactory.eINSTANCE.createCharactersMapping();
    // mysql
    createCharactersMapping.setLanguage(SupportDBUrlType.MYSQLDEFAULTURL.getLanguage());
    createCharactersMapping.setCharactersToReplace(// $NON-NLS-1$
    "abcdefghijklmnopqrstuvwxyzçâêîôûéèùïöüABCDEFGHIJKLMNOPQRSTUVWXYZÇÂÊÎÔÛÉÈÙÏÖÜ0123456789MySql");
    createCharactersMapping.setReplacementCharacters(// $NON-NLS-1$
    "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA9999999999MySql");
    charactersMapping.add(createCharactersMapping);
    // ~mysql
    // default
    createCharactersMapping.setLanguage(DbmsLanguage.SQL);
    createCharactersMapping.setCharactersToReplace(// $NON-NLS-1$
    "abcdefghijklmnopqrstuvwxyzçâêîôûéèùïöüABCDEFGHIJKLMNOPQRSTUVWXYZÇÂÊÎÔÛÉÈÙÏÖÜ0123456789Default");
    createCharactersMapping.setReplacementCharacters(// $NON-NLS-1$
    "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA9999999999Default");
    charactersMapping.add(createCharactersMapping);
    // ~default
    // netezza
    createCharactersMapping.setLanguage(SupportDBUrlType.NETEZZADEFAULTURL.getLanguage());
    createCharactersMapping.setCharactersToReplace(// $NON-NLS-1$
    "abcdefghijklmnopqrstuvwxyzçâêîôûéèùïöüABCDEFGHIJKLMNOPQRSTUVWXYZÇÂÊÎÔÛÉÈÙÏÖÜ0123456789Netezza");
    createCharactersMapping.setReplacementCharacters(// $NON-NLS-1$
    "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA9999999999Netezza");
    charactersMapping.add(createCharactersMapping);
    // ~netezza
    // $NON-NLS-1$
    String patternFinderFunction = netezzaDbmsLanguage.getPatternFinderFunction("name", charactersMapping);
    Assert.assertEquals(expectedResult, patternFinderFunction);
}
Also used : CharactersMapping(org.talend.dataquality.indicators.definition.CharactersMapping) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition) UDIndicatorDefinition(org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition) Test(org.junit.Test)

Example 24 with IndicatorDefinition

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

the class DbmsLanguageTest method testGetSqlExpressionDB2Case2.

/**
 * Test method for
 * {@link org.talend.dq.dbms.DbmsLanguage#getSqlExpression(IndicatorDefinition, String, EList, ProductVersion)} .
 */
@Test
public void testGetSqlExpressionDB2Case2() {
    // $NON-NLS-1$
    String sqlLang = "SQL";
    // $NON-NLS-1$
    String sqlBody = "SQL body";
    // $NON-NLS-1$
    String db2Lang = "DB2";
    // $NON-NLS-1$
    String db2Body = "DB2 body";
    // $NON-NLS-1$
    String db2NTLang = "DB2/NT";
    // $NON-NLS-1$
    String db2NTBody = "DB2/NT body";
    IndicatorDefinition indicatorDefinition = DefinitionFactory.eINSTANCE.createIndicatorDefinition();
    String language = db2Lang;
    EList<TdExpression> sqlGenericExpression = new BasicEList<TdExpression>();
    TdExpression tdExpression1 = RelationalFactory.eINSTANCE.createTdExpression();
    tdExpression1.setLanguage(sqlLang);
    tdExpression1.setBody(sqlBody);
    sqlGenericExpression.add(tdExpression1);
    TdExpression tdExpression2 = RelationalFactory.eINSTANCE.createTdExpression();
    tdExpression2.setLanguage(db2Lang);
    tdExpression2.setBody(db2Body);
    sqlGenericExpression.add(tdExpression2);
    TdExpression tdExpression3 = RelationalFactory.eINSTANCE.createTdExpression();
    tdExpression3.setLanguage(db2NTLang);
    tdExpression3.setBody(db2NTBody);
    sqlGenericExpression.add(tdExpression3);
    ProductVersion dbVersion = new ProductVersion(1, 0);
    TdExpression sqlExpression = DbmsLanguage.getSqlExpression(indicatorDefinition, language, sqlGenericExpression, dbVersion);
    Assert.assertEquals(tdExpression2, sqlExpression);
}
Also used : TdExpression(org.talend.cwm.relational.TdExpression) BasicEList(org.eclipse.emf.common.util.BasicEList) ProductVersion(org.talend.utils.ProductVersion) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition) UDIndicatorDefinition(org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition) Test(org.junit.Test)

Example 25 with IndicatorDefinition

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

the class DbmsLanguageTest method testGetPatternFinderFunctionStringEListOfCharactersMappingCase3.

/**
 * Test method for
 * {@link org.talend.dq.dbms.DbmsLanguage#getPatternFinderFunction(java.lang.String, org.eclipse.emf.common.util.EList)}
 * .
 *
 * case 3 : no default and no netezza
 */
@Test
public void testGetPatternFinderFunctionStringEListOfCharactersMappingCase3() {
    String expectedResult = null;
    NetezzaDbmsLanguage netezzaDbmsLanguage = (NetezzaDbmsLanguage) DbmsLanguageFactory.createDbmsLanguage(SupportDBUrlType.NETEZZADEFAULTURL);
    IndicatorDefinition createIndicatorDefinition = DefinitionFactory.eINSTANCE.createIndicatorDefinition();
    EList<CharactersMapping> charactersMapping = createIndicatorDefinition.getCharactersMapping();
    CharactersMapping createCharactersMapping = DefinitionFactory.eINSTANCE.createCharactersMapping();
    // mysql
    createCharactersMapping.setLanguage(SupportDBUrlType.MYSQLDEFAULTURL.getLanguage());
    createCharactersMapping.setCharactersToReplace(// $NON-NLS-1$
    "abcdefghijklmnopqrstuvwxyzçâêîôûéèùïöüABCDEFGHIJKLMNOPQRSTUVWXYZÇÂÊÎÔÛÉÈÙÏÖÜ0123456789MySql");
    createCharactersMapping.setReplacementCharacters(// $NON-NLS-1$
    "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA9999999999MySql");
    charactersMapping.add(createCharactersMapping);
    // ~mysql
    // $NON-NLS-1$
    String patternFinderFunction = netezzaDbmsLanguage.getPatternFinderFunction("name", charactersMapping);
    Assert.assertEquals(expectedResult, patternFinderFunction);
}
Also used : CharactersMapping(org.talend.dataquality.indicators.definition.CharactersMapping) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition) UDIndicatorDefinition(org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition) Test(org.junit.Test)

Aggregations

IndicatorDefinition (org.talend.dataquality.indicators.definition.IndicatorDefinition)141 UDIndicatorDefinition (org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition)37 Test (org.junit.Test)35 ArrayList (java.util.ArrayList)34 TdExpression (org.talend.cwm.relational.TdExpression)31 File (java.io.File)22 Analysis (org.talend.dataquality.analysis.Analysis)16 IFile (org.eclipse.core.resources.IFile)15 Property (org.talend.core.model.properties.Property)14 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)14 TDQIndicatorDefinitionItem (org.talend.dataquality.properties.TDQIndicatorDefinitionItem)14 PersistenceException (org.talend.commons.exception.PersistenceException)13 Indicator (org.talend.dataquality.indicators.Indicator)12 ModelElement (orgomg.cwm.objectmodel.core.ModelElement)12 Path (org.eclipse.core.runtime.Path)10 IFolder (org.eclipse.core.resources.IFolder)9 BasicEList (org.eclipse.emf.common.util.BasicEList)9 TdColumn (org.talend.cwm.relational.TdColumn)9 UserDefIndicator (org.talend.dataquality.indicators.sql.UserDefIndicator)7 TDQAnalysisItem (org.talend.dataquality.properties.TDQAnalysisItem)7