use of org.talend.dataquality.indicators.Indicator 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.Indicator in project tdq-studio-se by Talend.
the class IndicatorsComp method setInput.
// input composite indicator
public void setInput(Object... obj) {
List<ColumnSetIndicatorUnit> indicatortList = new ArrayList<ColumnSetIndicatorUnit>();
for (Object indicatorObj : obj) {
// for SimpleStatIndicator, CountAvgNullIndicator, MinMaxDateIndicator, WeakCorrelationIndicator
if (indicatorObj instanceof SimpleStatIndicator || indicatorObj instanceof CountAvgNullIndicator || indicatorObj instanceof MinMaxDateIndicator || indicatorObj instanceof WeakCorrelationIndicator) {
columnSetIndicator = (ColumnSetMultiValueIndicator) indicatorObj;
for (Indicator indicator : IndicatorHelper.getIndicatorLeavesBySingleNode(columnSetIndicator)) {
IndicatorEnum indicatorEnum = IndicatorEnum.findIndicatorEnum(indicator.eClass());
indicatortList.add(new ColumnSetIndicatorUnit(indicatorEnum, indicator));
}
// MOD msjian TDQ-8860: we always show the allMatchIndicator in the Indicators section
} else if (indicatorObj instanceof AllMatchIndicator) {
// for AllMatchIndicator
AllMatchIndicator allMatchIndicator = (AllMatchIndicator) indicatorObj;
indicatortList.add(new ColumnSetIndicatorUnit(IndicatorEnum.AllMatchIndicatorEnum, allMatchIndicator));
// TDQ-8860~
}
// ~
}
setElements(indicatortList.toArray(new ColumnSetIndicatorUnit[indicatortList.size()]));
}
use of org.talend.dataquality.indicators.Indicator in project tdq-studio-se by Talend.
the class PatternMouseAdapter method mouseDown.
@Override
public void mouseDown(MouseEvent e) {
DataManager dm = analysis.getContext().getConnection();
if (dm == null) {
masterPage.doSave(null);
}
// MOD gdbu 2011-8-26 bug : TDQ-2169
IRepositoryNode patternFolderNode = getPatternSelectDialogInputData();
if (patternFolderNode == null) {
return;
}
CheckedTreeSelectionDialog dialog = PatternUtilities.createPatternCheckedTreeSelectionDialog(patternFolderNode);
if (null != filters) {
for (ViewerFilter filter : filters) {
dialog.addFilter(filter);
}
}
// ~TDQ-2169
Object[] selectedRepNodes = PatternUtilities.getPatternRepNodesByIndicator(meIndicator);
dialog.setInitialSelections(selectedRepNodes);
dialog.create();
if (dialog.open() == Window.OK) {
// MOD qiongli 2012-10-17 TDQ-5923,just remove some deselected indicatorUnit,just create new indicatorUnit
// for some new added pattern nodes.
List<PatternRepNode> allSelectedPatternNodes = new ArrayList<PatternRepNode>();
Set<String> allSelectedNodeNames = new HashSet<String>();
for (Object obj : dialog.getResult()) {
if (obj instanceof PatternRepNode) {
PatternRepNode patternNode = (PatternRepNode) obj;
allSelectedPatternNodes.add(patternNode);
allSelectedNodeNames.add(patternNode.getLabel());
}
}
Set<String> oldSelectedNodeNames = new HashSet<String>();
Map<String, IndicatorUnit> oldSelectedUnits = new HashMap<String, IndicatorUnit>();
for (IndicatorUnit indicatorUnit : meIndicator.getIndicatorUnits()) {
Indicator indicator = indicatorUnit.getIndicator();
if (indicator instanceof PatternMatchingIndicator) {
if (!allSelectedNodeNames.contains(indicator.getName())) {
// this method will deal dependency with same time
columnDropTree.deleteIndicatorItems(meIndicator, indicatorUnit);
if (!columnDropTree.isDirty()) {
columnDropTree.setDirty(true);
}
} else {
oldSelectedNodeNames.add(indicator.getName());
oldSelectedUnits.put(indicator.getName(), indicatorUnit);
}
}
}
// Added yyin 20121121 TDQ-6329: after remove all, should also add the old selected patterns
// because the columnset does not have pagination, can not refresh automatically
boolean addOldSelected = false;
if (masterPage instanceof ColumnSetAnalysisDetailsPage) {
addOldSelected = true;
}
if (addOldSelected) {
for (TreeItem child : treeItem.getItems()) {
masterPage.getTreeViewer().removeItemBranch(child);
}
}
// ~
treeItem.removeAll();
for (PatternRepNode patternNode : allSelectedPatternNodes) {
if (oldSelectedNodeNames.contains(patternNode.getLabel()) && !addOldSelected) {
continue;
}
TypedReturnCode<IndicatorUnit> trc = PatternUtilities.createIndicatorUnit(patternNode.getPattern(), meIndicator, analysis);
if (trc.isOk()) {
createOneUnit(trc.getObject());
// TDQ-8860 add msjian 2014-4-30:check whether show allmatchindicator in the indicators section
if (masterPage instanceof ColumnSetAnalysisDetailsPage) {
EventManager.getInstance().publish(analysis, EventEnum.DQ_COLUMNSET_SHOW_MATCH_INDICATORS, null);
}
// TDQ-8860~
}
}
treeItem.setExpanded(true);
if (masterPage instanceof ColumnAnalysisDetailsPage) {
ColumnAnalysisDetailsPage page = (ColumnAnalysisDetailsPage) masterPage;
page.refreshTheTree(page.getCurrentModelElementIndicators());
}
}
}
use of org.talend.dataquality.indicators.Indicator in project tdq-studio-se by Talend.
the class DrillDownEditorInput method getColumnSetIndicatorResultSize.
/**
* DOC talend Comment method "getColumnSetIndicatorResultSize".
*
* @param itemsSize
* @return
*/
private Long getColumnSetIndicatorResultSize() {
Long itemsSize = 0l;
SimpleStatIndicator simpleStatIndicator = null;
// Find simpleStatIndicator from result of analysis
for (Indicator indicator : analysis.getResults().getIndicators()) {
if (SimpleStatIndicator.class.isInstance(indicator)) {
simpleStatIndicator = (SimpleStatIndicator) indicator;
break;
}
}
// Get the Result from simpleStatIndicator by currIndicator
if (simpleStatIndicator != null) {
if (DuplicateCountIndicator.class.isInstance(currIndicator)) {
itemsSize = simpleStatIndicator.getDuplicateCount();
} else if (DistinctCountIndicator.class.isInstance(currIndicator)) {
itemsSize = simpleStatIndicator.getDistinctCount();
} else if (UniqueCountIndicator.class.isInstance(currIndicator)) {
itemsSize = simpleStatIndicator.getUniqueCount();
} else if (RowCountIndicator.class.isInstance(currIndicator)) {
itemsSize = simpleStatIndicator.getCount();
}
}
return itemsSize;
}
use of org.talend.dataquality.indicators.Indicator in project tdq-studio-se by Talend.
the class DrillDownEditorInput method getColumnIndexArray.
/**
* Get index of column whiche will be used on the dirll down. Note that One indicator only belong one column so that
* the array of retrun value just contain one element.
*
* And if we create new map for view values menu rather than used same map with view rows menu then method can be
* removed
*
* @return
*/
public Integer[] getColumnIndexArray() {
if (!DrillDownUtils.judgeMenuType(this.getMenuType(), DrillDownUtils.MENU_VALUE_TYPE) || !UniqueCountIndicator.class.isInstance(currIndicator)) {
return null;
}
List<Integer> indexArray = new ArrayList<Integer>();
Indicator indicator = this.getCurrIndicator();
ModelElement analysisElement = indicator.getAnalyzedElement();
int index = 0;
if (analysisElement instanceof TdColumn) {
List<TdColumn> columns = getColumnsByTdColumn((TdColumn) analysisElement);
for (TdColumn column : columns) {
if (column.getName().equals(analysisElement.getName())) {
indexArray.add(index);
// break at here.
break;
}
index++;
}
} else if (analysisElement instanceof MetadataColumn) {
MetadataTable mTable = ColumnHelper.getColumnOwnerAsMetadataTable((MetadataColumn) analysisElement);
for (MetadataColumn mColumn : mTable.getColumns()) {
if (mColumn.getLabel().equals(analysisElement.getName())) {
indexArray.add(index);
// break at here.
break;
}
index++;
}
}
return indexArray.toArray(new Integer[indexArray.size()]);
}
Aggregations