use of org.talend.dataquality.indicators.Indicator in project tdq-studio-se by Talend.
the class ColumnSetAnalysisHandler method getIndicatorLeaves.
/**
* Method "getIndicatorLeaves" returns the indicators for the given column at the leaf level.
*
* @param column
* @return the indicators attached to this column
*/
public Collection<Indicator> getIndicatorLeaves(TdColumn column) {
// get the leaf indicators
Collection<Indicator> leafIndics = IndicatorHelper.getIndicatorLeaves(analysis.getResults());
// filter only indicators for this column
Collection<Indicator> indics = new ArrayList<Indicator>();
for (Indicator indicator : leafIndics) {
if (indicator.getAnalyzedElement() != null && indicator.getAnalyzedElement().equals(column)) {
indics.add(indicator);
}
}
return indics;
}
use of org.talend.dataquality.indicators.Indicator in project tdq-studio-se by Talend.
the class TableAnalysisHandler method getIndicatorLeaves.
/**
* Method "getIndicatorLeaves" returns the indicators for the given table at the leaf level.
*
* @param table
* @return the indicators attached to this table
*/
public Collection<Indicator> getIndicatorLeaves(TdTable table) {
// get the leaf indicators
Collection<Indicator> leafIndics = IndicatorHelper.getIndicatorLeaves(analysis.getResults());
// filter only indicators for this table
Collection<Indicator> indics = new ArrayList<Indicator>();
for (Indicator indicator : leafIndics) {
if (indicator.getAnalyzedElement() != null && indicator.getAnalyzedElement().equals(table)) {
indics.add(indicator);
}
}
return indics;
}
use of org.talend.dataquality.indicators.Indicator in project tdq-studio-se by Talend.
the class MultiColumnAnalysisExecutor method instantiateQuery.
/**
* DOC scorreia Comment method "instantiateQuery".
*
* @param indicator
*/
private void instantiateQuery(Indicator indicator) {
if (ColumnsetPackage.eINSTANCE.getColumnSetMultiValueIndicator().isSuperTypeOf(indicator.eClass())) {
ColumnSetMultiValueIndicator colSetMultValIndicator = (ColumnSetMultiValueIndicator) indicator;
final EList<ModelElement> analyzedColumns = colSetMultValIndicator.getAnalyzedColumns();
final EList<String> numericFunctions = initializeNumericFunctions(colSetMultValIndicator);
final EList<String> dateFunctions = initializeDateFunctions(colSetMultValIndicator);
// ADD msjian 2011-5-30 17479: Excel Odbc connection can not run well on the correlation analysis
// note: this feature is not supported now, if support, delete this
// $NON-NLS-1$
final String caseStr = "SUM(CASE WHEN {0} IS NULL THEN 1 ELSE 0 END)";
if (// $NON-NLS-1$
"EXCEL".equals(dbms().getDbmsName()) && (dateFunctions.contains(caseStr) || numericFunctions.contains(caseStr))) {
// $NON-NLS-1$
setError(Messages.getString("MultiColumnAnalysisExecutor.errMessage"));
Display.getDefault().syncExec(new Runnable() {
public void run() {
MessageDialog.openWarning(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), Messages.getString("MultiColumnAnalysisExecutor.errTitle"), // $NON-NLS-1$
getErrorMessage());
return;
}
});
}
// ~
// get indicator definition
final Expression sqlGenericExpression = dbms().getSqlExpression(indicator.getIndicatorDefinition());
// separate nominal from numeric columns
List<String> nominalColumns = new ArrayList<String>();
for (ModelElement column : colSetMultValIndicator.getNominalColumns()) {
nominalColumns.add(getQuotedColumnName(column));
}
List<String> computedColumns = new ArrayList<String>();
for (ModelElement column : colSetMultValIndicator.getNumericColumns()) {
// call functions for each column
for (String f : numericFunctions) {
computedColumns.add(replaceVariablesLow(f, getQuotedColumnName(column)));
}
}
for (ModelElement column : colSetMultValIndicator.getDateColumns()) {
// call functions for each column
for (String f : dateFunctions) {
computedColumns.add(replaceVariablesLow(f, getQuotedColumnName(column)));
}
}
// add count(*)
computedColumns.add(colSetMultValIndicator.getCountAll());
// MOD msjian TDQ-7254: fix the columnset analysis run get error. the columnset analysis don't need to
// consider the datamining type.
List<String> columns = new ArrayList<String>();
// if the analysis type is columnset, use analyzed columns
if (AnalysisType.COLUMN_SET == cachedAnalysis.getParameters().getAnalysisType()) {
for (ModelElement column : analyzedColumns) {
columns.add(getQuotedColumnName(column));
}
} else {
columns = nominalColumns;
}
// TDQ-7254~
String selectItems = createSelect(columns, computedColumns);
String grpByClause = createGroupBy(columns);
// all columns must belong to the same table
TdColumn firstColumn = SwitchHelpers.COLUMN_SWITCH.doSwitch(analyzedColumns.get(0));
String tableName = dbms().getQueryColumnSetWithPrefix(firstColumn);
this.catalogOrSchema = dbms().getCatalogOrSchemaName(firstColumn);
// definition is SELECT <%=__COLUMN_NAMES__%> FROM <%=__TABLE_NAME__%> GROUP BY
// <%=__GROUP_BY_ALIAS__%>
String sqlExpr = dbms().fillGenericQueryWithColumnTableAndAlias(sqlGenericExpression.getBody(), selectItems, tableName, grpByClause);
// handle data filter
String stringDataFilter = ContextHelper.getDataFilterWithoutContext(cachedAnalysis);
if (stringDataFilter == null) {
stringDataFilter = PluginConstant.EMPTY_STRING;
}
sqlExpr = dbms().addWhereToStatement(sqlExpr, stringDataFilter);
indicator.setInstantiatedExpression(BooleanExpressionHelper.createTdExpression(sqlGenericExpression.getLanguage(), sqlExpr));
// MOD qiongli 2011-3-30 feature 19192.allow drill down for sql engine.
if (ColumnsetPackage.eINSTANCE.getSimpleStatIndicator().isSuperTypeOf(indicator.eClass())) {
SimpleStatIndicator simpleIndicator = (SimpleStatIndicator) indicator;
// MOD TDQ-7287 lost some columns(type!=norminal) when view values in column set ana. yyin 20130514
String columnsName = createSelect(columns, new ArrayList<String>());
for (Indicator leafIndicator : simpleIndicator.getLeafIndicators()) {
final Expression leafSqlGenericExpression = dbms().getSqlExpression(leafIndicator.getIndicatorDefinition());
String leafSqlExpr = dbms().fillGenericQueryWithColumnTableAndAlias(leafSqlGenericExpression.getBody(), columnsName, tableName, grpByClause);
leafSqlExpr = dbms().addWhereToStatement(leafSqlExpr, stringDataFilter);
leafIndicator.setInstantiatedExpression(BooleanExpressionHelper.createTdExpression(leafSqlGenericExpression.getLanguage(), leafSqlExpr));
}
}
}
}
use of org.talend.dataquality.indicators.Indicator in project tdq-studio-se by Talend.
the class SchemaAnalysisExecutor method evaluate.
/*
* (non-Javadoc)
*
* @see org.talend.dq.analysis.AnalysisExecutor#runAnalysis(org.talend.dataquality.analysis.Analysis,
* java.lang.String)
*/
@Override
protected ReturnCode evaluate(Analysis analysis, java.sql.Connection connection, String sqlStatement) {
SchemaEvaluator eval = new SchemaEvaluator();
// MOD xqliu 2009-02-09 bug 6237
eval.setMonitor(getMonitor());
// // --- add indicators
EList<Indicator> indicators = analysis.getResults().getIndicators();
for (Indicator indicator : indicators) {
ModelElement analyzedElement = indicator.getAnalyzedElement();
if (analyzedElement == null) {
continue;
}
Schema cat = SwitchHelpers.SCHEMA_SWITCH.doSwitch(analyzedElement);
if (cat == null) {
continue;
}
eval.storeIndicator(cat, indicator);
// ADDED rli 2008-07-10 fixed for the SchemaIndicator will increased after connection analysis running.
indicator.reset();
}
if (getMonitor() != null) {
getMonitor().worked(compIndicatorsWorked);
}
ReturnCode retCode = runAnalysisLow(analysis, sqlStatement, eval, connection);
return retCode;
}
use of org.talend.dataquality.indicators.Indicator in project tdq-studio-se by Talend.
the class ConnectionAnalysisExecutor method evaluate.
/*
* (non-Javadoc)
*
* @see org.talend.dq.analysis.AnalysisExecutor#runAnalysis(org.talend.dataquality.analysis.Analysis,
* java.lang.String)
*/
@Override
protected ReturnCode evaluate(Analysis analysis, java.sql.Connection connection, String sqlStatement) {
ConnectionEvaluator eval = new ConnectionEvaluator();
// MOD xqliu 2009-02-09 bug 6237
eval.setMonitor(getMonitor());
// // --- add indicators
EList<Indicator> indicators = analysis.getResults().getIndicators();
for (Indicator indicator : indicators) {
ModelElement analyzedElement = indicator.getAnalyzedElement();
if (analyzedElement == null) {
continue;
}
Connection dataProvider = SwitchHelpers.CONNECTION_SWITCH.doSwitch(analyzedElement);
if (dataProvider == null) {
continue;
}
eval.storeIndicator(dataProvider, indicator);
// ADDED rli 2008-07-10 fixed for the SchemaIndicator will increased after connection analysis running.
indicator.reset();
}
ReturnCode retCode = runAnalysisLow(analysis, sqlStatement, eval, connection);
if (getMonitor() != null) {
getMonitor().worked(compIndicatorsWorked);
}
return retCode;
}
Aggregations