Search in sources :

Example 6 with RowCountIndicator

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

the class ColumnSetDBMapTest method testSubListLongLongMapOfLongListOfObjectDataValidationCase4.

/**
 * Test method for
 * {@link org.talend.dataquality.indicators.mapdb.ColumnSetDBMap#subList(long, long, java.util.Map, org.talend.cwm.indicator.DataValidation)}
 * Case 4 row count case
 */
@Test
public void testSubListLongLongMapOfLongListOfObjectDataValidationCase4() {
    ColumnSetDBMap dbMap1 = new ColumnSetDBMap();
    Assert.assertEquals(true, dbMap1.isEmpty());
    List<Object> keyList = new ArrayList<Object>();
    // $NON-NLS-1$
    keyList.add("id1");
    // $NON-NLS-1$
    keyList.add("name1");
    dbMap1.put(keyList, 1l);
    keyList = new ArrayList<Object>();
    // $NON-NLS-1$
    keyList.add("id2");
    // $NON-NLS-1$
    keyList.add("name2");
    dbMap1.put(keyList, 2l);
    Assert.assertEquals(2, dbMap1.size());
    RowCountIndicator rowCountIndicator = IndicatorsFactory.eINSTANCE.createRowCountIndicator();
    List<Object[]> subList = dbMap1.subList(0, 2, new HashMap<Long, List<Object>>(), IDataValidationFactory.INSTANCE.createValidation(rowCountIndicator));
    Assert.assertEquals(2, subList.size());
}
Also used : ColumnSetDBMap(org.talend.dataquality.indicators.mapdb.ColumnSetDBMap) ArrayList(java.util.ArrayList) RowCountIndicator(org.talend.dataquality.indicators.RowCountIndicator) List(java.util.List) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 7 with RowCountIndicator

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

the class IndicatorHelperTest method testGetNullCountIndicator1.

/**
 * Test method for
 * {@link org.talend.dataquality.helpers.IndicatorHelper#getNullCountIndicator(orgomg.cwm.objectmodel.core.ModelElement, java.util.Map)}
 * . get NullCountIndicator
 */
@Test
public void testGetNullCountIndicator1() {
    // TdColumn
    TdColumn column1 = RelationalFactory.eINSTANCE.createTdColumn();
    // ~
    // Indicator
    Indicator rowCountIndicator = IndicatorsFactory.eINSTANCE.createRowCountIndicator();
    Indicator nullCountIndicator = IndicatorsFactory.eINSTANCE.createNullCountIndicator();
    // ~
    // List
    List<Indicator> list = new ArrayList<Indicator>();
    list.add(rowCountIndicator);
    list.add(nullCountIndicator);
    // ~
    // Map
    Map<ModelElement, List<Indicator>> elementToIndicator = new HashMap<ModelElement, List<Indicator>>();
    elementToIndicator.put(column1, list);
    // ~
    NullCountIndicator nullCountIndicator2 = IndicatorHelper.getNullCountIndicator(column1, elementToIndicator);
    assert (nullCountIndicator2 != null);
}
Also used : ModelElement(orgomg.cwm.objectmodel.core.ModelElement) TdColumn(org.talend.cwm.relational.TdColumn) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) NullCountIndicator(org.talend.dataquality.indicators.NullCountIndicator) Indicator(org.talend.dataquality.indicators.Indicator) RowCountIndicator(org.talend.dataquality.indicators.RowCountIndicator) NullCountIndicator(org.talend.dataquality.indicators.NullCountIndicator) Test(org.junit.Test)

Example 8 with RowCountIndicator

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

the class IndicatorHelperTest method testGetRowCountIndicator1.

/**
 * Test method for
 * {@link org.talend.dataquality.helpers.IndicatorHelper#getRowCountIndicator(orgomg.cwm.objectmodel.core.ModelElement, java.util.Map)}
 * . get RowCountIndicator
 */
@Test
public void testGetRowCountIndicator1() {
    // TdColumn
    TdColumn column1 = RelationalFactory.eINSTANCE.createTdColumn();
    // ~
    // Indicator
    Indicator rowCountIndicator = IndicatorsFactory.eINSTANCE.createRowCountIndicator();
    Indicator nullCountIndicator = IndicatorsFactory.eINSTANCE.createNullCountIndicator();
    // ~
    // List
    List<Indicator> list = new ArrayList<Indicator>();
    list.add(rowCountIndicator);
    list.add(nullCountIndicator);
    // ~
    // Map
    Map<ModelElement, List<Indicator>> elementToIndicator = new HashMap<ModelElement, List<Indicator>>();
    elementToIndicator.put(column1, list);
    // ~
    RowCountIndicator rowCountIndicator2 = IndicatorHelper.getRowCountIndicator(column1, elementToIndicator);
    assert (rowCountIndicator2 != null);
}
Also used : ModelElement(orgomg.cwm.objectmodel.core.ModelElement) TdColumn(org.talend.cwm.relational.TdColumn) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) RowCountIndicator(org.talend.dataquality.indicators.RowCountIndicator) NullCountIndicator(org.talend.dataquality.indicators.NullCountIndicator) Indicator(org.talend.dataquality.indicators.Indicator) RowCountIndicator(org.talend.dataquality.indicators.RowCountIndicator) Test(org.junit.Test)

Example 9 with RowCountIndicator

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

the class AnalysisTableTreeViewer method createOneUnit.

public void createOneUnit(final TreeItem treeItem, TableIndicatorUnit indicatorUnit) {
    final TreeItem indicatorItem = new TreeItem(treeItem, SWT.NONE);
    final TableIndicatorUnit unit = indicatorUnit;
    IndicatorEnum type = indicatorUnit.getType();
    final IndicatorEnum indicatorEnum = type;
    indicatorItem.setData(TABLE_INDICATOR_KEY, treeItem.getData(TABLE_INDICATOR_KEY));
    indicatorItem.setData(INDICATOR_UNIT_KEY, unit);
    indicatorItem.setData(VIEWER_KEY, this);
    String label = indicatorUnit.getIndicatorName();
    // $NON-NLS-1$
    label = label != null ? label : "Unknown indicator";
    SysIndicatorDefinitionRepNode recursiveFindIndicatorDefinition = RepositoryNodeHelper.recursiveFindIndicatorDefinition(indicatorUnit.getIndicator().getIndicatorDefinition());
    if (recursiveFindIndicatorDefinition != null && !recursiveFindIndicatorDefinition.getProject().isMainProject()) {
        label = label + recursiveFindIndicatorDefinition.getDisplayProjectName();
    }
    if (IndicatorEnum.WhereRuleIndicatorEnum.compareTo(type) == 0) {
        indicatorItem.setImage(0, ImageLib.getImage(ImageLib.DQ_RULE));
    } else if (IndicatorEnum.RowCountIndicatorEnum.compareTo(type) == 0) {
        indicatorItem.setImage(0, ImageLib.getImage(ImageLib.IND_DEFINITION));
    }
    indicatorItem.setText(0, label);
    TreeEditor optionEditor = new TreeEditor(tree);
    // $NON-NLS-1$
    final Label optionLabel = createTreeItemLabel(tree, ImageLib.OPTION, "AnalysisTableTreeViewer.options");
    optionLabel.setData(indicatorUnit);
    optionLabel.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseDown(MouseEvent e) {
            boolean hasIndicatorParameters = openIndicatorOptionDialog(Display.getCurrent().getActiveShell(), indicatorItem);
            if (hasIndicatorParameters) {
                optionLabel.setImage(ImageLib.getImage(ImageLib.INDICATOR_OPTION_CHECKED));
            }
        }
    });
    optionEditor.minimumWidth = optionLabel.getImage().getBounds().width;
    optionEditor.horizontalAlignment = SWT.CENTER;
    optionEditor.setEditor(optionLabel, indicatorItem, 1);
    TreeEditor delEditor = null;
    if (!(unit.getIndicator() instanceof RowCountIndicator)) {
        delEditor = new TreeEditor(tree);
        // $NON-NLS-1$
        Label delLabel = createTreeItemLabel(tree, ImageLib.DELETE_ACTION, "AnalysisTableTreeViewer.delete");
        delLabel.addMouseListener(new MouseAdapter() {

            @Override
            public void mouseDown(MouseEvent e) {
                deleteIndicatorItems((TableIndicator) treeItem.getData(TABLE_INDICATOR_KEY), unit);
                if (indicatorItem.getParentItem() != null && indicatorItem.getParentItem().getData(INDICATOR_UNIT_KEY) != null) {
                    setElements(tableIndicators);
                } else {
                    removeItemBranch(indicatorItem);
                    indicatorTreeItemMap.remove(unit);
                }
            }
        });
        delEditor.minimumWidth = delLabel.getImage().getBounds().width;
        delEditor.horizontalAlignment = SWT.CENTER;
        delEditor.setEditor(delLabel, indicatorItem, 2);
    }
    if (delEditor == null) {
        indicatorItem.setData(ITEM_EDITOR_KEY, new TreeEditor[] { optionEditor });
    } else {
        indicatorItem.setData(ITEM_EDITOR_KEY, new TreeEditor[] { optionEditor, delEditor });
    }
    if (indicatorEnum != null && indicatorEnum.hasChildren()) {
        indicatorItem.setData(treeItem.getData(TABLE_INDICATOR_KEY));
        createIndicatorItems(indicatorItem, indicatorUnit.getChildren());
    }
    if (hasIndicatorParameters(indicatorUnit)) {
        optionLabel.setImage(ImageLib.getImage(ImageLib.INDICATOR_OPTION_CHECKED));
    }
    // ADD xqliu 2009-04-30 bug 6808
    this.indicatorTreeItemMap.put(unit, indicatorItem);
}
Also used : TableIndicator(org.talend.dataprofiler.core.model.TableIndicator) MouseEvent(org.eclipse.swt.events.MouseEvent) IndicatorEnum(org.talend.dq.nodes.indicator.type.IndicatorEnum) TreeEditor(org.eclipse.swt.custom.TreeEditor) TreeItem(org.eclipse.swt.widgets.TreeItem) SysIndicatorDefinitionRepNode(org.talend.dq.nodes.SysIndicatorDefinitionRepNode) Label(org.eclipse.swt.widgets.Label) MouseAdapter(org.eclipse.swt.events.MouseAdapter) TableIndicatorUnit(org.talend.dataprofiler.core.ui.editor.preview.TableIndicatorUnit) RowCountIndicator(org.talend.dataquality.indicators.RowCountIndicator)

Example 10 with RowCountIndicator

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

the class ColumnSetIndicatorEvaluator method storeDataSet.

/**
 * store data which from 'simpleIndicator.getListRows()' except RowCountIndicator.
 *
 * @param indicToRowMap
 */
private void storeDataSet() {
    EMap<Indicator, AnalyzedDataSet> indicToRowMap = analysis.getResults().getIndicToRowMap();
    for (Indicator indicator : analysis.getResults().getIndicators()) {
        if (indicator instanceof SimpleStatIndicator) {
            SimpleStatIndicator simpleIndicator = (SimpleStatIndicator) indicator;
            if (!analysis.getParameters().isStoreData()) {
                break;
            }
            if (simpleIndicator.isUsedMapDBMode() && AnalysisHelper.isJavaExecutionEngine(analysis)) {
            // nothing need to do
            } else {
                List<Object[]> listRows = simpleIndicator.getListRows();
                if (listRows == null || listRows.isEmpty()) {
                    break;
                }
                for (Indicator leafIndicator : simpleIndicator.getLeafIndicators()) {
                    if (leafIndicator instanceof RowCountIndicator) {
                        continue;
                    }
                    List<Object[]> dataList = new ArrayList<Object[]>();
                    AnalyzedDataSet analyzedDataSet = indicToRowMap.get(leafIndicator);
                    if (analyzedDataSet == null) {
                        analyzedDataSet = AnalysisFactory.eINSTANCE.createAnalyzedDataSet();
                        indicToRowMap.put(leafIndicator, analyzedDataSet);
                        analyzedDataSet.setDataCount(analysis.getParameters().getMaxNumberRows());
                        analyzedDataSet.setRecordSize(0);
                    }
                    for (int i = 0; i < listRows.size(); i++) {
                        // if (dataList.size() >= analyzedDataSet.getDataCount()) {
                        // break;
                        // }
                        Object[] object = listRows.get(i);
                        // the last element store the count value.
                        Object count = object[object.length > 0 ? object.length - 1 : 0];
                        if (leafIndicator instanceof DistinctCountIndicator) {
                            dataList.add(object);
                        } else if (leafIndicator instanceof UniqueCountIndicator) {
                            if (count != null && NumberUtils.isNumber(count + PluginConstant.EMPTY_STRING)) {
                                if (Long.valueOf(count + PluginConstant.EMPTY_STRING).longValue() == 1) {
                                    dataList.add(object);
                                }
                            }
                        } else if (leafIndicator instanceof DuplicateCountIndicator) {
                            if (count != null && NumberUtils.isNumber(count + PluginConstant.EMPTY_STRING)) {
                                if (Long.valueOf(count + PluginConstant.EMPTY_STRING).longValue() > 1) {
                                    dataList.add(object);
                                }
                            }
                        }
                    }
                    analyzedDataSet.setData(dataList);
                }
                // MOD sizhaoliu TDQ-7144 clear the listRows after usage for drill down
                if (!simpleIndicator.isStoreData()) {
                    simpleIndicator.setListRows(new ArrayList<Object[]>());
                }
            }
        }
        if (indicator instanceof AllMatchIndicator) {
            AllMatchIndicator allMatchIndicator = (AllMatchIndicator) indicator;
            if (!allMatchIndicator.isStoreData()) {
                allMatchIndicator.setListRows(new ArrayList<Object[]>());
            }
        }
    }
}
Also used : DuplicateCountIndicator(org.talend.dataquality.indicators.DuplicateCountIndicator) AnalyzedDataSet(org.talend.dataquality.analysis.AnalyzedDataSet) ArrayList(java.util.ArrayList) UniqueCountIndicator(org.talend.dataquality.indicators.UniqueCountIndicator) 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) DistinctCountIndicator(org.talend.dataquality.indicators.DistinctCountIndicator) AllMatchIndicator(org.talend.dataquality.indicators.columnset.AllMatchIndicator) RowCountIndicator(org.talend.dataquality.indicators.RowCountIndicator) SimpleStatIndicator(org.talend.dataquality.indicators.columnset.SimpleStatIndicator)

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