Search in sources :

Example 41 with IndicatorParameters

use of org.talend.dataquality.indicators.IndicatorParameters 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 42 with IndicatorParameters

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

the class FrequencyStatisticsExplorerTest method testGetFreqRowsStatement_4.

/**
 * Test method for {@link org.talend.dq.analysis.explore.FrequencyStatisticsExplorer#getFreqRowsStatement()} case_3:
 * for UDIndicatorDefinition
 */
@Test
public void testGetFreqRowsStatement_4() {
    // create database construction
    TdTable table = org.talend.cwm.relational.RelationalFactory.eINSTANCE.createTdTable();
    // $NON-NLS-1$
    table.setName("TDQ_CALENDAR");
    TdColumn column = org.talend.cwm.relational.RelationalFactory.eINSTANCE.createTdColumn();
    // $NON-NLS-1$
    column.setName("CAL_DATE");
    TdSqlDataType tdsql = org.talend.cwm.relational.RelationalFactory.eINSTANCE.createTdSqlDataType();
    // $NON-NLS-1$
    tdsql.setName("DATE");
    tdsql.setJavaDataType(Types.DATE);
    column.setSqlDataType(tdsql);
    table.getOwnedElement().add(column);
    column.setOwner(table);
    // create indicator
    UserDefIndicator userDefIndicator = IndicatorSqlFactory.eINSTANCE.createUserDefIndicator();
    UDIndicatorDefinition indicatorDefinition = UserdefineFactory.eINSTANCE.createUDIndicatorDefinition();
    // $NON-NLS-1$
    indicatorDefinition.setName("user define count");
    userDefIndicator.setName(indicatorDefinition.getName());
    userDefIndicator.setIndicatorDefinition(indicatorDefinition);
    TdExpression newTdExp = // $NON-NLS-1$
    BooleanExpressionHelper.createTdExpression(// $NON-NLS-1$
    "SQL", "SELECT * FROM <%=__TABLE_NAME__%> <%=__WHERE_CLAUSE__%>", // $NON-NLS-1$
    null);
    newTdExp.setModificationDate(DateUtils.getCurrentDate(DateUtils.PATTERN_5));
    indicatorDefinition.getViewRowsExpression().add(newTdExp);
    // $NON-NLS-1$  //$NON-NLS-2$
    ChartDataEntity chartDataEntity = new ChartDataEntity(userDefIndicator, "2012-06-05", "1");
    chartDataEntity.setLabelNull(false);
    // $NON-NLS-1$
    chartDataEntity.setKey("2012-06-05");
    assertFalse(chartDataEntity.isLabelNull());
    userDefIndicator.setAnalyzedElement(column);
    IndicatorParameters indicatorParameters = IndicatorsFactory.eINSTANCE.createIndicatorParameters();
    indicatorParameters.setDateParameters(null);
    userDefIndicator.setParameters(indicatorParameters);
    assertNull(indicatorParameters.getDateParameters());
    AnalysisResult createAnalysisResult = AnalysisFactory.eINSTANCE.createAnalysisResult();
    ExecutionInformations createExecutionInformations = AnalysisFactory.eINSTANCE.createExecutionInformations();
    createAnalysisResult.setResultMetadata(createExecutionInformations);
    createAnalysisResult.getIndicators().add(userDefIndicator);
    userDefIndicator.setAnalyzedElement(column);
    ana.setResults(createAnalysisResult);
    freqExp = new FrequencyStatisticsExplorer();
    freqExp.setAnalysis(ana);
    freqExp.setEnitty(chartDataEntity);
    String clause = freqExp.getFreqRowsStatement();
    // $NON-NLS-1$
    assertEquals("SELECT * FROM TDQ_CALENDAR ", clause);
}
Also used : ExecutionInformations(org.talend.dataquality.analysis.ExecutionInformations) TdTable(org.talend.cwm.relational.TdTable) TdColumn(org.talend.cwm.relational.TdColumn) UDIndicatorDefinition(org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition) TdExpression(org.talend.cwm.relational.TdExpression) IndicatorParameters(org.talend.dataquality.indicators.IndicatorParameters) ChartDataEntity(org.talend.dq.indicators.preview.table.ChartDataEntity) TdSqlDataType(org.talend.cwm.relational.TdSqlDataType) UserDefIndicator(org.talend.dataquality.indicators.sql.UserDefIndicator) AnalysisResult(org.talend.dataquality.analysis.AnalysisResult) Test(org.junit.Test)

Example 43 with IndicatorParameters

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

the class PatternExplorerRealTest method setUp.

/**
 * DOC zshen Comment method "setUp".
 *
 * @throws java.lang.Exception
 */
@Before
public void setUp() throws Exception {
    patternExplorer = new RegexPatternExplorer();
    // mock setEntity
    PatternMatchingIndicator indicator = IndicatorsFactoryImpl.eINSTANCE.createRegexpMatchingIndicator();
    // create pattern parameter
    IndicatorParameters createIndicatorParameters = IndicatorsFactory.eINSTANCE.createIndicatorParameters();
    indicator.setParameters(createIndicatorParameters);
    Domain createDomain = DomainFactoryImpl.eINSTANCE.createDomain();
    createIndicatorParameters.setDataValidDomain(createDomain);
    Pattern createPattern = PatternFactoryImpl.eINSTANCE.createPattern();
    createDomain.getPatterns().add(createPattern);
    RegularExpression createPatternComponent = PatternFactoryImpl.eINSTANCE.createRegularExpression();
    createPattern.getComponents().add(createPatternComponent);
    TdExpression createTdExpression = RelationalFactoryImpl.eINSTANCE.createTdExpression();
    createPatternComponent.setExpression(createTdExpression);
    createTdExpression.setLanguage(SupportDBUrlType.HIVEDEFAULTURL.getLanguage());
    // $NON-NLS-1$
    createTdExpression.setBody("`su.*`");
    ModelElement element = RelationalFactoryImpl.eINSTANCE.createTdColumn();
    // $NON-NLS-1$
    element.setName("lname");
    indicator.setAnalyzedElement(element);
    Expression createIndiExpression = CoreFactoryImpl.eINSTANCE.createExpression();
    createIndiExpression.setLanguage(SupportDBUrlType.HIVEDEFAULTURL.getLanguage());
    // $NON-NLS-1$
    createIndiExpression.setBody("SELECT *  FROM `tbi`.`customer`  WHERE (customer.lname = \"sunny\")");
    indicator.setInstantiatedExpression(createIndiExpression);
    Analysis analysis = AnalysisFactoryImpl.eINSTANCE.createAnalysis();
    AnalysisContext createAnalysisContext = AnalysisFactoryImpl.eINSTANCE.createAnalysisContext();
    analysis.setContext(createAnalysisContext);
    DatabaseConnection createDatabaseConnection = ConnectionFactoryImpl.eINSTANCE.createDatabaseConnection();
    TaggedValueHelper.setTaggedValue(createDatabaseConnection, TaggedValueHelper.DB_PRODUCT_NAME, SupportDBUrlType.HIVEDEFAULTURL.getLanguage());
    // $NON-NLS-1$
    TaggedValueHelper.setTaggedValue(createDatabaseConnection, TaggedValueHelper.DB_PRODUCT_VERSION, "1.0");
    // $NON-NLS-1$
    TaggedValueHelper.setTaggedValue(createDatabaseConnection, TaggedValueHelper.DB_IDENTIFIER_QUOTE_STRING, "`");
    createAnalysisContext.setConnection(createDatabaseConnection);
    patternExplorer.setAnalysis(analysis);
    ChartDataEntity cdEntity = new ChartDataEntity();
    cdEntity.setIndicator(indicator);
    patternExplorer.setEnitty(cdEntity);
}
Also used : Pattern(org.talend.dataquality.domain.pattern.Pattern) RegularExpression(org.talend.dataquality.domain.pattern.RegularExpression) TdExpression(org.talend.cwm.relational.TdExpression) IndicatorParameters(org.talend.dataquality.indicators.IndicatorParameters) AnalysisContext(org.talend.dataquality.analysis.AnalysisContext) ChartDataEntity(org.talend.dq.indicators.preview.table.ChartDataEntity) ModelElement(orgomg.cwm.objectmodel.core.ModelElement) PatternMatchingIndicator(org.talend.dataquality.indicators.PatternMatchingIndicator) TdExpression(org.talend.cwm.relational.TdExpression) RegularExpression(org.talend.dataquality.domain.pattern.RegularExpression) Expression(orgomg.cwm.objectmodel.core.Expression) Analysis(org.talend.dataquality.analysis.Analysis) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) Domain(org.talend.dataquality.domain.Domain) Before(org.junit.Before)

Example 44 with IndicatorParameters

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

the class PatternExplorerRealTest method testGetValidValuesStatement_2.

/**
 * Test method for {@link org.talend.dq.analysis.explore.PatternExplorer#getValidValuesStatement()}. when the test
 * for indicator is user define indicator
 */
@Test
public void testGetValidValuesStatement_2() {
    patternExplorer = new RegexPatternExplorer();
    // mock setEntity
    PatternMatchingIndicator indicator = IndicatorsFactoryImpl.eINSTANCE.createRegexpMatchingIndicator();
    UDIndicatorDefinition indicatorDef = UserdefineFactoryImpl.eINSTANCE.createUDIndicatorDefinition();
    indicator.setIndicatorDefinition(indicatorDef);
    TdExpression udiTdExpression = RelationalFactoryImpl.eINSTANCE.createTdExpression();
    udiTdExpression.setLanguage(SupportDBUrlType.HIVEDEFAULTURL.getLanguage());
    udiTdExpression.setBody(ViewValidValues);
    indicatorDef.getViewValidValuesExpression().add(udiTdExpression);
    // create pattern parameter
    IndicatorParameters createIndicatorParameters = IndicatorsFactory.eINSTANCE.createIndicatorParameters();
    indicator.setParameters(createIndicatorParameters);
    Domain createDomain = DomainFactoryImpl.eINSTANCE.createDomain();
    createIndicatorParameters.setDataValidDomain(createDomain);
    Pattern createPattern = PatternFactoryImpl.eINSTANCE.createPattern();
    createDomain.getPatterns().add(createPattern);
    RegularExpression createPatternComponent = PatternFactoryImpl.eINSTANCE.createRegularExpression();
    createPattern.getComponents().add(createPatternComponent);
    TdExpression createTdExpression = RelationalFactoryImpl.eINSTANCE.createTdExpression();
    createPatternComponent.setExpression(createTdExpression);
    createTdExpression.setLanguage(SupportDBUrlType.HIVEDEFAULTURL.getLanguage());
    // $NON-NLS-1$
    createTdExpression.setBody("`su.*`");
    TdColumn element = RelationalFactoryImpl.eINSTANCE.createTdColumn();
    // $NON-NLS-1$
    element.setName("lname");
    TdTable createTdTable = RelationalFactoryImpl.eINSTANCE.createTdTable();
    // $NON-NLS-1$
    createTdTable.setName("table1");
    TableHelper.addColumn(createTdTable, element);
    Catalog createCatalog = orgomg.cwm.resource.relational.impl.RelationalFactoryImpl.eINSTANCE.createCatalog();
    // $NON-NLS-1$
    createCatalog.setName("catalog1");
    List<TdTable> tableList = new ArrayList<TdTable>();
    tableList.add(createTdTable);
    CatalogHelper.addTables(tableList, createCatalog);
    indicator.setAnalyzedElement(element);
    Expression createIndiExpression = CoreFactoryImpl.eINSTANCE.createExpression();
    createIndiExpression.setLanguage(SupportDBUrlType.HIVEDEFAULTURL.getLanguage());
    // $NON-NLS-1$
    createIndiExpression.setBody("SELECT *  FROM `tbi`.`customer`  WHERE (customer.lname = \"sunny\")");
    indicator.setInstantiatedExpression(createIndiExpression);
    Analysis analysis = AnalysisFactoryImpl.eINSTANCE.createAnalysis();
    AnalysisContext createAnalysisContext = AnalysisFactoryImpl.eINSTANCE.createAnalysisContext();
    analysis.setContext(createAnalysisContext);
    DatabaseConnection createDatabaseConnection = ConnectionFactoryImpl.eINSTANCE.createDatabaseConnection();
    TaggedValueHelper.setTaggedValue(createDatabaseConnection, TaggedValueHelper.DB_PRODUCT_NAME, SupportDBUrlType.HIVEDEFAULTURL.getLanguage());
    // $NON-NLS-1$
    TaggedValueHelper.setTaggedValue(createDatabaseConnection, TaggedValueHelper.DB_PRODUCT_VERSION, "1.0");
    // $NON-NLS-1$
    TaggedValueHelper.setTaggedValue(createDatabaseConnection, TaggedValueHelper.DB_IDENTIFIER_QUOTE_STRING, "`");
    createAnalysisContext.setConnection(createDatabaseConnection);
    patternExplorer.setAnalysis(analysis);
    ChartDataEntity cdEntity = new ChartDataEntity();
    cdEntity.setIndicator(indicator);
    patternExplorer.setEnitty(cdEntity);
    Assert.assertTrue(patternExplorer.setAnalysis(analysis));
    String clause = patternExplorer.getValidValuesStatement();
    // $NON-NLS-1$
    assertEquals("SELECT `lname` FROM `catalog1`.`table1` ", clause);
}
Also used : Pattern(org.talend.dataquality.domain.pattern.Pattern) RegularExpression(org.talend.dataquality.domain.pattern.RegularExpression) TdTable(org.talend.cwm.relational.TdTable) UDIndicatorDefinition(org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition) TdExpression(org.talend.cwm.relational.TdExpression) IndicatorParameters(org.talend.dataquality.indicators.IndicatorParameters) ArrayList(java.util.ArrayList) AnalysisContext(org.talend.dataquality.analysis.AnalysisContext) ChartDataEntity(org.talend.dq.indicators.preview.table.ChartDataEntity) Catalog(orgomg.cwm.resource.relational.Catalog) PatternMatchingIndicator(org.talend.dataquality.indicators.PatternMatchingIndicator) TdColumn(org.talend.cwm.relational.TdColumn) TdExpression(org.talend.cwm.relational.TdExpression) RegularExpression(org.talend.dataquality.domain.pattern.RegularExpression) Expression(orgomg.cwm.objectmodel.core.Expression) Analysis(org.talend.dataquality.analysis.Analysis) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) Domain(org.talend.dataquality.domain.Domain) Test(org.junit.Test)

Example 45 with IndicatorParameters

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

the class PatternExplorerRealTest method testGetInvalidRowsStatement_4.

/**
 * Test method for {@link org.talend.dq.analysis.explore.PatternExplorer#getInvalidRowsStatement()}. when the test
 * for indicator is user define indicator
 */
@Test
public void testGetInvalidRowsStatement_4() {
    patternExplorer = new RegexPatternExplorer();
    // mock setEntity
    PatternMatchingIndicator indicator = IndicatorsFactoryImpl.eINSTANCE.createRegexpMatchingIndicator();
    UDIndicatorDefinition indicatorDef = UserdefineFactoryImpl.eINSTANCE.createUDIndicatorDefinition();
    indicator.setIndicatorDefinition(indicatorDef);
    TdExpression udiTdExpression = RelationalFactoryImpl.eINSTANCE.createTdExpression();
    udiTdExpression.setLanguage(SupportDBUrlType.HIVEDEFAULTURL.getLanguage());
    udiTdExpression.setBody(ViewInvalidRows);
    indicatorDef.getViewInvalidRowsExpression().add(udiTdExpression);
    // create pattern parameter
    IndicatorParameters createIndicatorParameters = IndicatorsFactory.eINSTANCE.createIndicatorParameters();
    indicator.setParameters(createIndicatorParameters);
    Domain createDomain = DomainFactoryImpl.eINSTANCE.createDomain();
    createIndicatorParameters.setDataValidDomain(createDomain);
    Pattern createPattern = PatternFactoryImpl.eINSTANCE.createPattern();
    createDomain.getPatterns().add(createPattern);
    RegularExpression createPatternComponent = PatternFactoryImpl.eINSTANCE.createRegularExpression();
    createPattern.getComponents().add(createPatternComponent);
    TdExpression createTdExpression = RelationalFactoryImpl.eINSTANCE.createTdExpression();
    createPatternComponent.setExpression(createTdExpression);
    createTdExpression.setLanguage(SupportDBUrlType.HIVEDEFAULTURL.getLanguage());
    // $NON-NLS-1$
    createTdExpression.setBody("`su.*`");
    TdColumn element = RelationalFactoryImpl.eINSTANCE.createTdColumn();
    // $NON-NLS-1$
    element.setName("lname");
    TdTable createTdTable = RelationalFactoryImpl.eINSTANCE.createTdTable();
    // $NON-NLS-1$
    createTdTable.setName("table1");
    TableHelper.addColumn(createTdTable, element);
    Catalog createCatalog = orgomg.cwm.resource.relational.impl.RelationalFactoryImpl.eINSTANCE.createCatalog();
    // $NON-NLS-1$
    createCatalog.setName("catalog1");
    List<TdTable> tableList = new ArrayList<TdTable>();
    tableList.add(createTdTable);
    CatalogHelper.addTables(tableList, createCatalog);
    indicator.setAnalyzedElement(element);
    Expression createIndiExpression = CoreFactoryImpl.eINSTANCE.createExpression();
    createIndiExpression.setLanguage(SupportDBUrlType.HIVEDEFAULTURL.getLanguage());
    // $NON-NLS-1$
    createIndiExpression.setBody("SELECT *  FROM `tbi`.`customer`  WHERE (customer.lname = \"sunny\")");
    indicator.setInstantiatedExpression(createIndiExpression);
    Analysis analysis = AnalysisFactoryImpl.eINSTANCE.createAnalysis();
    AnalysisContext createAnalysisContext = AnalysisFactoryImpl.eINSTANCE.createAnalysisContext();
    analysis.setContext(createAnalysisContext);
    DatabaseConnection createDatabaseConnection = ConnectionFactoryImpl.eINSTANCE.createDatabaseConnection();
    TaggedValueHelper.setTaggedValue(createDatabaseConnection, TaggedValueHelper.DB_PRODUCT_NAME, SupportDBUrlType.HIVEDEFAULTURL.getLanguage());
    // $NON-NLS-1$
    TaggedValueHelper.setTaggedValue(createDatabaseConnection, TaggedValueHelper.DB_PRODUCT_VERSION, "1.0");
    // $NON-NLS-1$
    TaggedValueHelper.setTaggedValue(createDatabaseConnection, TaggedValueHelper.DB_IDENTIFIER_QUOTE_STRING, "`");
    createAnalysisContext.setConnection(createDatabaseConnection);
    ChartDataEntity cdEntity = new ChartDataEntity();
    cdEntity.setIndicator(indicator);
    Assert.assertTrue(patternExplorer.setAnalysis(analysis));
    patternExplorer.setEnitty(cdEntity);
    String clause = patternExplorer.getInvalidRowsStatement();
    // $NON-NLS-1$
    assertEquals("SELECT * FROM `catalog1`.`table1` WHERE NOT (id>=1) ", clause);
}
Also used : Pattern(org.talend.dataquality.domain.pattern.Pattern) RegularExpression(org.talend.dataquality.domain.pattern.RegularExpression) TdTable(org.talend.cwm.relational.TdTable) UDIndicatorDefinition(org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition) TdExpression(org.talend.cwm.relational.TdExpression) IndicatorParameters(org.talend.dataquality.indicators.IndicatorParameters) ArrayList(java.util.ArrayList) AnalysisContext(org.talend.dataquality.analysis.AnalysisContext) ChartDataEntity(org.talend.dq.indicators.preview.table.ChartDataEntity) Catalog(orgomg.cwm.resource.relational.Catalog) PatternMatchingIndicator(org.talend.dataquality.indicators.PatternMatchingIndicator) TdColumn(org.talend.cwm.relational.TdColumn) TdExpression(org.talend.cwm.relational.TdExpression) RegularExpression(org.talend.dataquality.domain.pattern.RegularExpression) Expression(orgomg.cwm.objectmodel.core.Expression) Analysis(org.talend.dataquality.analysis.Analysis) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) Domain(org.talend.dataquality.domain.Domain) Test(org.junit.Test)

Aggregations

IndicatorParameters (org.talend.dataquality.indicators.IndicatorParameters)65 Domain (org.talend.dataquality.domain.Domain)27 DateParameters (org.talend.dataquality.indicators.DateParameters)15 Test (org.junit.Test)14 TdColumn (org.talend.cwm.relational.TdColumn)14 Pattern (org.talend.dataquality.domain.pattern.Pattern)14 TdExpression (org.talend.cwm.relational.TdExpression)13 TextParameters (org.talend.dataquality.indicators.TextParameters)12 RegularExpression (org.talend.dataquality.domain.pattern.RegularExpression)10 ChartDataEntity (org.talend.dq.indicators.preview.table.ChartDataEntity)10 Indicator (org.talend.dataquality.indicators.Indicator)9 ArrayList (java.util.ArrayList)8 PatternMatchingIndicator (org.talend.dataquality.indicators.PatternMatchingIndicator)8 Expression (orgomg.cwm.objectmodel.core.Expression)8 RegexpMatchingIndicator (org.talend.dataquality.indicators.RegexpMatchingIndicator)7 UserDefIndicator (org.talend.dataquality.indicators.sql.UserDefIndicator)7 PhoneNumberUtil (com.google.i18n.phonenumbers.PhoneNumberUtil)6 PhoneNumber (com.google.i18n.phonenumbers.Phonenumber.PhoneNumber)6 Analysis (org.talend.dataquality.analysis.Analysis)6 UDIndicatorDefinition (org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition)6