use of org.talend.dataquality.indicators.schema.SchemaIndicator in project tdq-studio-se by Talend.
the class OverviewResultPage method createResultSection.
@Override
protected void createResultSection(Composite parent) {
statisticalSection = this.createSection(form, parent, DefaultMessagesImpl.getString("ConnectionMasterDetailsPage.statisticalinformations"), // $NON-NLS-1$
null);
Composite sectionClient = toolkit.createComposite(statisticalSection);
sectionClient.setLayout(new GridLayout());
catalogTableViewer = new TableViewer(sectionClient, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION);
Table catalogTable = catalogTableViewer.getTable();
TableUtils.addActionTooltip(catalogTable);
catalogTable.setHeaderVisible(true);
catalogTable.setBackgroundMode(SWT.INHERIT_FORCE);
catalogTable.setLinesVisible(true);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(catalogTable);
List<Catalog> catalogs = getCatalogs();
boolean containSubSchema = false;
for (Catalog catalog : catalogs) {
List<Schema> schemas = CatalogHelper.getSchemas(catalog);
if (schemas.size() > 0) {
containSubSchema = true;
break;
}
}
if (catalogs.size() > 0 && containSubSchema) {
createCatalogSchemaColumns(catalogTable);
provider = new CatalogSchemaViewerProvier();
addColumnSorters(catalogTableViewer, catalogTable.getColumns(), catalogWithSchemaSorters);
createSchemaTableViewer(sectionClient);
schemaTableViewer.addSelectionChangedListener(new DisplayTableAndViewListener());
catalogTableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
StructuredSelection selection = (StructuredSelection) event.getSelection();
OverviewIndUIElement firstElement = (OverviewIndUIElement) selection.getFirstElement();
List<OverviewIndUIElement> cataUIEleList = new ArrayList<OverviewIndUIElement>();
if (firstElement != null) {
Indicator overviewIndicator = firstElement.getOverviewIndicator();
// selection.getFirstElement();
CatalogIndicator catalogIndicator = (CatalogIndicator) overviewIndicator;
// MOD qiongli bug 13093,2010-7-2,
// selection.getFirstElement();
currentCatalogIndicator = (SchemaIndicator) overviewIndicator;
// MOD xqliu 2009-11-30 bug 9114
if (catalogIndicator != null) {
EList<SchemaIndicator> schemaIndicators = catalogIndicator.getSchemaIndicators();
for (SchemaIndicator schemaIndicator : schemaIndicators) {
RepositoryNode schemaNode = RepositoryNodeHelper.recursiveFind(schemaIndicator.getAnalyzedElement());
OverviewIndUIElement cataUIEle = new OverviewIndUIElement();
cataUIEle.setNode(schemaNode);
cataUIEle.setOverviewIndicator(schemaIndicator);
cataUIEleList.add(cataUIEle);
}
schemaTableViewer.setInput(cataUIEleList);
schemaTableViewer.getTable().setVisible(true);
addColumnSorters(schemaTableViewer, schemaTableViewer.getTable().getColumns(), schemaSorters);
}
}
// ~
}
});
createContextMenuFor(schemaTableViewer);
} else {
if (catalogs.size() > 0) {
createCatalogTableColumns(catalogTable);
provider = new CatalogViewerProvier();
} else {
createSchemaTableColumns(catalogTable);
provider = new SchemaViewerProvier();
}
addColumnSorters(catalogTableViewer, catalogTable.getColumns(), schemaSorters);
catalogTableViewer.addSelectionChangedListener(new DisplayTableAndViewListener());
}
catalogTableViewer.setLabelProvider(provider);
catalogTableViewer.setContentProvider(provider);
doSetInput();
tableAndViewComposite = new Composite(sectionClient, SWT.NONE);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(tableAndViewComposite);
GridLayout layout = new GridLayout(2, false);
layout.marginWidth = 0;
layout.horizontalSpacing = 50;
tableAndViewComposite.setLayout(layout);
tableAndViewComposite.setVisible(false);
sectionClient.layout();
statisticalSection.setClient(sectionClient);
createContextMenuFor(catalogTableViewer);
}
use of org.talend.dataquality.indicators.schema.SchemaIndicator in project tdq-studio-se by Talend.
the class SchemaSorter method compare.
public int compare(Viewer viewer, Object o1, Object o2) {
SchemaIndicator indicator1 = (SchemaIndicator) ((OverviewIndUIElement) o1).getOverviewIndicator();
SchemaIndicator indicator2 = (SchemaIndicator) ((OverviewIndUIElement) o2).getOverviewIndicator();
String value1;
String value2;
long number1;
long number2;
switch(sortType) {
case SCHEMA:
value1 = indicator1.getAnalyzedElement().getName();
value2 = indicator2.getAnalyzedElement().getName();
return value1.compareTo(value2);
case -SCHEMA:
value1 = indicator1.getAnalyzedElement().getName();
value2 = indicator2.getAnalyzedElement().getName();
return value2.compareTo(value1);
case ROWS:
number1 = indicator1.getTableRowCount();
number2 = indicator2.getTableRowCount();
return new Long(number1).compareTo(new Long(number2));
case -ROWS:
number1 = indicator1.getTableRowCount();
number2 = indicator2.getTableRowCount();
return new Long(number2).compareTo(new Long(number1));
case TABLES:
number1 = indicator1.getTableCount();
number2 = indicator2.getTableCount();
return new Long(number1).compareTo(new Long(number2));
case -TABLES:
number1 = indicator1.getTableCount();
number2 = indicator2.getTableCount();
return new Long(number2).compareTo(new Long(number1));
case ROWS_TABLES:
number1 = indicator1.getTableCount() == 0 ? 0 : indicator1.getTableRowCount() / indicator1.getTableCount();
number2 = indicator2.getTableCount() == 0 ? 0 : indicator2.getTableRowCount() / indicator2.getTableCount();
return new Long(number1).compareTo(new Long(number2));
case -ROWS_TABLES:
number1 = indicator1.getTableCount() == 0 ? 0 : indicator1.getTableRowCount() / indicator1.getTableCount();
number2 = indicator2.getTableCount() == 0 ? 0 : indicator2.getTableRowCount() / indicator2.getTableCount();
return new Long(number2).compareTo(new Long(number1));
case VIEWS:
number1 = indicator1.getViewCount();
number2 = indicator2.getViewCount();
return new Long(number1).compareTo(new Long(number2));
case -VIEWS:
number1 = indicator1.getViewCount();
number2 = indicator2.getViewCount();
return new Long(number2).compareTo(new Long(number1));
case ROWS_VIEWS:
number1 = indicator1.getViewCount() == 0 ? 0 : indicator1.getTableRowCount() / indicator1.getViewCount();
number2 = indicator2.getViewCount() == 0 ? 0 : indicator2.getTableRowCount() / indicator2.getViewCount();
return new Long(number1).compareTo(new Long(number2));
case -ROWS_VIEWS:
number1 = indicator1.getViewCount() == 0 ? 0 : indicator1.getTableRowCount() / indicator1.getViewCount();
number2 = indicator2.getViewCount() == 0 ? 0 : indicator2.getTableRowCount() / indicator2.getViewCount();
return new Long(number2).compareTo(new Long(number1));
case KEYS:
number1 = indicator1.getKeyCount();
number2 = indicator2.getKeyCount();
return new Long(number1).compareTo(new Long(number2));
case -KEYS:
number1 = indicator1.getKeyCount();
number2 = indicator2.getKeyCount();
return new Long(number2).compareTo(new Long(number1));
case INDEXES:
number1 = indicator1.getIndexCount();
number2 = indicator2.getIndexCount();
return new Long(number1).compareTo(new Long(number2));
case -INDEXES:
number1 = indicator1.getIndexCount();
number2 = indicator2.getIndexCount();
return new Long(number2).compareTo(new Long(number1));
default:
return 0;
}
}
use of org.talend.dataquality.indicators.schema.SchemaIndicator 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.SchemaIndicator in project tdq-studio-se by Talend.
the class AbstractStatisticalViewerProvider method getColumnText.
public String getColumnText(Object element, int columnIndex) {
String text = PluginConstant.EMPTY_STRING;
if (element instanceof OverviewIndUIElement) {
SchemaIndicator indicator = (SchemaIndicator) ((OverviewIndUIElement) element).getOverviewIndicator();
switch(columnIndex) {
case 0:
// for TDQ-8833 vertica database has a catalog and the name of it is PluginConstant.EMPTY_STRING
ModelElement analyzedElement = indicator.getAnalyzedElement();
if (analyzedElement.getClass() == orgomg.cwm.resource.relational.impl.CatalogImpl.class) {
if (PluginConstant.EMPTY_STRING.equals(analyzedElement.getName())) {
return text = org.talend.dataquality.PluginConstant.DEFAULT_STRING;
}
}
// ~
text = analyzedElement.getName();
return text;
case 1:
text = PluginConstant.EMPTY_STRING + indicator.getTableRowCount();
return text;
default:
break;
}
return getOtherColumnText(columnIndex, indicator);
}
return text;
}
use of org.talend.dataquality.indicators.schema.SchemaIndicator 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;
}
Aggregations