Search in sources :

Example 1 with SchemaIndicator

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);
}
Also used : SchemaIndicator(org.talend.dataquality.indicators.schema.SchemaIndicator) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) Schema(orgomg.cwm.resource.relational.Schema) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) CatalogIndicator(org.talend.dataquality.indicators.schema.CatalogIndicator) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) Catalog(orgomg.cwm.resource.relational.Catalog) CatalogIndicator(org.talend.dataquality.indicators.schema.CatalogIndicator) SchemaIndicator(org.talend.dataquality.indicators.schema.SchemaIndicator) Indicator(org.talend.dataquality.indicators.Indicator) TableIndicator(org.talend.dataquality.indicators.schema.TableIndicator) ViewIndicator(org.talend.dataquality.indicators.schema.ViewIndicator) GridLayout(org.eclipse.swt.layout.GridLayout) EList(org.eclipse.emf.common.util.EList) OverviewIndUIElement(org.talend.dataprofiler.core.model.OverviewIndUIElement) List(java.util.List) ArrayList(java.util.ArrayList) EList(org.eclipse.emf.common.util.EList) TableViewer(org.eclipse.jface.viewers.TableViewer)

Example 2 with SchemaIndicator

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;
    }
}
Also used : SchemaIndicator(org.talend.dataquality.indicators.schema.SchemaIndicator)

Example 3 with SchemaIndicator

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;
}
Also used : SchemaIndicator(org.talend.dataquality.indicators.schema.SchemaIndicator) IRepositoryNode(org.talend.repository.model.IRepositoryNode) Connection(org.talend.core.model.metadata.builder.connection.Connection) ArrayList(java.util.ArrayList) OverviewIndUIElement(org.talend.dataprofiler.core.model.OverviewIndUIElement) IRepositoryNode(org.talend.repository.model.IRepositoryNode) RepositoryNode(org.talend.repository.model.RepositoryNode) ConnectionIndicator(org.talend.dataquality.indicators.schema.ConnectionIndicator) CatalogIndicator(org.talend.dataquality.indicators.schema.CatalogIndicator) ConnectionIndicator(org.talend.dataquality.indicators.schema.ConnectionIndicator) SchemaIndicator(org.talend.dataquality.indicators.schema.SchemaIndicator) Indicator(org.talend.dataquality.indicators.Indicator)

Example 4 with SchemaIndicator

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;
}
Also used : SchemaIndicator(org.talend.dataquality.indicators.schema.SchemaIndicator) ModelElement(orgomg.cwm.objectmodel.core.ModelElement) OverviewIndUIElement(org.talend.dataprofiler.core.model.OverviewIndUIElement)

Example 5 with SchemaIndicator

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;
}
Also used : DataProvider(orgomg.cwm.foundation.softwaredeployment.DataProvider) SchemaIndicator(org.talend.dataquality.indicators.schema.SchemaIndicator) ReturnCode(org.talend.utils.sugars.ReturnCode) Schema(orgomg.cwm.resource.relational.Schema) CatalogIndicator(org.talend.dataquality.indicators.schema.CatalogIndicator) CatalogIndicator(org.talend.dataquality.indicators.schema.CatalogIndicator) SchemaIndicator(org.talend.dataquality.indicators.schema.SchemaIndicator) Indicator(org.talend.dataquality.indicators.Indicator) Catalog(orgomg.cwm.resource.relational.Catalog)

Aggregations

SchemaIndicator (org.talend.dataquality.indicators.schema.SchemaIndicator)12 Indicator (org.talend.dataquality.indicators.Indicator)6 CatalogIndicator (org.talend.dataquality.indicators.schema.CatalogIndicator)6 Schema (orgomg.cwm.resource.relational.Schema)6 ConnectionIndicator (org.talend.dataquality.indicators.schema.ConnectionIndicator)4 Catalog (orgomg.cwm.resource.relational.Catalog)4 ArrayList (java.util.ArrayList)3 Connection (org.talend.core.model.metadata.builder.connection.Connection)3 OverviewIndUIElement (org.talend.dataprofiler.core.model.OverviewIndUIElement)3 IRepositoryNode (org.talend.repository.model.IRepositoryNode)3 ReturnCode (org.talend.utils.sugars.ReturnCode)3 RepositoryNode (org.talend.repository.model.RepositoryNode)2 DataProvider (orgomg.cwm.foundation.softwaredeployment.DataProvider)2 ModelElement (orgomg.cwm.objectmodel.core.ModelElement)2 Field (java.lang.reflect.Field)1 SQLException (java.sql.SQLException)1 List (java.util.List)1 EList (org.eclipse.emf.common.util.EList)1 EObject (org.eclipse.emf.ecore.EObject)1 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)1