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);
}
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;
}
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);
}
// }
}
}
}
}
}
}
}
}
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;
}
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;
}
Aggregations