Search in sources :

Example 1 with DataProvider

use of orgomg.cwm.foundation.softwaredeployment.DataProvider 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)

Example 2 with DataProvider

use of orgomg.cwm.foundation.softwaredeployment.DataProvider in project tdq-studio-se by Talend.

the class SqlexplorerService method removeAliasInSQLExplorer.

/*
     * (non-Javadoc)
     * 
     * @see
     * org.talend.dataprofiler.service.ISqlexplorerService#removeAliasInSQLExplorer(orgomg.cwm.foundation.softwaredeployment
     * .DataProvider[])
     */
@Override
public void removeAliasInSQLExplorer(DataProvider... dataproviders) {
    SQLExplorerPlugin sqlPlugin = SQLExplorerPlugin.getDefault();
    AliasManager aliasManager = sqlPlugin.getAliasManager();
    DatabaseStructureView dsView = sqlPlugin.findDatabaseStructureView();
    // alias from propertyFile map at the same time.
    try {
        Collection<Alias> aliases = aliasManager.getAliases();
        if (aliases.isEmpty()) {
            return;
        }
        for (DataProvider dataProvider : dataproviders) {
            String aliasName = dataProvider.getName();
            if (null == aliasName) {
                continue;
            }
            Alias alias = aliasManager.getAlias(aliasName);
            if (alias != null) {
                sqlPlugin.getPropertyFile().remove(alias);
                aliasManager.removeAlias(aliasName);
            }
            // if the ctabItem is open,close it.
            if (dsView != null) {
                dsView.closeCurrentCabItem(aliasName);
            }
        }
    } catch (Exception e) {
        log.error(e, e);
    }
    aliasManager.modelChanged();
}
Also used : DataProvider(orgomg.cwm.foundation.softwaredeployment.DataProvider) AliasManager(net.sourceforge.sqlexplorer.dbproduct.AliasManager) Alias(net.sourceforge.sqlexplorer.dbproduct.Alias) DatabaseStructureView(net.sourceforge.sqlexplorer.plugin.views.DatabaseStructureView) SQLExplorerPlugin(net.sourceforge.sqlexplorer.plugin.SQLExplorerPlugin) PartInitException(org.eclipse.ui.PartInitException) MalformedURLException(java.net.MalformedURLException)

Example 3 with DataProvider

use of orgomg.cwm.foundation.softwaredeployment.DataProvider in project tdq-studio-se by Talend.

the class CheckAndUpdateAnalysisDependencyTask method checkAndRemoveWrongDependencies.

/**
 * check each analysis if it has only one client dependency, if more than one, remove the useless one.
 *
 * @param list
 * @throws CoreException
 */
private void checkAndRemoveWrongDependencies(List<Analysis> analyses) throws CoreException {
    for (Analysis analysis : analyses) {
        if (analysis != null) {
            boolean isAnalysisModified = false;
            if (analysis.getContext().getAnalysedElements() == null || analysis.getContext().getAnalysedElements().size() < 1) {
                continue;
            }
            TdColumn tdColumn = SwitchHelpers.COLUMN_SWITCH.doSwitch(analysis.getContext().getAnalysedElements().get(0));
            if (tdColumn == null) {
                continue;
            }
            // find the correct db connection from analyzed element
            DataManager correctDB = ConnectionHelper.getConnection(tdColumn);
            // check if the connection is correct or not
            DataManager connection = analysis.getContext().getConnection();
            if (connection == null || !correctDB.getName().equals(connection.getName())) {
                analysis.getContext().setConnection(correctDB);
                isAnalysisModified = true;
            }
            List<DataProvider> clientDependencyDB = null;
            for (Dependency dependency : analysis.getClientDependency()) {
                ModelElement supplier = dependency.getSupplier().get(0);
                if (supplier instanceof DataProvider) {
                    if (supplier != null && correctDB.getName().equals(supplier.getName())) {
                        continue;
                    } else {
                        if (clientDependencyDB == null) {
                            clientDependencyDB = new ArrayList<DataProvider>();
                        }
                        clientDependencyDB.add((DataProvider) supplier);
                    }
                }
            }
            if (clientDependencyDB != null) {
                for (DataProvider uselessDB : clientDependencyDB) {
                    // if the db in client dependency do not equal to the correct db, remove it from both the
                    // analysis and db connection
                    removeDependenciesBetweenAnaCon(uselessDB, analysis);
                    isAnalysisModified = true;
                }
            }
            if (isAnalysisModified) {
                EMFSharedResources.getInstance().saveResource(analysis.eResource());
            }
        }
    }
}
Also used : DataProvider(orgomg.cwm.foundation.softwaredeployment.DataProvider) ModelElement(orgomg.cwm.objectmodel.core.ModelElement) TdColumn(org.talend.cwm.relational.TdColumn) Analysis(org.talend.dataquality.analysis.Analysis) DataManager(orgomg.cwm.foundation.softwaredeployment.DataManager) Dependency(orgomg.cwm.objectmodel.core.Dependency)

Example 4 with DataProvider

use of orgomg.cwm.foundation.softwaredeployment.DataProvider in project tdq-studio-se by Talend.

the class SchemaEvaluator 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) {
        SchemaIndicator schemaIndicator = DataqualitySwitchHelper.SCHEMA_SWITCH.doSwitch(indicator);
        if (schemaIndicator == null) {
            continue;
        }
        Schema schema = (Schema) schemaIndicator.getAnalyzedElement();
        String catName = schema.getName();
        // MOD yyi 2009-11-30 10187
        if (!checkSchema(schema)) {
            // $NON-NLS-1$
            ok.setReturnCode(Messages.getString("Evaluator.schemaNotExist", catName), false);
            return ok;
        }
        // ~
        // ADD xqliu 2010-01-06 bug 10919
        EObject container = schema.eContainer();
        if (container != null) {
            Catalog catalog = SwitchHelpers.CATALOG_SWITCH.doSwitch(container);
            if (catalog != null) {
                catName = catalog.getName();
                // MOD gdbu 2011-4-21 bug : 20578
                if (!ConnectionUtils.isOdbcProgress(connection) && !ConnectionUtils.isOdbcOracle(connection) && StringUtils.isNotEmpty(catName) && dbms().supportCatalogSelection()) {
                    connection.setCatalog(catName);
                }
            // ~20578
            }
        }
        // ~
        evalSchemaIndicLow(null, schemaIndicator, null, schema, 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) EObject(org.eclipse.emf.ecore.EObject) SchemaIndicator(org.talend.dataquality.indicators.schema.SchemaIndicator) Indicator(org.talend.dataquality.indicators.Indicator) Catalog(orgomg.cwm.resource.relational.Catalog)

Aggregations

DataProvider (orgomg.cwm.foundation.softwaredeployment.DataProvider)4 Indicator (org.talend.dataquality.indicators.Indicator)2 SchemaIndicator (org.talend.dataquality.indicators.schema.SchemaIndicator)2 ReturnCode (org.talend.utils.sugars.ReturnCode)2 Catalog (orgomg.cwm.resource.relational.Catalog)2 Schema (orgomg.cwm.resource.relational.Schema)2 MalformedURLException (java.net.MalformedURLException)1 Alias (net.sourceforge.sqlexplorer.dbproduct.Alias)1 AliasManager (net.sourceforge.sqlexplorer.dbproduct.AliasManager)1 SQLExplorerPlugin (net.sourceforge.sqlexplorer.plugin.SQLExplorerPlugin)1 DatabaseStructureView (net.sourceforge.sqlexplorer.plugin.views.DatabaseStructureView)1 EObject (org.eclipse.emf.ecore.EObject)1 PartInitException (org.eclipse.ui.PartInitException)1 TdColumn (org.talend.cwm.relational.TdColumn)1 Analysis (org.talend.dataquality.analysis.Analysis)1 CatalogIndicator (org.talend.dataquality.indicators.schema.CatalogIndicator)1 DataManager (orgomg.cwm.foundation.softwaredeployment.DataManager)1 Dependency (orgomg.cwm.objectmodel.core.Dependency)1 ModelElement (orgomg.cwm.objectmodel.core.ModelElement)1