use of org.talend.dataquality.indicators.Indicator in project tdq-studio-se by Talend.
the class DrillDownUtils method createDrillDownMenuForJava.
/**
* DOC talend Comment method "createDrillDownMenu".
*
* @param analysis
* @param dataEntity
* @param menu
* @param itemEntities
* @param analysis
*/
public static void createDrillDownMenuForJava(final ChartDataEntity dataEntity, Menu menu, MenuItemEntity[] itemEntities, final Analysis analysis) {
final Indicator indicator = dataEntity != null ? dataEntity.getIndicator() : null;
AnalyzedDataSet analyDataSet = analysis.getResults().getIndicToRowMap().get(indicator);
boolean hasData = analyDataSet != null && (analyDataSet.getData() != null && analyDataSet.getData().size() > 0 || analyDataSet.getFrequencyData() != null && analyDataSet.getFrequencyData().size() > 0 || analyDataSet.getPatternData() != null && analyDataSet.getPatternData().size() > 0);
if (hasData) {
createDrillDownMenu(dataEntity, menu, itemEntities, analysis);
}
}
use of org.talend.dataquality.indicators.Indicator in project tdq-studio-se by Talend.
the class DrillDownUtils method getMapDB.
/**
* Get MapDB which store the drill down data for current indicator
*
* @param analysis
*
* @return
*/
public static AbstractDB<Object> getMapDB(final ChartDataEntity dataEntity, Analysis analysis, MenuItemEntity itemEntitie) {
AnalysisType analysisType = analysis.getParameters().getAnalysisType();
if (AnalysisType.COLUMN_SET == analysisType) {
return getColumnSetAnalysisMapDB(analysis);
}
Indicator indicator = dataEntity.getIndicator();
String selectValue = dataEntity.getLabel();
// TDQ-10785: fix the drill down menu for frequency table indicator and pattern frequency indicator can not use
// when the data is too long
String keyLabel = String.valueOf(dataEntity.getKey());
// the equals on the right is the same to FrequencyTypeStateUtil.getKeyLabel()
if (keyLabel.length() > 30 && selectValue.equals(keyLabel.substring(0, 30) + "...(" + keyLabel.length() + " characters)")) {
// $NON-NLS-1$ //$NON-NLS-2$
selectValue = keyLabel;
}
// TDQ-10785~
String dbMapName = getDBMapName(analysisType, indicator, selectValue, itemEntitie);
return MapDBUtils.getMapDB(dbMapName, dataEntity.getIndicator());
}
use of org.talend.dataquality.indicators.Indicator in project tdq-studio-se by Talend.
the class ColumnAnalysisExecutor method evaluate.
@Override
protected ReturnCode evaluate(Analysis analysis, java.sql.Connection connection, String sqlStatement) {
IndicatorEvaluator eval = CreateIndicatorEvaluator(analysis);
// MOD xqliu 2009-02-09 bug 6237
eval.setMonitor(getMonitor());
// set it into the evaluator
eval.setConnection(connection);
// use pooled connection
eval.setPooledConnection(POOLED_CONNECTION);
// --- add indicators
EList<Indicator> indicators = analysis.getResults().getIndicators();
RowCountIndicatorsAdapter.getInstance().clear();
for (Indicator indicator : indicators) {
assert indicator != null;
TdColumn tdColumn = SwitchHelpers.COLUMN_SWITCH.doSwitch(indicator.getAnalyzedElement());
if (tdColumn == null) {
continue;
}
// --- get the schema owner
if (!belongToSameSchemata(tdColumn)) {
// $NON-NLS-1$
setError(Messages.getString("ColumnAnalysisExecutor.GivenColumn", tdColumn.getName()));
return new ReturnCode(getErrorMessage(), Boolean.FALSE);
}
String columnName = ColumnHelper.getFullName(tdColumn);
eval.storeIndicator(columnName, indicator);
}
// when to close connection
boolean closeAtTheEnd = true;
Package catalog = schemata.values().iterator().next();
if (!eval.selectCatalog(catalog.getName())) {
// $NON-NLS-1$
log.warn(Messages.getString("ColumnAnalysisExecutor.FAILEDTOSELECTCATALOG", catalog.getName()));
}
return eval.evaluateIndicators(sqlStatement, closeAtTheEnd);
}
use of org.talend.dataquality.indicators.Indicator in project tdq-studio-se by Talend.
the class ColumnAnalysisSqlExecutor method runAnalysisIndicatorsParallel.
/**
* DOC xqliu Comment method "runAnalysisIndicatorsParallel".
*
* @param analysis
* @param elementToIndicator
* @param indicators
* @param pooledConnection
* @return
* @throws SQLException
*/
private boolean runAnalysisIndicatorsParallel(Analysis analysis, Map<ModelElement, List<Indicator>> elementToIndicator, List<Indicator> indicators, boolean pooledConnection) throws SQLException {
// reset the connection pool before run this analysis
resetConnectionPool(analysis);
// MOD gdbu 2011-6-10 bug : 21273
try {
final int totleWork = compIndicatorsWorked;
List<ExecutiveAnalysisJob> jobs = new ArrayList<ExecutiveAnalysisJob>();
final IProgressMonitor monitor = this.getMonitor();
if (monitor != null) {
// $NON-NLS-1$
monitor.subTask("Run Indicators Parallel");
}
int temp = 0;
for (int i = 0; i < indicators.size(); i++) {
final Indicator indicator = indicators.get(i);
if (!this.continueRun()) {
return false;
}
// TDQ-11851,in order to syn UI and backend-threads, add this Display.
if (monitor != null) {
Display.getDefault().syncExec(new Runnable() {
public void run() {
monitor.subTask(Messages.getString("ColumnAnalysisSqlExecutor.AnalyzedElement", // $NON-NLS-1$
indicator.getAnalyzedElement().getName()));
}
});
int current = (i + 1) * totleWork / indicators.size();
if (current > temp) {
monitor.worked(current - temp);
temp = current;
}
}
Connection conn = null;
if (pooledConnection) {
conn = getPooledConnection(analysis).getObject();
} else {
conn = getConnection(analysis).getObject();
}
if (conn != null) {
ExecutiveAnalysisJob eaj = new ExecutiveAnalysisJob(ColumnAnalysisSqlExecutor.this, conn, elementToIndicator, indicator);
eaj.setName(AnalysisExecutorHelper.getIndicatorName(indicator));
eaj.schedule();
jobs.add(eaj);
}
}
boolean hasErrorMessage = false;
// should call join() after schedule all the jobs
for (int i = 0; i < jobs.size(); i++) {
ExecutiveAnalysisJob eaj = jobs.get(i);
if (!this.continueRun()) {
break;
}
eaj.join();
if (eaj.errorMessage != null) {
hasErrorMessage = true;
ColumnAnalysisSqlExecutor.this.parallelExeStatus = false;
}
}
// Added TDQ-8388 20140530 yyin: only show one message to let the user check detail in error log.
if (hasErrorMessage) {
// $NON-NLS-1$
setError(Messages.getString("ColumnAnalysisSqlExecutor.ERRORREFERTOLOG"));
}
} catch (Throwable thr) {
log.error(thr);
} finally {
resetConnectionPool(analysis);
}
// ~21273
return parallelExeStatus;
// ~
}
use of org.talend.dataquality.indicators.Indicator in project tdq-studio-se by Talend.
the class ColumnSetAnalysisExecutor method runAnalysis.
/*
* (non-Jsdoc)
*
* @see org.talend.dq.analysis.AnalysisExecutor#runAnalysis(org.talend.dataquality.analysis.Analysis,
* java.lang.String)
*/
@Override
protected boolean runAnalysis(Analysis analysis, String sqlStatement) {
ColumnSetIndicatorEvaluator eval = createIndicatorEvaluator(analysis);
eval.setMonitor(getMonitor());
// --- add indicators
EList<Indicator> indicators = analysis.getResults().getIndicators();
for (Indicator indicator : indicators) {
if (ColumnsetPackage.eINSTANCE.getColumnSetMultiValueIndicator().isSuperTypeOf(indicator.eClass())) {
ColumnSetMultiValueIndicator colSetMultValIndicator = (ColumnSetMultiValueIndicator) indicator;
colSetMultValIndicator.prepare();
eval.storeIndicator(indicator.getName(), colSetMultValIndicator);
}
}
TypedReturnCode<java.sql.Connection> connection = null;
// MOD yyi 2011-02-22 17871:delimitefile
if (!isDelimitedFile) {
connection = initConnection(analysis, eval);
if (!connection.isOk()) {
return false;
}
}
// when to close connection
boolean closeAtTheEnd = true;
ReturnCode rc = eval.evaluateIndicators(sqlStatement, closeAtTheEnd);
// close connection
if (connection != null) {
if (POOLED_CONNECTION) {
// release the pooled connection
resetConnectionPool(analysis);
} else {
ConnectionUtils.closeConnection(connection.getObject());
}
}
if (!rc.isOk()) {
traceError(rc.getMessage());
}
if (getMonitor() != null) {
getMonitor().worked(compIndicatorsWorked);
}
return rc.isOk();
}
Aggregations