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());
}
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);
}
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);
}
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);
}
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[]>());
}
}
}
}
Aggregations