use of org.talend.dataquality.indicators.schema.ConnectionIndicator in project tdq-studio-se by Talend.
the class ConnectionAnalysisDetailsPage method getSchemaIndicators.
@Override
public List<OverviewIndUIElement> getSchemaIndicators() {
ConnectionIndicator conIndicator = (ConnectionIndicator) getCurrentModelElement().getResults().getIndicators().get(0);
Connection analyzedElement = (Connection) conIndicator.getAnalyzedElement();
EList<SchemaIndicator> schemaIndicators = conIndicator.getSchemaIndicators();
List<OverviewIndUIElement> cataUIEleList = new ArrayList<OverviewIndUIElement>();
RepositoryNode connNode = RepositoryNodeHelper.recursiveFind(analyzedElement);
for (Indicator indicator : schemaIndicators) {
if (connNode != null) {
for (IRepositoryNode schemaNode : connNode.getChildren()) {
String nodeUuid = ResourceHelper.getUUID(((MetadataSchemaRepositoryObject) schemaNode.getObject()).getSchema());
String anaUuid = ResourceHelper.getUUID(indicator.getAnalyzedElement());
if (nodeUuid.equals(anaUuid)) {
OverviewIndUIElement cataUIEle = new OverviewIndUIElement();
cataUIEle.setNode(schemaNode);
cataUIEle.setOverviewIndicator(indicator);
cataUIEleList.add(cataUIEle);
break;
}
}
}
}
return cataUIEleList;
}
use of org.talend.dataquality.indicators.schema.ConnectionIndicator in project tdq-studio-se by Talend.
the class ConnectionEvaluator method addToConnectionIndicator.
/*
* (non-Javadoc)
*
* @see
* org.talend.dq.indicators.AbstractSchemaEvaluator#addToConnectionIndicator(org.talend.dataquality.indicators.schema
* .CatalogIndicator, org.talend.dataquality.indicators.schema.SchemaIndicator)
*/
@Override
protected void addToConnectionIndicator(CatalogIndicator catalogIndicator, SchemaIndicator schemaIndicator) {
final ConnectionIndicator connectionIndicator = getConnectionIndicator();
if (connectionIndicator == null) {
return;
}
boolean addSuccess = connectionIndicator.addCatalogIndicator(catalogIndicator);
// only increment catalog/schema count when the catalogIndicator is a new instance and is added successfully.
if (addSuccess) {
connectionIndicator.setCatalogCount(connectionIndicator.getCatalogCount() + 1);
connectionIndicator.setSchemaCount(connectionIndicator.getSchemaCount() + catalogIndicator.getSchemaCount());
}
// set table count view count... from schemaIndicator not from catalogIndicator.
connectionIndicator.setTableCount(connectionIndicator.getTableCount() + schemaIndicator.getTableCount());
connectionIndicator.setTableRowCount(connectionIndicator.getTableRowCount() + schemaIndicator.getTableRowCount());
connectionIndicator.setViewCount(connectionIndicator.getViewCount() + schemaIndicator.getViewCount());
connectionIndicator.setViewRowCount(connectionIndicator.getViewRowCount() + schemaIndicator.getViewRowCount());
connectionIndicator.setKeyCount(connectionIndicator.getKeyCount() + schemaIndicator.getKeyCount());
connectionIndicator.setIndexCount(connectionIndicator.getIndexCount() + schemaIndicator.getIndexCount());
}
use of org.talend.dataquality.indicators.schema.ConnectionIndicator in project tdq-studio-se by Talend.
the class ConnectionEvaluator method addToConnectionIndicator.
@Override
protected void addToConnectionIndicator(Indicator indicator) {
final ConnectionIndicator connectionIndicator = getConnectionIndicator();
if (connectionIndicator == null) {
return;
}
SchemaSwitch<Boolean> schemaSwitch = new SchemaSwitch<Boolean>() {
/*
* (non-Javadoc)
*
* @see
* org.talend.dataquality.indicators.schema.util.SchemaSwitch#caseCatalogIndicator(org.talend.dataquality
* .indicators.schema.CatalogIndicator)
*/
@Override
public Boolean caseCatalogIndicator(CatalogIndicator object) {
connectionIndicator.addCatalogIndicator(object);
connectionIndicator.setCatalogCount(connectionIndicator.getCatalogCount() + 1);
// increment schema count
connectionIndicator.setSchemaCount(connectionIndicator.getSchemaCount() + object.getSchemaCount());
// MOD scorreia 2009-01-16 increment other counts
incrementCounts(connectionIndicator, object);
return true;
}
private void incrementCounts(final ConnectionIndicator connIndicator, SchemaIndicator childIndicator) {
connIndicator.setTableCount(connIndicator.getTableCount() + childIndicator.getTableCount());
connIndicator.setTableRowCount(connIndicator.getTableRowCount() + childIndicator.getTableRowCount());
// MOD klliu 2011-12-26 bug TDQ-4235
connIndicator.setViewCount(connIndicator.getViewCount() + childIndicator.getViewCount());
connIndicator.setViewRowCount(connIndicator.getViewRowCount() + childIndicator.getViewRowCount());
connIndicator.setKeyCount(connIndicator.getKeyCount() + childIndicator.getKeyCount());
connIndicator.setIndexCount(connIndicator.getIndexCount() + childIndicator.getIndexCount());
}
/*
* (non-Javadoc)
*
* @see
* org.talend.dataquality.indicators.schema.util.SchemaSwitch#caseSchemaIndicator(org.talend.dataquality
* .indicators.schema.SchemaIndicator)
*/
@Override
public Boolean caseSchemaIndicator(SchemaIndicator object) {
connectionIndicator.addSchemaIndicator(object);
connectionIndicator.setSchemaCount(connectionIndicator.getSchemaCount() + 1);
// MOD scorreia 2009-01-16 increment other counts
incrementCounts(connectionIndicator, object);
return true;
}
};
schemaSwitch.doSwitch(indicator);
}
use of org.talend.dataquality.indicators.schema.ConnectionIndicator in project tdq-studio-se by Talend.
the class ConnectionEvaluator method executeSqlQuery.
/*
* (non-Javadoc)
*
* @see org.talend.dq.indicators.Evaluator#executeSqlQuery(java.lang.String)
*
* Note that the given statement is not used.
*/
@Override
protected ReturnCode executeSqlQuery(String sqlStatement) throws SQLException {
// assert this.getAnalyzedElements().size() == 1 : "Invalid number of analyzed elements: "
// + this.getAnalyzedElements().size();
ReturnCode ok = new ReturnCode(true);
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;
}
elementIndics = this.elementToIndicators.values().iterator().next();
if (elementIndics.isEmpty()) {
// $NON-NLS-1$
String msg = Messages.getString("Evaluator.NoInidcator2", dataProvider);
log.error(msg);
ok.setReturnCode(msg, false);
return ok;
}
ConnectionIndicator connectionIndicator = getConnectionIndicator();
this.resetCounts(connectionIndicator);
List<Catalog> catalogs = ConnectionHelper.getCatalogs(dataProvider);
if (isTos(dataProvider)) {
cleanUpCatalog(catalogs);
}
if (this.getMonitor() != null) {
this.getMonitor().beginTask("Analyze catalogs", 100);
}
int temp = 0;
if (catalogs.isEmpty()) {
// no catalog, only schemata
List<Schema> schemata = ConnectionHelper.getSchema(dataProvider);
// MOD yyi 2009-11-30 10187
for (Schema tdSchema : schemata) {
if (!checkSchema(tdSchema)) {
// $NON-NLS-1$
ok.setReturnCode(Messages.getString("Evaluator.schemaNotExist", tdSchema.getName()), false);
return ok;
}
}
// for (Schema tdSchema : schemata) {
for (int i = 0; i < schemata.size(); i++) {
Schema tdSchema = schemata.get(i);
if (this.getMonitor() != null) {
this.getMonitor().setTaskName(Messages.getString("ColumnAnalysisSqlExecutor.AnalyzedElement", Messages.getString("ColumnAnalysisSqlExecutor.AnalyzedElementSchema", tdSchema.getName())));
}
evalSchemaIndic(tdSchema, ok);
if (this.getMonitor() != null) {
int current = (i + 1) * 100 / schemata.size();
if (current > temp) {
this.getMonitor().worked(current - temp);
temp = current;
}
}
}
} else {
// MOD yyi 2009-11-30 10187
for (Catalog tdCatalog : catalogs) {
if (!checkCatalog(tdCatalog.getName())) {
// $NON-NLS-1$
ok.setReturnCode(Messages.getString("Evaluator.catalogNotExist", tdCatalog.getName()), false);
return ok;
}
}
// for (Catalog tdCatalog : catalogs) {
for (int i = 0; i < catalogs.size(); i++) {
if (this.continueRun()) {
Catalog tdCatalog = catalogs.get(i);
String catName = tdCatalog.getName();
if (this.getMonitor() != null) {
this.getMonitor().setTaskName(Messages.getString("ColumnAnalysisSqlExecutor.AnalyzedElement", Messages.getString("ColumnAnalysisSqlExecutor.AnalyzedElementCatalog", catName)));
}
if (dbms().supportCatalogSelection()) {
try {
connection.setCatalog(catName);
} catch (SQLException e) {
// $NON-NLS-1$
log.warn("Exception while executing SQL query " + sqlStatement, e);
}
}
CatalogIndicator catalogIndic = SchemaFactory.eINSTANCE.createCatalogIndicator();
// MOD xqliu 2009-1-21 feature 4715
DefinitionHandler.getInstance().setDefaultIndicatorDefinition(catalogIndic);
List<Schema> schemas = CatalogHelper.getSchemas(tdCatalog);
if (schemas.isEmpty()) {
// no schema
evalCatalogIndic(catalogIndic, tdCatalog, ok);
} else {
catalogIndic.setAnalyzedElement(tdCatalog);
// --- create SchemaIndicator for each pair of catalog schema
for (Schema tdSchema : schemas) {
if (this.continueRun()) {
if (this.getMonitor() != null) {
this.getMonitor().setTaskName(Messages.getString("ColumnAnalysisSqlExecutor.AnalyzedElement", Messages.getString("ColumnAnalysisSqlExecutor.AnalyzedElementCatalog", catName) + ", " + Messages.getString("ColumnAnalysisSqlExecutor.AnalyzedElementSchema", tdSchema.getName())));
}
// --- create SchemaIndicator for each catalog
SchemaIndicator schemaIndic = SchemaFactory.eINSTANCE.createSchemaIndicator();
// MOD xqliu 2009-1-21 feature 4715
DefinitionHandler.getInstance().setDefaultIndicatorDefinition(schemaIndic);
evalSchemaIndicLow(catalogIndic, schemaIndic, tdCatalog, tdSchema, ok);
}
}
catalogIndic.setSchemaCount(schemas.size());
}
if (this.getMonitor() != null) {
int current = (i + 1) * 100 / catalogs.size();
if (current > temp) {
this.getMonitor().worked(current - temp);
temp = current;
}
}
}
}
if (this.getMonitor() != null) {
this.getMonitor().done();
}
}
if (log.isDebugEnabled()) {
printCounts(connectionIndicator);
}
return ok;
}
use of org.talend.dataquality.indicators.schema.ConnectionIndicator in project tdq-studio-se by Talend.
the class ConnectionAnalysisDetailsPage method getCatalogIndicators.
@Override
public List<OverviewIndUIElement> getCatalogIndicators() {
ConnectionIndicator conIndicator = (ConnectionIndicator) getCurrentModelElement().getResults().getIndicators().get(0);
Connection analyzedElement = (Connection) conIndicator.getAnalyzedElement();
EList<CatalogIndicator> catalogIndicators = conIndicator.getCatalogIndicators();
List<OverviewIndUIElement> cataUIEleList = new ArrayList<OverviewIndUIElement>();
RepositoryNode connNode = RepositoryNodeHelper.recursiveFind(analyzedElement);
for (Indicator indicator : catalogIndicators) {
if (connNode != null) {
for (IRepositoryNode catalogNode : connNode.getChildren()) {
Catalog catalog = ((MetadataCatalogRepositoryObject) catalogNode.getObject()).getCatalog();
String connUuid = ResourceHelper.getUUID(catalog);
String anaUuid = ResourceHelper.getUUID(indicator.getAnalyzedElement());
if (connUuid.equals(anaUuid)) {
OverviewIndUIElement cataUIEle = new OverviewIndUIElement();
cataUIEle.setNode(catalogNode);
cataUIEle.setOverviewIndicator(indicator);
cataUIEleList.add(cataUIEle);
break;
}
}
}
}
return cataUIEleList;
}
Aggregations