Search in sources :

Example 16 with RowCountIndicator

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

the class RowCountIndicatorsAdapter method handle.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.dataquality.indicators.impl.IndicatorImpl#handle(java.lang.Object)
     */
@Override
public boolean handle(Object data) {
    int index = 0;
    for (RowCountIndicator rci : this.rowCountIndiSet) {
        rci.handle(data);
        index++;
    }
    if (index == 0 || index != rowCountIndiSet.size()) {
        return false;
    }
    return super.handle(data);
}
Also used : RowCountIndicator(org.talend.dataquality.indicators.RowCountIndicator)

Example 17 with RowCountIndicator

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

the class DelimitedFileIndicatorEvaluator method handleByARow.

private ReturnCode handleByARow(String[] rowValues, long currentRow, List<ModelElement> analysisElementList, List<MetadataColumn> columnElementList, EMap<Indicator, AnalyzedDataSet> indicToRowMap) {
    ReturnCode returnCode = new ReturnCode(true);
    Object object = null;
    int maxNumberRows = analysis.getParameters().getMaxNumberRows();
    int recordIncrement = 0;
    element: for (int i = 0; i < analysisElementList.size(); i++) {
        MetadataColumn mColumn = (MetadataColumn) analysisElementList.get(i);
        Integer position = ColumnHelper.getColumnIndex(mColumn);
        // warning with a file of badly form
        if (position == null || position >= rowValues.length) {
            log.warn(// $NON-NLS-1$
            Messages.getString(// $NON-NLS-1$
            "DelimitedFileIndicatorEvaluator.incorrectData", mColumn.getLabel(), currentRow, delimitedFileconnection.getFilePath()));
            returnCode.setOk(false);
            continue;
        }
        object = TalendTypeConvert.convertToObject(mColumn.getTalendType(), rowValues[position], mColumn.getPattern());
        List<Indicator> indicators = getIndicators(mColumn.getLabel());
        for (Indicator indicator : indicators) {
            if (!continueRun()) {
                break element;
            }
            // bug 19036,to irregularly data,still compute for RowCountIndicator
            if (object == null && !(indicator instanceof RowCountIndicator)) {
                continue element;
            }
            // Added yyin 20120608 TDQ-3589
            if (indicator instanceof DuplicateCountIndicator) {
                ((DuplicateCountIndicator) indicator).handle(object, rowValues);
            } else {
                // ~
                indicator.handle(object);
            }
            AnalyzedDataSet analyzedDataSet = indicToRowMap.get(indicator);
            if (analyzedDataSet == null) {
                analyzedDataSet = AnalysisFactory.eINSTANCE.createAnalyzedDataSet();
                indicToRowMap.put(indicator, analyzedDataSet);
                analyzedDataSet.setDataCount(maxNumberRows);
                analyzedDataSet.setRecordSize(0);
            }
            // see IndicatorEvaluator line 166, the logic is almost the same
            if (analysis.getParameters().isStoreData()) {
                if (indicator.mustStoreRow()) {
                    List<Object[]> valueObjectList = initDataSet(indicator, indicToRowMap, object);
                    recordIncrement = valueObjectList.size();
                    List<Object> inputRowList = new ArrayList<Object>();
                    for (int j = 0; j < rowValues.length; j++) {
                        Object newobject = rowValues[j];
                        if (indicator.isUsedMapDBMode()) {
                            inputRowList.add(newobject == null ? PluginConstant.NULL_STRING : newobject);
                            continue;
                        } else {
                            if (recordIncrement < maxNumberRows) {
                                if (recordIncrement < valueObjectList.size()) {
                                    valueObjectList.get(recordIncrement)[j] = newobject;
                                } else {
                                    Object[] valueObject = new Object[rowValues.length];
                                    valueObject[j] = newobject;
                                    valueObjectList.add(valueObject);
                                }
                            } else {
                                break;
                            }
                        }
                    }
                    if (indicator.isUsedMapDBMode()) {
                        MapDBUtils.handleDrillDownData(object, inputRowList, indicator);
                    }
                } else if (indicator instanceof UniqueCountIndicator && analysis.getResults().getIndicToRowMap().get(indicator).getData() != null) {
                    List<Object[]> removeValueObjectList = analysis.getResults().getIndicToRowMap().get(indicator).getData();
                    if (columnElementList.size() == 0) {
                        continue;
                    }
                    int offsetting = columnElementList.indexOf(indicator.getAnalyzedElement());
                    for (Object[] dataObject : removeValueObjectList) {
                        // Added yyin 20120611 TDQ5279
                        if (object instanceof Integer) {
                            if (object.equals(Integer.parseInt((String) dataObject[offsetting]))) {
                                removeValueObjectList.remove(dataObject);
                                break;
                            }
                        }
                        // ~
                        if (dataObject[offsetting].equals(object)) {
                            removeValueObjectList.remove(dataObject);
                            break;
                        }
                    }
                }
            }
        }
    }
    return returnCode;
}
Also used : DuplicateCountIndicator(org.talend.dataquality.indicators.DuplicateCountIndicator) ReturnCode(org.talend.utils.sugars.ReturnCode) AnalyzedDataSet(org.talend.dataquality.analysis.AnalyzedDataSet) UniqueCountIndicator(org.talend.dataquality.indicators.UniqueCountIndicator) UniqueCountIndicator(org.talend.dataquality.indicators.UniqueCountIndicator) Indicator(org.talend.dataquality.indicators.Indicator) DuplicateCountIndicator(org.talend.dataquality.indicators.DuplicateCountIndicator) RowCountIndicator(org.talend.dataquality.indicators.RowCountIndicator) MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) ArrayList(java.util.ArrayList) List(java.util.List) RowCountIndicator(org.talend.dataquality.indicators.RowCountIndicator)

Example 18 with RowCountIndicator

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

the class ColumnSetIndicatorEvaluator method handleObjects.

/**
 * handle Objects and store data for delimited file .
 *
 * @param objectLs
 * @param rowValues
 * @param metadataColumn is one of analysedElements.it is used to get its Table then get the table's columns.
 */
private void handleObjects(EList<Object> objectLs, String[] rowValues, List<MetadataColumn> columnList) {
    if (objectLs.size() == 0) {
        return;
    }
    EList<Indicator> indicators = analysis.getResults().getIndicators();
    EMap<Indicator, AnalyzedDataSet> indicToRowMap = analysis.getResults().getIndicToRowMap();
    int recordIncrement = 0;
    if (indicators != null) {
        for (Indicator indicator : indicators) {
            if (!this.continueRun()) {
                break;
            }
            if (ColumnsetPackage.eINSTANCE.getColumnSetMultiValueIndicator().isSuperTypeOf(indicator.eClass())) {
                indicator.handle(objectLs);
                // feature 19192,store all rows value for RowCountIndicator
                if (indicator instanceof SimpleStatIndicator) {
                    SimpleStatIndicator simpIndi = (SimpleStatIndicator) indicator;
                    for (Indicator leafIndicator : simpIndi.getLeafIndicators()) {
                        if (!this.continueRun()) {
                            break;
                        }
                        // (distinct count, unique count, duplicate count, etc).
                        if (!analysis.getParameters().isStoreData()) {
                            // ~
                            continue;
                        }
                        List<Object[]> valueObjectList = initDataSet(leafIndicator, indicToRowMap);
                        recordIncrement = valueObjectList.size();
                        Object[] valueObject = new Object[columnList.size()];
                        if (recordIncrement < analysis.getParameters().getMaxNumberRows()) {
                            for (int j = 0; j < columnList.size(); j++) {
                                if (!this.continueRun()) {
                                    break;
                                }
                                Object newobject = PluginConstant.EMPTY_STRING;
                                // if (recordIncrement < analysis.getParameters().getMaxNumberRows()) {
                                if (j < rowValues.length) {
                                    newobject = rowValues[j];
                                }
                                if (recordIncrement < valueObjectList.size()) {
                                    valueObjectList.get(recordIncrement)[j] = newobject;
                                } else {
                                    valueObject[j] = newobject;
                                    valueObjectList.add(valueObject);
                                }
                            // }
                            }
                        }
                    }
                }
            }
        }
    }
}
Also used : AnalyzedDataSet(org.talend.dataquality.analysis.AnalyzedDataSet) SimpleStatIndicator(org.talend.dataquality.indicators.columnset.SimpleStatIndicator) UniqueCountIndicator(org.talend.dataquality.indicators.UniqueCountIndicator) Indicator(org.talend.dataquality.indicators.Indicator) DistinctCountIndicator(org.talend.dataquality.indicators.DistinctCountIndicator) AllMatchIndicator(org.talend.dataquality.indicators.columnset.AllMatchIndicator) SimpleStatIndicator(org.talend.dataquality.indicators.columnset.SimpleStatIndicator) DuplicateCountIndicator(org.talend.dataquality.indicators.DuplicateCountIndicator) RowCountIndicator(org.talend.dataquality.indicators.RowCountIndicator)

Example 19 with RowCountIndicator

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

the class FrequencyTypeStateUtil method isWithRowCountIndicator.

public static boolean isWithRowCountIndicator(Indicator indicator) {
    ModelElement currentAnalyzedElement = indicator.getAnalyzedElement();
    InternalEObject eIndicator = (InternalEObject) indicator;
    AnalysisResult result = (AnalysisResult) eIndicator.eContainer();
    // MOD msjian TDQ-5960: fix a NPE
    if (result == null) {
        return false;
    }
    EList<Indicator> indicators = result.getIndicators();
    if (indicators != null) {
        for (Indicator indi : indicators) {
            ModelElement analyzedElement = indi.getAnalyzedElement();
            if (analyzedElement == currentAnalyzedElement) {
                if (indi instanceof RowCountIndicator) {
                    return true;
                } else if (indi instanceof CountsIndicator) {
                    CountsIndicator cindi = (CountsIndicator) indi;
                    return cindi.getRowCountIndicator() != null;
                }
            }
        }
    }
    return false;
}
Also used : ModelElement(orgomg.cwm.objectmodel.core.ModelElement) CountsIndicator(org.talend.dataquality.indicators.CountsIndicator) RowCountIndicator(org.talend.dataquality.indicators.RowCountIndicator) InternalEObject(org.eclipse.emf.ecore.InternalEObject) AnalysisResult(org.talend.dataquality.analysis.AnalysisResult) CountsIndicator(org.talend.dataquality.indicators.CountsIndicator) BenfordLawFrequencyIndicator(org.talend.dataquality.indicators.BenfordLawFrequencyIndicator) Indicator(org.talend.dataquality.indicators.Indicator) RowCountIndicator(org.talend.dataquality.indicators.RowCountIndicator)

Example 20 with RowCountIndicator

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

the class WhereRuleStatisticsStateUtil method initRowCount.

public static Long initRowCount(TableIndicator tableIndicator1) {
    Long result = 0L;
    if (tableIndicator1 != null) {
        TableIndicatorUnit[] tius = tableIndicator1.getIndicatorUnits();
        for (TableIndicatorUnit tiu : tius) {
            if (tiu.getIndicator() instanceof RowCountIndicator) {
                RowCountIndicator rci = (RowCountIndicator) tiu.getIndicator();
                result = rci.getCount();
                break;
            }
        }
    }
    return result;
}
Also used : TableIndicatorUnit(org.talend.dataprofiler.core.ui.editor.preview.TableIndicatorUnit) RowCountIndicator(org.talend.dataquality.indicators.RowCountIndicator)

Aggregations

RowCountIndicator (org.talend.dataquality.indicators.RowCountIndicator)33 Indicator (org.talend.dataquality.indicators.Indicator)12 Test (org.junit.Test)11 NullCountIndicator (org.talend.dataquality.indicators.NullCountIndicator)10 DuplicateCountIndicator (org.talend.dataquality.indicators.DuplicateCountIndicator)9 ArrayList (java.util.ArrayList)8 DistinctCountIndicator (org.talend.dataquality.indicators.DistinctCountIndicator)7 UniqueCountIndicator (org.talend.dataquality.indicators.UniqueCountIndicator)7 PersistenceException (org.talend.commons.exception.PersistenceException)6 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)6 TDQIndicatorDefinitionItem (org.talend.dataquality.properties.TDQIndicatorDefinitionItem)6 List (java.util.List)5 AverageLengthIndicator (org.talend.dataquality.indicators.AverageLengthIndicator)5 BlankCountIndicator (org.talend.dataquality.indicators.BlankCountIndicator)5 TdColumn (org.talend.cwm.relational.TdColumn)4 DefValueCountIndicator (org.talend.dataquality.indicators.DefValueCountIndicator)4 InvalidRegCodeCountIndicator (org.talend.dataquality.indicators.InvalidRegCodeCountIndicator)4 MaxLengthIndicator (org.talend.dataquality.indicators.MaxLengthIndicator)4 MaxValueIndicator (org.talend.dataquality.indicators.MaxValueIndicator)4 MeanIndicator (org.talend.dataquality.indicators.MeanIndicator)4