use of org.talend.dataquality.indicators.Indicator in project tdq-studio-se by Talend.
the class DrillDownEditorInput method filterAdaptColumnHeader.
/**
* DOC zshen Comment method "filterAdaptColumnHeader".
*
* @returnget the name of column which will be displayed on the drill down editor.
*/
public List<String> filterAdaptColumnHeader() {
// get columnHeader
Indicator indicator = this.getCurrIndicator();
ModelElement analysisElement = indicator.getAnalyzedElement();
String menuType = this.getMenuType();
List<String> columnElementList = new ArrayList<String>();
// MOD qiongli 2011-3-3,feature 19192 ,drill down for columnSet with java engine .
if (analysisElement == null && indicator.eContainer() instanceof SimpleStatIndicator) {
columnElementList = columnHeaderForColumnSet((SimpleStatIndicator) indicator.eContainer());
} else {
// MOD qiongli 2011-1-9 feature 16796
if (DrillDownUtils.judgeMenuType(menuType, DrillDownUtils.MENU_VALUE_TYPE)) {
columnElementList.add(ModelElementHelper.getName(indicator.getAnalyzedElement()));
} else if (analysisElement instanceof TdColumn) {
for (TdColumn column : getColumnsByTdColumn((TdColumn) analysisElement)) {
columnElementList.add(column.getName());
}
} else if (analysisElement instanceof MetadataColumn) {
MetadataTable mTable = ColumnHelper.getColumnOwnerAsMetadataTable((MetadataColumn) analysisElement);
for (MetadataColumn mColumn : mTable.getColumns()) {
columnElementList.add(mColumn.getLabel());
}
}
}
return columnElementList;
}
use of org.talend.dataquality.indicators.Indicator in project tdq-studio-se by Talend.
the class CatalogEvaluator method executeSqlQuery.
@Override
protected ReturnCode executeSqlQuery(String sqlStatement) throws SQLException {
ReturnCode ok = new ReturnCode(true);
// --- preconditions
DataProvider dataProvider = this.getDataManager();
if (this.elementToIndicators.values().isEmpty()) {
// $NON-NLS-1$
String msg = Messages.getString("Evaluator.NoInidcator1");
log.error(msg);
ok.setReturnCode(msg, false);
return ok;
}
Indicator[] indics = this.getAllIndicators();
if (indics.length == 0) {
// $NON-NLS-1$
String msg = Messages.getString("Evaluator.NoInidcator2", dataProvider);
log.error(msg);
ok.setReturnCode(msg, false);
return ok;
}
for (Indicator indicator : indics) {
CatalogIndicator catalogIndicator = DataqualitySwitchHelper.CATALOG_SWITCH.doSwitch(indicator);
if (catalogIndicator == null) {
continue;
}
Catalog catalog = (Catalog) catalogIndicator.getAnalyzedElement();
String catName = catalog.getName();
// MOD yyi 2009-11-30 10187
if (!checkCatalog(catName)) {
// $NON-NLS-1$
ok.setReturnCode(Messages.getString("Evaluator.catalogNotExist", catName), false);
return ok;
}
// MOD qiongli 2012-8-9,Method 'Method not supported' not supported for HiveConnection
if (dbms().supportCatalogSelection()) {
connection.setCatalog(catName);
}
List<Schema> schemas = CatalogHelper.getSchemas(catalog);
if (schemas.isEmpty()) {
// no schema
evalCatalogIndic(catalogIndicator, catalog, ok);
} else {
catalogIndicator.setAnalyzedElement(catalog);
catalogIndicator.setSchemaCount(schemas.size());
// --- create SchemaIndicator for each pair of catalog schema
for (Schema tdSchema : schemas) {
// --- create SchemaIndicator for each catalog
SchemaIndicator schemaIndic = SchemaFactory.eINSTANCE.createSchemaIndicator();
// MOD xqliu 2009-1-21 feature 4715
DefinitionHandler.getInstance().setDefaultIndicatorDefinition(schemaIndic);
evalSchemaIndicLow(catalogIndicator, schemaIndic, catalog, tdSchema, ok);
}
}
}
return ok;
}
use of org.talend.dataquality.indicators.Indicator in project tdq-studio-se by Talend.
the class Evaluator method prepareIndicators.
private boolean prepareIndicators() {
boolean ok = true;
for (Indicator indic : allIndicators) {
if (!indic.prepare()) {
javaPatternMessage = indic.getName();
ok = false;
}
}
return ok;
}
use of org.talend.dataquality.indicators.Indicator in project tdq-studio-se by Talend.
the class ColumnSetIndicatorEvaluator method evaluateBySql.
/**
* orgnize EList 'objectLs' by SQL.
*
* @param sqlStatement
* @param ok
* @return
* @throws SQLException
*/
private ReturnCode evaluateBySql(String sqlStatement, ReturnCode ok) throws SQLException {
Statement statement = null;
ResultSet resultSet = null;
try {
statement = createStatement();
if (continueRun()) {
if (log.isInfoEnabled()) {
// $NON-NLS-1$
log.info("Executing query: " + sqlStatement);
}
statement.execute(sqlStatement);
}
// get the results
resultSet = statement.getResultSet();
List<String> columnNames = getAnalyzedElementsName();
if (resultSet == null) {
// $NON-NLS-1$
String mess = Messages.getString("Evaluator.NoResultSet", sqlStatement);
log.warn(mess);
ok.setReturnCode(mess, false);
return ok;
}
EMap<Indicator, AnalyzedDataSet> indicToRowMap = analysis.getResults().getIndicToRowMap();
indicToRowMap.clear();
while (resultSet.next()) {
// MOD yyi 2012-04-11 TDQ-4916:Add memory control for java analysis.
if (!continueRun()) {
break;
}
EList<Object> objectLs = new BasicEList<Object>();
Iterator<String> it = columnNames.iterator();
while (it.hasNext()) {
Object obj = ResultSetUtils.getBigObject(resultSet, it.next());
objectLs.add(obj);
}
if (objectLs.size() == 0) {
continue;
}
handleObjects(objectLs, resultSet);
}
} finally {
if (resultSet != null) {
resultSet.close();
}
if (statement != null) {
statement.close();
}
closeConnection();
}
return ok;
}
use of org.talend.dataquality.indicators.Indicator in project tdq-studio-se by Talend.
the class ColumnSetIndicatorEvaluator method executeSqlQuery.
@Override
protected ReturnCode executeSqlQuery(String sqlStatement) throws SQLException {
ReturnCode ok = new ReturnCode(true);
AnalysisResult anaResult = analysis.getResults();
EMap<Indicator, AnalyzedDataSet> indicToRowMap = anaResult.getIndicToRowMap();
indicToRowMap.clear();
if (isDelimitedFile) {
ok = evaluateByDelimitedFile(sqlStatement, ok);
} else {
ok = evaluateBySql(sqlStatement, ok);
}
return ok;
}
Aggregations