use of org.talend.cwm.exception.AnalysisExecutionException in project tdq-studio-se by Talend.
the class FunctionalDependencyExecutor method runAnalysis.
@Override
protected boolean runAnalysis(Analysis analysis, String sqlStatement) {
Boolean runStatus = Boolean.TRUE;
TypedReturnCode<java.sql.Connection> trc = this.getConnectionBeforeRun(analysis);
if (!trc.isOk()) {
log.error(trc.getMessage());
setError(trc.getMessage());
traceError(Messages.getString("FunctionalDependencyExecutor.CANNOTEXECUTEANALYSIS", analysis.getName(), // $NON-NLS-1$
trc.getMessage()));
return Boolean.FALSE;
}
Connection connection = trc.getObject();
try {
// execute the sql statement for each indicator
EList<Indicator> indicators = analysis.getResults().getIndicators();
EList<Indicator> deactivatedIndicators = analysis.getParameters().getDeactivatedIndicators();
for (Indicator indicator : indicators) {
if (deactivatedIndicators.contains(indicator)) {
// do not evaluate this indicator
continue;
}
Expression query = dbms().getInstantiatedExpression(indicator);
if (query == null) {
// TODO internationalize the string.
traceError(// $NON-NLS-1$//$NON-NLS-2$
"Query not executed for indicator: \"" + AnalysisExecutorHelper.getIndicatorName(indicator) + "\" " + // $NON-NLS-1$
"query is null");
runStatus = Boolean.FALSE;
continue;
}
try {
boolean exeStatus = executeQuery(indicator, connection, query);
if (!exeStatus) {
// TODO internationalize the string.
traceError(// $NON-NLS-1$//$NON-NLS-2$
"Query not executed for indicator: \"" + AnalysisExecutorHelper.getIndicatorName(indicator) + "\" " + "SQL query: " + // $NON-NLS-1$
query.getBody());
runStatus = Boolean.FALSE;
continue;
}
} catch (AnalysisExecutionException e) {
traceError(e.getMessage());
runStatus = Boolean.FALSE;
continue;
}
indicator.setComputed(true);
}
} finally {
ReturnCode rc = closeConnection(analysis, connection);
if (!rc.isOk()) {
runStatus = Boolean.FALSE;
}
}
return runStatus;
}
use of org.talend.cwm.exception.AnalysisExecutionException in project tdq-studio-se by Talend.
the class RowMatchingAnalysisExecutor method executeQuery.
/**
* DOC scorreia Comment method "executeQuery".
*
* @param indicator
* @param connection
* @param query
* @return
* @throws AnalysisExecutionException
*/
private boolean executeQuery(Indicator indicator, Connection connection, Expression query) throws AnalysisExecutionException {
try {
List<Object[]> myResultSet = executeQuery(catalogOrSchema, connection, query.getBody());
String tableName = getAnalyzedTable(indicator);
// MOD xqliu 2009-06-16 bug 7334
// set data filter here
reversion = indiReversionMap != null && indiReversionMap.get(indicator) != null ? indiReversionMap.get(indicator).booleanValue() : false;
String stringDataFilter = reversion ? ContextHelper.getDataFilterWithoutContext(this.cachedAnalysis, AnalysisHelper.DATA_FILTER_B) : ContextHelper.getDataFilterWithoutContext(this.cachedAnalysis, AnalysisHelper.DATA_FILTER_A);
List<String> whereClauses = new ArrayList<String>();
if (stringDataFilter != null && !stringDataFilter.trim().equals(PluginConstant.EMPTY_STRING)) {
whereClauses.add(stringDataFilter);
}
// ~
// give result to indicator so that it handles the results
boolean ok = indicator.storeSqlResults(myResultSet);
// get row count and store it in indicator
// $NON-NLS-1$
Long count = getCount(cachedAnalysis, "*", tableName, catalogOrSchema, whereClauses);
ok = ok && count != null;
indicator.setCount(count);
// compute matching count
if (ColumnsetPackage.eINSTANCE.getRowMatchingIndicator().equals(indicator.eClass())) {
RowMatchingIndicator rowMatchingIndicator = (RowMatchingIndicator) indicator;
Long notMatchingValueCount = rowMatchingIndicator.getNotMatchingValueCount();
ok = ok && notMatchingValueCount != null;
if (ok) {
rowMatchingIndicator.setMatchingValueCount(count - notMatchingValueCount);
}
}
return ok;
} catch (SQLException e) {
log.error(e, e);
// MOD TDQ-8388 return the exact error message
throw new AnalysisExecutionException(e.getMessage());
}
}
use of org.talend.cwm.exception.AnalysisExecutionException in project tdq-studio-se by Talend.
the class TableAnalysisSqlExecutor method createSqlStatement.
@Override
protected String createSqlStatement(Analysis analysis) {
this.cachedAnalysis = analysis;
AnalysisResult results = analysis.getResults();
assert results != null;
try {
// --- get data filter
stringDataFilter = ContextHelper.getDataFilterWithoutContext(analysis);
// --- get all the leaf indicators used for the sql computation
Collection<Indicator> leafIndicators = IndicatorHelper.getIndicatorLeavesBySingleNode(results);
// --- create one sql statement for each leaf indicator
for (Indicator indicator : leafIndicators) {
if (!createSqlQuery(stringDataFilter, indicator, false)) {
log.error(Messages.getString("ColumnAnalysisSqlExecutor.CREATEQUERYERROR", // $NON-NLS-1$
AnalysisExecutorHelper.getIndicatorName(indicator)));
return null;
}
}
} catch (AnalysisExecutionException e) {
log.error(e, e);
return null;
}
return PluginConstant.EMPTY_STRING;
}
Aggregations