Search in sources :

Example 1 with RegexpMatchingIndicator

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

the class ColumnSetAnalysisDetailsPage method refreshIndicatorsSection.

/**
 * refresh the Indicators Section.
 */
public void refreshIndicatorsSection() {
    // when there have pattern, show allmatchindicator
    ModelElementIndicator[] modelElementIndicator = treeViewer.getModelElementIndicator();
    if (modelElementIndicator != null) {
        for (ModelElementIndicator modelElementInd : modelElementIndicator) {
            Indicator[] inds = modelElementInd.getPatternIndicators();
            for (Indicator ind : inds) {
                if (ind instanceof RegexpMatchingIndicator) {
                    indicatorsViewer.setInput(simpleStatIndicator, allMatchIndicator);
                    return;
                }
            }
        }
    }
    indicatorsViewer.setInput(simpleStatIndicator);
}
Also used : RegexpMatchingIndicator(org.talend.dataquality.indicators.RegexpMatchingIndicator) RegexpMatchingIndicator(org.talend.dataquality.indicators.RegexpMatchingIndicator) AllMatchIndicator(org.talend.dataquality.indicators.columnset.AllMatchIndicator) ModelElementIndicator(org.talend.dataprofiler.core.model.ModelElementIndicator) Indicator(org.talend.dataquality.indicators.Indicator) CompositeIndicator(org.talend.dataquality.indicators.CompositeIndicator) SimpleStatIndicator(org.talend.dataquality.indicators.columnset.SimpleStatIndicator) ModelElementIndicator(org.talend.dataprofiler.core.model.ModelElementIndicator)

Example 2 with RegexpMatchingIndicator

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

the class PatternStatisticeStateUtilTest method testGetUnitValueCase1.

/**
 * Test method for
 * {@link org.talend.dataprofiler.core.ui.editor.preview.model.states.pattern.PatternStatisticeStateUtil#getUnitValue(org.talend.dataquality.indicators.Indicator, java.lang.Object)}
 * .
 * case1:normal RegexpMatchingIndicator case
 */
@Test
public void testGetUnitValueCase1() {
    Object pMatchExt = null;
    RegexpMatchingIndicator regexpMatchingIndicator = IndicatorsFactoryImpl.eINSTANCE.createRegexpMatchingIndicator();
    regexpMatchingIndicator.setComputed(true);
    regexpMatchingIndicator.setMatchingValueCount(40l);
    regexpMatchingIndicator.setNotMatchingValueCount(50l);
    PatternMatchingExt unitValue = PatternStatisticeStateUtil.getUnitValue(regexpMatchingIndicator, pMatchExt);
    // $NON-NLS-1$
    Assert.assertEquals("Matching count value shoud be 40l", 40l, unitValue.getMatchingValueCount());
    // $NON-NLS-1$
    Assert.assertEquals("Not matching count value shoud be 50l", 50l, unitValue.getNotMatchingValueCount());
}
Also used : RegexpMatchingIndicator(org.talend.dataquality.indicators.RegexpMatchingIndicator) PatternMatchingExt(org.talend.dq.indicators.ext.PatternMatchingExt) Test(org.junit.Test)

Example 3 with RegexpMatchingIndicator

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

the class RegexpMatchingIndicatorImplTest method testGetRegexFail2DomainIsNull.

/**
 * Test method for {@link org.talend.dataquality.indicators.impl.RegexpMatchingIndicatorImpl#getJavaRegex()}.
 */
@Test
public void testGetRegexFail2DomainIsNull() {
    // RegexpMatchingIndicator
    RegexpMatchingIndicator createRegexpMatchingIndicator = IndicatorsFactory.eINSTANCE.createRegexpMatchingIndicator();
    // ~RegexpMatchingIndicator
    // IndicatorParameters
    IndicatorParameters createIndicatorParameters = IndicatorsFactory.eINSTANCE.createIndicatorParameters();
    // ~IndicatorParameters
    createRegexpMatchingIndicator.setParameters(createIndicatorParameters);
    // call getRegex()
    String regexResult = createRegexpMatchingIndicator.getRegex();
    // ~call getRegex()
    Assert.assertTrue(regexResult == null);
}
Also used : IndicatorParameters(org.talend.dataquality.indicators.IndicatorParameters) RegexpMatchingIndicator(org.talend.dataquality.indicators.RegexpMatchingIndicator) Test(org.junit.Test)

Example 4 with RegexpMatchingIndicator

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

the class RegexpMatchingIndicatorImplTest method testGetRegexFail1NotJavaRegex.

/**
 * Test method for {@link org.talend.dataquality.indicators.impl.RegexpMatchingIndicatorImpl#getJavaRegex()}.
 */
@Test
public void testGetRegexFail1NotJavaRegex() {
    // RegexpMatchingIndicator
    RegexpMatchingIndicator createRegexpMatchingIndicator = IndicatorsFactory.eINSTANCE.createRegexpMatchingIndicator();
    // ~RegexpMatchingIndicator
    // IndicatorParameters
    IndicatorParameters createIndicatorParameters = IndicatorsFactory.eINSTANCE.createIndicatorParameters();
    // ~IndicatorParameters
    // Domain
    Domain createDomain = DomainFactory.eINSTANCE.createDomain();
    EList<Pattern> patterns = createDomain.getPatterns();
    // ~Domain
    // Pattern
    Pattern createJavaPattern = PatternFactory.eINSTANCE.createPattern();
    Pattern createSQLPattern = PatternFactory.eINSTANCE.createPattern();
    Pattern createMSSQLPattern = PatternFactory.eINSTANCE.createPattern();
    patterns.add(createJavaPattern);
    patterns.add(createSQLPattern);
    patterns.add(createMSSQLPattern);
    // ~Pattern
    // init java Pattern data
    RegularExpression createJavaRegularExpression = PatternFactory.eINSTANCE.createRegularExpression();
    TdExpression createJavaTdExpression = RelationalFactory.eINSTANCE.createTdExpression();
    createJavaTdExpression.setBody(JavaRegex);
    createJavaTdExpression.setLanguage("Microsoft SQL Server");
    createJavaRegularExpression.setExpression(createJavaTdExpression);
    createJavaRegularExpression.setExpressionType(ExpressionType.REGEXP.getLiteral());
    EList<PatternComponent> components = createJavaPattern.getComponents();
    components.add(createJavaRegularExpression);
    // ~init java Pattern data
    createIndicatorParameters.setDataValidDomain(createDomain);
    createRegexpMatchingIndicator.setParameters(createIndicatorParameters);
    TdColumn column = RelationalFactory.eINSTANCE.createTdColumn();
    MetadataTable mdColumn = RelationalFactory.eINSTANCE.createTdTable();
    column.setTable(mdColumn);
    createRegexpMatchingIndicator.setAnalyzedElement(column);
    // call getRegex()
    String regexResult = createRegexpMatchingIndicator.getRegex();
    // ~call getRegex()
    Assert.assertTrue(regexResult == null);
}
Also used : Pattern(org.talend.dataquality.domain.pattern.Pattern) RegularExpression(org.talend.dataquality.domain.pattern.RegularExpression) TdColumn(org.talend.cwm.relational.TdColumn) TdExpression(org.talend.cwm.relational.TdExpression) IndicatorParameters(org.talend.dataquality.indicators.IndicatorParameters) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) PatternComponent(org.talend.dataquality.domain.pattern.PatternComponent) RegexpMatchingIndicator(org.talend.dataquality.indicators.RegexpMatchingIndicator) Domain(org.talend.dataquality.domain.Domain) Test(org.junit.Test)

Example 5 with RegexpMatchingIndicator

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

the class RegexpMatchingIndicatorImplTest method testGetRegexWithDefaultSQLWhenNoJava.

/**
 * Test method for {@link org.talend.dataquality.indicators.impl.RegexpMatchingIndicatorImpl#getJavaRegex()}.
 */
@Test
public void testGetRegexWithDefaultSQLWhenNoJava() {
    // RegexpMatchingIndicator
    RegexpMatchingIndicator createRegexpMatchingIndicator = IndicatorsFactory.eINSTANCE.createRegexpMatchingIndicator();
    // ~RegexpMatchingIndicator
    // IndicatorParameters
    IndicatorParameters createIndicatorParameters = IndicatorsFactory.eINSTANCE.createIndicatorParameters();
    // ~IndicatorParameters
    // Domain
    Domain createDomain = DomainFactory.eINSTANCE.createDomain();
    EList<Pattern> patterns = createDomain.getPatterns();
    // ~Domain
    // Pattern
    Pattern createSQLPattern = PatternFactory.eINSTANCE.createPattern();
    Pattern createMSSQLPattern = PatternFactory.eINSTANCE.createPattern();
    patterns.add(createSQLPattern);
    patterns.add(createMSSQLPattern);
    // ~Pattern
    // init default:SQL Pattern data
    RegularExpression createDefaultExpression = PatternFactory.eINSTANCE.createRegularExpression();
    TdExpression createDefaultTdExpression = RelationalFactory.eINSTANCE.createTdExpression();
    createDefaultTdExpression.setBody("'sql body'");
    createDefaultTdExpression.setLanguage("SQL");
    createDefaultExpression.setExpression(createDefaultTdExpression);
    createDefaultExpression.setExpressionType(ExpressionType.REGEXP.getLiteral());
    EList<PatternComponent> components = createSQLPattern.getComponents();
    components.add(createDefaultExpression);
    // ~init default Pattern data
    createIndicatorParameters.setDataValidDomain(createDomain);
    createRegexpMatchingIndicator.setParameters(createIndicatorParameters);
    // call getRegex()
    String regexResult = createRegexpMatchingIndicator.getRegex();
    // ~call getRegex()
    Assert.assertTrue("sql body".equalsIgnoreCase(regexResult));
}
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) PatternComponent(org.talend.dataquality.domain.pattern.PatternComponent) RegexpMatchingIndicator(org.talend.dataquality.indicators.RegexpMatchingIndicator) Domain(org.talend.dataquality.domain.Domain) Test(org.junit.Test)

Aggregations

RegexpMatchingIndicator (org.talend.dataquality.indicators.RegexpMatchingIndicator)18 IndicatorParameters (org.talend.dataquality.indicators.IndicatorParameters)7 ArrayList (java.util.ArrayList)6 Test (org.junit.Test)6 Pattern (org.talend.dataquality.domain.pattern.Pattern)6 Domain (org.talend.dataquality.domain.Domain)5 Indicator (org.talend.dataquality.indicators.Indicator)5 AllMatchIndicator (org.talend.dataquality.indicators.columnset.AllMatchIndicator)5 ModelElement (orgomg.cwm.objectmodel.core.ModelElement)4 TdExpression (org.talend.cwm.relational.TdExpression)3 PatternComponent (org.talend.dataquality.domain.pattern.PatternComponent)3 RegularExpression (org.talend.dataquality.domain.pattern.RegularExpression)3 PatternMatchingIndicator (org.talend.dataquality.indicators.PatternMatchingIndicator)3 HashMap (java.util.HashMap)2 Matcher (java.util.regex.Matcher)2 Pattern (java.util.regex.Pattern)2 ModelElementIndicator (org.talend.dataprofiler.core.model.ModelElementIndicator)2 Analysis (org.talend.dataquality.analysis.Analysis)2 CompositeIndicator (org.talend.dataquality.indicators.CompositeIndicator)2 SimpleStatIndicator (org.talend.dataquality.indicators.columnset.SimpleStatIndicator)2