Search in sources :

Example 1 with ConnectionIndicator

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;
}
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 2 with ConnectionIndicator

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

Example 3 with ConnectionIndicator

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

Example 4 with ConnectionIndicator

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

Example 5 with ConnectionIndicator

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

Aggregations

ConnectionIndicator (org.talend.dataquality.indicators.schema.ConnectionIndicator)7 CatalogIndicator (org.talend.dataquality.indicators.schema.CatalogIndicator)6 SchemaIndicator (org.talend.dataquality.indicators.schema.SchemaIndicator)5 Connection (org.talend.core.model.metadata.builder.connection.Connection)4 ArrayList (java.util.ArrayList)3 Indicator (org.talend.dataquality.indicators.Indicator)3 IRepositoryNode (org.talend.repository.model.IRepositoryNode)3 Catalog (orgomg.cwm.resource.relational.Catalog)3 OverviewIndUIElement (org.talend.dataprofiler.core.model.OverviewIndUIElement)2 RepositoryNode (org.talend.repository.model.RepositoryNode)2 Schema (orgomg.cwm.resource.relational.Schema)2 Field (java.lang.reflect.Field)1 SQLException (java.sql.SQLException)1 Test (org.junit.Test)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1 ConnectionItem (org.talend.core.model.properties.ConnectionItem)1 MetadataCatalogRepositoryObject (org.talend.core.repository.model.repositoryObject.MetadataCatalogRepositoryObject)1 Analysis (org.talend.dataquality.analysis.Analysis)1 SchemaSwitch (org.talend.dataquality.indicators.schema.util.SchemaSwitch)1 ReturnCode (org.talend.utils.sugars.ReturnCode)1