Search in sources :

Example 16 with IndicatorEnum

use of org.talend.dq.nodes.indicator.type.IndicatorEnum in project tdq-studio-se by Talend.

the class ChartDataEntity method isOutOfRange.

/**
 * DOC Zqin Comment method "isOutOfRange".
 *
 * @return
 */
public boolean isOutOfRange(String inputValue) {
    outOfRange = false;
    if (inputValue == null || indicator == null) {
        return false;
    }
    IndicatorEnum indicatorEnum = IndicatorEnum.findIndicatorEnum(indicator.eClass());
    if (indicatorEnum != null) {
        switch(indicatorEnum) {
            case ModeIndicatorEnum:
                String expectedValue = IndicatorHelper.getExpectedValue(indicator);
                if (expectedValue != null) {
                    Boolean ignoreCaseOption = IndicatorHelper.ignoreCaseOption(indicator);
                    // MOD sgandon 01/04/2010 bug 12086 : ignoreCaseOption was not checked for null value
                    if (ignoreCaseOption != null && ignoreCaseOption) {
                        outOfRange = !(ignoreCaseOption && StringUtils.equalsIgnoreCase(value, expectedValue));
                    } else {
                        outOfRange = !StringUtils.equals(value, expectedValue);
                    }
                }
                break;
            default:
                outOfRange = checkRange(inputValue);
        }
    }
    return outOfRange;
}
Also used : IndicatorEnum(org.talend.dq.nodes.indicator.type.IndicatorEnum)

Example 17 with IndicatorEnum

use of org.talend.dq.nodes.indicator.type.IndicatorEnum in project tdq-studio-se by Talend.

the class ChartDataEntity method getRangeAsString.

/**
 * DOC Zqin Comment method "getRangeAsString".
 *
 * @return retrun the message when indicator value out the defined range.
 */
public String getRangeAsString() {
    StringBuilder msg = new StringBuilder();
    if (indicator != null) {
        IndicatorEnum indicatorEnum = IndicatorEnum.findIndicatorEnum(indicator.eClass());
        // TDQ-10785: when the data is too long, add a tooltip to show the first 200 characters.
        if (indicatorEnum == IndicatorEnum.PatternFreqIndicatorEnum || indicatorEnum == IndicatorEnum.PatternLowFreqIndicatorEnum || indicatorEnum == IndicatorEnum.FrequencyIndicatorEnum || indicatorEnum == IndicatorEnum.LowFrequencyIndicatorEnum || indicatorEnum == IndicatorEnum.SoundexIndicatorEnum || indicatorEnum == IndicatorEnum.SoundexLowIndicatorEnum || indicatorEnum == IndicatorEnum.EastAsiaPatternLowFreqIndicatorEnum || indicatorEnum == IndicatorEnum.EastAsiaPatternFreqIndicatorEnum) {
            if (key != null && key.toString().length() > 30) {
                msg.append(key.toString().length() > 200 ? key.toString().substring(0, 200) + "...(" + key.toString().length() + " characters)" : // $NON-NLS-1$ //$NON-NLS-2$
                key.toString());
            }
        } else if (indicatorEnum == IndicatorEnum.ModeIndicatorEnum) {
            // $NON-NLS-1$ //$NON-NLS-2$
            msg.append("This value differs from the expected value: \"" + IndicatorHelper.getExpectedValue(indicator) + "\"");
        } else if (indicatorEnum == IndicatorEnum.BoxIIndicatorEnum) {
            if (isOutOfRange(getValue())) {
                // $NON-NLS-1$
                msg.append("This value is outside the expected data's thresholds: " + range);
            }
        } else {
            if (isOutOfRange(getValue())) {
                // $NON-NLS-1$
                msg.append("This value is outside the expected indicator's thresholds: " + range);
                // $NON-NLS-1$
                msg.append("\n");
            }
            if (isOutOfRange(getPersent())) {
                // $NON-NLS-1$
                msg.append("This value is outside the expected indicator's thresholds in percent: " + range);
            }
        }
    }
    return msg.length() == 0 ? null : msg.toString();
}
Also used : IndicatorEnum(org.talend.dq.nodes.indicator.type.IndicatorEnum)

Example 18 with IndicatorEnum

use of org.talend.dq.nodes.indicator.type.IndicatorEnum in project tdq-studio-se by Talend.

the class IndicatorCommonUtil method getIndicatorValue.

public static Object getIndicatorValue(Indicator indicator) {
    Object value = null;
    IndicatorEnum type = IndicatorEnum.findIndicatorEnum(indicator.eClass());
    if (type != null) {
        try {
            if (type == IndicatorEnum.RangeIndicatorEnum || type == IndicatorEnum.IQRIndicatorEnum) {
                value = ((RangeIndicator) indicator).getRange();
                ((RangeIndicator) indicator).setComputed(true);
            } else if (indicator.isComputed()) {
                switch(type) {
                    case RowCountIndicatorEnum:
                        value = ((RowCountIndicator) indicator).getCount();
                        break;
                    case NullCountIndicatorEnum:
                        value = ((NullCountIndicator) indicator).getNullCount();
                        break;
                    case DistinctCountIndicatorEnum:
                        value = ((DistinctCountIndicator) indicator).getDistinctValueCount();
                        break;
                    case UniqueIndicatorEnum:
                        value = (((UniqueCountIndicator) indicator).getUniqueValueCount());
                        break;
                    case DuplicateCountIndicatorEnum:
                        value = ((DuplicateCountIndicator) indicator).getDuplicateValueCount();
                        break;
                    case BlankCountIndicatorEnum:
                        value = ((BlankCountIndicator) indicator).getBlankCount();
                        break;
                    case DefValueCountIndicatorEnum:
                        value = ((DefValueCountIndicator) indicator).getDefaultValCount();
                        break;
                    case MinLengthIndicatorEnum:
                        value = ((MinLengthIndicator) indicator).getLength();
                        break;
                    case MinLengthWithNullIndicatorEnum:
                        value = ((MinLengthWithNullIndicator) indicator).getLength();
                        break;
                    case MinLengthWithBlankIndicatorEnum:
                        value = ((MinLengthWithBlankIndicator) indicator).getLength();
                        break;
                    case MinLengthWithBlankNullIndicatorEnum:
                        value = ((MinLengthWithBlankNullIndicator) indicator).getLength();
                        break;
                    case MaxLengthIndicatorEnum:
                        value = ((MaxLengthIndicator) indicator).getLength();
                        break;
                    case MaxLengthWithNullIndicatorEnum:
                        value = ((MaxLengthWithNullIndicator) indicator).getLength();
                        break;
                    case MaxLengthWithBlankIndicatorEnum:
                        value = ((MaxLengthWithBlankIndicator) indicator).getLength();
                        break;
                    case MaxLengthWithBlankNullIndicatorEnum:
                        value = ((MaxLengthWithBlankNullIndicator) indicator).getLength();
                        break;
                    case AverageLengthIndicatorEnum:
                        value = ((AverageLengthIndicator) indicator).getAverageLength();
                        break;
                    case AverageLengthWithNullIndicatorEnum:
                        value = ((AvgLengthWithNullIndicator) indicator).getAverageLength();
                        break;
                    case AverageLengthWithBlankIndicatorEnum:
                        value = ((AvgLengthWithBlankIndicator) indicator).getAverageLength();
                        break;
                    case AverageLengthWithNullBlankIndicatorEnum:
                        value = ((AvgLengthWithBlankNullIndicator) indicator).getAverageLength();
                        break;
                    case FrequencyIndicatorEnum:
                    case DateFrequencyIndicatorEnum:
                    case WeekFrequencyIndicatorEnum:
                    case MonthFrequencyIndicatorEnum:
                    case QuarterFrequencyIndicatorEnum:
                    case YearFrequencyIndicatorEnum:
                    case BinFrequencyIndicatorEnum:
                    case LowFrequencyIndicatorEnum:
                    case DateLowFrequencyIndicatorEnum:
                    case WeekLowFrequencyIndicatorEnum:
                    case MonthLowFrequencyIndicatorEnum:
                    case QuarterLowFrequencyIndicatorEnum:
                    case YearLowFrequencyIndicatorEnum:
                    case BinLowFrequencyIndicatorEnum:
                    case PatternFreqIndicatorEnum:
                    case PatternLowFreqIndicatorEnum:
                    case EastAsiaPatternFreqIndicatorEnum:
                    case EastAsiaPatternLowFreqIndicatorEnum:
                    case DatePatternFreqIndicatorEnum:
                    case SoundexIndicatorEnum:
                    case SoundexLowIndicatorEnum:
                    case BenfordLawFrequencyIndicatorEnum:
                        value = handleFrequency(indicator);
                        break;
                    case MeanIndicatorEnum:
                        value = ((MeanIndicator) indicator).getMean();
                        break;
                    case MedianIndicatorEnum:
                        value = ((MedianIndicator) indicator).getMedian();
                        break;
                    case MinValueIndicatorEnum:
                        value = ((MinValueIndicator) indicator).getValue();
                        break;
                    case MaxValueIndicatorEnum:
                        value = ((MaxValueIndicator) indicator).getValue();
                        break;
                    case LowerQuartileIndicatorEnum:
                        value = ((LowerQuartileIndicator) indicator).getValue();
                        break;
                    case UpperQuartileIndicatorEnum:
                        value = ((UpperQuartileIndicator) indicator).getValue();
                        break;
                    case RegexpMatchingIndicatorEnum:
                    case SqlPatternMatchingIndicatorEnum:
                    case AllMatchIndicatorEnum:
                        value = handleMatchingValue(indicator);
                        break;
                    case ModeIndicatorEnum:
                        value = ((ModeIndicator) indicator).getMode();
                        break;
                    case UserDefinedIndicatorEnum:
                        value = handleUDIValue(indicator);
                        break;
                    case WhereRuleIndicatorEnum:
                        Long userCount = ((WhereRuleIndicator) indicator).getUserCount();
                        value = userCount == null ? 0 : userCount;
                        break;
                    // MOD qiongli 2011-7-21 feature 22362
                    case ValidPhoneCountIndicatorEnum:
                        value = ((ValidPhoneCountIndicator) indicator).getValidPhoneNumCount();
                        break;
                    case ValidRegCodeCountIndicatorEnum:
                        value = ((ValidRegCodeCountIndicator) indicator).getValidRegCount();
                        break;
                    case InvalidRegCodeCountIndicatorEnum:
                        value = ((InvalidRegCodeCountIndicator) indicator).getInvalidRegCount();
                        break;
                    case WellFormE164PhoneCountIndicatorEnum:
                        value = ((WellFormE164PhoneCountIndicator) indicator).getWellFormE164PhoneCount();
                        break;
                    case WellFormIntePhoneCountIndicatorEnum:
                        value = ((WellFormIntePhoneCountIndicator) indicator).getWellFormIntePhoneCount();
                        break;
                    case WellFormNationalPhoneCountIndicatorEnum:
                        value = ((WellFormNationalPhoneCountIndicator) indicator).getWellFormNatiPhoneCount();
                        break;
                    case PossiblePhoneCountIndicatorEnum:
                        value = ((PossiblePhoneCountIndicator) indicator).getPossiblePhoneCount();
                        break;
                    case FormatFreqPieIndictorEnum:
                        value = handleFreqPie(indicator);
                    default:
                }
                if (value == null || "null".equalsIgnoreCase(value.toString())) {
                    // $NON-NLS-1$
                    indicator.setComputed(false);
                }
            }
        } catch (Exception e) {
            // $NON-NLS-1$
            log.error(Messages.getString("IndicatorCommonUtil.FailValue", e.getMessage()), e);
        }
    }
    return value;
}
Also used : IndicatorEnum(org.talend.dq.nodes.indicator.type.IndicatorEnum) MinLengthWithNullIndicator(org.talend.dataquality.indicators.MinLengthWithNullIndicator) BlankCountIndicator(org.talend.dataquality.indicators.BlankCountIndicator) MaxLengthWithBlankIndicator(org.talend.dataquality.indicators.MaxLengthWithBlankIndicator) MedianIndicator(org.talend.dataquality.indicators.MedianIndicator) ModeIndicator(org.talend.dataquality.indicators.ModeIndicator) MinLengthWithBlankIndicator(org.talend.dataquality.indicators.MinLengthWithBlankIndicator) AvgLengthWithNullIndicator(org.talend.dataquality.indicators.AvgLengthWithNullIndicator) NullCountIndicator(org.talend.dataquality.indicators.NullCountIndicator) DistinctCountIndicator(org.talend.dataquality.indicators.DistinctCountIndicator) WellFormIntePhoneCountIndicator(org.talend.dataquality.indicators.WellFormIntePhoneCountIndicator) MaxValueIndicator(org.talend.dataquality.indicators.MaxValueIndicator) MaxLengthWithBlankNullIndicator(org.talend.dataquality.indicators.MaxLengthWithBlankNullIndicator) LowerQuartileIndicator(org.talend.dataquality.indicators.LowerQuartileIndicator) RowCountIndicator(org.talend.dataquality.indicators.RowCountIndicator) MeanIndicator(org.talend.dataquality.indicators.MeanIndicator) WellFormE164PhoneCountIndicator(org.talend.dataquality.indicators.WellFormE164PhoneCountIndicator) PossiblePhoneCountIndicator(org.talend.dataquality.indicators.PossiblePhoneCountIndicator) ValidPhoneCountIndicator(org.talend.dataquality.indicators.ValidPhoneCountIndicator) DuplicateCountIndicator(org.talend.dataquality.indicators.DuplicateCountIndicator) MaxLengthWithNullIndicator(org.talend.dataquality.indicators.MaxLengthWithNullIndicator) MaxLengthIndicator(org.talend.dataquality.indicators.MaxLengthIndicator) MinLengthWithBlankNullIndicator(org.talend.dataquality.indicators.MinLengthWithBlankNullIndicator) AvgLengthWithBlankIndicator(org.talend.dataquality.indicators.AvgLengthWithBlankIndicator) ValidRegCodeCountIndicator(org.talend.dataquality.indicators.ValidRegCodeCountIndicator) MinLengthIndicator(org.talend.dataquality.indicators.MinLengthIndicator) InvalidRegCodeCountIndicator(org.talend.dataquality.indicators.InvalidRegCodeCountIndicator) DefValueCountIndicator(org.talend.dataquality.indicators.DefValueCountIndicator) AverageLengthIndicator(org.talend.dataquality.indicators.AverageLengthIndicator) AvgLengthWithBlankNullIndicator(org.talend.dataquality.indicators.AvgLengthWithBlankNullIndicator) RangeIndicator(org.talend.dataquality.indicators.RangeIndicator) UpperQuartileIndicator(org.talend.dataquality.indicators.UpperQuartileIndicator) WellFormNationalPhoneCountIndicator(org.talend.dataquality.indicators.WellFormNationalPhoneCountIndicator) MinValueIndicator(org.talend.dataquality.indicators.MinValueIndicator)

Example 19 with IndicatorEnum

use of org.talend.dq.nodes.indicator.type.IndicatorEnum in project tdq-studio-se by Talend.

the class AbstractIndicatorSelectGrid method tickCell.

private void tickCell(Point cell, boolean tick) {
    if (!getItem(cell.y).getCheckable(cell.x)) {
        return;
    }
    if (cell.x == 1) {
        for (int i = 2; i < getColumnCount(); i++) {
            tickCell(new Point(i, cell.y), tick);
        }
    }
    getItem(cell.y).setChecked(cell.x, tick);
    getItem(cell.y).setGrayed(cell.x, false);
    IIndicatorNode indicatorNode = (IIndicatorNode) getItem(cell.y).getData();
    IndicatorEnum indicatorEnum = indicatorNode.getIndicatorEnum();
    ModelElementIndicator meIndicator = (ModelElementIndicator) getColumn(cell.x).getData();
    if (meIndicator != null && indicatorEnum != null) {
        if (tick) {
            if (IndicatorEnum.isSpecialIndicatorEnum(indicatorEnum)) {
                meIndicator.addTempSpecialIndicator(indicatorEnum, indicatorNode.createNewIndicatorInstance());
            } else {
                meIndicator.addTempIndicatorEnum(indicatorEnum);
            }
        } else {
            if (IndicatorEnum.isSpecialIndicatorEnum(indicatorEnum)) {
                meIndicator.removeTempSpecialIndicator(indicatorNode.getIndicatorInstance());
            } else {
                meIndicator.removeTempIndicatorEnum(indicatorEnum);
            }
        }
    }
    // select the entire indicator category
    if (getItem(cell.y).hasChildren()) {
        for (GridItem child : getItem(cell.y).getItems()) {
            tickCell(new Point(cell.x, indexOf(child)), tick);
        }
    }
}
Also used : TalendGridItem(org.eclipse.nebula.widgets.grid.TalendGridItem) GridItem(org.eclipse.nebula.widgets.grid.GridItem) IndicatorEnum(org.talend.dq.nodes.indicator.type.IndicatorEnum) Point(org.eclipse.swt.graphics.Point) Point(org.eclipse.swt.graphics.Point) IIndicatorNode(org.talend.dq.nodes.indicator.IIndicatorNode) ModelElementIndicator(org.talend.dataprofiler.core.model.ModelElementIndicator)

Example 20 with IndicatorEnum

use of org.talend.dq.nodes.indicator.type.IndicatorEnum in project tdq-studio-se by Talend.

the class AbstractIndicatorSelectGrid method createChildNodes.

/**
 * recursively create tree nodes and checked the existing indicators.
 *
 * @param grid
 * @param currentItem
 * @param indicatorNode
 */
void createChildNodes(GridItem parentItem, GridItem currentItem, IIndicatorNode indicatorNode) {
    Boolean[] hasCheckableInColumn = new Boolean[getColumnCount()];
    for (int j = 1; j < getColumnCount(); j++) {
        hasCheckableInColumn[j] = false;
    }
    for (int i = 0; i < indicatorNode.getChildren().length; i++) {
        IIndicatorNode childNode = indicatorNode.getChildren()[i];
        TalendGridItem childItem = new TalendGridItem(currentItem, SWT.NONE);
        childItem.setImage(ImageLib.getImage(childNode.getImageName()));
        if (childNode.hasChildren()) {
            createChildNodes(currentItem, childItem, childNode);
        }
        childItem.setText(childNode.getLabel());
        childItem.setData(childNode);
        if (parentItem == null) {
            childItem.setExpanded(true);
        }
        boolean hasCheckableInRow = false;
        for (int j = 2; j < getColumnCount(); j++) {
            // ignore indicator label column and row select column
            IndicatorEnum indicatorEnum = childNode.getIndicatorEnum();
            // DB columns
            ModelElementIndicator meIndicator = null;
            if (j - 2 < _modelElementIndicators.length) {
                meIndicator = _modelElementIndicators[j - 2];
            } else {
                meIndicator = _modelElementIndicators[0];
            }
            // Enable/disable the check box
            boolean isMatch = _dialog.isMatchCurrentIndicator(meIndicator, childNode);
            childItem.setCheckable(j, isMatch);
            if (isMatch) {
                hasCheckableInRow = true;
                hasCheckableInColumn[j] = true;
                // Check the box if it is already selected
                if (meIndicator != null && (meIndicator.tempContains(indicatorEnum) || meIndicator.specialTempContains(childNode.getIndicatorInstance()))) {
                    childItem.setChecked(j, true);
                }
            }
        }
        childItem.setCheckable(1, hasCheckableInRow);
    }
    boolean entireCategoryCheckable = false;
    for (int j = 2; j < getColumnCount(); j++) {
        if (hasCheckableInColumn[j]) {
            entireCategoryCheckable = true;
        } else {
            currentItem.setCheckable(j, false);
        }
    }
    currentItem.setCheckable(1, entireCategoryCheckable);
}
Also used : IndicatorEnum(org.talend.dq.nodes.indicator.type.IndicatorEnum) TalendGridItem(org.eclipse.nebula.widgets.grid.TalendGridItem) Point(org.eclipse.swt.graphics.Point) IIndicatorNode(org.talend.dq.nodes.indicator.IIndicatorNode) ModelElementIndicator(org.talend.dataprofiler.core.model.ModelElementIndicator)

Aggregations

IndicatorEnum (org.talend.dq.nodes.indicator.type.IndicatorEnum)33 ModelElementIndicator (org.talend.dataprofiler.core.model.ModelElementIndicator)10 IndicatorUnit (org.talend.dataprofiler.core.ui.editor.preview.IndicatorUnit)7 Indicator (org.talend.dataquality.indicators.Indicator)7 ArrayList (java.util.ArrayList)6 TableIndicatorUnit (org.talend.dataprofiler.core.ui.editor.preview.TableIndicatorUnit)4 RangeIndicator (org.talend.dataquality.indicators.RangeIndicator)4 RowCountIndicator (org.talend.dataquality.indicators.RowCountIndicator)4 TalendGridItem (org.eclipse.nebula.widgets.grid.TalendGridItem)3 Point (org.eclipse.swt.graphics.Point)3 TreeItem (org.eclipse.swt.widgets.TreeItem)3 BoxIndicator (org.talend.dataquality.indicators.BoxIndicator)3 CountsIndicator (org.talend.dataquality.indicators.CountsIndicator)3 IQRIndicator (org.talend.dataquality.indicators.IQRIndicator)3 PhoneNumbStatisticsIndicator (org.talend.dataquality.indicators.PhoneNumbStatisticsIndicator)3 IIndicatorNode (org.talend.dq.nodes.indicator.IIndicatorNode)3 IRepositoryNode (org.talend.repository.model.IRepositoryNode)3 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)2 MetadataColumnRepositoryObject (org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject)2 MetadataXmlElementTypeRepositoryObject (org.talend.core.repository.model.repositoryObject.MetadataXmlElementTypeRepositoryObject)2