Search in sources :

Example 1 with PatternMatchingExt

use of org.talend.dq.indicators.ext.PatternMatchingExt 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 2 with PatternMatchingExt

use of org.talend.dq.indicators.ext.PatternMatchingExt in project tdq-studio-se by Talend.

the class PatternStatisticeStateUtilTest method testGetUnitValueCase2.

/**
 * Test method for
 * {@link org.talend.dataprofiler.core.ui.editor.preview.model.states.pattern.PatternStatisticeStateUtil#getUnitValue(org.talend.dataquality.indicators.Indicator, java.lang.Object)}
 * .
 * case2:normal UDI case
 */
@Test
public void testGetUnitValueCase2() {
    PatternMatchingExt pMatchExt = null;
    UserDefIndicator userDefIndicator = IndicatorSqlFactoryImpl.eINSTANCE.createUserDefIndicator();
    userDefIndicator.setComputed(true);
    userDefIndicator.setMatchingValueCount(40l);
    userDefIndicator.setNotMatchingValueCount(50l);
    PatternMatchingExt unitValue = PatternStatisticeStateUtil.getUnitValue(userDefIndicator, 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());
    // $NON-NLS-1$
    Assert.assertNotEquals("unitValue should not same with pMatchExt but it is not now", pMatchExt, unitValue);
}
Also used : PatternMatchingExt(org.talend.dq.indicators.ext.PatternMatchingExt) UserDefIndicator(org.talend.dataquality.indicators.sql.UserDefIndicator) Test(org.junit.Test)

Example 3 with PatternMatchingExt

use of org.talend.dq.indicators.ext.PatternMatchingExt in project tdq-studio-se by Talend.

the class AnalysisExecutor method hasOutThreshold.

/**
 * DOC qiongli Comment method "hasOutThreshold".
 *
 * @param indicator
 * @return
 */
private boolean hasOutThreshold(Indicator indicator) {
    String[] indicatorThreshold = IndicatorHelper.getIndicatorThreshold(indicator);
    String[] indiPercentThreshold = IndicatorHelper.getIndicatorThresholdInPercent(indicator);
    Object obj = IndicatorCommonUtil.getIndicatorValue(indicator);
    if (indicatorThreshold != null || indiPercentThreshold != null) {
        // MOD qiongli 2011-11-15 TDQ-3690 avoid String "null",and get the value for ValueIndicator to transfer.
        if (obj != null && !PluginConstant.EMPTY_STRING.equals(obj.toString()) && !"null".equalsIgnoreCase(obj.toString())) {
            // $NON-NLS-1$
            String value = PluginConstant.EMPTY_STRING;
            if (indicator instanceof ValueIndicator) {
                value = ((ValueIndicator) indicator).getValue();
            }
            ChartDataEntity chartDataEntity = new ChartDataEntity(indicator, PluginConstant.EMPTY_STRING, value);
            if (obj instanceof PatternMatchingExt) {
                obj = (((PatternMatchingExt) obj).getMatchingValueCount());
            }
            if (chartDataEntity.isOutOfRange(obj.toString())) {
                return true;
            }
        }
    }
    List<Indicator> leaves = IndicatorHelper.getIndicatorLeaves(indicator);
    if (leaves.size() > 0 && !leaves.get(0).equals(indicator)) {
        for (Indicator leaveIndicator : leaves) {
            if (hasOutThreshold(leaveIndicator)) {
                return true;
            }
        }
    }
    return false;
}
Also used : ValueIndicator(org.talend.dataquality.indicators.ValueIndicator) PatternMatchingExt(org.talend.dq.indicators.ext.PatternMatchingExt) ChartDataEntity(org.talend.dq.indicators.preview.table.ChartDataEntity) Indicator(org.talend.dataquality.indicators.Indicator) ValueIndicator(org.talend.dataquality.indicators.ValueIndicator)

Example 4 with PatternMatchingExt

use of org.talend.dq.indicators.ext.PatternMatchingExt in project tdq-studio-se by Talend.

the class IndicatorCommonUtil method handleMatchingValue.

/**
 * DOC xqliu Comment method "handleMatchingValue".
 *
 * @param indicator
 * @return
 */
public static PatternMatchingExt handleMatchingValue(Indicator indicator) {
    PatternMatchingExt patternExt = new PatternMatchingExt();
    if (UDIHelper.isUDI(indicator)) {
        UserDefIndicator udi = (UserDefIndicator) indicator;
        if (udi.getMatchingValueCount() != null) {
            patternExt.setMatchingValueCount(udi.getMatchingValueCount());
        }
        if (udi.getNotMatchingValueCount() != null) {
            patternExt.setNotMatchingValueCount(udi.getNotMatchingValueCount());
        }
    } else {
        // TDQ-12282 msjian : fix a NPE
        Long matchingValueCount = ((PatternMatchingIndicator) indicator).getMatchingValueCount();
        patternExt.setMatchingValueCount(matchingValueCount == null ? 0l : matchingValueCount);
        Long notMatchingValueCount = ((PatternMatchingIndicator) indicator).getNotMatchingValueCount();
        patternExt.setNotMatchingValueCount(notMatchingValueCount == null ? 0l : notMatchingValueCount);
    }
    return patternExt;
}
Also used : PatternMatchingIndicator(org.talend.dataquality.indicators.PatternMatchingIndicator) PatternMatchingExt(org.talend.dq.indicators.ext.PatternMatchingExt) UserDefIndicator(org.talend.dataquality.indicators.sql.UserDefIndicator)

Example 5 with PatternMatchingExt

use of org.talend.dq.indicators.ext.PatternMatchingExt in project tdq-studio-se by Talend.

the class PatternStatisticsTableState method getDataEntity.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.dataprofiler.core.ui.editor.preview.model.states.table.AbstractTableTypeStates#getDataEntity()
     */
@Override
public ChartDataEntity[] getDataEntity() {
    List<ChartDataEntity> dataEnities = new ArrayList<ChartDataEntity>();
    for (IndicatorUnit unit : units) {
        PatternMatchingExt patternExt = PatternStatisticeStateUtil.getUnitValue(unit.getIndicator(), unit.getValue());
        String notMathCount = PatternStatisticeStateUtil.getNotMatchCount(patternExt);
        String machCount = PatternStatisticeStateUtil.getMatchCount(patternExt);
        PatternChartDataEntity patternEntity = PatternStatisticeStateUtil.createDataEntity(unit, unit.getIndicator().getName(), notMathCount, machCount);
        dataEnities.add(patternEntity);
    }
    return dataEnities.toArray(new ChartDataEntity[dataEnities.size()]);
}
Also used : PatternChartDataEntity(org.talend.dq.indicators.preview.table.PatternChartDataEntity) ArrayList(java.util.ArrayList) IndicatorUnit(org.talend.dataprofiler.core.ui.editor.preview.IndicatorUnit) PatternMatchingExt(org.talend.dq.indicators.ext.PatternMatchingExt) PatternChartDataEntity(org.talend.dq.indicators.preview.table.PatternChartDataEntity) ChartDataEntity(org.talend.dq.indicators.preview.table.ChartDataEntity)

Aggregations

PatternMatchingExt (org.talend.dq.indicators.ext.PatternMatchingExt)9 Test (org.junit.Test)4 IndicatorUnit (org.talend.dataprofiler.core.ui.editor.preview.IndicatorUnit)2 RegexpMatchingIndicator (org.talend.dataquality.indicators.RegexpMatchingIndicator)2 UserDefIndicator (org.talend.dataquality.indicators.sql.UserDefIndicator)2 ChartDataEntity (org.talend.dq.indicators.preview.table.ChartDataEntity)2 PatternChartDataEntity (org.talend.dq.indicators.preview.table.PatternChartDataEntity)2 ArrayList (java.util.ArrayList)1 CustomerDefaultCategoryDataset (org.talend.dataprofiler.common.ui.editor.preview.CustomerDefaultCategoryDataset)1 Indicator (org.talend.dataquality.indicators.Indicator)1 PatternMatchingIndicator (org.talend.dataquality.indicators.PatternMatchingIndicator)1 SqlPatternMatchingIndicator (org.talend.dataquality.indicators.SqlPatternMatchingIndicator)1 ValueIndicator (org.talend.dataquality.indicators.ValueIndicator)1